Skip to content

ASoC: apple: macaudio: Open the tweeter HPF only while protection is granted - #949

Merged
RyanTheTide merged 2 commits into
sgv2-kernel-interfacefrom
sgv2/tweeter-hpf
Nov 5, 2026
Merged

RyanTheTide merged 2 commits into
sgv2-kernel-interfacefrom
sgv2/tweeter-hpf

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

On top of #922 (sgv2-kernel-interface, 459c031).

Problem. macaudio fixes every SN012776 tweeter amp's playback high-pass filter at 800 Hz. With speakerguardd v2, protection runs in the graph and measures each voice coil with a low-frequency pilot tone added inside the protection stage. The amp filter sits after that stage, so it removes the tweeter pilot. The tweeter V/I sense never carries it, and tweeter closed-loop temperature stays at its calibration value. Woofers, filtered at 2 Hz, track as expected.

Live v2 runs (J616s x2, M2 x1): while the pilot is enabled, tweeter pilot-bin V/I power is 25-37 dB below the woofers', and below the window acceptance thresholds.

Change. A tweeter_hpf field in the platform match data. It defaults to "800 Hz" and is set to the woofers' 2 Hz on the J413 and J616s/J616c, the two machines that run in-graph protection with a tweeter pilot. On those machines the graph's crossover comes before the protection stage. Every other machine is unchanged. The control stays fixed and read-only, the sense-path DC blockers are untouched, and the speaker gate is unchanged: no amp plays without the owner's grant.

Tests. KUnit apple-speaker-hpf (4 cases). apple-* 30/30 on arm64 qemu (PROVE_LOCKING). Hardware results are in the comments below.

🤖 Generated with Claude Code

macaudio fixes the playback high-pass filter of every SN012776 tweeter
amp at 800 Hz, a safety net from before any speaker protection ran in
userspace. On machines where the protection runs in the PipeWire graph
and measures each voice coil with a low-frequency pilot tone, that
filter sits after the protection stage and removes the pilot from the
tweeter outputs. The tweeters' V/I sense then never carries the pilot,
so their closed-loop temperature never leaves its calibration value
and only the open-loop model protects them. The woofers, filtered at
2 Hz, track as expected. The amp's sense-path DC blockers are separate
and unchanged.

On those machines the graph's crossover, which keeps program bass off
the tweeters, comes before the protection stage, so the amp filter adds
nothing to the tweeters' protection there but takes away their sense.

Add a tweeter_hpf field to the platform match data, "800 Hz" when
unset, and set it to the woofers' 2 Hz on the J413 and the J616s/J616c,
both of which run the in-graph protection with a tweeter pilot. Every
other machine keeps 800 Hz. The control stays fixed and read-only, and
the speaker gate is unchanged: no amp plays unless the protection owner
grants it.

KUnit apple-speaker-hpf: woofers stay at 2 Hz, the default tweeter
corner stays 800 Hz on every machine that does not set it, the two
pilot machines get the woofer corner below the pilot, and no machine
selects "Disabled".

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware check, M2 (J413), one-shot 7.3.0-aurora-sgv2k6h (#922 tip + this commit, same tree). SELinux enforcing, 0 AVCs.

  • All four amps read DC_BLK0 0x21 (2 Hz playback HPF), tweeters included; before this change the tweeters read 0x26 (800 Hz). DC_BLK1 is unchanged.
  • v2 granted and ran, with no faults. At low drive, the tweeters' pilot-bin V/I power while the pilot is on matches the woofers' (V ~3e-3 for both; before, the tweeters were 25-37 dB lower and under the acceptance thresholds). Tweeter windows are accepted: the window resistance leaves its calibration value and tweeter T_CL leaves the calibration temperature, as the woofers' does.
  • At the lowest sink volume the drive is ~1e-16 W, below the pilot enable threshold on every channel. No channel, woofer or tweeter, gets windows there, which is the expected gate behavior.
  • The M2 is back on fleet16 with speakerguardd 0.1 active.

…granted

The previous change fixed the tweeter playback high-pass at the woofers'
2 Hz on the J413 and J616 for good. That opens the tweeters even when no
protection engine owns the speakers, which is exactly when the 800 Hz
filter is the only thing keeping program bass off them.

Tie it to the grant instead. The tweeter corners become the driver's,
like the speaker volumes: read-only to userspace, 800 Hz from the card's
binding on, and set to the machine's granted corner
(tweeter_hpf_granted) in macaudio_spk_grant(), before the amps go up to
the operating gain. Every withdrawal (an explicit release, the owner's
file closing, a new owner, the lease running out, system sleep) goes
through macaudio_spk_floor(), which brings the amps to the safe level
first and then restores 800 Hz. A corner that cannot be restored is a
failed floor: speaker playback is refused until the driver reloads. A
corner that cannot be opened fails the grant and floors.

The machines that open the tweeters while granted are the J316, J413
and J616s/J616c, the boards whose protection engine runs the crossover
ahead of its protection stage and a low-frequency pilot on every voice
coil. Every other machine keeps 800 Hz throughout.

KUnit apple-speaker-hpf, now 7 cases: a grant opens the tweeters, an
explicit release, the owner going and a lease timeout restore 800 Hz,
a refused renewal opens nothing, a failed restore is a failed floor, a
failed open floors, other machines stay at 800 Hz, woofers stay at 2 Hz,
and no machine ever selects "Disabled".

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide RyanTheTide changed the title ASoC: apple: macaudio: Let match data set the tweeter HPF corner ASoC: apple: macaudio: Open the tweeter HPF only while protection is granted Nov 5, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Rework (680711e): the tweeter playback high-pass now opens to the woofers' 2 Hz only while protection is granted, on J316, J413 and J616s/J616c. It opens in macaudio_spk_grant() before the amps go up. Every withdrawal goes through macaudio_spk_floor(), which sets the safe level and then puts 800 Hz back. A restore that fails is a failed floor. KUnit apple-speaker-hpf has 7 cases; apple-* passes 33/33.

Hardware, one-shot 7.3.0-aurora-sgv2k6i (same tree as this branch), SELinux enforcing, 0 AVCs, all Amp Fault Status 0:

  • M2 (J413): tweeters read DC_BLK0 0x26 at the floor, 0x21 while granted, and 0x26 again after release (owner gone). On the 0.3/0.6/1.0 ladder (60/60/300 s), the tweeters accepted about 1045 fresh windows each (before: 0). r(T_CL, T_OL) was 0.986 and 0.984 on the tweeters and 0.997 on the woofers. 0 dropouts, 0 faults.
  • M1 Pro (J316s): the params were compiled from its own AID9 bundle and the self-check passed with derived wiring (b8b8759a). The graph was generated from the self-check record. Tweeters read 0x26 at the floor, 0x21 while granted, and 0x26 after release. The music ladder has not been run yet.
  • Open: on the M2, v2's cold-sense guard (SENSE_IMPLAUSIBLE) latched about 2 s after the tweeter pilot started: tweeter T_CL read about 15-19 C at cold start, below calibration. That is v2-side and stricter only, but it will block tweeter relaxation.

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.

1 participant