diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-03-03 21:16:01 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-03-05 19:05:24 -0500 |
commit | 4752a887190ff38175be47aae26a821e8941b96e (patch) | |
tree | 581377138a993781000857e16b8c5d05bf1a3af4 /sound/soc/codecs/wm8994.c | |
parent | 56cea3f1e7db0ccde9e2ac66df2f920c73c419ef (diff) |
ASoC: wm8994: Use audio mode for jack detection when system is active
When we are out of system sleep always use audio mode for jack detection
in order to avoid potential performance issues handing off between modes.
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 | 77 |
1 files changed, 48 insertions, 29 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 2417ef9316ed..bc12d097ef0d 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c | |||
@@ -685,8 +685,6 @@ SOC_SINGLE_TLV("MIXINL IN1RP Boost Volume", WM8994_INPUT_MIXER_1, 8, 1, 0, | |||
685 | static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode) | 685 | static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode) |
686 | { | 686 | { |
687 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 687 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
688 | u16 old = snd_soc_read(codec, WM8994_ANTIPOP_2) | ||
689 | & WM1811_JACKDET_MODE_MASK; | ||
690 | 688 | ||
691 | if (!wm8994->jackdet || !wm8994->jack_cb) | 689 | if (!wm8994->jackdet || !wm8994->jack_cb) |
692 | return; | 690 | return; |
@@ -694,28 +692,17 @@ static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode) | |||
694 | if (wm8994->active_refcount) | 692 | if (wm8994->active_refcount) |
695 | mode = WM1811_JACKDET_MODE_AUDIO; | 693 | mode = WM1811_JACKDET_MODE_AUDIO; |
696 | 694 | ||
697 | if (mode == old) | 695 | if (mode == wm8994->jackdet_mode) |
698 | return; | 696 | return; |
699 | 697 | ||
700 | snd_soc_update_bits(codec, WM8994_ANTIPOP_2, | 698 | wm8994->jackdet_mode = mode; |
701 | WM1811_JACKDET_MODE_MASK, mode); | ||
702 | |||
703 | switch (mode) { | ||
704 | case WM1811_JACKDET_MODE_MIC: | ||
705 | case WM1811_JACKDET_MODE_AUDIO: | ||
706 | switch (old) { | ||
707 | case WM1811_JACKDET_MODE_MIC: | ||
708 | case WM1811_JACKDET_MODE_AUDIO: | ||
709 | break; | ||
710 | default: | ||
711 | msleep(2); | ||
712 | break; | ||
713 | } | ||
714 | 699 | ||
715 | default: | 700 | /* Always use audio mode to detect while the system is active */ |
716 | break; | 701 | if (mode != WM1811_JACKDET_MODE_NONE) |
717 | } | 702 | mode = WM1811_JACKDET_MODE_AUDIO; |
718 | 703 | ||
704 | snd_soc_update_bits(codec, WM8994_ANTIPOP_2, | ||
705 | WM1811_JACKDET_MODE_MASK, mode); | ||
719 | } | 706 | } |
720 | 707 | ||
721 | static void active_reference(struct snd_soc_codec *codec) | 708 | static void active_reference(struct snd_soc_codec *codec) |
@@ -2749,7 +2736,7 @@ static struct snd_soc_dai_driver wm8994_dai[] = { | |||
2749 | }; | 2736 | }; |
2750 | 2737 | ||
2751 | #ifdef CONFIG_PM | 2738 | #ifdef CONFIG_PM |
2752 | static int wm8994_suspend(struct snd_soc_codec *codec) | 2739 | static int wm8994_codec_suspend(struct snd_soc_codec *codec) |
2753 | { | 2740 | { |
2754 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 2741 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
2755 | struct wm8994 *control = wm8994->wm8994; | 2742 | struct wm8994 *control = wm8994->wm8994; |
@@ -2783,7 +2770,7 @@ static int wm8994_suspend(struct snd_soc_codec *codec) | |||
2783 | return 0; | 2770 | return 0; |
2784 | } | 2771 | } |
2785 | 2772 | ||
2786 | static int wm8994_resume(struct snd_soc_codec *codec) | 2773 | static int wm8994_codec_resume(struct snd_soc_codec *codec) |
2787 | { | 2774 | { |
2788 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 2775 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
2789 | struct wm8994 *control = wm8994->wm8994; | 2776 | struct wm8994 *control = wm8994->wm8994; |
@@ -2842,8 +2829,8 @@ static int wm8994_resume(struct snd_soc_codec *codec) | |||
2842 | return 0; | 2829 | return 0; |
2843 | } | 2830 | } |
2844 | #else | 2831 | #else |
2845 | #define wm8994_suspend NULL | 2832 | #define wm8994_codec_suspend NULL |
2846 | #define wm8994_resume NULL | 2833 | #define wm8994_codec_resume NULL |
2847 | #endif | 2834 | #endif |
2848 | 2835 | ||
2849 | static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994) | 2836 | static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994) |
@@ -3955,8 +3942,8 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) | |||
3955 | static struct snd_soc_codec_driver soc_codec_dev_wm8994 = { | 3942 | static struct snd_soc_codec_driver soc_codec_dev_wm8994 = { |
3956 | .probe = wm8994_codec_probe, | 3943 | .probe = wm8994_codec_probe, |
3957 | .remove = wm8994_codec_remove, | 3944 | .remove = wm8994_codec_remove, |
3958 | .suspend = wm8994_suspend, | 3945 | .suspend = wm8994_codec_suspend, |
3959 | .resume = wm8994_resume, | 3946 | .resume = wm8994_codec_resume, |
3960 | .set_bias_level = wm8994_set_bias_level, | 3947 | .set_bias_level = wm8994_set_bias_level, |
3961 | }; | 3948 | }; |
3962 | 3949 | ||
@@ -3983,11 +3970,43 @@ static int __devexit wm8994_remove(struct platform_device *pdev) | |||
3983 | return 0; | 3970 | return 0; |
3984 | } | 3971 | } |
3985 | 3972 | ||
3973 | #ifdef CONFIG_PM_SLEEP | ||
3974 | static int wm8994_suspend(struct device *dev) | ||
3975 | { | ||
3976 | struct wm8994_priv *wm8994 = dev_get_drvdata(dev); | ||
3977 | |||
3978 | /* Drop down to power saving mode when system is suspended */ | ||
3979 | if (wm8994->jackdet && !wm8994->active_refcount) | ||
3980 | regmap_update_bits(wm8994->wm8994->regmap, WM8994_ANTIPOP_2, | ||
3981 | WM1811_JACKDET_MODE_MASK, | ||
3982 | wm8994->jackdet_mode); | ||
3983 | |||
3984 | return 0; | ||
3985 | } | ||
3986 | |||
3987 | static int wm8994_resume(struct device *dev) | ||
3988 | { | ||
3989 | struct wm8994_priv *wm8994 = dev_get_drvdata(dev); | ||
3990 | |||
3991 | if (wm8994->jackdet && wm8994->jack_cb) | ||
3992 | regmap_update_bits(wm8994->wm8994->regmap, WM8994_ANTIPOP_2, | ||
3993 | WM1811_JACKDET_MODE_MASK, | ||
3994 | WM1811_JACKDET_MODE_AUDIO); | ||
3995 | |||
3996 | return 0; | ||
3997 | } | ||
3998 | #endif | ||
3999 | |||
4000 | static const struct dev_pm_ops wm8994_pm_ops = { | ||
4001 | SET_SYSTEM_SLEEP_PM_OPS(wm8994_suspend, wm8994_resume) | ||
4002 | }; | ||
4003 | |||
3986 | static struct platform_driver wm8994_codec_driver = { | 4004 | static struct platform_driver wm8994_codec_driver = { |
3987 | .driver = { | 4005 | .driver = { |
3988 | .name = "wm8994-codec", | 4006 | .name = "wm8994-codec", |
3989 | .owner = THIS_MODULE, | 4007 | .owner = THIS_MODULE, |
3990 | }, | 4008 | .pm = &wm8994_pm_ops, |
4009 | }, | ||
3991 | .probe = wm8994_probe, | 4010 | .probe = wm8994_probe, |
3992 | .remove = __devexit_p(wm8994_remove), | 4011 | .remove = __devexit_p(wm8994_remove), |
3993 | }; | 4012 | }; |