Skip to content

Commit

Permalink
ASoC: rt5663: Check the JD status in the button pushing
Browse files Browse the repository at this point in the history
Check the JD status in the button pushing to prevent the IRQ that is locked
by button pushing event while the jack unpluging.

Signed-off-by: Oder Chiou <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
oder-chiou authored and broonie committed Nov 10, 2017
1 parent ba68fa3 commit de6ae8a
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions sound/soc/codecs/rt5663.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct rt5663_priv {
struct snd_soc_codec *codec;
struct rt5663_platform_data pdata;
struct regmap *regmap;
struct delayed_work jack_detect_work;
struct delayed_work jack_detect_work, jd_unplug_work;
struct snd_soc_jack *hs_jack;
struct timer_list btn_check_timer;
struct impedance_mapping_table *imp_table;
Expand Down Expand Up @@ -1940,8 +1940,15 @@ static void rt5663_jack_detect_work(struct work_struct *work)
break;
}
/* button release or spurious interrput*/
if (btn_type == 0)
if (btn_type == 0) {
report = rt5663->jack_type;
cancel_delayed_work_sync(
&rt5663->jd_unplug_work);
} else {
queue_delayed_work(system_wq,
&rt5663->jd_unplug_work,
msecs_to_jiffies(500));
}
}
} else {
/* jack out */
Expand All @@ -1962,6 +1969,37 @@ static void rt5663_jack_detect_work(struct work_struct *work)
SND_JACK_BTN_2 | SND_JACK_BTN_3);
}

static void rt5663_jd_unplug_work(struct work_struct *work)
{
struct rt5663_priv *rt5663 =
container_of(work, struct rt5663_priv, jd_unplug_work.work);
struct snd_soc_codec *codec = rt5663->codec;

if (!codec)
return;

if (!rt5663_check_jd_status(codec)) {
/* jack out */
switch (rt5663->codec_ver) {
case CODEC_VER_1:
rt5663_v2_jack_detect(rt5663->codec, 0);
break;
case CODEC_VER_0:
rt5663_jack_detect(rt5663->codec, 0);
break;
default:
dev_err(codec->dev, "Unknown CODEC Version\n");
}

snd_soc_jack_report(rt5663->hs_jack, 0, SND_JACK_HEADSET |
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3);
} else {
queue_delayed_work(system_wq, &rt5663->jd_unplug_work,
msecs_to_jiffies(500));
}
}

static const struct snd_kcontrol_new rt5663_snd_controls[] = {
/* DAC Digital Volume */
SOC_DOUBLE_TLV("DAC Playback Volume", RT5663_STO1_DAC_DIG_VOL,
Expand Down Expand Up @@ -3556,6 +3594,7 @@ static int rt5663_i2c_probe(struct i2c_client *i2c,
}

INIT_DELAYED_WORK(&rt5663->jack_detect_work, rt5663_jack_detect_work);
INIT_DELAYED_WORK(&rt5663->jd_unplug_work, rt5663_jd_unplug_work);

if (i2c->irq) {
ret = request_irq(i2c->irq, rt5663_irq,
Expand Down

0 comments on commit de6ae8a

Please sign in to comment.