[alsa-devel] [PATCH 11/21] ASoC: rsnd: count each mod (SSI/SRC/DVC)

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Mon Jun 15 08:24:34 CEST 2015


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

Each Renesas sound mod (= SSI/SRC/DVC) might be called from many paths
if it supports MIXer. Then, we don't need to re-call each mod function
that had been called. This patch count each mod status.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym at renesas.com>
---
 sound/soc/sh/rcar/core.c | 17 +++++++++++------
 sound/soc/sh/rcar/rsnd.h | 41 ++++++++++++++++++++++++++---------------
 2 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 027b043..50ec28c 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -211,15 +211,20 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod)
 ({								\
 	struct rsnd_priv *priv = rsnd_mod_to_priv(mod);		\
 	struct device *dev = rsnd_priv_to_dev(priv);		\
-	u32 mask = (1 << __rsnd_mod_shift_##func) & ~(1 << 31);	\
-	u32 call = __rsnd_mod_call_##func << __rsnd_mod_shift_##func;	\
+	u32 mask = 0xF << __rsnd_mod_shift_##func;			\
+	u8 val  = (mod->status >> __rsnd_mod_shift_##func) & 0xF;	\
+	u8 add  = ((val + __rsnd_mod_add_##func) & 0xF);		\
 	int ret = 0;							\
-	if ((mod->status & mask) == call) {				\
-		dev_dbg(dev, "%s[%d] %s\n",				\
-			rsnd_mod_name(mod), rsnd_mod_id(mod), #func);	\
+	int called = 0;							\
+	if (val == __rsnd_mod_call_##func) {				\
+		called = 1;						\
 		ret = (mod)->ops->func(mod, param);			\
-		mod->status = (mod->status & ~mask) | (~call & mask);	\
+		mod->status = (mod->status & ~mask) +			\
+			(add << __rsnd_mod_shift_##func);		\
 	}								\
+	dev_dbg(dev, "%s[%d] 0x%08x %s\n",				\
+		rsnd_mod_name(mod), rsnd_mod_id(mod), mod->status,	\
+		called ? #func : "");					\
 	ret;								\
 })
 
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index e37234e..8a114cb 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -259,25 +259,36 @@ struct rsnd_mod {
 /*
  * status
  *
- * bit
- * 0	0: probe	1: remove
- * 1	0: init		1: quit
- * 2	0: start	1: stop
- * 3	0: pcm_new
- * 4	0: fallback
+ * 0xH0000CBA
  *
- * 31 bit is always called (see __rsnd_mod_call)
- * 31	0: hw_params
+ * A	0: probe	1: remove
+ * B	0: init		1: quit
+ * C	0: start	1: stop
+ *
+ * H is always called (see __rsnd_mod_call)
+ * H	0: pcm_new
+ * H	0: fallback
+ * H	0: hw_params
  */
 #define __rsnd_mod_shift_probe		0
 #define __rsnd_mod_shift_remove		0
-#define __rsnd_mod_shift_init		1
-#define __rsnd_mod_shift_quit		1
-#define __rsnd_mod_shift_start		2
-#define __rsnd_mod_shift_stop		2
-#define __rsnd_mod_shift_pcm_new	3
-#define __rsnd_mod_shift_fallback	4
-#define __rsnd_mod_shift_hw_params	31 /* always called */
+#define __rsnd_mod_shift_init		4
+#define __rsnd_mod_shift_quit		4
+#define __rsnd_mod_shift_start		8
+#define __rsnd_mod_shift_stop		8
+#define __rsnd_mod_shift_pcm_new	28 /* always called */
+#define __rsnd_mod_shift_fallback	28 /* always called */
+#define __rsnd_mod_shift_hw_params	28 /* always called */
+
+#define __rsnd_mod_add_probe		 1
+#define __rsnd_mod_add_remove		-1
+#define __rsnd_mod_add_init		 1
+#define __rsnd_mod_add_quit		-1
+#define __rsnd_mod_add_start		 1
+#define __rsnd_mod_add_stop		-1
+#define __rsnd_mod_add_pcm_new		0
+#define __rsnd_mod_add_fallback		0
+#define __rsnd_mod_add_hw_params	0
 
 #define __rsnd_mod_call_probe		0
 #define __rsnd_mod_call_remove		1
-- 
1.9.1



More information about the Alsa-devel mailing list