Lines Matching +full:be +full:- +full:dai +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0
16 #include <sound/soc-dai.h>
21 #define DAI "sound-dai" macro
22 #define CELL "#sound-dai-cells"
23 #define PREFIX "simple-audio-card,"
41 * Get node via "sound-dai = <&phandle port>" in asoc_simple_parse_platform()
42 * it will be used as xxx_of_node on soc_bind_dai_link() in asoc_simple_parse_platform()
44 ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args); in asoc_simple_parse_platform()
50 dlc->of_node = args.np; in asoc_simple_parse_platform()
61 struct snd_soc_dai *dai; in asoc_simple_parse_dai() local
68 * Get node via "sound-dai = <&phandle port>" in asoc_simple_parse_dai()
69 * it will be used as xxx_of_node on soc_bind_dai_link() in asoc_simple_parse_dai()
71 ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args); in asoc_simple_parse_dai()
76 * Try to find from DAI args in asoc_simple_parse_dai()
78 dai = snd_soc_get_dai_via_args(&args); in asoc_simple_parse_dai()
79 if (dai) { in asoc_simple_parse_dai()
80 dlc->dai_name = snd_soc_dai_name_get(dai); in asoc_simple_parse_dai()
81 dlc->dai_args = snd_soc_copy_dai_args(dev, &args); in asoc_simple_parse_dai()
82 if (!dlc->dai_args) in asoc_simple_parse_dai()
83 return -ENOMEM; in asoc_simple_parse_dai()
91 * Here, dlc->dai_name is pointer to CPU/Codec DAI name. in asoc_simple_parse_dai()
93 * dlc->dai_name is keeping unbinded CPU or Codec in asoc_simple_parse_dai()
96 * If user re-bind CPU or Codec driver again, ALSA SoC will try in asoc_simple_parse_dai()
122 struct device_node *top = dev->of_node; in simple_parse_convert()
141 snprintf(prop, sizeof(prop), "%smclk-fs", PREFIX); in simple_parse_mclk_fs()
142 of_property_read_u32(top, prop, &props->mclk_fs); in simple_parse_mclk_fs()
144 snprintf(prop, sizeof(prop), "%smclk-fs", prefix); in simple_parse_mclk_fs()
145 of_property_read_u32(node, prop, &props->mclk_fs); in simple_parse_mclk_fs()
146 of_property_read_u32(np, prop, &props->mclk_fs); in simple_parse_mclk_fs()
158 struct device_node *top = dev->of_node; in simple_parse_node()
159 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in simple_parse_node()
160 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in simple_parse_node()
162 struct asoc_simple_dai *dai; in simple_parse_node() local
167 dai = simple_props_to_dai_cpu(dai_props, 0); in simple_parse_node()
170 dai = simple_props_to_dai_codec(dai_props, 0); in simple_parse_node()
179 ret = asoc_simple_parse_clk(dev, np, dai, dlc); in simple_parse_node()
183 ret = asoc_simple_parse_tdm(np, dai); in simple_parse_node()
197 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in simple_link_init()
201 prefix, &dai_link->dai_fmt); in simple_link_init()
205 dai_link->init = asoc_simple_dai_init; in simple_link_init()
206 dai_link->ops = &simple_ops; in simple_link_init()
218 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in simple_dai_link_of_dpcm()
219 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in simple_dai_link_of_dpcm()
220 struct device_node *top = dev->of_node; in simple_dai_link_of_dpcm()
228 /* For single DAI link & old style of DT node */ in simple_dai_link_of_dpcm()
232 if (li->cpu) { in simple_dai_link_of_dpcm()
240 dai_link->dynamic = 1; in simple_dai_link_of_dpcm()
241 dai_link->dpcm_merged_format = 1; in simple_dai_link_of_dpcm()
247 snprintf(dai_name, sizeof(dai_name), "fe.%s", cpus->dai_name); in simple_dai_link_of_dpcm()
257 /* BE settings */ in simple_dai_link_of_dpcm()
258 dai_link->no_pcm = 1; in simple_dai_link_of_dpcm()
259 dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; in simple_dai_link_of_dpcm()
267 snprintf(dai_name, sizeof(dai_name), "be.%s", codecs->dai_name); in simple_dai_link_of_dpcm()
270 snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, in simple_dai_link_of_dpcm()
272 snd_soc_of_parse_node_prefix(node, cconf, codecs->of_node, in simple_dai_link_of_dpcm()
274 snd_soc_of_parse_node_prefix(np, cconf, codecs->of_node, in simple_dai_link_of_dpcm()
278 simple_parse_convert(dev, np, &dai_props->adata); in simple_dai_link_of_dpcm()
285 li->link++; in simple_dai_link_of_dpcm()
298 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in simple_dai_link_of()
315 /* For single DAI link & old style of DT node */ in simple_dai_link_of()
335 "%s-%s", cpus->dai_name, codecs->dai_name); in simple_dai_link_of()
346 li->link++; in simple_dai_link_of()
363 struct device_node *top = dev->of_node; in __simple_for_each_link()
370 /* Check if it has dai-link */ in __simple_for_each_link()
371 node = of_get_child_by_name(top, PREFIX "dai-link"); in __simple_for_each_link()
377 add_devs = of_get_child_by_name(top, PREFIX "additional-devs"); in __simple_for_each_link()
379 /* loop for all dai-link */ in __simple_for_each_link()
387 /* Skip additional-devs node */ in __simple_for_each_link()
397 ret = -ENODEV; in __simple_for_each_link()
404 /* get convert-xxx property */ in __simple_for_each_link()
419 * or has convert-xxx property in __simple_for_each_link()
425 * |1(CPU)|0(Codec) li->cpu in __simple_for_each_link()
429 if (li->cpu != (np == codec)) in __simple_for_each_link()
435 * |1(CPU)|0(Codec) li->cpu in __simple_for_each_link()
439 if (li->cpu && (np != codec)) in __simple_for_each_link()
478 * as "CPU-Codec". in simple_for_each_link()
481 * all CPUs are detected as "CPU-dummy", and in simple_for_each_link()
482 * all Codecs are detected as "dummy-Codec". in simple_for_each_link()
483 * To avoid random sub-device numbering, in simple_for_each_link()
484 * detect "dummy-Codec" in last; in simple_for_each_link()
486 for (li->cpu = 1; li->cpu >= 0; li->cpu--) { in simple_for_each_link()
508 node = of_get_child_by_name(dev->of_node, PREFIX "additional-devs"); in simple_populate_aux()
537 /* Single/Muti DAI link(s) & New style of DT node */ in simple_parse_of()
553 ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs"); in simple_parse_of()
563 if (li->link >= SNDRV_MAX_LINKS) { in simple_count_noml()
567 return -EINVAL; in simple_count_noml()
573 * Some CPU might be using soc-generic-dmaengine-pcm. This means CPU and Platform in simple_count_noml()
574 * are different Component, but are sharing same component->dev. in simple_count_noml()
578 * In case of no Platform, it will be Platform == CPU, but Platform will be in simple_count_noml()
582 * simple-card-utils.c :: asoc_simple_canonicalize_platform() in simple_count_noml()
584 li->num[li->link].cpus = 1; in simple_count_noml()
585 li->num[li->link].platforms = 1; in simple_count_noml()
587 li->num[li->link].codecs = 1; in simple_count_noml()
589 li->link += 1; in simple_count_noml()
599 if (li->link >= SNDRV_MAX_LINKS) { in simple_count_dpcm()
603 return -EINVAL; in simple_count_dpcm()
606 if (li->cpu) { in simple_count_dpcm()
612 li->num[li->link].cpus = 1; in simple_count_dpcm()
613 li->num[li->link].platforms = 1; in simple_count_dpcm()
615 li->link++; /* CPU-dummy */ in simple_count_dpcm()
617 li->num[li->link].codecs = 1; in simple_count_dpcm()
619 li->link++; /* dummy-Codec */ in simple_count_dpcm()
629 struct device_node *top = dev->of_node; in simple_get_dais_count()
633 * CPU-Codec / CPU-dummy / dummy-Codec in simple_get_dais_count()
636 * same number for "dummy-Codec" in simple_get_dais_count()
639 * CPU0 --- Codec0 link : 5 in simple_get_dais_count()
640 * CPU1 --- Codec1 dais : 7 in simple_get_dais_count()
641 * CPU2 -/ ccnf : 1 in simple_get_dais_count()
642 * CPU3 --- Codec2 in simple_get_dais_count()
644 * => 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec in simple_get_dais_count()
646 * => 1 ccnf = 1xdummy-Codec in simple_get_dais_count()
649 * CPU0 --- Codec0 link : 5 in simple_get_dais_count()
650 * CPU1 --- Codec1 dais : 6 in simple_get_dais_count()
651 * CPU2 -/ ccnf : 1 in simple_get_dais_count()
652 * CPU3 -/ in simple_get_dais_count()
654 * => 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec in simple_get_dais_count()
656 * => 1 ccnf = 1xdummy-Codec in simple_get_dais_count()
659 * CPU0 --- Codec0 link : 6 in simple_get_dais_count()
660 * CPU1 -/ dais : 6 in simple_get_dais_count()
661 * CPU2 --- Codec1 ccnf : 2 in simple_get_dais_count()
662 * CPU3 -/ in simple_get_dais_count()
664 * => 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec in simple_get_dais_count()
666 * => 2 ccnf = 2xdummy-Codec in simple_get_dais_count()
669 * CPU0 --- Codec0 (convert-rate) link : 3 in simple_get_dais_count()
670 * CPU1 --- Codec1 dais : 4 in simple_get_dais_count()
673 * => 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec in simple_get_dais_count()
675 * => 1 ccnf = 1xdummy-Codec in simple_get_dais_count()
678 li->num[0].cpus = 1; in simple_get_dais_count()
679 li->num[0].codecs = 1; in simple_get_dais_count()
680 li->num[0].platforms = 1; in simple_get_dais_count()
682 li->link = 1; in simple_get_dais_count()
696 ret = asoc_simple_init_hp(card, &priv->hp_jack, PREFIX); in simple_soc_probe()
700 ret = asoc_simple_init_mic(card, &priv->mic_jack, PREFIX); in simple_soc_probe()
714 struct device *dev = &pdev->dev; in asoc_simple_probe()
715 struct device_node *np = dev->of_node; in asoc_simple_probe()
720 /* Allocate the private data and the DAI link array */ in asoc_simple_probe()
723 return -ENOMEM; in asoc_simple_probe()
726 card->owner = THIS_MODULE; in asoc_simple_probe()
727 card->dev = dev; in asoc_simple_probe()
728 card->probe = simple_soc_probe; in asoc_simple_probe()
729 card->driver_name = "simple-card"; in asoc_simple_probe()
733 return -ENOMEM; in asoc_simple_probe()
739 if (!li->link) in asoc_simple_probe()
740 return -EINVAL; in asoc_simple_probe()
759 struct snd_soc_dai_link *dai_link = priv->dai_link; in asoc_simple_probe()
760 struct simple_dai_props *dai_props = priv->dai_props; in asoc_simple_probe()
762 ret = -EINVAL; in asoc_simple_probe()
764 cinfo = dev->platform_data; in asoc_simple_probe()
766 dev_err(dev, "no info for asoc-simple-card\n"); in asoc_simple_probe()
770 if (!cinfo->name || in asoc_simple_probe()
771 !cinfo->codec_dai.name || in asoc_simple_probe()
772 !cinfo->codec || in asoc_simple_probe()
773 !cinfo->platform || in asoc_simple_probe()
774 !cinfo->cpu_dai.name) { in asoc_simple_probe()
779 cpus = dai_link->cpus; in asoc_simple_probe()
780 cpus->dai_name = cinfo->cpu_dai.name; in asoc_simple_probe()
782 codecs = dai_link->codecs; in asoc_simple_probe()
783 codecs->name = cinfo->codec; in asoc_simple_probe()
784 codecs->dai_name = cinfo->codec_dai.name; in asoc_simple_probe()
786 platform = dai_link->platforms; in asoc_simple_probe()
787 platform->name = cinfo->platform; in asoc_simple_probe()
789 card->name = (cinfo->card) ? cinfo->card : cinfo->name; in asoc_simple_probe()
790 dai_link->name = cinfo->name; in asoc_simple_probe()
791 dai_link->stream_name = cinfo->name; in asoc_simple_probe()
792 dai_link->dai_fmt = cinfo->daifmt; in asoc_simple_probe()
793 dai_link->init = asoc_simple_dai_init; in asoc_simple_probe()
794 memcpy(dai_props->cpu_dai, &cinfo->cpu_dai, in asoc_simple_probe()
795 sizeof(*dai_props->cpu_dai)); in asoc_simple_probe()
796 memcpy(dai_props->codec_dai, &cinfo->codec_dai, in asoc_simple_probe()
797 sizeof(*dai_props->codec_dai)); in asoc_simple_probe()
817 { .compatible = "simple-audio-card", },
818 { .compatible = "simple-scu-audio-card",
826 .name = "asoc-simple-card",
836 MODULE_ALIAS("platform:asoc-simple-card");