ASoC: rsnd: add callback status check method
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 27 Nov 2014 08:02:55 +0000 (08:02 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 3 Dec 2014 18:51:39 +0000 (18:51 +0000)
R-Car sound can use SSI/SRC/DVC modules, and these are controlled as
rsnd_mod in rsnd driver. These rsnd_mod has each own function as
callback. Basically these callback function has pair like probe/remove,
start/stop, etc. And, these functions are called by order to each stage
like below.
 1. src->probe
 2. ssi->probe
 3. dvc->probe
 4. src->start
 5. ssi->start
 6. dvc->start
 7. src->stop
 8. ssi->stop
 9. dvc->stop
10. src->remove
11. ssi->remove
12. dvc->remove

But, current rsnd driver doesn't care about its status which indicates
which function is called.
For example, if 5) returns error, 6) is not called. In such case,
9) should not be called. This patch care about each modules status.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/rsnd.h

index 0785f84b54db4c851ec0f42799a675ac49380c5c..fce61a05d771b778db63c0deb918c8ee2b3c9690 100644 (file)
@@ -416,9 +416,16 @@ 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);            \
-       dev_dbg(dev, "%s[%d] %s\n",                             \
-               rsnd_mod_name(mod), rsnd_mod_id(mod), #func);   \
-       (mod)->ops->func(mod, rdai);                            \
+       u32 mask = 1 << __rsnd_mod_shift_##func;                        \
+       u32 call = __rsnd_mod_call_##func << __rsnd_mod_shift_##func;   \
+       int ret = 0;                                                    \
+       if ((mod->status & mask) == call) {                             \
+               dev_dbg(dev, "%s[%d] %s\n",                             \
+                       rsnd_mod_name(mod), rsnd_mod_id(mod), #func);   \
+               ret = (mod)->ops->func(mod, rdai);                      \
+               mod->status = (mod->status & ~mask) | (~call & mask);   \
+       }                                                               \
+       ret;                                                            \
 })
 
 #define rsnd_mod_call(mod, func, rdai...)      \
index 83e1066e31bf7df04502e9a32e8511b68f110bac..c74c239f2ce38105305825a7d184c1d839f4f1d7 100644 (file)
@@ -218,7 +218,35 @@ struct rsnd_mod {
        struct rsnd_mod_ops *ops;
        struct rsnd_dma dma;
        struct rsnd_dai_stream *io;
+       u32 status;
 };
+/*
+ * status
+ *
+ * bit
+ * 0   0: probe        1: remove
+ * 1   0: init         1: quit
+ * 2   0: start        1: stop
+ * 3   0: pcm_new
+ * 4   0: fallback
+ */
+#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_call_probe          0
+#define __rsnd_mod_call_remove         1
+#define __rsnd_mod_call_init           0
+#define __rsnd_mod_call_quit           1
+#define __rsnd_mod_call_start          0
+#define __rsnd_mod_call_stop           1
+#define __rsnd_mod_call_pcm_new                0
+#define __rsnd_mod_call_fallback       0
 
 #define rsnd_mod_to_priv(mod) ((mod)->priv)
 #define rsnd_mod_to_dma(mod) (&(mod)->dma)