Skip to contentSkip to conversation

ASoC: rt298: Add jack suspend and resume functions.

PATCH In review Bard Liao 3 participants 5 messages Jun 13, 2016

Subsystems (3)
lore
Share & tools
lore

Bard Liao

author
#0 lore raw

PATCH 1/1 ASoC: rt298: Add jack suspend and resume functions.

We need to disable jack detection before entering suspend and enable it after resume.

This was essential as headphone jack widget will always remain on if a jack is inserted and results in no audio after system resumes from a suspend.

---
 sound/soc/codecs/rt298.c | 20 ++++++++++++++++++++
 sound/soc/codecs/rt298.h |  2 ++
 2 files changed, 22 insertions(+)
sound/soc/codecs/rt298.c +20 -0
index d403c20..629b038 100644
@@ -1270,6 +1270,26 @@ static int rt298_i2c_remove(struct i2c_client *i2c)
 	return 0;
 }
 
+void rt298_jack_suspend(struct snd_soc_codec *codec)
+{
+	struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
+	struct snd_soc_dapm_context *dapm;
+
+	dapm = snd_soc_codec_get_dapm(rt298->codec);
+	snd_soc_dapm_disable_pin(dapm, "LDO1");
+	snd_soc_dapm_sync(dapm);
+}
+EXPORT_SYMBOL_GPL(rt298_jack_suspend);
+
+void rt298_jack_resume(struct snd_soc_codec *codec)
+{
+	struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
+	bool hp = false;
+	bool mic = false;
+
+	rt298_jack_detect(rt298, &hp, &mic);
+}
+EXPORT_SYMBOL_GPL(rt298_jack_resume);
 
 static struct i2c_driver rt298_i2c_driver = {
 	.driver = {
sound/soc/codecs/rt298.h +2 -0
index 3638f3d..2de342f 100644
@@ -211,6 +211,8 @@ enum {
 };
 
 int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack);
+void rt298_jack_suspend(struct snd_soc_codec *codec);
+void rt298_jack_resume(struct snd_soc_codec *codec);
 
 #endif /* __RT298_H__ */
 
Signature · 1 line
1.8.1.1.439.g50a6b54
maintainer
#1 lore raw
Quoted 10 lines · Bard Liao
sound/soc/codecs/rt298.c +10 -0
+void rt298_jack_suspend(struct snd_soc_codec *codec)
+{
+	struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
+	struct snd_soc_dapm_context *dapm;
+
+	dapm = snd_soc_codec_get_dapm(rt298->codec);
+	snd_soc_dapm_disable_pin(dapm, "LDO1");
+	snd_soc_dapm_sync(dapm);
+}
+EXPORT_SYMBOL_GPL(rt298_jack_suspend);

sound/soc/codecs/rt298.c static int rt298_i2c_remove(struct i2c_client *i2c) · line 1292

Quoted 10 lines
sound/soc/codecs/rt298.c +10 -0
+
+void rt298_jack_resume(struct snd_soc_codec *codec)
+{
+	struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
+	bool hp = false;
+	bool mic = false;
+
+	rt298_jack_detect(rt298, &hp, &mic);
+}
+EXPORT_SYMBOL_GPL(rt298_jack_resume);

This is usually done by having the _jack_detect() function take NULL as the jack to disable the detection. Keeping in line with the existing pattern would be good, and would make it easier if we do start to get this more standardized.

#2 lore raw
Quoted 19 lines · Mark Brown
Quoted 17 lines · Bard Liao
sound/soc/codecs/rt298.c +17 -0
+void rt298_jack_suspend(struct snd_soc_codec *codec)
+{
+	struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
+	struct snd_soc_dapm_context *dapm;
+
+	dapm = snd_soc_codec_get_dapm(rt298->codec);
+	snd_soc_dapm_disable_pin(dapm, "LDO1");
+	snd_soc_dapm_sync(dapm);
+}
+EXPORT_SYMBOL_GPL(rt298_jack_suspend);
+
+void rt298_jack_resume(struct snd_soc_codec *codec)
+{
+	struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
+	bool hp = false;
+	bool mic = false;
+
Quoted 8 lines

sound/soc/codecs/rt298.c static int rt298_i2c_remove(struct i2c_client *i2c) · line 1292

Quoted 3 lines
sound/soc/codecs/rt298.c +3 -0
+	rt298_jack_detect(rt298, &hp, &mic);
+}
+EXPORT_SYMBOL_GPL(rt298_jack_resume);

This is usually done by having the _jack_detect() function take NULL as the jack to disable the detection. Keeping in line with the existing pattern would be good, and would make it easier if we do start to get this more standardized.

This was based on existing pattern in rt5672.

But yes I agree with you that we can so this by calling rt298_mic_detect(), will try that out

Thanks

Signature · 1 line
~Vinod
maintainer
#3 lore raw
Quoted 1 line · Vinod Koul

This was based on existing pattern in rt5672.

Oh dear, that's broken and should be fixed.

#4 lore raw
Quoted 5 lines · Mark Brown
Quoted 1 line · Vinod Koul

This was based on existing pattern in rt5672.

Oh dear, that's broken and should be fixed.

Sure, I will try to fix that up :)

Thanks

Signature · 1 line
~Vinod