Skip to content

ASoC/arm64: the Mac mini M4 (J773g) speaker, behind the protection lease (stacked on #2236) - #2298

Closed
DjDeveloperr wants to merge 6 commits into
mainfrom
djdev/j773g-speaker
Closed

DjDeveloperr wants to merge 6 commits into
mainfrom
djdev/j773g-speaker

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2236 (J773g headphone jack). Review the last four commits.

This adds the Mac mini M4's (J773g) internal speaker as a sound card. Its playback is gated: macaudio admits speaker playback only under a protection lease, and only speakerguardd v2 takes one. Nothing here plays sound unprotected.

The hardware

  • One SN012776 at /arm-io/i2c3/audio-speaker (0x38), mono, speaker-protection = 0, on the AOP's speaker stream.
  • The ADT's audio-speaker stream lists a TX channel (base-ns ADMAC 0) but no RX: there is no V/I sense.
  • The tuning is AID36. sgv2's reader finds its protection unit is atsp, one channel and no sense (at parity in sgv2's shipped policy).

Commits

  1. ASoC: apple: aop_spkr: a speaker stream without a sense channel. The sense ring exists only when the node names a sense DMA channel. Every user of the ring already handles its absence.
  2. dt-bindings: sound: apple,macaudio: Add J773g.
  3. ASoC: apple: macaudio: add the Mac mini M4 (J773g) speaker. Derive has_sense on AOP-fed cards from whether the speaker CPU DAI node names a "sense" DMA channel (matching aop_spkr), share macaudio_j575c_cfg for J773g instead of duplicating the config struct, and update the spk_fixed_ceiling comment to document how no-sense models governed by a feed-forward protection daemon run at 0 dB under a lease and return to the muted floor if the daemon stops renewing.
  4. arm64: dts: apple: t8132-j773g: the speaker. The card, the spkr channel, and the amp enabled with no sound-name-prefix. A mono speaker's controls go unprefixed; with the prefix, macaudio refused the card.

Testing (J773g, kernel 7.3.0 on the M4 mini stack)

  • card 0: AppleJ773g [Mac mini J773g] (Secondary = speaker) and card 1: AppleJack.
  • With has_sense derived from dma-names, J773g no longer exposes a Speaker Sense PCM.
  • Protected playback verified on J773g (26B123 firmware) with speakerguardd v2 (AID36, derived-nosense) holding the lease; without a protection owner, playback is not admitted.
  • Builds on integration/aurora 0abc2f3 with arm64: dts: apple: t8132-j773g: the headphone jack #2236 (macaudio.o, t8132-j773g.dtb).

The Mac mini has no microphones, so the AOP audio node was deleted; but
like the M4 Pro Mac mini (J773s) its headphone jack is a CS42L84 on the
AOP's jack back-end. Describe the jack's streams, "cout" and "cin" on
base-ns ADMAC channels 4 and 5 (ADT audio-codec-output and
audio-codec-input), with no "dma" channel so the AOP audio component
attaches no microphone, and a jack card of its own. The speaker stays
without a card.

Signed-off-by: Diljit Singh <hey@djdev.me>
The speaker service always took a V/I sense ring, armed on the sense DMA
channel before every power-up. The Mac mini M4 (J773g) has none: its ADT
audio-speaker stream lists a TX channel only (its RX entry is unused), and
its amp's speaker-protection is 0. Its speaker would fail to start.

Give the speaker service its sense ring only when the audio node names a
"sense" DMA channel. Every user of the ring already handles a service
without one (the jack's); the sense front-end then fails to open with
-ENODEV, as it would without the channel.

Tested on a J773g: the speaker card binds with the "spkr" channel alone, its
playback front-end opens, and opening Speaker Sense fails with -ENODEV.
Nothing was played (playback waits for a protection lease).

Signed-off-by: Diljit Singh <hey@djdev.me>
The Mac mini M4 (J773g) has its own speaker configuration (one SN012776
without V/I sense on the AOP), unlike the M4 Pro Mac mini's J773.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Tested on the owner's Mac mini J773g with the macOS 27.2 (26B123) firmware (boot dcp8, 11-20). The kernel was 010c3eb, whose J773g speaker code and DT match this PR's head. The AOP was handed over by aura#418, with the 27.2 __EDATA/ED0p support (60f279c + b224fde).

  • The AppleJ773g card registers once the AOP is ready. speakerguardd v2 (AID36, derived-nosense) reused its bound self-check and took the lease: Speaker protection interface: Speaker Protection (lease).
  • One protected playback at 5% volume: a 3 s, -30 dBFS tone into sgv2's sgv2.voicing.j773g sink, with the volume set to 0.05 and read back. The kernel logged Speaker protection granted, and speakerguardd logged protection granted, then the first 353 frames (7.4 ms) held until the amps played; 0 frames over capacity since start. The speaker PCM (card 0, pcm1p) ran (hw_ptr 68,309 → 192,074). The SN012776 power-control register went 0x82 → 0x80 only during playback, and no amp faults were logged.
  • The no DMA channel "sense" / -19 at component open is the J773g's no-sense front end that this PR describes. sgv2 handles it as derived-nosense.

Retargeting to integration/aurora so the host tests and dt-checks run (a stacked PR gets neither). The diff now includes #2236, which this PR needs anyway.

🤖 Generated with Claude Code

@DjDeveloperr
DjDeveloperr changed the base branch from j773g/headphone-jack-20261119 to integration/aurora November 21, 2026 01:04
@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 2.

The no-sense speaker service is correct. sound/soc/apple/aop_spkr.rs:1683-1688 reads the sense DMA name from the node, not the board, and the DT override drops it. The amp has no sound-name-prefix, like the J575c's single amp.

  1. sound/soc/apple/macaudio.c:2677-2679 still sets ma->has_sense from the board config (safe_vol != 0 && !spk_fixed_ceiling), so the J773g card keeps a Speaker Sense PCM that can only fail with -ENODEV. macaudio cannot tell this Mac from one with sense. Derive has_sense from the same thing aop_spkr uses: the speaker link's CPU DAI node has a sense entry in dma-names. The J773g needs nothing extra then, and macaudio_j773g_cfg (:4299-4314) becomes field-for-field identical to macaudio_j575c_cfg (:4257-4272). Point apple,j773g-macaudio at that one, or give both a shared config, rather than adding a copy.
  2. macaudio.c:186-191 documents that without V/I sense the SN012776 volumes stay under safe_vol even when granted (spk_fixed_ceiling). This config has no sense and leaves that flag off, so a granted lease runs the amp at 0 dB (macaudio_spk_gain(), :1040-1042), protected only by the feed-forward unit. The driver now contradicts its own comment. Update that comment to say how a no-sense Mac is governed under a lease and what keeps it muted if the daemon dies mid-stream.

Nit: the PR body quotes a full-scale figure taken from the macOS tuning. Remove it: it is not needed to review the kernel side. The body's last line should be Assisted-by: LLM (<Vendor>:<Model>), not "Generated with Claude Code".

HW row: J773g on this head, default command line. One protected playback as already done. Then kill speakerguardd mid-stream: the stream stops and the amp reads back the floor within the lease. Restart it and the lease is taken again. Also one s2idle cycle with the card present. Pass needs 0 amp faults, 0 failed units, 0 AVC and 0 new kernel errors. Land #2236 first (this diff contains it).

Assisted-by: LLM (Claude:Opus 5.5)

One SN012776 on the AOP's speaker stream: the J616s/J713 frame (250 BCLKs
of 12 MHz, six 32-bit playback slots, which the firmware runs whole), the
amp on the first slot, and no sense channel.

Derive has_sense on AOP-fed cards from whether the speaker CPU DAI node
names a "sense" DMA channel (matching aop_spkr), so J773g does not expose
a broken Speaker Sense PCM and shares macaudio_j575c_cfg with J575c
rather than duplicating the config struct. Update the spk_fixed_ceiling
comment to document how no-sense models governed by a feed-forward
protection daemon run at 0 dB under a lease and return to the muted floor
via spk_lease_timer / spk_stop_worker / spk_expire_work if the daemon
stops renewing.

