Skip to content

ASoC: apple: macaudio: lease-only fixed ceiling, held only at its amp level - #1862

Merged
RyanTheTide merged 2 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/j873-speaker-ceiling
Nov 23, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/j873-speaker-ceiling

Conversation

@sithglan

@sithglan sithglan commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Split as Ryan suggested: the lease-only commit and the amp-level check, with the J873 left at enable_speakers = false. Based on integration/aurora f44bf7af65ea, which has #1884 (the spk_fixed_ceiling mechanism); merges cleanly on the current tip. No board sets spk_fixed_ceiling after this PR, so no speaker's behaviour changes.

  1. Lease-only fixed ceiling (3fa618e, unchanged). On a machine with spk_fixed_ceiling, the speaker stays at the floor while locked, and "Speaker Volume Unlock" lifts nothing there. Only a "Speaker Protection" lease raises the limit, and only to safe_vol, the gain a grant runs the amps at.
  2. A fixed ceiling holds only at its amp level (226c790). A fixed ceiling is a volume computed for one amp level, which the driver takes from each SN012776 amp's apple,speaker-config. At another level the same volume drives the speaker differently. The ceiling now names its level (spk_ceiling_level), the level read is logged, and at any other level the speakers stay off.

The J873 enable: a follow-up

The enable (safe_vol = -16, spk_fixed_ceiling, spk_ceiling_level = 15, lease-only) is kept for a follow-up PR, together with its power and thermal case: the J274 speaker model, a full-scale square wave at 0.77 W, and the coil settling at 123 °C against the model's 140 °C limit. It follows once the boot loader hands the kernel a limit from the machine's own speaker data. The -16 dB constant has no source in the J873's data, which was the open blocker here.

Background, unchanged:

  • The J873's AOP speaker stream has no receive side (ADT stream RX slot mask 0x00, where J813's is 0xff).
  • The amp has speaker-protection = 0, and no sense PCM reaches Linux.
  • speakerguardd's side is speakerguardd#222.

Testing

  • The Apple sound KUnit suites pass (arm64, QEMU): 72 tests.
    • The admission case checks the lease-only limit: the floor whether locked or unlocked without a lease, safe_vol only unlocked under a lease.
    • The fixed-ceiling protection case checks that an unlock leaves the amps at the floor.
    • The new amp-level case runs with a test-only fixed-ceiling config at level 15. It admits an amp at 15 and refuses a link with an amp at 7 or one without a level.
    • The J873 admission expectation is unchanged: speaker off.
  • Negative controls:
    • With the old limit (safe_vol in every state), the admission and protection cases fail.
    • With the level check dropped, macaudio_levels_fixed_ceiling fails (71/72).
  • macaudio.o builds with W=1 and no warnings. checkpatch --strict is clean on both commits (the amp-level test now uses a small helper).
  • No speaker was driven for this version. The earlier J873g lease runs (at -15 and -16 dB) belong to the follow-up.

cc @joshuaswarren

Assisted-by: LLM (Claude:Opus 5.5)

@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.

@sithglan
sithglan force-pushed the thomas/j873-speaker-ceiling branch from 66e221d to d543077 Compare November 14, 2026 11:25
@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 <[email protected]>

@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, Thomas. The -16 dB rework is careful work: the square-wave correction, the thermal table and asahi-audio#28. The lease fix that went in with #1884 reads right too.

I can't merge it, and the reason now goes beyond the level itself. Our speaker rule is that nothing produces audible output except through speakerguardd. With spk_fixed_ceiling, macaudio_vlimit_unlock() holds the SN012776 volumes at safe_vol in the locked state as well (sound/soc/apple/macaudio.c:537-538 on integration/aurora). So with this PR, raw ALSA can drive the J873 speaker at -16 dB with no daemon running at all. Every other SN012776 speaker stays at the floor (max = 1) until a protection daemon unlocks it or speakerguardd grants a lease.

The tree already says how a speaker without sense should run. The J775 comment (macaudio.c:4075-4087) says such a speaker "can only be run under a protection lease held by speakerguardd with a no-sense model, as on the J773g". speakerguardd has that path now: the derived no-sense wiring from speakerguardd#212.

