Lines Matching refs:dai
3 // soc-dai.c
10 #include <sound/soc-dai.h>
13 #define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret)
14 static inline int _soc_dai_ret(struct snd_soc_dai *dai,
27 dev_err(dai->dev,
29 func, dai->name, ret);
39 #define soc_dai_mark_push(dai, substream, tgt) ((dai)->mark_##tgt = substream)
40 #define soc_dai_mark_pop(dai, substream, tgt) ((dai)->mark_##tgt = NULL)
41 #define soc_dai_mark_match(dai, substream, tgt) ((dai)->mark_##tgt == substream)
45 * @dai: DAI
52 int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
57 if (dai->driver->ops &&
58 dai->driver->ops->set_sysclk)
59 ret = dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
61 ret = snd_soc_component_set_sysclk(dai->component, clk_id, 0,
64 return soc_dai_ret(dai, ret);
70 * @dai: DAI
78 int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
83 if (dai->driver->ops &&
84 dai->driver->ops->set_clkdiv)
85 ret = dai->driver->ops->set_clkdiv(dai, div_id, div);
87 return soc_dai_ret(dai, ret);
93 * @dai: DAI
101 int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
106 if (dai->driver->ops &&
107 dai->driver->ops->set_pll)
108 ret = dai->driver->ops->set_pll(dai, pll_id, source,
111 ret = snd_soc_component_set_pll(dai->component, pll_id, source,
114 return soc_dai_ret(dai, ret);
120 * @dai: DAI
125 int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
129 if (dai->driver->ops &&
130 dai->driver->ops->set_bclk_ratio)
131 ret = dai->driver->ops->set_bclk_ratio(dai, ratio);
133 return soc_dai_ret(dai, ret);
139 struct snd_soc_dai *dai;
145 for_each_rtd_dais(rtd, i, dai) {
146 if (dai->driver->ops &&
147 dai->driver->ops->num_auto_selectable_formats)
148 max = max(max, dai->driver->ops->num_auto_selectable_formats);
158 * @dai: DAI
169 u64 snd_soc_dai_get_fmt(struct snd_soc_dai *dai, int priority)
171 const struct snd_soc_dai_ops *ops = dai->driver->ops;
202 * @dai: DAI
207 int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
211 if (dai->driver->ops && dai->driver->ops->set_fmt)
212 ret = dai->driver->ops->set_fmt(dai, fmt);
214 return soc_dai_ret(dai, ret);
244 * @dai: The DAI to configure
265 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
276 if (dai->driver->ops &&
277 dai->driver->ops->xlate_tdm_slot_mask)
278 dai->driver->ops->xlate_tdm_slot_mask(slots,
284 snd_soc_dai_tdm_mask_set(dai, stream, *tdm_mask[stream]);
286 if (dai->driver->ops &&
287 dai->driver->ops->set_tdm_slot)
288 ret = dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
290 return soc_dai_ret(dai, ret);
296 * @dai: DAI
306 int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
312 if (dai->driver->ops &&
313 dai->driver->ops->set_channel_map)
314 ret = dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
316 return soc_dai_ret(dai, ret);
322 * @dai: DAI
330 int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai,
336 if (dai->driver->ops &&
337 dai->driver->ops->get_channel_map)
338 ret = dai->driver->ops->get_channel_map(dai, tx_num, tx_slot,
340 return soc_dai_ret(dai, ret);
346 * @dai: DAI
351 int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
355 if (dai->driver->ops &&
356 dai->driver->ops->set_tristate)
357 ret = dai->driver->ops->set_tristate(dai, tristate);
359 return soc_dai_ret(dai, ret);
365 * @dai: DAI
371 int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
380 if (dai->driver->ops &&
381 dai->driver->ops->mute_stream &&
383 !dai->driver->ops->no_capture_mute))
384 ret = dai->driver->ops->mute_stream(dai, mute, direction);
386 return soc_dai_ret(dai, ret);
390 int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
396 if (dai->driver->ops &&
397 dai->driver->ops->hw_params)
398 ret = dai->driver->ops->hw_params(substream, params, dai);
402 soc_dai_mark_push(dai, substream, hw_params);
404 return soc_dai_ret(dai, ret);
407 void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
411 if (rollback && !soc_dai_mark_match(dai, substream, hw_params))
414 if (dai->driver->ops &&
415 dai->driver->ops->hw_free)
416 dai->driver->ops->hw_free(substream, dai);
419 soc_dai_mark_pop(dai, substream, hw_params);
422 int snd_soc_dai_startup(struct snd_soc_dai *dai,
427 if (!snd_soc_dai_stream_valid(dai, substream->stream))
430 if (dai->driver->ops &&
431 dai->driver->ops->startup)
432 ret = dai->driver->ops->startup(substream, dai);
436 soc_dai_mark_push(dai, substream, startup);
438 return soc_dai_ret(dai, ret);
441 void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
445 if (!snd_soc_dai_stream_valid(dai, substream->stream))
448 if (rollback && !soc_dai_mark_match(dai, substream, startup))
451 if (dai->driver->ops &&
452 dai->driver->ops->shutdown)
453 dai->driver->ops->shutdown(substream, dai);
456 soc_dai_mark_pop(dai, substream, startup);
459 int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
463 if (dai->driver->ops &&
464 dai->driver->ops->compress_new)
465 ret = dai->driver->ops->compress_new(rtd, num);
466 return soc_dai_ret(dai, ret);
474 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
476 struct snd_soc_pcm_stream *stream = snd_soc_dai_get_pcm_stream(dai, dir);
493 struct snd_soc_dai *dai;
499 dai = snd_soc_find_dai_with_mutex(cpu);
500 if (dai && snd_soc_dai_stream_valid(dai, direction)) {
506 dai = snd_soc_find_dai_with_mutex(codec);
507 if (dai && snd_soc_dai_stream_valid(dai, direction)) {
520 void snd_soc_dai_action(struct snd_soc_dai *dai,
524 dai->stream[stream].active += action;
527 dai->component->active += action;
531 int snd_soc_dai_active(struct snd_soc_dai *dai)
537 active += dai->stream[stream].active;
545 struct snd_soc_dai *dai;
548 for_each_rtd_dais(rtd, i, dai) {
549 if (dai->probed)
552 if (dai->driver->ops) {
553 if (dai->driver->ops->probe_order != order)
556 if (dai->driver->ops->probe) {
557 int ret = dai->driver->ops->probe(dai);
560 return soc_dai_ret(dai, ret);
563 dai->probed = 1;
571 struct snd_soc_dai *dai;
574 for_each_rtd_dais(rtd, i, dai) {
575 if (!dai->probed)
578 if (dai->driver->ops) {
579 if (dai->driver->ops->remove_order != order)
582 if (dai->driver->ops->remove) {
583 r = dai->driver->ops->remove(dai);
588 dai->probed = 0;
596 struct snd_soc_dai *dai;
599 for_each_rtd_dais(rtd, i, dai) {
600 if (dai->driver->ops &&
601 dai->driver->ops->pcm_new) {
602 int ret = dai->driver->ops->pcm_new(rtd, dai);
604 return soc_dai_ret(dai, ret);
614 struct snd_soc_dai *dai;
617 for_each_rtd_dais(rtd, i, dai) {
618 if (!snd_soc_dai_stream_valid(dai, substream->stream))
620 if (dai->driver->ops &&
621 dai->driver->ops->prepare) {
622 ret = dai->driver->ops->prepare(substream, dai);
624 return soc_dai_ret(dai, ret);
631 static int soc_dai_trigger(struct snd_soc_dai *dai,
636 if (!snd_soc_dai_stream_valid(dai, substream->stream))
639 if (dai->driver->ops &&
640 dai->driver->ops->trigger)
641 ret = dai->driver->ops->trigger(substream, cmd, dai);
643 return soc_dai_ret(dai, ret);
650 struct snd_soc_dai *dai;
657 for_each_rtd_dais(rtd, i, dai) {
658 ret = soc_dai_trigger(dai, substream, cmd);
662 if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger)
663 snd_soc_dai_digital_mute(dai, 0, substream->stream);
665 soc_dai_mark_push(dai, substream, trigger);
671 for_each_rtd_dais(rtd, i, dai) {
672 if (rollback && !soc_dai_mark_match(dai, substream, trigger))
675 if (dai->driver->ops && dai->driver->ops->mute_unmute_on_trigger)
676 snd_soc_dai_digital_mute(dai, 1, substream->stream);
678 r = soc_dai_trigger(dai, substream, cmd);
681 soc_dai_mark_pop(dai, substream, trigger);
692 struct snd_soc_dai *dai;
695 for_each_rtd_dais(rtd, i, dai) {
696 if (dai->driver->ops &&
697 dai->driver->ops->bespoke_trigger) {
698 ret = dai->driver->ops->bespoke_trigger(substream,
699 cmd, dai);
701 return soc_dai_ret(dai, ret);
713 struct snd_soc_dai *dai;
724 for_each_rtd_cpu_dais(rtd, i, dai)
725 if (dai->driver->ops &&
726 dai->driver->ops->delay)
727 *cpu_delay = max(*cpu_delay, dai->driver->ops->delay(substream, dai));
730 for_each_rtd_codec_dais(rtd, i, dai)
731 if (dai->driver->ops &&
732 dai->driver->ops->delay)
733 *codec_delay = max(*codec_delay, dai->driver->ops->delay(substream, dai));
736 int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
741 if (dai->driver->cops &&
742 dai->driver->cops->startup)
743 ret = dai->driver->cops->startup(cstream, dai);
747 soc_dai_mark_push(dai, cstream, compr_startup);
749 return soc_dai_ret(dai, ret);
753 void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
757 if (rollback && !soc_dai_mark_match(dai, cstream, compr_startup))
760 if (dai->driver->cops &&
761 dai->driver->cops->shutdown)
762 dai->driver->cops->shutdown(cstream, dai);
765 soc_dai_mark_pop(dai, cstream, compr_startup);
769 int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
774 if (dai->driver->cops &&
775 dai->driver->cops->trigger)
776 ret = dai->driver->cops->trigger(cstream, cmd, dai);
778 return soc_dai_ret(dai, ret);
782 int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
788 if (dai->driver->cops &&
789 dai->driver->cops->set_params)
790 ret = dai->driver->cops->set_params(cstream, params, dai);
792 return soc_dai_ret(dai, ret);
796 int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
802 if (dai->driver->cops &&
803 dai->driver->cops->get_params)
804 ret = dai->driver->cops->get_params(cstream, params, dai);
806 return soc_dai_ret(dai, ret);
810 int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
816 if (dai->driver->cops &&
817 dai->driver->cops->ack)
818 ret = dai->driver->cops->ack(cstream, bytes, dai);
820 return soc_dai_ret(dai, ret);
824 int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
830 if (dai->driver->cops &&
831 dai->driver->cops->pointer)
832 ret = dai->driver->cops->pointer(cstream, tstamp, dai);
834 return soc_dai_ret(dai, ret);
838 int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai,
844 if (dai->driver->cops &&
845 dai->driver->cops->set_metadata)
846 ret = dai->driver->cops->set_metadata(cstream, metadata, dai);
848 return soc_dai_ret(dai, ret);
852 int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
858 if (dai->driver->cops &&
859 dai->driver->cops->get_metadata)
860 ret = dai->driver->cops->get_metadata(cstream, metadata, dai);
862 return soc_dai_ret(dai, ret);