aboutsummaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-10 13:29:16 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-12 11:57:04 -0200
commit49677aef90de7834e7bb4b0adf95c3342c2c8668 (patch)
treec408101461ecdd783c8d5f8fe88423f518fb808e /drivers/media
parent1b3fd2d342667005855deae74200195695433259 (diff)
[media] em28xx-audio: fix the period size in bytes
If the period size is wrong, userspace will assume a wrong delay any may negociate an inadequate value. The em28xx devices use 8 for URB interval, in microframes, and the driver programs it to have 64 packets. That means that the IRQ sampling period is 125 * 8 * 64, with is equal to 64 ms. So, that's the minimal latency with the current settings. It is possible to program a lower latency, by using less than 64 packets, but that increases the amount of bandwitdh used, and the number of IRQ events per second. In any case, in order to support it, the driver logic should be changed to fill those parameters in realtime. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index 6c7d3460029..f6fcee3d4fb 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -52,6 +52,7 @@ MODULE_PARM_DESC(debug, "activates debug info");
#define EM28XX_MAX_AUDIO_BUFS 5
#define EM28XX_MIN_AUDIO_PACKETS 64
+
#define dprintk(fmt, arg...) do { \
if (debug) \
printk(KERN_INFO "em28xx-audio %s: " fmt, \
@@ -217,15 +218,26 @@ static struct snd_pcm_hardware snd_em28xx_hw_capture = {
.formats = SNDRV_PCM_FMTBIT_S16_LE,
- .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT,
+ .rates = SNDRV_PCM_RATE_48000,
.rate_min = 48000,
.rate_max = 48000,
.channels_min = 2,
.channels_max = 2,
.buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */
- .period_bytes_min = 64, /* 12544/2, */
- .period_bytes_max = 12544,
+
+
+ /*
+ * The period is 12.288 bytes. Allow a 10% of variation along its
+ * value, in order to avoid overruns/underruns due to some clock
+ * drift.
+ *
+ * FIXME: This period assumes 64 packets, and a 48000 PCM rate.
+ * Calculate it dynamically.
+ */
+ .period_bytes_min = 11059,
+ .period_bytes_max = 13516,
+
.periods_min = 2,
.periods_max = 98, /* 12544, */
};