aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2015-07-16 01:42:33 -0400
committerMark Brown <broonie@kernel.org>2015-07-16 08:10:46 -0400
commitb14c917409f47dbfdff93e69effd6740f6a809f7 (patch)
treeac1b28b5f434035ab10fa00f2e41073e418aba79
parentf312bc59d21bed7593199a1921468868150954fa (diff)
ASoC: rt5645: Update dapm pins when the card is not instantiated yet
This makes sure the dapm state is consistent when the card is instantiated. However, if the card is not instantiated yet, we still update the registers manually in the "jack in" case, so that we can immediately report if a mic is present or not. Disabling "Mic Det Power" after detection, and on jack out, can wait until the card gets instantiated. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/rt5645.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 8693a25830d3..33d1aff38d5f 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -2805,12 +2805,11 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
2805 if (jack_insert) { 2805 if (jack_insert) {
2806 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0006); 2806 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0006);
2807 2807
2808 if (codec->component.card->instantiated) { 2808 /* for jack type detect */
2809 /* for jack type detect */ 2809 snd_soc_dapm_force_enable_pin(dapm, "LDO2");
2810 snd_soc_dapm_force_enable_pin(dapm, "LDO2"); 2810 snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power");
2811 snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); 2811 snd_soc_dapm_sync(dapm);
2812 snd_soc_dapm_sync(dapm); 2812 if (!dapm->card->instantiated) {
2813 } else {
2814 /* Power up necessary bits for JD if dapm is 2813 /* Power up necessary bits for JD if dapm is
2815 not ready yet */ 2814 not ready yet */
2816 regmap_update_bits(rt5645->regmap, RT5645_PWR_ANLG1, 2815 regmap_update_bits(rt5645->regmap, RT5645_PWR_ANLG1,
@@ -2841,12 +2840,8 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
2841 rt5645_enable_push_button_irq(codec, true); 2840 rt5645_enable_push_button_irq(codec, true);
2842 } 2841 }
2843 } else { 2842 } else {
2844 if (codec->component.card->instantiated) { 2843 snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
2845 snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); 2844 snd_soc_dapm_sync(dapm);
2846 snd_soc_dapm_sync(dapm);
2847 } else
2848 regmap_update_bits(rt5645->regmap,
2849 RT5645_PWR_VOL, RT5645_PWR_MIC_DET, 0);
2850 rt5645->jack_type = SND_JACK_HEADPHONE; 2845 rt5645->jack_type = SND_JACK_HEADPHONE;
2851 } 2846 }
2852 2847
@@ -2855,19 +2850,10 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
2855 if (rt5645->en_button_func) 2850 if (rt5645->en_button_func)
2856 rt5645_enable_push_button_irq(codec, false); 2851 rt5645_enable_push_button_irq(codec, false);
2857 else { 2852 else {
2858 if (codec->component.card->instantiated) { 2853 if (rt5645->pdata.jd_mode == 0)
2859 if (rt5645->pdata.jd_mode == 0) 2854 snd_soc_dapm_disable_pin(dapm, "LDO2");
2860 snd_soc_dapm_disable_pin(dapm, "LDO2"); 2855 snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
2861 snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); 2856 snd_soc_dapm_sync(dapm);
2862 snd_soc_dapm_sync(dapm);
2863 } else {
2864 if (rt5645->pdata.jd_mode == 0)
2865 regmap_update_bits(rt5645->regmap,
2866 RT5645_PWR_MIXER,
2867 RT5645_PWR_LDO2, 0);
2868 regmap_update_bits(rt5645->regmap,
2869 RT5645_PWR_VOL, RT5645_PWR_MIC_DET, 0);
2870 }
2871 } 2857 }
2872 } 2858 }
2873 2859