All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][RFC] ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() ID method
@ 2018-12-13  5:18 Kuninori Morimoto
  2018-12-13 16:42 ` Tony Lindgren
  0 siblings, 1 reply; 3+ messages in thread
From: Kuninori Morimoto @ 2018-12-13  5:18 UTC (permalink / raw)
  To: Mark Brown, Tony Lindgren; +Cc: Linux-ALSA

commit b6f3fc005a2c8 ("ASoC: simple-card-utils: fixup
asoc_simple_card_get_dai_id() counting") fixuped getting DAI ID method.
It will get DAI ID from OF graph "port", but, we want to consider about
"endpoint", too.
And, we also want to keep compatibility.

This patch fixup it as

	if (driver has specified DAI ID)
		use it as DAI ID
	else if (OF graph endpoint has reg)
		use it as DAI ID
	else if (OF graph port has reg)
		use it as DAI ID
	else
		use endpoint count as DAI ID

Fixes: commit b6f3fc005a2c8 ("ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() counting")
Reported-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
> Tony

Can you test this patch ?
It can keep compatibility, I think.

> Mark

I added [RFC] on this patch.
If this patch was OK by Tony's test,
I will re-post it as v3 patch-set.

 sound/soc/generic/simple-card-utils.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 17d8aee..b807a47 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -269,22 +269,46 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai);
 
 static int asoc_simple_card_get_dai_id(struct device_node *ep)
 {
+	struct device_node *node;
+	struct device_node *endpoint;
 	struct of_endpoint info;
+	int i, id;
 	int ret;
 
+	/* use driver specified DAI ID if exist */
 	ret = snd_soc_get_dai_id(ep);
 	if (ret != -ENOTSUPP)
 		return ret;
 
+	/* use endpoint/port reg if exist */
+	ret = of_graph_parse_endpoint(ep, &info);
+	if (ret == 0) {
+		if (info.id)
+			return info.id;
+		if (info.port)
+			return info.port;
+	}
+
+	node = of_graph_get_port_parent(ep);
+
 	/*
 	 * Non HDMI sound case, counting port/endpoint on its DT
 	 * is enough. Let's count it.
 	 */
-	ret = of_graph_parse_endpoint(ep, &info);
-	if (ret)
-		return -ENXIO;
+	i = 0;
+	id = -1;
+	for_each_endpoint_of_node(node, endpoint) {
+		if (endpoint == ep)
+			id = i;
+		i++;
+	}
+
+	of_node_put(node);
+
+	if (id < 0)
+		return -ENODEV;
 
-	return info.port;
+	return id;
 }
 
 int asoc_simple_card_parse_graph_dai(struct device_node *ep,
-- 
2.7.4

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

* Re: [PATCH][RFC] ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() ID method
  2018-12-13  5:18 [PATCH][RFC] ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() ID method Kuninori Morimoto
@ 2018-12-13 16:42 ` Tony Lindgren
  2018-12-14  0:16   ` Kuninori Morimoto
  0 siblings, 1 reply; 3+ messages in thread
From: Tony Lindgren @ 2018-12-13 16:42 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

* Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> [181213 05:18]:
> commit b6f3fc005a2c8 ("ASoC: simple-card-utils: fixup
> asoc_simple_card_get_dai_id() counting") fixuped getting DAI ID method.
> It will get DAI ID from OF graph "port", but, we want to consider about
> "endpoint", too.
> And, we also want to keep compatibility.
> 
> This patch fixup it as
> 
> 	if (driver has specified DAI ID)
> 		use it as DAI ID
> 	else if (OF graph endpoint has reg)
> 		use it as DAI ID
> 	else if (OF graph port has reg)
> 		use it as DAI ID
> 	else
> 		use endpoint count as DAI ID

Yup I tested this instead of the earlier 1/7 patch
and things work nice for me. I also commented out
reg properties from the codec end and the mapping
worked fine. So please feel free to add:

Tested-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH][RFC] ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() ID method
  2018-12-13 16:42 ` Tony Lindgren
@ 2018-12-14  0:16   ` Kuninori Morimoto
  0 siblings, 0 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2018-12-14  0:16 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Linux-ALSA, Mark Brown


Hi Tony

Thank you for testing

> > This patch fixup it as
> > 
> > 	if (driver has specified DAI ID)
> > 		use it as DAI ID
> > 	else if (OF graph endpoint has reg)
> > 		use it as DAI ID
> > 	else if (OF graph port has reg)
> > 		use it as DAI ID
> > 	else
> > 		use endpoint count as DAI ID
> 
> Yup I tested this instead of the earlier 1/7 patch
> and things work nice for me. I also commented out
> reg properties from the codec end and the mapping
> worked fine. So please feel free to add:
> 
> Tested-by: Tony Lindgren <tony@atomide.com>

Good !!
Thank you, again !!
I will re-post it as v3 patch-set

Best regards
---
Kuninori Morimoto

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

end of thread, other threads:[~2018-12-14  0:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13  5:18 [PATCH][RFC] ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() ID method Kuninori Morimoto
2018-12-13 16:42 ` Tony Lindgren
2018-12-14  0:16   ` 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.