diff options
author | Steven Toth <stoth@linuxtv.org> | 2008-10-11 11:34:39 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-17 16:24:43 -0400 |
commit | eb0c58bb1325593840af0e7fbb4dbc654e756591 (patch) | |
tree | 2780d6605987a3d0d86014131562e11076d2b2ed /drivers | |
parent | a739a7e4c642ebb1ab803fc2c9743aaf1833058b (diff) |
V4L/DVB (9232): cx23885: Move the MFE frontend allocation into the correct place
cx23885 frontend allocation code needs to exist in the higher function,
and it also needs to ensure videobug is also correctly initialised
on a per frontend basis. This code uses the previous num_frontends
patch to safely init each future MFE frontend on a single tsport as
as safely as possible - given that we don't have any of those boards.
Again, better to add all of this safety code now, while the MFE patch
set is fresh in everyone mind, than to try and add it 12-24 months from
now, when the subject is cold.
Signed-off-by: Steven Toth <stoth@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/cx23885/cx23885-dvb.c | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c index d779b8dd180a..9dfc96008551 100644 --- a/drivers/media/video/cx23885/cx23885-dvb.c +++ b/drivers/media/video/cx23885/cx23885-dvb.c | |||
@@ -314,13 +314,6 @@ static int dvb_register(struct cx23885_tsport *port) | |||
314 | struct cx23885_i2c *i2c_bus = NULL; | 314 | struct cx23885_i2c *i2c_bus = NULL; |
315 | struct videobuf_dvb_frontend *fe0; | 315 | struct videobuf_dvb_frontend *fe0; |
316 | 316 | ||
317 | printk(KERN_INFO "%s() allocating 1 frontend\n", __func__); | ||
318 | |||
319 | if (videobuf_dvb_alloc_frontend(dev, &port->frontends, 1) == NULL) { | ||
320 | printk(KERN_ERR "%s() failed to alloc\n", __func__); | ||
321 | return -ENOMEM; | ||
322 | } | ||
323 | |||
324 | /* Get the first frontend */ | 317 | /* Get the first frontend */ |
325 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); | 318 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); |
326 | if (!fe0) | 319 | if (!fe0) |
@@ -560,26 +553,46 @@ int cx23885_dvb_register(struct cx23885_tsport *port) | |||
560 | 553 | ||
561 | struct videobuf_dvb_frontend *fe0; | 554 | struct videobuf_dvb_frontend *fe0; |
562 | struct cx23885_dev *dev = port->dev; | 555 | struct cx23885_dev *dev = port->dev; |
563 | int err; | 556 | int err, i; |
557 | |||
558 | /* Here we need to allocate the correct number of frontends, | ||
559 | * as reflected in the cards struct. The reality is that currrently | ||
560 | * no cx23885 boards support this - yet. But, if we don't modify this | ||
561 | * code then the second frontend would never be allocated (later) | ||
562 | * and fail with error before the attach in dvb_register(). | ||
563 | * Without these changes we risk an OOPS later. The changes here | ||
564 | * are for safety, and should provide a good foundation for the | ||
565 | * future addition of any multi-frontend cx23885 based boards. | ||
566 | */ | ||
567 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, | ||
568 | port->num_frontends); | ||
564 | 569 | ||
565 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); | 570 | for (i = 1; i <= port->num_frontends; i++) { |
566 | if (!fe0) | 571 | if (videobuf_dvb_alloc_frontend(dev, &port->frontends, i) == NULL) { |
567 | err = -EINVAL; | 572 | printk(KERN_ERR "%s() failed to alloc\n", __func__); |
573 | return -ENOMEM; | ||
574 | } | ||
575 | |||
576 | fe0 = videobuf_dvb_get_frontend(&port->frontends, i); | ||
577 | if (!fe0) | ||
578 | err = -EINVAL; | ||
568 | 579 | ||
569 | dprintk(1, "%s\n", __func__); | 580 | dprintk(1, "%s\n", __func__); |
570 | dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", | 581 | dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", |
571 | dev->board, | 582 | dev->board, |
572 | dev->name, | 583 | dev->name, |
573 | dev->pci_bus, | 584 | dev->pci_bus, |
574 | dev->pci_slot); | 585 | dev->pci_slot); |
575 | 586 | ||
576 | err = -ENODEV; | 587 | err = -ENODEV; |
577 | 588 | ||
578 | /* dvb stuff */ | 589 | /* dvb stuff */ |
579 | printk("%s: cx23885 based dvb card\n", dev->name); | 590 | /* We have to init the queue for each frontend on a port. */ |
580 | videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock, | 591 | printk("%s: cx23885 based dvb card\n", dev->name); |
592 | videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock, | ||
581 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, | 593 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, |
582 | sizeof(struct cx23885_buffer), port); | 594 | sizeof(struct cx23885_buffer), port); |
595 | } | ||
583 | err = dvb_register(port); | 596 | err = dvb_register(port); |
584 | if (err != 0) | 597 | if (err != 0) |
585 | printk("%s() dvb_register failed err = %d\n", __func__, err); | 598 | printk("%s() dvb_register failed err = %d\n", __func__, err); |
@@ -591,8 +604,14 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port) | |||
591 | { | 604 | { |
592 | struct videobuf_dvb_frontend *fe0; | 605 | struct videobuf_dvb_frontend *fe0; |
593 | 606 | ||
607 | /* FIXME: in an error condition where the we have | ||
608 | * an expected number of frontends (attach problem) | ||
609 | * then this might not clean up correctly, if 1 | ||
610 | * is invalid. | ||
611 | * This comment only applies to future boards IF they | ||
612 | * implement MFE support. | ||
613 | */ | ||
594 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); | 614 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); |
595 | /* dvb */ | ||
596 | if(fe0->dvb.frontend) | 615 | if(fe0->dvb.frontend) |
597 | videobuf_dvb_unregister_bus(&port->frontends); | 616 | videobuf_dvb_unregister_bus(&port->frontends); |
598 | 617 | ||