Lines Matching +full:pcm +full:- +full:clock +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
3 * dice_pcm.c - a part of driver for DICE based devices
6 * Copyright (c) 2014 Takashi Sakamoto <o-takashi@sakamocchi.jp>
14 struct snd_pcm_substream *substream = rule->private; in dice_rate_constraint()
15 struct snd_dice *dice = substream->private_data; in dice_rate_constraint()
16 unsigned int index = substream->pcm->device; in dice_rate_constraint()
26 enum snd_dice_rate_mode mode; in dice_rate_constraint() local
29 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in dice_rate_constraint()
30 pcm_channels = dice->tx_pcm_chs[index]; in dice_rate_constraint()
32 pcm_channels = dice->rx_pcm_chs[index]; in dice_rate_constraint()
36 if (snd_dice_stream_get_rate_mode(dice, rate, &mode) < 0) in dice_rate_constraint()
39 if (!snd_interval_test(c, pcm_channels[mode])) in dice_rate_constraint()
52 struct snd_pcm_substream *substream = rule->private; in dice_channels_constraint()
53 struct snd_dice *dice = substream->private_data; in dice_channels_constraint()
54 unsigned int index = substream->pcm->device; in dice_channels_constraint()
64 enum snd_dice_rate_mode mode; in dice_channels_constraint() local
67 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in dice_channels_constraint()
68 pcm_channels = dice->tx_pcm_chs[index]; in dice_channels_constraint()
70 pcm_channels = dice->rx_pcm_chs[index]; in dice_channels_constraint()
74 if (snd_dice_stream_get_rate_mode(dice, rate, &mode) < 0) in dice_channels_constraint()
80 channels.min = min(channels.min, pcm_channels[mode]); in dice_channels_constraint()
81 channels.max = max(channels.max, pcm_channels[mode]); in dice_channels_constraint()
92 struct snd_pcm_hardware *hw = &runtime->hw; in limit_channels_and_rates()
97 pcm_channels = dice->tx_pcm_chs[index]; in limit_channels_and_rates()
99 pcm_channels = dice->rx_pcm_chs[index]; in limit_channels_and_rates()
101 hw->channels_min = UINT_MAX; in limit_channels_and_rates()
102 hw->channels_max = 0; in limit_channels_and_rates()
105 enum snd_dice_rate_mode mode; in limit_channels_and_rates() local
109 if (snd_dice_stream_get_rate_mode(dice, rate, &mode) < 0) in limit_channels_and_rates()
111 hw->rates |= snd_pcm_rate_to_rate_bit(rate); in limit_channels_and_rates()
113 channels = pcm_channels[mode]; in limit_channels_and_rates()
116 hw->channels_min = min(hw->channels_min, channels); in limit_channels_and_rates()
117 hw->channels_max = max(hw->channels_max, channels); in limit_channels_and_rates()
128 struct snd_pcm_runtime *runtime = substream->runtime; in init_hw_info()
129 struct snd_pcm_hardware *hw = &runtime->hw; in init_hw_info()
130 unsigned int index = substream->pcm->device; in init_hw_info()
135 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in init_hw_info()
136 hw->formats = AM824_IN_PCM_FORMAT_BITS; in init_hw_info()
138 stream = &dice->tx_stream[index]; in init_hw_info()
140 hw->formats = AM824_OUT_PCM_FORMAT_BITS; in init_hw_info()
142 stream = &dice->rx_stream[index]; in init_hw_info()
145 err = limit_channels_and_rates(dice, substream->runtime, dir, in init_hw_info()
152 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in init_hw_info()
157 SNDRV_PCM_HW_PARAM_RATE, -1); in init_hw_info()
166 struct snd_dice *dice = substream->private_data; in pcm_open()
167 struct amdtp_domain *d = &dice->domain; in pcm_open()
199 mutex_lock(&dice->mutex); in pcm_open()
201 // When source of clock is not internal or any stream is reserved for in pcm_open()
202 // transmission of PCM frames, the available sampling rate is limited in pcm_open()
205 (dice->substreams_counter > 0 && d->events_per_period > 0)) { in pcm_open()
206 unsigned int frames_per_period = d->events_per_period; in pcm_open()
207 unsigned int frames_per_buffer = d->events_per_buffer; in pcm_open()
212 mutex_unlock(&dice->mutex); in pcm_open()
216 substream->runtime->hw.rate_min = rate; in pcm_open()
217 substream->runtime->hw.rate_max = rate; in pcm_open()
221 if (rate > 96000 && !dice->disable_double_pcm_frames) { in pcm_open()
226 err = snd_pcm_hw_constraint_minmax(substream->runtime, in pcm_open()
230 mutex_unlock(&dice->mutex); in pcm_open()
234 err = snd_pcm_hw_constraint_minmax(substream->runtime, in pcm_open()
238 mutex_unlock(&dice->mutex); in pcm_open()
244 mutex_unlock(&dice->mutex); in pcm_open()
256 struct snd_dice *dice = substream->private_data; in pcm_close()
266 struct snd_dice *dice = substream->private_data; in pcm_hw_params()
269 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN) { in pcm_hw_params()
274 mutex_lock(&dice->mutex); in pcm_hw_params()
276 if (rate > 96000 && !dice->disable_double_pcm_frames) { in pcm_hw_params()
283 ++dice->substreams_counter; in pcm_hw_params()
284 mutex_unlock(&dice->mutex); in pcm_hw_params()
292 struct snd_dice *dice = substream->private_data; in pcm_hw_free()
294 mutex_lock(&dice->mutex); in pcm_hw_free()
296 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in pcm_hw_free()
297 --dice->substreams_counter; in pcm_hw_free()
301 mutex_unlock(&dice->mutex); in pcm_hw_free()
308 struct snd_dice *dice = substream->private_data; in capture_prepare()
309 struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device]; in capture_prepare()
312 mutex_lock(&dice->mutex); in capture_prepare()
314 mutex_unlock(&dice->mutex); in capture_prepare()
322 struct snd_dice *dice = substream->private_data; in playback_prepare()
323 struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device]; in playback_prepare()
326 mutex_lock(&dice->mutex); in playback_prepare()
328 mutex_unlock(&dice->mutex); in playback_prepare()
337 struct snd_dice *dice = substream->private_data; in capture_trigger()
338 struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device]; in capture_trigger()
348 return -EINVAL; in capture_trigger()
355 struct snd_dice *dice = substream->private_data; in playback_trigger()
356 struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device]; in playback_trigger()
366 return -EINVAL; in playback_trigger()
374 struct snd_dice *dice = substream->private_data; in capture_pointer()
375 struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device]; in capture_pointer()
377 return amdtp_domain_stream_pcm_pointer(&dice->domain, stream); in capture_pointer()
381 struct snd_dice *dice = substream->private_data; in playback_pointer()
382 struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device]; in playback_pointer()
384 return amdtp_domain_stream_pcm_pointer(&dice->domain, stream); in playback_pointer()
389 struct snd_dice *dice = substream->private_data; in capture_ack()
390 struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device]; in capture_ack()
392 return amdtp_domain_stream_pcm_ack(&dice->domain, stream); in capture_ack()
397 struct snd_dice *dice = substream->private_data; in playback_ack()
398 struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device]; in playback_ack()
400 return amdtp_domain_stream_pcm_ack(&dice->domain, stream); in playback_ack()
425 struct snd_pcm *pcm; in snd_dice_create_pcm() local
433 if (dice->tx_pcm_chs[i][j] > 0) in snd_dice_create_pcm()
435 if (dice->rx_pcm_chs[i][j] > 0) in snd_dice_create_pcm()
439 err = snd_pcm_new(dice->card, "DICE", i, playback, capture, in snd_dice_create_pcm()
440 &pcm); in snd_dice_create_pcm()
443 pcm->private_data = dice; in snd_dice_create_pcm()
444 pcm->nonatomic = true; in snd_dice_create_pcm()
445 strcpy(pcm->name, dice->card->shortname); in snd_dice_create_pcm()
448 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, in snd_dice_create_pcm()
452 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, in snd_dice_create_pcm()
455 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, in snd_dice_create_pcm()