All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 04/15] ASoC: audio-graph: add graph_parse_mclk_fs()
Date: 18 Mar 2019 13:50:31 +0900	[thread overview]
Message-ID: <87zhpsyezj.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <875zsgztld.wl-kuninori.morimoto.gx@renesas.com>


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

It is parsing mclk_fs at many places, but it should be
same operation. This patch adds graph_parse_mclk_fs()
and parse it.

This patch also renames similar function graph_get_conversion()
to graph_parse_convert().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card.c | 50 +++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 27 deletions(-)

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 733ba1e..7dd772a 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -196,6 +196,24 @@ static void graph_parse_convert(struct device *dev,
 	of_node_put(node);
 }
 
+static void graph_parse_mclk_fs(struct device_node *top,
+				struct device_node *ep,
+				struct graph_dai_props *props)
+{
+	struct device_node *port	= of_get_parent(ep);
+	struct device_node *ports	= of_get_parent(port);
+	struct device_node *node	= of_graph_get_port_parent(ep);
+
+	of_property_read_u32(top,	"mclk-fs", &props->mclk_fs);
+	of_property_read_u32(ports,	"mclk-fs", &props->mclk_fs);
+	of_property_read_u32(port,	"mclk-fs", &props->mclk_fs);
+	of_property_read_u32(ep,	"mclk-fs", &props->mclk_fs);
+
+	of_node_put(port);
+	of_node_put(ports);
+	of_node_put(node);
+}
+
 static int graph_dai_link_of_dpcm(struct graph_priv *priv,
 				  struct device_node *cpu_ep,
 				  struct device_node *codec_ep,
@@ -226,13 +244,6 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv,
 
 	dev_dbg(dev, "link_of DPCM (%pOF)\n", ep);
 
-	of_property_read_u32(top,   "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(ports, "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(port,  "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(ep,    "mclk-fs", &dai_props->mclk_fs);
-
-	graph_parse_convert(dev, ep, &dai_props->adata);
-
 	of_node_put(ports);
 	of_node_put(port);
 	of_node_put(node);
@@ -311,6 +322,9 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv,
 					     "prefix");
 	}
 
+	graph_parse_convert(dev, ep, &dai_props->adata);
+	graph_parse_mclk_fs(top, ep, dai_props);
+
 	asoc_simple_card_canonicalize_platform(dai_link);
 
 	ret = asoc_simple_card_of_parse_tdm(ep, dai);
@@ -339,10 +353,6 @@ static int graph_dai_link_of(struct graph_priv *priv,
 	struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, li->link);
 	struct graph_dai_props *dai_props = graph_priv_to_props(priv, li->link);
 	struct device_node *top = dev->of_node;
-	struct device_node *cpu_port;
-	struct device_node *cpu_ports;
-	struct device_node *codec_port;
-	struct device_node *codec_ports;
 	struct asoc_simple_dai *cpu_dai;
 	struct asoc_simple_dai *codec_dai;
 	int ret;
@@ -351,11 +361,6 @@ static int graph_dai_link_of(struct graph_priv *priv,
 	if (!li->cpu)
 		return 0;
 
-	cpu_port	= of_get_parent(cpu_ep);
-	cpu_ports	= of_get_parent(cpu_port);
-	codec_port	= of_get_parent(codec_ep);
-	codec_ports	= of_get_parent(codec_port);
-
 	dev_dbg(dev, "link_of (%pOF)\n", cpu_ep);
 
 	li->link++;
@@ -366,17 +371,8 @@ static int graph_dai_link_of(struct graph_priv *priv,
 	dai_props->codec_dai	= &priv->dais[li->dais++];
 
 	/* Factor to mclk, used in hw_params() */
-	of_property_read_u32(top,         "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(cpu_ports,   "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(codec_ports, "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(cpu_port,    "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(codec_port,  "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(cpu_ep,      "mclk-fs", &dai_props->mclk_fs);
-	of_property_read_u32(codec_ep,    "mclk-fs", &dai_props->mclk_fs);
-	of_node_put(cpu_port);
-	of_node_put(cpu_ports);
-	of_node_put(codec_port);
-	of_node_put(codec_ports);
+	graph_parse_mclk_fs(top, cpu_ep,   dai_props);
+	graph_parse_mclk_fs(top, codec_ep, dai_props);
 
 	ret = asoc_simple_card_parse_daifmt(dev, cpu_ep, codec_ep,
 					    NULL, &dai_link->dai_fmt);
-- 
2.7.4

  parent reply	other threads:[~2019-03-18  4:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18  4:49 [PATCH 00/15] ASoC: simple-card: share similar function Kuninori Morimoto
2019-03-18  4:50 ` [PATCH 01/15] ASoC: simple-card: rename simple_get_conversion() to simple_parse_convert() Kuninori Morimoto
2019-03-18 14:51   ` Applied "ASoC: simple-card: rename simple_get_conversion() to simple_parse_convert()" to the asoc tree Mark Brown
2019-03-18  4:50 ` [PATCH 02/15] ASoC: simple-card: add simple_parse_mclk_fs() Kuninori Morimoto
2019-03-18 14:50   ` Applied "ASoC: simple-card: add simple_parse_mclk_fs()" to the asoc tree Mark Brown
2019-03-18  4:50 ` [PATCH 03/15] ASoC: audio-graph: rename graph_get_conversion() to graph_parse_convert() Kuninori Morimoto
2019-03-18 14:50   ` Applied "ASoC: audio-graph: rename graph_get_conversion() to graph_parse_convert()" to the asoc tree Mark Brown
2019-03-18  4:50 ` Kuninori Morimoto [this message]
2019-03-18 14:50   ` Applied "ASoC: audio-graph: add graph_parse_mclk_fs()" " Mark Brown
2019-03-18  4:53 ` [PATCH 05/15] ASoC: simple-card-utils: add asoc_simple_debug_info() Kuninori Morimoto
2019-03-18  4:53 ` [PATCH 06/15] ASoC: simple_card_utils: share common priv for simple-card/audio-graph Kuninori Morimoto
2019-03-18  4:53 ` [PATCH 07/15] ASoC: simple-card-utils: share asoc_simple_startup() Kuninori Morimoto
2019-03-18  4:53 ` [PATCH 08/15] ASoC: simple-card-utils: share asoc_simple_shutdown() Kuninori Morimoto
2019-03-18  4:53 ` [PATCH 09/15] ASoC: simple-card-utils: share asoc_simple_hw_param() Kuninori Morimoto
2019-03-18  4:54 ` [PATCH 10/15] ASoC: simple-card-utils: share asoc_simple_dai_init() Kuninori Morimoto
2019-03-18  4:54 ` [PATCH 11/15] ASoC: simple-card-utils: share asoc_simple_be_hw_params_fixup() Kuninori Morimoto
2019-03-18  4:54 ` [PATCH 12/15] ASoC: simple-card-utils: share asoc_simple_card_init_priv() Kuninori Morimoto
2019-03-18  4:55 ` [PATCH 13/15] ASoC: simple-card-utils: separate asoc_simple_card_parse_dai() Kuninori Morimoto
2019-03-18  4:55 ` [PATCH 14/15] ASoC: simple-card-utils: rename asoc_simple_card_xxx() to asoc_simple_() Kuninori Morimoto
2019-03-18  4:55 ` [PATCH 15/15] ASoC: simple-card-utils: test memory allocation Kuninori Morimoto
2019-03-20  4:49 ` [PATCH 00/15] ASoC: simple-card: share similar function 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=87zhpsyezj.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@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.