Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	Simon <horms@verge.net.au>, Liam Girdwood <lgirdwood@gmail.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: [PATCH 02/11] ASoC: rsnd: Get correct SCU ID
Date: Mon, 03 Mar 2014 20:50:00 -0800 (PST)	[thread overview]
Message-ID: <8761nu1say.wl%kuninori.morimoto.gx@gmail.com> (raw)
In-Reply-To: <878usq1scd.wl%kuninori.morimoto.gx@gmail.com>

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

Current rsnd driver is assuming that SCU/SRU ID is
same as SSIU/SSI ID, because Gen1 can't select it.
But, Gen2 can select it.
The SCU/SRU/SSIU/SSI pair depends on the platform.
This patch get correct SCU ID from platform info.
To keep compatible, it still assuming SCU ID = SSI ID
if platform doesn't have info

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/rcar_snd.h |    1 +
 sound/soc/sh/rcar/core.c |   47 ++++++++++++++++++++++++++++++++--------------
 sound/soc/sh/rcar/rsnd.h |   14 ++++++++++++++
 sound/soc/sh/rcar/scu.c  |   21 ++++++++++++++++-----
 sound/soc/sh/rcar/ssi.c  |    9 ++++++++-
 5 files changed, 72 insertions(+), 20 deletions(-)

