mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Rob Herring <robh+dt@kernel.org>, Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	Liam Girdwood <lgirdwood@gmail.com>, Simon <horms@verge.net.au>,
	Laurent <laurent.pinchart@ideasonboard.com>,
	Guennadi <g.liakhovetski@gmx.de>,
	Grant Likely <grant.likely@linaro.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Linux-DT <devicetree@vger.kernel.org>,
	Linux-Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai()
Date: Mon, 28 Nov 2016 02:47:16 +0000	[thread overview]
Message-ID: <877f7owccz.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87k2bowckx.wl%kuninori.morimoto.gx@renesas.com>

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

simple-card already has asoc_simple_card_parse_dai(),
but graph base parsing needs graph specific version of it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     | 10 +++++++
 sound/soc/generic/simple-card-utils.c | 53 +++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 09750ac..c223f79 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -60,6 +60,16 @@ int asoc_simple_card_parse_dai(struct device_node *node,
 				  const char *cells_name,
 				  int *is_single_links);
 
+#define asoc_simple_card_parse_graph_cpu(ep, dai_link)			\
+	asoc_simple_card_parse_graph_dai(ep, &dai_link->cpu_of_node,	\
+					 &dai_link->cpu_dai_name)
+#define asoc_simple_card_parse_graph_codec(ep, dai_link)		\
+	asoc_simple_card_parse_graph_dai(ep, &dai_link->codec_of_node,	\
+					 &dai_link->codec_dai_name)
+int asoc_simple_card_parse_graph_dai(struct device_node *ep,
+				     struct device_node **endpoint_np,
+				     const char **dai_name);
+
 int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
 			      struct asoc_simple_dai *simple_dai);
 
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 003331e..527944d 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -10,6 +10,7 @@
 #include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <sound/simple_card_utils.h>
 
 int asoc_simple_card_parse_daifmt(struct device *dev,
@@ -165,6 +166,58 @@ int asoc_simple_card_parse_dai(struct device_node *node,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai);
 
+int asoc_simple_card_parse_graph_dai(struct device_node *ep,
+				     struct device_node **dai_of_node,
+				     const char **dai_name)
+{
+	struct device_node *node, *port, *endpoint;
+	int i, id;
+
+	if (!ep)
+		return 0;
+
+	/*
+	 * of_graph_get_port_parent() will call
+	 * of_node_put(). So, call of_node_get() here
+	 */
+	of_node_get(ep);
+	node = of_graph_get_port_parent(ep);
+
+	i = 0;
+	id = -1;
+	for_each_of_port(node, port) {
+		if (!of_graph_port_type_is_sound(port))
+			continue;
+
+		for_each_of_endpoint_in_port(port, endpoint) {
+			if (endpoint == ep)
+				id = i;
+			i++;
+		}
+	}
+	if (id < 0)
+		return -ENODEV;
+
+	/* Get dai->name */
+	if (dai_name) {
+		struct of_phandle_args args;
+		int ret;
+
+		args.np		= node;
+		args.args[0]	= id;
+		args.args_count	= (i > 1);
+
+		ret = snd_soc_get_dai_name(&args, dai_name);
+		if (ret < 0)
+			return ret;
+	}
+
+	*dai_of_node = node;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_card_parse_graph_dai);
+
 int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
 			      struct asoc_simple_dai *simple_dai)
 {
-- 
1.9.1

  parent reply	other threads:[~2016-11-28  2:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
2016-11-28  2:44 ` [PATCH v5 01/14] Documentation: of: add type property Kuninori Morimoto
2016-12-01 16:26   ` Rob Herring
2016-12-08  1:57     ` Kuninori Morimoto
2016-11-28  2:45 ` [PATCH v5 02/14] of_graph: add of_graph_get_remote_endpoint() Kuninori Morimoto
2016-11-28  2:45 ` [PATCH v5 03/14] of_graph: add of_graph_port_type_is() Kuninori Morimoto
2016-11-28  2:45 ` [PATCH v5 04/14] of_graph: add of_graph_get_port_parent() Kuninori Morimoto
2016-11-28  2:46 ` [PATCH v5 05/14] of_graph: add of_graph_get_top_port() Kuninori Morimoto
2016-11-28  2:46 ` [PATCH v5 06/14] of_graph: add for_each_of_port() / for_each_of_endpoint_in_port() Kuninori Morimoto
2016-11-28  2:46 ` [PATCH v5 07/14] of_graph: add of_graph_get_endpoint_count() Kuninori Morimoto
2016-11-28  2:46 ` [PATCH v5 08/14] ASoC: simple-card-utils: adjust for graph on asoc_simple_card_parse_card_name Kuninori Morimoto
2016-11-28  2:47 ` Kuninori Morimoto [this message]
2016-11-28  3:41   ` [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai() kbuild test robot
2016-11-28  4:10     ` Kuninori Morimoto
2016-11-28  2:47 ` [PATCH v5 10/14] ASoC: simple-card-utils: add asoc_simple_card_try_to_probe_graph_card() Kuninori Morimoto
2016-11-28  2:47 ` [PATCH v5 11/14] ASoC: add simple-graph-card document Kuninori Morimoto
2016-12-02 13:50   ` Rob Herring
2016-12-04 23:48     ` Kuninori Morimoto
2016-12-05  2:38       ` Kuninori Morimoto
2016-12-05 22:58       ` Rob Herring
2016-12-06  0:57         ` Kuninori Morimoto
2016-12-06 15:03           ` Rob Herring
2016-12-07  0:10             ` Kuninori Morimoto
2016-12-05  2:21     ` Kuninori Morimoto
2016-11-28  2:48 ` [PATCH v5 12/14] ASoC: add simple-graph-card support Kuninori Morimoto
2016-11-28  4:19   ` kbuild test robot
2016-11-28  2:48 ` [PATCH v5 13/14] ASoC: add simple-graph-scu-card document Kuninori Morimoto
2016-12-05 22:40   ` Rob Herring
2016-12-06  6:33     ` Kuninori Morimoto
2016-11-28  2:48 ` [PATCH v5 14/14] ASoC: add simple-graph-scu-card support Kuninori Morimoto
2016-11-28  4:36   ` kbuild test robot

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=877f7owccz.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=grant.likely@linaro.org \
    --cc=horms@verge.net.au \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®