All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: don't use original dummy dlc
@ 2023-12-04  1:31 Kuninori Morimoto
  2023-12-04  1:31 ` [PATCH 1/5] ASoC: fsl: fsl-asoc-card: don't need DUMMY Platform Kuninori Morimoto
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2023-12-04  1:31 UTC (permalink / raw)
  To: Bard Liao, Brent Lu, Cezary Rojewski, Daniel Baluta,
	Jaroslav Kysela, Kai Vehmanen, Liam Girdwood, Liam Girdwood,
	Mark Brown, Peter Ujfalusi, Pierre-Louis Bossart,
	Ranjani Sridharan, Shengjiu Wang, Sylwester Nawrocki,
	Takashi Iwai, Xiubo Li
  Cc: Fabio Estevam, Kai Vehmanen, Nicolin Chen, alsa-devel, linux-sound


Hi Mark, and each driver owner

This patch-set try to not use original dummy dlc.

"Empty" dlc might be used on Platform, but "dummy" dlc is not needed
for it. [PATCH 1/5][PATCH 2/5] removes "dummy" dlc from Platform.

Now ASoC have common dummy dlc (= snd_soc_dummy_dlc).
[PATCH 3/5][PATCH 4/5] will use it instead of original dummy dlc.

Many drivers are using below macro

	SND_SOC_DAILINK_DEFS(link,
		     DAILINK_COMP_ARRAY(COMP_CPU(...)),
(X)		     DAILINK_COMP_ARRAY(COMP_DUMMY()),
		     DAILINK_COMP_ARRAY(COMP_EMPTY()));

But (X) part will create original dummy dlc.
[PATCH 5/5] will try not to create original dummy dlc, and replace
it to common dummy dlc.

Kuninori Morimoto (5):
  ASoC: fsl: fsl-asoc-card: don't need DUMMY Platform
  ASoC: samsung: odroid: don't need DUMMY Platform
  ASoC: intel: hdaudio.c: use snd_soc_dummy_dlc
  ASoC: sof: use snd_soc_dummy_dlc
  ASoC: soc.h: don't create dummy Component via COMP_DUMMY()

 include/sound/soc.h                  |  2 +-
 sound/soc/fsl/fsl-asoc-card.c        |  3 +--
 sound/soc/intel/avs/boards/hdaudio.c |  6 ++----
 sound/soc/samsung/odroid.c           |  3 +--
 sound/soc/soc-core.c                 | 30 ++++++++++++++++++++++++++++
 sound/soc/sof/sof-client-probes.c    |  4 +---
 6 files changed, 36 insertions(+), 12 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] ASoC: fsl: fsl-asoc-card: don't need DUMMY Platform
  2023-12-04  1:31 [PATCH 0/5] ASoC: don't use original dummy dlc Kuninori Morimoto
@ 2023-12-04  1:31 ` Kuninori Morimoto
  2023-12-04  1:31 ` [PATCH 2/5] ASoC: samsung: odroid: " Kuninori Morimoto
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2023-12-04  1:31 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Shengjiu Wang,
	Takashi Iwai, Xiubo Li
  Cc: Fabio Estevam, Nicolin Chen, alsa-devel, linux-sound

We can use SND_SOC_DAILINK_REG() with 2 parameter.
DUMMY Platform is not needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/fsl/fsl-asoc-card.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 7518ab9d768e..bc07f26ba303 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -305,8 +305,7 @@ SND_SOC_DAILINK_DEFS(hifi_fe,
 
 SND_SOC_DAILINK_DEFS(hifi_be,
 	DAILINK_COMP_ARRAY(COMP_EMPTY()),
-	DAILINK_COMP_ARRAY(COMP_EMPTY()),
-	DAILINK_COMP_ARRAY(COMP_DUMMY()));
+	DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 static const struct snd_soc_dai_link fsl_asoc_card_dai[] = {
 	/* Default ASoC DAI Link*/
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] ASoC: samsung: odroid: don't need DUMMY Platform
  2023-12-04  1:31 [PATCH 0/5] ASoC: don't use original dummy dlc Kuninori Morimoto
  2023-12-04  1:31 ` [PATCH 1/5] ASoC: fsl: fsl-asoc-card: don't need DUMMY Platform Kuninori Morimoto
