Re: [PATCH] ALSA: hda/cs8409: Fix for Dell Cirrus audio jack detect

From: Takashi Iwai

Date: Tue Jul 14 2026 - 01:50:19 EST


On Mon, 13 Jul 2026 23:21:41 +0200,
Steven 'Steve' Kendall wrote:
>
> On some models like the Dell Inspiron 15 3520, jack
> detection does not work. This patch switches to polling
> and more regularly queries the lower values rather
> than cached values for the headphone and mic jacks.
> It also includes some logic to prevent the polling
> while headphones are already plugged so no
> audible "tick" can be heard.
>
> ---

This makes the remaining text not taken by git-am.
And, I guess the text above should have been combined with the below?

> This patch switches to a polling method for a
> specific Dell machine (Inspiron 15 3520). This fixes
> jack detection for this model. It's possible the gate
> on manufacturer and model are unnecessary and this problem
> is common to a wider set of machines, but I've only tested
> on one machine thus far. I left the other logic ungated
> as it seemed likely the cache was not providing up-to-date
> information broadly. But I'm open to gating more or less
> of the content or changing the approach entirely.

The jack polling is really the last resort, and I'd like to know why
the normal jack detection doesn't work at first. Is it the missing
unsol event? Or the jack detection itself doesn't work?
If it's a missing unsol event, this drop happens always? Or on
certain runtime PM state?


thanks,

Takashi

>
> Signed-off-by: Steven 'Steve' Kendall <skend@xxxxxxxxxxxx>
> ---
> sound/hda/codecs/cirrus/cs8409.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/sound/hda/codecs/cirrus/cs8409.c b/sound/hda/codecs/cirrus/cs8409.c
> index c43ff3ef75b6e..733234844e7df 100644
> --- a/sound/hda/codecs/cirrus/cs8409.c
> +++ b/sound/hda/codecs/cirrus/cs8409.c
> @@ -766,6 +766,9 @@ static int cs42l42_handle_tip_sense(struct sub_codec *cs42l42, unsigned int reg_
> /* TIP_SENSE INSERT/REMOVE */
> switch (reg_ts_status) {
> case CS42L42_TS_PLUG:
> + // if jack is already plugged, ignore plug event
> + if (cs42l42->hp_jack_in)
> + break;
> if (cs42l42->no_type_dect) {
> status_changed = 1;
> cs42l42->hp_jack_in = 1;
> @@ -776,6 +779,9 @@ static int cs42l42_handle_tip_sense(struct sub_codec *cs42l42, unsigned int reg_
> break;
>
> case CS42L42_TS_UNPLUG:
> + // if jack is already unplugged, ignore unplug event
> + if (!cs42l42->hp_jack_in && !cs42l42->mic_jack_in)
> + break;
> status_changed = 1;
> cs42l42->hp_jack_in = 0;
> cs42l42->mic_jack_in = 0;
> @@ -1092,12 +1098,14 @@ static int cs8409_cs42l42_exec_verb(struct hdac_device *dev, unsigned int cmd, u
> switch (nid) {
> case CS8409_CS42L42_HP_PIN_NID:
> if (verb == AC_VERB_GET_PIN_SENSE) {
> + cs42l42_jack_unsol_event(cs42l42);
> *res = (cs42l42->hp_jack_in) ? AC_PINSENSE_PRESENCE : 0;
> return 0;
> }
> break;
> case CS8409_CS42L42_AMIC_PIN_NID:
> if (verb == AC_VERB_GET_PIN_SENSE) {
> + cs42l42_jack_unsol_event(cs42l42);
> *res = (cs42l42->mic_jack_in) ? AC_PINSENSE_PRESENCE : 0;
> return 0;
> }
> @@ -1157,6 +1165,11 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
> case CS8409_WARLOCK_MLK_DUAL_MIC:
> spec->scodecs[CS8409_CODEC0]->full_scale_vol = CS42L42_FULL_SCALE_VOL_0DB;
> spec->speaker_pdn_gpio = CS8409_WARLOCK_SPEAKER_PDN;
> + // if Dell Inspiron 15 3520, poll jack at 250ms
> + if (codec->bus->pci->subsystem_vendor == 0x1028 &&
> + codec->bus->pci->subsystem_device == 0x0bb2) {
> + codec->jackpoll_interval = msecs_to_jiffies(250);
> + }
> break;
> default:
> spec->scodecs[CS8409_CODEC0]->full_scale_vol =
> @@ -1208,8 +1221,10 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
> * Run immediately after init.
> */
> if (spec->init_done && spec->build_ctrl_done
> - && !spec->scodecs[CS8409_CODEC0]->hp_jack_in)
> + && !spec->scodecs[CS8409_CODEC0]->hp_jack_in) {
> cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]);
> + cs42l42_enable_jack_detect(spec->scodecs[CS8409_CODEC0]);
> + }
> break;
> default:
> break;
>
> ---
> base-commit: d96fcfe1b7f94ac742984ae7986b94a116abff1b
> change-id: 20260710-fix-headphone-plug-cirrus-dell-5e3b49da5f52
>
> Best regards,
> --
> Steven 'Steve' Kendall <skend@xxxxxxxxxxxx>
>