diff mbox series

[09/11] ASoC: codecs: rt298: Enable irq only when needed

Message ID 20220609133541.3984886-10-amadeuszx.slawinski@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series ASoC: codecs: Series of fixes for realtek codecs used on RVPs | expand

Commit Message

Amadeusz Sławiński June 9, 2022, 1:35 p.m. UTC
Interrupt is only needed when jack detection is enabled, so enable it
then, similarly disable it when jack detection is being disabled.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/codecs/rt298.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index 078810f2ec7b..3c13b6dc3be9 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -16,6 +16,7 @@ 
 #include <linux/spi/spi.h>
 #include <linux/dmi.h>
 #include <linux/acpi.h>
+#include <linux/irq.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -337,6 +338,7 @@  static int rt298_mic_detect(struct snd_soc_component *component,
 
 	/* If jack in NULL, disable HS jack */
 	if (!jack) {
+		disable_irq(rt298->i2c->irq);
 		regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0);
 		dapm = snd_soc_component_get_dapm(component);
 		snd_soc_dapm_disable_pin(dapm, "LDO1");
@@ -346,6 +348,7 @@  static int rt298_mic_detect(struct snd_soc_component *component,
 
 	rt298->jack = jack;
 	regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x2);
+	enable_irq(rt298->i2c->irq);
 
 	rt298_jack_detect(rt298, &hp, &mic);
 	if (hp)
@@ -1015,6 +1018,9 @@  static int rt298_probe(struct snd_soc_component *component)
 	INIT_DELAYED_WORK(&rt298->jack_detect_work, rt298_jack_detect_work);
 
 	if (rt298->i2c->irq) {
+		/* irq will be enabled in rt298_mic_detect */
+		irq_set_status_flags(rt298->i2c->irq, IRQ_NOAUTOEN);
+
 		ret = request_threaded_irq(rt298->i2c->irq, NULL, rt298_irq,
 					   IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt298", rt298);
 		if (ret) {