All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>,
	Laurent <laurent.pinchart@ideasonboard.com>,
	Lars-Peter Clausen <lars@metafoo.de>
Cc: Simon <horms@verge.net.au>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	Linux-DT <devicetree@vger.kernel.org>,
	Linux-ALSA <alsa-devel@alsa-project.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jose Abreu <Jose.Abreu@synopsys.com>
Subject: [PATCH 2/4] ASoC: add of_parse_snd_connection_with_args() for sound-dai/graph connection
Date: Thu, 14 Apr 2016 05:47:43 +0000	[thread overview]
Message-ID: <87y48gvj9i.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <871t68wxxe.wl%kuninori.morimoto.gx@renesas.com>

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

Current ASoC card connection is based on "sound-dai" on DT,
but V4L2 connection is using graph base.
This patch adds common function which can detect both connection.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  2 ++
 sound/soc/soc-core.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 02b4a21..17ddc25 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1669,6 +1669,8 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
 				     struct device_node **framemaster);
+int of_parse_snd_soc_connection_with_args(const struct device_node *np,
+					  struct of_phandle_args *out_args);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name);
 int snd_soc_of_get_dai_link_codecs(struct device *dev,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d2e62b15..643b244 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 <sound/core.h>
 #include <sound/jack.h>
 #include <sound/pcm.h>
@@ -3839,6 +3840,47 @@ static int snd_soc_get_dai_name(struct of_phandle_args *args,
 	return ret;
 }
 
+int of_parse_snd_soc_connection_with_args(const struct device_node *np,
+					  struct of_phandle_args *out_args)
+{
+	int ret;
+
+	ret = of_parse_phandle_with_args(np, "sound-dai",
+					 "#sound-dai-cells", 0, out_args);
+	if (ret) {
+		struct device_node *p_node = NULL;
+		struct device_node *ep_node = NULL;
+		struct of_endpoint ep;
+
+		/* try graph base parse */
+		p_node = of_graph_get_remote_port_parent(np);
+		if (!p_node)
+			return -EINVAL;
+
+		ep_node = of_graph_get_remote_port(np);
+		if (!p_node) {
+			ret = -EINVAL;
+			goto graph_err_parent;
+		}
+
+		ret = of_graph_parse_endpoint(ep_node, &ep);
+		if (ret < 0)
+			goto graph_err_endpoint;
+
+		out_args->np		= p_node;
+		out_args->args_count	= (1 != of_graph_get_endpoint_count(p_node));
+		out_args->args[0]	= ep.port;
+
+graph_err_endpoint:
+		of_node_put(ep_node);
+graph_err_parent:
+		of_node_put(p_node);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(of_parse_snd_soc_connection_with_args);
+
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name)
 {
-- 
1.9.1

  parent reply	other threads:[~2016-04-14  5:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14  5:45 [PATCH 0/4] ASoC: add graph base connection on simple-card Kuninori Morimoto
2016-04-14  5:47 ` [PATCH 1/4] of_graph: add of_graph_get_endpoint_count() Kuninori Morimoto
2016-04-14  5:47 ` Kuninori Morimoto [this message]
2016-04-14  6:17   ` [alsa-devel] [PATCH 2/4] ASoC: add of_parse_snd_connection_with_args() for sound-dai/graph connection kbuild test robot
2016-04-14  7:07     ` [PATCH] of: add missing const for of_parse_phandle_with_args() in !CONFIG_OF Kuninori Morimoto
2016-04-14  7:07       ` Kuninori Morimoto
2016-05-10  2:53     ` [PATCH][RESEND] " Kuninori Morimoto
2016-05-10  2:53       ` Kuninori Morimoto
2016-04-14  5:48 ` [PATCH 3/4] ASoC: snd_soc_of_get_dai_name() uses of_parse_snd_soc_connection_with_args() Kuninori Morimoto
2016-04-14  5:48 ` [PATCH 4/4] ASoC: simple-card: probe both sound-dai and remote-endpoint Kuninori Morimoto
     [not found] ` <871t68wxxe.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2016-04-14  9:01   ` [alsa-devel] [PATCH 0/4] ASoC: add graph base connection on simple-card Jean-Francois Moine
2016-04-14  9:01     ` Jean-Francois Moine
     [not found]     ` <20160414110128.56a0da97d526cdcb8d5f1ddf-GANU6spQydw@public.gmane.org>
2016-04-15  7:25       ` Kuninori Morimoto
2016-04-15  7:25         ` Kuninori Morimoto
2016-04-15  9:26         ` Kuninori Morimoto
2016-04-15 11:31           ` Jean-Francois Moine
2016-04-15 11:31             ` Jean-Francois Moine
2016-04-18  2:43             ` Kuninori Morimoto
2016-04-18  2:43               ` [alsa-devel] " Kuninori Morimoto
     [not found]               ` <87r3e3ej5t.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2016-04-18  7:38                 ` Jean-Francois Moine
2016-04-18  7:38                   ` Jean-Francois Moine
2016-04-20  2:55                   ` Kuninori Morimoto
2016-04-20 16:18                     ` Jean-Francois Moine
2016-04-20 16:18                       ` Jean-Francois Moine
2016-04-18 17:12 ` Rob Herring
2016-04-18 17:12   ` Rob Herring

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=87y48gvj9i.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=Jose.Abreu@synopsys.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=horms@verge.net.au \
    --cc=lars@metafoo.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-renesas-soc@vger.kernel.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.