[alsa-devel] [PATCH v2] ASoC: rt286: add jack detection enable/disable APIs and export

Jie Yang yang.jie at intel.com
Wed Feb 4 14:34:03 CET 2015


Some platforms, e.g. WSB, don't need jack detection when
system is in Suspend, for power save reason.

Here add jack detection enable/disable APIs and export them, when
disabled, it will ignore interrupt, and disable LDO1, which is
used for jack detection when headphone is plugged in.

Signed-off-by: Jie Yang <yang.jie at intel.com>
Reviewed-by: Bard Liao <bardliao at realtek.com>
---
 sound/soc/codecs/rt286.c | 24 ++++++++++++++++++++++++
 sound/soc/codecs/rt286.h |  2 ++
 2 files changed, 26 insertions(+)

diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 8104d22..9ea01d0 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -400,6 +400,30 @@ int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
 }
 EXPORT_SYMBOL_GPL(rt286_mic_detect);
 
+int rt286_enable_jack_detection(struct snd_soc_codec *codec)
+{
+	struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
+
+	if (rt286->jack->status | SND_JACK_HEADPHONE)
+		snd_soc_dapm_force_enable_pin(&rt286->codec->dapm, "LDO1");
+	snd_soc_dapm_sync(&rt286->codec->dapm);
+	enable_irq(rt286->i2c->irq);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt286_enable_jack_detection);
+
+int rt286_disable_jack_detection(struct snd_soc_codec *codec)
+{
+	struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
+
+	disable_irq(rt286->i2c->irq);
+
+	snd_soc_dapm_disable_pin(&rt286->codec->dapm, "LDO1");
+	snd_soc_dapm_sync(&rt286->codec->dapm);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(rt286_disable_jack_detection);
+
 static int is_mclk_mode(struct snd_soc_dapm_widget *source,
 			 struct snd_soc_dapm_widget *sink)
 {
diff --git a/sound/soc/codecs/rt286.h b/sound/soc/codecs/rt286.h
index b539b73..c958182 100644
--- a/sound/soc/codecs/rt286.h
+++ b/sound/soc/codecs/rt286.h
@@ -193,6 +193,8 @@ enum {
 };
 
 int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack);
+int rt286_enable_jack_detection(struct snd_soc_codec *codec);
+int rt286_disable_jack_detection(struct snd_soc_codec *codec);
 
 #endif /* __RT286_H__ */
 
-- 
1.9.1



More information about the Alsa-devel mailing list