Tested on a J773g: the card "Mac mini J773g" registers with its Secondary
(speaker) playback device next to the jack's card; with no protection
owner, playback is not admitted.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Addressed both blockers and the PR body nit (head 4defe7a7f):

  1. Derived ma->has_sense on AOP-fed cards from whether the speaker CPU DAI node (link->cpus->of_node) has a "sense" entry in dma-names (matching aop_spkr), while keeping MCA-fed cards unchanged. Removed the duplicate macaudio_j773g_cfg and pointed apple,j773g-macaudio at &macaudio_j575c_cfg.
  2. Updated the spk_fixed_ceiling comment in sound/soc/apple/macaudio.c to explain how no-sense models governed by a feed-forward protection daemon run at 0 dB under a lease and return to the muted floor (0) via spk_lease_timer -> spk_stop_worker -> spk_expire_work if the daemon stops renewing.
  3. Removed the macOS tuning full-scale figure from the PR body and replaced the footer with Assisted-by: LLM (...).

Local checks: per-commit scripts/checkpatch.pl --strict (0 errors) and LLVM/clang compile of sound/soc/apple/macaudio.o + apple/t8132-j773g.dtb pass.

Assisted-by: LLM (Gemini:4 Neon)

On Macs whose AOP speaker stream has no V/I sense channel (such as the
Mac mini M4, J773g), the audio node lists only "spkr", "cout", and "cin"
in dma-names. Allow that combination in the binding.

Signed-off-by: Diljit Singh <hey@djdev.me>
The speaker card: the AOP audio component's speaker back-end (DAI 3) to the
SN012776 (ADT /arm-io/i2c3/audio-speaker at 0x38), on base-ns ADMAC channel 0
("spkr", ADT audio-speaker; no "sense", its RX entry is unused). The amp is
enabled and takes no sound-name-prefix: a mono speaker's controls go
unprefixed, as macaudio expects (it refused the card with "Speaker HPF
Corner Frequency"). Playback waits for a protection lease.

Tested on a J773g together with the previous commits: card 0 "Mac mini
J773g" (speaker) and card 1 the jack. Nothing was played.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Fixed the dt-checks failure in 5047b15c3: added the ["spkr", "cout", "cin"] dma-names variant (speaker stream without V/I sense, plus headset jack, no microphones) to Documentation/devicetree/bindings/sound/apple,t6041-aop-audio.yaml.

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Both points from the last review are on the head. has_sense now follows the speaker CPU DAI's sense DMA name, apple,j773g-macaudio reuses macaudio_j575c_cfg, and the spk_fixed_ceiling comment describes how a no-sense Mac is governed and muted when the lease lapses. dt-checks passes with the new spkr/cout/cin dma-names variant. Still open: the J773g row that kills speakerguardd mid-stream (stream stops, amp at the floor within the lease, lease taken again on restart) plus one s2idle cycle. #2236 needs to land first.

@github-actions github-actions Bot added area:audio Area from CODEOWNERS (bot) area:bringup Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026
@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 5047b15c3.

Blockers:

  1. sound/soc/apple/macaudio.c:193: The new comment promises that the amp reaches the floor within the lease window. On expiry, the timer closes the start gate and queues the stop and floor work. The floor worker can still wait on the speaker mutex and card power. Please describe the two timings separately and measure expiry-to-stream-stop and expiry-to-amp-floor on the reviewed stack. Exercise renewal loss with the owner still present as well as owner exit and s2idle. Owner exit can take the separate close/release path, so it alone cannot validate expiry. The existing low-volume playback row establishes admission during a lease.
  2. Remove the AI attribution from the PR body. Resolve the base conflict after #2236 and rerun the protected-playback and regression checks on the resulting commit.

Checked: Read the diff and signed commit messages, the AOP binding alternatives, the DT channel ordering, the shared config and the lease stop/floor paths. The no-sense detection follows the DMA property, and the three channel names match the added schema variant. Hosted dt-checks and host-tests passed at the reviewed commit. The safety timing above remains unverified.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merge readiness at 5047b15c: not ready yet

Check Detail
CI at head ok 2 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 5047b15c, a Mac and a result in the PR body or a comment
Conflicts no merge conflicts with main: merge it in (no force push)
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:audio, area:bringup

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 1, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Closing this as stale. It has conflicted with main since 11-24, and the requested changes from 11-28 are still open:

  • describe and measure the two speaker-safety timings separately: lease expiry to stream stop, and lease expiry to amp floor;
  • exercise renewal loss with the owner still present, owner exit, and s2idle;
  • remove the attribution line from the body.

These need J773g speaker-safety runs, and the PR is stacked on #2236, which hasn't landed. The branch stays. Reopen this PR, or open a new one, once #2236 is in and the speaker-safety row is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:audio Area from CODEOWNERS (bot) area:bringup Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants