Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Takashi Sakamoto and committed by
Takashi Iwai
1fde7a44 a0e02331

+17 -5
+2 -1
sound/firewire/bebob/bebob.h
··· 218 218 int snd_bebob_stream_discover(struct snd_bebob *bebob); 219 219 int snd_bebob_stream_init_duplex(struct snd_bebob *bebob); 220 220 int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate, 221 - unsigned int frames_per_period); 221 + unsigned int frames_per_period, 222 + unsigned int frames_per_buffer); 222 223 int snd_bebob_stream_start_duplex(struct snd_bebob *bebob); 223 224 void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob); 224 225 void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob);
+1 -1
sound/firewire/bebob/bebob_midi.c
··· 17 17 return err; 18 18 19 19 mutex_lock(&bebob->mutex); 20 - err = snd_bebob_stream_reserve_duplex(bebob, 0, 0); 20 + err = snd_bebob_stream_reserve_duplex(bebob, 0, 0, 0); 21 21 if (err >= 0) { 22 22 ++bebob->substreams_counter; 23 23 err = snd_bebob_stream_start_duplex(bebob);
+11 -1
sound/firewire/bebob/bebob_pcm.c
··· 157 157 if (src == SND_BEBOB_CLOCK_TYPE_EXTERNAL || 158 158 (bebob->substreams_counter > 0 && d->events_per_period > 0)) { 159 159 unsigned int frames_per_period = d->events_per_period; 160 + unsigned int frames_per_buffer = d->events_per_buffer; 160 161 unsigned int sampling_rate; 161 162 162 163 err = spec->get(bebob, &sampling_rate); ··· 175 174 err = snd_pcm_hw_constraint_minmax(substream->runtime, 176 175 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 177 176 frames_per_period, frames_per_period); 177 + if (err < 0) { 178 + mutex_unlock(&bebob->mutex); 179 + goto err_locked; 180 + } 181 + 182 + err = snd_pcm_hw_constraint_minmax(substream->runtime, 183 + SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 184 + frames_per_buffer, frames_per_buffer); 178 185 if (err < 0) { 179 186 mutex_unlock(&bebob->mutex); 180 187 goto err_locked; ··· 222 213 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { 223 214 unsigned int rate = params_rate(hw_params); 224 215 unsigned int frames_per_period = params_period_size(hw_params); 216 + unsigned int frames_per_buffer = params_buffer_size(hw_params); 225 217 226 218 mutex_lock(&bebob->mutex); 227 219 err = snd_bebob_stream_reserve_duplex(bebob, rate, 228 - frames_per_period); 220 + frames_per_period, frames_per_buffer); 229 221 if (err >= 0) 230 222 ++bebob->substreams_counter; 231 223 mutex_unlock(&bebob->mutex);
+3 -2
sound/firewire/bebob/bebob_stream.c
··· 555 555 } 556 556 557 557 int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate, 558 - unsigned int frames_per_period) 558 + unsigned int frames_per_period, 559 + unsigned int frames_per_buffer) 559 560 { 560 561 unsigned int curr_rate; 561 562 int err; ··· 611 610 } 612 611 613 612 err = amdtp_domain_set_events_per_period(&bebob->domain, 614 - frames_per_period, 0); 613 + frames_per_period, frames_per_buffer); 615 614 if (err < 0) { 616 615 cmp_connection_release(&bebob->out_conn); 617 616 cmp_connection_release(&bebob->in_conn);