summaryrefslogtreecommitdiff
path: root/drivers/media/usb/em28xx/em28xx-audio.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-13 03:34:23 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-14 14:39:52 -0200
commita02b9c238b408f69fc78d528b549b85001df98b8 (patch)
treeac3fadaf4a4c826a7fd9c44716f60a3311876a23 /drivers/media/usb/em28xx/em28xx-audio.c
parentebbfbc2006700f0b5701fb3efa44b55a09fba5d1 (diff)
downloadlinux-a02b9c238b408f69fc78d528b549b85001df98b8.tar.gz
linux-a02b9c238b408f69fc78d528b549b85001df98b8.tar.xz
[media] em28xx: adjust period size at runtime
While the current hardcoded period is ok for the current values, we may latter change the driver to work with different bit rates or with different latencies than 64ms. So, adust the period size at runtime. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb/em28xx/em28xx-audio.c')
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index 26cf431b1a46..74575e0ed41b 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -293,7 +293,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
mutex_unlock(&dev->lock);
}
+ /* Dynamically adjust the period size */
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
+ snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
+ dev->adev.period * 95 / 100,
+ dev->adev.period * 105 / 100);
+
dev->adev.capture_pcm_substream = substream;
return 0;
@@ -803,6 +808,9 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
em28xx_info("Number of URBs: %d, with %d packets and %d size",
num_urb, npackets, urb_size);
+ /* Estimate the bytes per period */
+ dev->adev.period = urb_size * npackets;
+
/* Allocate space to store the number of URBs to be used */
dev->adev.transfer_buffer = kcalloc(num_urb,