All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Linux-ALSA <alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org>,
	Simon <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>,
	Linux-DT <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH 4/7] ASoC: add snd_soc_get_dai_id()
Date: Mon, 13 Feb 2017 02:01:31 +0000	[thread overview]
Message-ID: <87a89q97ht.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87fuji97ls.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>


From: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>

ALSA SoC needs to know connected DAI ID for probing.
On OF-graph case, basically we can check DT port location.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
---
 include/sound/soc.h  |  1 +
 sound/soc/soc-core.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index cdfb55f..ab4639e 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1664,6 +1664,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
 				     struct device_node **framemaster);
+int snd_soc_get_dai_id(struct device_node *ep);
 int snd_soc_get_dai_name(struct of_phandle_args *args,
 			 const char **dai_name);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a110d39..67901a3 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -34,6 +34,7 @@
 #include <linux/ctype.h>
 #include <linux/slab.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <linux/dmi.h>
 #include <sound/core.h>
 #include <sound/jack.h>
@@ -4035,6 +4036,28 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
+int snd_soc_get_dai_id(struct device_node *ep)
+{
+	struct device_node *node;
+	struct device_node *endpoint;
+	int i, id;
+
+	node = of_graph_get_port_parent(ep);
+
+	i = 0;
+	id = -1;
+	for_each_endpoint_of_node(node, endpoint) {
+		if (endpoint == ep)
+			id = i;
+		i++;
+	}
+	if (id < 0)
+		return -ENODEV;
+
+	return id;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_dai_id);
+
 int snd_soc_get_dai_name(struct of_phandle_args *args,
 				const char **dai_name)
 {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-02-13  2:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-13  1:59 [PATCH 0/7][resend] ASoC: add OF-graph base simple-card Kuninori Morimoto
     [not found] ` <87fuji97ls.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-02-13  2:00   ` [PATCH 1/7][resend] of_graph: add of_graph_get_remote_endpoint() Kuninori Morimoto
2017-02-13  2:00   ` [PATCH 2/7][resend] of_graph: add of_graph_get_port_parent() Kuninori Morimoto
2017-02-13  2:01   ` [PATCH 3/7][resend] of_graph: add of_graph_get_endpoint_count() Kuninori Morimoto
2017-02-13  2:01   ` Kuninori Morimoto [this message]
2017-02-13  2:02   ` [PATCH 5/7][resend] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai() Kuninori Morimoto
     [not found]     ` <878tpa97gw.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-02-13  2:38       ` [alsa-devel] " kbuild test robot
     [not found]         ` <201702131030.kYW5IxyV%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-02-13  4:14           ` Kuninori Morimoto
2017-02-13  2:02   ` [PATCH 6/7][resend] ASoC: add simple-graph-card document Kuninori Morimoto
2017-02-13  2:02   ` [PATCH 7/7][resend] ASoC: add simple-graph-card support Kuninori Morimoto
2017-03-02  5:24 [PATCH v3 0/7] ASoC: add OF-graph base simple-card Kuninori Morimoto
     [not found] ` <87fuiwmeya.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-03-02  5:26   ` [PATCH 4/7] ASoC: add snd_soc_get_dai_id() Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a89q97ht.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx-zm6kxycvzfbbdgjk7y7tuq@public.gmane.org \
    --cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.