ASoC: rsnd: add rsnd_get_adinr()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fri, 9 May 2014 00:44:14 +0000 (17:44 -0700)
committerMark Brown <broonie@linaro.org>
Tue, 13 May 2014 18:06:16 +0000 (19:06 +0100)
SRC module needs ADINR register settings,
but, it has many similar xxx_ADINR register,
and needs same settings.
This patch adds rsnd_get_adinr() to sharing code.

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

index f74d02cb70f1c7f25ff08a93b4fb63ee82f1e5e4..e47aa53471b1158799404202d361f29aedd2ae8a 100644 (file)
@@ -309,6 +309,32 @@ void  rsnd_dma_quit(struct rsnd_priv *priv,
        dma->chan = NULL;
 }
 
+/*
+ *     settting function
+ */
+u32 rsnd_get_adinr(struct rsnd_mod *mod)
+{
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       u32 adinr = runtime->channels;
+
+       switch (runtime->sample_bits) {
+       case 16:
+               adinr |= (8 << 16);
+               break;
+       case 32:
+               adinr |= (0 << 16);
+               break;
+       default:
+               dev_warn(dev, "not supported sample bits\n");
+               return 0;
+       }
+
+       return adinr;
+}
+
 /*
  *     rsnd_dai functions
  */
index 061b04cbd7d5272864593308a5911c99bfad2506..fee3ec21aaeb664f28139b8169fd6a993ac2497f 100644 (file)
@@ -136,6 +136,7 @@ void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
                enum rsnd_reg reg, u32 data);
 void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
                    u32 mask, u32 data);
+u32 rsnd_get_adinr(struct rsnd_mod *mod);
 
 /*
  *     R-Car DMA
index d51c59bf7c474f8305c1b12d01e993ec9be99fcb..c90c36d41799f3f059e0b4a4847f0c7b2aecaf67 100644 (file)
@@ -18,15 +18,6 @@ struct rsnd_src {
 
 #define RSND_SRC_NAME_SIZE 16
 
-/*
- * ADINR
- */
-#define OTBL_24                (0 << 16)
-#define OTBL_22                (2 << 16)
-#define OTBL_20                (4 << 16)
-#define OTBL_18                (6 << 16)
-#define OTBL_16                (8 << 16)
-
 #define rsnd_src_convert_rate(p) ((p)->info->convert_rate)
 #define rsnd_mod_to_src(_mod)                          \
        container_of((_mod), struct rsnd_src, mod)
@@ -197,7 +188,6 @@ static int rsnd_src_set_convert_rate(struct rsnd_mod *mod,
        struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
        struct rsnd_src *src = rsnd_mod_to_src(mod);
        u32 convert_rate = rsnd_src_convert_rate(src);
-       u32 adinr = runtime->channels;
        u32 fsrate = 0;
 
        if (convert_rate)
@@ -214,17 +204,7 @@ static int rsnd_src_set_convert_rate(struct rsnd_mod *mod,
        rsnd_mod_write(mod, SRC_SRCIR, 1);
 
        /* Set channel number and output bit length */
-       switch (runtime->sample_bits) {
-       case 16:
-               adinr |= OTBL_16;
-               break;
-       case 32:
-               adinr |= OTBL_24;
-               break;
-       default:
-               return -EIO;
-       }
-       rsnd_mod_write(mod, SRC_ADINR, adinr);
+       rsnd_mod_write(mod, SRC_ADINR, rsnd_get_adinr(mod));
 
        /* Enable the initial value of IFS */
        if (fsrate) {
@@ -487,8 +467,8 @@ static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod,
        if (ret < 0)
                return ret;
 
-       rsnd_mod_write(mod, SSI_BUSIF_ADINR, rsnd_mod_read(mod, SRC_ADINR));
-       rsnd_mod_write(mod, SSI_BUSIF_MODE,  rsnd_mod_read(mod, SRC_BUSIF_MODE));
+       rsnd_mod_write(mod, SSI_BUSIF_ADINR, rsnd_get_adinr(mod));
+       rsnd_mod_write(mod, SSI_BUSIF_MODE,  1);
 
        rsnd_mod_write(mod, SRC_SRCCR, 0x00011110);