alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: rt298: Add jack suspend and resume functions.
@ 2016-06-13 12:28 Bard Liao
  2016-06-13 14:09 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Bard Liao @ 2016-06-13 12:28 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: oder_chiou, alsa-devel, lars, vinod.koul, Bard Liao,
	senthilnathanx.veppur, flove

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.

Signed-off-by: Senthilnathan Veppur <senthilnathanx.veppur@intel.com>
Signed-off-by: Bard Liao <bardliao@realtek.com>
---
 sound/soc/codecs/rt298.c | 20 ++++++++++++++++++++
 sound/soc/codecs/rt298.h |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index d403c20..629b038 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -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 = {
diff --git a/sound/soc/codecs/rt298.h b/sound/soc/codecs/rt298.h
index 3638f3d..2de342f 100644
--- a/sound/soc/codecs/rt298.h
+++ b/sound/soc/codecs/rt298.h
@@ -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__ */
 
-- 
1.8.1.1.439.g50a6b54

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: rt298: Add jack suspend and resume functions.
  2016-06-13 12:28 [PATCH] ASoC: rt298: Add jack suspend and resume functions Bard Liao
@ 2016-06-13 14:09 ` Mark Brown
  2016-06-13 16:55   ` Vinod Koul
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2016-06-13 14:09 UTC (permalink / raw)
  To: Bard Liao
  Cc: oder_chiou, alsa-devel, lars, vinod.koul, lgirdwood,
	senthilnathanx.veppur, flove


[-- Attachment #1.1: Type: text/plain, Size: 898 bytes --]

On Mon, Jun 13, 2016 at 08:28:39PM +0800, Bard Liao wrote:

> +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);

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.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: rt298: Add jack suspend and resume functions.
  2016-06-13 16:55   ` Vinod Koul
@ 2016-06-13 16:50     ` Mark Brown
  2016-06-13 17:04       ` Vinod Koul
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2016-06-13 16:50 UTC (permalink / raw)
  To: Vinod Koul
  Cc: oder_chiou, alsa-devel, lars, lgirdwood, senthilnathanx.veppur,
	Bard Liao, flove


[-- Attachment #1.1: Type: text/plain, Size: 154 bytes --]

On Mon, Jun 13, 2016 at 10:25:37PM +0530, Vinod Koul wrote:

> This was based on existing pattern in rt5672.

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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: rt298: Add jack suspend and resume functions.
  2016-06-13 14:09 ` Mark Brown
@ 2016-06-13 16:55   ` Vinod Koul
  2016-06-13 16:50     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Vinod Koul @ 2016-06-13 16:55 UTC (permalink / raw)
  To: Mark Brown
  Cc: oder_chiou, alsa-devel, lars, lgirdwood, senthilnathanx.veppur,
	Bard Liao, flove


[-- Attachment #1.1: Type: text/plain, Size: 1210 bytes --]

On Mon, Jun 13, 2016 at 03:09:23PM +0100, Mark Brown wrote:
> On Mon, Jun 13, 2016 at 08:28:39PM +0800, Bard Liao wrote:
> 
> > +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);
> 
> 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
-- 
~Vinod

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: rt298: Add jack suspend and resume functions.
  2016-06-13 16:50     ` Mark Brown
@ 2016-06-13 17:04       ` Vinod Koul
  0 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2016-06-13 17:04 UTC (permalink / raw)
  To: Mark Brown
  Cc: oder_chiou, alsa-devel, lars, lgirdwood, senthilnathanx.veppur,
	Bard Liao, flove


[-- Attachment #1.1: Type: text/plain, Size: 291 bytes --]

On Mon, Jun 13, 2016 at 05:50:46PM +0100, Mark Brown wrote:
> On Mon, Jun 13, 2016 at 10:25:37PM +0530, Vinod Koul wrote:
> 
> > 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
-- 
~Vinod

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-13 16:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-13 12:28 [PATCH] ASoC: rt298: Add jack suspend and resume functions Bard Liao
2016-06-13 14:09 ` Mark Brown
2016-06-13 16:55   ` Vinod Koul
2016-06-13 16:50     ` Mark Brown
2016-06-13 17:04       ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).