mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/cs8409: Fix for Dell Cirrus audio jack detect
@ 2026-07-13 21:21 Steven 'Steve' Kendall
  2026-07-14  5:50 ` Takashi Iwai
  2026-07-14 16:17 ` Stefan Binding
  0 siblings, 2 replies; 8+ messages in thread
From: Steven 'Steve' Kendall @ 2026-07-13 21:21 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: linux-sound, linux-kernel, Steven 'Steve' Kendall

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 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.

Signed-off-by: Steven 'Steve' Kendall <skend@chromium.org>
---
 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@chromium.org>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-17 21:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-13 21:21 [PATCH] ALSA: hda/cs8409: Fix for Dell Cirrus audio jack detect Steven 'Steve' Kendall
2026-07-14  5:50 ` Takashi Iwai
2026-07-14 19:51   ` Steven Kendall
2026-07-15  7:47     ` Takashi Iwai
2026-07-17 21:18       ` Steven Kendall
2026-07-14 16:17 ` Stefan Binding
2026-07-14 19:26   ` Steven Kendall
2026-07-15 15:16     ` Stefan Binding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox