Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 293502
b: refs/heads/master
c: c986564
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Mar 12, 2012
1 parent afd2367 commit 062676f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 80f48143ffde97c48c5e550e2fcd2c9f8e77e554
refs/heads/master: c986564b3115ebd24a907515ac0b7ca2bef794f9
69 changes: 34 additions & 35 deletions trunk/sound/soc/codecs/wm8994.c
Original file line number Diff line number Diff line change
Expand Up @@ -3166,19 +3166,23 @@ static void wm8958_default_micdet(u16 status, void *data)

/* If we have jackdet that will detect removal */
if (wm8994->jackdet) {
mutex_lock(&wm8994->accdet_lock);

snd_soc_update_bits(codec, WM8958_MIC_DETECT_1,
WM8958_MICD_ENA, 0);

wm1811_jackdet_set_mode(codec,
WM1811_JACKDET_MODE_JACK);

mutex_unlock(&wm8994->accdet_lock);

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);
}

wm1811_jackdet_set_mode(codec,
WM1811_JACKDET_MODE_JACK);
}
}

Expand Down Expand Up @@ -3213,6 +3217,7 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
struct wm8994_priv *wm8994 = data;
struct snd_soc_codec *codec = wm8994->codec;
int reg;
bool present;

mutex_lock(&wm8994->accdet_lock);

Expand All @@ -3225,11 +3230,10 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)

dev_dbg(codec->dev, "JACKDET %x\n", reg);

if (reg & WM1811_JACKDET_LVL) {
dev_dbg(codec->dev, "Jack detected\n");
present = reg & WM1811_JACKDET_LVL;

snd_soc_jack_report(wm8994->micdet[0].jack,
SND_JACK_MECHANICAL, SND_JACK_MECHANICAL);
if (present) {
dev_dbg(codec->dev, "Jack detected\n");

snd_soc_update_bits(codec, WM8958_MICBIAS2,
WM8958_MICB2_DISCH, 0);
Expand All @@ -3247,32 +3251,12 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)

snd_soc_update_bits(codec, WM8958_MIC_DETECT_1,
WM8958_MICD_ENA, WM8958_MICD_ENA);

/* 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);
}
} else {
dev_dbg(codec->dev, "Jack not detected\n");

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);

/* Enable debounce while removed */
snd_soc_update_bits(codec, WM1811_JACKDET_CTRL,
WM1811_JACKDET_DB, WM1811_JACKDET_DB);
Expand All @@ -3286,6 +3270,28 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)

mutex_unlock(&wm8994->accdet_lock);

/* If required for an external cap force MICBIAS on */
if (wm8994->pdata->jd_ext_cap) {
mutex_lock(&codec->mutex);

if (present)
snd_soc_dapm_force_enable_pin(&codec->dapm,
"MICBIAS2");
else
snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS2");

snd_soc_dapm_sync(&codec->dapm);
mutex_unlock(&codec->mutex);
}

if (present)
snd_soc_jack_report(wm8994->micdet[0].jack,
SND_JACK_MECHANICAL, SND_JACK_MECHANICAL);
else
snd_soc_jack_report(wm8994->micdet[0].jack, 0,
SND_JACK_MECHANICAL | SND_JACK_HEADSET |
wm8994->btn_mask);

return IRQ_HANDLED;
}

Expand Down Expand Up @@ -3389,17 +3395,13 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
struct snd_soc_codec *codec = wm8994->codec;
int reg, count;

mutex_lock(&wm8994->accdet_lock);

/*
* Jack detection may have detected a removal simulataneously
* with an update of the MICDET status; if so it will have
* stopped detection and we can ignore this interrupt.
*/
if (!(snd_soc_read(codec, WM8958_MIC_DETECT_1) & WM8958_MICD_ENA)) {
mutex_unlock(&wm8994->accdet_lock);
if (!(snd_soc_read(codec, WM8958_MIC_DETECT_1) & WM8958_MICD_ENA))
return IRQ_HANDLED;
}

/* We may occasionally read a detection without an impedence
* range being provided - if that happens loop again.
Expand All @@ -3408,7 +3410,6 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
do {
reg = snd_soc_read(codec, WM8958_MIC_DETECT_3);
if (reg < 0) {
mutex_unlock(&wm8994->accdet_lock);
dev_err(codec->dev,
"Failed to read mic detect status: %d\n",
reg);
Expand Down Expand Up @@ -3439,8 +3440,6 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
dev_warn(codec->dev, "Accessory detection with no callback\n");

out:
mutex_unlock(&wm8994->accdet_lock);

return IRQ_HANDLED;
}

Expand Down

0 comments on commit 062676f

Please sign in to comment.