diff options
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-audio.c | 8 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx.h | 2 |
2 files changed, 10 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) | |||
293 | mutex_unlock(&dev->lock); | 293 | mutex_unlock(&dev->lock); |
294 | } | 294 | } |
295 | 295 | ||
296 | /* Dynamically adjust the period size */ | ||
296 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | 297 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); |
298 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, | ||
299 | dev->adev.period * 95 / 100, | ||
300 | dev->adev.period * 105 / 100); | ||
301 | |||
297 | dev->adev.capture_pcm_substream = substream; | 302 | dev->adev.capture_pcm_substream = substream; |
298 | 303 | ||
299 | return 0; | 304 | return 0; |
@@ -803,6 +808,9 @@ static int em28xx_audio_urb_init(struct em28xx *dev) | |||
803 | em28xx_info("Number of URBs: %d, with %d packets and %d size", | 808 | em28xx_info("Number of URBs: %d, with %d packets and %d size", |
804 | num_urb, npackets, urb_size); | 809 | num_urb, npackets, urb_size); |
805 | 810 | ||
811 | /* Estimate the bytes per period */ | ||
812 | dev->adev.period = urb_size * npackets; | ||
813 | |||
806 | /* Allocate space to store the number of URBs to be used */ | 814 | /* Allocate space to store the number of URBs to be used */ |
807 | 815 | ||
808 | dev->adev.transfer_buffer = kcalloc(num_urb, | 816 | dev->adev.transfer_buffer = kcalloc(num_urb, |
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index 5d5d1b6f0294..10b817245f7e 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h | |||
@@ -505,6 +505,8 @@ struct em28xx_audio { | |||
505 | unsigned int hwptr_done_capture; | 505 | unsigned int hwptr_done_capture; |
506 | struct snd_card *sndcard; | 506 | struct snd_card *sndcard; |
507 | 507 | ||
508 | size_t period; | ||
509 | |||
508 | int users; | 510 | int users; |
509 | spinlock_t slock; | 511 | spinlock_t slock; |
510 | }; | 512 | }; |