Skip to contentSkip to conversation

ASoC: clarify Codec2Codec params

PATCH RESEND In review Kuninori Morimoto 2 participants 8 messages Apr 2, 2023 – Apr 5, 2023

Subsystems (7)
lore
Share & tools
lore

Kuninori Morimoto

author maintainer
#0 lore raw

cover ASoC: clarify Codec2Codec params

Hi Mark

ASoC is supporting Codec2Codec, but its parameter name is "params" and "num_params" which are very unclear naming.

This patch-set clarifies it by replacing to c2c_params / num_c2c_params.

Kuninori Morimoto (5):
ASoC: soc.h: clarify Codec2Codec params
ASoC: audio-graph-card2: switch to use c2c_params instead of params
ASoC: meson: switch to use c2c_params instead of params
ASoC: samsung: switch to use c2c_params instead of params
ASoC: soc.h: remove unused params/num_params

 include/sound/soc.h                   |  9 ++++--
 sound/soc/generic/audio-graph-card2.c |  4 +--
 sound/soc/generic/simple-card-utils.c | 24 +++++++--------
 sound/soc/meson/axg-card.c            |  3 +-
 sound/soc/meson/gx-card.c             |  3 +-
 sound/soc/meson/meson-codec-glue.c    |  5 +--
 sound/soc/samsung/aries_wm8994.c      |  6 ++--
 sound/soc/samsung/bells.c             | 21 ++++++++-----
 sound/soc/samsung/littlemill.c        |  3 +-
 sound/soc/samsung/lowland.c           |  3 +-
 sound/soc/samsung/speyside.c          |  3 +-
 sound/soc/soc-dapm.c                  | 44 +++++++++++++--------------
 sound/soc/soc-pcm.c                   | 10 +++---
 13 files changed, 78 insertions(+), 60 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH RESEND 1/5 ASoC: soc.h: clarify Codec2Codec params

From: Kuninori Morimoto <[email protected]>

snd_soc_dai_link has params/num_params, but it is unclear that params for what. This patch clarify it is params for Codec2Codec.

---
 include/sound/soc.h  | 12 +++++++++---
 sound/soc/soc-core.c | 11 +++++++++++
 sound/soc/soc-dapm.c | 44 ++++++++++++++++++++++----------------------
 sound/soc/soc-pcm.c  | 10 +++++-----
 4 files changed, 47 insertions(+), 30 deletions(-)
