Repository navigation
ASoC: tas2764: J604 amplifier shutdown as macOS does it - #1894
IronsideXXVI wants to merge 6 commits into
Conversation
…ng; rollback measured on the machine; upstream state STATUS.md: the 1.901 reset cause is confirmed on the machine (the memory-controller state read at probe, patch 0531): with that driver kept from starting, 1.901 starts, unlocks with no hands, joins the network and has 0 failed units. The rollback pieces are now measured on the machine: the last good kernel beside the new one, Limine's one-shot with the last good kernel as default, the 15 s Stage 1 window a second Mac can hold, the failed-boot count clear, and the forced USB-C port-controller reset. kernel/ is unchanged; the published series stays 1.888, the last kernel that passed all checks. UPSTREAM.md: new aurora-silicon/aurora-bless#6 and aurora-silicon/linux#1894; the rule for what we open on aurora-silicon/linux now; the panel colour matrix rebases onto the set_matrix conversion already upstream.
b8e9ffb to
20e0882
Compare
…writes; new #1895 (headset codec) UPSTREAM.md: #1894 carries the three amplifier initialisation writes macOS makes besides the shutdown sequence; #1895 gives the J604 headset codec the 20 probe writes macOS makes. Both are byte-for-byte what macOS writes on the machine and have not run under Linux yet.
|
On a J604 under Linux, this series leaves the speakers silent. The amplifiers stay muted during playback. Tested on a J604 (MacBook Pro 14", M4, Mac16,1; os-fw 26.6.2, system-fw 27.0; aura 1.0.0b13). The kernel was alarm-aurora's pkgrel 38 recipe on I booted the same kernel twice:
The tree without the properties came from a kernel without this series: it is the J604 tree of linux 2129f55 plus #1888, and it otherwise differs from the trial tree only by #1895, #1917 and #1919's properties the trackpad actuator node and two cell properties on Disclosure: an LLM (Claude) ran these tests on my Mac and drafted this. I did the listening and looking, reviewed it, and am responsible for it. Assisted-by: LLM |
|
Thank you, this is exactly the comparison we needed, and it's a real problem. I'm holding this PR until we understand it. Our own J604 runs these six patches in our kernel series (since our 1.905, now 1.913) and its six amplifiers play there. Our userspace differs from yours, though (speakersafetyd plus our own DSP graph, not speakerguardd-v2), and so does our tree. So we may never hit the path where an amp stays at Next on our side: read amp If you have the time, a build with only |
|
@IronsideXXVI, re your comment: here is the split you asked for. The shutdown dance alone also leaves the speakers silent, in a different way: the amps report active but stay silent, and fault at every stream stop. The same kernel with neither property plays clean. Same J604 and kernel as before (alarm-aurora's pkgrel 38 recipe on 7c71d6d plus #1543, #1894, #1895, #1917, #1918, #1919, #1922), speakerguardd-v2 1.0.0alpha.1-40. Each row is one
In every boot, speakerguardd v2's silent switch test record was valid, every stream got its grant ( Two observations, for what they are worth:
I also have the opposite variant ( Disclosure: an LLM (Claude) ran these boots and measurements on my Mac and drafted this. I did the listening, reviewed it, and am responsible for it. Assisted-by: LLM |
|
@IronsideXXVI One more data point. The amp silence is not caused by the cs42l84 interrupt storm from #1895. I rebuilt the same kernel with #1895's fourth commit (c0a5945, code-identical to f0ca074) and checked that cs42l84 and both I2C controllers show 0 interrupts in 10 s. Then I booted this PR as is (both properties) on its own J604 tree:
So the rows in my previous comment stand with the storm gone: both properties mute, dance-only is silent with Disclosure: an LLM (Claude) ran these tests on my Mac and drafted this. I did the listening, reviewed it, and am responsible for it. Assisted-by: LLM |
|
@davishann15-commits Thank you for the split and for ruling out the #1895 storm. Here is what we have on our side, and what we don't have yet. Our J604. The six amps play on our J604 with this series: Dylan listened on our 1.914 kernel, playing his own audio. Our Our register values (idle only so far). With both playback PCMs closed, all six amps read page 0 A note on Where we think the difference is. Your kernel and ours differ in Two rows that would split it. Either would help a lot:
On the stop-time |
|
@IronsideXXVI, re your comment: here is row 1. With Same J604 and method as before: one
As in the other rows, the speakerguardd v2 self-check and switch test passed, and each stream got its grant and was released at its end. On About row 2: I'd rather not run the speakers under speakersafetyd on this Mac. On this J604, speaker protection is speakerguardd v2, set up as Aurora's maintainers asked for this board. The speakersafetyd J604 board file is still in review (alarm-aurora#320), and I don't want to play through the speakers under a protection setup that hasn't been checked on this machine. If you have another way to split the grant path that keeps v2, I'm glad to run it. For example, a debug parameter or a test patch that skips the tweeter-corner restore on a grant, or one that leaves the unmute alone. I can also test your stop-sequence change when it's up. Disclosure: an LLM (Claude) ran this boot and the measurements on my Mac and drafted this. I did the listening, reviewed it, and am responsible for it. Assisted-by: LLM |
|
@davishann15-commits thanks, row 1 settles it. With So the init writes will go up as their own PR: binding, driver and J604 DT, on current integration/aurora. This PR goes back to draft with only the shutdown dance. Our tree also masks the TDM clock error on amps that dance (062e74cd71). It hasn't been tested on a granted stream, so it stays out of here until it has. I'll link the new PR here once it's open. |
Some Apple machines bracket every software shutdown of their SN012776 amplifiers with writes to the vendor's hidden page 0xfd. Add a boolean property that tells the driver to do the same on that amplifier. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
macOS brackets every software shutdown of the J604's six SN012776 amplifiers with writes to the vendor's hidden page 0xfd: 0x0d = 0x0d, 0x64 = 0x04, 0x0d = 0x00, then PWR_CTRL shutdown, then 0x0d = 0x0d, 0x64 = 0x00, 0x0d = 0x00. Measured on the J604 under macOS 26B123 with the I2C3 controller traced around a short system sound: the same sequence on all six amplifiers, 0.59 s after the last mute; power-up and mute transitions carry no hidden-page writes. The driver already implements exactly this as TAS2764_SHUTDOWN_DANCE, but only for every amplifier at once through ENABLED_APPLE_QUIRKS, which leaves it off. Honour the "apple,shutdown-dance" property on SN012776 amplifiers, with the dance's immediate-SDZ init step. Machines without the property are unchanged. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
Set apple,shutdown-dance on the J604's six SN012776 amplifiers, the sequence macOS 26B123 writes on all six at every software shutdown. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
20e0882 to
cdce368
Compare
|
The init writes are now #2595 (binding, driver and J604 DT, on This PR is rebased onto the same base and holds only the shutdown dance (patches 1-3). It stays a draft until I understand why the dance leaves the speakers silent on @davishann15-commits' J604. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Review of the draft; nothing here needs action before you're ready.
-
davishann15-commits' rows settle the current state:
- with the dance, V and I sense read powered down during playback (
0x98/0x99); - the speakers are silent, and with the dance alone they fault with
bad TDM clockat every stream stop; - without the dance they play clean.
Until that's understood this can't go in, as you say.
- with the dance, V and I sense read powered down during playback (
-
When it comes back, the selection question from #2595/#2615 applies here too. The dance is already a built-in quirk (
TAS2764_SHUTDOWN_DANCE). If macOS does it on every SN012776, the quirk mask is the place, as #2615 does for page 00x07and page 10x47. A per-boardapple,shutdown-danceproperty would need a stated hardware reason why the J604 differs. -
Once #2615 is in, its init write leaves page 0
0x07at0x68after the dance's own0x60(immediate SDZ) init step. When you retest the dance, check which value the dance actually needs there, since the silent rows differ in exactly that register.
|
Thanks, noted. When I retest the dance I'll check which page 0 |
cdce368 to
a202f14
Compare
|
Blockers: 1.
Nit: the dance init step (tas2764-quirks.h:104) writes the whole of page 0 CI (host-tests, dt-checks) passes, the commits carry a human Signed-off-by, and machines without HW row: J604 on this head with the return-value fix, speakerguardd v2 granted stream: page 0 Assisted-by: LLM (Claude:Opus 5.5) |
tas2764_update_pwr_ctrl() returned the shutdown dance helper's result unchanged. The helper ends with snd_soc_component_update_bits(), which returns 1 when it changed the register, and both callers in tas2764_mute() treat any non-zero value as an error: - unmute: SHUTDOWN -> MUTE returns 1, so tas2764_mute() returns before it sets unmuted and writes MUTE -> ACTIVE. The amplifier stays in MUTE for the whole stream. - mute: ACTIVE -> MUTE returns 1, so the ramp wait, stream_stopped and the deferred shutdown are skipped. The amplifier is still in MUTE when the bus clock stops, and the fault handler reports the clock loss. Map a positive result to 0, as the plain path already does. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…undo it tas2764_do_quirky_pwr_ctrl_change() chained its steps on !ret, and the shutdown write in the middle is an update_bits() that returns 1 when it changes the register. So on every real ACTIVE or MUTE -> SHUTDOWN transition the post sequence was skipped: 0xfd:0x64 stayed at 4. The final update_bits() then overwrote ret, so a failed pre sequence was lost as well. Treat only a negative value as an error, keep the first one, and always run the post sequence once the pre sequence has been tried, so 0xfd:0x64 goes back to 0 and the hidden page is deselected even when a step before it failed. Return 0 on success. The helper is reachable from the device tree for the first time with apple,shutdown-dance. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
The dance's init step wrote all of page 0 0x07 (0x60), so the final value depended on which init write ran last. The register is MISC_CFG2 in the TAS2764 data sheet (reset 0x20): SDZ_MODE in bits 7:6, SDZ_TIMEOUT in 5:4 and DVC_RAMP_RATE in 3:2. Name it, and set SDZ_MODE to immediate with regmap_update_bits(), so the other fields keep what reset and the other writes left. From reset the register ends at 0x60 as before. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
|
Thanks Ryan, you were right on both.
Nit: the init table no longer writes all of page 0 These are three small commits on top, so the earlier ones are easy to compare. I can squash them before merge if you'd rather. What I ran on the new head (1c00ab3): checkpatch --strict is clean on all three commits. clang and gcc builds of the codec and the J604 dtb at W=1 give no warnings. The dtb check shows no new warnings against the base, and the ti,tas27xx binding passes. The host test suite gives 423 passed and 28 failed on both this head and the old head, with the same four failing suites (GPU and Thunderbolt tests, nothing in sound). How bad it was on the J604, from reading the code (not from a trace): with the deferred shutdown, every stream starts from SHUTDOWN. The first write in mute() is SHUTDOWN -> MUTE, which returns 1, and mute() returned before the MUTE -> ACTIVE write. So as far as I can tell, all six amps sat in MUTE through every stream since the dance went on for this machine. That also means the earlier rows in the description (amps in MUTE during playback, Nothing from this head has run on the J604 yet. The same two fixes go into my next J604 kernel. Your HW row is queued on it, and on the current kernel first, so there is a before and after: page 0 Overlap: #1895 touches t8132-j604.dts. #2615 adds the same |
The J604 (MacBook Pro 14" M4, T8132) has six SN012776 amplifiers. macOS 26B123 brackets every software shutdown of all six with writes to the vendor's hidden page 0xfd. I measured it on the J604 by tracing the I2C3 controller under macOS:
0x0d = 0x0d,0x64 = 0x04,0x0d = 0x00PWR_CTRLshutdown0x0d = 0x0d,0x64 = 0x00,0x0d = 0x00The writes come 0.59 s after the last mute; power-up and mute transitions carry none.
tas2764.calready implements exactly this asTAS2764_SHUTDOWN_DANCE, but only as a switch for every amplifier at once throughENABLED_APPLE_QUIRKS, which leaves it off. These patches add a booleanapple,shutdown-danceproperty and honour it per amplifier, together with the dance's immediate-SDZ init step. The J604's six amplifiers set it.Machines without the property are unchanged.
Why this is a draft. On a second J604, @davishann15-commits found that with the dance the speakers stay silent: V and I sense read powered down during playback (
0x02=0x98/0x99), and with the dance alone every stream stop reportsbad TDM clockon all six amps. With only the init writes they play clean. Until I know why, this stays a draft and is not meant for merging.The init writes that used to be patches 4-6 here are now their own PR: #2595.
Checked on top of
integration/auroradf62a8c:tools/asahi/run-host-tests.pyandscripts/dtc/apple-dt-check.sh, as the CI runs them: the same results as on the base (checkpatch clean;run-host-tests.pyfails only the tests that also fail on the base on my arm64 host, no rustc 1.96 there;apple-dt-check.sh: binding ok, no new DT warnings; ADT coverage and DART power-domain checks pass)(Updated 2026-11-20: rebased onto
integration/auroradf62a8c; the init writes moved out to #2595.)(Updated 2026-11-21: three commits on top from Ryan's review: the dance path no longer passes update_bits()'s 1 up as an error, the post sequence always runs, and only the SDZ mode field is set. From reading the code, the first one alone keeps every amp in MUTE for the whole stream, which may explain the silence above; the J604 rows run again on the new head before I draw conclusions.)
Assisted-by: LLM (Claude:Opus 5.5, Claude:Fable 5.2)