summaryrefslogtreecommitdiff
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorGianluca Gennari <gennarone@gmail.com>2012-02-13 13:59:22 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-03-08 08:57:44 -0300
commit86d38d1e0e0f66ec3973b718d35a590e04fb32fa (patch)
tree0573a2f36bf058d8ffbcd9965901be181a984797 /drivers/media/video/em28xx/em28xx-video.c
parent0c07aec31a98a63ee83f2bbad4a2fab0e0f58d33 (diff)
[media] em28xx: pre-allocate DVB isoc transfer buffers
On MIPS/ARM set-top-boxes, as well as old x86 PCs, memory allocation failures in the em28xx driver are common, due to memory fragmentation over time, that makes impossible to allocate large chunks of coherent memory. A typical system with 256/512 MB of RAM fails after just 1 day of uptime (see the old thread for detailed reports and crashlogs). In fact, the em28xx driver allocates memory for USB isoc transfers at runtime, as opposite to the dvb-usb drivers that allocates the USB buffers when the device is initialized, and frees them when the device is disconnected. Moreover, in digital mode the USB isoc transfer buffers are freed, allocated and cleared every time the user selects a new channel, wasting time and resources. This patch solves both problems by allocating DVB isoc transfer buffers in em28xx_usb_probe(), and freeing them in em28xx_usb_disconnect(). In fact, the buffers size and number depend only on the max USB packet size that is parsed from the USB descriptors in em28xx_usb_probe(), so it can never change for a given device. This approach makes no sense in analog mode (as the buffer size depends on the alternate mode selected at runtime), the patch creates two separate sets of buffers for digital and analog modes. For digital-only devices, USB buffers are created when the device is probed and freed when the device is disconnected. For analog-only devices, nothing changes: isoc buffers are created at runtime. For hybrid devices, two sets of buffers are maintained: the digital-mode buffers are created when the device is probed, and freed when the device is disconnected; analog-mode buffers are created/destroyed at runtime as before. So, in analog mode, digital and analog buffers coexists at the same time: this can be justified by the fact that digital mode is by far more commonly used nowadays, so it makes sense to optimize the driver for this use case scenario. The patch has been tested in the last few days on a x86 PC and a MIPS set-top-box, with the PCTV 290e (digital only) and the Terratec Hybrid XS (hybrid device). With the latter, I switched several times between analog and digital mode (Kaffeine/TvTime) with no issue at all. I unplugged/plugged the devices several times with no problem. Also, after over 3 days of normal usage in the MPIS set-top-box, the PCTV 290e was still up and running. Signed-off-by: Gianluca Gennari <gennarone@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 613300b51a9e..324b695c0724 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -760,17 +760,19 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
goto fail;
}
- if (!dev->isoc_ctl.num_bufs)
+ if (!dev->isoc_ctl.analog_bufs.num_bufs)
urb_init = 1;
if (urb_init) {
if (em28xx_vbi_supported(dev) == 1)
- rc = em28xx_init_isoc(dev, EM28XX_NUM_PACKETS,
+ rc = em28xx_init_isoc(dev, EM28XX_ANALOG_MODE,
+ EM28XX_NUM_PACKETS,
EM28XX_NUM_BUFS,
dev->max_pkt_size,
em28xx_isoc_copy_vbi);
else
- rc = em28xx_init_isoc(dev, EM28XX_NUM_PACKETS,
+ rc = em28xx_init_isoc(dev, EM28XX_ANALOG_MODE,
+ EM28XX_NUM_PACKETS,
EM28XX_NUM_BUFS,
dev->max_pkt_size,
em28xx_isoc_copy);
@@ -2267,7 +2269,7 @@ static int em28xx_v4l2_close(struct file *filp)
v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0);
/* do this before setting alternate! */
- em28xx_uninit_isoc(dev);
+ em28xx_uninit_isoc(dev, EM28XX_ANALOG_MODE);
em28xx_set_mode(dev, EM28XX_SUSPEND);
/* set alternate 0 */