Skip to content

Commit

Permalink
ASoC: cs42l42: Report full jack status when plug is detected
Browse files Browse the repository at this point in the history
[ Upstream commit 8d06f79 ]

When a plug event is detect report the full state of all status
bits, don't assume that there will have been a previous unplug
event to clear all the bits. Report the state of both HEADPHONE
and MICROPHONE bits according to detected type, and clear all the
button status bits. The current button status is already checked
and reported at the end of the function.

During a system suspend the jack could be unplugged and plugged,
possibly changing the jack type. On resume the interrupt status will
indicate a plug event - there will not be an unplug event to clear
the bits.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220121120412.672284-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
rfvirgil authored and gregkh committed Apr 8, 2022
1 parent 7594d42 commit d398278
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sound/soc/codecs/cs42l42.c
Expand Up @@ -1637,19 +1637,27 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)

mutex_lock(&cs42l42->jack_detect_mutex);

/* Check auto-detect status */
/*
* Check auto-detect status. Don't assume a previous unplug event has
* cleared the flags. If the jack is unplugged and plugged during
* system suspend there won't have been an unplug event.
*/
if ((~masks[5]) & irq_params_table[5].mask) {
if (stickies[5] & CS42L42_HSDET_AUTO_DONE_MASK) {
cs42l42_process_hs_type_detect(cs42l42);
switch (cs42l42->hs_type) {
case CS42L42_PLUG_CTIA:
case CS42L42_PLUG_OMTP:
snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADSET,
SND_JACK_HEADSET);
SND_JACK_HEADSET |
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3);
break;
case CS42L42_PLUG_HEADPHONE:
snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADPHONE,
SND_JACK_HEADPHONE);
SND_JACK_HEADSET |
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3);
break;
default:
break;
Expand Down

0 comments on commit d398278

Please sign in to comment.