diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-05-30 08:42:29 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-06-01 14:28:58 -0400 |
commit | 2da1c4bf765cb32024e5db6fa75dab92916fa3b1 (patch) | |
tree | dbf9c6619cb1c0257398959c4a58d4b30f52b850 /sound/soc/codecs/wm8994.c | |
parent | 2d01e39b9073361317eb72b390dc2a4a3d76e192 (diff) |
ASoC: wm8994: Allow debounce before MICDET identification
For systems which do not have a jack detection feature allow some debounce
to be specified before we perform accessory identification, improving
robustness without impacting button detection responsiveness.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8994.c')
-rw-r--r-- | sound/soc/codecs/wm8994.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 5d046b1c5a7e..0f58f003dc1a 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c | |||
@@ -3660,6 +3660,8 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data) | |||
3660 | 3660 | ||
3661 | pm_runtime_get_sync(codec->dev); | 3661 | pm_runtime_get_sync(codec->dev); |
3662 | 3662 | ||
3663 | cancel_delayed_work_sync(&wm8994->mic_complete_work); | ||
3664 | |||
3663 | mutex_lock(&wm8994->accdet_lock); | 3665 | mutex_lock(&wm8994->accdet_lock); |
3664 | 3666 | ||
3665 | reg = snd_soc_read(codec, WM1811_JACKDET_CTRL); | 3667 | reg = snd_soc_read(codec, WM1811_JACKDET_CTRL); |
@@ -3842,11 +3844,33 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, | |||
3842 | } | 3844 | } |
3843 | EXPORT_SYMBOL_GPL(wm8958_mic_detect); | 3845 | EXPORT_SYMBOL_GPL(wm8958_mic_detect); |
3844 | 3846 | ||
3847 | static void wm8958_mic_work(struct work_struct *work) | ||
3848 | { | ||
3849 | struct wm8994_priv *wm8994 = container_of(work, | ||
3850 | struct wm8994_priv, | ||
3851 | mic_complete_work.work); | ||
3852 | struct snd_soc_codec *codec = wm8994->hubs.codec; | ||
3853 | |||
3854 | dev_crit(codec->dev, "MIC WORK %x\n", wm8994->mic_status); | ||
3855 | |||
3856 | pm_runtime_get_sync(codec->dev); | ||
3857 | |||
3858 | mutex_lock(&wm8994->accdet_lock); | ||
3859 | |||
3860 | wm8994->mic_id_cb(wm8994->mic_id_cb_data, wm8994->mic_status); | ||
3861 | |||
3862 | mutex_unlock(&wm8994->accdet_lock); | ||
3863 | |||
3864 | pm_runtime_put(codec->dev); | ||
3865 | |||
3866 | dev_crit(codec->dev, "MIC WORK %x DONE\n", wm8994->mic_status); | ||
3867 | } | ||
3868 | |||
3845 | static irqreturn_t wm8958_mic_irq(int irq, void *data) | 3869 | static irqreturn_t wm8958_mic_irq(int irq, void *data) |
3846 | { | 3870 | { |
3847 | struct wm8994_priv *wm8994 = data; | 3871 | struct wm8994_priv *wm8994 = data; |
3848 | struct snd_soc_codec *codec = wm8994->hubs.codec; | 3872 | struct snd_soc_codec *codec = wm8994->hubs.codec; |
3849 | int reg, count, ret; | 3873 | int reg, count, ret, id_delay; |
3850 | 3874 | ||
3851 | /* | 3875 | /* |
3852 | * Jack detection may have detected a removal simulataneously | 3876 | * Jack detection may have detected a removal simulataneously |
@@ -3856,6 +3880,7 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data) | |||
3856 | if (!(snd_soc_read(codec, WM8958_MIC_DETECT_1) & WM8958_MICD_ENA)) | 3880 | if (!(snd_soc_read(codec, WM8958_MIC_DETECT_1) & WM8958_MICD_ENA)) |
3857 | return IRQ_HANDLED; | 3881 | return IRQ_HANDLED; |
3858 | 3882 | ||
3883 | cancel_delayed_work_sync(&wm8994->mic_complete_work); | ||
3859 | cancel_delayed_work_sync(&wm8994->open_circuit_work); | 3884 | cancel_delayed_work_sync(&wm8994->open_circuit_work); |
3860 | 3885 | ||
3861 | pm_runtime_get_sync(codec->dev); | 3886 | pm_runtime_get_sync(codec->dev); |
@@ -3904,8 +3929,12 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data) | |||
3904 | } | 3929 | } |
3905 | } | 3930 | } |
3906 | 3931 | ||
3932 | wm8994->mic_status = reg; | ||
3933 | id_delay = wm8994->wm8994->pdata.mic_id_delay; | ||
3934 | |||
3907 | if (wm8994->mic_detecting) | 3935 | if (wm8994->mic_detecting) |
3908 | wm8994->mic_id_cb(wm8994->mic_id_cb_data, reg); | 3936 | schedule_delayed_work(&wm8994->mic_complete_work, |
3937 | msecs_to_jiffies(id_delay)); | ||
3909 | else | 3938 | else |
3910 | wm8958_button_det(codec, reg); | 3939 | wm8958_button_det(codec, reg); |
3911 | 3940 | ||
@@ -3971,6 +4000,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) | |||
3971 | break; | 4000 | break; |
3972 | } | 4001 | } |
3973 | 4002 | ||
4003 | INIT_DELAYED_WORK(&wm8994->mic_complete_work, wm8958_mic_work); | ||
4004 | |||
3974 | for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) | 4005 | for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) |
3975 | init_completion(&wm8994->fll_locked[i]); | 4006 | init_completion(&wm8994->fll_locked[i]); |
3976 | 4007 | ||