asoc: codecs: rt5639: switch codec system clock
Simon Je [Fri, 2 Aug 2013 00:59:57 +0000 (09:59 +0900)]
We need to switch the codec system clock to
internal clock only when bias level is OFF
when plugggin earjack.

Bug 1340840

Change-Id: I01ad0ccff952c1f811d24cb22fde70192753d77e
Signed-off-by: Simon Je <sje@nvidia.com>
(cherry picked from commit a438685c653c1cd79d1edb057a678276f2dc7cfe)
Reviewed-on: http://git-master/r/281660
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Scott Peterson <speterson@nvidia.com>
Reviewed-by: Gabby Lee <galee@nvidia.com>
Tested-by: Gabby Lee <galee@nvidia.com>

sound/soc/codecs/rt5639.c

index 1e8351c..2059385 100644 (file)
@@ -507,7 +507,7 @@ static void DC_Calibrate(struct snd_soc_codec *codec)
 int rt5639_headset_detect(struct snd_soc_codec *codec, int jack_insert)
 {
        int jack_type;
-       int sclk_src;
+       int sclk_src = 0;
        int reg63, reg64;
 
        if (jack_insert) {
@@ -517,11 +517,12 @@ int rt5639_headset_detect(struct snd_soc_codec *codec, int jack_insert)
                        snd_soc_write(codec, RT5639_PWR_ANLG1, 0xa814);
                        snd_soc_write(codec, RT5639_MICBIAS, 0x3830);
                        snd_soc_write(codec, RT5639_GEN_CTRL1 , 0x3701);
+                       sclk_src = snd_soc_read(codec, RT5639_GLB_CLK) &
+                               RT5639_SCLK_SRC_MASK;
+                       snd_soc_update_bits(codec, RT5639_GLB_CLK,
+                               RT5639_SCLK_SRC_MASK,
+                               0x3 << RT5639_SCLK_SRC_SFT);
                }
-               sclk_src = snd_soc_read(codec, RT5639_GLB_CLK) &
-                       RT5639_SCLK_SRC_MASK;
-               snd_soc_update_bits(codec, RT5639_GLB_CLK,
-                       RT5639_SCLK_SRC_MASK, 0x3 << RT5639_SCLK_SRC_SFT);
                snd_soc_update_bits(codec, RT5639_PWR_ANLG1,
                        RT5639_PWR_LDO2, RT5639_PWR_LDO2);
                snd_soc_update_bits(codec, RT5639_PWR_ANLG2,
@@ -548,8 +549,9 @@ int rt5639_headset_detect(struct snd_soc_codec *codec, int jack_insert)
                        jack_type = RT5639_HEADSET_DET;
                snd_soc_update_bits(codec, RT5639_IRQ_CTRL2,
                        RT5639_MB1_OC_CLR, 0);
-               snd_soc_update_bits(codec, RT5639_GLB_CLK,
-                       RT5639_SCLK_SRC_MASK, sclk_src);
+               if (SND_SOC_BIAS_OFF == codec->dapm.bias_level)
+                       snd_soc_update_bits(codec, RT5639_GLB_CLK,
+                               RT5639_SCLK_SRC_MASK, sclk_src);
                snd_soc_write(codec, RT5639_PWR_ANLG1, reg63);
                snd_soc_write(codec, RT5639_PWR_ANLG2, reg64);
        } else {