@ 2023-12-04  1:31 ` Kuninori Morimoto
  2023-12-04  1:31 ` [PATCH 3/5] ASoC: intel: hdaudio.c: use snd_soc_dummy_dlc Kuninori Morimoto
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2023-12-04  1:31 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Sylwester Nawrocki,
	Takashi Iwai
  Cc: alsa-devel, linux-sound

We can use SND_SOC_DAILINK_REG() with 2 parameter.
DUMMY Platform is not needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/samsung/odroid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index e95f3d3f0401..110ae14dd7ea 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -157,8 +157,7 @@ SND_SOC_DAILINK_DEFS(primary,
 
 SND_SOC_DAILINK_DEFS(mixer,
 	DAILINK_COMP_ARRAY(COMP_DUMMY()),
-	DAILINK_COMP_ARRAY(COMP_EMPTY()),
-	DAILINK_COMP_ARRAY(COMP_DUMMY()));
+	DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 SND_SOC_DAILINK_DEFS(secondary,
 	DAILINK_COMP_ARRAY(COMP_EMPTY()),
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] ASoC: intel: hdaudio.c: use snd_soc_dummy_dlc
  2023-12-04  1:31 [PATCH 0/5] ASoC: don't use original dummy dlc Kuninori Morimoto
  2023-12-04  1:31 ` [PATCH 1/5] ASoC: fsl: fsl-asoc-card: don't need DUMMY Platform Kuninori Morimoto
  2023-12-04  1:31 ` [PATCH 2/5] ASoC: samsung: odroid: " Kuninori Morimoto
@ 2023-12-04  1:31 ` Kuninori Morimoto
  2023-12-04  1:31 ` [PATCH 4/5] ASoC: sof: " Kuninori Morimoto
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2023-12-04  1:31 UTC (permalink / raw)
  To: Bard Liao, Brent Lu, Cezary Rojewski, Jaroslav Kysela,
	Kai Vehmanen, Liam Girdwood, Mark Brown, Peter Ujfalusi,
	Pierre-Louis Bossart, Ranjani Sridharan, Takashi Iwai
  Cc: alsa-devel, linux-sound

We already have snd_soc_dummy_dlc.
Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/intel/avs/boards/hdaudio.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/avs/boards/hdaudio.c b/sound/soc/intel/avs/boards/hdaudio.c
index 844a918f9a81..79b4aca41333 100644
--- a/sound/soc/intel/avs/boards/hdaudio.c
+++ b/sound/soc/intel/avs/boards/hdaudio.c
@@ -155,8 +155,6 @@ static int avs_probing_link_init(struct snd_soc_pcm_runtime *rtm)
 	return 0;
 }
 
-SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY()));
-
 static struct snd_soc_dai_link probing_link = {
 	.name = "probing-LINK",
 	.id = -1,
@@ -164,8 +162,8 @@ static struct snd_soc_dai_link probing_link = {
 	.no_pcm = 1,
 	.dpcm_playback = 1,
 	.dpcm_capture = 1,
-	.cpus = dummy,
-	.num_cpus = ARRAY_SIZE(dummy),
+	.cpus = &snd_soc_dummy_dlc,
+	.num_cpus = 1,
 	.init = avs_probing_link_init,
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] ASoC: sof: use snd_soc_dummy_dlc
  2023-12-04  1:31 [PATCH 0/5] ASoC: don't use original dummy dlc Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2023-12-04  1:31 ` [PATCH 3/5] ASoC: intel: hdaudio.c: use snd_soc_dummy_dlc Kuninori Morimoto
@ 2023-12-04  1:31 ` Kuninori Morimoto
  2023-12-04  1:31 ` [PATCH 5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY() Kuninori Morimoto
  2023-12-19 18:06 ` [PATCH 0/5] ASoC: don't use original dummy dlc Mark Brown
  5 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2023-12-04  1:31 UTC (permalink / raw)
  To: Bard Liao, Daniel Baluta, Jaroslav Kysela, Liam Girdwood,
	Mark Brown, Peter Ujfalusi, Pierre-Louis Bossart,
	Ranjani Sridharan, Takashi Iwai
  Cc: Kai Vehmanen, alsa-devel, linux-sound

We already have snd_soc_dummy_dlc.
Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sof/sof-client-probes.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/soc/sof/sof-client-probes.c b/sound/soc/sof/sof-client-probes.c
index 7cc9e8f18de7..30f771ac7bbf 100644
--- a/sound/soc/sof/sof-client-probes.c
+++ b/sound/soc/sof/sof-client-probes.c
@@ -381,8 +381,6 @@ static const struct snd_soc_component_driver sof_probes_component = {
 	.legacy_dai_naming = 1,
 };
 
-SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY()));
-
 static int sof_probes_client_probe(struct auxiliary_device *auxdev,
 				   const struct auxiliary_device_id *id)
 {
@@ -475,7 +473,7 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev,
 	links[0].cpus = &cpus[0];
 	links[0].num_cpus = 1;
 	links[0].cpus->dai_name = "Probe Extraction CPU DAI";
-	links[0].codecs = dummy;
+	links[0].codecs = &snd_soc_dummy_dlc;
 	links[0].num_codecs = 1;
 	links[0].platforms = platform_component;
 	links[0].num_platforms = ARRAY_SIZE(platform_component);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY()
  2023-12-04  1:31 [PATCH 0/5] ASoC: don't use original dummy dlc Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2023-12-04  1:31 ` [PATCH 4/5] ASoC: sof: " Kuninori Morimoto
@ 2023-12-04  1:31 ` Kuninori Morimoto
  2023-12-04 15:44   ` Amadeusz Sławiński
  2023-12-19 18:06 ` [PATCH 0/5] ASoC: don't use original dummy dlc Mark Brown
  5 siblings, 1 reply; 10+ messages in thread
From: Kuninori Morimoto @ 2023-12-04  1:31 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Takashi Iwai
  Cc: alsa-devel, linux-sound

Many ASoC drivers define CPU/Codec/Platform dai_link by below macro.

	SND_SOC_DAILINK_DEFS(link,
(A)		     DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
(B)		     DAILINK_COMP_ARRAY(COMP_CODEC("codec", "dai1"),
(B)					COMP_CODEC("codec", "dai2")),
(C)		     DAILINK_COMP_ARRAY(COMP_EMPTY()));

In this case, this macro will be converted to like below

	[o] = static struct snd_soc_dai_link_component

(A)	[o] link_cpus[]      = {{ .dai_name = "cpu_dai" }};
(B)	[o] link_codecs[]    = {{ .dai_name = "dai1", .name = "codec" },
				{ .dai_name = "dai2", .name = "codec" }}
(C)	[o] link_platforms[] = {{ }};

CPU and Codec info will be filled by COMP_CPU() / COMP_CODEC (= A,B),
and Platform will have empty data by COMP_EMPTY() (= C) in this case.

Platform empty info will be filled when driver probe()
(most of case, CPU info will be copied to use soc-generic-dmaengine-pcm).

For example in case of DPCM FE/BE, it will be like below.
Codec will be dummy Component / DAI in this case (X).

	SND_SOC_DAILINK_DEFS(link,
		     DAILINK_COMP_ARRAY(COMP_CPU(...)),
(X)		     DAILINK_COMP_ARRAY(COMP_DUMMY()),
		     DAILINK_COMP_ARRAY(COMP_EMPTY()));

(X) part will converted like below

	[o] link_codecs[]    = {{ .name = "snd-soc-dummy",
				  .dai_name = "snd-soc-dummy-dai", }}

Even though we already have common asoc_dummy_dlc for dummy
Component / DAI, this macro will re-create new dummy dlc.
Some drivers defines many dai_link info via SND_SOC_DAILINK_DEFS(),
this means many dummy dlc also will be re-created. This is waste of
memory.

If we can use existing common asoc_dummy_dlc at (X),
we can avoid to re-creating dummy dlc, then, we can save the memory.

At that time, we want to keep existing code as much as possible, because
too many drivers are using this macro. But because of its original style,
using common asoc_dummy_dlc from it is very difficult or impossible.

So let's change the mind. The macro is used like below

	SND_SOC_DAILINK_DEFS(link,
		     DAILINK_COMP_ARRAY(COMP_CPU(...)),
(x)		     DAILINK_COMP_ARRAY(COMP_DUMMY()),
		     DAILINK_COMP_ARRAY(COMP_EMPTY()));

	static struct snd_soc_dai_link dai_links[] = {
	{
		.name = ...,
		.stream_name = ...,
(y)		SND_SOC_DAILINK_REG(link),
	},

(y) part will be like below

        static struct snd_soc_dai_link dai_links[] = {
        {
                .name = ...,
                .stream_name = ...,
 ^		...
 |		.codecs		= link_codecs,
(y)		.num_codecs	= ARRAY_SIZE(link_codecs),
 v		...
	}

This patch try to use trick on COMP_DUMMY()

-	#define COMP_DUMMY()	{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
+	#define COMP_DUMMY()

By this tric, (x) part will be like below.

before
	[o] link_codecs[] = {{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }}
after
	[o] link_codecs[] = { };

This is same as below

	[o] link_codecs[0];

This means it has pointer (link_codecs), but the array size is 0.
(y) part will be like below.

	static struct snd_soc_dai_link dai_links[] = {
	{
		...
		.codecs		= link_codecs,
		.num_codecs	= 0,
		...
	},

This is very special settings that normal use usually not do,
but new macro do.
We can find this special settings on soc-core.c and fill it as
"dummy DAI" (= asoc_dummy_dlc). By this tric, we can avoid to re-create
dummy dlc and save the memory.

This patch add tric at COMP_DUMMY() and add snd_soc_fill_dummy_dai()
to fill dummy DAI.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  2 +-
 sound/soc/soc-core.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index f3803c2dc349..7cbe85ca040d 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -938,7 +938,7 @@ snd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) {
 #define COMP_PLATFORM(_name)		{ .name = _name }
 #define COMP_AUX(_name)			{ .name = _name }
 #define COMP_CODEC_CONF(_name)		{ .name = _name }
-#define COMP_DUMMY()			{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
+#define COMP_DUMMY()			/* see snd_soc_fill_dummy_dai() */
 
 extern struct snd_soc_dai_link_component null_dailink_component[0];
 extern struct snd_soc_dai_link_component snd_soc_dummy_dlc;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 132946f82a29..88de4c5a376f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -576,6 +576,34 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
 	return NULL;
 }
 
+static void snd_soc_fill_dummy_dai(struct snd_soc_card *card)
+{
+	struct snd_soc_dai_link *dai_link;
+	int i;
+
+	/*
+	 * COMP_DUMMY() creates size 0 array for CPU/Codec on dai_link.
+	 * This function fill it as dummy DAI.
+	 *
+	 * size = 0, but has pointer means created by COMP_DUMMY()
+	 */
+	for_each_card_prelinks(card, i, dai_link) {
+		if (dai_link->num_cpus == 0 && dai_link->cpus) {
+			dai_link->num_cpus	= 1;
+			dai_link->cpus		= &snd_soc_dummy_dlc;
+		}
+		if (dai_link->num_codecs == 0 && dai_link->codecs) {
+			dai_link->num_codecs	= 1;
+			dai_link->codecs	= &snd_soc_dummy_dlc;
+		}
+		if (dai_link->num_platforms == 0 && dai_link->platforms) {
+			dev_warn(card->dev, "platform don't need dummy Component/DAI\n");
+			dai_link->num_platforms	= 0;
+			dai_link->platforms	= NULL;
+		}
+	}
+}
+
 static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card)
 {
 	struct snd_soc_pcm_runtime *rtd;
@@ -2131,6 +2159,8 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
 	mutex_lock(&client_mutex);
 	snd_soc_card_mutex_lock_root(card);
 
+	snd_soc_fill_dummy_dai(card);
+
 	snd_soc_dapm_init(&card->dapm, card, NULL);
 
 	/* check whether any platform is ignore machine FE and using topology */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY()
  2023-12-04  1:31 ` [PATCH 5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY() Kuninori Morimoto
@ 2023-12-04 15:44   ` Amadeusz Sławiński
  2023-12-07  1:21     ` Kuninori Morimoto
  0 siblings, 1 reply; 10+ messages in thread
From: Amadeusz Sławiński @ 2023-12-04 15:44 UTC (permalink / raw)
  To: Kuninori Morimoto, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Takashi Iwai
  Cc: alsa-devel, linux-sound

On 12/4/2023 2:31 AM, Kuninori Morimoto wrote:
> Many ASoC drivers define CPU/Codec/Platform dai_link by below macro.
> 
> 	SND_SOC_DAILINK_DEFS(link,
> (A)		     DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
> (B)		     DAILINK_COMP_ARRAY(COMP_CODEC("codec", "dai1"),
> (B)					COMP_CODEC("codec", "dai2")),
> (C)		     DAILINK_COMP_ARRAY(COMP_EMPTY()));
> 
> In this case, this macro will be converted to like below
> 
> 	[o] = static struct snd_soc_dai_link_component
> 
> (A)	[o] link_cpus[]      = {{ .dai_name = "cpu_dai" }};
> (B)	[o] link_codecs[]    = {{ .dai_name = "dai1", .name = "codec" },
> 				{ .dai_name = "dai2", .name = "codec" }}
> (C)	[o] link_platforms[] = {{ }};
> 
> CPU and Codec info will be filled by COMP_CPU() / COMP_CODEC (= A,B),
> and Platform will have empty data by COMP_EMPTY() (= C) in this case.
> 
> Platform empty info will be filled when driver probe()
> (most of case, CPU info will be copied to use soc-generic-dmaengine-pcm).
> 
> For example in case of DPCM FE/BE, it will be like below.
> Codec will be dummy Component / DAI in this case (X).
> 
> 	SND_SOC_DAILINK_DEFS(link,
> 		     DAILINK_COMP_ARRAY(COMP_CPU(...)),
> (X)		     DAILINK_COMP_ARRAY(COMP_DUMMY()),
> 		     DAILINK_COMP_ARRAY(COMP_EMPTY()));
> 
> (X) part will converted like below
> 
> 	[o] link_codecs[]    = {{ .name = "snd-soc-dummy",
> 				  .dai_name = "snd-soc-dummy-dai", }}
> 
> Even though we already have common asoc_dummy_dlc for dummy
> Component / DAI, this macro will re-create new dummy dlc.
> Some drivers defines many dai_link info via SND_SOC_DAILINK_DEFS(),
> this means many dummy dlc also will be re-created. This is waste of
> memory.
> 
> If we can use existing common asoc_dummy_dlc at (X),
> we can avoid to re-creating dummy dlc, then, we can save the memory.
> 
> At that time, we want to keep existing code as much as possible, because
> too many drivers are using this macro. But because of its original style,
> using common asoc_dummy_dlc from it is very difficult or impossible.
> 
> So let's change the mind. The macro is used like below
> 
> 	SND_SOC_DAILINK_DEFS(link,
> 		     DAILINK_COMP_ARRAY(COMP_CPU(...)),
> (x)		     DAILINK_COMP_ARRAY(COMP_DUMMY()),
> 		     DAILINK_COMP_ARRAY(COMP_EMPTY()));
> 
> 	static struct snd_soc_dai_link dai_links[] = {
> 	{
> 		.name = ...,
> 		.stream_name = ...,
> (y)		SND_SOC_DAILINK_REG(link),
> 	},
> 
> (y) part will be like below
> 
>          static struct snd_soc_dai_link dai_links[] = {
>          {
>                  .name = ...,
>                  .stream_name = ...,
>   ^		...
>   |		.codecs		= link_codecs,
> (y)		.num_codecs	= ARRAY_SIZE(link_codecs),
>   v		...
> 	}
> 
> This patch try to use trick on COMP_DUMMY()
> 
> -	#define COMP_DUMMY()	{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
> +	#define COMP_DUMMY()
> 
> By this tric, (x) part will be like below.
> 
> before
> 	[o] link_codecs[] = {{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }}
> after
> 	[o] link_codecs[] = { };
> 
> This is same as below
> 
> 	[o] link_codecs[0];
> 
> This means it has pointer (link_codecs), but the array size is 0.
> (y) part will be like below.
> 
> 	static struct snd_soc_dai_link dai_links[] = {
> 	{
> 		...
> 		.codecs		= link_codecs,
> 		.num_codecs	= 0,
> 		...
> 	},
> 
> This is very special settings that normal use usually not do,
> but new macro do.
> We can find this special settings on soc-core.c and fill it as
> "dummy DAI" (= asoc_dummy_dlc). By this tric, we can avoid to re-create
> dummy dlc and save the memory.
> 
> This patch add tric at COMP_DUMMY() and add snd_soc_fill_dummy_dai()
> to fill dummy DAI.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>   include/sound/soc.h  |  2 +-
>   sound/soc/soc-core.c | 30 ++++++++++++++++++++++++++++++
>   2 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index f3803c2dc349..7cbe85ca040d 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -938,7 +938,7 @@ snd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) {
>   #define COMP_PLATFORM(_name)		{ .name = _name }
>   #define COMP_AUX(_name)			{ .name = _name }
>   #define COMP_CODEC_CONF(_name)		{ .name = _name }
> -#define COMP_DUMMY()			{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
> +#define COMP_DUMMY()			/* see snd_soc_fill_dummy_dai() */

Isn't it effectively making COMP_DUMMY same as COMP_EMPTY, or am I not 
seeing something? I guess next step could be to just remove all 
COMP_DUMMY and replace them with COMP_EMPTY to avoid two definitions 
which are same thing?

>   
>   extern struct snd_soc_dai_link_component null_dailink_component[0];
>   extern struct snd_soc_dai_link_component snd_soc_dummy_dlc;
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 132946f82a29..88de4c5a376f 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -576,6 +576,34 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
>   	return NULL;
>   }
>   
> +static void snd_soc_fill_dummy_dai(struct snd_soc_card *card)
> +{
> +	struct snd_soc_dai_link *dai_link;
> +	int i;
> +
> +	/*
> +	 * COMP_DUMMY() creates size 0 array for CPU/Codec on dai_link.
> +	 * This function fill it as dummy DAI.
> +	 *
> +	 * size = 0, but has pointer means created by COMP_DUMMY()
> +	 */
> +	for_each_card_prelinks(card, i, dai_link) {
> +		if (dai_link->num_cpus == 0 && dai_link->cpus) {
> +			dai_link->num_cpus	= 1;
> +			dai_link->cpus		= &snd_soc_dummy_dlc;
> +		}
> +		if (dai_link->num_codecs == 0 && dai_link->codecs) {
> +			dai_link->num_codecs	= 1;
> +			dai_link->codecs	= &snd_soc_dummy_dlc;
> +		}
> +		if (dai_link->num_platforms == 0 && dai_link->platforms) {
> +			dev_warn(card->dev, "platform don't need dummy Component/DAI\n");

I would just replace above print with code comment, no need to spam dmesg.

> +			dai_link->num_platforms	= 0;
> +			dai_link->platforms	= NULL;
> +		}
> +	}
> +}
> +
>   static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card)
>   {
>   	struct snd_soc_pcm_runtime *rtd;
> @@ -2131,6 +2159,8 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
>   	mutex_lock(&client_mutex);
>   	snd_soc_card_mutex_lock_root(card);
>   
> +	snd_soc_fill_dummy_dai(card);
> +
>   	snd_soc_dapm_init(&card->dapm, card, NULL);
>   
>   	/* check whether any platform is ignore machine FE and using topology */


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY()
  2023-12-04 15:44   ` Amadeusz Sławiński
@ 2023-12-07  1:21     ` Kuninori Morimoto
  2023-12-07  8:24       ` Amadeusz Sławiński
  0 siblings, 1 reply; 10+ messages in thread
From: Kuninori Morimoto @ 2023-12-07  1:21 UTC (permalink / raw)
  To: Amadeusz Sławiński
  Cc: alsa-devel, linux-sound, Jaroslav Kysela, Liam Girdwood,
	Mark Brown, Takashi Iwai


Hi Amadeusz

Thank you for your feedback

> > --- a/include/sound/soc.h
> > +++ b/include/sound/soc.h
> > @@ -938,7 +938,7 @@ snd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) {
> >   #define COMP_PLATFORM(_name)		{ .name = _name }
> >   #define COMP_AUX(_name)			{ .name = _name }
> >   #define COMP_CODEC_CONF(_name)		{ .name = _name }
> > -#define COMP_DUMMY()			{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
> > +#define COMP_DUMMY()			/* see snd_soc_fill_dummy_dai() */
> 
> Isn't it effectively making COMP_DUMMY same as COMP_EMPTY, or am I not 
> seeing something? I guess next step could be to just remove all 
> COMP_DUMMY and replace them with COMP_EMPTY to avoid two definitions 
> which are same thing?

It is a little bit macro magic

COMP_EMPTY()
	static struct snd_soc_dai_link_component name[]	= {{ }},
	                                                   ^^^
COMP_DUMMY()
	static struct snd_soc_dai_link_component name[]	= {   },
	                                                   ^^^
EMPTY case will be 1 element array, DUMMY case will be 0 element array.
So, EMPTY case has empty element, and is not a special/strange array.
But DUMMY case, it has pointer but 0 size array, very special/strange.
This patch making this special/strange array on purpose, and convert it
to asoc_dummy_dlc() on soc-core.c
Is this good answer for you ?

> > +		if (dai_link->num_platforms == 0 && dai_link->platforms) {
> > +			dev_warn(card->dev, "platform don't need dummy Component/DAI\n");
> 
> I would just replace above print with code comment, no need to spam dmesg.

OK, will fix in v2


Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY()
  2023-12-07  1:21     ` Kuninori Morimoto
@ 2023-12-07  8:24       ` Amadeusz Sławiński
  0 siblings, 0 replies; 10+ messages in thread
From: Amadeusz Sławiński @ 2023-12-07  8:24 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: alsa-devel, linux-sound, Jaroslav Kysela, Liam Girdwood,
	Mark Brown, Takashi Iwai

On 12/7/2023 2:21 AM, Kuninori Morimoto wrote:
> 
> Hi Amadeusz
> 
> Thank you for your feedback
> 
>>> --- a/include/sound/soc.h
>>> +++ b/include/sound/soc.h
>>> @@ -938,7 +938,7 @@ snd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) {
>>>    #define COMP_PLATFORM(_name)		{ .name = _name }
>>>    #define COMP_AUX(_name)			{ .name = _name }
>>>    #define COMP_CODEC_CONF(_name)		{ .name = _name }
>>> -#define COMP_DUMMY()			{ .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
>>> +#define COMP_DUMMY()			/* see snd_soc_fill_dummy_dai() */
>>
>> Isn't it effectively making COMP_DUMMY same as COMP_EMPTY, or am I not
>> seeing something? I guess next step could be to just remove all
>> COMP_DUMMY and replace them with COMP_EMPTY to avoid two definitions
>> which are same thing?
> 
> It is a little bit macro magic
> 
> COMP_EMPTY()
> 	static struct snd_soc_dai_link_component name[]	= {{ }},
> 	                                                   ^^^
> COMP_DUMMY()
> 	static struct snd_soc_dai_link_component name[]	= {   },
> 	                                                   ^^^
> EMPTY case will be 1 element array, DUMMY case will be 0 element array.
> So, EMPTY case has empty element, and is not a special/strange array.
> But DUMMY case, it has pointer but 0 size array, very special/strange.
> This patch making this special/strange array on purpose, and convert it
> to asoc_dummy_dlc() on soc-core.c
> Is this good answer for you ?
> 

Yes, thanks!

>>> +		if (dai_link->num_platforms == 0 && dai_link->platforms) {
>>> +			dev_warn(card->dev, "platform don't need dummy Component/DAI\n");
>>
>> I would just replace above print with code comment, no need to spam dmesg.
> 
> OK, will fix in v2
> 
> 
> Thank you for your help !!
> 
> Best regards
> ---
> Renesas Electronics
> Ph.D. Kuninori Morimoto


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] ASoC: don't use original dummy dlc
  2023-12-04  1:31 [PATCH 0/5] ASoC: don't use original dummy dlc Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2023-12-04  1:31 ` [PATCH 5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY() Kuninori Morimoto
@ 2023-12-19 18:06 ` Mark Brown
  5 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2023-12-19 18:06 UTC (permalink / raw)
  To: Bard Liao, Brent Lu, Cezary Rojewski, Daniel Baluta,
	Jaroslav Kysela, Kai Vehmanen, Liam Girdwood, Liam Girdwood,
	Peter Ujfalusi, Pierre-Louis Bossart, Ranjani Sridharan,
	Shengjiu Wang, Sylwester Nawrocki, Takashi Iwai, Xiubo Li,
	Kuninori Morimoto
  Cc: Fabio Estevam, Kai Vehmanen, Nicolin Chen, alsa-devel, linux-sound

On Mon, 04 Dec 2023 01:31:10 +0000, Kuninori Morimoto wrote:
> This patch-set try to not use original dummy dlc.
> 
> "Empty" dlc might be used on Platform, but "dummy" dlc is not needed
> for it. [PATCH 1/5][PATCH 2/5] removes "dummy" dlc from Platform.
> 
> Now ASoC have common dummy dlc (= snd_soc_dummy_dlc).
> [PATCH 3/5][PATCH 4/5] will use it instead of original dummy dlc.
> 
> [...]

Applied to

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

Thanks!

[1/5] ASoC: fsl: fsl-asoc-card: don't need DUMMY Platform
      commit: 7465582e0b18859d3681192ec2ccf22a81370040
[2/5] ASoC: samsung: odroid: don't need DUMMY Platform
      commit: 56558d6ab8c09c416bdb6d72b7e02894539a882a
[3/5] ASoC: intel: hdaudio.c: use snd_soc_dummy_dlc
      commit: c2dfe29f30d8850af324449f416491b171af19aa
[4/5] ASoC: sof: use snd_soc_dummy_dlc
      commit: e8776ff9ce9f5a8a9d8294101fd2924cebdd2da1
[5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY()
      commit: 13f58267cda3d6946c8f4de368ad5d4a003baa61

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-19 18:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04  1:31 [PATCH 0/5] ASoC: don't use original dummy dlc Kuninori Morimoto
2023-12-04  1:31 ` [PATCH 1/5] ASoC: fsl: fsl-asoc-card: don't need DUMMY Platform Kuninori Morimoto
2023-12-04  1:31 ` [PATCH 2/5] ASoC: samsung: odroid: " Kuninori Morimoto
2023-12-04  1:31 ` [PATCH 3/5] ASoC: intel: hdaudio.c: use snd_soc_dummy_dlc Kuninori Morimoto
2023-12-04  1:31 ` [PATCH 4/5] ASoC: sof: " Kuninori Morimoto
2023-12-04  1:31 ` [PATCH 5/5] ASoC: soc.h: don't create dummy Component via COMP_DUMMY() Kuninori Morimoto
2023-12-04 15:44   ` Amadeusz Sławiński
2023-12-07  1:21     ` Kuninori Morimoto
2023-12-07  8:24       ` Amadeusz Sławiński
2023-12-19 18:06 ` [PATCH 0/5] ASoC: don't use original dummy dlc Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.