ASoC: Tegra: add api to set dam cif stere_conv field
Ravindra Lokhande [Wed, 24 Apr 2013 14:44:11 +0000 (19:44 +0530)]
Add api to change dam cif register stereo conversion field.

Bug 1266294

Change-Id: Ib6880737fca29d13149d2810f5ce26b9cd9c16c7
Signed-off-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-on: http://git-master/r/222530
Tested-by: Gilles Miet <gmiet@nvidia.com>
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>
GVS: Gerrit_Virtual_Submit

sound/soc/tegra/tegra30_dam.c
sound/soc/tegra/tegra30_dam.h
sound/soc/tegra/tegra30_i2s.c

index e936346..0b1c13f 100644 (file)
@@ -1026,6 +1026,42 @@ void tegra30_dam_enable_clip_counter(struct tegra30_dam_context *dam, int on)
        tegra30_dam_writel(dam, val, TEGRA30_DAM_CLIP);
 }
 
+int tegra30_dam_set_acif_stereo_conv(int ifc, int chtype, int conv)
+{
+       unsigned int reg;
+       unsigned int val = 0;
+
+       if (ifc >= TEGRA30_NR_DAM_IFC)
+               return -EINVAL;
+
+       if ((conv != TEGRA30_CIF_STEREOCONV_CH0) &&
+               (conv != TEGRA30_CIF_STEREOCONV_CH1) &&
+               (conv != TEGRA30_CIF_STEREOCONV_AVG))
+                       return -EINVAL;
+
+       switch (chtype) {
+       case dam_ch_out:
+               reg = TEGRA30_DAM_AUDIOCIF_OUT_CTRL;
+               break;
+       case dam_ch_in0:
+               reg = TEGRA30_DAM_AUDIOCIF_CH0_CTRL;
+               break;
+       case dam_ch_in1:
+               reg = TEGRA30_DAM_AUDIOCIF_CH1_CTRL;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       val = tegra30_dam_readl(dams_cont_info[ifc], reg);
+       val &= ~TEGRA30_CIF_STEREOCONV_MASK;
+       val |= conv;
+
+       tegra30_dam_writel(dams_cont_info[ifc], val, reg);
+
+       return 0;
+}
+
 static int tegra30_dam_probe(struct platform_device *pdev)
 {
        struct resource *res,  *region;
index 4ded54b..df3b6e5 100644 (file)
 #define TEGRA30_CIF_BIT16                              3
 #define TEGRA30_CIF_CH1                                        0
 #define TEGRA30_CIF_MONOCONV_COPY                      (1<<0)
-#define TEGRA30_CIF_STEREOCONV_CH0                     (0<<4)
+#define TEGRA30_CIF_STEREOCONV_SHIFT           4
+#define TEGRA30_CIF_STEREOCONV_MASK                    (3 << TEGRA30_CIF_STEREOCONV_SHIFT)
+#define TEGRA30_CIF_STEREOCONV_CH0                     (0 << TEGRA30_CIF_STEREOCONV_SHIFT)
+#define TEGRA30_CIF_STEREOCONV_CH1                     (1 << TEGRA30_CIF_STEREOCONV_SHIFT)
+#define TEGRA30_CIF_STEREOCONV_AVG                     (2 << TEGRA30_CIF_STEREOCONV_SHIFT)
 
 #ifndef CONFIG_ARCH_TEGRA_3x_SOC
 /* TEGRA30_DAM_CH0_BIQUAD_FIXED_COEF_0 */
@@ -185,6 +189,7 @@ int tegra30_dam_set_acif(int ifc, int chtype, unsigned int audio_channels,
        unsigned int audio_bits, unsigned int client_channels,
        unsigned int client_bits);
 void tegra30_dam_enable(int ifc, int on, int chtype);
+int tegra30_dam_set_acif_stereo_conv(int ifc, int chtype, int conv);
 #ifndef CONFIG_ARCH_TEGRA_3x_SOC
 void tegra30_dam_write_coeff_ram(int ifc, int fsin, int fsout);
 void tegra30_dam_set_farrow_param(int ifc, int fsin, int fsout);
index ccd3dd4..db5a600 100644 (file)
@@ -1143,6 +1143,10 @@ int t14x_make_voice_call_connections(struct codec_config *codec_info,
                        bb_info->rate, bb_info->sample_size, codec_info->channels,
                        codec_info->rate, codec_info->bitsize);
 
+               tegra30_dam_set_acif_stereo_conv(bb_i2s->dam_ifc,
+                               TEGRA30_DAM_CHIN0_SRC,
+                               TEGRA30_CIF_STEREOCONV_AVG);
+
                /*make ahub connections*/
 
                /*if this is the only user of i2s tx, make i2s rx connection*/