Repository navigation
ASoC: cs42l42/cs42l84: Apple headset remote (vol up/down, play/pause) - #9
Merged
Merged
Conversation
RyanTheTide
force-pushed
the
remote/cs42l84-apple-headset-remote
branch
2 times, most recently
from
September 23, 2026 12:07
62f8c8c to
ffa3944
Compare
A failed status or mask read leaves part of the interrupt snapshot uninitialized, and the handler can then interpret that data as headset or button events. It also carries on with register access after a failed runtime resume. Check the runtime-PM acquisition and each snapshot read before processing any events, returning IRQ_NONE otherwise and logging failed reads. Acquire the device with RPM_TRANSPARENT: the I2C transport never enables runtime PM, and a plain pm_runtime_resume_and_get() would fail with -EACCES there and drop every jack interrupt. Release the IRQ mutex and PM reference on every exit path through a single error label. Should the codec stop responding altogether, IRQ_NONE lets the spurious-interrupt detector disable the level-triggered line instead of leaving it storming. Fixes: 2c394ca ("ASoC: Add support for CS42L42 codec") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Apple wired headset volume buttons use a microphone-bias signalling protocol instead of the resistor levels handled by the analogue detector. The CS42L83 can identify these remotes and decode their button indications without an audio stream or an external serial clock. After CTIA or OMTP detection, perform a bounded identification exchange on CS42L83. Wait for the receive acknowledgment rather than the earlier transmit-complete indication, which can expose an incomplete identifier. Validate all three identifier symbols before enabling remote reception. Restore the analogue detector on timeout, a short, an invalid identifier, or a register-access error. Preserve the receiver's raw volume indications before applying the analogue interrupt masks. Report volume indications as press/release pairs and use short-detect transitions for the centre button. Discard pre-identification button state, and clear events latched while the detector is reconfigured before unmasking its interrupts again. Restore the saved detector settings on unplug, redetection and suspend under the existing IRQ mutex, releasing any remote button still held. Select this capability from the CS42L83 device identity. No board-specific property, clock provider, work item or extra power reference is needed. The CS42L42 continues to use its analogue detector. The undocumented CS42L83 sequence was independently implemented from register-level reverse engineering and validated on a J700 with a B0 codec and Apple wired earbuds. Other boards and codec revisions have not been hardware-tested. The machine driver must expose the appropriate SND_JACK_BTN capabilities and key mappings. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Apple wired headset volume buttons and the centre play/pause button use a microphone-bias signalling protocol rather than the CTIA/OMTP resistor levels used for plug-type detection. The CS42L84 already exposes status bits for this over its microphone-detect block, but they are undocumented, unlike CS42L83's, and CS42L84 raises no known interrupt for them. Poll CS42L84_REMOTE_BUTTON_STATUS1 and the short-detect bit of HS_DET_STATUS2 at a fixed cadence while a mic-equipped headset is attached, and report press/release pairs on each rising edge, matching how the preceding CS42L83 patch reports its volume pulses. The centre button is therefore reported as a momentary press; a long press is not distinguished. The first sample after polling starts only establishes a baseline, so a line that is already shorted at detection is not reported as a press. Start polling once plug detection has settled and stop it on unplug or redetection, guarded by the same irq_lock used elsewhere for plug-state transitions. The poll runs on the freezable workqueue so it does not access the codec across system suspend, and is registered as resource-managed delayed work so it is cancelled if probe fails after a plug interrupt has already started it. The undocumented CS42L84 bits were identified by reverse engineering against a running CS42L84 on a J316 (MacBook Pro 16"), reading raw register state live via I2C while triggering the remote's buttons, and cross-checking candidate bits against the equivalent CS42L83 mechanism. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
CS42L83 and CS42L84 now decode Apple wired-headset remote presses (see the preceding cs42l42 and cs42l84 patches) and report them as SND_JACK_BTN_0..2 on the codec's jack. When CS42L83 falls back to its analogue detector for other headsets, it can also report SND_JACK_BTN_3. Request those bits on the headphone jack and map them to the usual keys so userspace sees ordinary input events: centre button to KEY_PLAYPAUSE, volume up/down to KEY_VOLUMEUP and KEY_VOLUMEDOWN, and a fourth button to KEY_VOICECOMMAND, matching other CS42L42-family machine drivers. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
force-pushed
the
remote/cs42l84-apple-headset-remote
branch
from
September 23, 2026 12:27
ffa3944 to
8d24a7d
Compare
This was referenced Sep 24, 2026
cb2206
pushed a commit
to cb2206/linux
that referenced
this pull request
Oct 5, 2026
…free drm/apple: synchronize external display buffer swaps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Apple wired-headset remote support (centre button = play/pause, plus volume up/down) across both Cirrus codec families used on Apple Silicon Macs, reported through ALSA as ordinary jack button/key events.
cs42l42_irq_thread(). It usesRPM_TRANSPARENTbecause the I2C transport never enables runtime PM.SND_JACK_BTN_0..3toKEY_PLAYPAUSE/KEY_VOLUMEUP/KEY_VOLUMEDOWN/KEY_VOICECOMMANDon the headphone jack.Should work on (codec confirmed): every M1/M2/M3 Mac, M4 (Mac Mini + MacBook Air), M4 Max (MacBook Pro), M5 (MacBook Air), and M5 Pro (MacBook Pro). CS42L83 = M1 generation (t8103) + MacBook Neo. CS42L84 = everything else above.
Unknown (codec unconfirmed): M4 Pro (same board family as the M4 Max), M5 Max (same board family as the M5 Pro).