What would make this mergeable:

  1. Kernel: on fixed-ceiling machines, keep the locked state at the floor. Only a speakerguardd grant should lift the amp, and then only to safe_vol. #1884 already sets the operating gain to the ceiling for a grant, so this is mostly the locked branch of macaudio_vlimit_unlock(). The KUnit admission case would then check "admitted, lease only".
  2. speakerguardd: a J873 no-sense model (the J873 counterpart of #212) with -16 dB as its hard cap, and with the asahi-audio#28 high-pass in the protected graph.
  3. The level: the thermal case still rests on the J274 model, not on a J873 measurement. As a ceiling argument that's reasonable, but the owner's sign-off on the level is still needed, as in the first review.

Happy to review the reworked kernel half as soon as it's up.

A machine with spk_fixed_ceiling has no sense path, so no protection
daemon can hold its speakers. Its SN012776 volumes have sat at safe_vol
in the locked state as well, so raw ALSA could drive the speaker at that
level with no daemon running. Every other SN012776 speaker stays at the
floor until a protection daemon unlocks it or a "Speaker Protection"
lease is granted.

Keep these speakers at the floor while locked, and leave them there for
"Speaker Volume Unlock": only a "Speaker Protection" lease lifts the
limit, and only to safe_vol, which a grant already uses as the operating
gain. macaudio_sn012776_vlimit() computes the limit. The admission KUnit
suite checks it, and the fixed-ceiling protection case now also checks
that an unlock leaves the amps at the floor.

No machine sets spk_fixed_ceiling yet.

Signed-off-by: Thomas Glanzmann <[email protected]>
@sithglan
sithglan force-pushed the thomas/j873-speaker-ceiling branch from d032b1a to 61fefdb Compare November 20, 2026 12:46
@sithglan

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr thanks. The kernel half is up: 61fefdb4d50d, rebased onto integration/aurora f44bf7af65ea, now two commits.

1. "ASoC: apple: macaudio: lift a fixed ceiling only for a speaker lease" (no machine sets the flag):

  • macaudio_sn012776_vlimit(cfg, unlock, leased) computes the SN012776 limit. On a spk_fixed_ceiling machine it is the floor (max = 1) locked, and also unlocked without a lease. Only unlocked under a "Speaker Protection" lease is it safe_vol.
  • macaudio_vlimit_unlock() uses that with macaudio_spk_leased(). macaudio_vlimit_update() returns early on such a machine, so "Speaker Volume Unlock" never reports the speakers unlocked there.
  • A grant still sets the operating gain to the ceiling (ASoC: apple: macaudio: add a fixed speaker ceiling for machines without sense #1884, unchanged), so only a speakerguardd grant lifts the amp, and only to safe_vol.

2. The J873 enable: the config comment and commit message now say it is lease-only. The J775 comment no longer calls the J873 speaker off.

KUnit (arm64, QEMU): the six apple-speaker suites pass, 61 tests.

  • Admission: the J873 is admitted and lease-only (macaudio_spk_lease_only()). A new case checks the limit for each combination of locked, unlocked and leased, against a J813 control that unlocks to 0 dB.
  • Protection: the fixed-ceiling case now checks that an unlock on the "Speaker Volume Unlock" interface leaves the amps at the floor, before the lease takes them to the ceiling.
  • Negative control: with the old limit (safe_vol in every state), both cases fail.

macaudio.o builds with W=1 and no warnings, and checkpatch --strict is clean on both commits.

The J873 hardware runs in the description are from before this change, when the ceiling applied in every state; the lease path they used is unchanged. A J873g run on this head comes with the speakerguardd model, since without it nothing lifts the speaker.

speakerguardd: I'll write the J873 no-sense model next, as a speakerguardd PR on the derived-nosense path from #212. One question about its basis first. #212's J773g model came from its macOS tuning. The J873 ADT marks the amp speaker-protection = 0, so macOS may ship no protection tuning for AID48 at all. I'll check that in a macOS 27.2 install.

  • If there is a tuning, the model is derived from it as on the J773g, with -16 dB as the hard cap and asahi-audio#28's high-pass in the protected graph.
  • If there isn't, the only thermal basis is the J274 model the kernel commit uses. Would you take a J873 profile built from that for the lease? Or should the J873 speaker wait until there is a measured J873 model?

The level still needs the owner's sign-off, as you say.

@sithglan

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr follow-up to my question: macOS does ship a protection tuning for the J873, so the second case doesn't arise.

I read the M6's macOS 27.2 System volume with speakerguardd's apfs_ro, read only. Tunings/AID48 has the speaker graph (builtin_speaker_out.dspg) and three general strips (one default, two selected by speaker ID). All of them carry an atsp unit, one speakerguardd already compiles, and no sense unit. For comparison, the J813's AID42 carries lsm2 with lsid.

So the J873 model can be derived from the Mac's own tuning, the derived-nosense way #212 does for the J773g. Its hard cap is -16 dB, and asahi-audio#28's high-pass sits in the protected graph. Next I'll run a dry run of aurora-speaker-upgrade --check on the J873g (collect and compile, nothing played or switched). The strips select by speaker ID, so it also needs /chosen/asahi,speaker-id from the boot chain. Anything that plays through the speaker waits for the owner's go.

@sithglan

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr the speakerguardd half (your point 2) is up as aurora-silicon/speakerguardd#222:

  • Wiring: the T8152 AOP transport carries no V/I sense, so the J873g runs AID48's atsp unit on soc: apple: T8140 PMC voters, CLPC DCS/fabric floors and GFX PMP report #212's derived-nosense path, for its one amp.
  • The -16 dB hard cap: it is a per-board operating volume in gate.json, which the self-check records. The supervisor grants only while the amp sits at exactly -16 dB, and anything else latches. Without this, the first grant on this PR's kernel would latch, because the supervisor wants 0 dB.
  • The high-pass: asahi-audio#28's 4th-order Butterworth at 100 Hz sits in the protect stage, in front of the unit.

On the J873g, read only:

  • The Mac's own macOS 27.2 tuning collects and compiles (Atsp, 1 channels, 0 sense, full scale 11900 mV).
  • The live device tree derives derived-nosense (card AppleJ873, wiring d1d62e8a0aaaef3d).
  • "Amp Gain Volume" reads 15, the blob's operating point (11.89 V peak).

The self-check and a supervised grant need this PR's kernel with CONFIG_SND_PROC_FS. The grant plays through the speaker, so it waits for the owner's go, and the level still needs the owner's sign-off.

@sithglan

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr The owner signs off on -16 dB as the J873 speaker's fixed ceiling. The owner listened to it on the J873g tonight under speakerguardd#222's lease: loud, with no distortion.

Kernel. It's the J873g's running kernel source with this PR's macaudio change applied, 7.3.0-aurora-j873-spk1862+:

  • the lease-only limit from 61fefdb4d50d: macaudio_sn012776_vlimit(), macaudio_spk_lease_only() and the early return in macaudio_vlimit_update();
  • plus CONFIG_SND_PROC_FS, which speakerguardd reads.

Without a lease:

  • After boot, "Speaker Volume" sits at the floor (raw 1), with "Amp Gain Volume" at 15. The interface is "Speaker Volume Unlock", which lifts nothing.
  • While speakerguardd holds the interface and nothing plays, the volume stays at the floor too (raw 0).

Under the lease (speakerguardd#222 0e64095: AID48 from macOS 26B123, self-check passed with volume_cdb=-1600):

  • The kernel logs "Speaker protection granted" only while a stream plays, and "withdrawn: released by the owner" 5 s after it ends.
  • Granted, the volume is raw 169 (-16 dB), never higher, and it returns to the floor at each withdrawal.

Program: all of it went through the protect stage (100 Hz 4th-order high-pass, then AID48's atsp unit):

  • pink noise at -24 and -12 dBFS;
  • a -6 dBFS sweep from 100 Hz to 8 kHz;
  • a 3.5-minute music track at full scale (peaks 0 dBFS, mean -12.4 dBFS).

For the track, 210 one-second samples all read Speaker Volume 169 and Amp Fault Status 0, with one grant and one withdrawal in the kernel log.

One caveat. speakerguardd's own release gate doesn't admit the J873g yet: there is no macOS-parity attestation for the AID48 voicing on 26B123. So for this test the supervisor and the session helper were started by hand without the gate, and the program went straight into the protect stage without the voicing. Details are on speakerguardd#222.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 1.

The lease-only commit (3fa618e) reads right. macaudio_sn012776_vlimit() (sound/soc/apple/macaudio.c:422-430) gives the floor in every state except unlocked-and-leased. macaudio_spk_leave_lease() drops to the floor while spk_iface is still LEASE (:1825) and only then switches the interface. The early return in macaudio_vlimit_update() (:787-789) means "Speaker Volume Unlock" can never lift a fixed-ceiling machine. Under the lease, user writes to the volumes are refused (macaudio_spk_owned_write_check(), :2204), and speaker starts are refused until a grant (:3165). So the limit going to safe_vol at interface switch (:1786), not at grant, is still safe.

  1. macaudio.c:4093 hardcodes .safe_vol = -16 for the J873. The power and thermal case in the comment (:4078-4088) only holds at amp level 15 (18.5 dBV). The driver does not use 15: it reads the level from each amp's apple,speaker-config at boot and accepts anything up to SN012776_LEVEL_MAX (0x14) (macaudio_sn012776_level(), :2415-2426). On a J873 whose boot loader passes a higher level, the same -16 dB volume drives the speaker harder, and the 0.77 W / 123 C figures in the comment no longer hold. The ceiling has to follow the level the driver actually uses. Either derive the ceiling from the level read at probe and a power limit the machine provides (its own speaker tuning, which the speakerguardd side already compiles for this Mac, carried to the kernel through the DT the boot loader writes), or, at the very least, keep the speaker off when the level read is not the one the ceiling was computed for. Without a machine-provided limit, the speaker should stay off.

Nit: the spk_fixed_ceiling comment (:186-192) says the volumes "stay at the floor until a 'Speaker Protection' lease is granted". The code lifts the limit when the interface switches to the lease (:1786), and the grant then sets the volume. Please say "until the interface is on the lease; playback starts only after a grant".

HW row: J873g on a kernel built from exactly this head on integration/aurora (not a backport onto the running source), with speakerguardd started through its normal release path, not by hand: after boot "Speaker Volume" platform_max reads 1; an attempt to unlock on the "Speaker Volume Unlock" interface leaves it at 1; under a grant it reads SN012776_DB(safe_vol) and never higher across a full-scale program; at each withdrawal it is back to 1; the amp level read from the DT is logged; Amp Fault Status 0 throughout; 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@sithglan
sithglan force-pushed the thomas/j873-speaker-ceiling branch from 61fefdb to 505d900 Compare November 21, 2026 13:56
@sithglan

Copy link
Copy Markdown
Contributor Author

@RyanTheTide thanks. 505d90051fdf amends the J873 commit.

  1. The ceiling follows the level it was computed for. I took the "at the very least" variant:
    • A fixed ceiling now names the amp level it was computed for, spk_ceiling_level (15 on the J873).
    • macaudio_sn012776_levels_present() logs each amp's level on such a machine. At any other level it logs amp level N, the fixed ceiling holds only at 15, and the speaker stays off ("no usable amp levels from the boot loader, disabling speakers").
    • So a boot loader that passes another level leaves the J873 speaker off, rather than running it at -16 dB from that level.
    • Not done: deriving the ceiling from the level plus a power limit the machine provides. The J873 ADT's speaker node carries the level (speaker-config), the DC blocker, BOP and speaker-protection = 0, but no power or thermal limit. A limit from the Mac's speaker tuning would have to reach the DT through the boot loader, and that path doesn't exist yet. Until it does, this check keeps the speaker on only at the level the owner signed off.
  2. Nit: the spk_fixed_ceiling comment now says the volumes stay at the floor until the interface is on the lease, and that playback starts only after a grant.

KUnit (arm64, QEMU): 72 of 72 pass in the Apple sound suites.

  • The new macaudio_levels_fixed_ceiling case admits a J873 link whose amp is at 0x0f. It refuses one with a second amp at 0x07, and one with an amp without a level, and it refuses levels 14 and 16.
  • It fails when the level check is dropped.
  • checkpatch is clean.

HW row: pending, for two reasons.

  • speakerguardd's normal release path doesn't admit the J873g yet: there is no parity attestation for its voicing (speakerguardd#222).
  • The row plays through the speaker, which needs the owner's go.

The parts that need no sound I can run on a kernel built from this head: platform_max 1 after boot, an unlock attempt leaving it at 1, and the logged amp level. I'll post those with the full row.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of 505d900: Blockers: 1.

The amended J873 commit closes the level-mismatch hole. It does not give the ceiling a source in the machine's data. The lease paths are unchanged since 61fefdb and still keep the floor. The nit is fixed.

  1. Not resolved: the ceiling is still a constant that does not come from this Mac. The new level check works and fails closed. macaudio_sn012776_level_allowed() (sound/soc/apple/macaudio.c:2438-2441) accepts only spk_ceiling_level. macaudio_sn012776_levels_present() (:2461-2472) logs the level and returns false for any amp at another level, or with no level or an out-of-range one. macaudio_parse_of() then skips the Speaker link (:2709-2717). macaudio_limit_sn012776_levels() (:2481-2503) reads the same nodes, so "Amp Gain Volume" cannot exceed the level that was checked. So a boot loader that passes a level above 15 now leaves the speaker off, which was the failure in our last comment. What is left is the value itself. .safe_vol = -16 and .spk_ceiling_level = 15 (:4118-4120) are board-table constants. The comment (:4101-4112) and the commit message derive them from another Mac's speaker model (J274), and the commit message says this Mac's ADT carries no power or thermal limit. The kernel therefore admits the speaker (:4114) with a limit that nothing on this machine provides. That is the case our last comment said should leave the speaker off. Fix: in this PR keep .enable_speakers = false for the J873 and land spk_fixed_ceiling/spk_ceiling_level and the level check as inert mechanism. Then admit it in a follow-up once the boot loader writes a limit from the machine's own speaker data into the amp node. The driver should compute the ceiling from that limit and the level it read, and leave the speaker off when the property is missing.

Lease and unlock paths (no change since 61fefdb). macaudio_spk_enter_lease() sets the interface to LEASE (:1770), which refuses starts. It then floors (:1778) and fixes the amp gains, and lifts the limit to safe_vol only after both succeed (:1793). macaudio_spk_leave_lease() floors with the ramp (:1822) and drops the limit to 1 (:1832) before it switches the interface back (:1849). The ramp skips the steps at or above the ceiling (:1200-1202). macaudio_vlimit_update() returns early both while leased (:791) and on a lease-only machine (:795), so "Speaker Volume Unlock" never lifts it. Probe starts at the floor (:3553). Floor kept on every path.

Nit (resolved): the spk_fixed_ceiling comment (:186-193) now says the floor holds until the interface is on the lease, and playback starts only after a grant.

The PR description is out of date. It says 61 tests where the commit says 72, it quotes the old log string "the boot loader passed no amp levels", and its "Not in this PR" list says the speakerguardd model does not exist yet. It has no Assisted-by: line.

HW row: J873g on a kernel built from exactly this head on integration/aurora, with a DT whose amp node carries the machine-provided limit. Pass criteria: dmesg logs the amp level and the ceiling computed from that limit. With the property removed, or with the level changed, the Speaker link is skipped. After boot "Speaker Volume" platform_max is 1, and an unlock attempt leaves it at 1. Under a grant through speakerguardd's normal release path it never goes above the computed ceiling over a full-scale program, and it returns to 1 at each withdrawal. Amp Fault Status stays 0. 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

sithglan added a commit to sithglan/speakerguardd that referenced this pull request Nov 21, 2026
… -16 dB)

The supervisor grants only while every amp's volume reads 0 dB on its
own TLV. The J873g's kernel (aurora-silicon/linux#1862) lifts its one
SN012776 under the "Speaker Protection" lease only to a fixed ceiling,
-16 dB on the DVC (raw 169), and holds it at the floor otherwise. Its
first grant would read -16 dB and latch: "granted, but Speaker is at
169 (Some(-1600)) cdB, not 0 dB".

Make the ceiling speakerguardd's own hard cap for the board:
- gate.json operating_volume_db names it per board, in dB on the
  control's TLV: {"j873g": -16.0}. gen.operating_volume_db() reads it
  (0 dB for any other board). A value above 0 dB, below -40 dB or not a
  number refuses the board.
- The self-check records it in selfcheck.bind as volume_cdb=-1600. 0 dB
  writes no line, so every existing record stays as it is. A bound pass
  whose volume differs from the gate's (one written before this change
  on a J873g) is checked again, not reused.
- The supervisor parses volume_cdb (absent: 0; outside -4000..0 cdB:
  the record is refused) and its Expect holds the grant to exactly that
  volume. 0 dB, a step above or below -16 dB, or a volume without a dB
  scale latches, as a wrong 0 dB volume does today.

The operating point is unchanged: the blob is compiled for the amp
gain's full scale (gain 15, 11.89 V peak, read back from "Amp Gain
Volume"). The model therefore computes for 16 dB more drive than the
speaker gets under the ceiling.

Tests:
- supervisor (selfcheck.rs): the record's volume_cdb parses, and is
  refused when positive, below -40 dB, fractional, empty or given twice;
- supervisor (supervise.rs): a J873g-shaped machine at -16 dB grants and
  renews; at 0 dB, -15.5 dB, -16.5 dB or without a dB scale it latches
  ("not -16 dB"); and without the record's volume, -16 dB latches.
  Comparing against 0 dB, as before, fails the first case;
- test_wiring.py: the shipped gate gives -16 dB for the J873g and 0 dB
  elsewhere, malformed values refuse, and bind_lines() writes
  volume_cdb only when it is not 0.

cargo test/clippy -D warnings/fmt for sgv2-supervisor, the four session
suites, gen.py --check and tools/check-clean.sh pass.

Signed-off-by: Thomas Glanzmann <[email protected]>
sithglan added a commit to sithglan/speakerguardd that referenced this pull request Nov 21, 2026
asahi-audio#28 gave the J873g's speaker, which has no measurement behind
its low end, a 4th-order Butterworth high-pass at 100 Hz: two
bq_highpass sections, Q 1.3066 and 0.5412. It keeps the drive below
100 Hz under what the J274 graph gives the M1 Mac mini's speaker, at
every frequency. The review of aurora-silicon/linux#1862 asked for it in
the protected graph.

gate.json protect_highpass names it per board ({"hz", "order"}, an even
order of 2 to 8, a corner of 20 Hz to 1 kHz). gen.pipewire_conf() puts
its sections on every amp's lane in the protect stage, in front of the
sgv2 instance's unit port. The unit therefore models the program the amp
gets, and no voicing setting can drop the filter. The sections are
PipeWire's builtin bq_highpass at the Butterworth Q of each pole pair
(butterworth_q(), which the voicing low-pass already uses): monotonic
and never above 0 dB. A malformed entry refuses the board's graph. No
other board has an entry, so every other generated file is unchanged
(gen.py --check).

Tests (test_wiring.py, ProtectHighpass):
- the shipped gate gives the J873g (100 Hz, 4) and no other board an
  entry;
- the J873g's protect stage has hp0s0 -> hp0s1 -> sgv2:in_0 with the
  input on hp0s0, and without the entry it is the plain stage;
- the cascade's RBJ response at 48 kHz is asahi-audio#28's recording on
  the J873g (-41.8, -24.1, -12.6 and -3.0 dB at 30, 50, 70 and
  100 Hz) and never above 0 dB from 10 Hz to 24 kHz;
- malformed entries refuse.

Signed-off-by: Thomas Glanzmann <[email protected]>
@sithglan

Copy link
Copy Markdown
Contributor Author

@RyanTheTide the description is updated:

  • the test count is 72, with the amp-level case;
  • the log string is "no usable amp levels from the boot loader, disabling speakers";
  • "Not in this PR" points at speakerguardd#222;
  • the Assisted-by: line is there.

I also corrected the sense statement. The descriptor's slot masks have no receive side, but the same stream names a receive DMA provider. The amp's speaker-config also names V/I slots. So "no sense reaches the AP" is not established (speakerguardd#222).

On the blocker: agreed, it is not resolved. I have no machine source for the value. What this Mac hands over for its amp is the ADT's speaker-config (amp level 15 and the slots), amp-dcblocker-config, bop-config and speaker-protection = 0. None of these is a power, voltage or thermal limit. The -16 dB comes from the J274 model and the owner's sign-off, and neither is this Mac's data.

The one place left is the Mac's own audio tuning on the ESP, which only userspace reads today. I'll check it on the J873g, read only, and report whether it describes a limit for this speaker, without values. If it does, the route would be:

  • the boot loader passes that limit in the amp node;
  • macaudio computes the ceiling from it;
  • the speaker stays off without it.

Until then the PR is held, as the description now says.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

The spk_fixed_ceiling mechanism from #1884 is on integration/aurora, but neither commit here is, and both apply cleanly to 110861f. The open blocker is the J873 enable: the -16 dB ceiling and level 15 are constants in the board table, not values this Mac provides. The lease-only commit and the level check could go in on their own with the J873 left at enable_speakers = false, and the enable follow once the boot loader hands the kernel a limit from the machine's own speaker data.

Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches.

@sithglan
sithglan force-pushed the thomas/j873-speaker-ceiling branch from 505d900 to 09b8160 Compare November 23, 2026 04:56
A fixed speaker ceiling (spk_fixed_ceiling) is a volume computed for one
amp level. The driver takes each SN012776 amp's level from the
apple,speaker-config the boot loader passes, and at another level the
same volume drives the speaker differently. Let a fixed ceiling name the
level it was computed for (spk_ceiling_level), log the level read, and
keep the speakers off when any amp has another level.

No board uses a fixed ceiling yet. The J873, for which it was written,
stays off until its limit comes from the machine's own speaker data.

A new amp-level KUnit case admits an amp at the ceiling's level 15 and
refuses a link with an amp at 7 or one without a level. It fails when
the level check is dropped.

Signed-off-by: Thomas Glanzmann <[email protected]>
@sithglan
sithglan force-pushed the thomas/j873-speaker-ceiling branch from 09b8160 to 226c790 Compare November 23, 2026 04:58
@sithglan sithglan changed the title ASoC: apple: macaudio: run the J873 speaker under a fixed -16 dB ceiling ASoC: apple: macaudio: lease-only fixed ceiling, held only at its amp level Nov 23, 2026
@sithglan

Copy link
Copy Markdown
Contributor Author

Thanks. Split as you suggested: 505d900 → 226c790. The PR is now the lease-only commit (3fa618e, unchanged) and the amp-level check on its own (226c790, "hold a fixed ceiling only at its amp level"). The J873 stays at enable_speakers = false and safe_vol = 0, with its admission expectation unchanged (speaker off).

  • What 226c790 keeps: spk_ceiling_level, macaudio_sn012776_level_allowed(), the level logging and the new KUnit case. The case now uses a test-only fixed-ceiling config at level 15, so it doesn't depend on the J873 table.
  • What it leaves out: the J873 enable (-16 dB, lease-only, level 15) and its power and thermal case. They stay on a local branch for a follow-up, once the boot loader hands the kernel a limit from the machine's own speaker data.
  • No board sets spk_fixed_ceiling on this branch or on the tip, so nothing changes behaviour here.

Checks:

  • KUnit (arm64 QEMU): 72/72. With the level check dropped, macaudio_levels_fixed_ceiling fails (71/72).
  • macaudio.o builds clean with W=1.
  • checkpatch --strict is now clean on both commits. The earlier head had six alignment CHECKs in the amp-level test, despite what the old description said; a small helper fixes that.
  • It merges cleanly on b10280c.

Assisted-by: LLM (Claude:Opus 5.5)

@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.

Formal §1–§6 pre-PR review on 226c7903c978c809c4931b977e015182f0fcad12:

  • §1 No model gating: Pass. Uses spk_fixed_ceiling and spk_ceiling_level in struct macaudio_platform_cfg and validates per-amp levels from DT apple,speaker-config, with no SoC/board conditionals.
  • §2 Production-ready: Pass. Clean, minimal, no cmdline/module parameters or workarounds.
  • §3 Safety: Pass. Splitting out the J873 enablement resolves the prior CHANGES_REQUESTED blockers. Both commits strictly tighten the already-merged #1884 mechanism:
    • macaudio_sn012776_vlimit() keeps spk_fixed_ceiling amps at the floor (1) when locked and under Speaker Volume Unlock (with macaudio_vlimit_update() returning early), lifting to safe_vol only under a Speaker Protection lease (macaudio_spk_enter_lease() / macaudio_spk_leave_lease() preserve floor invariants on entry and teardown).
    • macaudio_sn012776_level_allowed() / macaudio_sn012776_levels_present() log each amp's level and disable speakers when any amp's level differs from spk_ceiling_level (with of_node_put() properly handled on all paths).
    • No board in the tree sets spk_fixed_ceiling = true (t8152-j873 remains at enable_speakers = false, safe_vol = 0), so behavior on all currently supported Macs is unchanged.
  • §4 Clean-room & attribution: Pass. Both commits (3fa618e415f6, 226c7903c978) carry human author/committer and human Signed-off-by: with zero AI trailers in commit messages; PR body includes Assisted-by:.
  • §5 Evidence & CI: Pass for an inert safety-tightening change with no enabled board. Applies cleanly to current integration/aurora; host-tests CI is green on 226c7903c978; 72/72 Apple sound KUnit cases (including lease-only and amp-level negative controls) and W=1 builds are verified.
  • §6 Naming: Pass.

Clearing prior change requests — ready for merge.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit 065764c into aurora-silicon:integration/aurora Nov 23, 2026
1 check passed
sithglan added a commit to sithglan/speakerguardd that referenced this pull request Nov 24, 2026
… -16 dB)

The supervisor grants only while every amp's volume reads 0 dB on its
own TLV. The J873g's kernel (aurora-silicon/linux#1862) lifts its one
SN012776 under the "Speaker Protection" lease only to a fixed ceiling,
-16 dB on the DVC (raw 169), and holds it at the floor otherwise. Its
first grant would read -16 dB and latch: "granted, but Speaker is at
169 (Some(-1600)) cdB, not 0 dB".

Make the ceiling speakerguardd's own hard cap for the board:
- gate.json operating_volume_db names it per board, in dB on the
  control's TLV: {"j873g": -16.0}. gen.operating_volume_db() reads it
  (0 dB for any other board). A value above 0 dB, below -40 dB or not a
  number refuses the board.
- The self-check records it in selfcheck.bind as volume_cdb=-1600. 0 dB
  writes no line, so every existing record stays as it is. A bound pass
  whose volume differs from the gate's (one written before this change
  on a J873g) is checked again, not reused.
- The supervisor parses volume_cdb (absent: 0; outside -4000..0 cdB:
  the record is refused) and its Expect holds the grant to exactly that
  volume. 0 dB, a step above or below -16 dB, or a volume without a dB
  scale latches, as a wrong 0 dB volume does today.

The operating point is unchanged: the blob is compiled for the amp
gain's full scale (gain 15, 11.89 V peak, read back from "Amp Gain
Volume"). The model therefore computes for 16 dB more drive than the
speaker gets under the ceiling.

Tests:
- supervisor (selfcheck.rs): the record's volume_cdb parses, and is
  refused when positive, below -40 dB, fractional, empty or given twice;
- supervisor (supervise.rs): a J873g-shaped machine at -16 dB grants and
  renews; at 0 dB, -15.5 dB, -16.5 dB or without a dB scale it latches
  ("not -16 dB"); and without the record's volume, -16 dB latches.
  Comparing against 0 dB, as before, fails the first case;
- test_wiring.py: the shipped gate gives -16 dB for the J873g and 0 dB
  elsewhere, malformed values refuse, and bind_lines() writes
  volume_cdb only when it is not 0.

cargo test/clippy -D warnings/fmt for sgv2-supervisor, the four session
suites, gen.py --check and tools/check-clean.sh pass.

Signed-off-by: Thomas Glanzmann <[email protected]>
sithglan added a commit to sithglan/speakerguardd that referenced this pull request Nov 24, 2026
asahi-audio#28 gave the J873g's speaker, which has no measurement behind
its low end, a 4th-order Butterworth high-pass at 100 Hz: two
bq_highpass sections, Q 1.3066 and 0.5412. It keeps the drive below
100 Hz under what the J274 graph gives the M1 Mac mini's speaker, at
every frequency. The review of aurora-silicon/linux#1862 asked for it in
the protected graph.

gate.json protect_highpass names it per board ({"hz", "order"}, an even
order of 2 to 8, a corner of 20 Hz to 1 kHz). gen.pipewire_conf() puts
its sections on every amp's lane in the protect stage, in front of the
sgv2 instance's unit port. The unit therefore models the program the amp
gets, and no voicing setting can drop the filter. The sections are
PipeWire's builtin bq_highpass at the Butterworth Q of each pole pair
(butterworth_q(), which the voicing low-pass already uses): monotonic
and never above 0 dB. A malformed entry refuses the board's graph. No
other board has an entry, so every other generated file is unchanged
(gen.py --check).

Tests (test_wiring.py, ProtectHighpass):
- the shipped gate gives the J873g (100 Hz, 4) and no other board an
  entry;
- the J873g's protect stage has hp0s0 -> hp0s1 -> sgv2:in_0 with the
  input on hp0s0, and without the entry it is the plain stage;
- the cascade's RBJ response at 48 kHz is asahi-audio#28's recording on
  the J873g (-41.8, -24.1, -12.6 and -3.0 dB at 30, 50, 70 and
  100 Hz) and never above 0 dB from 10 Hz to 24 kHz;
- malformed entries refuse.

Signed-off-by: Thomas Glanzmann <[email protected]>
sithglan added a commit to sithglan/speakerguardd that referenced this pull request Nov 27, 2026
…ng; gate.json only caps it

Under a grant, macaudio limits every amp volume control to the level the
grant runs it at: 0 dB, or on a machine whose speaker only a lease may
lift (spk_fixed_ceiling, aurora-silicon/linux#1862) that machine's fixed
ceiling (-16 dB on the J873g). Read the operating volume from the card's
TLV maximum under the grant instead of demanding 0 dB or hardcoding a
per-board volume in gate.json.

- kernel.rs: AmpLevel carries max_centi_db, the dB at the control's
  current maximum (db_scale_centi() at the info maximum).
- supervise.rs: volume_problem() takes the ceiling from the card. Every
  amp must report the same ceiling, within -40..0 dB, at or below any
  gate.json cap, and sit exactly at it. A card that reports no ceiling
  latches, whatever gate.json says.
- gate.json / gen.py: operating_volume_cap_db is an optional per-board
  cap that can only lower the card's ceiling; no board carries an entry
  today, and malformed entries refuse the board.
- selfcheck: records the cap (volume_cap_cdb) only when set; refuses any
  record naming volume_cdb and does not reuse one whose cap differs.
- docs: document the card-ceiling contract in docs/CAPABILITIES.md and
  docs/NEW-PLATFORM.md.

On every Mac except a spk_fixed_ceiling board, the card's TLV maximum
under a grant equals the held 0 dB, so the check accepts the same state
as before.

Signed-off-by: Thomas Glanzmann <[email protected]>
sithglan added a commit to sithglan/speakerguardd that referenced this pull request Nov 27, 2026
asahi-audio#28 gave the J873g's speaker, which has no measurement behind
its low end, a 4th-order Butterworth high-pass at 100 Hz: two
bq_highpass sections, Q 1.3066 and 0.5412. It keeps the drive below
100 Hz under what the J274 graph gives the M1 Mac mini's speaker, at
every frequency. The review of aurora-silicon/linux#1862 asked for it in
the protected graph.

gate.json protect_highpass names it per board ({"hz", "order"}, an even
order of 2 to 8, a corner of 20 Hz to 1 kHz). gen.pipewire_conf() puts
its sections on every amp's lane in the protect stage, in front of the
sgv2 instance's unit port. The unit therefore models the program the amp
gets, and no voicing setting can drop the filter. The sections are
PipeWire's builtin bq_highpass at the Butterworth Q of each pole pair
(butterworth_q(), which the voicing low-pass already uses): monotonic
and never above 0 dB. A malformed entry refuses the board's graph. No
other board has an entry, so every other generated file is unchanged
(gen.py --check).

Tests (test_wiring.py, ProtectHighpass):
- the shipped gate gives the J873g (100 Hz, 4) and no other board an
  entry;
- the J873g's protect stage has hp0s0 -> hp0s1 -> sgv2:in_0 with the
  input on hp0s0, and without the entry it is the plain stage;
- the cascade's RBJ response at 48 kHz is asahi-audio#28's recording on
  the J873g (-41.8, -24.1, -12.6 and -3.0 dB at 30, 50, 70 and
  100 Hz) and never above 0 dB from 10 Hz to 24 kHz;
- malformed entries refuse.

Signed-off-by: Thomas Glanzmann <[email protected]>
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.

3 participants