Lines Matching full:dai

3 // soc-dai.c
10 #include <sound/soc-dai.h>
13 #define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret) argument
14 static inline int _soc_dai_ret(struct snd_soc_dai *dai, in _soc_dai_ret() argument
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) argument
40 #define soc_dai_mark_pop(dai, substream, tgt) ((dai)->mark_##tgt = NULL) argument
41 #define soc_dai_mark_match(dai, substream, tgt) ((dai)->mark_##tgt == substream) argument
44 * snd_soc_dai_set_sysclk - configure DAI system or master clock.
45 * @dai: DAI
46 * @clk_id: DAI specific clock ID
50 * Configures the DAI master (MCLK) or system (SYSCLK) clocking.
52 int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, in snd_soc_dai_set_sysclk() argument
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()
64 return soc_dai_ret(dai, ret); in snd_soc_dai_set_sysclk()
69 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
70 * @dai: DAI
71 * @div_id: DAI specific clock divider ID
74 * Configures the clock dividers. This is used to derive the best DAI bit and
75 * frame clocks from the system or master clock. It's best to set the DAI bit
78 int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, in snd_soc_dai_set_clkdiv() argument
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()
87 return soc_dai_ret(dai, ret); in snd_soc_dai_set_clkdiv()
92 * snd_soc_dai_set_pll - configure DAI PLL.
93 * @dai: DAI
94 * @pll_id: DAI specific PLL ID
95 * @source: DAI specific source for the PLL
101 int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, in snd_soc_dai_set_pll() argument
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()
114 return soc_dai_ret(dai, ret); in snd_soc_dai_set_pll()
120 * @dai: DAI
123 * Configures the DAI for a preset BCLK to sample rate ratio.
125 int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) in snd_soc_dai_set_bclk_ratio() argument
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()
133 return soc_dai_ret(dai, ret); in snd_soc_dai_set_bclk_ratio()
139 struct snd_soc_dai *dai; in snd_soc_dai_get_fmt_max_priority() local
145 for_each_rtd_dais(rtd, i, dai) { in snd_soc_dai_get_fmt_max_priority()
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()
158 * @dai: DAI
162 * quality by the DAI so that the core can configure a
169 u64 snd_soc_dai_get_fmt(struct snd_soc_dai *dai, int priority) in snd_soc_dai_get_fmt() argument
171 const struct snd_soc_dai_ops *ops = dai->driver->ops; in snd_soc_dai_get_fmt()
201 * snd_soc_dai_set_fmt - configure DAI hardware audio format.
202 * @dai: DAI
205 * Configures the DAI hardware format and clocking.
207 int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) in snd_soc_dai_set_fmt() argument
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()
214 return soc_dai_ret(dai, ret); in snd_soc_dai_set_fmt()
224 * Generates the TDM tx and rx slot default masks for DAI.
243 * snd_soc_dai_set_tdm_slot() - Configures a DAI for TDM operation
244 * @dai: The DAI to configure
250 * This function configures the specified DAI for TDM operation. @slot contains
253 * active slots of the TDM stream for the specified DAI, i.e. which slots the
254 * DAI should write to or read from. If a bit is set the corresponding slot is
257 * maps to the first channel of the DAI, the second active slot to the second
265 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, in snd_soc_dai_set_tdm_slot() argument
271 if (dai->driver->ops && in snd_soc_dai_set_tdm_slot()
272 dai->driver->ops->xlate_tdm_slot_mask) in snd_soc_dai_set_tdm_slot()
273 dai->driver->ops->xlate_tdm_slot_mask(slots, in snd_soc_dai_set_tdm_slot()
278 dai->tx_mask = tx_mask; in snd_soc_dai_set_tdm_slot()
279 dai->rx_mask = rx_mask; in snd_soc_dai_set_tdm_slot()
281 if (dai->driver->ops && in snd_soc_dai_set_tdm_slot()
282 dai->driver->ops->set_tdm_slot) in snd_soc_dai_set_tdm_slot()
283 ret = dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask, in snd_soc_dai_set_tdm_slot()
285 return soc_dai_ret(dai, ret); in snd_soc_dai_set_tdm_slot()
290 * snd_soc_dai_set_channel_map - configure DAI audio channel map
291 * @dai: DAI
301 int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, in snd_soc_dai_set_channel_map() argument
307 if (dai->driver->ops && in snd_soc_dai_set_channel_map()
308 dai->driver->ops->set_channel_map) in snd_soc_dai_set_channel_map()
309 ret = dai->driver->ops->set_channel_map(dai, tx_num, tx_slot, in snd_soc_dai_set_channel_map()
311 return soc_dai_ret(dai, ret); in snd_soc_dai_set_channel_map()
316 * snd_soc_dai_get_channel_map - Get DAI audio channel map
317 * @dai: DAI
325 int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai, in snd_soc_dai_get_channel_map() argument
331 if (dai->driver->ops && in snd_soc_dai_get_channel_map()
332 dai->driver->ops->get_channel_map) in snd_soc_dai_get_channel_map()
333 ret = dai->driver->ops->get_channel_map(dai, tx_num, tx_slot, in snd_soc_dai_get_channel_map()
335 return soc_dai_ret(dai, ret); in snd_soc_dai_get_channel_map()
340 * snd_soc_dai_set_tristate - configure DAI system or master clock.
341 * @dai: DAI
344 * Tristates the DAI so that others can use it.
346 int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) in snd_soc_dai_set_tristate() argument
350 if (dai->driver->ops && in snd_soc_dai_set_tristate()
351 dai->driver->ops->set_tristate) in snd_soc_dai_set_tristate()
352 ret = dai->driver->ops->set_tristate(dai, tristate); in snd_soc_dai_set_tristate()
354 return soc_dai_ret(dai, ret); in snd_soc_dai_set_tristate()
359 * snd_soc_dai_digital_mute - configure DAI system or master clock.
360 * @dai: DAI
364 * Mutes the DAI DAC.
366 int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, in snd_soc_dai_digital_mute() argument
375 if (dai->driver->ops && in snd_soc_dai_digital_mute()
376 dai->driver->ops->mute_stream && in snd_soc_dai_digital_mute()
378 !dai->driver->ops->no_capture_mute)) in snd_soc_dai_digital_mute()
379 ret = dai->driver->ops->mute_stream(dai, mute, direction); in snd_soc_dai_digital_mute()
381 return soc_dai_ret(dai, ret); in snd_soc_dai_digital_mute()
385 int snd_soc_dai_hw_params(struct snd_soc_dai *dai, in snd_soc_dai_hw_params() argument
392 if (dai->driver->ops && in snd_soc_dai_hw_params()
393 dai->driver->ops->hw_params) { in snd_soc_dai_hw_params()
394 /* perform any topology hw_params fixups before DAI */ in snd_soc_dai_hw_params()
399 ret = dai->driver->ops->hw_params(substream, params, dai); in snd_soc_dai_hw_params()
404 soc_dai_mark_push(dai, substream, hw_params); in snd_soc_dai_hw_params()
406 return soc_dai_ret(dai, ret); in snd_soc_dai_hw_params()
409 void snd_soc_dai_hw_free(struct snd_soc_dai *dai, in snd_soc_dai_hw_free() argument
413 if (rollback && !soc_dai_mark_match(dai, substream, hw_params)) in snd_soc_dai_hw_free()
416 if (dai->driver->ops && in snd_soc_dai_hw_free()
417 dai->driver->ops->hw_free) in snd_soc_dai_hw_free()
418 dai->driver->ops->hw_free(substream, dai); in snd_soc_dai_hw_free()
421 soc_dai_mark_pop(dai, substream, hw_params); in snd_soc_dai_hw_free()
424 int snd_soc_dai_startup(struct snd_soc_dai *dai, in snd_soc_dai_startup() argument
429 if (dai->driver->ops && in snd_soc_dai_startup()
430 dai->driver->ops->startup) in snd_soc_dai_startup()
431 ret = dai->driver->ops->startup(substream, dai); in snd_soc_dai_startup()
435 soc_dai_mark_push(dai, substream, startup); in snd_soc_dai_startup()
437 return soc_dai_ret(dai, ret); in snd_soc_dai_startup()
440 void snd_soc_dai_shutdown(struct snd_soc_dai *dai, in snd_soc_dai_shutdown() argument
444 if (rollback && !soc_dai_mark_match(dai, substream, startup)) in snd_soc_dai_shutdown()
447 if (dai->driver->ops && in snd_soc_dai_shutdown()
448 dai->driver->ops->shutdown) in snd_soc_dai_shutdown()
449 dai->driver->ops->shutdown(substream, dai); in snd_soc_dai_shutdown()
452 soc_dai_mark_pop(dai, substream, startup); in snd_soc_dai_shutdown()
455 int snd_soc_dai_compress_new(struct snd_soc_dai *dai, in snd_soc_dai_compress_new() argument
459 if (dai->driver->compress_new) in snd_soc_dai_compress_new()
460 ret = dai->driver->compress_new(rtd, num); in snd_soc_dai_compress_new()
461 return soc_dai_ret(dai, ret); in snd_soc_dai_compress_new()
465 * snd_soc_dai_stream_valid() - check if a DAI supports the given stream
467 * Returns true if the DAI supports the indicated stream type.
469 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir) in snd_soc_dai_stream_valid() argument
471 struct snd_soc_pcm_stream *stream = snd_soc_dai_get_pcm_stream(dai, dir); in snd_soc_dai_stream_valid()
488 struct snd_soc_dai *dai; in snd_soc_dai_link_set_capabilities() local
494 dai = snd_soc_find_dai_with_mutex(cpu); in snd_soc_dai_link_set_capabilities()
495 if (dai && snd_soc_dai_stream_valid(dai, direction)) { in snd_soc_dai_link_set_capabilities()
501 dai = snd_soc_find_dai_with_mutex(codec); in snd_soc_dai_link_set_capabilities()
502 if (dai && snd_soc_dai_stream_valid(dai, direction)) { in snd_soc_dai_link_set_capabilities()
515 void snd_soc_dai_action(struct snd_soc_dai *dai, in snd_soc_dai_action() argument
519 dai->stream_active[stream] += action; in snd_soc_dai_action()
522 dai->component->active += action; in snd_soc_dai_action()
526 int snd_soc_dai_active(struct snd_soc_dai *dai) in snd_soc_dai_active() argument
532 active += dai->stream_active[stream]; in snd_soc_dai_active()
540 struct snd_soc_dai *dai; in snd_soc_pcm_dai_probe() local
543 for_each_rtd_dais(rtd, i, dai) { in snd_soc_pcm_dai_probe()
544 if (dai->driver->probe_order != order) in snd_soc_pcm_dai_probe()
547 if (dai->driver->probe) { in snd_soc_pcm_dai_probe()
548 int ret = dai->driver->probe(dai); in snd_soc_pcm_dai_probe()
551 return soc_dai_ret(dai, ret); in snd_soc_pcm_dai_probe()
554 dai->probed = 1; in snd_soc_pcm_dai_probe()
562 struct snd_soc_dai *dai; in snd_soc_pcm_dai_remove() local
565 for_each_rtd_dais(rtd, i, dai) { in snd_soc_pcm_dai_remove()
566 if (dai->driver->remove_order != order) in snd_soc_pcm_dai_remove()
569 if (dai->probed && in snd_soc_pcm_dai_remove()
570 dai->driver->remove) { in snd_soc_pcm_dai_remove()
571 r = dai->driver->remove(dai); in snd_soc_pcm_dai_remove()
576 dai->probed = 0; in snd_soc_pcm_dai_remove()
584 struct snd_soc_dai *dai; in snd_soc_pcm_dai_new() local
587 for_each_rtd_dais(rtd, i, dai) { in snd_soc_pcm_dai_new()
588 if (dai->driver->pcm_new) { in snd_soc_pcm_dai_new()
589 int ret = dai->driver->pcm_new(rtd, dai); in snd_soc_pcm_dai_new()
591 return soc_dai_ret(dai, ret); in snd_soc_pcm_dai_new()
601 struct snd_soc_dai *dai; in snd_soc_pcm_dai_prepare() local
604 for_each_rtd_dais(rtd, i, dai) { in snd_soc_pcm_dai_prepare()
605 if (dai->driver->ops && in snd_soc_pcm_dai_prepare()
606 dai->driver->ops->prepare) { in snd_soc_pcm_dai_prepare()
607 ret = dai->driver->ops->prepare(substream, dai); in snd_soc_pcm_dai_prepare()
609 return soc_dai_ret(dai, ret); in snd_soc_pcm_dai_prepare()
616 static int soc_dai_trigger(struct snd_soc_dai *dai, in soc_dai_trigger() argument
621 if (dai->driver->ops && in soc_dai_trigger()
622 dai->driver->ops->trigger) in soc_dai_trigger()
623 ret = dai->driver->ops->trigger(substream, cmd, dai); in soc_dai_trigger()
625 return soc_dai_ret(dai, ret); in soc_dai_trigger()
632 struct snd_soc_dai *dai; in snd_soc_pcm_dai_trigger() local
639 for_each_rtd_dais(rtd, i, dai) { in snd_soc_pcm_dai_trigger()
640 ret = soc_dai_trigger(dai, substream, cmd); in snd_soc_pcm_dai_trigger()
643 soc_dai_mark_push(dai, substream, trigger); in snd_soc_pcm_dai_trigger()
649 for_each_rtd_dais(rtd, i, dai) { in snd_soc_pcm_dai_trigger()
650 if (rollback && !soc_dai_mark_match(dai, substream, trigger)) in snd_soc_pcm_dai_trigger()
653 r = soc_dai_trigger(dai, substream, cmd); in snd_soc_pcm_dai_trigger()
656 soc_dai_mark_pop(dai, substream, trigger); in snd_soc_pcm_dai_trigger()
667 struct snd_soc_dai *dai; in snd_soc_pcm_dai_bespoke_trigger() local
670 for_each_rtd_dais(rtd, i, dai) { in snd_soc_pcm_dai_bespoke_trigger()
671 if (dai->driver->ops && in snd_soc_pcm_dai_bespoke_trigger()
672 dai->driver->ops->bespoke_trigger) { in snd_soc_pcm_dai_bespoke_trigger()
673 ret = dai->driver->ops->bespoke_trigger(substream, in snd_soc_pcm_dai_bespoke_trigger()
674 cmd, dai); in snd_soc_pcm_dai_bespoke_trigger()
676 return soc_dai_ret(dai, ret); in snd_soc_pcm_dai_bespoke_trigger()
688 struct snd_soc_dai *dai; in snd_soc_pcm_dai_delay() local
699 for_each_rtd_cpu_dais(rtd, i, dai) in snd_soc_pcm_dai_delay()
700 if (dai->driver->ops && in snd_soc_pcm_dai_delay()
701 dai->driver->ops->delay) in snd_soc_pcm_dai_delay()
702 *cpu_delay = max(*cpu_delay, dai->driver->ops->delay(substream, dai)); in snd_soc_pcm_dai_delay()
705 for_each_rtd_codec_dais(rtd, i, dai) in snd_soc_pcm_dai_delay()
706 if (dai->driver->ops && in snd_soc_pcm_dai_delay()
707 dai->driver->ops->delay) in snd_soc_pcm_dai_delay()
708 *codec_delay = max(*codec_delay, dai->driver->ops->delay(substream, dai)); in snd_soc_pcm_dai_delay()
711 int snd_soc_dai_compr_startup(struct snd_soc_dai *dai, in snd_soc_dai_compr_startup() argument
716 if (dai->driver->cops && in snd_soc_dai_compr_startup()
717 dai->driver->cops->startup) in snd_soc_dai_compr_startup()
718 ret = dai->driver->cops->startup(cstream, dai); in snd_soc_dai_compr_startup()
722 soc_dai_mark_push(dai, cstream, compr_startup); in snd_soc_dai_compr_startup()
724 return soc_dai_ret(dai, ret); in snd_soc_dai_compr_startup()
728 void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai, in snd_soc_dai_compr_shutdown() argument
732 if (rollback && !soc_dai_mark_match(dai, cstream, compr_startup)) in snd_soc_dai_compr_shutdown()
735 if (dai->driver->cops && in snd_soc_dai_compr_shutdown()
736 dai->driver->cops->shutdown) in snd_soc_dai_compr_shutdown()
737 dai->driver->cops->shutdown(cstream, dai); in snd_soc_dai_compr_shutdown()
740 soc_dai_mark_pop(dai, cstream, compr_startup); in snd_soc_dai_compr_shutdown()
744 int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai, in snd_soc_dai_compr_trigger() argument
749 if (dai->driver->cops && in snd_soc_dai_compr_trigger()
750 dai->driver->cops->trigger) in snd_soc_dai_compr_trigger()
751 ret = dai->driver->cops->trigger(cstream, cmd, dai); in snd_soc_dai_compr_trigger()
753 return soc_dai_ret(dai, ret); in snd_soc_dai_compr_trigger()
757 int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai, in snd_soc_dai_compr_set_params() argument
763 if (dai->driver->cops && in snd_soc_dai_compr_set_params()
764 dai->driver->cops->set_params) in snd_soc_dai_compr_set_params()
765 ret = dai->driver->cops->set_params(cstream, params, dai); in snd_soc_dai_compr_set_params()
767 return soc_dai_ret(dai, ret); in snd_soc_dai_compr_set_params()
771 int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai, in snd_soc_dai_compr_get_params() argument
777 if (dai->driver->cops && in snd_soc_dai_compr_get_params()
778 dai->driver->cops->get_params) in snd_soc_dai_compr_get_params()
779 ret = dai->driver->cops->get_params(cstream, params, dai); in snd_soc_dai_compr_get_params()
781 return soc_dai_ret(dai, ret); in snd_soc_dai_compr_get_params()
785 int snd_soc_dai_compr_ack(struct snd_soc_dai *dai, in snd_soc_dai_compr_ack() argument
791 if (dai->driver->cops && in snd_soc_dai_compr_ack()
792 dai->driver->cops->ack) in snd_soc_dai_compr_ack()
793 ret = dai->driver->cops->ack(cstream, bytes, dai); in snd_soc_dai_compr_ack()
795 return soc_dai_ret(dai, ret); in snd_soc_dai_compr_ack()
799 int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai, in snd_soc_dai_compr_pointer() argument
805 if (dai->driver->cops && in snd_soc_dai_compr_pointer()
806 dai->driver->cops->pointer) in snd_soc_dai_compr_pointer()
807 ret = dai->driver->cops->pointer(cstream, tstamp, dai); in snd_soc_dai_compr_pointer()
809 return soc_dai_ret(dai, ret); in snd_soc_dai_compr_pointer()
813 int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai, in snd_soc_dai_compr_set_metadata() argument
819 if (dai->driver->cops && in snd_soc_dai_compr_set_metadata()
820 dai->driver->cops->set_metadata) in snd_soc_dai_compr_set_metadata()
821 ret = dai->driver->cops->set_metadata(cstream, metadata, dai); in snd_soc_dai_compr_set_metadata()
823 return soc_dai_ret(dai, ret); in snd_soc_dai_compr_set_metadata()
827 int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai, in snd_soc_dai_compr_get_metadata() argument
833 if (dai->driver->cops && in snd_soc_dai_compr_get_metadata()
834 dai->driver->cops->get_metadata) in snd_soc_dai_compr_get_metadata()
835 ret = dai->driver->cops->get_metadata(cstream, metadata, dai); in snd_soc_dai_compr_get_metadata()
837 return soc_dai_ret(dai, ret); in snd_soc_dai_compr_get_metadata()