include/sound/soc.h +9 -3
index 57c5786a625b..276afdb1f445 100644
@@ -684,8 +684,14 @@ struct snd_soc_dai_link {
 
 	int id;	/* optional ID for machine driver link identification */
 
-	const struct snd_soc_pcm_stream *params;
-	unsigned int num_params;
+	/*
+	 * for Codec2Codec
+	 */
+	const struct snd_soc_pcm_stream *c2c_params;
+	unsigned int num_c2c_params;
+
+	const struct snd_soc_pcm_stream *params;	/* REMOVE ME */
+	unsigned int num_params;			/* REMOVE ME */
 
 	unsigned int dai_fmt;           /* format to set on init */
 
@@ -1065,7 +1071,7 @@ struct snd_soc_pcm_runtime {
 	struct snd_soc_dai_link *dai_link;
 	struct snd_pcm_ops ops;
 
-	unsigned int params_select; /* currently selected param for dai link */
+	unsigned int c2c_params_select; /* currently selected c2c_param for dai link */
 
 	/* Dynamic PCM BE runtime data */
 	struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
sound/soc/soc-core.c +11 -0
index 9bbcff492c1e..04f1bc8a3128 100644
@@ -2294,6 +2294,9 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
  */
 int snd_soc_register_card(struct snd_soc_card *card)
 {
+	struct snd_soc_dai_link *dai_link;
+	int i;
+
 	if (!card->name || !card->dev)
 		return -EINVAL;
 
@@ -2314,6 +2317,14 @@ int snd_soc_register_card(struct snd_soc_card *card)
 	mutex_init(&card->dapm_mutex);
 	mutex_init(&card->pcm_mutex);
 
+	/* REMOVE ME */
+	for_each_card_prelinks(card, i, dai_link) {
+		if (!dai_link->c2c_params) {
+			dai_link->c2c_params	 = dai_link->params;
+			dai_link->num_c2c_params = dai_link->num_params;
+		}
+	}
+
 	return snd_soc_bind_card(card);
 }
 EXPORT_SYMBOL_GPL(snd_soc_register_card);
sound/soc/soc-dapm.c +22 -22

147 lines not on this page · raw message

sound/soc/soc-pcm.c +5 -5
index b830a53ceacb..913a7d98e742 100644
@@ -2793,9 +2793,9 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
 		struct snd_soc_dai *codec_dai;
 
 		/* Adapt stream for codec2codec links */
-		int cpu_capture = rtd->dai_link->params ?
+		int cpu_capture = rtd->dai_link->c2c_params ?
 			SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
-		int cpu_playback = rtd->dai_link->params ?
+		int cpu_playback = rtd->dai_link->c2c_params ?
 			SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
 
 		for_each_rtd_codec_dais(rtd, i, codec_dai) {
@@ -2839,7 +2839,7 @@ static int soc_create_pcm(struct snd_pcm **pcm,
 	int ret;
 
 	/* create the PCM */
-	if (rtd->dai_link->params) {
+	if (rtd->dai_link->c2c_params) {
 		snprintf(new_name, sizeof(new_name), "codec2codec(%s)",
 			 rtd->dai_link->stream_name);
 
@@ -2896,7 +2896,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 	 * don't interface with the outside world or application layer
 	 * we don't have to do any special handling on close.
 	 */
-	if (!rtd->dai_link->params)
+	if (!rtd->dai_link->c2c_params)
 		rtd->close_delayed_work_func = snd_soc_close_delayed_work;
 
 	rtd->pcm = pcm;
@@ -2904,7 +2904,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 	pcm->private_data = rtd;
 	pcm->no_device_suspend = true;
 
-	if (rtd->dai_link->no_pcm || rtd->dai_link->params) {
+	if (rtd->dai_link->no_pcm || rtd->dai_link->c2c_params) {
 		if (playback)
 			pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
 		if (capture)
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH RESEND 2/5 ASoC: audio-graph-card2: switch to use c2c_params instead of params

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

ASoC is now using c2c_params instead of params. This patch replace it.

---
 sound/soc/generic/audio-graph-card2.c |  4 ++--
 sound/soc/generic/simple-card-utils.c | 24 ++++++++++++------------
 2 files changed, 14 insertions(+), 14 deletions(-)
sound/soc/generic/audio-graph-card2.c +2 -2
index d145b74d41e4..25aa79dd55b3 100644
@@ -920,8 +920,8 @@ int audio_graph2_link_c2c(struct asoc_simple_priv *priv,
 		c2c_conf->channels_min	=
 		c2c_conf->channels_max	= 2; /* update ME */
 
-		dai_link->params	= c2c_conf;
-		dai_link->num_params	= 1;
+		dai_link->c2c_params		= c2c_conf;
+		dai_link->num_c2c_params	= 1;
 	}
 
 	ep0 = port_to_endpoint(port0);
sound/soc/generic/simple-card-utils.c +12 -12
index 34a9b91e676f..467edd96eae5 100644
@@ -562,12 +562,12 @@ static int asoc_simple_init_for_codec2codec(struct snd_soc_pcm_runtime *rtd,
 {
 	struct snd_soc_dai_link *dai_link = rtd->dai_link;
 	struct snd_soc_component *component;
-	struct snd_soc_pcm_stream *params;
+	struct snd_soc_pcm_stream *c2c_params;
 	struct snd_pcm_hardware hw;
 	int i, ret, stream;
 
 	/* Do nothing if it already has Codec2Codec settings */
-	if (dai_link->params)
+	if (dai_link->c2c_params)
 		return 0;
 
 	/* Do nothing if it was DPCM :: BE */
@@ -592,19 +592,19 @@ static int asoc_simple_init_for_codec2codec(struct snd_soc_pcm_runtime *rtd,
 		return ret;
 	}
 
-	params = devm_kzalloc(rtd->dev, sizeof(*params), GFP_KERNEL);
-	if (!params)
+	c2c_params = devm_kzalloc(rtd->dev, sizeof(*c2c_params), GFP_KERNEL);
+	if (!c2c_params)
 		return -ENOMEM;
 
-	params->formats = hw.formats;
-	params->rates = hw.rates;
-	params->rate_min = hw.rate_min;
-	params->rate_max = hw.rate_max;
-	params->channels_min = hw.channels_min;
-	params->channels_max = hw.channels_max;
+	c2c_params->formats		= hw.formats;
+	c2c_params->rates		= hw.rates;
+	c2c_params->rate_min		= hw.rate_min;
+	c2c_params->rate_max		= hw.rate_max;
+	c2c_params->channels_min	= hw.channels_min;
+	c2c_params->channels_max	= hw.channels_max;
 
-	dai_link->params = params;
-	dai_link->num_params = 1;
+	dai_link->c2c_params		= c2c_params;
+	dai_link->num_c2c_params	= 1;
 
 	return 0;
 }
Signature · 1 line
2.25.1
author maintainer
#3 lore raw

PATCH RESEND 3/5 ASoC: meson: switch to use c2c_params instead of params

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

ASoC is now using c2c_params instead of params. This patch replace it. num_c2c_params (was num_params) was not mandatory before, but let's set it by this patch.

---
 sound/soc/meson/axg-card.c         | 3 ++-
 sound/soc/meson/gx-card.c          | 3 ++-
 sound/soc/meson/meson-codec-glue.c | 5 +++--
 3 files changed, 7 insertions(+), 4 deletions(-)
sound/soc/meson/axg-card.c +2 -1
index 2b77010c2c5c..a25c397c66c5 100644
@@ -337,7 +337,8 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
 		return ret;
 
 	if (axg_card_cpu_is_codec(dai_link->cpus->of_node)) {
-		dai_link->params = &codec_params;
+		dai_link->c2c_params = &codec_params;
+		dai_link->num_c2c_params = 1;
 	} else {
 		dai_link->no_pcm = 1;
 		snd_soc_dai_link_set_capabilities(dai_link);
sound/soc/meson/gx-card.c +2 -1
index 5119434a81c4..58c411d3c489 100644
@@ -104,7 +104,8 @@ static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
 
 	/* Or apply codec to codec params if necessary */
 	if (gx_card_cpu_identify(dai_link->cpus, "CODEC CTRL")) {
-		dai_link->params = &codec_params;
+		dai_link->c2c_params = &codec_params;
+		dai_link->num_c2c_params = 1;
 	} else {
 		dai_link->no_pcm = 1;
 		snd_soc_dai_link_set_capabilities(dai_link);
sound/soc/meson/meson-codec-glue.c +3 -2
index 5913486c43ab..e702d408ee96 100644
@@ -105,13 +105,14 @@ int meson_codec_glue_output_startup(struct snd_pcm_substream *substream,
 	if (!in_data)
 		return -ENODEV;
 
-	if (WARN_ON(!rtd->dai_link->params)) {
+	if (WARN_ON(!rtd->dai_link->c2c_params)) {
 		dev_warn(dai->dev, "codec2codec link expected\n");
 		return -EINVAL;
 	}
 
 	/* Replace link params with the input params */
-	rtd->dai_link->params = &in_data->params;
+	rtd->dai_link->c2c_params = &in_data->params;
+	rtd->dai_link->num_c2c_params = 1;
 
 	return snd_soc_runtime_set_dai_fmt(rtd, in_data->fmt);
 }
Signature · 1 line
2.25.1
author maintainer
#4 lore raw

PATCH RESEND 4/5 ASoC: samsung: switch to use c2c_params instead of params

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

ASoC is now using c2c_params instead of params. This patch replace it. num_c2c_params (was num_params) was not mandatory before, but let's set it by this patch.

---
 sound/soc/samsung/aries_wm8994.c |  6 ++++--
 sound/soc/samsung/bells.c        | 21 ++++++++++++++-------
 sound/soc/samsung/littlemill.c   |  3 ++-
 sound/soc/samsung/lowland.c      |  3 ++-
 sound/soc/samsung/speyside.c     |  3 ++-
 5 files changed, 24 insertions(+), 12 deletions(-)
sound/soc/samsung/aries_wm8994.c +4 -2
index 0fbbf3b02c09..7492bb41456c 100644
@@ -483,14 +483,16 @@ static struct snd_soc_dai_link aries_dai[] = {
 		.name = "WM8994 AIF2",
 		.stream_name = "Baseband",
 		.init = &aries_baseband_init,
-		.params = &baseband_params,
+		.c2c_params = &baseband_params,
+		.num_c2c_params = 1,
 		.ignore_suspend = 1,
 		SND_SOC_DAILINK_REG(baseband),
 	},
 	{
 		.name = "WM8994 AIF3",
 		.stream_name = "Bluetooth",
-		.params = &bluetooth_params,
+		.c2c_params = &bluetooth_params,
+		.num_c2c_params = 1,
 		.ignore_suspend = 1,
 		SND_SOC_DAILINK_REG(bluetooth),
 	},
sound/soc/samsung/bells.c +14 -7
index 76998a4a4cad..70b63d4faa99 100644
@@ -264,7 +264,8 @@ static struct snd_soc_dai_link bells_dai_wm2200[] = {
 		.stream_name = "DSP-CODEC",
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
-		.params = &sub_params,
+		.c2c_params = &sub_params,
+		.num_c2c_params = 1,
 		.ignore_suspend = 1,
 		SND_SOC_DAILINK_REG(wm2200_dsp_codec),
 	},
@@ -300,7 +301,8 @@ static struct snd_soc_dai_link bells_dai_wm5102[] = {
 		.stream_name = "DSP-CODEC",
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
-		.params = &sub_params,
+		.c2c_params = &sub_params,
+		.num_c2c_params = 1,
 		.ignore_suspend = 1,
 		SND_SOC_DAILINK_REG(wm5102_dsp_codec),
 	},
@@ -310,7 +312,8 @@ static struct snd_soc_dai_link bells_dai_wm5102[] = {
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.ignore_suspend = 1,
-		.params = &baseband_params,
+		.c2c_params = &baseband_params,
+		.num_c2c_params = 1,
 		SND_SOC_DAILINK_REG(wm5102_baseband),
 	},
 	{
@@ -319,7 +322,8 @@ static struct snd_soc_dai_link bells_dai_wm5102[] = {
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBS_CFS,
 		.ignore_suspend = 1,
-		.params = &sub_params,
+		.c2c_params = &sub_params,
+		.num_c2c_params = 1,
 		SND_SOC_DAILINK_REG(wm5102_sub),
 	},
 };
@@ -355,7 +359,8 @@ static struct snd_soc_dai_link bells_dai_wm5110[] = {
 		.stream_name = "DSP-CODEC",
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
-		.params = &sub_params,
+		.c2c_params = &sub_params,
+		.num_c2c_params = 1,
 		.ignore_suspend = 1,
 		SND_SOC_DAILINK_REG(wm5110_dsp_codec),
 	},
@@ -365,7 +370,8 @@ static struct snd_soc_dai_link bells_dai_wm5110[] = {
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.ignore_suspend = 1,
-		.params = &baseband_params,
+		.c2c_params = &baseband_params,
+		.num_c2c_params = 1,
 		SND_SOC_DAILINK_REG(wm5110_baseband),
 	},
 	{
@@ -374,7 +380,8 @@ static struct snd_soc_dai_link bells_dai_wm5110[] = {
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBS_CFS,
 		.ignore_suspend = 1,
-		.params = &sub_params,
+		.c2c_params = &sub_params,
+		.num_c2c_params = 1,
 		SND_SOC_DAILINK_REG(wm5110_sub),
 	},
 };
sound/soc/samsung/littlemill.c +2 -1
index 411e25cec591..5d8118e69359 100644
@@ -167,7 +167,8 @@ static struct snd_soc_dai_link littlemill_dai[] = {
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.ignore_suspend = 1,
-		.params = &baseband_params,
+		.c2c_params = &baseband_params,
+		.num_c2c_params = 1,
 		SND_SOC_DAILINK_REG(baseband),
 	},
 };
sound/soc/samsung/lowland.c +2 -1
index b44f5e92224f..106770be6fc5 100644
@@ -119,7 +119,8 @@ static struct snd_soc_dai_link lowland_dai[] = {
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 				SND_SOC_DAIFMT_CBM_CFM,
 		.ignore_suspend = 1,
-		.params = &sub_params,
+		.c2c_params = &sub_params,
+		.num_c2c_params = 1,
 		.init = lowland_wm9081_init,
 		SND_SOC_DAILINK_REG(speaker),
 	},
sound/soc/samsung/speyside.c +2 -1
index 69d7b0115b38..22e2ad63d64d 100644
@@ -219,7 +219,8 @@ static struct snd_soc_dai_link speyside_dai[] = {
 		.init = speyside_wm8996_init,
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
-		.params = &dsp_codec_params,
+		.c2c_params = &dsp_codec_params,
+		.num_c2c_params = 1,
 		.ignore_suspend = 1,
 		SND_SOC_DAILINK_REG(dsp_codec),
 	},
Signature · 1 line
2.25.1
author maintainer
#5 lore raw

PATCH RESEND 5/5 ASoC: soc.h: remove unused params/num_params

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

No drivers are using params/num_params any more.
Let's remove these.

---
 include/sound/soc.h  |  3 ---
 sound/soc/soc-core.c | 11 -----------
 2 files changed, 14 deletions(-)
include/sound/soc.h +0 -3
index 276afdb1f445..3833184c187f 100644
@@ -690,9 +690,6 @@ struct snd_soc_dai_link {
 	const struct snd_soc_pcm_stream *c2c_params;
 	unsigned int num_c2c_params;
 
-	const struct snd_soc_pcm_stream *params;	/* REMOVE ME */
-	unsigned int num_params;			/* REMOVE ME */
-
 	unsigned int dai_fmt;           /* format to set on init */
 
 	enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
sound/soc/soc-core.c +0 -11
index 04f1bc8a3128..9bbcff492c1e 100644
@@ -2294,9 +2294,6 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
  */
 int snd_soc_register_card(struct snd_soc_card *card)
 {
-	struct snd_soc_dai_link *dai_link;
-	int i;
-
 	if (!card->name || !card->dev)
 		return -EINVAL;
 
@@ -2317,14 +2314,6 @@ int snd_soc_register_card(struct snd_soc_card *card)
 	mutex_init(&card->dapm_mutex);
 	mutex_init(&card->pcm_mutex);
 
-	/* REMOVE ME */
-	for_each_card_prelinks(card, i, dai_link) {
-		if (!dai_link->c2c_params) {
-			dai_link->c2c_params	 = dai_link->params;
-			dai_link->num_c2c_params = dai_link->num_params;
-		}
-	}
-
 	return snd_soc_bind_card(card);
 }
 EXPORT_SYMBOL_GPL(snd_soc_register_card);
Signature · 1 line
2.25.1
maintainer
#6 lore raw
In reply to Kuninori Morimoto
Quoted 7 lines · Kuninori Morimoto

Hi Mark

ASoC is supporting Codec2Codec, but its parameter name is "params" and "num_params" which are very unclear naming.

This patch-set clarifies it by replacing to c2c_params / num_c2c_params.

You should copy the maintainers of the drivers you're updating on the patches for those drivers, otherwise people might not see and review them.

maintainer
#7 lore raw
In reply to Kuninori Morimoto
Quoted 8 lines · Kuninori Morimoto

ASoC is supporting Codec2Codec, but its parameter name is "params" and "num_params" which are very unclear naming.

This patch-set clarifies it by replacing to c2c_params / num_c2c_params.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/5] ASoC: soc.h: clarify Codec2Codec params

      commit: 7ddc7f91beb285246e926e3adf0b292b071aea33
[2/5] ASoC: audio-graph-card2: switch to use c2c_params instead of params
      commit: a1cd7e8017aabe4dded887dcca30e126ec2753c3
[3/5] ASoC: meson: switch to use c2c_params instead of params
      commit: 433f4a1697fae78c34377de1ef3abd26aec8214e
[4/5] ASoC: samsung: switch to use c2c_params instead of params
      commit: e7a73b05542d82e209af450dd90b730255f6e775
[5/5] ASoC: soc.h: remove unused params/num_params
      commit: 1ea63f29c27712d6b9c45af67cd71299d849c5e3

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark