Lines Matching +full:link +full:- +full:trigger +full:- +full:order
1 // SPDX-License-Identifier: GPL-2.0
3 // soc-dai.c
10 #include <sound/soc-dai.h>
11 #include <sound/soc-link.h>
23 case -EPROBE_DEFER: in _soc_dai_ret()
24 case -ENOTSUPP: in _soc_dai_ret()
27 dev_err(dai->dev, in _soc_dai_ret()
29 func, dai->name, ret); in _soc_dai_ret()
39 #define soc_dai_mark_push(dai, substream, tgt) ((dai)->mark_##tgt = substream)
40 #define soc_dai_mark_pop(dai, tgt) ((dai)->mark_##tgt = NULL)
41 #define soc_dai_mark_match(dai, substream, tgt) ((dai)->mark_##tgt == substream)
44 * snd_soc_dai_set_sysclk - configure DAI system or master clock.
57 if (dai->driver->ops && in snd_soc_dai_set_sysclk()
58 dai->driver->ops->set_sysclk) in snd_soc_dai_set_sysclk()
59 ret = dai->driver->ops->set_sysclk(dai, clk_id, freq, dir); in snd_soc_dai_set_sysclk()
61 ret = snd_soc_component_set_sysclk(dai->component, clk_id, 0, in snd_soc_dai_set_sysclk()
69 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
81 int ret = -EINVAL; in snd_soc_dai_set_clkdiv()
83 if (dai->driver->ops && in snd_soc_dai_set_clkdiv()
84 dai->driver->ops->set_clkdiv) in snd_soc_dai_set_clkdiv()
85 ret = dai->driver->ops->set_clkdiv(dai, div_id, div); in snd_soc_dai_set_clkdiv()
92 * snd_soc_dai_set_pll - configure DAI PLL.
106 if (dai->driver->ops && in snd_soc_dai_set_pll()
107 dai->driver->ops->set_pll) in snd_soc_dai_set_pll()
108 ret = dai->driver->ops->set_pll(dai, pll_id, source, in snd_soc_dai_set_pll()
111 ret = snd_soc_component_set_pll(dai->component, pll_id, source, in snd_soc_dai_set_pll()
119 * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio.
127 int ret = -ENOTSUPP; in snd_soc_dai_set_bclk_ratio()
129 if (dai->driver->ops && in snd_soc_dai_set_bclk_ratio()
130 dai->driver->ops->set_bclk_ratio) in snd_soc_dai_set_bclk_ratio()
131 ret = dai->driver->ops->set_bclk_ratio(dai, ratio); in snd_soc_dai_set_bclk_ratio()
146 if (dai->driver->ops && in snd_soc_dai_get_fmt_max_priority()
147 dai->driver->ops->num_auto_selectable_formats) in snd_soc_dai_get_fmt_max_priority()
148 max = max(max, dai->driver->ops->num_auto_selectable_formats); in snd_soc_dai_get_fmt_max_priority()
157 * snd_soc_dai_get_fmt - get supported audio format.
171 const struct snd_soc_dai_ops *ops = dai->driver->ops; in snd_soc_dai_get_fmt()
189 max = ops->num_auto_selectable_formats; in snd_soc_dai_get_fmt()
195 fmt |= ops->auto_selectable_formats[i]; in snd_soc_dai_get_fmt()
201 * snd_soc_dai_set_fmt - configure DAI hardware audio format.
209 int ret = -ENOTSUPP; in snd_soc_dai_set_fmt()
211 if (dai->driver->ops && dai->driver->ops->set_fmt) in snd_soc_dai_set_fmt()
212 ret = dai->driver->ops->set_fmt(dai, fmt); in snd_soc_dai_set_fmt()
219 * snd_soc_xlate_tdm_slot_mask - generate tx/rx slot mask.
234 return -EINVAL; in snd_soc_xlate_tdm_slot_mask()
236 *tx_mask = (1 << slots) - 1; in snd_soc_xlate_tdm_slot_mask()
237 *rx_mask = (1 << slots) - 1; in snd_soc_xlate_tdm_slot_mask()
243 * snd_soc_dai_set_tdm_slot() - Configures a DAI for TDM operation
269 int ret = -ENOTSUPP; in snd_soc_dai_set_tdm_slot()
276 if (dai->driver->ops && in snd_soc_dai_set_tdm_slot()
277 dai->driver->ops->xlate_tdm_slot_mask) in snd_soc_dai_set_tdm_slot()
278 dai->driver->ops->xlate_tdm_slot_mask(slots, in snd_soc_dai_set_tdm_slot()
286 if (dai->driver->ops && in snd_soc_dai_set_tdm_slot()
287 dai->driver->ops->set_tdm_slot) in snd_soc_dai_set_tdm_slot()
288 ret = dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask, in snd_soc_dai_set_tdm_slot()
295 * snd_soc_dai_set_channel_map - configure DAI audio channel map
299 * 0~num-1 uses
302 * 0~num-1 uses
310 int ret = -ENOTSUPP; in snd_soc_dai_set_channel_map()
312 if (dai->driver->ops && in snd_soc_dai_set_channel_map()
313 dai->driver->ops->set_channel_map) in snd_soc_dai_set_channel_map()
314 ret = dai->driver->ops->set_channel_map(dai, tx_num, tx_slot, in snd_soc_dai_set_channel_map()
321 * snd_soc_dai_get_channel_map - Get DAI audio channel map
325 * 0~num-1 uses
328 * 0~num-1 uses
334 int ret = -ENOTSUPP; in snd_soc_dai_get_channel_map()
336 if (dai->driver->ops && in snd_soc_dai_get_channel_map()
337 dai->driver->ops->get_channel_map) in snd_soc_dai_get_channel_map()
338 ret = dai->driver->ops->get_channel_map(dai, tx_num, tx_slot, in snd_soc_dai_get_channel_map()
345 * snd_soc_dai_set_tristate - configure DAI system or master clock.
353 int ret = -EINVAL; in snd_soc_dai_set_tristate()
355 if (dai->driver->ops && in snd_soc_dai_set_tristate()
356 dai->driver->ops->set_tristate) in snd_soc_dai_set_tristate()
357 ret = dai->driver->ops->set_tristate(dai, tristate); in snd_soc_dai_set_tristate()
364 * snd_soc_dai_digital_mute - configure DAI system or master clock.
374 int ret = -ENOTSUPP; in snd_soc_dai_digital_mute()
380 if (dai->driver->ops && in snd_soc_dai_digital_mute()
381 dai->driver->ops->mute_stream && in snd_soc_dai_digital_mute()
383 !dai->driver->ops->no_capture_mute)) in snd_soc_dai_digital_mute()
384 ret = dai->driver->ops->mute_stream(dai, mute, direction); in snd_soc_dai_digital_mute()
396 if (dai->driver->ops && in snd_soc_dai_hw_params()
397 dai->driver->ops->hw_params) in snd_soc_dai_hw_params()
398 ret = dai->driver->ops->hw_params(substream, params, dai); in snd_soc_dai_hw_params()
414 if (dai->driver->ops && in snd_soc_dai_hw_free()
415 dai->driver->ops->hw_free) in snd_soc_dai_hw_free()
416 dai->driver->ops->hw_free(substream, dai); in snd_soc_dai_hw_free()
427 if (!snd_soc_dai_stream_valid(dai, substream->stream)) in snd_soc_dai_startup()
430 if (dai->driver->ops && in snd_soc_dai_startup()
431 dai->driver->ops->startup) in snd_soc_dai_startup()
432 ret = dai->driver->ops->startup(substream, dai); in snd_soc_dai_startup()
445 if (!snd_soc_dai_stream_valid(dai, substream->stream)) in snd_soc_dai_shutdown()
451 if (dai->driver->ops && in snd_soc_dai_shutdown()
452 dai->driver->ops->shutdown) in snd_soc_dai_shutdown()
453 dai->driver->ops->shutdown(substream, dai); in snd_soc_dai_shutdown()
462 int ret = -ENOTSUPP; in snd_soc_dai_compress_new()
463 if (dai->driver->ops && in snd_soc_dai_compress_new()
464 dai->driver->ops->compress_new) in snd_soc_dai_compress_new()
465 ret = dai->driver->ops->compress_new(rtd); in snd_soc_dai_compress_new()
470 * snd_soc_dai_stream_valid() - check if a DAI supports the given stream
479 return stream->channels_min; in snd_soc_dai_stream_valid()
486 dai->stream[stream].active += action; in snd_soc_dai_action()
489 dai->component->active += action; in snd_soc_dai_action()
499 active += dai->stream[stream].active; in snd_soc_dai_active()
505 int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order) in snd_soc_pcm_dai_probe() argument
511 if (dai->probed) in snd_soc_pcm_dai_probe()
514 if (dai->driver->ops) { in snd_soc_pcm_dai_probe()
515 if (dai->driver->ops->probe_order != order) in snd_soc_pcm_dai_probe()
518 if (dai->driver->ops->probe) { in snd_soc_pcm_dai_probe()
519 int ret = dai->driver->ops->probe(dai); in snd_soc_pcm_dai_probe()
525 dai->probed = 1; in snd_soc_pcm_dai_probe()
531 int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order) in snd_soc_pcm_dai_remove() argument
537 if (!dai->probed) in snd_soc_pcm_dai_remove()
540 if (dai->driver->ops) { in snd_soc_pcm_dai_remove()
541 if (dai->driver->ops->remove_order != order) in snd_soc_pcm_dai_remove()
544 if (dai->driver->ops->remove) { in snd_soc_pcm_dai_remove()
545 r = dai->driver->ops->remove(dai); in snd_soc_pcm_dai_remove()
550 dai->probed = 0; in snd_soc_pcm_dai_remove()
562 if (dai->driver->ops && in snd_soc_pcm_dai_new()
563 dai->driver->ops->pcm_new) { in snd_soc_pcm_dai_new()
564 int ret = dai->driver->ops->pcm_new(rtd, dai); in snd_soc_pcm_dai_new()
580 if (!snd_soc_dai_stream_valid(dai, substream->stream)) in snd_soc_pcm_dai_prepare()
582 if (dai->driver->ops && in snd_soc_pcm_dai_prepare()
583 dai->driver->ops->prepare) { in snd_soc_pcm_dai_prepare()
584 ret = dai->driver->ops->prepare(substream, dai); in snd_soc_pcm_dai_prepare()
598 if (!snd_soc_dai_stream_valid(dai, substream->stream)) in soc_dai_trigger()
601 if (dai->driver->ops && in soc_dai_trigger()
602 dai->driver->ops->trigger) in soc_dai_trigger()
603 ret = dai->driver->ops->trigger(substream, cmd, dai); in soc_dai_trigger()
624 if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger) in snd_soc_pcm_dai_trigger()
625 snd_soc_dai_digital_mute(dai, 0, substream->stream); in snd_soc_pcm_dai_trigger()
627 soc_dai_mark_push(dai, substream, trigger); in snd_soc_pcm_dai_trigger()
634 if (rollback && !soc_dai_mark_match(dai, substream, trigger)) in snd_soc_pcm_dai_trigger()
637 if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger) in snd_soc_pcm_dai_trigger()
638 snd_soc_dai_digital_mute(dai, 1, substream->stream); in snd_soc_pcm_dai_trigger()
643 soc_dai_mark_pop(dai, trigger); in snd_soc_pcm_dai_trigger()
667 if (dai->driver->ops && in snd_soc_pcm_dai_delay()
668 dai->driver->ops->delay) in snd_soc_pcm_dai_delay()
669 *cpu_delay = max(*cpu_delay, dai->driver->ops->delay(substream, dai)); in snd_soc_pcm_dai_delay()
673 if (dai->driver->ops && in snd_soc_pcm_dai_delay()
674 dai->driver->ops->delay) in snd_soc_pcm_dai_delay()
675 *codec_delay = max(*codec_delay, dai->driver->ops->delay(substream, dai)); in snd_soc_pcm_dai_delay()
683 if (dai->driver->cops && in snd_soc_dai_compr_startup()
684 dai->driver->cops->startup) in snd_soc_dai_compr_startup()
685 ret = dai->driver->cops->startup(cstream, dai); in snd_soc_dai_compr_startup()
702 if (dai->driver->cops && in snd_soc_dai_compr_shutdown()
703 dai->driver->cops->shutdown) in snd_soc_dai_compr_shutdown()
704 dai->driver->cops->shutdown(cstream, dai); in snd_soc_dai_compr_shutdown()
716 if (dai->driver->cops && in snd_soc_dai_compr_trigger()
717 dai->driver->cops->trigger) in snd_soc_dai_compr_trigger()
718 ret = dai->driver->cops->trigger(cstream, cmd, dai); in snd_soc_dai_compr_trigger()
730 if (dai->driver->cops && in snd_soc_dai_compr_set_params()
731 dai->driver->cops->set_params) in snd_soc_dai_compr_set_params()
732 ret = dai->driver->cops->set_params(cstream, params, dai); in snd_soc_dai_compr_set_params()
744 if (dai->driver->cops && in snd_soc_dai_compr_get_params()
745 dai->driver->cops->get_params) in snd_soc_dai_compr_get_params()
746 ret = dai->driver->cops->get_params(cstream, params, dai); in snd_soc_dai_compr_get_params()
758 if (dai->driver->cops && in snd_soc_dai_compr_ack()
759 dai->driver->cops->ack) in snd_soc_dai_compr_ack()
760 ret = dai->driver->cops->ack(cstream, bytes, dai); in snd_soc_dai_compr_ack()
772 if (dai->driver->cops && in snd_soc_dai_compr_pointer()
773 dai->driver->cops->pointer) in snd_soc_dai_compr_pointer()
774 ret = dai->driver->cops->pointer(cstream, tstamp, dai); in snd_soc_dai_compr_pointer()
786 if (dai->driver->cops && in snd_soc_dai_compr_set_metadata()
787 dai->driver->cops->set_metadata) in snd_soc_dai_compr_set_metadata()
788 ret = dai->driver->cops->set_metadata(cstream, metadata, dai); in snd_soc_dai_compr_set_metadata()
800 if (dai->driver->cops && in snd_soc_dai_compr_get_metadata()
801 dai->driver->cops->get_metadata) in snd_soc_dai_compr_get_metadata()
802 ret = dai->driver->cops->get_metadata(cstream, metadata, dai); in snd_soc_dai_compr_get_metadata()