aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-30 05:55:14 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-01 09:21:51 -0500
commit4585790d1cde32a5719c24412e9845e031358e08 (patch)
tree1350ab58fb4fa2611c45c96da0c0daa6143b4096 /sound/soc/codecs
parent604533de0f60c3be6ae99fdaf44d1d79f38b307e (diff)
ASoC: Allow more WM8958/WM1811 button levels with default handler
The WM8958 and WM1811 support detecting a range of buttons. Allow the user to provide platform data enabling more of these levels without having to write a custom detection handler. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/wm8994.c42
-rw-r--r--sound/soc/codecs/wm8994.h1
2 files changed, 35 insertions, 8 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 45bfa09f2e45..3e52d40866d2 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -3043,6 +3043,7 @@ static void wm8958_default_micdet(u16 status, void *data)
3043{ 3043{
3044 struct snd_soc_codec *codec = data; 3044 struct snd_soc_codec *codec = data;
3045 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 3045 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3046 int report;
3046 3047
3047 dev_dbg(codec->dev, "MICDET %x\n", status); 3048 dev_dbg(codec->dev, "MICDET %x\n", status);
3048 3049
@@ -3055,7 +3056,7 @@ static void wm8958_default_micdet(u16 status, void *data)
3055 wm8958_micd_set_rate(codec); 3056 wm8958_micd_set_rate(codec);
3056 3057
3057 snd_soc_jack_report(wm8994->micdet[0].jack, 0, 3058 snd_soc_jack_report(wm8994->micdet[0].jack, 0,
3058 SND_JACK_BTN_0 | SND_JACK_HEADSET); 3059 wm8994->btn_mask | SND_JACK_HEADSET);
3059 3060
3060 return; 3061 return;
3061 } 3062 }
@@ -3088,12 +3089,27 @@ static void wm8958_default_micdet(u16 status, void *data)
3088 3089
3089 /* Report short circuit as a button */ 3090 /* Report short circuit as a button */
3090 if (wm8994->jack_mic) { 3091 if (wm8994->jack_mic) {
3092 report = 0;
3091 if (status & 0x4) 3093 if (status & 0x4)
3092 snd_soc_jack_report(wm8994->micdet[0].jack, 3094 report |= SND_JACK_BTN_0;
3093 SND_JACK_BTN_0, SND_JACK_BTN_0); 3095
3094 else 3096 if (status & 0x8)
3095 snd_soc_jack_report(wm8994->micdet[0].jack, 3097 report |= SND_JACK_BTN_1;
3096 0, SND_JACK_BTN_0); 3098
3099 if (status & 0x10)
3100 report |= SND_JACK_BTN_2;
3101
3102 if (status & 0x20)
3103 report |= SND_JACK_BTN_3;
3104
3105 if (status & 0x40)
3106 report |= SND_JACK_BTN_4;
3107
3108 if (status & 0x80)
3109 report |= SND_JACK_BTN_5;
3110
3111 snd_soc_jack_report(wm8994->micdet[0].jack, report,
3112 wm8994->btn_mask);
3097 } 3113 }
3098} 3114}
3099 3115
@@ -3118,6 +3134,7 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
3118{ 3134{
3119 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 3135 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3120 struct wm8994 *control = wm8994->wm8994; 3136 struct wm8994 *control = wm8994->wm8994;
3137 u16 micd_lvl_sel;
3121 3138
3122 switch (control->type) { 3139 switch (control->type) {
3123 case WM1811: 3140 case WM1811:
@@ -3145,9 +3162,18 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
3145 3162
3146 wm8958_micd_set_rate(codec); 3163 wm8958_micd_set_rate(codec);
3147 3164
3148 /* Detect microphones and short circuits */ 3165 /* Detect microphones and short circuits by default */
3166 if (wm8994->pdata->micd_lvl_sel)
3167 micd_lvl_sel = wm8994->pdata->micd_lvl_sel;
3168 else
3169 micd_lvl_sel = 0x41;
3170
3171 wm8994->btn_mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 |
3172 SND_JACK_BTN_2 | SND_JACK_BTN_3 |
3173 SND_JACK_BTN_4 | SND_JACK_BTN_5;
3174
3149 snd_soc_update_bits(codec, WM8958_MIC_DETECT_2, 3175 snd_soc_update_bits(codec, WM8958_MIC_DETECT_2,
3150 WM8958_MICD_LVL_SEL_MASK, 0x41); 3176 WM8958_MICD_LVL_SEL_MASK, micd_lvl_sel);
3151 3177
3152 snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, 3178 snd_soc_update_bits(codec, WM8958_MIC_DETECT_1,
3153 WM8958_MICD_ENA, WM8958_MICD_ENA); 3179 WM8958_MICD_ENA, WM8958_MICD_ENA);
diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h
index c3e71d72eb6a..77e3d8c9eeb8 100644
--- a/sound/soc/codecs/wm8994.h
+++ b/sound/soc/codecs/wm8994.h
@@ -129,6 +129,7 @@ struct wm8994_priv {
129 struct wm8994_micdet micdet[2]; 129 struct wm8994_micdet micdet[2];
130 bool detecting; 130 bool detecting;
131 bool jack_mic; 131 bool jack_mic;
132 int btn_mask;
132 133
133 wm8958_micdet_cb jack_cb; 134 wm8958_micdet_cb jack_cb;
134 void *jack_cb_data; 135 void *jack_cb_data;