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/rt274.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index 144a6f775c21..730de9452333 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.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> @@ -395,28 +396,42 @@ static void rt274_jack_detect_work(struct work_struct *work) SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); }
-static irqreturn_t rt274_irq(int irq, void *data); - static int rt274_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); + bool mic = false; + bool hp = false; + int status = 0; + int ret;
rt274->jack = jack;
if (jack == NULL) { /* Disable jack detection */ + disable_irq(rt274->i2c->irq); regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, RT274_IRQ_EN, RT274_IRQ_DIS);
return 0; }
+ /* Enable jack detection */ regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, RT274_IRQ_EN, RT274_IRQ_EN); + enable_irq(rt274->i2c->irq);
/* Send an initial report */ - rt274_irq(0, rt274); + ret = rt274_jack_detect(rt274, &hp, &mic); + if (!ret) { + if (hp) + status |= SND_JACK_HEADPHONE; + + if (mic) + status |= SND_JACK_MICROPHONE; + + snd_soc_jack_report(rt274->jack, status, SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); + }
return 0; } @@ -984,6 +999,9 @@ static int rt274_probe(struct snd_soc_component *component) INIT_DELAYED_WORK(&rt274->jack_detect_work, rt274_jack_detect_work);
if (rt274->i2c->irq) { + /* irq will be enabled in rt274_mic_detect */ + irq_set_status_flags(rt274->i2c->irq, IRQ_NOAUTOEN); + ret = request_threaded_irq(rt274->i2c->irq, NULL, rt274_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt274", rt274); if (ret) {