ASoC: rsnd: care audio local bus data format consistency
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 31 Jul 2014 06:52:26 +0000 (23:52 -0700)
committerMark Brown <broonie@linaro.org>
Thu, 31 Jul 2014 19:36:33 +0000 (20:36 +0100)
R-Car sound uses Audio Local Bus which uses Lch/Rch format.
This bus is used if driver uses BUSIF.
But sound data is written as Rch/Lch format in register.
This means Rch <-> Lch will be inverted.
SSIU :: BUSIF_DALIGN is used to controlling data format.

Reported-by: Jun Watanabe <jun.watanabe.ue@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/sh/rcar/gen.c
sound/soc/sh/rcar/rsnd.h
sound/soc/sh/rcar/src.c

index 5f9e0722abcf8ecd48d2c995290ce832301e202f..5db0557509911ba6c73b0ff63479e4f71fad99be 100644 (file)
@@ -284,6 +284,7 @@ static int rsnd_gen2_probe(struct platform_device *pdev,
                /* FIXME: it needs SSI_MODE2/3 in the future */
                RSND_GEN_M_REG(SSI_BUSIF_MODE,  0x0,    0x80),
                RSND_GEN_M_REG(SSI_BUSIF_ADINR, 0x4,    0x80),
+               RSND_GEN_M_REG(BUSIF_DALIGN,    0x8,    0x80),
                RSND_GEN_M_REG(SSI_CTRL,        0x10,   0x80),
                RSND_GEN_M_REG(INT_ENABLE,      0x18,   0x80),
        };
index 631b149df08f318e1b043e6104edabe5584ade0c..d119adf97c9c07538f7f4c05583482b8c52fea56 100644 (file)
@@ -90,6 +90,7 @@ enum rsnd_reg {
        RSND_REG_SHARE19,
        RSND_REG_SHARE20,
        RSND_REG_SHARE21,
+       RSND_REG_SHARE22,
 
        RSND_REG_MAX,
 };
@@ -127,6 +128,7 @@ enum rsnd_reg {
 #define RSND_REG_AUDIO_CLK_SEL2                RSND_REG_SHARE19
 #define RSND_REG_CMD_CTRL              RSND_REG_SHARE20
 #define RSND_REG_CMDOUT_TIMSEL         RSND_REG_SHARE21
+#define RSND_REG_BUSIF_DALIGN          RSND_REG_SHARE22
 
 struct rsnd_of_data;
 struct rsnd_priv;
index 1ef811a26bd780366107028ebca537ec477978c5..9183e0145503f65368b4a018eeb93f9a19eb8de6 100644 (file)
@@ -110,6 +110,8 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
                        struct rsnd_dai *rdai,
                        int use_busif)
 {
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(ssi_mod);
+       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
        int ssi_id = rsnd_mod_id(ssi_mod);
 
        /*
@@ -146,10 +148,27 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
         * DMA settings for SSIU
         */
        if (use_busif) {
+               u32 val = 0x76543210;
+               u32 mask = ~0;
+
                rsnd_mod_write(ssi_mod, SSI_BUSIF_ADINR,
                               rsnd_get_adinr(ssi_mod));
                rsnd_mod_write(ssi_mod, SSI_BUSIF_MODE,  1);
                rsnd_mod_write(ssi_mod, SSI_CTRL, 0x1);
+
+               mask <<= runtime->channels * 4;
+               val = val & mask;
+
+               switch (runtime->sample_bits) {
+               case 16:
+                       val |= 0x67452301 & ~mask;
+                       break;
+               case 32:
+                       val |= 0x76543210 & ~mask;
+                       break;
+               }
+               rsnd_mod_write(ssi_mod, BUSIF_DALIGN, val);
+
        }
 
        return 0;