Lines Matching +full:multi +full:- +full:port

1 // SPDX-License-Identifier: GPL-2.0
8 // based on ${LINUX}/sound/soc/generic/audio-graph-card.c
24 port@0 {
25 bitclock-master;
27 frame-master;
36 You can set daifmt at ports/port/endpoint.
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";
71 cpu: port {
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";
98 multi {
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>; }; };
215 port@0 {
216 bitclock-master;
217 frame-master;
218 codec0_ep: endpoint { remote-endpoint = <&c2cf_ep>; }; };
219 port@1 { codec1_ep: endpoint { remote-endpoint = <&c2cb_ep>; }; };
233 #define GRAPH_NODENAME_MULTI "multi"
238 static struct device_node *port_to_ports(struct device_node *port) in port_to_ports() argument
240 struct device_node *ports = of_get_parent(port); in port_to_ports()
257 * => lnk: port@0 { ... }; in __graph_get_type()
258 * port@1 { ... }; in __graph_get_type()
271 fw_devlink_purge_absent_suppliers(&np->fwnode); in __graph_get_type()
277 fw_devlink_purge_absent_suppliers(&np->fwnode); in __graph_get_type()
283 fw_devlink_purge_absent_suppliers(&np->fwnode); in __graph_get_type()
312 str = "DPCM Front-End"; in graph_get_type()
314 str = "DPCM Back-End"; in graph_get_type()
334 static struct device_node *graph_get_next_multi_ep(struct device_node **port, int idx) in graph_get_next_multi_ep() argument
336 struct device_node *ports __free(device_node) = port_to_ports(*port); in graph_get_next_multi_ep()
340 * multi { in graph_get_next_multi_ep()
342 * => lnk: port@0 { ... }; // to pair in graph_get_next_multi_ep()
343 * port@1 { ep { ... = rep0 } }; // Multi Element in graph_get_next_multi_ep()
344 * port@2 { ep { ... = rep1 } }; // Multi Element in graph_get_next_multi_ep()
350 * port@0 { rep0 }; in graph_get_next_multi_ep()
351 * port@1 { rep1 }; in graph_get_next_multi_ep()
358 * In overlay case, "port" are not necessarily in order. So we need to use in graph_get_next_multi_ep()
361 of_node_put(*port); in graph_get_next_multi_ep()
363 *port = of_graph_get_port_by_id(ports, idx); in graph_get_next_multi_ep()
364 if (*port) { in graph_get_next_multi_ep()
365 struct device_node *ep __free(device_node) = of_graph_get_next_port_endpoint(*port, NULL); in graph_get_next_multi_ep()
382 struct device_node *port __free(device_node) = ep_to_port(ep); in graph_parse_convert()
383 struct device_node *ports __free(device_node) = port_to_ports(port); in graph_parse_convert()
384 struct simple_util_data *adata = &props->adata; in graph_parse_convert()
387 simple_util_parse_convert(port, NULL, adata); in graph_parse_convert()
398 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in __graph_parse_node()
399 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in __graph_parse_node()
431 if (!dai_link->name) { in __graph_parse_node()
437 if (dai_link->num_cpus > 1) in __graph_parse_node()
439 if (dai_link->num_codecs > 1) in __graph_parse_node()
446 simple_util_set_dailink_name(dev, dai_link, "%s%s-%s%s", in __graph_parse_node()
447 cpus->dai_name, cpu_multi, in __graph_parse_node()
448 codecs->dai_name, codec_multi); in __graph_parse_node()
453 cpus->of_node, cpus->dai_name, cpu_multi); in __graph_parse_node()
456 codecs->of_node, codecs->dai_name, codec_multi); in __graph_parse_node()
461 simple_util_set_dailink_name(dev, dai_link, "c2c.%s%s-%s%s", in __graph_parse_node()
462 cpus->dai_name, cpu_multi, in __graph_parse_node()
463 codecs->dai_name, codec_multi); in __graph_parse_node()
472 * if DPCM-BE case in __graph_parse_node()
480 snd_soc_of_parse_node_prefix(rports, cconf, codecs->of_node, "prefix"); in __graph_parse_node()
481 snd_soc_of_parse_node_prefix(rport, cconf, codecs->of_node, "prefix"); in __graph_parse_node()
500 * +---+ +---+ in graph_parse_node_multi_nm()
501 * | X|<-@------->|x | in graph_parse_node_multi_nm()
503 * cpu0 <--|A 1|<--------->|4 a|-> codec0 in graph_parse_node_multi_nm()
504 * cpu1 <--|B 2|<-----+--->|5 b|-> codec1 in graph_parse_node_multi_nm()
505 * cpu2 <--|C 3|<----/ +---+ in graph_parse_node_multi_nm()
506 * +---+ in graph_parse_node_multi_nm()
508 * multi { in graph_parse_node_multi_nm()
510 * port@0 { mcpu_top_ep {... = mcodec_ep; }; }; // (X) to pair in graph_parse_node_multi_nm()
511 * <mcpu_port> port@1 { mcpu0_ep { ... = cpu0_ep; }; // (A) Multi Element in graph_parse_node_multi_nm()
513 * port@2 { mcpu1_ep { ... = cpu1_ep; }; // (B) Multi Element in graph_parse_node_multi_nm()
515 * port@3 { mcpu2_ep { ... = cpu2_ep; }; // (C) Multi Element in graph_parse_node_multi_nm()
520 * port@0 { mcodec_top_ep {... = mcpu_ep; }; }; // (x) to pair in graph_parse_node_multi_nm()
521 * <mcodec_port>port@1 { mcodec0_ep { ... = codec0_ep; }; // (a) Multi Element in graph_parse_node_multi_nm()
523 * port@2 { mcodec1_ep { ... = codec1_ep; }; // (b) Multi Element in graph_parse_node_multi_nm()
536 int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); in graph_parse_node_multi_nm()
539 if (cpu_idx > dai_link->num_cpus) in graph_parse_node_multi_nm()
540 return -EINVAL; in graph_parse_node_multi_nm()
555 ret = -EINVAL; in graph_parse_node_multi_nm()
561 /* ignore 1st port which is for pair connection */ in graph_parse_node_multi_nm()
565 if (codec_idx > dai_link->num_codecs) in graph_parse_node_multi_nm()
569 dai_link->ch_maps[*nm_idx].cpu = cpu_idx; in graph_parse_node_multi_nm()
570 dai_link->ch_maps[*nm_idx].codec = codec_idx; in graph_parse_node_multi_nm()
587 struct device_node *port, in graph_parse_node_multi() argument
590 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_parse_node_multi()
592 int ret = -ENOMEM; in graph_parse_node_multi()
594 int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); in graph_parse_node_multi()
600 if (gtype != GRAPH_DPCM && !dai_link->ch_maps && in graph_parse_node_multi()
601 dai_link->num_cpus > 1 && dai_link->num_codecs > 1 && in graph_parse_node_multi()
602 dai_link->num_cpus != dai_link->num_codecs) { in graph_parse_node_multi()
604 dai_link->ch_maps = devm_kcalloc(dev, nm_max, in graph_parse_node_multi()
606 if (!dai_link->ch_maps) in graph_parse_node_multi()
612 * multi { in graph_parse_node_multi()
614 * <port> port@0 { ... }; // to pair in graph_parse_node_multi()
615 * port@1 { mcpu1_ep { ... = cpu1_ep };}; // Multi Element in graph_parse_node_multi()
616 * port@2 { mcpu2_ep { ... = cpu2_ep };}; // Multi Element in graph_parse_node_multi()
622 * <ep> port@0 { cpu1_ep { ... = mcpu1_ep };}; in graph_parse_node_multi()
626 struct device_node *ep __free(device_node) = graph_get_next_multi_ep(&port, idx + 1); in graph_parse_node_multi()
635 if (is_cpu && dai_link->ch_maps) { in graph_parse_node_multi()
636 ret = graph_parse_node_multi_nm(dai_link, &nm_idx, idx, port); in graph_parse_node_multi()
642 if (is_cpu && dai_link->ch_maps && (nm_idx != nm_max)) in graph_parse_node_multi()
643 ret = -EINVAL; in graph_parse_node_multi()
662 struct device_node *port __free(device_node) = ep_to_port(ep); in graph_parse_node()
664 if (graph_lnk_is_multi(port)) in graph_parse_node()
665 return graph_parse_node_multi(priv, gtype, port, li, is_cpu); in graph_parse_node()
685 * port { in graph_parse_daifmt()
703 * This function is called by (C) -> (B) -> (A) order. in graph_parse_daifmt()
714 struct device_node *port __free(device_node) = ep_to_port(ep); in graph_parse_bitframe()
715 struct device_node *ports __free(device_node) = port_to_ports(port); in graph_parse_bitframe()
719 snd_soc_daifmt_parse_clock_provider_as_bitmap(port, NULL) | in graph_parse_bitframe()
730 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_link_init()
731 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in graph_link_init()
779 of_property_read_u32(lnk, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
780 of_property_read_u32(ports_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
781 of_property_read_u32(ports_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
782 of_property_read_u32(port_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
783 of_property_read_u32(port_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
784 of_property_read_u32(ep_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
785 of_property_read_u32(ep_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
796 dlc->ext_fmt = graph_parse_bitframe(ep_cpu); in graph_link_init()
803 dlc->ext_fmt = graph_parse_bitframe(ep_codec); in graph_link_init()
811 dai_link->playback_only = playback_only; in graph_link_init()
812 dai_link->capture_only = capture_only; in graph_link_init()
814 dai_link->trigger_start = trigger_start; in graph_link_init()
815 dai_link->trigger_stop = trigger_stop; in graph_link_init()
817 dai_link->dai_fmt = daifmt; in graph_link_init()
818 dai_link->init = simple_util_dai_init; in graph_link_init()
819 dai_link->ops = &graph_ops; in graph_link_init()
820 if (priv->ops) in graph_link_init()
821 dai_link->ops = priv->ops; in graph_link_init()
868 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in audio_graph2_link_dpcm()
869 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in audio_graph2_link_dpcm()
878 * // Front-End in audio_graph2_link_dpcm()
880 * => lnk: port@0 { ep: { ... = rep }; }; in audio_graph2_link_dpcm()
883 * // Back-End in audio_graph2_link_dpcm()
891 * rport: port@0 { rep: { ... = ep } }; in audio_graph2_link_dpcm()
900 dai_link->dynamic = 1; in audio_graph2_link_dpcm()
901 dai_link->dpcm_merged_format = 1; in audio_graph2_link_dpcm()
912 * // Front-End in audio_graph2_link_dpcm()
916 * // Back-End in audio_graph2_link_dpcm()
918 * => lnk: port@0 { ep: { ... = rep; }; }; in audio_graph2_link_dpcm()
925 * rport: port@0 { rep: { ... = ep; }; }; in audio_graph2_link_dpcm()
936 dai_link->no_pcm = 1; in audio_graph2_link_dpcm()
937 dai_link->be_hw_params_fixup = simple_util_be_hw_params_fixup; in audio_graph2_link_dpcm()
957 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in audio_graph2_link_c2c()
962 int ret = -EINVAL; in audio_graph2_link_c2c()
968 * => lnk: port@0 { c2c0_ep: { ... = codec0_ep; }; }; in audio_graph2_link_c2c()
969 * port@1 { c2c1_ep: { ... = codec1_ep; }; }; in audio_graph2_link_c2c()
975 * port@0 { codec0_ep: ... }; }; in audio_graph2_link_c2c()
976 * port@1 { codec1_ep: ... }; }; in audio_graph2_link_c2c()
998 c2c_conf->formats = SNDRV_PCM_FMTBIT_S32_LE; /* update ME */ in audio_graph2_link_c2c()
999 c2c_conf->rates = SNDRV_PCM_RATE_8000_384000; in audio_graph2_link_c2c()
1000 c2c_conf->rate_min = in audio_graph2_link_c2c()
1001 c2c_conf->rate_max = val; in audio_graph2_link_c2c()
1002 c2c_conf->channels_min = in audio_graph2_link_c2c()
1003 c2c_conf->channels_max = 2; /* update ME */ in audio_graph2_link_c2c()
1005 dai_link->c2c_params = c2c_conf; in audio_graph2_link_c2c()
1006 dai_link->num_c2c_params = 1; in audio_graph2_link_c2c()
1045 int ret = -EINVAL; in graph_link()
1049 if (hooks && hooks->custom_normal) in graph_link()
1050 func = hooks->custom_normal; in graph_link()
1055 if (hooks && hooks->custom_dpcm) in graph_link()
1056 func = hooks->custom_dpcm; in graph_link()
1061 if (hooks && hooks->custom_c2c) in graph_link()
1062 func = hooks->custom_c2c; in graph_link()
1079 li->link++; in graph_link()
1087 * Multi CPU / Codec in graph_counter()
1089 * multi { in graph_counter()
1091 * => lnk: port@0 { ... }; // to pair in graph_counter()
1092 * port@1 { ... }; // Multi Element in graph_counter()
1093 * port@2 { ... }; // Multi Element in graph_counter()
1107 return of_graph_get_port_count(ports) - 1; in graph_counter()
1126 * => lnk: port { endpoint { .. }; }; in graph_count_normal()
1132 * simple-card.c :: simple_count_noml() in graph_count_normal()
1134 li->num[li->link].cpus = in graph_count_normal()
1135 li->num[li->link].platforms = graph_counter(cpu_port); in graph_count_normal()
1137 li->num[li->link].codecs = graph_counter(codec_port); in graph_count_normal()
1151 * // Front-End in graph_count_dpcm()
1153 * => lnk: port@0 { endpoint { ... }; }; in graph_count_dpcm()
1156 * // Back-End in graph_count_dpcm()
1158 * => lnk: port@0 { endpoint { ... }; }; in graph_count_dpcm()
1168 * simple-card.c :: simple_count_noml() in graph_count_dpcm()
1170 li->num[li->link].cpus = graph_counter(rport); /* FE */ in graph_count_dpcm()
1171 li->num[li->link].platforms = graph_counter(rport); in graph_count_dpcm()
1173 li->num[li->link].codecs = graph_counter(rport); /* BE */ in graph_count_dpcm()
1194 * => lnk: port@0 { endpoint { ... }; }; in graph_count_c2c()
1195 * port@1 { endpoint { ... }; }; in graph_count_c2c()
1202 * simple-card.c :: simple_count_noml() in graph_count_c2c()
1204 li->num[li->link].cpus = in graph_count_c2c()
1205 li->num[li->link].platforms = graph_counter(codec0); in graph_count_c2c()
1207 li->num[li->link].codecs = graph_counter(codec1); in graph_count_c2c()
1220 int ret = -EINVAL; in graph_count()
1222 if (li->link >= SNDRV_MAX_LINKS) { in graph_count()
1250 li->link++; in graph_count()
1266 struct device_node *node = dev->of_node; in graph_for_each_link()
1271 /* loop for all listed CPU port */ in graph_for_each_link()
1293 return -ENOMEM; in audio_graph2_parse_of()
1295 card->probe = graph_util_card_probe; in audio_graph2_parse_of()
1296 card->owner = THIS_MODULE; in audio_graph2_parse_of()
1297 card->dev = dev; in audio_graph2_parse_of()
1299 if ((hooks) && (hooks)->hook_pre) { in audio_graph2_parse_of()
1300 ret = (hooks)->hook_pre(priv); in audio_graph2_parse_of()
1306 if (!li->link) in audio_graph2_parse_of()
1307 ret = -EINVAL; in audio_graph2_parse_of()
1315 priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); in audio_graph2_parse_of()
1316 if (IS_ERR(priv->pa_gpio)) { in audio_graph2_parse_of()
1317 ret = PTR_ERR(priv->pa_gpio); in audio_graph2_parse_of()
1341 if ((hooks) && (hooks)->hook_post) { in audio_graph2_parse_of()
1342 ret = (hooks)->hook_post(priv); in audio_graph2_parse_of()
1349 ret = snd_soc_of_parse_aux_devs(card, "aux-devs"); in audio_graph2_parse_of()
1365 struct device *dev = &pdev->dev; in graph_probe()
1370 return -ENOMEM; in graph_probe()
1376 { .compatible = "audio-graph-card2", },
1383 .name = "asoc-audio-graph-card2",
1392 MODULE_ALIAS("platform:asoc-audio-graph-card2");