Commit a02b9c23 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[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: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent ebbfbc20
...@@ -293,7 +293,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) ...@@ -293,7 +293,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
} }
/* Dynamically adjust the period size */
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 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; dev->adev.capture_pcm_substream = substream;
return 0; return 0;
...@@ -803,6 +808,9 @@ static int em28xx_audio_urb_init(struct em28xx *dev) ...@@ -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", em28xx_info("Number of URBs: %d, with %d packets and %d size",
num_urb, npackets, urb_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 */ /* Allocate space to store the number of URBs to be used */
dev->adev.transfer_buffer = kcalloc(num_urb, dev->adev.transfer_buffer = kcalloc(num_urb,
......
...@@ -505,6 +505,8 @@ struct em28xx_audio { ...@@ -505,6 +505,8 @@ struct em28xx_audio {
unsigned int hwptr_done_capture; unsigned int hwptr_done_capture;
struct snd_card *sndcard; struct snd_card *sndcard;
size_t period;
int users; int users;
spinlock_t slock; spinlock_t slock;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment