Lines Matching +full:hw +full:- +full:channels
1 // SPDX-License-Identifier: GPL-2.0-only
3 * motu-pcm.c - a part of driver for MOTU FireWire series
5 * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
14 struct snd_motu_packet_format *formats = rule->private; in motu_rate_constraint()
29 pcm_channels = formats->pcm_chunks[mode]; in motu_rate_constraint()
43 struct snd_motu_packet_format *formats = rule->private; in motu_channels_constraint()
49 struct snd_interval channels = { in motu_channels_constraint() local
61 pcm_channels = formats->pcm_chunks[mode]; in motu_channels_constraint()
62 channels.min = min(channels.min, pcm_channels); in motu_channels_constraint()
63 channels.max = max(channels.max, pcm_channels); in motu_channels_constraint()
66 return snd_interval_refine(c, &channels); in motu_channels_constraint()
73 struct snd_pcm_hardware *hw = &runtime->hw; in limit_channels_and_rates() local
76 hw->channels_min = UINT_MAX; in limit_channels_and_rates()
77 hw->channels_max = 0; in limit_channels_and_rates()
83 pcm_channels = formats->pcm_chunks[mode]; in limit_channels_and_rates()
87 hw->rates |= snd_pcm_rate_to_rate_bit(rate); in limit_channels_and_rates()
88 hw->channels_min = min(hw->channels_min, pcm_channels); in limit_channels_and_rates()
89 hw->channels_max = max(hw->channels_max, pcm_channels); in limit_channels_and_rates()
98 struct snd_pcm_runtime *runtime = substream->runtime; in init_hw_info()
99 struct snd_pcm_hardware *hw = &runtime->hw; in init_hw_info() local
104 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in init_hw_info()
105 hw->formats = SNDRV_PCM_FMTBIT_S32; in init_hw_info()
106 stream = &motu->tx_stream; in init_hw_info()
107 formats = &motu->tx_packet_formats; in init_hw_info()
109 hw->formats = SNDRV_PCM_FMTBIT_S32; in init_hw_info()
110 stream = &motu->rx_stream; in init_hw_info()
111 formats = &motu->rx_packet_formats; in init_hw_info()
118 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in init_hw_info()
123 SNDRV_PCM_HW_PARAM_RATE, -1); in init_hw_info()
132 struct snd_motu *motu = substream->private_data; in pcm_open()
133 struct amdtp_domain *d = &motu->domain; in pcm_open()
141 mutex_lock(&motu->mutex); in pcm_open()
160 (motu->substreams_counter > 0 && d->events_per_period > 0)) { in pcm_open()
161 unsigned int frames_per_period = d->events_per_period; in pcm_open()
162 unsigned int frames_per_buffer = d->events_per_buffer; in pcm_open()
169 substream->runtime->hw.rate_min = rate; in pcm_open()
170 substream->runtime->hw.rate_max = rate; in pcm_open()
173 err = snd_pcm_hw_constraint_minmax(substream->runtime, in pcm_open()
179 err = snd_pcm_hw_constraint_minmax(substream->runtime, in pcm_open()
189 mutex_unlock(&motu->mutex); in pcm_open()
193 mutex_unlock(&motu->mutex); in pcm_open()
200 struct snd_motu *motu = substream->private_data; in pcm_close()
210 struct snd_motu *motu = substream->private_data; in pcm_hw_params()
213 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN) { in pcm_hw_params()
218 mutex_lock(&motu->mutex); in pcm_hw_params()
222 ++motu->substreams_counter; in pcm_hw_params()
223 mutex_unlock(&motu->mutex); in pcm_hw_params()
231 struct snd_motu *motu = substream->private_data; in pcm_hw_free()
233 mutex_lock(&motu->mutex); in pcm_hw_free()
235 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in pcm_hw_free()
236 --motu->substreams_counter; in pcm_hw_free()
240 mutex_unlock(&motu->mutex); in pcm_hw_free()
247 struct snd_motu *motu = substream->private_data; in capture_prepare()
250 mutex_lock(&motu->mutex); in capture_prepare()
252 mutex_unlock(&motu->mutex); in capture_prepare()
254 amdtp_stream_pcm_prepare(&motu->tx_stream); in capture_prepare()
260 struct snd_motu *motu = substream->private_data; in playback_prepare()
263 mutex_lock(&motu->mutex); in playback_prepare()
265 mutex_unlock(&motu->mutex); in playback_prepare()
267 amdtp_stream_pcm_prepare(&motu->rx_stream); in playback_prepare()
274 struct snd_motu *motu = substream->private_data; in capture_trigger()
278 amdtp_stream_pcm_trigger(&motu->tx_stream, substream); in capture_trigger()
281 amdtp_stream_pcm_trigger(&motu->tx_stream, NULL); in capture_trigger()
284 return -EINVAL; in capture_trigger()
291 struct snd_motu *motu = substream->private_data; in playback_trigger()
295 amdtp_stream_pcm_trigger(&motu->rx_stream, substream); in playback_trigger()
298 amdtp_stream_pcm_trigger(&motu->rx_stream, NULL); in playback_trigger()
301 return -EINVAL; in playback_trigger()
309 struct snd_motu *motu = substream->private_data; in capture_pointer()
311 return amdtp_domain_stream_pcm_pointer(&motu->domain, &motu->tx_stream); in capture_pointer()
315 struct snd_motu *motu = substream->private_data; in playback_pointer()
317 return amdtp_domain_stream_pcm_pointer(&motu->domain, &motu->rx_stream); in playback_pointer()
322 struct snd_motu *motu = substream->private_data; in capture_ack()
324 return amdtp_domain_stream_pcm_ack(&motu->domain, &motu->tx_stream); in capture_ack()
329 struct snd_motu *motu = substream->private_data; in playback_ack()
331 return amdtp_domain_stream_pcm_ack(&motu->domain, &motu->rx_stream); in playback_ack()
359 err = snd_pcm_new(motu->card, motu->card->driver, 0, 1, 1, &pcm); in snd_motu_create_pcm_devices()
362 pcm->private_data = motu; in snd_motu_create_pcm_devices()
363 pcm->nonatomic = true; in snd_motu_create_pcm_devices()
364 strcpy(pcm->name, motu->card->shortname); in snd_motu_create_pcm_devices()