diff options
Diffstat (limited to 'drivers/media/video/cx88/cx88-dvb.c')
-rw-r--r-- | drivers/media/video/cx88/cx88-dvb.c | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 613dfea4ff3e..aef5297534af 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c | |||
@@ -614,34 +614,41 @@ static struct stv0288_config tevii_tuner_earda_config = { | |||
614 | .set_ts_params = cx24116_set_ts_param, | 614 | .set_ts_params = cx24116_set_ts_param, |
615 | }; | 615 | }; |
616 | 616 | ||
617 | static int dvb_register(struct cx8802_dev *dev) | 617 | static int cx8802_alloc_frontends(struct cx8802_dev *dev) |
618 | { | 618 | { |
619 | struct cx88_core *core = dev->core; | 619 | struct cx88_core *core = dev->core; |
620 | struct videobuf_dvb_frontend *fe0, *fe1 = NULL; | 620 | struct videobuf_dvb_frontend *fe = NULL; |
621 | int mfe_shared = 0; /* bus not shared by default */ | ||
622 | int i; | 621 | int i; |
623 | 622 | ||
624 | if (0 != core->i2c_rc) { | ||
625 | printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name); | ||
626 | goto frontend_detach; | ||
627 | } | ||
628 | |||
629 | if (!core->board.num_frontends) | ||
630 | return -EINVAL; | ||
631 | |||
632 | mutex_init(&dev->frontends.lock); | 623 | mutex_init(&dev->frontends.lock); |
633 | INIT_LIST_HEAD(&dev->frontends.felist); | 624 | INIT_LIST_HEAD(&dev->frontends.felist); |
634 | 625 | ||
626 | if (!core->board.num_frontends) | ||
627 | return -ENODEV; | ||
628 | |||
635 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, | 629 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, |
636 | core->board.num_frontends); | 630 | core->board.num_frontends); |
637 | for (i = 1; i <= core->board.num_frontends; i++) { | 631 | for (i = 1; i <= core->board.num_frontends; i++) { |
638 | fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, i); | 632 | fe = videobuf_dvb_alloc_frontend(&dev->frontends, i); |
639 | if (!fe0) { | 633 | if (!fe) { |
640 | printk(KERN_ERR "%s() failed to alloc\n", __func__); | 634 | printk(KERN_ERR "%s() failed to alloc\n", __func__); |
641 | videobuf_dvb_dealloc_frontends(&dev->frontends); | 635 | videobuf_dvb_dealloc_frontends(&dev->frontends); |
642 | goto frontend_detach; | 636 | return -ENOMEM; |
643 | } | 637 | } |
644 | } | 638 | } |
639 | return 0; | ||
640 | } | ||
641 | |||
642 | static int dvb_register(struct cx8802_dev *dev) | ||
643 | { | ||
644 | struct cx88_core *core = dev->core; | ||
645 | struct videobuf_dvb_frontend *fe0, *fe1 = NULL; | ||
646 | int mfe_shared = 0; /* bus not shared by default */ | ||
647 | |||
648 | if (0 != core->i2c_rc) { | ||
649 | printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name); | ||
650 | goto frontend_detach; | ||
651 | } | ||
645 | 652 | ||
646 | /* Get the first frontend */ | 653 | /* Get the first frontend */ |
647 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | 654 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); |
@@ -1243,6 +1250,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1243 | struct cx88_core *core = drv->core; | 1250 | struct cx88_core *core = drv->core; |
1244 | struct cx8802_dev *dev = drv->core->dvbdev; | 1251 | struct cx8802_dev *dev = drv->core->dvbdev; |
1245 | int err; | 1252 | int err; |
1253 | struct videobuf_dvb_frontend *fe; | ||
1254 | int i; | ||
1246 | 1255 | ||
1247 | dprintk( 1, "%s\n", __func__); | 1256 | dprintk( 1, "%s\n", __func__); |
1248 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", | 1257 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", |
@@ -1258,39 +1267,34 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1258 | /* If vp3054 isn't enabled, a stub will just return 0 */ | 1267 | /* If vp3054 isn't enabled, a stub will just return 0 */ |
1259 | err = vp3054_i2c_probe(dev); | 1268 | err = vp3054_i2c_probe(dev); |
1260 | if (0 != err) | 1269 | if (0 != err) |
1261 | goto fail_probe; | 1270 | goto fail_core; |
1262 | 1271 | ||
1263 | /* dvb stuff */ | 1272 | /* dvb stuff */ |
1264 | printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); | 1273 | printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); |
1265 | dev->ts_gen_cntrl = 0x0c; | 1274 | dev->ts_gen_cntrl = 0x0c; |
1266 | 1275 | ||
1276 | err = cx8802_alloc_frontends(dev); | ||
1277 | if (err) | ||
1278 | goto fail_core; | ||
1279 | |||
1267 | err = -ENODEV; | 1280 | err = -ENODEV; |
1268 | if (core->board.num_frontends) { | 1281 | for (i = 1; i <= core->board.num_frontends; i++) { |
1269 | struct videobuf_dvb_frontend *fe; | 1282 | fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i); |
1270 | int i; | 1283 | if (fe == NULL) { |
1271 | 1284 | printk(KERN_ERR "%s() failed to get frontend(%d)\n", | |
1272 | for (i = 1; i <= core->board.num_frontends; i++) { | ||
1273 | fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i); | ||
1274 | if (fe == NULL) { | ||
1275 | printk(KERN_ERR "%s() failed to get frontend(%d)\n", | ||
1276 | __func__, i); | 1285 | __func__, i); |
1277 | goto fail_probe; | 1286 | goto fail_probe; |
1278 | } | 1287 | } |
1279 | videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, | 1288 | videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, |
1280 | &dev->pci->dev, &dev->slock, | 1289 | &dev->pci->dev, &dev->slock, |
1281 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1290 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
1282 | V4L2_FIELD_TOP, | 1291 | V4L2_FIELD_TOP, |
1283 | sizeof(struct cx88_buffer), | 1292 | sizeof(struct cx88_buffer), |
1284 | dev); | 1293 | dev); |
1285 | /* init struct videobuf_dvb */ | 1294 | /* init struct videobuf_dvb */ |
1286 | fe->dvb.name = dev->core->name; | 1295 | fe->dvb.name = dev->core->name; |
1287 | } | ||
1288 | } else { | ||
1289 | /* no frontends allocated */ | ||
1290 | printk(KERN_ERR "%s/2 .num_frontends should be non-zero\n", | ||
1291 | core->name); | ||
1292 | goto fail_core; | ||
1293 | } | 1296 | } |
1297 | |||
1294 | err = dvb_register(dev); | 1298 | err = dvb_register(dev); |
1295 | if (err) | 1299 | if (err) |
1296 | /* frontends/adapter de-allocated in dvb_register */ | 1300 | /* frontends/adapter de-allocated in dvb_register */ |