]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/cx88/cx88-dvb.c
Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds
[linux-2.6-omap-h63xx.git] / drivers / media / video / cx88 / cx88-dvb.c
index 099de66c72c492b81393397637733695cad100ba..cf6c30d4e545e5dcc6d7c02013738b51544a0b9a 100644 (file)
@@ -120,11 +120,10 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
 
        fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
        if (!fe_id) {
-               printk(KERN_ERR "%s() No frontend found\n", __FUNCTION__);
+               printk(KERN_ERR "%s() No frontend found\n", __func__);
                return -EINVAL;
        }
 
-
        drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
        if (drv) {
                if (acquire){
@@ -502,7 +501,7 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
                .ctrl      = &ctl,
        };
 
-/* Get the first frontend */
+       /* Get the first frontend */
        fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
        if (!fe0)
                return -EINVAL;
@@ -576,14 +575,14 @@ static struct cx24116_config tevii_s460_config = {
 
 static struct stv0299_config tevii_tuner_sharp_config = {
        .demod_address = 0x68,
-       .inittab = sharp_z0194a__inittab,
+       .inittab = sharp_z0194a_inittab,
        .mclk = 88000000UL,
        .invert = 1,
        .skip_reinit = 0,
        .lock_output = 1,
        .volt13_op0_op1 = STV0299_VOLT13_OP1,
        .min_delay_ms = 100,
-       .set_symbol_rate = sharp_z0194a__set_symbol_rate,
+       .set_symbol_rate = sharp_z0194a_set_symbol_rate,
        .set_ts_params = cx24116_set_ts_param,
 };
 
@@ -595,21 +594,19 @@ static struct stv0288_config tevii_tuner_earda_config = {
 
 static int dvb_register(struct cx8802_dev *dev)
 {
-       //struct cx88_core *core = dev->core;
-
-       ///* init struct videobuf_dvb */
-       //fe->dvb.name = core->name;
-       //dev->ts_gen_cntrl = 0x0c;
-
        struct cx88_core *core = dev->core;
        struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
+       int mfe_shared = 0; /* bus not shared by default */
 
        /* Get the first frontend */
        fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
        if (!fe0)
                return -EINVAL;
 
-       /* init frontend */
+       /* multi-frontend gate control is undefined or defaults to fe0 */
+       dev->frontends.gate = 0;
+
+       /* init frontend(s) */
        switch (core->boardnr) {
        case CX88_BOARD_HAUPPAUGE_DVB_T1:
                fe0->dvb.frontend = dvb_attach(cx22702_attach,
@@ -658,14 +655,16 @@ static int dvb_register(struct cx8802_dev *dev)
                if (fe0->dvb.frontend) {
                        if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
                        &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) {
-                               dprintk( 1, "%s(): HVR3000 - DVB-S LNB Init: failed\n", __FUNCTION__);
+                               dprintk( 1, "%s(): HVR3000 - DVB-S LNB Init: failed\n", __func__);
                        }
                } else {
-                       dprintk( 1, "%s(): HVR3000 - DVB-S Init: failed\n", __FUNCTION__);
+                       dprintk( 1, "%s(): HVR3000 - DVB-S Init: failed\n", __func__);
                }
                /* DVB-T init */
                fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
                if (fe1) {
+                       dev->frontends.gate = 2;
+                       mfe_shared = 1;
                        fe1->dvb.frontend = dvb_attach(cx22702_attach,
                                &hauppauge_hvr_config,
                                &dev->core->i2c_adap);
@@ -674,13 +673,13 @@ static int dvb_register(struct cx8802_dev *dev)
                                if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend,
                                                &dev->core->i2c_adap, 0x61,
                                                TUNER_PHILIPS_FMD1216ME_MK3)) {
-                                       dprintk( 1, "%s(): HVR3000 - DVB-T misc Init: failed\n", __FUNCTION__);
+                                       dprintk( 1, "%s(): HVR3000 - DVB-T misc Init: failed\n", __func__);
                                }
                        } else {
-                               dprintk( 1, "%s(): HVR3000 - DVB-T Init: failed\n", __FUNCTION__);
+                               dprintk( 1, "%s(): HVR3000 - DVB-T Init: failed\n", __func__);
                        }
                } else {
-                       dprintk( 1, "%s(): HVR3000 - DVB-T Init: can't find frontend 2.\n", __FUNCTION__);
+                       dprintk( 1, "%s(): HVR3000 - DVB-T Init: can't find frontend 2.\n", __func__);
                }
                break;
        case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
@@ -790,7 +789,7 @@ static int dvb_register(struct cx8802_dev *dev)
                if (fe0->dvb.frontend)
                        fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
                if (attach_xc3028(0x61, dev) < 0)
-                       return -EINVAL;
+                       goto frontend_detach;
                break;
        case CX88_BOARD_PCHDTV_HD3000:
                fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
@@ -1001,14 +1000,16 @@ static int dvb_register(struct cx8802_dev *dev)
                if (fe0->dvb.frontend) {
                        if(!dvb_attach(isl6421_attach, fe0->dvb.frontend,
                                &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) {
-                               dprintk( 1, "%s(): HVR4000 - DVB-S LNB Init: failed\n", __FUNCTION__);
+                               dprintk( 1, "%s(): HVR4000 - DVB-S LNB Init: failed\n", __func__);
                        }
                } else {
-                       dprintk( 1, "%s(): HVR4000 - DVB-S Init: failed\n", __FUNCTION__);
+                       dprintk( 1, "%s(): HVR4000 - DVB-S Init: failed\n", __func__);
                }
                /* DVB-T Init */
                fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
                if (fe1) {
+                       dev->frontends.gate = 2;
+                       mfe_shared = 1;
                        fe1->dvb.frontend = dvb_attach(cx22702_attach,
                                &hauppauge_hvr_config,
                                &dev->core->i2c_adap);
@@ -1017,13 +1018,13 @@ static int dvb_register(struct cx8802_dev *dev)
                                if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend,
                                        &dev->core->i2c_adap, 0x61,
                                        TUNER_PHILIPS_FMD1216ME_MK3)) {
-                                       dprintk( 1, "%s(): HVR4000 - DVB-T misc Init: failed\n", __FUNCTION__);
+                                       dprintk( 1, "%s(): HVR4000 - DVB-T misc Init: failed\n", __func__);
                                }
                        } else {
-                               dprintk( 1, "%s(): HVR4000 - DVB-T Init: failed\n", __FUNCTION__);
+                               dprintk( 1, "%s(): HVR4000 - DVB-T Init: failed\n", __func__);
                        }
                } else {
-                       dprintk( 1, "%s(): HVR4000 - DVB-T Init: can't find frontend 2.\n", __FUNCTION__);
+                       dprintk( 1, "%s(): HVR4000 - DVB-T Init: can't find frontend 2.\n", __func__);
                }
                break;
        case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
