Skip to content

ASoC: apple: macaudio: run the J873 speaker under a fixed -16 dB ceiling - #1862

Open
sithglan wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
sithglan:thomas/j873-speaker-ceiling
Open

sithglan wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
sithglan:thomas/j873-speaker-ceiling

Conversation

@sithglan

@sithglan sithglan commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Rebased on integration/aurora, which has #1884 (the spk_fixed_ceiling mechanism, split out of this PR) merged. Only the J873 commit is left. Per the speaker-safety rule this waits for the project owner's sign-off on the level.

The J873 (Mac mini M6) speaker has been off on integration: "no qualified speaker protection exists for J873 yet". It can't get that protection the way J813 did, because no sense data reaches Linux.

The AOP firmware runs the speaker stream, and the ADT's stream descriptor for it (iop-audio-controller/audio-speaker reg) has no receive side. Compared with J813:

J813 J873
TX slot mask 0x0f 0x01
RX slot mask 0xff 0x00
TX / RX slots 4 / 8 1 / 0
RX slot width 16 0

Both run a 12 MHz BCLK with 250 BCLKs per frame. The amp's V/I sense never reaches the AP, and the ADT gives the amp speaker-protection = 0, so macOS runs no closed-loop protection on the mini either. I checked this on hardware: aurora speakersafetyd takes the controls on J873, then can't open a sense stream.

This admits the speaker under #1884's spk_fixed_ceiling at -16 dB: enable_speakers = true, safe_vol = -16, spk_fixed_ceiling = true, and the KUnit admission expectation. The first version proposed -15 dB. Its thermal case only considered a sine, and the worst signal is a square wave (see below).

Power and thermal

  • At the ADT's amp level (15 = 18.5 dBV), full scale is 11.9 V peak. Into 4.6 Ω, the impedance of speakersafetyd's Mac mini (J274) mono model, that is:
    • 30.8 W for the worst signal, a full-scale square wave;
    • 15.4 W for a full-scale sine.
  • At -16 dB that is 0.77 W for the square wave and 0.39 W for the sine.

The J873 ADT has no thermal data for its speaker, so the thermal side uses that same J274 model:

J274 model
thermal resistance, coil / magnet 40 / 60 K/W
time constant, coil / magnet 3.7 / 250 s
ambient 46 °C
coil limit (t_limit) 140 °C, reached at a continuous 0.94 W
speakersafetyd starts cutting gain at 120 °C (t_limit - t_window)

Steady coil temperature at the ceiling, for continuous full-scale signals:

Signal Power Coil (≈)
square wave, kernel ceiling alone (raw ALSA) 0.77 W 123 °C
sine 0.39 W 85 °C
anything through the PipeWire chain (peaks held at -1 dBFS) at most 0.61 W at most 107 °C
  • The worst case settles 17 °C below the model's limit, and gets within 5 % of that after about 12 minutes, three magnet time constants. It takes no userspace to hold it there.
  • Comparison with speakersafetyd: at its limit, speakersafetyd cuts a speaker of this model to its floor gain, min_gain. At this amp level that is 10·log10(0.94 W / 30.8 W) = -15.2 dB, the gain that holds a full-scale square wave at 0.94 W. The ceiling sits 0.8 dB below that floor.
  • What -15 dB would have done: a full-scale square wave would have been 0.97 W, and the coil would have settled near 143 °C, over the limit.

The caveat: this is the J274's speaker model, not a measured J873 one.

PipeWire high-pass and limiter

aurora-silicon/asahi-audio#28 is the userspace half. It wraps the raw speaker node in a graph:

  • a stereo-to-mono downmix;
  • a 4th-order Butterworth high-pass at 100 Hz, which keeps the drive below 100 Hz under the J274 graph's at every frequency;
  • the LSP true-peak limiter at -1 dBFS that ends the other graphs.

It is measured on the J873g there.

Testing

On the J873g (M6), using a DT that carries the ADT's apple,speaker-config, apple,bop-config and apple,amp-dcblocker-config (what aura's kboot_audio passes).

At -16 dB, with this macaudio on the M6's integration kernel:

  • "Speaker Volume" tops out at 169 (-16.0 dB), and writing 201 (0 dB) is clamped to 169.
  • With "Speaker Protection Interface" on the lease, a grant reads back 1 and puts "Speaker Volume" at 169. A -40 dBFS tone then plays through asahi-audio#28's filter sink across 51 renewals, with none failing. A withdrawal puts the volume at 0, and speaker_starts_refused stays 0.

At -15 dB, with the #1797 stack (2026-11-13/14):

  • The speaker is admitted. The card has no Speaker Sense PCM, and PipeWire sees the speaker sink.
  • The same lease run passes (52 renewals). A 200 Hz tone on the speaker PCM powers the amp (DAPM OUT on), and dmesg shows no amp faults.

The six apple-speaker KUnit suites pass at -16 dB (arm64, QEMU: 60 tests).

Not in this PR

  • HW_CFG_T8152 in t8152_aop_audio.rs still declares two sense channels, and the J873 DT still has a sense DMA on RX1. Both are dead, given the descriptor above; macaudio no longer links them.
  • The M6's self-booting aura Stage 1 predates kboot_audio. Until it has it, the speaker stays off there ("the boot loader passed no amp levels").

cc @joshuaswarren

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the ADT comparison and the careful write-up. The mechanism itself looks right to me: spk_fixed_ceiling keeps the SN012776 volumes under safe_vol in the locked, unlocked and leased states, with no sense PCM. The -15 dB arithmetic also checks out: 8.41 Vrms at full scale is 15.4 W into 4.6 Ω, and -15 dB brings that to about 0.49 W.

I can't merge it as it stands, though, because of this tree's speaker-safety rule. A change may keep a speaker's limits or lower them. Anything that raises one needs explicit sign-off from the project owner and a speaker-safety qualification first, and speaker tests aren't part of review. Here the J873 speaker goes from not admitted (enable_speakers = false, safe_vol = 0) to admitted at a -15 dB ceiling with no closed-loop protection.

Could you split it into two?

  1. The mechanism alone: the spk_fixed_ceiling flag and its handling, with no board config setting it, so it changes nothing on any current machine. I'm happy to review that for merge on its own.
  2. Enabling J873: enable_speakers = true, safe_vol = -15, spk_fixed_ceiling = true and the KUnit expectation. This waits for the owner's sign-off on the level. It would help to include the thermal side: a continuous full-scale signal at 0.49 W against a 0.94 W rating has no thermal model behind it. The PipeWire high-pass/limiter chain the description mentions would also belong with it.

One technical note on the mechanism. As far as I can tell, with spk_fixed_ceiling set, macaudio_spk_gain(ma, true) still returns SN012776_0DB, which is above the new platform_max. The volume control's put then fails with -EINVAL (soc_mixer_valid_ctl()), and a "Speaker Protection" grant drops straight to the floor with "operating gain not set". That fails safe, but the log reads like a fault. It would be clearer either to return the ceiling there or to refuse the lease explicitly on fixed-ceiling machines.

@sithglan

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr thanks. I split it as you suggested:

  1. ASoC: apple: macaudio: add a fixed speaker ceiling for machines without sense #1884 is the mechanism alone. No board config sets it, so it changes nothing on any current machine.
  2. This PR is now only the J873 enablement, stacked on ASoC: apple: macaudio: add a fixed speaker ceiling for machines without sense #1884 (review the last commit). It waits for the owner's sign-off on the level.

You were right about the lease. Our hardware run switched the interface to the lease and back but never granted one, so it missed the bug. In #1884 a fixed-ceiling machine's operating gain is its ceiling: a grant now runs the amps at safe_vol instead of failing to the floor. The withdrawal ramp also skips the steps at or above the ceiling (-2 to -12 dB for J873), which would have failed the same way. A new KUnit case covers both, and it fails with the two changes reverted.

The thermal side is in the description and in the commit message. The J873 ADT has no thermal data, so it uses speakersafetyd's Mac mini (J274) model:

  • A continuous full-scale sine at -15 dB (0.49 W) settles the coil at about 95 °C.
  • That is 25 °C below the 120 °C where speakersafetyd starts cutting gain on that model, and 45 °C below its 140 °C limit.
  • At this amp level, speakersafetyd's own floor gain for that model is -15.2 dB. So the ceiling is about where the daemon itself would hold a hot speaker.

The PipeWire high-pass and limiter chain isn't in here yet.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Status from the contributor PR sweep: #1884 (the mechanism) is merged.

This PR raises the J873 speaker from not admitted to admitted at a -15 dB fixed ceiling, with no closed-loop protection. Under the tree's speaker-safety rule that needs the project owner's explicit sign-off on the level, as the review said, so it stays open and isn't merged here. Once you rebase it on integration/aurora, only the J873 commit will remain.

The J873 speaker cannot be protected the way the other SN012776 Macs
are. The AOP firmware runs its speaker stream, and that stream has no
receive side: the ADT's iop-audio-controller/audio-speaker descriptor
has no RX slots, where J813's has eight 16-bit ones. The amp's
voltage and current sense therefore never reach the AP. The ADT also
marks the amp with speaker-protection = 0, so macOS runs no closed-loop
protection on the Mac mini either. Without sense, no protection daemon
can govern the speaker, so it has stayed off.

Admit it under spk_fixed_ceiling at -16 dB. At the amp level its ADT
gives (15, 18.5 dBV), full scale is 11.9 V peak. Into the 4.6 ohms of
speakersafetyd's Mac mini (J274) speaker model, the worst signal, a
full-scale square wave, is 30.8 W; a full-scale sine is half that. At
-16 dB they are 0.77 W and 0.39 W.

The J873 ADT carries no thermal data for its speaker, so the thermal
side comes from that model: thermal resistances of 40 K/W (coil) and
60 K/W (magnet), time constants of 3.7 s and 250 s, a 46 C ambient and a
140 C coil limit, which a continuous 0.94 W reaches. A continuous
full-scale square wave at the ceiling settles the coil at
46 + 0.77 * 100 = 123 C, within 5% of that after about 12 minutes
(three magnet time constants): 17 C below the limit. A full-scale sine
settles at 85 C. At its limit speakersafetyd cuts a speaker of that
model to its floor gain, -15.2 dB at this amp level, which holds a
square wave at 0.94 W. The ceiling sits 0.8 dB below that floor.

