[alsa-devel] [PATCH 1/2][RFC] ASoC: soc-core: allow no Platform on dai_link

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Mon Feb 4 07:40:21 CET 2019


Hi Pierre

> > >>> 	codec_name
> > >>> 	codec_of_node
> > >>> 	codec_dai_name
> > >>> 	platform_name
> > >>> 	platform_of_node
> (snip)
> > The problem is that it's not just a renaming, there are multiple cases
> > where the codec_name, codec_dai_name fields are explicitly
> > handled. See my initial (compile-tested only) changes at [1]

BTW, do you think having macro for it can help us ?
This is just sample, it is including modern style multi-CPU so far,
but, conversion will be a little bit easier.
It is using samsung/bells.c driver for
single CPU/Codec/Platform sample.
We can adjust for multi CPU/Codec/Platform, I guess.

-----------
diff --git a/include/sound/soc.h b/include/sound/soc.h
index c18e076..0796b15 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -919,6 +919,8 @@ struct snd_soc_dai_link {
 	 */
 	const char *cpu_dai_name;
 
+	struct snd_soc_dai_link_component *cpus;
+	unsigned int num_cpus;
 	/*
 	 *	codec_name
 	 *	codec_of_node
@@ -1031,6 +1033,40 @@ struct snd_soc_dai_link {
 	struct list_head list; /* DAI link list of the soc card */
 	struct snd_soc_dobj dobj; /* For topology */
 };
+#define LINK_SET_LATER		{ }
+#define LINK_CPU(_dai)		{ .dai_name = _dai, }
+#define LINK_CODEC(_name, _dai)	{ .name = _name, .dai_name = _dai, }
+#define LINK_PLATFORM(_name)	{ .name = _name }
+
+#define SND_SOC_DAI_LINK_COMPONENT_CPU(name)		\
+	struct snd_soc_dai_link_component name##_cpu[]
+#define SND_SOC_DAI_LINK_COMPONENT_CODEC(name)		\
+	struct snd_soc_dai_link_component name##_codec[]
+#define SND_SOC_DAI_LINK_COMPONENT_PLATFORM(name)	\
+	struct snd_soc_dai_link_component name##_platform[]
+
+#define SND_SOC_DAI_LINK_COMPONENT_CC(name, cpu, codec) \
+	SND_SOC_DAI_LINK_COMPONENT_CPU(name)	= {cpu};\
+	SND_SOC_DAI_LINK_COMPONENT_CODEC(codec)	= {codec}
+
+#define SND_SOC_DAI_LINK_COMPONENT_CCP(name, cpu, codec, platform) \
+	SND_SOC_DAI_LINK_COMPONENT_CPU(name)		= {cpu};	\
+	SND_SOC_DAI_LINK_COMPONENT_CODEC(name)		= {codec};	\
+	SND_SOC_DAI_LINK_COMPONENT_PLATFORM(name)	= {platform}
+
+#define SND_SOC_LINK_CPU(name)		.cpus = name, .num_cpus = ARRAY_SIZE(name)
+#define SND_SOC_LINK_CODEC(name)	.codecs = name, .num_codecs = ARRAY_SIZE(name)
+#define SND_SOC_LINK_PLATFORM(name)	.platforms = name, .num_platforms = ARRAY_SIZE(name)
+
+#define SND_SOC_LINK_CC(name)		\
+	SND_SOC_LINK_CPU(name##_cpu),		\
+	SND_SOC_LINK_CODEC(name##_codec)
+
+#define SND_SOC_LINK_CCP(name)	\
+	SND_SOC_LINK_CPU(name##_cpu),		\
+	SND_SOC_LINK_CODEC(name##_codec),	\
+	SND_SOC_LINK_PLATFORM(name##_platform)
+
 #define for_each_link_codecs(link, i, codec)				\
 	for ((i) = 0;							\
 	     ((i) < link->num_codecs) && ((codec) = &link->codecs[i]);	\
diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c
index 0e66cd8..4ec2f5b 100644
--- a/sound/soc/samsung/bells.c
+++ b/sound/soc/samsung/bells.c
@@ -317,14 +317,16 @@ static struct snd_soc_dai_link bells_dai_wm5102[] = {
 	},
 };
 
+SND_SOC_DAI_LINK_COMPONENT_CCP(cpu_dsp,
+			LINK_CPU("samsung-i2s.0"),
+			LINK_CODEC("spi0.0", "wm0010-sdi1"),
+			LINK_PLATFORM("samsung-i2s.0"));
+
 static struct snd_soc_dai_link bells_dai_wm5110[] = {
 	{
 		.name = "CPU-DSP",
 		.stream_name = "CPU-DSP",
-		.cpu_dai_name = "samsung-i2s.0",
-		.codec_dai_name = "wm0010-sdi1",
-		.platform_name = "samsung-i2s.0",
-		.codec_name = "spi0.0",
+		SND_SOC_LINK_CCP(cpu_dsp),
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 	},
-- 
2.7.4




More information about the Alsa-devel mailing list