Lines Matching +full:sound +full:- +full:name +full:- +full:prefix

1 // SPDX-License-Identifier: GPL-2.0
3 // ASoC audio graph sound card support
8 // based on ${LINUX}/sound/soc/generic/simple-card.c
21 #include <sound/simple_card_utils.h>
25 #define PREFIX "audio-graph-card," macro
31 struct snd_soc_dapm_context *dapm = w->dapm; in graph_outdrv_event()
32 struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(dapm->card); in graph_outdrv_event()
36 gpiod_set_value_cansleep(priv->pa_gpio, 1); in graph_outdrv_event()
39 gpiod_set_value_cansleep(priv->pa_gpio, 0); in graph_outdrv_event()
42 return -EINVAL; in graph_outdrv_event()
71 if (ret != -ENOTSUPP) in graph_get_dai_id()
95 * Non HDMI sound case, counting port/endpoint on its DT in graph_get_dai_id()
99 id = -1; in graph_get_dai_id()
109 return -ENODEV; in graph_get_dai_id()
127 /* Get dai->name */ in asoc_simple_parse_dai()
135 * Here, dlc->dai_name is pointer to CPU/Codec DAI name. in asoc_simple_parse_dai()
136 * If user unbinded CPU or Codec driver, but not for Sound Card, in asoc_simple_parse_dai()
137 * dlc->dai_name is keeping unbinded CPU or Codec in asoc_simple_parse_dai()
140 * If user re-bind CPU or Codec driver again, ALSA SoC will try in asoc_simple_parse_dai()
142 * above reason, it might can't bind Sound Card. in asoc_simple_parse_dai()
143 * Because Sound Card is pointing to released dai_name pointer. in asoc_simple_parse_dai()
148 * 2) user need to rebind Sound Card everytime in asoc_simple_parse_dai()
151 ret = snd_soc_get_dai_name(&args, &dlc->dai_name); in asoc_simple_parse_dai()
155 dlc->of_node = node; in asoc_simple_parse_dai()
167 struct device_node *top = dev->of_node; in graph_parse_convert()
173 asoc_simple_parse_convert(dev, node, PREFIX, adata); in graph_parse_convert()
191 of_property_read_u32(top, "mclk-fs", &props->mclk_fs); in graph_parse_mclk_fs()
192 of_property_read_u32(ports, "mclk-fs", &props->mclk_fs); in graph_parse_mclk_fs()
193 of_property_read_u32(port, "mclk-fs", &props->mclk_fs); in graph_parse_mclk_fs()
194 of_property_read_u32(ep, "mclk-fs", &props->mclk_fs); in graph_parse_mclk_fs()
208 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_dai_link_of_dpcm()
209 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in graph_dai_link_of_dpcm()
210 struct device_node *top = dev->of_node; in graph_dai_link_of_dpcm()
211 struct device_node *ep = li->cpu ? cpu_ep : codec_ep; in graph_dai_link_of_dpcm()
216 struct snd_soc_dai_link_component *cpus = dai_link->cpus; in graph_dai_link_of_dpcm()
217 struct snd_soc_dai_link_component *codecs = dai_link->codecs; in graph_dai_link_of_dpcm()
221 if (!li->cpu && dup_codec) in graph_dai_link_of_dpcm()
228 li->link++; in graph_dai_link_of_dpcm()
232 if (li->cpu) { in graph_dai_link_of_dpcm()
236 codecs->of_node = NULL; in graph_dai_link_of_dpcm()
237 codecs->dai_name = "snd-soc-dummy-dai"; in graph_dai_link_of_dpcm()
238 codecs->name = "snd-soc-dummy"; in graph_dai_link_of_dpcm()
241 dai_link->dynamic = 1; in graph_dai_link_of_dpcm()
242 dai_link->dpcm_merged_format = 1; in graph_dai_link_of_dpcm()
245 dai_props->cpu_dai = &priv->dais[li->dais++]; in graph_dai_link_of_dpcm()
257 cpus->dai_name); in graph_dai_link_of_dpcm()
261 /* card->num_links includes Codec */ in graph_dai_link_of_dpcm()
267 cpus->of_node = NULL; in graph_dai_link_of_dpcm()
268 cpus->dai_name = "snd-soc-dummy-dai"; in graph_dai_link_of_dpcm()
269 cpus->name = "snd-soc-dummy"; in graph_dai_link_of_dpcm()
272 dai_link->no_pcm = 1; in graph_dai_link_of_dpcm()
273 dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; in graph_dai_link_of_dpcm()
276 dai_props->codec_dai = &priv->dais[li->dais++]; in graph_dai_link_of_dpcm()
279 dai_props->codec_conf = &priv->codec_conf[li->conf++]; in graph_dai_link_of_dpcm()
291 codecs->dai_name); in graph_dai_link_of_dpcm()
295 /* check "prefix" from top node */ in graph_dai_link_of_dpcm()
296 snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, in graph_dai_link_of_dpcm()
297 "prefix"); in graph_dai_link_of_dpcm()
298 snd_soc_of_parse_node_prefix(node, cconf, codecs->of_node, in graph_dai_link_of_dpcm()
299 PREFIX "prefix"); in graph_dai_link_of_dpcm()
300 snd_soc_of_parse_node_prefix(ports, cconf, codecs->of_node, in graph_dai_link_of_dpcm()
301 "prefix"); in graph_dai_link_of_dpcm()
302 snd_soc_of_parse_node_prefix(port, cconf, codecs->of_node, in graph_dai_link_of_dpcm()
303 "prefix"); in graph_dai_link_of_dpcm()
306 graph_parse_convert(dev, ep, &dai_props->adata); in graph_dai_link_of_dpcm()
316 NULL, &dai_link->dai_fmt); in graph_dai_link_of_dpcm()
322 dai_link->ops = &graph_ops; in graph_dai_link_of_dpcm()
323 dai_link->init = asoc_simple_dai_init; in graph_dai_link_of_dpcm()
338 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); in graph_dai_link_of()
339 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); in graph_dai_link_of()
340 struct device_node *top = dev->of_node; in graph_dai_link_of()
346 if (!li->cpu) in graph_dai_link_of()
351 li->link++; in graph_dai_link_of()
354 dai_props->cpu_dai = &priv->dais[li->dais++]; in graph_dai_link_of()
356 dai_props->codec_dai = &priv->dais[li->dais++]; in graph_dai_link_of()
363 NULL, &dai_link->dai_fmt); in graph_dai_link_of()
392 "%s-%s", in graph_dai_link_of()
393 dai_link->cpus->dai_name, in graph_dai_link_of()
394 dai_link->codecs->dai_name); in graph_dai_link_of()
398 dai_link->ops = &graph_ops; in graph_dai_link_of()
399 dai_link->init = asoc_simple_dai_init; in graph_dai_link_of()
420 struct device_node *node = dev->of_node; in graph_for_each_link()
445 /* get convert-xxx property */ in graph_for_each_link()
453 * or has convert-xxx property in graph_for_each_link()
460 /* else normal sound */ in graph_for_each_link()
492 for (li.cpu = 1; li.cpu >= 0; li.cpu--) { in graph_parse_of()
496 * In Normal sound case, all DAIs are detected in graph_parse_of()
497 * as "CPU-Codec". in graph_parse_of()
499 * In DPCM sound case, in graph_parse_of()
500 * all CPUs are detected as "CPU-dummy", and in graph_parse_of()
501 * all Codecs are detected as "dummy-Codec". in graph_parse_of()
502 * To avoid random sub-device numbering, in graph_parse_of()
503 * detect "dummy-Codec" in last; in graph_parse_of()
522 li->link += 1; /* 1xCPU-Codec */ in graph_count_noml()
523 li->dais += 2; /* 1xCPU + 1xCodec */ in graph_count_noml()
538 li->link++; /* 1xCPU-dummy */ in graph_count_dpcm()
539 li->dais++; /* 1xCPU */ in graph_count_dpcm()
542 li->link++; /* 1xdummy-Codec */ in graph_count_dpcm()
543 li->conf++; /* 1xdummy-Codec */ in graph_count_dpcm()
544 li->dais++; /* 1xCodec */ in graph_count_dpcm()
559 * CPU-Codec / CPU-dummy / dummy-Codec in graph_get_dais_count()
562 * same number for "dummy-Codec" in graph_get_dais_count()
565 * CPU0 --- Codec0 link : 5 in graph_get_dais_count()
566 * CPU1 --- Codec1 dais : 7 in graph_get_dais_count()
567 * CPU2 -/ ccnf : 1 in graph_get_dais_count()
568 * CPU3 --- Codec2 in graph_get_dais_count()
570 * => 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec in graph_get_dais_count()
572 * => 1 ccnf = 1xdummy-Codec in graph_get_dais_count()
575 * CPU0 --- Codec0 link : 5 in graph_get_dais_count()
576 * CPU1 --- Codec1 dais : 6 in graph_get_dais_count()
577 * CPU2 -/ ccnf : 1 in graph_get_dais_count()
578 * CPU3 -/ in graph_get_dais_count()
580 * => 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec in graph_get_dais_count()
582 * => 1 ccnf = 1xdummy-Codec in graph_get_dais_count()
585 * CPU0 --- Codec0 link : 6 in graph_get_dais_count()
586 * CPU1 -/ dais : 6 in graph_get_dais_count()
587 * CPU2 --- Codec1 ccnf : 2 in graph_get_dais_count()
588 * CPU3 -/ in graph_get_dais_count()
590 * => 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec in graph_get_dais_count()
592 * => 2 ccnf = 2xdummy-Codec in graph_get_dais_count()
595 * CPU0 --- Codec0 (convert-rate) link : 3 in graph_get_dais_count()
596 * CPU1 --- Codec1 dais : 4 in graph_get_dais_count()
599 * => 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec in graph_get_dais_count()
601 * => 1 ccnf = 1xdummy-Codec in graph_get_dais_count()
607 li->link, li->dais, li->conf); in graph_get_dais_count()
615 ret = asoc_simple_init_hp(card, &priv->hp_jack, NULL); in graph_card_probe()
619 ret = asoc_simple_init_mic(card, &priv->mic_jack, NULL); in graph_card_probe()
629 struct device *dev = &pdev->dev; in graph_probe()
637 return -ENOMEM; in graph_probe()
640 card->owner = THIS_MODULE; in graph_probe()
641 card->dev = dev; 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_card_probe; in graph_probe()
649 return -EINVAL; in graph_probe()
655 priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); in graph_probe()
656 if (IS_ERR(priv->pa_gpio)) { in graph_probe()
657 ret = PTR_ERR(priv->pa_gpio); in graph_probe()
664 if (ret != -EPROBE_DEFER) in graph_probe()
692 { .compatible = "audio-graph-card", },
693 { .compatible = "audio-graph-scu-card",
701 .name = "asoc-audio-graph-card",
710 MODULE_ALIAS("platform:asoc-audio-graph-card");
712 MODULE_DESCRIPTION("ASoC Audio Graph Sound Card");