Commit b8b89f5e authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() ID method

commit b6f3fc00 ("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 b6f3fc00 ("ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() counting")
Reported-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent de17f14e
...@@ -269,22 +269,46 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai); ...@@ -269,22 +269,46 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai);
static int asoc_simple_card_get_dai_id(struct device_node *ep) static int asoc_simple_card_get_dai_id(struct device_node *ep)
{ {
struct device_node *node;
struct device_node *endpoint;
struct of_endpoint info; struct of_endpoint info;
int i, id;
int ret; int ret;
/* use driver specified DAI ID if exist */
ret = snd_soc_get_dai_id(ep); ret = snd_soc_get_dai_id(ep);
if (ret != -ENOTSUPP) if (ret != -ENOTSUPP)
return ret; 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 * Non HDMI sound case, counting port/endpoint on its DT
* is enough. Let's count it. * is enough. Let's count it.
*/ */
ret = of_graph_parse_endpoint(ep, &info); i = 0;
if (ret) id = -1;
return -ENXIO; for_each_endpoint_of_node(node, endpoint) {
if (endpoint == ep)
id = i;
i++;
}
return info.port; of_node_put(node);
if (id < 0)
return -ENODEV;
return id;
} }
int asoc_simple_card_parse_graph_dai(struct device_node *ep, int asoc_simple_card_parse_graph_dai(struct device_node *ep,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment