aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8994.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-10-01 11:41:09 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-03 02:34:06 -0500
commitf02b0de0f0925ea6dd1c5eee0a9e7748e38af4e6 (patch)
treedcbebe5d022e972e334fb7bf28c9d7cd65dfd546 /sound/soc/codecs/wm8994.c
parent72222be39afbd39c16eb180646b0ac44bb1ba460 (diff)
ASoC: wm8994: Stop mic detection whenever we detect an open circuit
Jack detection will not do anything to help us detect a microphone when there is a fault in the cable and the debounce we have is enough to avoid getting an intermediate result so halt microphone detection when we detect that one is not present. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8994.c')
-rw-r--r--sound/soc/codecs/wm8994.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index ea504e24269f..4b4d58d3875e 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -3389,6 +3389,26 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data)
3389 return IRQ_HANDLED; 3389 return IRQ_HANDLED;
3390} 3390}
3391 3391
3392static void wm1811_micd_stop(struct snd_soc_codec *codec)
3393{
3394 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3395
3396 if (!wm8994->jackdet)
3397 return;
3398
3399 mutex_lock(&wm8994->accdet_lock);
3400
3401 snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0);
3402
3403 wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_JACK);
3404
3405 mutex_unlock(&wm8994->accdet_lock);
3406
3407 if (wm8994->wm8994->pdata.jd_ext_cap)
3408 snd_soc_dapm_disable_pin(&codec->dapm,
3409 "MICBIAS2");
3410}
3411
3392/* Default microphone detection handler for WM8958 - the user can 3412/* Default microphone detection handler for WM8958 - the user can
3393 * override this if they wish. 3413 * override this if they wish.
3394 */ 3414 */
@@ -3402,18 +3422,18 @@ static void wm8958_default_micdet(u16 status, void *data)
3402 3422
3403 /* Either nothing present or just starting detection */ 3423 /* Either nothing present or just starting detection */
3404 if (!(status & WM8958_MICD_STS)) { 3424 if (!(status & WM8958_MICD_STS)) {
3405 if (!wm8994->jackdet) { 3425 /* If nothing present then clear our statuses */
3406 /* If nothing present then clear our statuses */ 3426 dev_dbg(codec->dev, "Detected open circuit\n");
3407 dev_dbg(codec->dev, "Detected open circuit\n"); 3427 wm8994->jack_mic = false;
3408 wm8994->jack_mic = false; 3428 wm8994->mic_detecting = true;
3409 wm8994->mic_detecting = true;
3410 3429
3411 wm8958_micd_set_rate(codec); 3430 wm1811_micd_stop(codec);
3412 3431
3413 snd_soc_jack_report(wm8994->micdet[0].jack, 0, 3432 wm8958_micd_set_rate(codec);
3414 wm8994->btn_mask | 3433
3415 SND_JACK_HEADSET); 3434 snd_soc_jack_report(wm8994->micdet[0].jack, 0,
3416 } 3435 wm8994->btn_mask |
3436 SND_JACK_HEADSET);
3417 return; 3437 return;
3418 } 3438 }
3419 3439
@@ -3440,21 +3460,7 @@ static void wm8958_default_micdet(u16 status, void *data)
3440 wm8958_micd_set_rate(codec); 3460 wm8958_micd_set_rate(codec);
3441 3461
3442 /* If we have jackdet that will detect removal */ 3462 /* If we have jackdet that will detect removal */
3443 if (wm8994->jackdet) { 3463 wm1811_micd_stop(codec);
3444 mutex_lock(&wm8994->accdet_lock);
3445
3446 snd_soc_update_bits(codec, WM8958_MIC_DETECT_1,
3447 WM8958_MICD_ENA, 0);
3448
3449 wm1811_jackdet_set_mode(codec,
3450 WM1811_JACKDET_MODE_JACK);
3451
3452 mutex_unlock(&wm8994->accdet_lock);
3453
3454 if (wm8994->wm8994->pdata.jd_ext_cap)
3455 snd_soc_dapm_disable_pin(&codec->dapm,
3456 "MICBIAS2");
3457 }
3458 3464
3459 snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADPHONE, 3465 snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADPHONE,
3460 SND_JACK_HEADSET); 3466 SND_JACK_HEADSET);