Lines Matching +full:audio +full:- +full:graph +full:- +full:card
1 // SPDX-License-Identifier: GPL-2.0
3 // ASoC Audio Graph Card2 support
8 // based on ${LINUX}/sound/soc/generic/audio-graph-card.c
25 bitclock-master;
27 frame-master;
39 sample0: left_j, bitclock-master, frame-master
40 sample1: i2s, bitclock-master
56 linux/sound/soc/soc-utils.c
57 linux/sound/soc/generic/test-component.c
60 Normal Audio-Graph
63 CPU <---> Codec
66 compatible = "audio-graph-card2";
72 bitclock-master;
73 frame-master;
74 cpu_ep: endpoint { remote-endpoint = <&codec_ep>; }; };
78 port { codec_ep: endpoint { remote-endpoint = <&cpu_ep>; }; };
82 Multi-CPU/Codec
88 +----+ +---+
89 CPU1 --|A X| <-@----> |x a|-- Codec1
90 CPU2 --|B | | b|-- Codec2
91 +----+ +---+
94 compatible = "audio-graph-card2";
100 (@) mcpu: port@0 { mcpu0_ep: endpoint { remote-endpoint = <&mcodec0_ep>; }; }; // (X) to pair
101 port@1 { mcpu1_ep: endpoint { remote-endpoint = <&cpu1_ep>; }; }; // (A) Multi Element
102 port@2 { mcpu2_ep: endpoint { remote-endpoint = <&cpu2_ep>; }; }; // (B) Multi Element
105 port@0 { mcodec0_ep: endpoint { remote-endpoint = <&mcpu0_ep>; }; }; // (x) to pair
106 port@1 { mcodec1_ep: endpoint { remote-endpoint = <&codec1_ep>; }; }; // (a) Multi Element
107 port@2 { mcodec2_ep: endpoint { remote-endpoint = <&codec2_ep>; }; }; // (b) Multi Element
114 bitclock-master;
115 frame-master;
116 port@0 { cpu1_ep: endpoint { remote-endpoint = <&mcpu1_ep>; }; };
117 port@1 { cpu2_ep: endpoint { remote-endpoint = <&mcpu2_ep>; }; };
123 port@0 { codec1_ep: endpoint { remote-endpoint = <&mcodec1_ep>; }; };
124 port@1 { codec2_ep: endpoint { remote-endpoint = <&mcodec2_ep>; }; };
134 PCM0 <--> * fe0 be0 * <--> DAI0: Codec Headset
135 PCM1 <--> * fe1 be1 * <--> DAI1: Codec Speakers
136 PCM2 <--> * fe2 be2 * <--> DAI2: MODEM
137 PCM3 <--> * fe3 be3 * <--> DAI3: BT
138 * be4 * <--> DAI4: DMIC
139 * be5 * <--> DAI5: FM
143 compatible = "audio-graph-card2";
150 // indicate all Front-End, Back-End
155 // Front-End
157 fe0: port@0 { fe0_ep: endpoint { remote-endpoint = <&pcm0_ep>; }; };
158 fe1: port@1 { fe1_ep: endpoint { remote-endpoint = <&pcm1_ep>; }; };
161 // Back-End
163 be0: port@0 { be0_ep: endpoint { remote-endpoint = <&dai0_ep>; }; };
164 be1: port@1 { be1_ep: endpoint { remote-endpoint = <&dai1_ep>; }; };
172 bitclock-master;
173 frame-master;
174 port@0 { pcm0_ep: endpoint { remote-endpoint = <&fe0_ep>; }; };
175 port@1 { pcm1_ep: endpoint { remote-endpoint = <&fe1_ep>; }; };
182 port@0 { dai0_ep: endpoint { remote-endpoint = <&be0_ep>; }; };
183 port@1 { dai1_ep: endpoint { remote-endpoint = <&be1_ep>; }; };
192 +--+
193 | |<-- Codec0 <- IN
194 | |--> Codec1 -> OUT
195 +--+
198 compatible = "audio-graph-card2";
208 c2c: port@0 { c2cf_ep: endpoint { remote-endpoint = <&codec0_ep>; }; };
209 port@1 { c2cb_ep: endpoint { remote-endpoint = <&codec1_ep>; }; };
216 bitclock-master;
217 frame-master;
218 codec0_ep: endpoint { remote-endpoint = <&c2cf_ep>; }; };
219 port@1 { codec1_ep: endpoint { remote-endpoint = <&c2cb_ep>; }; };
273 fw_devlink_purge_absent_suppliers(&np->fwnode); in __graph_get_type()
279 fw_devlink_purge_absent_suppliers(&np->fwnode); in __graph_get_type()
285 fw_devlink_purge_absent_suppliers(&np->fwnode); in __graph_get_type()
314 str = "DPCM Front-End"; in graph_get_type()
316 str = "DPCM Back-End"; in graph_get_type()
385 struct simple_util_data *adata = &props->adata; in graph_parse_convert()
402 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in __graph_parse_node()
403 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in __graph_parse_node()
435 if (!dai_link->name) { in __graph_parse_node()
441 if (dai_link->num_cpus > 1) in __graph_parse_node()
443 if (dai_link->num_codecs > 1) in __graph_parse_node()
450 simple_util_set_dailink_name(dev, dai_link, "%s%s-%s%s", in __graph_parse_node()
451 cpus->dai_name, cpu_multi, in __graph_parse_node()
452 codecs->dai_name, codec_multi); in __graph_parse_node()
457 cpus->of_node, cpus->dai_name, cpu_multi); in __graph_parse_node()
460 codecs->of_node, codecs->dai_name, codec_multi); in __graph_parse_node()
465 simple_util_set_dailink_name(dev, dai_link, "c2c.%s%s-%s%s", in __graph_parse_node()
466 cpus->dai_name, cpu_multi, in __graph_parse_node()
467 codecs->dai_name, codec_multi); in __graph_parse_node()
476 * if DPCM-BE case in __graph_parse_node()
484 snd_soc_of_parse_node_prefix(rports, cconf, codecs->of_node, "prefix"); in __graph_parse_node()
485 snd_soc_of_parse_node_prefix(rport, cconf, codecs->of_node, "prefix"); in __graph_parse_node()
507 * +---+ +---+ in graph_parse_node_multi_nm()
508 * | X|<-@------->|x | in graph_parse_node_multi_nm()
510 * cpu0 <--|A 1|<--------->|4 a|-> codec0 in graph_parse_node_multi_nm()
511 * cpu1 <--|B 2|<-----+--->|5 b|-> codec1 in graph_parse_node_multi_nm()
512 * cpu2 <--|C 3|<----/ +---+ in graph_parse_node_multi_nm()
513 * +---+ in graph_parse_node_multi_nm()
543 int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); in graph_parse_node_multi_nm()
544 int ret = -EINVAL; in graph_parse_node_multi_nm()
546 if (cpu_idx > dai_link->num_cpus) in graph_parse_node_multi_nm()
573 if (codec_idx > dai_link->num_codecs) in graph_parse_node_multi_nm()
587 dai_link->ch_maps[*nm_idx].cpu = cpu_idx; in graph_parse_node_multi_nm()
588 dai_link->ch_maps[*nm_idx].codec = codec_idx; in graph_parse_node_multi_nm()
614 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_parse_node_multi()
617 int ret = -ENOMEM; in graph_parse_node_multi()
619 int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); in graph_parse_node_multi()
625 if (gtype != GRAPH_DPCM && !dai_link->ch_maps && in graph_parse_node_multi()
626 dai_link->num_cpus > 1 && dai_link->num_codecs > 1 && in graph_parse_node_multi()
627 dai_link->num_cpus != dai_link->num_codecs) { in graph_parse_node_multi()
629 dai_link->ch_maps = devm_kcalloc(dev, nm_max, in graph_parse_node_multi()
631 if (!dai_link->ch_maps) in graph_parse_node_multi()
661 if (is_cpu && dai_link->ch_maps) { in graph_parse_node_multi()
668 if (is_cpu && dai_link->ch_maps && (nm_idx != nm_max)) in graph_parse_node_multi()
669 ret = -EINVAL; in graph_parse_node_multi()
729 * if (A) or (B) or (C) has bitclock-master / frame-master flag. in graph_parse_daifmt()
743 * This function is called by (C) -> (B) -> (A) order. in graph_parse_daifmt()
759 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_link_init()
760 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in graph_link_init()
806 of_property_read_u32(lnk, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
807 of_property_read_u32(ports_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
808 of_property_read_u32(ports_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
809 of_property_read_u32(port_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
810 of_property_read_u32(port_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
811 of_property_read_u32(ep_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
812 of_property_read_u32(ep_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
831 dai_link->playback_only = playback_only; in graph_link_init()
832 dai_link->capture_only = capture_only; in graph_link_init()
834 dai_link->trigger_start = trigger_start; in graph_link_init()
835 dai_link->trigger_stop = trigger_stop; in graph_link_init()
837 dai_link->dai_fmt = daifmt | daiclk; in graph_link_init()
838 dai_link->init = simple_util_dai_init; in graph_link_init()
839 dai_link->ops = &graph_ops; in graph_link_init()
840 if (priv->ops) in graph_link_init()
841 dai_link->ops = priv->ops; in graph_link_init()
893 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in audio_graph2_link_dpcm()
894 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in audio_graph2_link_dpcm()
903 * // Front-End in audio_graph2_link_dpcm()
908 * // Back-End in audio_graph2_link_dpcm()
925 dai_link->dynamic = 1; in audio_graph2_link_dpcm()
926 dai_link->dpcm_merged_format = 1; in audio_graph2_link_dpcm()
937 * // Front-End in audio_graph2_link_dpcm()
941 * // Back-End in audio_graph2_link_dpcm()
961 dai_link->no_pcm = 1; in audio_graph2_link_dpcm()
962 dai_link->be_hw_params_fixup = simple_util_be_hw_params_fixup; in audio_graph2_link_dpcm()
987 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in audio_graph2_link_c2c()
992 int ret = -EINVAL; in audio_graph2_link_c2c()
1032 c2c_conf->formats = SNDRV_PCM_FMTBIT_S32_LE; /* update ME */ in audio_graph2_link_c2c()
1033 c2c_conf->rates = SNDRV_PCM_RATE_8000_384000; in audio_graph2_link_c2c()
1034 c2c_conf->rate_min = in audio_graph2_link_c2c()
1035 c2c_conf->rate_max = val; in audio_graph2_link_c2c()
1036 c2c_conf->channels_min = in audio_graph2_link_c2c()
1037 c2c_conf->channels_max = 2; /* update ME */ in audio_graph2_link_c2c()
1039 dai_link->c2c_params = c2c_conf; in audio_graph2_link_c2c()
1040 dai_link->num_c2c_params = 1; in audio_graph2_link_c2c()
1088 int ret = -EINVAL; in graph_link()
1092 if (hooks && hooks->custom_normal) in graph_link()
1093 func = hooks->custom_normal; in graph_link()
1098 if (hooks && hooks->custom_dpcm) in graph_link()
1099 func = hooks->custom_dpcm; in graph_link()
1104 if (hooks && hooks->custom_c2c) in graph_link()
1105 func = hooks->custom_c2c; in graph_link()
1122 li->link++; in graph_link()
1150 return of_get_child_count(ports) - 1; in graph_counter()
1175 * simple-card.c :: simple_count_noml() in graph_count_normal()
1177 li->num[li->link].cpus = in graph_count_normal()
1178 li->num[li->link].platforms = graph_counter(cpu_port); in graph_count_normal()
1180 li->num[li->link].codecs = graph_counter(codec_port); in graph_count_normal()
1197 * // Front-End in graph_count_dpcm()
1202 * // Back-End in graph_count_dpcm()
1214 * simple-card.c :: simple_count_noml() in graph_count_dpcm()
1216 li->num[li->link].cpus = graph_counter(rport); /* FE */ in graph_count_dpcm()
1217 li->num[li->link].platforms = graph_counter(rport); in graph_count_dpcm()
1219 li->num[li->link].codecs = graph_counter(rport); /* BE */ in graph_count_dpcm()
1251 * simple-card.c :: simple_count_noml() in graph_count_c2c()
1253 li->num[li->link].cpus = in graph_count_c2c()
1254 li->num[li->link].platforms = graph_counter(codec0); in graph_count_c2c()
1256 li->num[li->link].codecs = graph_counter(codec1); in graph_count_c2c()
1276 int ret = -EINVAL; in graph_count()
1278 if (li->link >= SNDRV_MAX_LINKS) { in graph_count()
1306 li->link++; in graph_count()
1322 struct device_node *node = dev->of_node; in graph_for_each_link()
1344 struct snd_soc_card *card = simple_priv_to_card(priv); in audio_graph2_parse_of() local
1349 return -ENOMEM; in audio_graph2_parse_of()
1351 card->probe = graph_util_card_probe; in audio_graph2_parse_of()
1352 card->owner = THIS_MODULE; in audio_graph2_parse_of()
1353 card->dev = dev; in audio_graph2_parse_of()
1355 if ((hooks) && (hooks)->hook_pre) { in audio_graph2_parse_of()
1356 ret = (hooks)->hook_pre(priv); in audio_graph2_parse_of()
1362 if (!li->link) in audio_graph2_parse_of()
1363 ret = -EINVAL; in audio_graph2_parse_of()
1371 priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); in audio_graph2_parse_of()
1372 if (IS_ERR(priv->pa_gpio)) { in audio_graph2_parse_of()
1373 ret = PTR_ERR(priv->pa_gpio); in audio_graph2_parse_of()
1378 ret = simple_util_parse_widgets(card, NULL); in audio_graph2_parse_of()
1382 ret = simple_util_parse_routing(card, NULL); in audio_graph2_parse_of()
1391 ret = simple_util_parse_card_name(card, NULL); in audio_graph2_parse_of()
1395 snd_soc_card_set_drvdata(card, priv); in audio_graph2_parse_of()
1397 if ((hooks) && (hooks)->hook_post) { in audio_graph2_parse_of()
1398 ret = (hooks)->hook_post(priv); in audio_graph2_parse_of()
1405 ret = snd_soc_of_parse_aux_devs(card, "aux-devs"); in audio_graph2_parse_of()
1409 ret = devm_snd_soc_register_card(dev, card); in audio_graph2_parse_of()
1421 struct device *dev = &pdev->dev; in graph_probe()
1426 return -ENOMEM; in graph_probe()
1432 { .compatible = "audio-graph-card2", },
1439 .name = "asoc-audio-graph-card2",
1448 MODULE_ALIAS("platform:asoc-audio-graph-card2");
1450 MODULE_DESCRIPTION("ASoC Audio Graph Card2");