]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
ASoC: wm8994: Support external capacitors on MICBIAS2 with jack detection
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 21 Feb 2012 16:23:35 +0000 (16:23 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 21 Feb 2012 16:49:53 +0000 (16:49 +0000)
When an external capacitor is connected to MICBIAS2 on devices with
jack detection (which is not required but may be done in some systems)
then the loading may mean that better performance is obtained when
the microphone bias is enabled normally rather than using the low power
mode. Provide platform data allowing systems to indicate if they require
this.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
include/linux/mfd/wm8994/pdata.h
sound/soc/codecs/wm8994.c

index 3fb1f407d5e6e36cf0c9cff31d222bff0258b91f..dc3e050116898457e410b4cbc0c14f2cb6c81171 100644 (file)
@@ -185,6 +185,9 @@ struct wm8994_pdata {
         unsigned int jd_scthr:2;
         unsigned int jd_thr:2;
 
+       /* Configure WM1811 jack detection for use with external capacitor */
+       unsigned int jd_ext_cap:1;
+
        /* WM8958 microphone bias configuration */
        int micbias[2];
 
index 77085c1047d59050fccad58c9e4702be6ca6ef34..0b1c271468af7ac0b806cd2d079496eeb30fe3a8 100644 (file)
@@ -3172,6 +3172,14 @@ static void wm8958_default_micdet(u16 status, void *data)
 
                        wm1811_jackdet_set_mode(codec,
                                                WM1811_JACKDET_MODE_JACK);
+
+                       if (wm8994->pdata->jd_ext_cap) {
+                               mutex_lock(&codec->mutex);
+                               snd_soc_dapm_disable_pin(&codec->dapm,
+                                                        "MICBIAS2");
+                               snd_soc_dapm_sync(&codec->dapm);
+                               mutex_unlock(&codec->mutex);
+                       }
                }
        }
 
@@ -3227,6 +3235,15 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
                snd_soc_update_bits(codec, WM8958_MICBIAS2,
                                    WM8958_MICB2_DISCH, 0);
 
+               /* If required for an external cap force MICBIAS on */
+               if (wm8994->pdata->jd_ext_cap) {
+                       mutex_lock(&codec->mutex);
+                       snd_soc_dapm_force_enable_pin(&codec->dapm,
+                                                     "MICBIAS2");
+                       snd_soc_dapm_sync(&codec->dapm);
+                       mutex_unlock(&codec->mutex);
+               }
+
                /*
                 * Start off measument of microphone impedence to find
                 * out what's actually there.
@@ -3241,6 +3258,13 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
                snd_soc_update_bits(codec, WM8958_MICBIAS2,
                                    WM8958_MICB2_DISCH, WM8958_MICB2_DISCH);
 
+               if (wm8994->pdata->jd_ext_cap) {
+                       mutex_lock(&codec->mutex);
+                       snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS2");
+                       snd_soc_dapm_sync(&codec->dapm);
+                       mutex_unlock(&codec->mutex);
+               }
+
                snd_soc_jack_report(wm8994->micdet[0].jack, 0,
                                    SND_JACK_MECHANICAL | SND_JACK_HEADSET |
                                    wm8994->btn_mask);