Repository navigation
ASoC: apple: t8140-aop-audio: hide the internal mics while the lid is closed - #354
Merged
Merged
Conversation
The low-power microphone's report path copies a span into the ALSA buffer and then advances hw_ptr_frames; the .pointer callback returns that value. ALSA calls .pointer from a status or HWSYNC request on another CPU, with the PCM stream lock held but not the driver's stream state lock, so the copy and the pointer are only ordered by the atomic itself. Both sides used relaxed accesses, which order nothing else: on arm64 a reader can see the new pointer before the frames behind it, and hand userspace stale buffer contents as captured audio. Store the pointer with release after the copy, and load it with acquire in .pointer. The resets at open and prepare publish a pointer too and use release as well. This is the message-passing pattern of the Linux kernel memory model's MP+pooncerelease+poacquireonce test (forbidden), where the relaxed form, MP+poonceonces, is allowed. Fixes: eeb1126 ("ASoC: apple: Add T8140 AOP audio driver") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Rust code that has to take a spinlock owned by C code, one that the C side takes with interrupts saved, has no way to do so: the helpers only cover spin_lock() and spin_unlock(). An input handler resynchronizing with its device's switch state is one such user: the input core delivers events with dev->event_lock held and interrupts off, and a handler reading the device's state outside of an event must hold the same lock. Add the irqsave/irqrestore pair, returning the flags to the caller. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
…closed
Closing the lid of the MacBook Neo (J700) disconnects its internal
microphones in hardware. Nothing tells the AP: the array then reads
back as digital silence and the low-power microphone as a constant near
negative full scale, and userspace keeps offering both as working
microphones. A meeting app recording in clamshell mode with an external
display records nothing, and never falls back to a microphone that
works.
The lid switch is already an input device ("Apple SMC power/lid events",
SW_LID, from macsmc-input). Follow it with an input handler, as
hid-appletb-kbd and the input-events LED trigger follow other input
devices, and report the result as a microphone jack on the card,
"Internal Mic Jack": unplugged while any lid switch reads closed. The
handler is a passive observer, so it does not open the device on its
own; macsmc-input reports lid changes whether or not it is open.
Every update of a switch's recorded state happens under that device's
event lock: the input core delivers events with it held, and the
handler reads the device's switch state with it held when it connects
(after opening the handle, so no event falls in between) and from its
start() callback, which the input core calls when a client that grabbed
the device releases it. A reading can therefore never overwrite a newer
event, and events a grabbing client kept to itself are caught up with.
Readings only count once the handle is open: the input core calls
start() while registering the handle, before the handler knows whether
opening it succeeds, and a handle that fails to open is freed without a
disconnect. A lid switch that goes away no longer counts as closed.
The count of closed switches is the only state shared between switches.
snd_jack_report() takes mutexes and is not ordered against other
callers, so a single work item makes every report, including the
initial one, which probe queues and flushes before registering the
card: reports reach ALSA in the order of the states they read. The
jack has no input device of its own: the lid it follows already is one,
and the control is what userspace reads.
With UCM naming the jack as the microphone's JackControl, PipeWire and
PulseAudio mark the microphone port unavailable, switch the card's
profile off and fall back to another source; when the lid opens the
profile, the node and the user's default source come back. Without
such a JackControl nothing changes.
[ryan: rebased onto aurora-wip 0daed2d + ATC PIPE park v3. #345
(harden-all) added the parser_tests and name_tests KUnit modules at the
end of t8140_aop_audio.rs, where this patch adds lid_tests: kept both,
lid_tests last. The added lines are those of the reviewed patch.]
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
added a commit
that referenced
this pull request
Oct 17, 2026
Bring the 7.2.10 assembly to the tree of the canonical top-up #7 assembly, stacked on top-up #6a 40a2ec8 so that it is a fast-forward of that publish head. The second parent is that canonical assembly; the tree is identical to it. Ported from aurora-wip, each commit with cherry-pick -x and its original author: - #306: aurora_j700_defconfig, regenerated for 7.2.10 with savedefconfig from the published 7.2.10 J700 configuration (900-config-tooling); - #354 (j700/clamshell-mic-v4), 3 commits: the LPAI pointer published after its frames, the spin_lock_irqsave() Rust helpers, and the mics reported unplugged with the lid closed (070-audio); - #355 (j700/tipd-hpd-pulse-v2), 9 commits: the CD321x DisplayPort hotplug decisions, their trace events and KUnit tests (170-usb), and the apple-dcp selftests that compile them (200-dcp); - #356 (fix/rust-dmabuf-xarray-20261018): the dma_buf stub gated on built-in DRM and the xarray KUnit values allocated before xa_lock (210-gpu, with the Fixes: tags of the 7.2.10 base); its dma-resv backport is already in asahi-wip; - #357 (fix/sep-followups-20261018), 7 commits: dma_wmb()/dma_rmb() for Rust, the SEP shared buffers ordered against the mailbox, the hwrng and sleep glue and its tests, and the trusted-keys built-in source fixes (100-sep). Our own 7.2-native commits, not on aurora-wip (100-sep): the Rust system_dfl_wq wrapper, and the SEP, Asahi DRM and binder work moved off the deprecated system_wq. Their AOP change is not carried: the 070-audio AOP driver already registers its services on its own ordered queue. Adaptations, each with a [ryan: ...] note in its commit: - the AOP lid tests go after the parser tests, where 7.2.10 has the name tests (context only); - trusted_key_core_done goes next to 7.2.10's trusted_key_source_migratable (context only); - the defconfig is regenerated, not picked; its note lists the 62 lines that differ from the 7.1 file, none of them a J700 setting. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
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.
With the lid closed, the MacBook Neo's internal microphones are covered, and they used to keep presenting as the default capture source. This series lets the AOP audio driver report the internal mics as unplugged while the lid is closed, through a standard ALSA jack (
Internal Mic Jack). UCM and PipeWire then hide the source and bring it back when the lid opens.Commits
Testing
f001934351ed. The only conflict was test-module placement next to apple: hardening sweep (AFK/AOP ring bounds, DART flush, DCP, qspi resume) #345's tests; the code is identical to the reviewed patch.Internal Mic Jackwas off whenever the lid was closed and on whenever it was open, in every 1 s sample, within 0.4–1.4 s;🤖 Generated with Claude Code