Skip to content

Commit

Permalink
ASoC: rt298: disable IRQ when jack is NULL
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bard Liao authored and Mark Brown committed Nov 29, 2016
1 parent 1001354 commit e3d62cb
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions sound/soc/codecs/rt298.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,31 @@ static void rt298_jack_detect_work(struct work_struct *work)
int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
{
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm;
bool hp = false;
bool mic = false;
int status = 0;

/* If jack in NULL, disable HS jack */
if (!jack) {
regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0);
dapm = snd_soc_codec_get_dapm(codec);
snd_soc_dapm_disable_pin(dapm, "LDO1");
snd_soc_dapm_sync(dapm);
return 0;
}

rt298->jack = jack;
regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x2);

/* Send an initial empty report */
snd_soc_jack_report(rt298->jack, 0,
rt298_jack_detect(rt298, &hp, &mic);
if (hp == true)
status |= SND_JACK_HEADPHONE;

if (mic == true)
status |= SND_JACK_MICROPHONE;

snd_soc_jack_report(rt298->jack, status,
SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);

return 0;
Expand Down

0 comments on commit e3d62cb

Please sign in to comment.