Lines Matching +full:hw +full:- +full:channels

1 // SPDX-License-Identifier: GPL-2.0-only
3 * ff-pcm.c - a part of driver for RME Fireface series
5 * Copyright (c) 2015-2017 Takashi Sakamoto
13 const unsigned int *pcm_channels = rule->private; in hw_rule_rate()
44 const unsigned int *pcm_channels = rule->private; in hw_rule_channels()
72 static void limit_channels_and_rates(struct snd_pcm_hardware *hw, in limit_channels_and_rates() argument
75 unsigned int rate, channels; in limit_channels_and_rates() local
78 hw->channels_min = UINT_MAX; in limit_channels_and_rates()
79 hw->channels_max = 0; in limit_channels_and_rates()
80 hw->rate_min = UINT_MAX; in limit_channels_and_rates()
81 hw->rate_max = 0; in limit_channels_and_rates()
91 channels = pcm_channels[mode]; in limit_channels_and_rates()
94 hw->channels_min = min(hw->channels_min, channels); in limit_channels_and_rates()
95 hw->channels_max = max(hw->channels_max, channels); in limit_channels_and_rates()
98 hw->rates |= snd_pcm_rate_to_rate_bit(rate); in limit_channels_and_rates()
99 hw->rate_min = min(hw->rate_min, rate); in limit_channels_and_rates()
100 hw->rate_max = max(hw->rate_max, rate); in limit_channels_and_rates()
107 struct snd_pcm_runtime *runtime = substream->runtime; in pcm_init_hw_params()
112 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in pcm_init_hw_params()
113 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32; in pcm_init_hw_params()
114 s = &ff->tx_stream; in pcm_init_hw_params()
115 pcm_channels = ff->spec->pcm_capture_channels; in pcm_init_hw_params()
117 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32; in pcm_init_hw_params()
118 s = &ff->rx_stream; in pcm_init_hw_params()
119 pcm_channels = ff->spec->pcm_playback_channels; in pcm_init_hw_params()
122 limit_channels_and_rates(&runtime->hw, pcm_channels); in pcm_init_hw_params()
126 SNDRV_PCM_HW_PARAM_RATE, -1); in pcm_init_hw_params()
132 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in pcm_init_hw_params()
141 struct snd_ff *ff = substream->private_data; in pcm_open()
142 struct amdtp_domain *d = &ff->domain; in pcm_open()
155 err = ff->spec->protocol->get_clock(ff, &rate, &src); in pcm_open()
159 mutex_lock(&ff->mutex); in pcm_open()
173 mutex_unlock(&ff->mutex); in pcm_open()
174 err = -EIO; in pcm_open()
178 substream->runtime->hw.rate_min = rate; in pcm_open()
179 substream->runtime->hw.rate_max = rate; in pcm_open()
181 if (ff->substreams_counter > 0) { in pcm_open()
182 unsigned int frames_per_period = d->events_per_period; in pcm_open()
183 unsigned int frames_per_buffer = d->events_per_buffer; in pcm_open()
185 rate = amdtp_rate_table[ff->rx_stream.sfc]; in pcm_open()
186 substream->runtime->hw.rate_min = rate; in pcm_open()
187 substream->runtime->hw.rate_max = rate; in pcm_open()
189 err = snd_pcm_hw_constraint_minmax(substream->runtime, in pcm_open()
193 mutex_unlock(&ff->mutex); in pcm_open()
197 err = snd_pcm_hw_constraint_minmax(substream->runtime, in pcm_open()
201 mutex_unlock(&ff->mutex); in pcm_open()
207 mutex_unlock(&ff->mutex); in pcm_open()
220 struct snd_ff *ff = substream->private_data; in pcm_close()
230 struct snd_ff *ff = substream->private_data; in pcm_hw_params()
233 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN) { in pcm_hw_params()
238 mutex_lock(&ff->mutex); in pcm_hw_params()
242 ++ff->substreams_counter; in pcm_hw_params()
243 mutex_unlock(&ff->mutex); in pcm_hw_params()
251 struct snd_ff *ff = substream->private_data; in pcm_hw_free()
253 mutex_lock(&ff->mutex); in pcm_hw_free()
255 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in pcm_hw_free()
256 --ff->substreams_counter; in pcm_hw_free()
260 mutex_unlock(&ff->mutex); in pcm_hw_free()
267 struct snd_ff *ff = substream->private_data; in pcm_capture_prepare()
268 struct snd_pcm_runtime *runtime = substream->runtime; in pcm_capture_prepare()
271 mutex_lock(&ff->mutex); in pcm_capture_prepare()
273 err = snd_ff_stream_start_duplex(ff, runtime->rate); in pcm_capture_prepare()
275 amdtp_stream_pcm_prepare(&ff->tx_stream); in pcm_capture_prepare()
277 mutex_unlock(&ff->mutex); in pcm_capture_prepare()
284 struct snd_ff *ff = substream->private_data; in pcm_playback_prepare()
285 struct snd_pcm_runtime *runtime = substream->runtime; in pcm_playback_prepare()
288 mutex_lock(&ff->mutex); in pcm_playback_prepare()
290 err = snd_ff_stream_start_duplex(ff, runtime->rate); in pcm_playback_prepare()
292 amdtp_stream_pcm_prepare(&ff->rx_stream); in pcm_playback_prepare()
294 mutex_unlock(&ff->mutex); in pcm_playback_prepare()
301 struct snd_ff *ff = substream->private_data; in pcm_capture_trigger()
305 amdtp_stream_pcm_trigger(&ff->tx_stream, substream); in pcm_capture_trigger()
308 amdtp_stream_pcm_trigger(&ff->tx_stream, NULL); in pcm_capture_trigger()
311 return -EINVAL; in pcm_capture_trigger()
319 struct snd_ff *ff = substream->private_data; in pcm_playback_trigger()
323 amdtp_stream_pcm_trigger(&ff->rx_stream, substream); in pcm_playback_trigger()
326 amdtp_stream_pcm_trigger(&ff->rx_stream, NULL); in pcm_playback_trigger()
329 return -EINVAL; in pcm_playback_trigger()
337 struct snd_ff *ff = sbstrm->private_data; in pcm_capture_pointer()
339 return amdtp_domain_stream_pcm_pointer(&ff->domain, &ff->tx_stream); in pcm_capture_pointer()
344 struct snd_ff *ff = sbstrm->private_data; in pcm_playback_pointer()
346 return amdtp_domain_stream_pcm_pointer(&ff->domain, &ff->rx_stream); in pcm_playback_pointer()
351 struct snd_ff *ff = substream->private_data; in pcm_capture_ack()
353 return amdtp_domain_stream_pcm_ack(&ff->domain, &ff->tx_stream); in pcm_capture_ack()
358 struct snd_ff *ff = substream->private_data; in pcm_playback_ack()
360 return amdtp_domain_stream_pcm_ack(&ff->domain, &ff->rx_stream); in pcm_playback_ack()
388 err = snd_pcm_new(ff->card, ff->card->driver, 0, 1, 1, &pcm); in snd_ff_create_pcm_devices()
392 pcm->private_data = ff; in snd_ff_create_pcm_devices()
393 pcm->nonatomic = true; in snd_ff_create_pcm_devices()
394 snprintf(pcm->name, sizeof(pcm->name), in snd_ff_create_pcm_devices()
395 "%s PCM", ff->card->shortname); in snd_ff_create_pcm_devices()