diff mbox series

[2/6] ASoC: simple-card-utils: alloc dai_link information for CPU/Codec/Platform

Message ID 87blb61tpv.wl-kuninori.morimoto.gx@renesas.com
State Accepted
Commit 050c7950fd706fec229af9f30e8ce254cea9b675
Headers show
Series ASoC: simple-card: cleanup and prepare for Multi CPU/Codec support | expand

Commit Message

Kuninori Morimoto March 26, 2021, 3:26 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

simple-card / audio-graph are assuming single CPU/Codec/Platform on
dai_link. Because of it, it is difficult to support Multi-CPU/Codec.

This patch allocs CPU/Codec/Platform dai_link imformation
instead of using existing props information. It can update to
multi-CPU/Codec, but is still assuming single-CPU/Codec for now.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     |  7 ++++---
 sound/soc/generic/simple-card-utils.c | 15 +++++++++++----
 2 files changed, 15 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index ba4a3e1897b9..86e46cbf9e14 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -43,9 +43,9 @@  struct asoc_simple_priv {
 	struct simple_dai_props {
 		struct asoc_simple_dai *cpu_dai;
 		struct asoc_simple_dai *codec_dai;
-		struct snd_soc_dai_link_component cpus;   /* single cpu */
-		struct snd_soc_dai_link_component codecs; /* single codec */
-		struct snd_soc_dai_link_component platforms;
+		struct snd_soc_dai_link_component *cpus;
+		struct snd_soc_dai_link_component *codecs;
+		struct snd_soc_dai_link_component *platforms;
 		struct asoc_simple_data adata;
 		struct snd_soc_codec_conf *codec_conf;
 		unsigned int mclk_fs;
@@ -54,6 +54,7 @@  struct asoc_simple_priv {
 	struct asoc_simple_jack mic_jack;
 	struct snd_soc_dai_link *dai_link;
 	struct asoc_simple_dai *dais;
+	struct snd_soc_dai_link_component *dlcs;
 	struct snd_soc_codec_conf *codec_conf;
 	struct gpio_desc *pa_gpio;
 	const struct snd_soc_ops *ops;
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 6897455219d1..f05954529dfc 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -601,13 +601,15 @@  int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 	struct snd_soc_dai_link *dai_link;
 	struct simple_dai_props *dai_props;
 	struct asoc_simple_dai *dais;
+	struct snd_soc_dai_link_component *dlcs;
 	struct snd_soc_codec_conf *cconf = NULL;
 	int i;
 
 	dai_props = devm_kcalloc(dev, li->link, sizeof(*dai_props), GFP_KERNEL);
 	dai_link  = devm_kcalloc(dev, li->link, sizeof(*dai_link),  GFP_KERNEL);
 	dais      = devm_kcalloc(dev, li->dais, sizeof(*dais),      GFP_KERNEL);
-	if (!dai_props || !dai_link || !dais)
+	dlcs      = devm_kcalloc(dev, li->link * 3, sizeof(*dai_props), GFP_KERNEL);
+	if (!dai_props || !dai_link || !dais || !dlcs)
 		return -ENOMEM;
 
 	if (li->conf) {
@@ -622,17 +624,22 @@  int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 	 *	simple-card-utils.c :: asoc_simple_canonicalize_platform()
 	 */
 	for (i = 0; i < li->link; i++) {
-		dai_link[i].cpus		= &dai_props[i].cpus;
+		dai_props[i].cpus	= dlcs + (3 * i) + 0;
+		dai_props[i].codecs	= dlcs + (3 * i) + 1;
+		dai_props[i].platforms	= dlcs + (3 * i) + 2;
+
+		dai_link[i].cpus		= dai_props[i].cpus;
 		dai_link[i].num_cpus		= 1;
-		dai_link[i].codecs		= &dai_props[i].codecs;
+		dai_link[i].codecs		= dai_props[i].codecs;
 		dai_link[i].num_codecs		= 1;
-		dai_link[i].platforms		= &dai_props[i].platforms;
+		dai_link[i].platforms		= dai_props[i].platforms;
 		dai_link[i].num_platforms	= 1;
 	}
 
 	priv->dai_props		= dai_props;
 	priv->dai_link		= dai_link;
 	priv->dais		= dais;
+	priv->dlcs		= dlcs;
 	priv->codec_conf	= cconf;
 
 	card->dai_link		= priv->dai_link;