summaryrefslogtreecommitdiff
path: root/sound/firewire/bebob/bebob_pcm.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2019-10-18 00:54:14 +0900
committerTakashi Iwai <tiwai@suse.de>2019-10-18 04:35:43 +0200
commit1fde7a447a7f423b893ac3fcac0ba65893924189 (patch)
treec916ac8d05c7a78f8b897e84f0be1437f88baf5b /sound/firewire/bebob/bebob_pcm.c
parenta0e023317e2d55c6b2fbf342c12d8a59797e1cff (diff)
downloadlinux-1fde7a447a7f423b893ac3fcac0ba65893924189.tar.gz
linux-1fde7a447a7f423b893ac3fcac0ba65893924189.tar.bz2
linux-1fde7a447a7f423b893ac3fcac0ba65893924189.zip
ALSA: bebob: share PCM buffer size for both direction
This commit allows ALSA bebob driver to share PCM buffer size for both capture and playback PCM substream. When AMDTP domain starts for one of the PCM substream, buffer size of the PCM substream is stores to AMDTP domain structure. Some AMDTP streams have already run with the buffer size when another PCM substream starts, therefore the PCM substream has a constraint to its buffer size. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20191017155424.885-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/bebob/bebob_pcm.c')
-rw-r--r--sound/firewire/bebob/bebob_pcm.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c
index 516c9874f4a1..8b2e0ceffe82 100644
--- a/sound/firewire/bebob/bebob_pcm.c
+++ b/sound/firewire/bebob/bebob_pcm.c
@@ -157,6 +157,7 @@ static int pcm_open(struct snd_pcm_substream *substream)
if (src == SND_BEBOB_CLOCK_TYPE_EXTERNAL ||
(bebob->substreams_counter > 0 && d->events_per_period > 0)) {
unsigned int frames_per_period = d->events_per_period;
+ unsigned int frames_per_buffer = d->events_per_buffer;
unsigned int sampling_rate;
err = spec->get(bebob, &sampling_rate);
@@ -178,6 +179,14 @@ static int pcm_open(struct snd_pcm_substream *substream)
mutex_unlock(&bebob->mutex);
goto err_locked;
}
+
+ err = snd_pcm_hw_constraint_minmax(substream->runtime,
+ SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
+ frames_per_buffer, frames_per_buffer);
+ if (err < 0) {
+ mutex_unlock(&bebob->mutex);
+ goto err_locked;
+ }
}
}
@@ -213,10 +222,11 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params);
unsigned int frames_per_period = params_period_size(hw_params);
+ unsigned int frames_per_buffer = params_buffer_size(hw_params);
mutex_lock(&bebob->mutex);
err = snd_bebob_stream_reserve_duplex(bebob, rate,
- frames_per_period);
+ frames_per_period, frames_per_buffer);
if (err >= 0)
++bebob->substreams_counter;
mutex_unlock(&bebob->mutex);