summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-12-13 21:29:42 -0500
committerMark Brown <broonie@kernel.org>2018-12-14 06:44:34 -0500
commitb8b89f5ee0b2555fa5a9d778685d2d6fb5122bb9 (patch)
tree7c083695ffc902919668d767309bd3b8c317b333 /sound
parentde17f14ea576d8a0f2932404467fa916542da94d (diff)
ASoC: simple-card-utils: fixup asoc_simple_card_get_dai_id() ID method
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> Tested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/generic/simple-card-utils.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 17d8aee43835..b807a47515eb 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);
269 269
270static int asoc_simple_card_get_dai_id(struct device_node *ep) 270static int asoc_simple_card_get_dai_id(struct device_node *ep)
271{ 271{
272 struct device_node *node;
273 struct device_node *endpoint;
272 struct of_endpoint info; 274 struct of_endpoint info;
275 int i, id;
273 int ret; 276 int ret;
274 277
278 /* use driver specified DAI ID if exist */
275 ret = snd_soc_get_dai_id(ep); 279 ret = snd_soc_get_dai_id(ep);
276 if (ret != -ENOTSUPP) 280 if (ret != -ENOTSUPP)
277 return ret; 281 return ret;
278 282
283 /* use endpoint/port reg if exist */
284 ret = of_graph_parse_endpoint(ep, &info);
285 if (ret == 0) {
286 if (info.id)
287 return info.id;
288 if (info.port)
289 return info.port;
290 }
291
292 node = of_graph_get_port_parent(ep);
293
279 /* 294 /*
280 * Non HDMI sound case, counting port/endpoint on its DT 295 * Non HDMI sound case, counting port/endpoint on its DT
281 * is enough. Let's count it. 296 * is enough. Let's count it.
282 */ 297 */
283 ret = of_graph_parse_endpoint(ep, &info); 298 i = 0;
284 if (ret) 299 id = -1;
285 return -ENXIO; 300 for_each_endpoint_of_node(node, endpoint) {
301 if (endpoint == ep)
302 id = i;
303 i++;
304 }
305
306 of_node_put(node);
307
308 if (id < 0)
309 return -ENODEV;
286 310
287 return info.port; 311 return id;
288} 312}
289 313
290int asoc_simple_card_parse_graph_dai(struct device_node *ep, 314int asoc_simple_card_parse_graph_dai(struct device_node *ep,