Lines Matching +full:audio +full:- +full:ports

1 // SPDX-License-Identifier: GPL-2.0
3 // ASoC audio graph sound card support
8 // based on ${LINUX}/sound/soc/generic/simple-card.c
26 struct device_node *ports = of_get_parent(port); in port_to_ports() local
28 if (!of_node_name_eq(ports, "ports")) { in port_to_ports()
29 of_node_put(ports); in port_to_ports()
32 return ports; in port_to_ports()
39 struct snd_soc_dapm_context *dapm = w->dapm; in graph_outdrv_event()
40 struct simple_util_priv *priv = snd_soc_card_get_drvdata(dapm->card); in graph_outdrv_event()
44 gpiod_set_value_cansleep(priv->pa_gpio, 1); in graph_outdrv_event()
47 gpiod_set_value_cansleep(priv->pa_gpio, 0); in graph_outdrv_event()
50 return -EINVAL; in graph_outdrv_event()
72 if (dai && (dai->component->driver->pcm_construct || in soc_component_is_pcm()
73 (dai->driver->ops && dai->driver->ops->pcm_new))) in soc_component_is_pcm()
83 struct device_node *top = dev->of_node; in graph_parse_convert()
85 struct device_node *ports = port_to_ports(port); in graph_parse_convert() local
89 simple_util_parse_convert(ports, NULL, adata); in graph_parse_convert()
94 of_node_put(ports); in graph_parse_convert()
104 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_parse_node()
105 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in graph_parse_node()
140 struct device_node *top = dev->of_node; in graph_link_init()
141 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_link_init()
142 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in graph_link_init()
153 NULL, &dai_link->dai_fmt); in graph_link_init()
163 of_property_read_u32(top, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
164 of_property_read_u32(ports_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
165 of_property_read_u32(ports_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
166 of_property_read_u32(port_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
167 of_property_read_u32(port_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
168 of_property_read_u32(ep_cpu, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
169 of_property_read_u32(ep_codec, "mclk-fs", &dai_props->mclk_fs); in graph_link_init()
179 dai_link->playback_only = playback_only; in graph_link_init()
180 dai_link->capture_only = capture_only; in graph_link_init()
182 dai_link->trigger_start = trigger_start; in graph_link_init()
183 dai_link->trigger_stop = trigger_stop; in graph_link_init()
185 dai_link->init = simple_util_dai_init; in graph_link_init()
186 dai_link->ops = &graph_ops; in graph_link_init()
187 if (priv->ops) in graph_link_init()
188 dai_link->ops = priv->ops; in graph_link_init()
206 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_dai_link_of_dpcm()
207 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in graph_dai_link_of_dpcm()
208 struct device_node *top = dev->of_node; in graph_dai_link_of_dpcm()
209 struct device_node *ep = li->cpu ? cpu_ep : codec_ep; in graph_dai_link_of_dpcm()
215 if (li->cpu) { in graph_dai_link_of_dpcm()
224 dai_link->dynamic = 1; in graph_dai_link_of_dpcm()
225 dai_link->dpcm_merged_format = 1; in graph_dai_link_of_dpcm()
232 "fe.%pOFP.%s", cpus->of_node, cpus->dai_name); in graph_dai_link_of_dpcm()
234 * In BE<->BE connections it is not required to create in graph_dai_link_of_dpcm()
238 * form a valid audio path. in graph_dai_link_of_dpcm()
240 * For example: FE <-> BE1 <-> BE2 <-> ... <-> BEn where in graph_dai_link_of_dpcm()
243 if (card->component_chaining && !soc_component_is_pcm(cpus)) { in graph_dai_link_of_dpcm()
244 dai_link->no_pcm = 1; in graph_dai_link_of_dpcm()
245 dai_link->be_hw_params_fixup = simple_util_be_hw_params_fixup; in graph_dai_link_of_dpcm()
254 struct device_node *ports; in graph_dai_link_of_dpcm() local
259 dai_link->no_pcm = 1; in graph_dai_link_of_dpcm()
260 dai_link->be_hw_params_fixup = simple_util_be_hw_params_fixup; in graph_dai_link_of_dpcm()
267 "be.%pOFP.%s", codecs->of_node, codecs->dai_name); in graph_dai_link_of_dpcm()
271 ports = port_to_ports(port); in graph_dai_link_of_dpcm()
272 snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, "prefix"); in graph_dai_link_of_dpcm()
273 snd_soc_of_parse_node_prefix(ports, cconf, codecs->of_node, "prefix"); in graph_dai_link_of_dpcm()
274 snd_soc_of_parse_node_prefix(port, cconf, codecs->of_node, "prefix"); in graph_dai_link_of_dpcm()
276 of_node_put(ports); in graph_dai_link_of_dpcm()
280 graph_parse_convert(dev, ep, &dai_props->adata); in graph_dai_link_of_dpcm()
284 li->link++; in graph_dai_link_of_dpcm()
295 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_dai_link_of()
313 "%s-%s", cpus->dai_name, codecs->dai_name); in graph_dai_link_of()
322 li->link++; in graph_dai_link_of()
331 if (priv->force_dpcm) in parse_as_dpcm_link()
334 if (!priv->dpcm_selectable) in parse_as_dpcm_link()
340 * or has convert-xxx property in parse_as_dpcm_link()
362 struct device_node *node = dev->of_node; in __graph_for_each_link()
380 /* get convert-xxx property */ in __graph_for_each_link()
388 * Codec endpoint can be NULL for pluggable audio HW. in __graph_for_each_link()
393 if (li->cpu || in __graph_for_each_link()
398 if (li->cpu) in __graph_for_each_link()
431 * as "CPU-Codec". in graph_for_each_link()
434 * all CPUs are detected as "CPU-dummy", and in graph_for_each_link()
435 * all Codecs are detected as "dummy-Codec". in graph_for_each_link()
436 * To avoid random sub-device numbering, in graph_for_each_link()
437 * detect "dummy-Codec" in last; in graph_for_each_link()
439 for (li->cpu = 1; li->cpu >= 0; li->cpu--) { in graph_for_each_link()
455 if (li->link >= SNDRV_MAX_LINKS) { in graph_count_noml()
457 return -EINVAL; in graph_count_noml()
463 * simple-card.c :: simple_count_noml() in graph_count_noml()
465 li->num[li->link].cpus = 1; in graph_count_noml()
466 li->num[li->link].platforms = 1; in graph_count_noml()
468 li->num[li->link].codecs = 1; in graph_count_noml()
470 li->link += 1; /* 1xCPU-Codec */ in graph_count_noml()
484 if (li->link >= SNDRV_MAX_LINKS) { in graph_count_dpcm()
486 return -EINVAL; in graph_count_dpcm()
489 if (li->cpu) { in graph_count_dpcm()
493 * simple-card.c :: simple_count_noml() in graph_count_dpcm()
495 li->num[li->link].cpus = 1; in graph_count_dpcm()
496 li->num[li->link].platforms = 1; in graph_count_dpcm()
498 li->link++; /* 1xCPU-dummy */ in graph_count_dpcm()
500 li->num[li->link].codecs = 1; in graph_count_dpcm()
502 li->link++; /* 1xdummy-Codec */ in graph_count_dpcm()
515 * CPU-Codec / CPU-dummy / dummy-Codec in graph_get_dais_count()
518 * same number for "dummy-Codec" in graph_get_dais_count()
521 * CPU0 --- Codec0 link : 5 in graph_get_dais_count()
522 * CPU1 --- Codec1 dais : 7 in graph_get_dais_count()
523 * CPU2 -/ ccnf : 1 in graph_get_dais_count()
524 * CPU3 --- Codec2 in graph_get_dais_count()
526 * => 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec in graph_get_dais_count()
528 * => 1 ccnf = 1xdummy-Codec in graph_get_dais_count()
531 * CPU0 --- Codec0 link : 5 in graph_get_dais_count()
532 * CPU1 --- Codec1 dais : 6 in graph_get_dais_count()
533 * CPU2 -/ ccnf : 1 in graph_get_dais_count()
534 * CPU3 -/ in graph_get_dais_count()
536 * => 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec in graph_get_dais_count()
538 * => 1 ccnf = 1xdummy-Codec in graph_get_dais_count()
541 * CPU0 --- Codec0 link : 6 in graph_get_dais_count()
542 * CPU1 -/ dais : 6 in graph_get_dais_count()
543 * CPU2 --- Codec1 ccnf : 2 in graph_get_dais_count()
544 * CPU3 -/ in graph_get_dais_count()
546 * => 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec in graph_get_dais_count()
548 * => 2 ccnf = 2xdummy-Codec in graph_get_dais_count()
551 * CPU0 --- Codec0 (convert-rate) link : 3 in graph_get_dais_count()
552 * CPU1 --- Codec1 dais : 4 in graph_get_dais_count()
555 * => 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec in graph_get_dais_count()
557 * => 1 ccnf = 1xdummy-Codec in graph_get_dais_count()
571 return -ENOMEM; in audio_graph_parse_of()
573 card->owner = THIS_MODULE; in audio_graph_parse_of()
574 card->dev = dev; in audio_graph_parse_of()
580 if (!li->link) in audio_graph_parse_of()
581 return -EINVAL; in audio_graph_parse_of()
587 priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); in audio_graph_parse_of()
588 if (IS_ERR(priv->pa_gpio)) { in audio_graph_parse_of()
589 ret = PTR_ERR(priv->pa_gpio); in audio_graph_parse_of()
633 struct device *dev = &pdev->dev; in graph_probe()
639 return -ENOMEM; in graph_probe()
642 card->dapm_widgets = graph_dapm_widgets; in graph_probe()
643 card->num_dapm_widgets = ARRAY_SIZE(graph_dapm_widgets); in graph_probe()
644 card->probe = graph_util_card_probe; in graph_probe()
647 priv->dpcm_selectable = 1; in graph_probe()
653 { .compatible = "audio-graph-card", },
654 { .compatible = "audio-graph-scu-card",
662 .name = "asoc-audio-graph-card",
671 MODULE_ALIAS("platform:asoc-audio-graph-card");
673 MODULE_DESCRIPTION("ASoC Audio Graph Sound Card");