aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBard Liao <bardliao@realtek.com>2016-11-28 00:24:06 -0500
committerMark Brown <broonie@kernel.org>2016-11-29 06:36:27 -0500
commite3d62cb8c70ff5ff946051484b1cdb38523d8b95 (patch)
treefe23440c3cfc66382d895fba352b1c263401d02e
parent1001354ca34179f3db924eb66672442a173147dc (diff)
ASoC: rt298: disable IRQ when jack is NULL
Disable IRQ when jack is NULL in rt298_mic_detect. So machine driver can use it in suspend/resume. Signed-off-by: Bard Liao <bardliao@realtek.com> Reviewed-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/rt298.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index 55558643166f..6c4ac5b04665 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -321,11 +321,31 @@ static void rt298_jack_detect_work(struct work_struct *work)
321int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) 321int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
322{ 322{
323 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); 323 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
324 struct snd_soc_dapm_context *dapm;
325 bool hp = false;
326 bool mic = false;
327 int status = 0;
328
329 /* If jack in NULL, disable HS jack */
330 if (!jack) {
331 regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0);
332 dapm = snd_soc_codec_get_dapm(codec);
333 snd_soc_dapm_disable_pin(dapm, "LDO1");
334 snd_soc_dapm_sync(dapm);
335 return 0;
336 }
324 337
325 rt298->jack = jack; 338 rt298->jack = jack;
339 regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x2);
326 340
327 /* Send an initial empty report */ 341 rt298_jack_detect(rt298, &hp, &mic);
328 snd_soc_jack_report(rt298->jack, 0, 342 if (hp == true)
343 status |= SND_JACK_HEADPHONE;
344
345 if (mic == true)
346 status |= SND_JACK_MICROPHONE;
347
348 snd_soc_jack_report(rt298->jack, status,
329 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); 349 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
330 350
331 return 0; 351 return 0;