diff --git a/include/sound/rcar_snd.h b/include/sound/rcar_snd.h
index 698f7b5..1d8c683 100644
--- a/include/sound/rcar_snd.h
+++ b/include/sound/rcar_snd.h
@@ -70,6 +70,7 @@ struct rsnd_scu_platform_info {
 
 struct rsnd_dai_path_info {
 	struct rsnd_ssi_platform_info *ssi;
+	struct rsnd_scu_platform_info *scu;
 };
 
 struct rsnd_dai_platform_info {
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 4504726..7316d10 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -107,6 +107,11 @@
 	(!(priv->info->func) ? 0 :		\
 	 priv->info->func(param))
 
+#define rsnd_is_enable_path(io, name) \
+	((io)->info ? (io)->info->name : NULL)
+#define rsnd_info_id(priv, io, name) \
+	((io)->info->name - priv->info->name##_info)
+
 /*
  *	rsnd_mod functions
  */
@@ -572,8 +577,10 @@ static int rsnd_path_init(struct rsnd_priv *priv,
 			  struct rsnd_dai_stream *io)
 {
 	struct rsnd_mod *mod;
+	struct rsnd_dai_platform_info *dai_info = rdai->info;
 	int ret;
-	int id;
+	int ssi_id = -1;
+	int scu_id = -1;
 
 	/*
 	 * Gen1 is created by SRU/SSI, and this SRU is base module of
@@ -584,29 +591,35 @@ static int rsnd_path_init(struct rsnd_priv *priv,
 	 *
 	 * Gen2 SCU path is very flexible, but, Gen1 SRU (SCU parts) is
 	 * using fixed path.
-	 *
-	 * Then, SSI id = SCU id here
 	 */
-	/* get SSI's ID */
-	mod = rsnd_ssi_mod_get_frm_dai(priv,
-				       rsnd_dai_id(priv, rdai),
-				       rsnd_dai_is_play(rdai, io));
-	if (!mod)
-		return 0;
-	id = rsnd_mod_id(mod);
+	if (dai_info) {
+		if (rsnd_is_enable_path(io, ssi))
+			ssi_id = rsnd_info_id(priv, io, ssi);
+		if (rsnd_is_enable_path(io, scu))
+			scu_id = rsnd_info_id(priv, io, scu);
+	} else {
+		/* get SSI's ID */
+		mod = rsnd_ssi_mod_get_frm_dai(priv,
+					       rsnd_dai_id(priv, rdai),
+					       rsnd_dai_is_play(rdai, io));
+		if (!mod)
+			return 0;
+		ssi_id = scu_id = rsnd_mod_id(mod);
+	}
+
 	ret = 0;
 
 	/* SCU */
-	mod = rsnd_scu_mod_get(priv, id);
-	if (mod) {
+	if (scu_id >= 0) {
+		mod = rsnd_scu_mod_get(priv, scu_id);
 		ret = rsnd_dai_connect(mod, io);
 		if (ret < 0)
 			return ret;
 	}
 
 	/* SSI */
-	mod = rsnd_ssi_mod_get(priv, id);
-	if (mod) {
+	if (ssi_id >= 0) {
+		mod = rsnd_ssi_mod_get(priv, ssi_id);
 		ret = rsnd_dai_connect(mod, io);
 		if (ret < 0)
 			return ret;
@@ -699,6 +712,9 @@ static int rsnd_dai_probe(struct platform_device *pdev,
 			drv[i].playback.formats		= RSND_FMTS;
 			drv[i].playback.channels_min	= 2;
 			drv[i].playback.channels_max	= 2;
+
+			if (info->dai_info)
+				rdai[i].playback.info = &info->dai_info[i].playback;
 			rsnd_path_init(priv, &rdai[i], &rdai[i].playback);
 		}
 		if (cmod) {
@@ -706,6 +722,9 @@ static int rsnd_dai_probe(struct platform_device *pdev,
 			drv[i].capture.formats		= RSND_FMTS;
 			drv[i].capture.channels_min	= 2;
 			drv[i].capture.channels_max	= 2;
+
+			if (info->dai_info)
+				rdai[i].capture.info = &info->dai_info[i].capture;
 			rsnd_path_init(priv, &rdai[i], &rdai[i].capture);
 		}
 
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index d5afdee..3472631 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -211,6 +211,7 @@ char *rsnd_mod_name(struct rsnd_mod *mod);
 struct rsnd_dai_stream {
 	struct snd_pcm_substream *substream;
 	struct rsnd_mod *mod[RSND_MOD_MAX];
+	struct rsnd_dai_path_info *info; /* rcar_snd.h */
 	int byte_pos;
 	int period_pos;
 	int byte_per_period;
@@ -328,6 +329,19 @@ struct rsnd_priv {
 #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags)
 #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags)
 
+#define rsnd_info_is_playback(priv, type)				\
+({									\
+	struct rcar_snd_info *info = rsnd_priv_to_info(priv);		\
+	int i, is_play = 0;						\
+	for (i = 0; i < info->dai_info_nr; i++) {			\
+		if (info->dai_info[i].playback.type == (type)->info) {	\
+			is_play = 1;					\
+			break;						\
+		}							\
+	}								\
+	is_play;							\
+})
+
 /*
  *	R-Car SCU
  */
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c
index 1073d35..b517300 100644
--- a/sound/soc/sh/rcar/scu.c
+++ b/sound/soc/sh/rcar/scu.c
@@ -620,6 +620,9 @@ int rsnd_scu_probe(struct platform_device *pdev,
 	 * init SCU
 	 */
 	nr	= info->scu_info_nr;
+	if (!nr)
+		return 0;
+
 	scu	= devm_kzalloc(dev, sizeof(*scu) * nr, GFP_KERNEL);
 	if (!scu) {
 		dev_err(dev, "SCU allocate failed\n");
@@ -644,11 +647,19 @@ int rsnd_scu_probe(struct platform_device *pdev,
 			if (rsnd_is_gen1(priv))
 				ops = &rsnd_scu_gen1_ops;
 			if (rsnd_is_gen2(priv)) {
-				struct rsnd_mod *ssi = rsnd_ssi_mod_get(priv, i);
-				int ret = rsnd_dma_init(priv,
-						rsnd_mod_to_dma(&scu->mod),
-						rsnd_ssi_is_play(ssi),
-						scu->info->dma_id);
+				int ret;
+				int is_play;
+
+				if (info->dai_info) {
+					is_play = rsnd_info_is_playback(priv, scu);
+				} else {
+					struct rsnd_mod *ssi = rsnd_ssi_mod_get(priv, i);
+					is_play = rsnd_ssi_is_play(ssi);
+				}
+				ret = rsnd_dma_init(priv,
+						    rsnd_mod_to_dma(&scu->mod),
+						    is_play,
+						    scu->info->dma_id);
 				if (ret < 0)
 					return ret;
 
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 3423481..9162c2b 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -567,9 +567,16 @@ int rsnd_ssi_probe(struct platform_device *pdev,
 		 * SSI DMA case
 		 */
 		if (pinfo->dma_id > 0) {
+			int is_play;
+
+			if (info->dai_info)
+				is_play = rsnd_info_is_playback(priv, ssi);
+			else
+				is_play = rsnd_ssi_is_play(&ssi->mod);
+
 			ret = rsnd_dma_init(
 				priv, rsnd_mod_to_dma(&ssi->mod),
-				rsnd_ssi_is_play(&ssi->mod),
+				is_play,
 				pinfo->dma_id);
 			if (ret < 0)
 				dev_info(dev, "SSI DMA failed. try PIO transter\n");
-- 
1.7.9.5

  parent reply	other threads:[~2014-03-04  4:50 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25  6:13 [PATCH 0/19] ASoC: rsnd: new module path method and DT support Kuninori Morimoto
2014-02-25  6:14 ` [PATCH 01/19] ASoC: rsnd: move priv member settings to upper side Kuninori Morimoto
2014-03-03  1:19   ` Mark Brown
2014-02-25  6:14 ` [PATCH 02/19] ASoC: rsnd: move rsnd_mod_call() macro Kuninori Morimoto
2014-03-03  1:19   ` Mark Brown
2014-02-25  6:15 ` [PATCH 03/19] ASoC: rsnd: remove verbose function parameter Kuninori Morimoto
2014-03-03  1:19   ` Mark Brown
2014-02-25  6:15 ` [PATCH 04/19] ASoC: rsnd: remove verbose debug message from scu/ssi Kuninori Morimoto
2014-03-03  1:20   ` Mark Brown
2014-02-25  6:15 ` [PATCH 05/19] ASoC: rsnd: unify rdai naming Kuninori Morimoto
2014-03-03  1:20   ` Mark Brown
2014-02-25  6:15 ` [PATCH 06/19] ASoC: rsnd: add .set_sysclk on snd_soc_dai_ops Kuninori Morimoto
2014-03-03  1:18   ` Mark Brown
2014-03-03  2:08     ` Kuninori Morimoto
2014-03-03  2:12       ` Kuninori Morimoto
2014-03-03  7:45         ` Kuninori Morimoto
2014-02-25  6:15 ` [PATCH 07/19] ASoC: rsnd: tidyup RSND_SSI_xxx flags Kuninori Morimoto
2014-03-03  1:21   ` Mark Brown
2014-02-25  6:15 ` [PATCH 08/19] ASoC: rsnd: run rsnd_path_init() when probe() timing Kuninori Morimoto
2014-03-03  1:22   ` Mark Brown
2014-02-25  6:15 ` [PATCH 09/19] ASoC: rsnd: use mod array instead of list on rdai Kuninori Morimoto
2014-02-25  6:15 ` [PATCH 10/19] ASoC: rsnd: get ssi/scu from rsnd_dai_stream Kuninori Morimoto
2014-02-25  6:16 ` [PATCH 11/19] ASoC: rsnd: add struct rsnd_dai_platform_info Kuninori Morimoto
2014-02-25  6:16 ` [PATCH 12/19] ASoC: rsnd: use function pointer for each probe Kuninori Morimoto
2014-02-25  6:16 ` [PATCH 13/19] ASoC: rsnd: Get correct SCU ID Kuninori Morimoto
2014-02-25  6:16 ` [PATCH 14/19] ASoC: rsnd: add rsnd_scu_enable_ssi_irq() Kuninori Morimoto
2014-02-25  6:16 ` [PATCH 15/19] ASoC: rsnd: call rsnd_scu_ssi_mode_init() from SSI Kuninori Morimoto
2014-02-25  6:16 ` [PATCH 16/19] ASoC: rsnd: add probe/remove callback on rsnd_mod_ops Kuninori Morimoto
2014-02-25  6:16 ` [PATCH 17/19] ASoC: rsnd: use mod probe method on SCU Kuninori Morimoto
2014-02-25  6:17 ` [PATCH 18/19] ASoC: rsnd: use mod probe method on SSI Kuninori Morimoto
2014-02-25  6:17 ` [PATCH 19/19] ASoC: rsnd: add DeviceTree support Kuninori Morimoto
2014-02-27  5:08 ` [PATCH 0/19] ASoC: rsnd: new module path method and DT support Mark Brown
2014-02-27 10:18   ` Kuninori Morimoto
2014-02-27 11:47     ` Mark Brown
2014-03-03  1:29 ` Mark Brown
2014-03-03  7:42 ` Kuninori Morimoto
2014-03-03  7:42   ` [PATCH 1/8] ASoC: rsnd: run rsnd_path_init() when probe() timing Kuninori Morimoto
2014-03-04  4:13     ` Mark Brown
2014-03-03  7:42   ` [PATCH 2/8] ASoC: rsnd: use mod array instead of list on rdai Kuninori Morimoto
2014-03-03  7:43   ` [PATCH 3/8] ASoC: rsnd: get ssi/scu from rsnd_dai_stream Kuninori Morimoto
2014-03-03  7:43   ` [PATCH 4/8] ASoC: rsnd: use devm_clk_get() instead of clk_get() Kuninori Morimoto
2014-03-03  7:43   ` [PATCH 5/8] ASoC: rsnd: use function pointer for each probe Kuninori Morimoto
2014-03-03  7:43   ` [PATCH 6/8] ASoC: rsnd: remove unused SSI_CONTROL Kuninori Morimoto
2014-03-03  7:43   ` [PATCH 7/8] ASoC: rsnd: modify rsnd_adg_ssi_ws_timing_gen2() parameter Kuninori Morimoto
2014-03-03  7:43   ` [PATCH 8/8] ASoC: rsnd: share reg_field and reduce memory Kuninori Morimoto
2014-03-04  4:49 ` [PATCH 0/19] ASoC: rsnd: new module path method and DT support Kuninori Morimoto
2014-03-04  4:49   ` [PATCH 01/11] ASoC: rsnd: add struct rsnd_dai_platform_info Kuninori Morimoto
2014-03-04  4:50   ` Kuninori Morimoto [this message]
2014-03-04  4:50   ` [PATCH 03/11] ASoC: rsnd: add rsnd_scu_enable_ssi_irq() Kuninori Morimoto
2014-03-04  4:50   ` [PATCH 04/11] ASoC: rsnd: call rsnd_scu_ssi_mode_init() from SSI Kuninori Morimoto
2014-03-04  4:50   ` [PATCH 05/11] ASoC: rsnd: add probe/remove callback on rsnd_mod_ops Kuninori Morimoto
2014-03-04  4:50   ` [PATCH 06/11] ASoC: rsnd: use mod probe method on SCU Kuninori Morimoto
2014-03-04  4:50   ` [PATCH 07/11] ASoC: rsnd: use mod probe method on SSI Kuninori Morimoto
2014-03-04  4:51   ` [PATCH 08/11] ASoC: rsnd: nothing to do on rsnd_dai_remove() Kuninori Morimoto
2014-03-04  4:51   ` [PATCH 09/11] ASoC: rsnd: remove all rsnd_xxx_remove() Kuninori Morimoto
2014-03-04  4:51   ` [PATCH 10/11] ASoC: rsnd: rename scu to src Kuninori Morimoto
2014-03-05  6:08     ` Mark Brown
2014-03-04  4:51   ` [PATCH 11/11] ASoC: rsnd: add DeviceTree support Kuninori Morimoto
2014-03-05  6:39     ` Forward: " Kuninori Morimoto
2014-03-10 14:52       ` Ben Dooks
     [not found]         ` <20140310145254.GJ4400-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2014-03-14  0:34           ` [alsa-devel] " Kuninori Morimoto
     [not found]             ` <87fvmlpqi1.wl%kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-03-18  2:29               ` [PATCH v2] " Kuninori Morimoto
     [not found]                 ` <87ob14jl2d.wl%kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-03-21 18:18                   ` Mark Brown
     [not found]                     ` <20140321181813.GP552-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-03-24  0:07                       ` Kuninori Morimoto
2014-03-24  3:29                       ` [PATCH] ASoC: rcar: subnode tidyup for renesas,rsnd.txt Kuninori Morimoto
     [not found]                         ` <87fvm8i8ah.wl%kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-03-25 13:04                           ` Mark Brown
2014-03-10 16:28 ` [PATCH 0/19] ASoC: rsnd: new module path method and DT support Ben Dooks
2014-03-11  0:00   ` 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=8761nu1say.wl%kuninori.morimoto.gx@gmail.com \
    --to=kuninori.morimoto.gx@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=horms@verge.net.au \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    /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