aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-11-22 06:44:32 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-03 02:34:12 -0500
commit63dd54521f1d143fbc6584ace66ef264a7f867f7 (patch)
treec7cc350894650771f79b95f6729b275b34d17de1
parent78b76dbec8da6437e30519e6bbe4fb44d798addf (diff)
ASoC: wm8994: Support custom accessory identification for WM1811A
Allow the user to override the accessory identification code with their own implementation if the system provides an alternative method. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/codecs/wm8994.c36
-rw-r--r--sound/soc/codecs/wm8994.h6
2 files changed, 25 insertions, 17 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 4cd1b6cdb34f..1dcccdbbc8b6 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -3504,15 +3504,20 @@ static void wm1811_mic_work(struct work_struct *work)
3504 3504
3505 dev_dbg(codec->dev, "Starting mic detection\n"); 3505 dev_dbg(codec->dev, "Starting mic detection\n");
3506 3506
3507 /* 3507 /* Use a user-supplied callback if we have one */
3508 * Start off measument of microphone impedence to find out 3508 if (wm8994->micd_cb) {
3509 * what's actually there. 3509 wm8994->micd_cb(wm8994->micd_cb_data);
3510 */ 3510 } else {
3511 wm8994->mic_detecting = true; 3511 /*
3512 wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_MIC); 3512 * Start off measument of microphone impedence to find out
3513 * what's actually there.
3514 */
3515 wm8994->mic_detecting = true;
3516 wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_MIC);
3513 3517
3514 snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, 3518 snd_soc_update_bits(codec, WM8958_MIC_DETECT_1,
3515 WM8958_MICD_ENA, WM8958_MICD_ENA); 3519 WM8958_MICD_ENA, WM8958_MICD_ENA);
3520 }
3516 3521
3517 mutex_unlock(&wm8994->accdet_lock); 3522 mutex_unlock(&wm8994->accdet_lock);
3518 3523
@@ -3624,7 +3629,7 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work)
3624 * detection algorithm. 3629 * detection algorithm.
3625 */ 3630 */
3626int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, 3631int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
3627 wm8958_micdet_cb cb, void *cb_data) 3632 wm1811_micdet_cb cb, void *cb_data)
3628{ 3633{
3629 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 3634 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
3630 struct wm8994 *control = wm8994->wm8994; 3635 struct wm8994 *control = wm8994->wm8994;
@@ -3639,17 +3644,18 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
3639 } 3644 }
3640 3645
3641 if (jack) { 3646 if (jack) {
3642 /* No longer supported */
3643 if (cb)
3644 return -EINVAL;
3645
3646 snd_soc_dapm_force_enable_pin(&codec->dapm, "CLK_SYS"); 3647 snd_soc_dapm_force_enable_pin(&codec->dapm, "CLK_SYS");
3647 snd_soc_dapm_sync(&codec->dapm); 3648 snd_soc_dapm_sync(&codec->dapm);
3648 3649
3649 wm8994->micdet[0].jack = jack; 3650 wm8994->micdet[0].jack = jack;
3650 3651
3651 wm8994->mic_detecting = true; 3652 if (cb) {
3652 wm8994->jack_mic = false; 3653 wm8994->micd_cb = cb;
3654 wm8994->micd_cb_data = cb_data;
3655 } else {
3656 wm8994->mic_detecting = true;
3657 wm8994->jack_mic = false;
3658 }
3653 3659
3654 wm8958_micd_set_rate(codec); 3660 wm8958_micd_set_rate(codec);
3655 3661
diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h
index f5546f242ab1..1a6bb4ed08f8 100644
--- a/sound/soc/codecs/wm8994.h
+++ b/sound/soc/codecs/wm8994.h
@@ -39,12 +39,12 @@ enum wm8994_vmid_mode {
39 WM8994_VMID_FORCE, 39 WM8994_VMID_FORCE,
40}; 40};
41 41
42typedef void (*wm8958_micdet_cb)(u16 status, void *data); 42typedef void (*wm1811_micdet_cb)(void *data);
43 43
44int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, 44int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
45 int micbias); 45 int micbias);
46int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, 46int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
47 wm8958_micdet_cb cb, void *cb_data); 47 wm1811_micdet_cb cb, void *cb_data);
48 48
49int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode); 49int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode);
50 50
@@ -138,6 +138,8 @@ struct wm8994_priv {
138 struct delayed_work jackdet_bootstrap; 138 struct delayed_work jackdet_bootstrap;
139 139
140 int micdet_irq; 140 int micdet_irq;
141 wm1811_micdet_cb micd_cb;
142 void *micd_cb_data;
141 143
142 int revision; 144 int revision;
143 145