asoc: tegra: enable HS/HP detection for RT5639
Nikesh Oswal [Tue, 25 Jun 2013 05:29:42 +0000 (10:29 +0530)]
1. HP must be powered down when routing to speaker
   else we can get spurious interrupts for HP detection
2. Increase the current threshold to 1500uA for HS/HP
   detection

Change-Id: I81560e07ea00d03da9fc7de0586fd1e759f6dde9
Signed-off-by: Nikesh Oswal <noswal@nvidia.com>
Reviewed-on: http://git-master/r/241788
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>
Reviewed-by: Scott Peterson <speterson@nvidia.com>

sound/soc/codecs/rt5639.c
sound/soc/tegra/tegra_rt5639.c

index d7f30b0..a7ad17d 100644 (file)
@@ -452,7 +452,7 @@ int rt5639_headset_detect(struct snd_soc_codec *codec, int jack_insert)
                snd_soc_update_bits(codec, RT5639_MICBIAS,
                        RT5639_MIC1_OVCD_MASK | RT5639_MIC1_OVTH_MASK |
                        RT5639_PWR_CLK25M_MASK | RT5639_PWR_MB_MASK,
-                       RT5639_MIC1_OVCD_EN | RT5639_MIC1_OVTH_600UA |
+                       RT5639_MIC1_OVCD_EN | RT5639_MIC1_OVTH_1500UA |
                        RT5639_PWR_MB_PU | RT5639_PWR_CLK25M_PU);
                snd_soc_update_bits(codec, RT5639_DUMMY1,
                        0x1, 0x1);
@@ -1190,11 +1190,16 @@ static int spk_event(struct snd_soc_dapm_widget *w,
                        RT5639_PWR_CLS_D, RT5639_PWR_CLS_D);
                rt5639_index_update_bits(codec, 0x1c, 0xf000, 0xf000);
                //rt5639_index_write(codec,0x1c,0xfd21);
+               snd_soc_update_bits(codec, RT5639_SPK_VOL,
+                       RT5639_L_MUTE | RT5639_R_MUTE, 0);
                break;
 
        case SND_SOC_DAPM_PRE_PMD:
                printk("spk_event --SND_SOC_DAPM_POST_PMD\n");
                //rt5639_index_write(codec,0x1c,0xfd00);
+               snd_soc_update_bits(codec, RT5639_SPK_VOL,
+                       RT5639_L_MUTE | RT5639_R_MUTE,
+                       RT5639_L_MUTE | RT5639_R_MUTE);
                rt5639_index_update_bits(codec, 0x1c, 0xf000, 0x0000);
                snd_soc_update_bits(codec,RT5639_PWR_DIG1,
                        RT5639_PWR_CLS_D, 0);
@@ -1210,13 +1215,20 @@ static int spk_event(struct snd_soc_dapm_widget *w,
 static int hp_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
 {
+       struct snd_soc_codec *codec = w->codec;
+
        switch (event) {
        case SND_SOC_DAPM_POST_PMU:
                printk("hp_event --SND_SOC_DAPM_POST_PMU\n");
+               snd_soc_update_bits(codec, RT5639_HP_VOL,
+                       RT5639_L_MUTE | RT5639_R_MUTE, 0);
                break;
 
        case SND_SOC_DAPM_PRE_PMD:
                printk("hp_event --SND_SOC_DAPM_POST_PMD\n");
+               snd_soc_update_bits(codec, RT5639_HP_VOL,
+                       RT5639_L_MUTE | RT5639_R_MUTE,
+                       RT5639_L_MUTE | RT5639_R_MUTE);
                break;
 
        default:
@@ -2194,12 +2206,6 @@ static int rt5639_set_bias_level(struct snd_soc_codec *codec,
 {
        switch (level) {
        case SND_SOC_BIAS_ON:
-#ifdef RT5639_DEMO
-               snd_soc_update_bits(codec, RT5639_SPK_VOL,
-                       RT5639_L_MUTE | RT5639_R_MUTE, 0);
-               snd_soc_update_bits(codec, RT5639_HP_VOL,
-                       RT5639_L_MUTE | RT5639_R_MUTE, 0);
-#endif
                break;
 
        case SND_SOC_BIAS_PREPARE:
@@ -2223,11 +2229,6 @@ static int rt5639_set_bias_level(struct snd_soc_codec *codec,
 
        case SND_SOC_BIAS_STANDBY:
 #ifdef RT5639_DEMO
-               snd_soc_update_bits(codec, RT5639_SPK_VOL,
-                       RT5639_L_MUTE | RT5639_R_MUTE, RT5639_L_MUTE | RT5639_R_MUTE);
-               snd_soc_update_bits(codec, RT5639_HP_VOL,
-                       RT5639_L_MUTE | RT5639_R_MUTE, RT5639_L_MUTE | RT5639_R_MUTE);
-
                snd_soc_update_bits(codec, RT5639_PWR_ANLG2,
                        RT5639_PWR_MB1 | RT5639_PWR_MB2,
                        0);
@@ -2251,10 +2252,6 @@ static int rt5639_set_bias_level(struct snd_soc_codec *codec,
 
        case SND_SOC_BIAS_OFF:
 #ifdef RT5639_DEMO
-               snd_soc_update_bits(codec, RT5639_SPK_VOL,
-                       RT5639_L_MUTE | RT5639_R_MUTE, RT5639_L_MUTE | RT5639_R_MUTE);
-               snd_soc_update_bits(codec, RT5639_HP_VOL,
-                       RT5639_L_MUTE | RT5639_R_MUTE, RT5639_L_MUTE | RT5639_R_MUTE);
                snd_soc_update_bits(codec, RT5639_OUTPUT,
                        RT5639_L_MUTE | RT5639_R_MUTE, RT5639_L_MUTE | RT5639_R_MUTE);
                snd_soc_update_bits(codec, RT5639_MONO_OUT,
index ebee70c..b1e3381 100644 (file)
@@ -477,10 +477,6 @@ static int tegra_rt5639_jack_notifier(struct notifier_block *self,
                state = BIT_NO_HEADSET;
        }
 
-       /*Headset Detection not working currently for RT5639
-       so report Headphone alway*/
-       state = BIT_HEADSET_NO_MIC;
-
        switch_set_state(&tegra_rt5639_headset_switch, state);
 
        return NOTIFY_OK;