Repository navigation
provision: compile and wire the built-in microphone as the default input, apart from the speakers - #283
Conversation
Each fixture now records its device tree's microphone array ("mic": the
enabled AOP audio node that lists the array's stream in dma-names, or
null on a Mac without one), read by wiring.read_mic_dt from the kernel's
device trees. wiring.describe_mic gives the array's card, capture PCM,
channel count and rate from that node and the audio block's compatible
(MIC_TRANSPORTS, the drivers' fixed layouts, like TRANSPORTS for the
speakers).
gen.py emits two files for every machine with an array:
- pipewire/sgv2-mic-<m>.conf: the array's PCM as an ALSA source of our
own (hw:CARD=<card>,DEV=<n>, raw channels, priority 100) and a
filter-chain around the sgv2_mic plugin that publishes the processed
channel as "Built-in Microphone" (priority 2005, the priority
asahi-audio gives its microphone filter).
- wireplumber/61-sgv2-mic-<m>.conf: WirePlumber's own node for that PCM
is disabled. asahi-audio attaches its microphone filter to that node,
so with both files linked there is one processed source, and without
them asahi-audio's filter is unchanged.
wiring.py also gains the blob header reader (magic, lengths, CRC, the
bound board, rate, microphone count, version, partial flag) and a host
for the plugin's microphone variant that runs one silent block and
returns its health and latency outputs. Provisioning uses both.
The speaker files, the wiring derivation and its hash are unchanged.
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…peakers speakerguardd-provision run now has a microphone step after the speaker steps. On a Mac whose device tree has a microphone array it compiles the same bundle's microphone chain (mic-compile, never --allow-partial) into /var/lib/speakerguardd/mic.bin, bound in mic.bind to the board, the unit, the bundle's digest, the compiler and the blob version the plugin takes; any change, or a blob whose header is not this Mac's, compiles again, so a blob of an older version is never kept. Only when the blob's header names this board, the array's rate and microphone count and the plugin's version, carries no partial flag, and the packaged plugin runs it with health 0 is the blob published (/run/speakerguardd/mic.bin) and the microphone graph written to /run/speakerguardd-graph/mic. The seat user's graph unit links both of its files or neither. Anything else (a refusal, a partial design, no microphone PCM, a plugin that refuses the blob) removes the blob and the files, records why in mic.json (pass, absent or refused), and leaves the distribution's microphone graph in use. A Mac without an array has no such step. The step runs after the speakers' records are written, keeps its own blob, binding, record and graph directory, and cannot change the speakers' result or the exit status. The speaker graph's digest, its clearing and the sleep hook do not see the microphone files. speakerguardd-selfcheck gains `mic`, the microphone's verdict (the header checks and one silent block through the packaged plugin, in a process of its own). `verify` reports it beside the speakers' result, never as one of its steps. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
graph-user installs the microphone links independently. If either filename is occupied by a user file or one symlink creation fails, the other link can still be installed, despite the stated both-or-neither contract. A lone WirePlumber rule can change the input graph without its processed source. Preflight the pair and roll back app-owned partial links on failure while preserving user files and speaker state. Add collision and second-link failure tests, then provide the live fallback row.
Review: graph-user linked the two microphone files independently, so a file of the user's at one name, or a link that failed, could leave one of them linked. A WirePlumber rule alone leaves no microphone; the PipeWire file alone, two. Check both names first; if either is taken by something that is not our link, link neither and remove whichever half of ours is there. If making the second link fails, remove the first. Only our own links are ever removed: the user's files, the speaker graph and the raw rules stay as they are. New tests: a user file at either name leaves neither link and the file untouched (and both come back once it is gone); a failing second link removes the first. The speaker state is unchanged in both. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
|
Review at 98bc160 addressed in 4edafdf. graph-user now links the microphone pair both-or-neither:
New tests: a user file at either name leaves neither link and the file intact (both come back once it is gone), and a failing second link removes the first. The speaker state is unchanged in both. Results: test_provision 143 OK, test_wiring / test_verify / test_session OK, Live row: still pending a decision (it needs a whole-tree bind of the speaker stack, or the package; see the lane notes). |
There was a problem hiding this comment.
The pair is now preflighted before installation, and a failed creation removes matching app-owned links while preserving user files. The added fixtures cover collisions in both positions and the second-link failure while checking speaker state. Code approved. Hosted checks and the live fallback row remain pending.
|
T6000 / J316s (M1 Pro), 4edafdf, PASS: capture-only row, nothing played. Setup: Fedora 45, 7.3.0-aurora-fleet89, Enforcing. speakerguardd-v2 RPM built from this head with fedora-aurora's speakerguardd-v2.spec (0.62), installed over 0.53 by RPM upgrade, reboot. Restored to 0.53 afterwards.
|
|
@aurora-silicon/core @aurora-silicon/omarchy-mac @DjDeveloperr: merge notice. App approval (adversarial) at |
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
The microphone tests need every fixture to say whether its Mac has an array. The J873g (Mac mini, M6) fixture came in with #285 after this branch was cut, so it had no "mic" key and test_wiring failed once main was merged in. Its AOP audio node at linux#3434 (23235970) lists dma-names "cout cin spkr" with no microphone stream, and read_mic_dtb() on that compiled t8152-j873g.dtb returns None. So "mic" is null, as on the other desktop Macs. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
|
Merge-train note: #283 merged with current main fails test_wiring. Fixed on the branch, re-review needed. Once #285 (J873g fixture) landed on main at 17:03, Pushed, no force:
Tested at f908625 (buildbox)
The push dismissed the approval at 4edafdf. Re-review is needed at f908625. The delta is the main merge plus one fixture line. The J316s row at 4edafdf still covers the microphone code, because the delta only touches the j873 fixture and main's own changes. |
There was a problem hiding this comment.
Verdict: MERGE at f908625 once required checks pass.
Checked: The forward merge brings in the J873g fixture and the only following commit adds mic: null. I traced J873g's exact DTS include: its enabled T8152 AOP audio lists cout, cin and spkr. The runtime microphone transport requires hpai, so the null fixture matches the device tree and keeps J873g out of the generated microphone graphs. The merge train reports exact wiring, session, provision, verify and upgrade suites passing.
|
Merge at
Revert: |
|
Merged as d9608fd. Revert: |
What: Wires the built-in microphone chain (#276, #277, #280) into speakerguardd v2's provisioning and session files. On a provisioned Mac whose microphone design compiles whole, the default input becomes the processed "Built-in Microphone" (the
sgv2_micplugin on the Mac's own tuning), and the raw array stays listed below it.speakerguardd-provision run): a microphone step after the speaker steps, with its own blob, binding, record and graph directory.mic-compile(never--allow-partial) into/var/lib/speakerguardd/mic.bin, bound inmic.bindto the board, the unit, the bundle digest, the compiler and the blob version the plugin takes. Any change compiles again, so a blob of an older version is never kept./run/speakerguardd/mic.binand the graph is written to/run/speakerguardd-graph/mic/.mic.json(pass,absentorrefused).gen.py, checked in per fixture with an array, written at runtime from the live device tree and card):sgv2-mic-<m>.conf: the array's PCM as our own ALSA source (hw:CARD=<card>,DEV=<n>, "Microphone Array (raw channels)", priority 100) and the filter-chain that publishes "Built-in Microphone" (priority 2005, the value asahi-audio gives its microphone filter, so its headset rules still sit above it).61-sgv2-mic-<m>.conf: disables WirePlumber's own node for that PCM.node.software-dsprule onapi.alsa.path = "hw:<card>,<n>"). With that node disabled the filter is not created, and our node's path matches none of its rules. Without our files nothing is linked and its filter is exactly as today. The runtime generator in asahi-audio#30 matches the same path form, so it is covered the same way.wiring.read_mic_dt, recorded in each fixture asmic), plus the audio block's compatible for the driver's fixed card suffix, PCM, channel count and rate (MIC_TRANSPORTS, likeTRANSPORTSfor the speakers). On a running Mac the PCM is found by its id on that card. No board list.speakerguardd-selfcheck micgives the microphone verdict (header checks, then one silent block through the packaged plugin in a process of its own).verifyreports it in amicfield beside the speakers' result, never as a step.Failure modes:
Tested:
python3 -I:gen.py --checkclean;test_wiring.py116 pass (1 skipped as on main),test_session.py61,test_provision.py141 (29 new),test_verify.py23 (1 new);packaging/upgrade/tests82;tools/check-clean.shclean.--allow-partialis refused and the flag is never passed; a stale blob version compiles again; a bound blob is kept and each bound field recompiles; boards without an array run no step; no PCM isabsent; a speaker failure does not stop the microphone; an exception in the microphone step does not change the exit status; a session links both files or neither.crates/,packaging/systemd,parity.json,gate.json, the session helper, the gate, or anysgv2-<m>.conf/60-sgv2-<m>.confdiffers from main. One test runs provisioning with and without a microphone node and compares the speaker blob,provision.bind,provision.json,speakerguardd.conf, the raw-PCM rules and the graph digest: identical.speakerguardd-selfcheck mic→pass, health 0, latency 1439 frames.sgv2-mic-j316.confand the real plugin: the filter-chain loads andsgv2.mic.j316appears asAudio/Source"Built-in Microphone", priority 2005. With no such card the raw node is not created and PipeWire still starts (nofail). All 16 generated files parse withspa-json-dump.micentries come from the kernel's device trees at aurora-silicon/linux main (deb2df2), compiled and read withwiring.read_mic_dtb: arrays on J293, J313, J316s, J413, J493, J616s, J700, J815; none on J274, J375c, J473, J474s, J475c.Risk: two-way · on Macs where the microphone design compiles whole, the default input changes from asahi-audio's microphone filter to sgv2's processed source at the next session start. A plain revert (or removing
mic.bin) returns asahi-audio's filter at the next session start. The speaker path is not changed.Not yet: