Skip to content

wiring, selfcheck, supervisor: a transport that carries no V/I sense (M4 Mac mini, J773g) - #212

Merged
DjDeveloperr merged 2 commits into
mainfrom
djdev/aop-spkr-no-sense
Nov 20, 2026
Merged

DjDeveloperr merged 2 commits into
mainfrom
djdev/aop-spkr-no-sense

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

On the M4 Mac mini (J773g) the speaker is a single SN012776 behind the AOP, and its speaker back-end names a TX channel and no sense DMA ("spkr", "cout", "cin", from the ADT's TX-only audio-speaker). The derivation still gave the amp a V/I pair from its slot properties, so the self-check refused the Mac. It first failed on no 'Speaker VSENSE Switch', and then found no speaker format, because the sense capture never opened.

Changes

  • wiring.py
    • Each speaker back-end's dma-names is recorded. The aop-spkr transport names its speaker channel ("spkr") and its sense channel ("sense").
    • A back-end that names "spkr" but not "sense" carries no V/I sense (transport_senses()). Its amps are wired without sense (no_sense_path).
    • A back-end with no dma-names, an older record, or a node that doesn't name "spkr" (such as the base T8132 node's "dma") keeps the sense its amp family offers.
  • Admitted for one amp only. Without sense, nothing proves which amp plays which unit channel. So derive() refuses no_sense_path for more than one amp, and the supervisor's machine_for() accepts derived-nosense only with amps == 1. A sense-capable multi-amp Mac whose device tree lost "sense" fails, and does not run unproven.
  • Refusals that stay. A tuning whose unit reads sense (spp3) is refused on such a transport. So is lsm2 with an LSID companion.
  • selfcheck. Such a Mac is proven like a family without sense: the speaker PCM only. Its record says method=derived-nosense (method_of()). The static report says what it was proven with.
  • supervisor. derived-nosense is taken only for a sense family with no sense channels and one amp. derived-static for a sense family is still refused.

Wiring hashes don't change for existing Macs. The J616s keeps 164e7a0d23003bab with or without the recorded names, and a J773g-shaped tree with "sense" named gives 5429615c46b1b4c1. The no-sense J773g wiring is d1d62e8a0aaaef3d, the record its self-check made on the Mac.

Tests

  • test_wiring.py NoSensePath (8 new, 79 in all), covering:
    • J773g → derived-nosense, 1ch, d1d62e8a0aaaef3d;
    • "sense" named → derived;
    • no names, an older record, or no "spkr" → sense kept;
    • other transports and the J616s hash unchanged;
    • spp3 refused, and lsm2 + LSID refused;
    • six amps without sense refused;
    • read_dt() records dma-names;
    • the static report.
  • Supervisor machine_for refuses 4 amps proven without sense.

On hardware: the J773g ran the first commit at 10:16 on 11-19: self-check passed (derived-nosense), protection granted, amp faults 0, 0 frames over capacity.

The base is main, which now carries v2. This branch is rebased onto main 766c0a3, after #213 and #215.

🤖 Generated with Claude Code

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

The org's Actions queue has been backed up since about 13:40Z: every aurora-silicon repo has runs queued, and this PR's checks haven't started. So I ran this workflow's steps locally on the head (fb71278, already on v2 f0506ea):

  • tools/check-clean.sh: OK.
  • cargo fmt --all --check: OK.
  • cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test --workspace (rustc 1.99): 37 test binaries, 0 failures.
  • packaging/session: gen.py --check, test_wiring.py (1 skipped), test_session.py, test_provision.py and test_verify.py all pass.

On hardware, the J773g ran this patch for its protected playback on 11-19 at 10:16 (self-check passed (derived-nosense), protection granted, amp faults 0). The patch also applies cleanly to the RC9 package pin bbd9ed3.

🤖 Generated with Claude Code

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Packaging so a normal update keeps the J773g speaker working: aurora-silicon/alarm-aurora#367 carries this PR as a patch on the RC9 pin (speakerguardd-v2 1.0.0alpha.1-43). It is installed on the J773g, where provisioning compiles and the self-check passes with the same params and wiring as this PR's build.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

main now carries speakerguardd 2. The v2 branch has been merged into it and now just follows main, so I have changed this PR's base to main. The diff is unchanged and it still merges cleanly.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Independent review (pre-merge, safety first): head fb71278f

Verdict: not ready. Two small blocking items. The J773g path itself looks right.

What I checked

  • Classification. transport_senses() returns false only when every speaker back-end has dma-names, its compatible maps to a transport with sense_dma (today only apple,t6041-aop-audio and its t8132 alias), and "sense" is not in the list. A missing property, or a hw record from before cpu_dma_names, keeps sense. This is a device-tree fact, not a runtime one. If a driver fails to open the sense DMA on a Mac whose DT names it, the Mac still goes through derived and fails the self-check, as before.
  • Current device trees (linux tree ed059081c70c): only t8132-j773g.dts names a speaker DMA without sense ("spkr", "cout", "cin", from the ADT's TX-only audio-speaker). J604, J713 and J715 get "dma", "spkr", "sense", … from t8132-laptop.dtsi. J614s, J616s, J614c and J616c get it from t604x.dtsi. J773s and J623/J624 have no speaker DMA yet.
  • Refusals still hold. I probed synthetic DTs with the fixtures' tunings:
    • spp3: refused.
    • lsm2 + LSID: refused ("LSID companion requires a complete V/I sense bus").
    • 6 amps on aop-spkr without sense: refused (no 6ch plugin).
    • J773g-shaped DT + atsp 1ch: derived-nosense, plugin 1ch, wiring d1d62e8a0aaaef3d. That is the hash in alarm-aurora#367.
  • Protection without V/I. atsp uses no sense (DESIGN.md, Sense table) and is open loop, the most protective case. The amp family stays sn012776, so the supervisor still checks each amp's gain readback against the blob's full scale, and each amp's fault status, before it grants. No sense binding is offered (bind.sense == 0).
  • Binding. covers() (result, board, kernel, params_sha256) is unchanged, and the session's reported wiring must still match. The no-sense hash differs from the sense hash for the same amp (d1d62e8a… vs 5429615c…), so a graph built for one cannot satisfy the other's record. machine_for still refuses derived-static for a sense family and derived-nosense for a family without sense (tests added). Existing Macs keep their hashes (the J616 fixture gives 164e7a0d23003bab with or without cpu_dma_names), so nothing is forced to re-check.
  • I found no new path that leaves the kernel floor without protection.

Blocking

  1. A DT regression can downgrade a sense-capable multi-amp Mac. Suppose t8132-laptop.dtsi lost "sense" from dma-names. A 4-amp MacBook Air M4 (J713) running plain lsm2 (LSID is still pending) would pass as derived-nosense. My probe of a 4-amp Air-shaped DT with sense dropped and plain lsm2 gave derived-nosense, plugin 4ch. Its channel map would rest on the DT and the tuning alone, with no register check and no switch test, so a woofer/tweeter swap would go unnoticed. On main that Mac fails the self-check and stays at the floor. The smallest fix: refuse no_sense_path for more than one amp in derive(), and require bind.amps == 1 for derived-nosense in machine_for, until a multi-amp Mac without sense exists. Alternatively, run the RX-slot half of check_registers() in the no-sense path. SN012776 registers are readable over I2C; only the V/I TX-slot checks need to be skipped. That proves the map for any number of amps.
  2. No Python tests for the new path. test_wiring.py runs the same 71 tests with and without this PR. Nothing covers transport_senses, no_sense_path, the spp3/LSID refusals or the derived-nosense method. Please add:
    • J773g DT → derived-nosense / 1ch;
    • "sense" named → derived;
    • property absent → derived;
    • spp3 refused, and lsm2 + LSID refused;
    • the guard from item 1.

Not blocking

  • Consider requiring "spkr" in the names before reading a missing "sense" as a hardware fact. The base t8132.dtsi node names only "dma", and today it classifies as no-sense.
  • The static() report text ("no amp registers … SD_MODE strap") is wrong for derived-nosense.
  • The PR body still says it targets v2. main now carries v2: Make v2 the main line (old variant preserved on legacy/v0.1) #207 merged, and v2 (dafc508) is an ancestor of main (39e5364). main is the right base, so please drop that note.
  • The initialize_sense follow-up you mention is fine to leave for later. It turns on switches that nothing reads.

Local runs

Arch aarch64, in a MemoryMax=2G scope, on main 39e5364 + #212 + #213 + #215 (all three merge cleanly):

  • cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings pass.
  • cargo test --workspace: sgv2-supervisor 94 passed, parity_law passed.
  • One failure, which also happens on plain main 39e5364: sgv2-core adversarial spp3_hard_path_holds_the_hard_target found a random proptest case (group target 0.08714 above hard target 0.08670). The seed (seed = 10374819889551966816, n = 8, rate = 48000, ff = On, secs = 7.952000980109578, amp = 1.9866279, h = Large) fails the same way on main. It deserves its own issue: spp3 is a sense unit, and the Arch package's check() runs this test.
  • Session suites (gen.py --check, test_wiring 71, test_session 51, test_provision 90, test_verify 22) pass on this head.

🤖 Generated with Claude Code

The T6041/T8132 AOP speaker service carries the amps' V/I sense as its
own "sense" DMA channel. A Mac whose AOP takes playback only (the M4
Mac mini, J773g: one SN012776, and its speaker node has a TX channel
and no sense) names no such channel, and opening the speaker card's
sense PCM fails. The derivation still gave its SN012776 a V/I pair from
the amp's slot properties, so the self-check refused the Mac ("no
'Speaker VSENSE Switch' control", then no speaker format: the sense
capture never opened).

Record each speaker back-end's dma-names and give the aop-spkr transport
a "sense_dma" name. Where the back-ends name their channels without it,
the amps' sense is not read: the wiring has no sense map and says
"no_sense_path". Such a Mac is proven like a family without sense (the
speaker PCM only) and its record says method=derived-nosense, which the
supervisor takes for a sense family only with no sense channels; a sense
family recorded derived-static is still refused. A tuning whose unit
reads sense (spp3) on such a transport is refused.

A back-end without dma-names, and every other transport, keeps today's
behaviour.

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

Review of the transport without V/I sense: a sense-capable Mac whose
device tree lost its "sense" DMA name (a 4-amp MacBook Air M4 on plain
lsm2, say) would pass as derived-nosense, with the order of its amps
resting on the device tree and the tuning alone: no register read and no
switch test would catch a woofer/tweeter swap. Without sense nothing
proves which amp plays which unit channel, so admit it for one amp only,
the case it exists for (the M4 Mac mini, J773g):

- wiring.derive() refuses no_sense_path for more than one amp;
- the supervisor's machine_for() takes derived-nosense only with
  amps == 1.

A missing "sense" counts as a hardware fact only when the back-end names
its speaker channel ("spkr"): the base T8132 node, which names only
"dma", keeps the family's sense. The static check's report now says what
a derived-nosense Mac was proven with (one amp, no sense, nothing to
order) instead of the J700's SD_MODE text, and the method choice is one
function, method_of().

Tests (test_wiring.py, NoSensePath): the J773g's device tree derives
derived-nosense, plugin 1ch, wiring d1d62e8a0aaaef3d (the record the Mac
made); a named "sense" keeps derived; no dma-names, an older record or a
node without "spkr" keep sense; other transports and the J616s's hash are
unchanged; spp3 and lsm2 with an LSID companion are refused; six amps
without sense are refused; read_dt() records dma-names; the static
report. The supervisor test adds the multi-amp refusal.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/aop-spkr-no-sense branch from fb71278 to c104ebd Compare November 20, 2026 01:31
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Review addressed in c104ebd, rebased onto main 766c0a3, after #213 and #215.

  1. One amp only.
    • wiring.derive() refuses no_sense_path for more than one amp.
    • The supervisor's machine_for() takes derived-nosense only with amps == 1.
    • Your Air-shaped case now fails. I used the J616s tree with "sense" dropped and plain lsm2: this Mac's speaker transport carries no V/I sense, which is admitted for one amp only; the order of its 6 amps would rest on the device tree alone.
  2. Python tests. NoSensePath adds 8 tests (79 in test_wiring.py now):
    • J773g → derived-nosense, 1ch, d1d62e8a0aaaef3d;
    • "sense" named → derived (5429615c…);
    • no dma-names, an older record, or no "spkr" → sense kept;
    • other transports and the J616s hash 164e7a0d23003bab unchanged;
    • spp3 refused, lsm2 + LSID refused;
    • six amps without sense refused;
    • read_dt() records dma-names (fake_dt now writes them);
    • the static report.
  3. PR body. It now says the base is main, and the PR base is set to main.

I took the non-blocking points too:

  • A missing "sense" counts only when the back-end names "spkr", so the base T8132 node's "dma" keeps sense.
  • The static report has its own text for derived-nosense.
  • The method choice is one function, method_of().

Local checks on this head (Arch aarch64, MemoryMax=2G scope):

Packaging that drops the patches once this merges: aurora-silicon/alarm-aurora PR (linked in the next comment).

🤖 Generated with Claude Code

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Packaging: aurora-silicon/alarm-aurora#373 pins both packages to main 766c0a3 (#213, #215) and carries this PR's two commits as patches. Once this merges I'll re-pin it to the merge commit and drop the patches.

🤖 Generated with Claude Code

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Independent re-review (pre-merge, safety first): head c104ebd6, base main 766c0a3

Verdict: ready to merge. Both blocking items from the previous review are fixed, and the new tests catch regressions of each one. I found no path that lifts the kernel floor without protection. Below are one coverage gap and one hardening idea; neither blocks the merge.

The two blocking items

  1. One amp only, enforced in both places.

    • wiring.derive() refuses no_sense_path when len(amps) != 1, before the unit-channel match.
    • machine_for() takes derived-nosense only for a sense family with amps == 1, and then demands sense == 0. With more amps it refuses ("admitted for one amp only").
  2. Python tests. NoSensePath adds 8 tests, so test_wiring.py goes from 71 to 79. They cover:

    • the J773g → derived-nosense, 1ch, d1d62e8a0aaaef3d;
    • a named "sense", missing or partial dma-names, and an older record;
    • other transports, and the J616s hash 164e7a0d23003bab;
    • the spp3 and lsm2+LSID refusals;
    • six amps without sense;
    • read_dt() recording dma-names;
    • the static report.

    The other points from that review are also done: "spkr" is required before a missing "sense" counts, the static report has its own wording, and the base is main.

Mutations

I applied each mutation alone, ran the suites, then reverted it.

Mutation Result
derive(): drop the one-amp check caught: test_several_amps_without_sense_are_refused
transport_senses(): drop the "spkr" requirement caught: test_missing_or_partial_dma_names_keep_sense
transport_senses() always true caught: 5 tests
derive(): drop the spp3 refusal caught: test_sense_units_are_refused
missing dma-names read as "no sense" caught: errors across the J616s/J815/atsp/Deferral classes
method_of() returns derived-static caught: 2 tests
static report back to the SD_MODE text caught: test_static_report_names_the_no_sense_case
record no_sense_path: False caught: 5 tests
machine_for(): drop if bind.amps == 1 caught: every_board_comes_from_its_record
machine_for(): accept the record's own sense count for derived-nosense caught: same test
machine_for(): a family without sense accepts derived-nosense caught: same test
run_locked(): in ("derived-static", "derived-nosense") → == "derived-static" survived: every session suite still passes (see the coverage gap below)

Safety re-check

  • Classification. A Mac loses sense only when its speaker back-end's transport has sense_dma (aop-spkr: the t6041 and t8132 compatibles) and the node names "spkr" without "sense". Every other case keeps the family's sense, and such a Mac still fails closed in the switch test, as on main:
    • no dma-names;
    • a None entry;
    • a record from before the names were read;
    • the base t8132.dtsi node's "dma".
  • Fixtures. All 13 fixture boards (J274 … J815) give the same hash, method, plugin, sense count and transport on main 766c0a3 and on this head.
  • Other Macs (linux integration/aurora 2c35f50):
    • The j414s (MCA), the M5 J714s (t6050-aop-audio, aop-dma), the Neo J700 (t8140, aop-t8140) and the J815 (aop-dma) have no sense_dma, so transport_senses() is always true for them.
    • J604, J713 and J715 (t8132-laptop.dtsi) and J614s, J616s, J614c and J616c (t604x.dtsi) name "sense".
    • No current Mac except the J773g takes the new path.
  • Units that read sense. spp3 is refused, and so is lsm2 with an LSID companion ("complete V/I sense bus"). A multi-amp tree without sense is refused in derive() and again in machine_for().
  • Binding.
    • The no-sense hash differs from the sense hash for the same amp (d1d62e8a… vs 5429615c…), and the session must report the recorded wiring. A device tree that later names "sense" therefore gives a different hash, and a stale derived-nosense record grants nothing.
    • covers() is unchanged.
    • The machine is still Sn012776: the gain readback against the blob's full scale and the fault-status check still run before a grant, and no sense binding is offered (bind.sense == 0).

Not blocking

  1. Coverage gap: run_locked() routing. No test checks that a derived-nosense wiring goes through static(). run_locked() has no else, so a method that no branch names would pass with no check at all, not even the speaker-PCM check. The head is correct: method_of() returns only the three names, and all three are handled. Two cheap guards:
    • a Deferral test like test_a_board_without_sense_is_never_deferred for the J773g fixture, expecting calls == ["static"];
    • a fail-closed else: errs.append(f"unknown method {w['method']}").
  2. Hardening: allowlist instead of denylist. derive() refuses sense-reading units by denylist (rl["kind"] in SENSE_UNITS), while describe() already treats an unknown unit_kind (None) as reading sense. An allowlist on the no-sense path (only atsp, and lsm2 without a companion) would also fail closed for a future unit kind. There is no impact today: UnitKind is a closed enum (spp3, atsp, lsm2).

Local runs

Arch aarch64, rustc 1.99, in a MemoryMax=2G scope, on head c104ebd:

🤖 Generated with Claude Code

@DjDeveloperr
DjDeveloperr merged commit f573f60 into main Nov 20, 2026
6 checks passed
sithglan added a commit to sithglan/speakerguardd that referenced this pull request Nov 21, 2026
The M6 Mac mini's (J873g) speaker back-end is the T8152 AOP
("apple,t8152-aop-audio"), which this derivation did not know:
describe() refused the Mac ("speaker back-end apple,t8152-aop-audio is
not a transport this derivation knows").

Add the transport: the T8152 configuration of t8152_aop_audio
(HW_CFG_T8152), one amp in one 32-bit slot, S24_LE, the ADMAC DMA of
the T8142 configuration. Whether its amp is sensed is not the table's
call. The entry carries the T6041's speaker_dma ("spkr") and sense_dma
("sense"), so the back-end node's dma-names decide, through the rule
from aurora-silicon#212.

The J873's card offers no sense PCM, so the entry says
"sense_channels": 0, and pcm_widths() refuses any wiring with sense
lanes on this transport. That can only refuse a Mac. The J873g's node
names its "sense" channel: the ADT's speaker stream has an RX, and its
amp's speaker-config names V and I slots. So the J873g is refused
("2 sense lanes on a 0-channel sense PCM") until its card carries the
sense PCM, or its node stops naming a sense channel because the stream
is shown to carry none. A node that names only its jack and speaker
channels derives the no-sense wiring (derived-nosense, one amp only,
the J773g's hash d1d62e8a0aaaef3d).

The J813's and J815's nodes list this compatible after
"apple,t8142-aop-audio", which matches first, so they keep the T8142
transport and their sense.

Tests: the J873g node as its device tree has it (with "sense"), and
one without dma-names, get a V/I pair and are refused for the missing
sense PCM; a node without a sense channel derives without sense; a
sense unit or several amps on that path are refused; the J815 keeps the
T8142 transport with its sense.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
sithglan added a commit to sithglan/speakerguardd that referenced this pull request Nov 24, 2026
The M6 Mac mini's (J873g) speaker back-end is the T8152 AOP
("apple,t8152-aop-audio"), which this derivation did not know:
describe() refused the Mac ("speaker back-end apple,t8152-aop-audio is
not a transport this derivation knows").

Add the transport: the T8152 configuration of t8152_aop_audio
(HW_CFG_T8152), one amp in one 32-bit slot, S24_LE, the ADMAC DMA of
the T8142 configuration. Whether its amp is sensed is not the table's
call. The entry carries the T6041's speaker_dma ("spkr") and sense_dma
("sense"), so the back-end node's dma-names decide, through the rule
from aurora-silicon#212.

The J873's card offers no sense PCM, so the entry says
"sense_channels": 0, and pcm_widths() refuses any wiring with sense
lanes on this transport. That can only refuse a Mac. The J873g's node
names its "sense" channel: the ADT's speaker stream has an RX, and its
amp's speaker-config names V and I slots. So the J873g is refused
("2 sense lanes on a 0-channel sense PCM") until its card carries the
sense PCM, or its node stops naming a sense channel because the stream
is shown to carry none. A node that names only its jack and speaker
channels derives the no-sense wiring (derived-nosense, one amp only,
the J773g's hash d1d62e8a0aaaef3d).

The J813's and J815's nodes list this compatible after
"apple,t8142-aop-audio", which matches first, so they keep the T8142
transport and their sense.

Tests: the J873g node as its device tree has it (with "sense"), and
one without dma-names, get a V/I pair and are refused for the missing
sense PCM; a node without a sense channel derives without sense; a
sense unit or several amps on that path are refused; the J815 keeps the
T8142 transport with its sense.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
joshuaswarren pushed a commit to joshuaswarren/speakerguardd that referenced this pull request Nov 25, 2026
…ense by name

Follow-ups from the review of aurora-silicon#212:

- run_locked() proved each method on its own branch and had no final
  else, so a wiring method no branch names would have recorded a pass
  with nothing checked. It now fails: "no check proves a '<method>'
  wiring".
- A transport that carries no V/I sense admitted every protection unit
  but spp3 (a denylist). It now admits only the units that run without
  sense, atsp and plain lsm2 (NO_SENSE_UNITS), so a unit added later is
  refused there until it is named. lsm2 with an LSID companion is still
  refused by the companion's own check.

Tests: run_locked() takes the static branch for a derived-nosense Mac,
deferred or not, and records a pass with method derived-nosense; an
unknown method fails with neither branch run (the test fails without the
new else); the allowlist admits atsp and lsm2 and refuses spp3, lsid and
an unnamed unit.

Signed-off-by: Diljit Singh <hey@djdev.me>
@RyanTheTide
RyanTheTide deleted the djdev/aop-spkr-no-sense branch November 27, 2026 13:21
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