aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-03-03 20:02:49 +0000
committerAndreas Blaesius <skate4life@gmx.de>2016-04-30 11:03:54 +0200
commit7f5fce040e42b2008207aa205008f15463c16fa5 (patch)
treed2bc807af77de78c78636052efac69bfd1a81954 /sound
parentfdfe8e67f9d42f85ee811759f668eed0024b4358 (diff)
downloadkernel_samsung_espresso10-7f5fce040e42b2008207aa205008f15463c16fa5.zip
kernel_samsung_espresso10-7f5fce040e42b2008207aa205008f15463c16fa5.tar.gz
kernel_samsung_espresso10-7f5fce040e42b2008207aa205008f15463c16fa5.tar.bz2
ASoC: wm8994: Factor out WM1811A detection mode setting
Push everything through one function for active use cases, should be no practical effect. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/wm8994.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 4c1973c..4372214 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -784,6 +784,8 @@ SOC_SINGLE_TLV("MIXINL IN1RP Boost Volume", WM8994_INPUT_MIXER_1, 8, 1, 0,
static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode)
{
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
+ u16 old = snd_soc_read(codec, WM8994_ANTIPOP_2)
+ & WM1811_JACKDET_MODE_MASK;
if (!wm8994->jackdet || !wm8994->jack_cb)
return;
@@ -791,11 +793,28 @@ static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode)
if (wm8994->active_refcount)
mode = WM1811_JACKDET_MODE_AUDIO;
+ if (mode == old)
+ return;
+
snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
WM1811_JACKDET_MODE_MASK, mode);
- if (mode == WM1811_JACKDET_MODE_MIC)
- msleep(2);
+ switch (mode) {
+ case WM1811_JACKDET_MODE_MIC:
+ case WM1811_JACKDET_MODE_AUDIO:
+ switch (old) {
+ case WM1811_JACKDET_MODE_MIC:
+ case WM1811_JACKDET_MODE_AUDIO:
+ break;
+ default:
+ msleep(2);
+ break;
+ }
+
+ default:
+ break;
+ }
+
}
static void active_reference(struct snd_soc_codec *codec)
@@ -809,15 +828,8 @@ static void active_reference(struct snd_soc_codec *codec)
dev_dbg(codec->dev, "Active refcount incremented, now %d\n",
wm8994->active_refcount);
- if (wm8994->active_refcount == 1) {
- /* If we're using jack detection go into audio mode */
- if (wm8994->jackdet && wm8994->jack_cb) {
- snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
- WM1811_JACKDET_MODE_MASK,
- WM1811_JACKDET_MODE_AUDIO);
- msleep(2);
- }
- }
+ /* If we're using jack detection go into audio mode */
+ wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_AUDIO);
mutex_unlock(&wm8994->accdet_lock);
}
@@ -836,16 +848,12 @@ static void active_dereference(struct snd_soc_codec *codec)
if (wm8994->active_refcount == 0) {
/* Go into appropriate detection only mode */
- if (wm8994->jackdet && wm8994->jack_cb) {
- if (wm8994->jack_mic || wm8994->mic_detecting)
- mode = WM1811_JACKDET_MODE_MIC;
- else
- mode = WM1811_JACKDET_MODE_JACK;
+ if (wm8994->jack_mic || wm8994->mic_detecting)
+ mode = WM1811_JACKDET_MODE_MIC;
+ else
+ mode = WM1811_JACKDET_MODE_JACK;
- snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
- WM1811_JACKDET_MODE_MASK,
- mode);
- }
+ wm1811_jackdet_set_mode(codec, mode);
}
mutex_unlock(&wm8994->accdet_lock);