The patch number 9232 was added via Steven Toth <[EMAIL PROTECTED]> to http://linuxtv.org/hg/v4l-dvb master development tree.
Kernel patches in this development tree may be modified to be backward compatible with older kernels. Compatibility modifications will be removed before inclusion into the mainstream Kernel If anyone has any objections, please let us know by sending a message to: [EMAIL PROTECTED] ------ From: Steven Toth <[EMAIL PROTECTED]> 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. Priority: normal Signed-off-by: Steven Toth <[EMAIL PROTECTED]> --- linux/drivers/media/video/cx23885/cx23885-dvb.c | 71 ++++++++++------ 1 file changed, 45 insertions(+), 26 deletions(-) diff -r f5764f2068fc -r 6ed6ba34f8fa linux/drivers/media/video/cx23885/cx23885-dvb.c --- a/linux/drivers/media/video/cx23885/cx23885-dvb.c Sat Oct 11 11:27:06 2008 -0400 +++ b/linux/drivers/media/video/cx23885/cx23885-dvb.c Sat Oct 11 11:34:39 2008 -0400 @@ -314,13 +314,6 @@ static int dvb_register(struct cx23885_t struct cx23885_dev *dev = port->dev; struct cx23885_i2c *i2c_bus = NULL; struct videobuf_dvb_frontend *fe0; - - printk(KERN_INFO "%s() allocating 1 frontend\n", __func__); - - if (videobuf_dvb_alloc_frontend(dev, &port->frontends, 1) == NULL) { - printk(KERN_ERR "%s() failed to alloc\n", __func__); - return -ENOMEM; - } /* Get the first frontend */ fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); @@ -561,26 +554,46 @@ int cx23885_dvb_register(struct cx23885_ struct videobuf_dvb_frontend *fe0; struct cx23885_dev *dev = port->dev; - int err; - - fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); - if (!fe0) - err = -EINVAL; - - dprintk(1, "%s\n", __func__); - dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", - dev->board, - dev->name, - dev->pci_bus, - dev->pci_slot); - - err = -ENODEV; - - /* dvb stuff */ - printk("%s: cx23885 based dvb card\n", dev->name); - videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock, + int err, i; + + /* Here we need to allocate the correct number of frontends, + * as reflected in the cards struct. The reality is that currrently + * no cx23885 boards support this - yet. But, if we don't modify this + * code then the second frontend would never be allocated (later) + * and fail with error before the attach in dvb_register(). + * Without these changes we risk an OOPS later. The changes here + * are for safety, and should provide a good foundation for the + * future addition of any multi-frontend cx23885 based boards. + */ + printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, + port->num_frontends); + + for (i = 1; i <= port->num_frontends; i++) { + if (videobuf_dvb_alloc_frontend(dev, &port->frontends, i) == NULL) { + printk(KERN_ERR "%s() failed to alloc\n", __func__); + return -ENOMEM; + } + + fe0 = videobuf_dvb_get_frontend(&port->frontends, i); + if (!fe0) + err = -EINVAL; + + dprintk(1, "%s\n", __func__); + dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", + dev->board, + dev->name, + dev->pci_bus, + dev->pci_slot); + + err = -ENODEV; + + /* dvb stuff */ + /* We have to init the queue for each frontend on a port. */ + printk("%s: cx23885 based dvb card\n", dev->name); + videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, sizeof(struct cx23885_buffer), port); + } err = dvb_register(port); if (err != 0) printk("%s() dvb_register failed err = %d\n", __func__, err); @@ -592,8 +605,14 @@ int cx23885_dvb_unregister(struct cx2388 { struct videobuf_dvb_frontend *fe0; + /* FIXME: in an error condition where the we have + * an expected number of frontends (attach problem) + * then this might not clean up correctly, if 1 + * is invalid. + * This comment only applies to future boards IF they + * implement MFE support. + */ fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); - /* dvb */ if(fe0->dvb.frontend) videobuf_dvb_unregister_bus(&port->frontends); --- Patch is available at: http://linuxtv.org/hg/v4l-dvb/rev/6ed6ba34f8fa22fc5b66feb4d2d1dd5509776fb6 _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits