Repository navigation
Conversation
Move the bodies of the tip plug and unplug cases of cs42l84_irq_thread() into cs42l84_handle_plug() and cs42l84_handle_unplug(), so that the following changes can run them outside the interrupt as well. The register writes, their order and the debug messages are unchanged. No functional change. Signed-off-by: LiamRay11 <228416644+LiamRay11@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the tip sense no longer reads plugged after headset detection, the plug path sets tip_state back to unplugged and turns HSBIAS off, but keeps hs_type and the jack report that detection just made, and then unmasks the ring sense interrupts. If the tip then settles unplugged, the next tip interrupt sees no change against tip_state and does nothing, so the jack stays reported as plugged with nothing in it. A ring interrupt in that state, or the no-change tip interrupt falling through to the ring check, runs headset detection again with the jack empty. Treat the invalidated detection as an unplug: turn HSBIAS off, clear hs_type, report the jack empty and leave the ring interrupts masked. If the tip then settles plugged, its interrupt is a change and detects again, as before. Also run the ring check only while the tip is plugged: with the tip unplugged or in transition there is nothing to detect. Signed-off-by: LiamRay11 <228416644+LiamRay11@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The driver learns of a plug only from its plug interrupt, which acts
on a change of the tip sense against the state saved at probe. That
leaves the jack reported wrongly in two cases:
- Headphones already in at boot. The probe saves the tip as plugged,
no headset detection runs and hs_type stays 0, so set_jack reports
the jack empty until the plug is pulled and pushed in again.
- A plug or unplug during a sleep that leaves the codec powered
(suspend-to-idle). The interrupt is not a wake source and nothing
reads the tip sense again on resume, so headphones pulled out
while asleep still read plugged afterwards. A sleep that puts the
codec in reset already detects again on resume.
Add cs42l84_sync_plug(), which reads the tip sense once and runs the
interrupt's own plug or unplug path when it disagrees with the
driver's state. It runs under irq_lock, like the interrupt thread, so
an interrupt for the same change finds the state already updated.
Call it from set_jack before the first report, and from a work item
that resume queues on system_freezable_wq when the codec kept its
power, so it runs after every device has resumed without adding the
headset detection to the resume path. Suspend cancels a check that is
still pending.
On a machine booted without headphones this adds one register read
at set_jack and after each such sleep.
Tested on a MacBook Pro (M6, J804), on an earlier base
(integration/aurora f5fa539) with an earlier version of this change:
booted without headphones, the attach check reads the tip unplugged and
does nothing more.
Signed-off-by: LiamRay11 <228416644+LiamRay11@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sithglan
left a comment
There was a problem hiding this comment.
Test report, 2026-11-17: Apple Mac mini M6 (J873g/T8152, board 0x24). PR revision tested: 9396cd421efd94f9573103e5d9597dda86ac6d4f.
Host validation used the combined #2105–2108/#2110–2112 series (54742c617db4 on 677be395b9d2) with Clang 22. All changed driver objects built with W=1 and no new warnings; two pre-existing DART unused-helper warnings were unchanged.
cs42l84.o built with Clang 22 and W=1 with no new warnings. Hardware smoke used this patch plus its existing upstream sleep prerequisite b912083 on the separate M6 test kernel. CS42L84 revision 36 bound successfully at 0-004b; 25 ALSA controls were readable and both jack controls reported off.
Physical insertion/removal, plugged-at-boot detection and jack changes across sleep were not exercised. This is attach/control smoke coverage, not full qualification of the jack-state fix.
Summary
cs42l84 learns of a plug only from a plug-sense interrupt that acts on a change. That leaves the jack reported wrong in three cases:
b91208392("Bring the codec back after a firmware sleep") already re-detects after a firmware sleep that resets the codec. This PR covers the other cases. It is generic, with no machine gate.Changes
Move the plug/unplug bodies of the IRQ thread into
cs42l84_handle_plug()/cs42l84_handle_unplug(). No functional change.If detection is invalidated because the tip did not stay plugged, treat it as an unplug: HSBIAS off,
hs_type0, jack reported empty, ring IRQs stay masked. Previously the report stayed "plugged" with nothing in the jack. The ring check now also runs only while the tip is plugged.cs42l84_sync_plug()reads the tip sense once and runs the IRQ's own path if it disagrees with the driver state. It is called:set_jackbefore the first reportsystem_freezable_wqthat resume queues when the codec kept powerSuspend cancels a pending check. Everything runs under
irq_lock.Testing
On hardware: MacBook Pro 14-inch (M6, J804), 2026-11-16, tested by LiamRay11.
bf423bf0ewith all nine J804 linux PRs merged (t8152-mailboxes, dart-gen3, dt-board, centauri, g18-fast-retire, cfg80211-stale-scan, smc, cs42l84-jack, and an NVMe PR that is not sent yet), plus retest-only device-tree changes that are not part of these PRs: SSD nodes (ANS mailbox, SART, NVMe), PCIe port 0 with the N1 Wi-Fi, the USB0 gadget console, and aread-onlyNVRAM partition. Those nodes were needed to reach the root filesystem and SSH.systemctl rebootfrom this kernel (watchdog restart) returned to the installed system.Results for this PR (draft): not run. The change was built into the retest kernel, but the jack codec is disabled in that tree and the plug test needs the owner at the machine, so it was not run. This stays a draft until it is.
sound/soc/codecs/cs42l84.owithW=1builds without warnings.integration/aurora has since moved to
677be395b; this branch still merges into it without conflicts.Notes
This affects every Mac with a CS42L84. A test on another machine (for example an M2/M3 laptop) would be welcome.
Dependencies
None.
🤖 Generated with Claude Code