diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2019-10-17 18:54:21 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-10-18 05:35:52 +0300 |
commit | 4de3eb062e2daf04646d23417a39b8843df4508b (patch) | |
tree | 35c8004b3735a8369c4151f90412900f7ebd8a63 /sound/firewire/fireface/ff-pcm.c | |
parent | 0f5482e7875bc2d507e6d92fcc8de22ff75fbdda (diff) | |
download | linux-4de3eb062e2daf04646d23417a39b8843df4508b.tar.xz |
ALSA: fireface: share PCM buffer size for both direction
This commit allows ALSA fireface 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-10-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/fireface/ff-pcm.c')
-rw-r--r-- | sound/firewire/fireface/ff-pcm.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c index 415bc9ccd1c7..005d959f8651 100644 --- a/sound/firewire/fireface/ff-pcm.c +++ b/sound/firewire/fireface/ff-pcm.c @@ -180,6 +180,7 @@ static int pcm_open(struct snd_pcm_substream *substream) } else { if (ff->substreams_counter > 0) { unsigned int frames_per_period = d->events_per_period; + unsigned int frames_per_buffer = d->events_per_buffer; rate = amdtp_rate_table[ff->rx_stream.sfc]; substream->runtime->hw.rate_min = rate; @@ -192,6 +193,14 @@ static int pcm_open(struct snd_pcm_substream *substream) mutex_unlock(&ff->mutex); goto release_lock; } + + 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(&ff->mutex); + goto release_lock; + } } } @@ -229,9 +238,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(&ff->mutex); - err = snd_ff_stream_reserve_duplex(ff, rate, frames_per_period); + err = snd_ff_stream_reserve_duplex(ff, rate, frames_per_period, + frames_per_buffer); if (err >= 0) ++ff->substreams_counter; mutex_unlock(&ff->mutex); |