Lines Matching +full:dai +full:- +full:links

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()
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()
66 * Get node via "sound-dai = <&phandle port>" in asoc_simple_parse_dai()
69 ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args); in asoc_simple_parse_dai()
76 * Here, dlc->dai_name is pointer to CPU/Codec DAI name. in asoc_simple_parse_dai()
78 * dlc->dai_name is keeping unbinded CPU or Codec in asoc_simple_parse_dai()
81 * If user re-bind CPU or Codec driver again, ALSA SoC will try in asoc_simple_parse_dai()
92 ret = snd_soc_of_get_dai_name(node, &dlc->dai_name); in asoc_simple_parse_dai()
96 dlc->of_node = args.np; in asoc_simple_parse_dai()
108 struct device_node *top = dev->of_node; in simple_parse_convert()
127 snprintf(prop, sizeof(prop), "%smclk-fs", PREFIX); in simple_parse_mclk_fs()
128 of_property_read_u32(top, prop, &props->mclk_fs); in simple_parse_mclk_fs()
130 snprintf(prop, sizeof(prop), "%smclk-fs", prefix); in simple_parse_mclk_fs()
131 of_property_read_u32(node, prop, &props->mclk_fs); in simple_parse_mclk_fs()
132 of_property_read_u32(np, prop, &props->mclk_fs); in simple_parse_mclk_fs()
144 struct device_node *top = dev->of_node; in simple_parse_node()
145 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in simple_parse_node()
146 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in simple_parse_node()
148 struct asoc_simple_dai *dai; in simple_parse_node() local
153 dai = simple_props_to_dai_cpu(dai_props, 0); in simple_parse_node()
156 dai = simple_props_to_dai_codec(dai_props, 0); in simple_parse_node()
165 ret = asoc_simple_parse_clk(dev, np, dai, dlc); in simple_parse_node()
169 ret = asoc_simple_parse_tdm(np, dai); in simple_parse_node()
183 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in simple_link_init()
187 prefix, &dai_link->dai_fmt); in simple_link_init()
191 dai_link->init = asoc_simple_dai_init; in simple_link_init()
192 dai_link->ops = &simple_ops; in simple_link_init()
204 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in simple_dai_link_of_dpcm()
205 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in simple_dai_link_of_dpcm()
206 struct device_node *top = dev->of_node; in simple_dai_link_of_dpcm()
214 /* For single DAI link & old style of DT node */ in simple_dai_link_of_dpcm()
218 if (li->cpu) { in simple_dai_link_of_dpcm()
226 dai_link->dynamic = 1; in simple_dai_link_of_dpcm()
227 dai_link->dpcm_merged_format = 1; in simple_dai_link_of_dpcm()
233 snprintf(dai_name, sizeof(dai_name), "fe.%s", cpus->dai_name); in simple_dai_link_of_dpcm()
244 dai_link->no_pcm = 1; in simple_dai_link_of_dpcm()
245 dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; in simple_dai_link_of_dpcm()
253 snprintf(dai_name, sizeof(dai_name), "be.%s", codecs->dai_name); in simple_dai_link_of_dpcm()
256 snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, in simple_dai_link_of_dpcm()
258 snd_soc_of_parse_node_prefix(node, cconf, codecs->of_node, in simple_dai_link_of_dpcm()
260 snd_soc_of_parse_node_prefix(np, cconf, codecs->of_node, in simple_dai_link_of_dpcm()
264 simple_parse_convert(dev, np, &dai_props->adata); in simple_dai_link_of_dpcm()
271 li->link++; in simple_dai_link_of_dpcm()
284 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in simple_dai_link_of()
301 /* For single DAI link & old style of DT node */ in simple_dai_link_of()
321 "%s-%s", cpus->dai_name, codecs->dai_name); in simple_dai_link_of()
332 li->link++; in simple_dai_link_of()
349 struct device_node *top = dev->of_node; in __simple_for_each_link()
355 /* Check if it has dai-link */ in __simple_for_each_link()
356 node = of_get_child_by_name(top, PREFIX "dai-link"); in __simple_for_each_link()
362 /* loop for all dai-link */ in __simple_for_each_link()
374 ret = -ENODEV; in __simple_for_each_link()
381 /* get convert-xxx property */ in __simple_for_each_link()
393 * or has convert-xxx property in __simple_for_each_link()
399 * |1(CPU)|0(Codec) li->cpu in __simple_for_each_link()
403 if (li->cpu != (np == codec)) in __simple_for_each_link()
409 * |1(CPU)|0(Codec) li->cpu in __simple_for_each_link()
413 if (li->cpu && (np != codec)) in __simple_for_each_link()
449 * as "CPU-Codec". in simple_for_each_link()
452 * all CPUs are detected as "CPU-dummy", and in simple_for_each_link()
453 * all Codecs are detected as "dummy-Codec". in simple_for_each_link()
454 * To avoid random sub-device numbering, in simple_for_each_link()
455 * detect "dummy-Codec" in last; in simple_for_each_link()
457 for (li->cpu = 1; li->cpu >= 0; li->cpu--) { in simple_for_each_link()
483 /* Single/Muti DAI link(s) & New style of DT node */ in simple_parse_of()
495 ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs"); in simple_parse_of()
505 if (li->link >= SNDRV_MAX_LINKS) { in simple_count_noml()
508 dev_err(dev, "too many links\n"); in simple_count_noml()
509 return -EINVAL; in simple_count_noml()
512 li->num[li->link].cpus = 1; in simple_count_noml()
513 li->num[li->link].codecs = 1; in simple_count_noml()
514 li->num[li->link].platforms = 1; in simple_count_noml()
516 li->link += 1; in simple_count_noml()
526 if (li->link >= SNDRV_MAX_LINKS) { in simple_count_dpcm()
529 dev_err(dev, "too many links\n"); in simple_count_dpcm()
530 return -EINVAL; in simple_count_dpcm()
533 if (li->cpu) { in simple_count_dpcm()
534 li->num[li->link].cpus = 1; in simple_count_dpcm()
535 li->num[li->link].platforms = 1; in simple_count_dpcm()
537 li->link++; /* CPU-dummy */ in simple_count_dpcm()
539 li->num[li->link].codecs = 1; in simple_count_dpcm()
541 li->link++; /* dummy-Codec */ in simple_count_dpcm()
551 struct device_node *top = dev->of_node; in simple_get_dais_count()
554 * link_num : number of links. in simple_get_dais_count()
555 * CPU-Codec / CPU-dummy / dummy-Codec in simple_get_dais_count()
558 * same number for "dummy-Codec" in simple_get_dais_count()
561 * CPU0 --- Codec0 link : 5 in simple_get_dais_count()
562 * CPU1 --- Codec1 dais : 7 in simple_get_dais_count()
563 * CPU2 -/ ccnf : 1 in simple_get_dais_count()
564 * CPU3 --- Codec2 in simple_get_dais_count()
566 * => 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec in simple_get_dais_count()
568 * => 1 ccnf = 1xdummy-Codec in simple_get_dais_count()
571 * CPU0 --- Codec0 link : 5 in simple_get_dais_count()
572 * CPU1 --- Codec1 dais : 6 in simple_get_dais_count()
573 * CPU2 -/ ccnf : 1 in simple_get_dais_count()
574 * CPU3 -/ in simple_get_dais_count()
576 * => 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec in simple_get_dais_count()
578 * => 1 ccnf = 1xdummy-Codec in simple_get_dais_count()
581 * CPU0 --- Codec0 link : 6 in simple_get_dais_count()
582 * CPU1 -/ dais : 6 in simple_get_dais_count()
583 * CPU2 --- Codec1 ccnf : 2 in simple_get_dais_count()
584 * CPU3 -/ in simple_get_dais_count()
586 * => 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec in simple_get_dais_count()
588 * => 2 ccnf = 2xdummy-Codec in simple_get_dais_count()
591 * CPU0 --- Codec0 (convert-rate) link : 3 in simple_get_dais_count()
592 * CPU1 --- Codec1 dais : 4 in simple_get_dais_count()
595 * => 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec in simple_get_dais_count()
597 * => 1 ccnf = 1xdummy-Codec in simple_get_dais_count()
600 li->num[0].cpus = 1; in simple_get_dais_count()
601 li->num[0].codecs = 1; in simple_get_dais_count()
602 li->num[0].platforms = 1; in simple_get_dais_count()
604 li->link = 1; in simple_get_dais_count()
618 ret = asoc_simple_init_hp(card, &priv->hp_jack, PREFIX); in simple_soc_probe()
622 ret = asoc_simple_init_mic(card, &priv->mic_jack, PREFIX); in simple_soc_probe()
632 struct device *dev = &pdev->dev; in asoc_simple_probe()
633 struct device_node *np = dev->of_node; in asoc_simple_probe()
638 /* Allocate the private data and the DAI link array */ in asoc_simple_probe()
641 return -ENOMEM; in asoc_simple_probe()
644 card->owner = THIS_MODULE; in asoc_simple_probe()
645 card->dev = dev; in asoc_simple_probe()
646 card->probe = simple_soc_probe; in asoc_simple_probe()
647 card->driver_name = "simple-card"; in asoc_simple_probe()
651 return -ENOMEM; in asoc_simple_probe()
657 if (!li->link) in asoc_simple_probe()
658 return -EINVAL; in asoc_simple_probe()
677 struct snd_soc_dai_link *dai_link = priv->dai_link; in asoc_simple_probe()
678 struct simple_dai_props *dai_props = priv->dai_props; in asoc_simple_probe()
680 cinfo = dev->platform_data; in asoc_simple_probe()
682 dev_err(dev, "no info for asoc-simple-card\n"); in asoc_simple_probe()
683 return -EINVAL; in asoc_simple_probe()
686 if (!cinfo->name || in asoc_simple_probe()
687 !cinfo->codec_dai.name || in asoc_simple_probe()
688 !cinfo->codec || in asoc_simple_probe()
689 !cinfo->platform || in asoc_simple_probe()
690 !cinfo->cpu_dai.name) { in asoc_simple_probe()
692 return -EINVAL; in asoc_simple_probe()
695 cpus = dai_link->cpus; in asoc_simple_probe()
696 cpus->dai_name = cinfo->cpu_dai.name; in asoc_simple_probe()
698 codecs = dai_link->codecs; in asoc_simple_probe()
699 codecs->name = cinfo->codec; in asoc_simple_probe()
700 codecs->dai_name = cinfo->codec_dai.name; in asoc_simple_probe()
702 platform = dai_link->platforms; in asoc_simple_probe()
703 platform->name = cinfo->platform; in asoc_simple_probe()
705 card->name = (cinfo->card) ? cinfo->card : cinfo->name; in asoc_simple_probe()
706 dai_link->name = cinfo->name; in asoc_simple_probe()
707 dai_link->stream_name = cinfo->name; in asoc_simple_probe()
708 dai_link->dai_fmt = cinfo->daifmt; in asoc_simple_probe()
709 dai_link->init = asoc_simple_dai_init; in asoc_simple_probe()
710 memcpy(dai_props->cpu_dai, &cinfo->cpu_dai, in asoc_simple_probe()
711 sizeof(*dai_props->cpu_dai)); in asoc_simple_probe()
712 memcpy(dai_props->codec_dai, &cinfo->codec_dai, in asoc_simple_probe()
713 sizeof(*dai_props->codec_dai)); in asoc_simple_probe()
733 { .compatible = "simple-audio-card", },
734 { .compatible = "simple-scu-audio-card",
742 .name = "asoc-simple-card",
752 MODULE_ALIAS("platform:asoc-simple-card");