[PATCH AUTOSEL 6.19-6.6] ASoC: cs42l43: Report insert for exotic peripherals

From: Sasha Levin

Date: Thu Mar 05 2026 - 10:38:35 EST


From: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>

[ Upstream commit 6510e1324bcdc8caf21f6d17efe27604c48f0d64 ]

For some exotic peripherals the type detect can return a reserved value
of 0x4. This will currently return an error and not report anything to
user-space, update this to report the insert normally.

Signed-off-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>
Link: https://patch.msgid.link/20260223093616.3800350-1-ckeepax@xxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---

LLM Generated explanations, may be completely bogus:

## Analysis

### What the commit does

This is a one-line fix to the CS42L43 audio codec's jack type detection.
The hardware's type detect register can return a reserved value of `0x4`
for "exotic peripherals." Before this fix, value `0x4` falls through to
the `default: return -EINVAL` case in the switch statement.

### What happens when -EINVAL is returned

The caller `cs42l43_tip_sense_work()` checks `if (report < 0)` and on
error:
1. Logs `"Jack detect failed: %d\n"`
2. Jumps to `error:` label
3. **No jack insert event is reported to userspace**

This means users with these "exotic peripherals" get no audio jack
detection at all — the device appears to not be plugged in.

### Bug classification

This is a **hardware quirk/workaround** — the hardware returns a
reserved value for certain real peripherals. The fix treats type `0x4`
the same as CTIA/OMTP (running load detection with headset=true), which
allows the system to properly detect and report the insert.

### Stable criteria assessment

1. **Fixes a real bug**: Yes — exotic peripherals are completely non-
functional without this fix (no insert reported to userspace)
2. **Obviously correct**: Yes — the fix adds one case label to treat
`0x4` like other headset types. The author (Charles Keepax) is the
subsystem maintainer at Cirrus Logic.
3. **Small and contained**: Yes — one line added to a switch statement
in a single file
4. **No new features**: Correct — this just makes existing hardware work
properly
5. **Risk**: Extremely low — it only affects the `0x4` type value which
previously returned an error anyway

This falls squarely into the **hardware quirks/workarounds** exception
category. The CS42L43 driver has been in the kernel since v6.6
(introduced August 2023, merged for 6.6-rc1), so it exists in recent
stable trees.

### Verification

- Explored `cs42l43_tip_sense_work()` at line ~766: confirmed that
negative return from `cs42l43_run_type_detect()` goes to `error:`
label without reporting jack state to userspace
- Confirmed the file was introduced in commit `fc918cbe874ee` (August 4,
2023) — present since v6.6
- Confirmed the author Charles Keepax is the original driver author and
Cirrus Logic engineer
- The commit was reviewed and merged by Mark Brown (ASoC maintainer)
- Multiple prior commits show ongoing type detection refinement for this
codec (dc96528b176fa, e77a4081d7e32, etc.)
- The change is a single `case 0x4:` fallthrough to the existing
CTIA/OMTP handler — no new code paths introduced

The fix is small, surgical, low-risk, and makes real hardware work for
users. It clearly meets stable kernel criteria.

**YES**

sound/soc/codecs/cs42l43-jack.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c
index b83bc4de1301d..3e04e6897b142 100644
--- a/sound/soc/codecs/cs42l43-jack.c
+++ b/sound/soc/codecs/cs42l43-jack.c
@@ -699,6 +699,7 @@ static int cs42l43_run_type_detect(struct cs42l43_codec *priv)
switch (type & CS42L43_HSDET_TYPE_STS_MASK) {
case 0x0: // CTIA
case 0x1: // OMTP
+ case 0x4:
return cs42l43_run_load_detect(priv, true);
case 0x2: // 3-pole
return cs42l43_run_load_detect(priv, false);
--
2.51.0