All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: soc-core: use more generic method to find platform
@ 2018-09-06  3:05 Kuninori Morimoto
  2018-09-06  3:05 ` [PATCH 1/3] ASoC: soc-core: manage platform name under snd_soc_init_platform() Kuninori Morimoto
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2018-09-06  3:05 UTC (permalink / raw)
  To: Linux-ALSA


Hi Mark

Now, ALSA SoC is using snd_soc_dai_link_component for platform
instead of legacy style (= platform_name/platform_of_node/platform).

OTOH, CPU/Codec are finding its DAI by using common snd_soc_find_dai()
function which uses snd_soc_dai_link_component.
Then, of course, we want to use same style for platform.

These patch do it.

Kuninori Morimoto (3):
  ASoC: soc-core: manage platform name under snd_soc_init_platform()
  ASoC: soc-core: add snd_soc_find_component()
  ASoC: soc-core: find platform by using snd_soc_find_component()

 sound/soc/soc-core.c | 84 +++++++++++++++++++++++++++-------------------------
 1 file changed, 43 insertions(+), 41 deletions(-)

-- 
2.7.4

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

* [PATCH 1/3] ASoC: soc-core: manage platform name under snd_soc_init_platform()
  2018-09-06  3:05 [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto
@ 2018-09-06  3:05 ` Kuninori Morimoto
  2018-09-06  3:06 ` [PATCH 2/3] ASoC: soc-core: add snd_soc_find_component() Kuninori Morimoto
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2018-09-06  3:05 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Now "platform" is controlled by snd_soc_dai_link_component,
thus its "name" can be initialized in snd_soc_init_platform().
This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 390da15..24d8338 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -844,7 +844,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 	struct snd_soc_component *component;
 	struct snd_soc_dai **codec_dais;
 	struct device_node *platform_of_node;
-	const char *platform_name;
 	int i;
 
 	if (dai_link->ignore)
@@ -891,11 +890,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 	/* Single codec links expect codec and codec_dai in runtime data */
 	rtd->codec_dai = codec_dais[0];
 
-	/* if there's no platform we match on the empty platform */
-	platform_name = dai_link->platform->name;
-	if (!platform_name && !dai_link->platform->of_node)
-		platform_name = "snd-soc-dummy";
-
 	/* find one from the set of registered platforms */
 	list_for_each_entry(component, &component_list, list) {
 		platform_of_node = component->dev->of_node;
@@ -906,7 +900,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 			if (platform_of_node != dai_link->platform->of_node)
 				continue;
 		} else {
-			if (strcmp(component->name, platform_name))
+			if (strcmp(component->name, dai_link->platform->name))
 				continue;
 		}
 
@@ -1019,6 +1013,8 @@ static void soc_remove_dai_links(struct snd_soc_card *card)
 static int snd_soc_init_platform(struct snd_soc_card *card,
 				 struct snd_soc_dai_link *dai_link)
 {
+	const char *name;
+
 	/*
 	 * FIXME
 	 *
@@ -1034,7 +1030,12 @@ static int snd_soc_init_platform(struct snd_soc_card *card,
 	if (!dai_link->platform)
 		return -ENOMEM;
 
-	dai_link->platform->name	= dai_link->platform_name;
+	/* if there's no platform we match on the empty platform */
+	name = dai_link->platform->name;
+	if (!name && !dai_link->platform_of_node)
+		name = "snd-soc-dummy";
+
+	dai_link->platform->name	= name;
 	dai_link->platform->of_node	= dai_link->platform_of_node;
 	dai_link->platform->dai_name	= NULL;
 
-- 
2.7.4

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

* [PATCH 2/3] ASoC: soc-core: add snd_soc_find_component()
  2018-09-06  3:05 [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto
  2018-09-06  3:05 ` [PATCH 1/3] ASoC: soc-core: manage platform name under snd_soc_init_platform() Kuninori Morimoto
@ 2018-09-06  3:06 ` Kuninori Morimoto
  2018-09-06  3:06 ` [PATCH 3/3] ASoC: soc-core: find platform by using snd_soc_find_component() Kuninori Morimoto
  2018-09-11  1:56 ` [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto
  3 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2018-09-06  3:06 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC has snd_soc_find_dai() which find DAI from
component_list by using snd_soc_dai_link_component information.
It finds component first, and find DAI from it.
This patch adds new snd_soc_find_component() to find component.
And exising snd_soc_find_dai() uses it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 51 +++++++++++++++++++++++++++++++++------------------
 1 file changed, 33 insertions(+), 18 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 24d8338..c4a40dd 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -736,6 +736,31 @@ static struct snd_soc_component *soc_find_component(
 	return NULL;
 }
 
+struct snd_soc_component *snd_soc_find_component(
+	const struct snd_soc_dai_link_component *dlc)
+{
+	struct snd_soc_component *component;
+	struct device_node *component_of_node;
+
+	lockdep_assert_held(&client_mutex);
+
+	/* Find CPU DAI from registered DAIs*/
+	list_for_each_entry(component, &component_list, list) {
+		component_of_node = component->dev->of_node;
+		if (!component_of_node && component->dev->parent)
+			component_of_node = component->dev->parent->of_node;
+
+		if (dlc->of_node && component_of_node != dlc->of_node)
+			continue;
+		if (dlc->name && strcmp(component->name, dlc->name))
+			continue;
+
+		return component;
+	}
+
+	return NULL;
+}
+
 /**
  * snd_soc_find_dai - Find a registered DAI
  *
@@ -752,28 +777,18 @@ struct snd_soc_dai *snd_soc_find_dai(
 {
 	struct snd_soc_component *component;
 	struct snd_soc_dai *dai;
-	struct device_node *component_of_node;
-
-	lockdep_assert_held(&client_mutex);
 
-	/* Find CPU DAI from registered DAIs*/
-	list_for_each_entry(component, &component_list, list) {
-		component_of_node = component->dev->of_node;
-		if (!component_of_node && component->dev->parent)
-			component_of_node = component->dev->parent->of_node;
+	component = snd_soc_find_component(dlc);
+	if (!component)
+		return NULL;
 
-		if (dlc->of_node && component_of_node != dlc->of_node)
-			continue;
-		if (dlc->name && strcmp(component->name, dlc->name))
+	list_for_each_entry(dai, &component->dai_list, list) {
+		if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
+		    && (!dai->driver->name
+			|| strcmp(dai->driver->name, dlc->dai_name)))
 			continue;
-		list_for_each_entry(dai, &component->dai_list, list) {
-			if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
-			    && (!dai->driver->name
-				|| strcmp(dai->driver->name, dlc->dai_name)))
-				continue;
 
-			return dai;
-		}
+		return dai;
 	}
 
 	return NULL;
-- 
2.7.4

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

* [PATCH 3/3] ASoC: soc-core: find platform by using snd_soc_find_component()
  2018-09-06  3:05 [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto
  2018-09-06  3:05 ` [PATCH 1/3] ASoC: soc-core: manage platform name under snd_soc_init_platform() Kuninori Morimoto
  2018-09-06  3:06 ` [PATCH 2/3] ASoC: soc-core: add snd_soc_find_component() Kuninori Morimoto
@ 2018-09-06  3:06 ` Kuninori Morimoto
  2018-09-11  1:56 ` [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto
  3 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2018-09-06  3:06 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Now, all CPU/Codec/Platform had been converted to snd_soc_component
from each own structure.
By this conversion, calling snd_soc_rtdcom_add() is required to add
its component to rtd, and then, it added new component finding
operation for platform.

But this operation is very similar to finding DAI which is used for
CPU/Codec. More detail, it is snd_soc_find_dai() which finds DAI
from snd_soc_dai_link_component.

Now, we have snd_soc_find_component(), and platform is handled by
snd_soc_dai_link_component.
Let's use it, and be more simple code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c4a40dd..de324d9 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -858,7 +858,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 	struct snd_soc_dai_link_component cpu_dai_component;
 	struct snd_soc_component *component;
 	struct snd_soc_dai **codec_dais;
-	struct device_node *platform_of_node;
 	int i;
 
 	if (dai_link->ignore)
@@ -905,22 +904,9 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 	/* Single codec links expect codec and codec_dai in runtime data */
 	rtd->codec_dai = codec_dais[0];
 
-	/* find one from the set of registered platforms */
-	list_for_each_entry(component, &component_list, list) {
-		platform_of_node = component->dev->of_node;
-		if (!platform_of_node && component->dev->parent->of_node)
-			platform_of_node = component->dev->parent->of_node;
-
-		if (dai_link->platform->of_node) {
-			if (platform_of_node != dai_link->platform->of_node)
-				continue;
-		} else {
-			if (strcmp(component->name, dai_link->platform->name))
-				continue;
-		}
-
+	component = snd_soc_find_component(dai_link->platform);
+	if (component)
 		snd_soc_rtdcom_add(rtd, component);
-	}
 
 	soc_add_pcm_runtime(card, rtd);
 	return 0;
-- 
2.7.4

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

* Re: [PATCH 0/3] ASoC: soc-core: use more generic method to find platform
  2018-09-06  3:05 [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2018-09-06  3:06 ` [PATCH 3/3] ASoC: soc-core: find platform by using snd_soc_find_component() Kuninori Morimoto
@ 2018-09-11  1:56 ` Kuninori Morimoto
  3 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2018-09-11  1:56 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

I noticed that this series seems have bug under DPCM.
I will fixup it, and re-post again.

> Now, ALSA SoC is using snd_soc_dai_link_component for platform
> instead of legacy style (= platform_name/platform_of_node/platform).
> 
> OTOH, CPU/Codec are finding its DAI by using common snd_soc_find_dai()
> function which uses snd_soc_dai_link_component.
> Then, of course, we want to use same style for platform.
> 
> These patch do it.
> 
> Kuninori Morimoto (3):
>   ASoC: soc-core: manage platform name under snd_soc_init_platform()
>   ASoC: soc-core: add snd_soc_find_component()
>   ASoC: soc-core: find platform by using snd_soc_find_component()
> 
>  sound/soc/soc-core.c | 84 +++++++++++++++++++++++++++-------------------------
>  1 file changed, 43 insertions(+), 41 deletions(-)
> 
> -- 
> 2.7.4
> 

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

end of thread, other threads:[~2018-09-11  1:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06  3:05 [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto
2018-09-06  3:05 ` [PATCH 1/3] ASoC: soc-core: manage platform name under snd_soc_init_platform() Kuninori Morimoto
2018-09-06  3:06 ` [PATCH 2/3] ASoC: soc-core: add snd_soc_find_component() Kuninori Morimoto
2018-09-06  3:06 ` [PATCH 3/3] ASoC: soc-core: find platform by using snd_soc_find_component() Kuninori Morimoto
2018-09-11  1:56 ` [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto

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.