ASoC: rt286: add jack detection enable/disable APIs and export
Subsystems (3)
PATCH v2 1/1 ASoC: rt286: add jack detection enable/disable APIs and export
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.
--- sound/soc/codecs/rt286.c | 24 ++++++++++++++++++++++++ sound/soc/codecs/rt286.h | 2 ++ 2 files changed, 26 insertions(+)
sound/soc/codecs/rt286.c +24 -0
@@ -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) {
sound/soc/codecs/rt286.h +2 -0
@@ -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__ */
Signature · 1 line
1.9.1
Mark Brown
maintainersound/soc/codecs/rt286.c int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) · line 425
Quoted 11 lines · Jie Yang
sound/soc/codecs/rt286.c +11
-0+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);
So, now I look at this again I'm wondering why this isn't writing to any registers - looking at the code we run on probe there's a register write if we're passed an interrupt which looks awfully like we're enabling jack detect. Probably we wouldn't need to do the rather odd disabling of the IRQ if we did that, but perhaps it's required.
I think there's actually problems with the existing jack detection code in the driver, I'd expect that the initial enabling of jack detect would be done when the machine driver says it wants jack detect by passing in the jack to report for.
Quoted 10 lines
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Thursday, February 05, 2015 4:26 AM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH v2] ASoC: rt286: add jack detection enable/disable APIs and exportOn Wed, Feb 04, 2015 at 09:34:03PM +0800, Jie Yang wrote:
Quoted 16 lines
sound/soc/codecs/rt286.c int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) · line 425
Quoted 10 lines
sound/soc/codecs/rt286.c +10
-0+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);So, now I look at this again I'm wondering why this isn't writing to any registers
- looking at the code we run on probe there's a register write if we're passed an interrupt which looks awfully like we're enabling jack detect. Probably we wouldn't need to do the rather odd disabling of the IRQ if we did that, but perhaps it's required.
[Keyon] yes, it's required to disable jack detection, otherwise, pin LDO1 will be force enabled again. So here I just disable the IRQ to make the code change smallest.
Quoted 4 lines
I think there's actually problems with the existing jack detection code in the driver, I'd expect that the initial enabling of jack detect would be done when the machine driver says it wants jack detect by passing in the jack to report for.
[Keyon] I agree that it may be more reasonable if we can pass jack(similar to rt286_mic_detect(), can use jack=NULL for disable) from this machine driver, then add checking this jack in handler rt286_irq(), don't call rt286_jack_detect() and snd_soc_jack_report() when the jack is NULL. What do you think about this solution?
Mark Brown
maintainerOn Thu, Feb 05, 2015 at 02:07:35AM +0000, Jie, Yang wrote:
Again, please fix your mailer to word wrap within paragraphs - your mails are very difficult to read.
Quoted 5 lines
[Keyon] I agree that it may be more reasonable if we can pass
jack(similar to rt286_mic_detect(), can use jack=NULL for disable)from this machine driver, then add checking this jack in handlerrt286_irq(), don't callrt286_jack_detect()andsnd_soc_jack_report()when the jack is NULL. What do you think about this solution?
That sounds fine. You should be able to just call the jack API with NULL jacks, it's set up to handle this since it's such a common case.