@@ -1057,7 +1058,6 @@ static int dvb_register(struct cx8802_dev *dev)
                                        goto frontend_detach;
                                core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
                                fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
-
                        }
                }
                break;
@@ -1106,13 +1106,10 @@ static int dvb_register(struct cx8802_dev *dev)
 
        /* register everything */
        return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
-               &dev->pci->dev, adapter_nr);
+               &dev->pci->dev, adapter_nr, mfe_shared);
 
 frontend_detach:
-       if (fe0->dvb.frontend) {
-               dvb_frontend_detach(fe0->dvb.frontend);
-               fe0->dvb.frontend = NULL;
-       }
+       videobuf_dvb_dealloc_frontends(&dev->frontends);
        return -EINVAL;
 }
 
@@ -1136,35 +1133,7 @@ static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
                udelay(1000);
                break;
 
-       case CX88_BOARD_HAUPPAUGE_HVR3000: /* ? */
-               if(core->dvbdev->frontends.active_fe_id == 1) {
-                       /* DVB-S/S2 Enabled */
-
-                       /* Toggle reset on cx22702 leaving i2c active */
-                       cx_write(MO_GP0_IO, core->board.input[0].gpio0);
-                       udelay(1000);
-                       cx_clear(MO_GP0_IO, 0x00000080);
-                       udelay(50);
-                       cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset */
-                       cx_set(MO_GP0_IO, 0x00000004); /* tri-state the cx22702 pins */
-                       udelay(1000);
-
-                       cx_write(MO_SRST_IO, 1); /* Take the cx24116/cx24123 out of reset */
-                       core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
-               } else
-               if (core->dvbdev->frontends.active_fe_id == 2) {
-                       /* DVB-T Enabled */
-
-                       /* Put the cx24116/cx24123 into reset */
-                       cx_write(MO_SRST_IO, 0);
-
-                       /* cx22702 out of reset and enable it */
-                       cx_set(MO_GP0_IO,   0x00000080);
-                       cx_clear(MO_GP0_IO, 0x00000004);
-                       core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
-                       udelay(1000);
-               }
-               break;
+       case CX88_BOARD_HAUPPAUGE_HVR3000:
        case CX88_BOARD_HAUPPAUGE_HVR4000:
                if(core->dvbdev->frontends.active_fe_id == 1) {
                        /* DVB-S/S2 Enabled */
@@ -1225,7 +1194,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
 {
        struct cx88_core *core = drv->core;
        struct cx8802_dev *dev = drv->core->dvbdev;
-       int err,i;
+       int err, i;
        struct videobuf_dvb_frontend *fe;
 
        dprintk( 1, "%s\n", __func__);
@@ -1251,7 +1220,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
        for (i = 1; i <= core->board.num_frontends; i++) {
                fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
                if (!fe) {
-                       printk(KERN_ERR "%s() failed to get frontend(%d)\n", __FUNCTION__, i);
+                       printk(KERN_ERR "%s() failed to get frontend(%d)\n", __func__, i);
                        continue;
                }
                videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
@@ -1267,15 +1236,17 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
        if (err != 0)
                printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
                       core->name, err);
-
- fail_core:
+fail_core:
        return err;
 }
 
 static int cx8802_dvb_remove(struct cx8802_driver *drv)
 {
+       struct cx88_core *core = drv->core;
        struct cx8802_dev *dev = drv->core->dvbdev;
 
+       dprintk( 1, "%s\n", __func__);
+
        videobuf_dvb_unregister_bus(&dev->frontends);
 
        vp3054_i2c_remove(dev);