include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / media / video / em28xx / em28xx-dvb.c
index f3f0e8f..bcd3c37 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "em28xx.h"
@@ -33,6 +34,7 @@
 #include "s5h1409.h"
 #include "mt352.h"
 #include "mt352_priv.h" /* FIXME */
+#include "tda1002x.h"
 
 MODULE_DESCRIPTION("driver for em28xx based DVB cards");
 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
@@ -245,7 +247,7 @@ static struct s5h1409_config em28xx_s5h1409_with_xc3028 = {
        .mpeg_timing   = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
 };
 
-static struct zl10353_config em28xx_terratec_xs_zl10353_xc3028 = {
+static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = {
        .demod_address = (0x1e >> 1),
        .no_tuner = 1,
        .disable_i2c_gate_ctrl = 1,
@@ -295,6 +297,11 @@ static struct mt352_config terratec_xs_mt352_cfg = {
        .demod_init = mt352_terratec_xs_init,
 };
 
+static struct tda10023_config em28xx_tda10023_config = {
+       .demod_address = 0x0c,
+       .invert = 1,
+};
+
 /* ------------------------------------------------------------------ */
 
 static int attach_xc3028(u8 addr, struct em28xx *dev)
@@ -307,22 +314,20 @@ static int attach_xc3028(u8 addr, struct em28xx *dev)
        cfg.i2c_addr  = addr;
 
        if (!dev->dvb->frontend) {
-               printk(KERN_ERR "%s/2: dvb frontend not attached. "
-                               "Can't attach xc3028\n",
-                      dev->name);
+               em28xx_errdev("/2: dvb frontend not attached. "
+                               "Can't attach xc3028\n");
                return -EINVAL;
        }
 
        fe = dvb_attach(xc2028_attach, dev->dvb->frontend, &cfg);
        if (!fe) {
-               printk(KERN_ERR "%s/2: xc3028 attach failed\n",
-                      dev->name);
+               em28xx_errdev("/2: xc3028 attach failed\n");
                dvb_frontend_detach(dev->dvb->frontend);
                dev->dvb->frontend = NULL;
                return -EINVAL;
        }
 
-       printk(KERN_INFO "%s/2: xc3028 attached\n", dev->name);
+       em28xx_info("%s/2: xc3028 attached\n", dev->name);
 
        return 0;
 }
@@ -457,7 +462,7 @@ static int dvb_init(struct em28xx *dev)
        dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL);
 
        if (dvb == NULL) {
-               printk(KERN_INFO "em28xx_dvb: memory allocation failed\n");
+               em28xx_info("em28xx_dvb: memory allocation failed\n");
                return -ENOMEM;
        }
        dev->dvb = dvb;
@@ -477,9 +482,7 @@ static int dvb_init(struct em28xx *dev)
                        goto out_free;
                }
                break;
-       case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
        case EM2880_BOARD_KWORLD_DVB_310U:
-       case EM2880_BOARD_EMPIRE_DUAL_TV:
                dvb->frontend = dvb_attach(zl10353_attach,
                                           &em28xx_zl10353_with_xc3028,
                                           &dev->i2c_adap);
@@ -488,9 +491,23 @@ static int dvb_init(struct em28xx *dev)
                        goto out_free;
                }
                break;
+       case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
+       case EM2882_BOARD_TERRATEC_HYBRID_XS:
+       case EM2880_BOARD_EMPIRE_DUAL_TV:
+               dvb->frontend = dvb_attach(zl10353_attach,
+                                          &em28xx_zl10353_xc3028_no_i2c_gate,
+                                          &dev->i2c_adap);
+               if (attach_xc3028(0x61, dev) < 0) {
+                       result = -EINVAL;
+                       goto out_free;
+               }
+               break;
        case EM2880_BOARD_TERRATEC_HYBRID_XS:
+       case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
+       case EM2881_BOARD_PINNACLE_HYBRID_PRO:
+       case EM2882_BOARD_DIKOM_DK300:
                dvb->frontend = dvb_attach(zl10353_attach,
-                                          &em28xx_terratec_xs_zl10353_xc3028,
+                                          &em28xx_zl10353_xc3028_no_i2c_gate,
                                           &dev->i2c_adap);
                if (dvb->frontend == NULL) {
                        /* This board could have either a zl10353 or a mt352.
@@ -540,16 +557,26 @@ static int dvb_init(struct em28xx *dev)
                }
                break;
 #endif
+       case EM2870_BOARD_REDDO_DVB_C_USB_BOX:
+               /* Philips CU1216L NIM (Philips TDA10023 + Infineon TUA6034) */
+               dvb->frontend = dvb_attach(tda10023_attach,
+                       &em28xx_tda10023_config,
+                       &dev->i2c_adap, 0x48);
+               if (dvb->frontend) {
+                       if (!dvb_attach(simple_tuner_attach, dvb->frontend,
+                               &dev->i2c_adap, 0x60, TUNER_PHILIPS_CU1216L)) {
+                               result = -EINVAL;
+                               goto out_free;
+                       }
+               }
+               break;
        default:
-               printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card"
-                               " isn't supported yet\n",
-                      dev->name);
+               em28xx_errdev("/2: The frontend of your DVB/ATSC card"
+                               " isn't supported yet\n");
                break;
        }
        if (NULL == dvb->frontend) {
-               printk(KERN_ERR
-                      "%s/2: frontend initialization failed\n",
-                      dev->name);
+               em28xx_errdev("/2: frontend initialization failed\n");
                result = -EINVAL;
                goto out_free;
        }
@@ -563,7 +590,7 @@ static int dvb_init(struct em28xx *dev)
                goto out_free;
 
        em28xx_set_mode(dev, EM28XX_SUSPEND);
-       printk(KERN_INFO "Successfully loaded em28xx-dvb\n");
+       em28xx_info("Successfully loaded em28xx-dvb\n");
        return 0;
 
 out_free:
@@ -582,6 +609,7 @@ static int dvb_fini(struct em28xx *dev)
 
        if (dev->dvb) {
                unregister_dvb(dev->dvb);
+               kfree(dev->dvb);
                dev->dvb = NULL;
        }