asoc: tegra: aic326x machine: configure codec as master for voice call
Nikesh Oswal [Mon, 13 Feb 2012 06:39:43 +0000 (22:39 -0800)]
Change-Id: I970ab858399113e4ea0d079779a2cb368af90850
Signed-off-by: Nikesh Oswal <noswal@nvidia.com>
Reviewed-on: http://git-master/r/84539
Reviewed-by: Scott Peterson <speterson@nvidia.com>

Rebase-Id: R3d1ecd834247900490b70767273676bcd0e71e46

sound/soc/tegra/tegra_aic326x.c

index f9a9257..f751ee7 100644 (file)
@@ -520,14 +520,13 @@ static int tegra_aic326x_voice_call_hw_params(
        struct snd_soc_card *card = codec->card;
        struct tegra_aic326x *machine = snd_soc_card_get_drvdata(card);
        int srate, mclk;
-       int err;
+       int err, pcmdiv, vxclkdiv;;
 
        srate = params_rate(params);
        mclk = tegra_aic326x_get_mclk(srate);
        if (mclk < 0)
                return mclk;
 
-
        err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk);
        if (err < 0) {
                if (!(machine->util_data.set_mclk % mclk))
@@ -541,9 +540,9 @@ static int tegra_aic326x_voice_call_hw_params(
        tegra_asoc_utils_lock_clk_rate(&machine->util_data, 1);
 
        err = snd_soc_dai_set_fmt(codec_dai,
-                                       SND_SOC_DAIFMT_DSP_B |
+                                       SND_SOC_DAIFMT_DSP_A |
                                        SND_SOC_DAIFMT_NB_NF |
-                                       SND_SOC_DAIFMT_CBS_CFS);
+                                       SND_SOC_DAIFMT_CBM_CFM);
        if (err < 0) {
                dev_err(card->dev, "codec_dai fmt not set\n");
                return err;
@@ -556,6 +555,24 @@ static int tegra_aic326x_voice_call_hw_params(
                return err;
        }
 
+       if (params_rate(params) == 8000) {
+               /* Change these Settings for 8KHz*/
+               pcmdiv = 1;
+               /* BB expecting 2048Khz bclk */
+               vxclkdiv = 27;
+       } else if (params_rate(params) == 16000) {
+               pcmdiv = 1;
+               /* BB expecting 2048Khz bclk */
+               vxclkdiv = 27;
+       } else {
+               dev_err(card->dev, "codec_dai unsupported voice rate\n");
+               return -EINVAL;
+       }
+
+       //snd_soc_dai_set_clkdiv(codec_dai, ASI2_BCLK_N, vxclkdiv);
+       //snd_soc_dai_set_clkdiv(codec_dai, ASI2_WCLK_N, pcmdiv);
+
+
 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
        /* codec configuration */
        machine->codec_info[HIFI_CODEC].rate = params_rate(params);
@@ -1045,6 +1062,7 @@ static __devinit int tegra_aic326x_driver_probe(struct platform_device *pdev)
        tegra_aic326x_i2s_dai_name[machine->codec_info[BT_SCO].i2s_id];
 #endif
 
+
 #ifdef CONFIG_SWITCH
        /* Add h2w switch class support */
        ret = switch_dev_register(&aic326x_wired_switch_dev);