ASoC: rsnd: add rsnd_get_adinr()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fri, 9 May 2014 00:44:14 +0000 (17:44 -0700)
committerSimon Horman <horms@verge.net.au>
Fri, 5 Dec 2014 00:24:04 +0000 (09:24 +0900)
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>
(cherry picked from commit d7bdbc5d9e4e813522f46632527826211270b9d0)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/rsnd.h
sound/soc/sh/rcar/src.c

index 8bc3ef2..c3a5035 100644 (file)
@@ -309,6 +309,32 @@ void  rsnd_dma_quit(struct rsnd_priv *priv,
 }
 
 /*
+ *     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
  */
 #define __rsnd_mod_call(mod, func, rdai, io)                   \
index 061b04c..fee3ec2 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 09424bc..60e966d 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);