The speaker still needs its apple,speaker-config from the boot loader,
as on the other SN012776 machines.

Tested on the J873g (M6) with the integration kernel and a DT carrying
the ADT's amp properties, at -15 dB:
- the speaker is admitted, and there is no Speaker Sense PCM;
- "Speaker Volume" tops out at 171 (-15 dB) at bind, and a write of 201
  (0 dB) is clamped;
- with the "Speaker Protection Interface" on the lease, a grant puts
  "Speaker Volume" at 171 and a quiet tone plays under 52 renewals; a
  withdrawal puts it at 0;
- a 200 Hz tone on the speaker PCM powers the amp (DAPM OUT on), and
  speaker_starts_refused stays 0.
At -16 dB, with this macaudio on the M6's integration kernel: the limit
is 169, a write of 201 is clamped to it, and a grant puts the volume at
169 while the tone plays (51 renewals).

The apple-speaker KUnit suites pass with the J873 admission expectation
changed (arm64, QEMU: 60 tests).

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan force-pushed the thomas/j873-speaker-ceiling branch from d543077 to d032b1a Compare November 14, 2026 12:58
@sithglan sithglan changed the title ASoC: apple: macaudio: run the J873 speaker under a fixed ceiling ASoC: apple: macaudio: run the J873 speaker under a fixed -16 dB ceiling Nov 14, 2026
@sithglan

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr this is rebased on integration/aurora, so only the J873 commit is left. Since my last reply there are three changes:

1. A correction to my thermal reply, and a lower ceiling. I worked the thermal case for a full-scale sine. The worst signal is a full-scale square wave, which has twice the power. At -15 dB that is 0.97 W, and the J274 model settles the coil near 143 °C, over its 140 °C limit. So the PR now proposes -16 dB:

Signal at -16 dB Power Coil (J274 model)
full-scale square wave, raw ALSA 0.77 W ≈ 123 °C
full-scale sine 0.39 W ≈ 85 °C
anything through the PipeWire chain (peaks held at -1 dBFS) ≤ 0.61 W ≤ 107 °C

The kernel ceiling alone keeps the worst case 17 °C under the limit. speakersafetyd's own floor for that model is -15.2 dB, the gain that holds a square wave at the limit, and -16 dB is 0.8 dB below it. The description and the commit message are updated. The level still waits for the owner's sign-off.

2. The PipeWire high-pass and limiter chain is aurora-silicon/asahi-audio#28. It's a mono downmix, then a 4th-order Butterworth high-pass at 100 Hz, then the LSP true-peak limiter at -1 dBFS. There is no J873 speaker data, so the high-pass corner is chosen so that, at every frequency below 100 Hz, it drives the speaker less than the J274 graph drives the M1 Mac mini's. Measured on the M6 from the graph's output, with the amp muted:

  • 30/50/70/100 Hz come out at -41.8/-24.1/-12.6/-3.0 dB.
  • Full-scale input peaks at -1.00 dBFS.

3. The lease now passes on hardware. With "Speaker Protection Interface" on the lease:

The apple-speaker KUnit suites pass at -16 dB (60 tests).

sithglan added a commit to sithglan/asahi-audio that referenced this pull request Nov 14, 2026
The J873's speaker has no V/I sense: the AOP speaker stream has no
receive side, so neither speakersafetyd nor speakerguardd can run.
aurora-silicon/linux#1862 proposes to admit it under a fixed -16 dB
kernel ceiling instead, and its review asked for the userspace part to
go with it.

firs/j873/graph.json downmixes the stereo sink to the mono speaker PCM
(L/2 + R/2). A 4th-order Butterworth high-pass at 100 Hz (two biquads)
follows, then the LSP true-peak limiter at -1 dBFS that ends the other
graphs. There is no measurement of this speaker, so there is no FIR, no
bass extension and no loudness compensation.

Below 100 Hz the high-pass drives the speaker less, at every frequency,
than the J274 graph drives the M1 Mac mini's speaker. The limiter
catches the high-pass's overshoot on full-scale input, and a sink
volume above 100 %, since the volume is a software gain ahead of the
graph.

The rule matches hw:AppleJ873,1. There is no J873 UCM profile yet, so
README.J873.md shows the PipeWire object that stands in for the raw
node until there is one. The Makefile installs j873.

Tested on the J873g with that object, the rule and the graph installed:
- WirePlumber builds the filter sink, hides the raw node and makes the
  filter the default sink.
- Recorded from the graph's output with the amp muted, for full-scale
  input: 30, 50, 70 and 100 Hz come out at -41.8, -24.1, -12.6 and
  -3.0 dB, matching the Butterworth response. 150 Hz to 5 kHz sines
  peak at -1.00 dBFS, a 200 Hz square wave at -1.25 dBFS. One channel
  alone comes out at -6.0 dB.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants