Skip to contentSkip to conversation

ASoC: rt286: add irq enable/disable APIs and export

PATCH Superseded Jie Yang 2 participants 4 messages Feb 4, 2015

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jie Yang

author
#0 lore raw

PATCH 1/1 ASoC: rt286: add irq enable/disable APIs and export

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

Here add irq enable/disable APIs and export them, also 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
index 8104d22..66afb9b 100644
@@ -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_irq(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_irq);
+
+int rt286_disable_irq(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_irq);
+
 static int is_mclk_mode(struct snd_soc_dapm_widget *source,
 			 struct snd_soc_dapm_widget *sink)
 {
sound/soc/codecs/rt286.h +2 -0
index b539b73..fb18331 100644
@@ -193,6 +193,8 @@ enum {
 };
 
 int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack);
+int rt286_enable_irq(struct snd_soc_codec *codec);
+int rt286_disable_irq(struct snd_soc_codec *codec);
 
 #endif /* __RT286_H__ */
 
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Review

Quoted 8 lines · Jie Yang

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

Here add irq enable/disable APIs and export them, also disable LDO1, which is used for jack detection when headphone is plugged in.

(quoted diff) +2 -0
+int rt286_enable_irq(struct snd_soc_codec *codec)
+{

This isn't a great idiom for the API - the machine driver isn't working with the interrupt, it's working with the jack detection so it should do the disable and reenable in terms of the jack detection too. Otherwise it's not clear that this won't interfere with other interrupt functions the device has and that it'll disable the jack detection hardware in the device rather than just ignoring the interrupt (which is presumably desired and appears to be actually happening in the code).

author
#2 lore raw
Quoted 17 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Wednesday, February 04, 2015 8:59 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ASoC: rt286: add irq enable/disable APIs and export

Quoted 7 lines · Jie Yang

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

Here add irq enable/disable APIs and export them, also disable LDO1, which is used for jack detection when headphone is plugged in.

+int rt286_enable_irq(struct snd_soc_codec *codec) {

Quoted 7 lines

This isn't a great idiom for the API - the machine driver isn't working with the interrupt, it's working with the jack detection so it should do the disable and reenable in terms of the jack detection too. Otherwise it's not clear that this won't interfere with other interrupt functions the device has and that it'll disable the jack detection hardware in the device rather than just ignoring the interrupt (which is presumably desired and appears to be actually happening in the code).

[Keyon] thanks for review, Mark, do you mean we should change the function names to rt286_enable/disable_jack_detection()?

maintainer
#3 lore raw
Quoted 2 lines · Yang

[Keyon] thanks for review, Mark, do you mean we should change the function names to rt286_enable/disable_jack_detection()?

Yes, that should be fine.