Skip to content

ASoC: apple: macaudio: add a fixed speaker ceiling for machines without sense - #1884

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:integration/aurorafrom
sithglan:thomas/macaudio-fixed-ceiling
Nov 14, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:integration/aurorafrom
sithglan:thomas/macaudio-fixed-ceiling

Conversation

@sithglan

Copy link
Copy Markdown
Contributor

Split out of #1862 as @DjDeveloperr asked: this is the mechanism alone. No machine config sets it, so nothing changes on any current machine. #1862 now enables it on the J873 and is stacked on this one.

spk_fixed_ceiling is for a machine where the amps' voltage and current sense never reach the AP, so no protection daemon can govern its speakers. Its SN012776 volumes are limited to safe_vol in every state: under the lock, after an unlock and under "Speaker Protection". It gets no sense PCM.

Changes since #1862

The review found that under a granted lease, macaudio_spk_gain(ma, true) still returned SN012776_0DB. That is above the volumes' new platform_max, so the put failed with -EINVAL and the grant dropped to the floor ("operating gain not set"). Now:

  • A fixed-ceiling machine's operating gain is its ceiling. A grant runs the amps at safe_vol, and the engine attenuates below that, as on the other machines.
  • The withdrawal ramp skips the steps at or above the ceiling. For a -15 dB ceiling that is -2 to -12 dB; those writes would have failed the same way.

Testing

  • KUnit (arm64, QEMU): the six apple-speaker suites pass, 60 tests. The new macaudio_spk_fixed_ceiling case runs a J316 profile with a -15 dB ceiling. An unlock leaves the limit at the ceiling, a grant sets the amps to it, and a release ramps them down from below it to the floor. With the gain and ramp changes reverted, the case fails twice: the grant writes 201 where 171 is expected, and the ramp starts at or above the ceiling.
  • macaudio.o builds with W=1 and no warnings (LLVM 22), and checkpatch is clean.
  • Not run on hardware, because no machine sets the flag in this PR. ASoC: apple: macaudio: run the J873 speaker under a fixed -16 dB ceiling #1862 has the J873 runs.

…ut sense

Speaker protection on the SN012776 Macs needs the amps' voltage and
current sense: speakersafetyd governs the volumes from it under "Speaker
Volume Unlock", and the volumes sit at the lock's floor without it. A
machine whose sense never reaches the AP can have neither, so its
speakers stay off.

Add spk_fixed_ceiling for such a machine. Its SN012776 volumes are
limited to safe_vol in every state: under the lock, after an unlock and
under "Speaker Protection". It gets no sense PCM.

Under a granted lease the amps run at a fixed operating gain, and all
attenuation is the engine's. With the ceiling that gain is safe_vol, not
0 dB: 0 dB is above the volumes' limit, so the grant's write would fail
and floor the speakers ("operating gain not set"). The withdrawal ramp
starts below the ceiling for the same reason.

No machine sets it yet, so nothing changes on any current machine.

The new KUnit case runs a J316 profile with a -15 dB ceiling: the
volumes' limit after an unlock is the ceiling, a grant sets the amps to
it, and a release ramps them down from below it to the floor. Without
the operating gain and ramp changes, the grant and the ramp write above
the ceiling and the case fails.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>

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

Reviewed the mechanism alone, as asked on #1862. No board config sets spk_fixed_ceiling, and every hunk is behind that flag, so nothing changes on any current machine.

With the flag set:

  • The SN012776 limit is SN012776_DB(safe_vol) whether locked, unlocked or granted, and there is no sense PCM.
  • A grant's operating gain is the ceiling, so the lease no longer drops to the floor ("operating gain not set"). That was the note on #1862.
  • The withdrawal ramp starts below the ceiling.

The new KUnit case covers both fixes and fails without them.

An optional hardening for later: refuse spk_fixed_ceiling with safe_vol >= 0 at probe. Then a misconfigured board fails closed instead of getting a 0 dB ceiling.

host-tests is green on this head. Base drift doesn't touch macaudio.c or the test header. Approving and merging. #1862 (the J873 enablement) still waits for the owner's sign-off on the level.

@DjDeveloperr
DjDeveloperr merged commit 9777df3 into aurora-silicon:integration/aurora Nov 14, 2026
1 check passed
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