[PATCH 08/11] ASoC: codecs: rt286: Enable irq only when needed
Amadeusz Sławiński
amadeuszx.slawinski at linux.intel.com
Thu Jun 9 15:35:38 CEST 2022
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 at linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski at intel.com>
---
sound/soc/codecs/rt286.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 02a41c915776..6384b4cb9eaf 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.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>
@@ -324,11 +325,14 @@ static int rt286_mic_detect(struct snd_soc_component *component,
if (rt286->jack->status & SND_JACK_HEADPHONE)
snd_soc_dapm_force_enable_pin(dapm, "LDO1");
regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x2);
+ enable_irq(rt286->i2c->irq);
+
/* Send an initial empty report */
snd_soc_jack_report(rt286->jack, rt286->jack->status,
SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
} else {
/* disable IRQ */
+ disable_irq(rt286->i2c->irq);
regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x0);
snd_soc_dapm_disable_pin(dapm, "LDO1");
}
@@ -951,6 +955,9 @@ static int rt286_probe(struct snd_soc_component *component)
INIT_DELAYED_WORK(&rt286->jack_detect_work, rt286_jack_detect_work);
if (rt286->i2c->irq) {
+ /* irq will be enabled in rt286_mic_detect */
+ irq_set_status_flags(rt286->i2c->irq, IRQ_NOAUTOEN);
+
ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq,
IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286);
if (ret) {
--
2.25.1
More information about the Alsa-devel
mailing list