diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-09 14:20:59 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-09 14:32:43 -0400 |
commit | e9b54de420bfdd335d66c90b4d68e894677db668 (patch) | |
tree | 8077bd844b8c51f2a8bbffec680072f60c20936f /sound/soc | |
parent | cbd71f304a86f0c8a545220967687f02054edea0 (diff) |
ASoC: wm8994: Add debounce to wm8994 mic detection
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/wm8994.c | 27 | ||||
-rw-r--r-- | sound/soc/codecs/wm8994.h | 2 |
2 files changed, 22 insertions, 7 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 98e462cbec73..54512880e191 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c | |||
@@ -3059,22 +3059,20 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, | |||
3059 | } | 3059 | } |
3060 | EXPORT_SYMBOL_GPL(wm8994_mic_detect); | 3060 | EXPORT_SYMBOL_GPL(wm8994_mic_detect); |
3061 | 3061 | ||
3062 | static irqreturn_t wm8994_mic_irq(int irq, void *data) | 3062 | static void wm8994_mic_work(struct work_struct *work) |
3063 | { | 3063 | { |
3064 | struct wm8994_priv *priv = data; | 3064 | struct wm8994_priv *priv = container_of(work, |
3065 | struct wm8994_priv, | ||
3066 | mic_work.work); | ||
3065 | struct snd_soc_codec *codec = priv->codec; | 3067 | struct snd_soc_codec *codec = priv->codec; |
3066 | int reg; | 3068 | int reg; |
3067 | int report; | 3069 | int report; |
3068 | 3070 | ||
3069 | #ifndef CONFIG_SND_SOC_WM8994_MODULE | ||
3070 | trace_snd_soc_jack_irq(dev_name(codec->dev)); | ||
3071 | #endif | ||
3072 | |||
3073 | reg = snd_soc_read(codec, WM8994_INTERRUPT_RAW_STATUS_2); | 3071 | reg = snd_soc_read(codec, WM8994_INTERRUPT_RAW_STATUS_2); |
3074 | if (reg < 0) { | 3072 | if (reg < 0) { |
3075 | dev_err(codec->dev, "Failed to read microphone status: %d\n", | 3073 | dev_err(codec->dev, "Failed to read microphone status: %d\n", |
3076 | reg); | 3074 | reg); |
3077 | return IRQ_HANDLED; | 3075 | return; |
3078 | } | 3076 | } |
3079 | 3077 | ||
3080 | dev_dbg(codec->dev, "Microphone status: %x\n", reg); | 3078 | dev_dbg(codec->dev, "Microphone status: %x\n", reg); |
@@ -3116,6 +3114,20 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data) | |||
3116 | 3114 | ||
3117 | snd_soc_jack_report(priv->micdet[1].jack, report, | 3115 | snd_soc_jack_report(priv->micdet[1].jack, report, |
3118 | SND_JACK_HEADSET | SND_JACK_BTN_0); | 3116 | SND_JACK_HEADSET | SND_JACK_BTN_0); |
3117 | } | ||
3118 | |||
3119 | static irqreturn_t wm8994_mic_irq(int irq, void *data) | ||
3120 | { | ||
3121 | struct wm8994_priv *priv = data; | ||
3122 | struct snd_soc_codec *codec = priv->codec; | ||
3123 | |||
3124 | #ifndef CONFIG_SND_SOC_WM8994_MODULE | ||
3125 | trace_snd_soc_jack_irq(dev_name(codec->dev)); | ||
3126 | #endif | ||
3127 | |||
3128 | pm_wakeup_event(codec->dev, 300); | ||
3129 | |||
3130 | schedule_delayed_work(&priv->mic_work, msecs_to_jiffies(250)); | ||
3119 | 3131 | ||
3120 | return IRQ_HANDLED; | 3132 | return IRQ_HANDLED; |
3121 | } | 3133 | } |
@@ -3488,6 +3500,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) | |||
3488 | wm8994->codec = codec; | 3500 | wm8994->codec = codec; |
3489 | 3501 | ||
3490 | mutex_init(&wm8994->accdet_lock); | 3502 | mutex_init(&wm8994->accdet_lock); |
3503 | INIT_DELAYED_WORK(&wm8994->mic_work, wm8994_mic_work); | ||
3491 | 3504 | ||
3492 | for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) | 3505 | for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) |
3493 | init_completion(&wm8994->fll_locked[i]); | 3506 | init_completion(&wm8994->fll_locked[i]); |
diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h index 91650bba205e..d77e06f0a675 100644 --- a/sound/soc/codecs/wm8994.h +++ b/sound/soc/codecs/wm8994.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <sound/soc.h> | 12 | #include <sound/soc.h> |
13 | #include <linux/firmware.h> | 13 | #include <linux/firmware.h> |
14 | #include <linux/completion.h> | 14 | #include <linux/completion.h> |
15 | #include <linux/workqueue.h> | ||
15 | 16 | ||
16 | #include "wm_hubs.h" | 17 | #include "wm_hubs.h" |
17 | 18 | ||
@@ -127,6 +128,7 @@ struct wm8994_priv { | |||
127 | 128 | ||
128 | struct mutex accdet_lock; | 129 | struct mutex accdet_lock; |
129 | struct wm8994_micdet micdet[2]; | 130 | struct wm8994_micdet micdet[2]; |
131 | struct delayed_work mic_work; | ||
130 | bool mic_detecting; | 132 | bool mic_detecting; |
131 | bool jack_mic; | 133 | bool jack_mic; |
132 | int btn_mask; | 134 | int btn_mask; |