ASoC: rt286: add jack detection enable/disable APIs and export
Subsystems (3)
PATCH v3 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 | 29 +++++++++++++++++++++++++++++ sound/soc/codecs/rt286.h | 2 ++ 2 files changed, 31 insertions(+)
sound/soc/codecs/rt286.c +29 -0
@@ -402,6 +402,33 @@ 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 snd_soc_jack *jack) +{ +struct rt286_priv *rt286 =snd_soc_codec_get_drvdata (codec); + +if (!jack) +return -EINVAL ; + rt286->jack = jack; +if (jack->status |SND_JACK_HEADPHONE ) +snd_soc_dapm_force_enable_pin (&rt286->codec->dapm,"LDO1" ); +snd_soc_dapm_sync (&rt286->codec->dapm); +return 0 ; +} +EXPORT_SYMBOL_GPL (rt286_enable_jack_detection); + +int rt286_disable_jack_detection (struct snd_soc_codec *codec,struct snd_soc_jack *jack) +{ +struct rt286_priv *rt286 =snd_soc_codec_get_drvdata (codec); + +if (!jack) +return -EINVAL ; + rt286->jack =NULL ; +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) {
@@ -1012,6 +1039,8 @@ static irqreturn_t rt286_irq(int irq, void *data)bool mic = false;int status =0 ; +if (!rt286->jack) +return IRQ_HANDLED ;rt286_jack_detect (rt286, &hp, &mic);/* Clear IRQ */
sound/soc/codecs/rt286.h +2 -0
@@ -200,6 +200,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,struct snd_soc_jack *jack); +int rt286_disable_jack_detection (struct snd_soc_codec *codec,struct snd_soc_jack *jack);#endif /* __RT286_H__ */
Signature · 1 line
1.9.1
2015-02-06 7:40 GMT+01:00 Jie Yang <[email protected]>:
[...]
sound/soc/codecs/rt286.c static irqreturn_t rt286_irq(int irq, void *data) · line 1046
Quoted 9 lines
sound/soc/codecs/rt286.c +2
-0@@ -1012,6 +1039,8 @@ static irqreturn_t rt286_irq(int irq, void *data)bool mic = false;int status =0 ; +if (!rt286->jack) +return IRQ_HANDLED ;rt286_jack_detect (rt286, &hp, &mic);/* Clear IRQ */
This seems wrong. Are you sure you want to return IRQ_HANDLED when you did nothing to handle the interrupt?
Best Regards,
Michał Mirosław
Quoted 14 lines
-----Original Message-----
From: Michał Mirosław [mailto:[email protected]]
Sent: Friday, February 06, 2015 6:21 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [alsa-devel] [PATCH v3] ASoC: rt286: add jack detection enable/disable APIs and export2015-02-06 7:40 GMT+01:00 Jie Yang <[email protected]>:
[...]Quoted 4 lines
sound/soc/codecs/rt286.c +0
-0@@ -1012,6 +1039,8 @@ static irqreturn_t rt286_irq(int irq, void *data)bool mic = false;int status =0 ;
Quoted 8 lines
sound/soc/codecs/rt286.c static irqreturn_t rt286_irq(int irq, void *data) · line 1046
Quoted 5 lines
sound/soc/codecs/rt286.c +2
-0+if (!rt286->jack) +return IRQ_HANDLED ;rt286_jack_detect (rt286, &hp, &mic);/* Clear IRQ */ This seems wrong. Are you sure you want to return
IRQ_HANDLEDwhen you did nothing to handle the interrupt?
[Keyon] thanks, yes, I also noticed this. The interrupt will keep coming endlessly with returning IRQ_HANDLED here. :(
Quoted 3 lines
Best Regards,
Michał Mirosław
Hi, Mark,
Please hold on and not review this patch ATM, seems it can't disable the irq with this implement. Sorry for the confusing.
~Keyon
Quoted 85 lines
-----Original Message-----
From: Jie, Yang
Sent: Friday, February 06, 2015 2:40 PM
To: [email protected]
Cc: [email protected]; Girdwood, Liam R; Jie, Yang
Subject: [PATCH v3] ASoC: rt286: add jack detection enable/disable APIs and exportSome 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 <[email protected]>Reviewed-by Bard Liao <[email protected]>--- sound/soc/codecs/rt286.c | 29 +++++++++++++++++++++++++++++ sound/soc/codecs/rt286.h | 2 ++ 2 files changed, 31 insertions(+)sound/soc/codecs/rt286.c index renamed from sound/soc/codecs/rt286.c +0
-0d5cc1bc..1a0c250f 100644
sound/soc/codecs/rt286.c +29
-0@@ -402,6 +402,33 @@ 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 +snd_soc_jack *jack) { +struct rt286_priv *rt286 =snd_soc_codec_get_drvdata (codec); + +if (!jack) +return -EINVAL ; + rt286->jack = jack; +if (jack->status |SND_JACK_HEADPHONE ) +snd_soc_dapm_force_enable_pin (&rt286->codec->dapm,"LDO1" ); +snd_soc_dapm_sync (&rt286->codec->dapm); +return 0 ; +} +EXPORT_SYMBOL_GPL (rt286_enable_jack_detection); + +int rt286_disable_jack_detection (struct snd_soc_codec *codec,struct +snd_soc_jack *jack) { +struct rt286_priv *rt286 =snd_soc_codec_get_drvdata (codec); + +if (!jack) +return -EINVAL ; + rt286->jack =NULL ; +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) {@@ -1012,6 +1039,8 @@ static irqreturn_t rt286_irq(int irq, void *data)bool mic = false;int status =0 ; +if (!rt286->jack) +return IRQ_HANDLED ;rt286_jack_detect (rt286, &hp, &mic);/* Clear IRQ */ sound/soc/codecs/rt286.h index renamed from sound/soc/codecs/rt286.h +0
-07130edb..d793185 100644
sound/soc/codecs/rt286.h +3
-1@@ -200,6 +200,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,struct +snd_soc_jack *jack);int rt286_disable_jack_detection (struct +snd_soc_codec *codec,struct snd_soc_jack *jack);#endif /* __RT286_H__ */ --1.9.1