Skip to content

ASoC: tas2764: J604 amplifier init and shutdown as macOS does them - #1894

Open
IronsideXXVI wants to merge 6 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-tas2764-shutdown-dance
Open

IronsideXXVI wants to merge 6 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-tas2764-shutdown-dance

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

The J604 (MacBook Pro 14" M4, T8132) has six SN012776 amplifiers. This series makes the driver set them up and shut them down the way macOS 26B123 does on this machine. Both behaviours were measured on the J604 by tracing the I2C3 controller under macOS.

Shutdown (patches 1-3). macOS brackets every software shutdown of all six amplifiers with writes to the vendor's hidden page 0xfd:

  • before: 0x0d = 0x0d, 0x64 = 0x04, 0x0d = 0x00
  • then PWR_CTRL shutdown
  • after: 0x0d = 0x0d, 0x64 = 0x00, 0x0d = 0x00

The writes come 0.59 s after the last mute; power-up and mute transitions carry none. tas2764.c already implements exactly this as TAS2764_SHUTDOWN_DANCE, but only as a switch for every amplifier at once through ENABLED_APPLE_QUIRKS, which leaves it off. These patches add a boolean apple,shutdown-dance property and honour it per amplifier, together with the dance's immediate-SDZ init step. The J604's six amplifiers set it.

Init (patches 4-6). This part was traced at boot, from the hypervisor's entry. Each amplifier's init matches the driver (the six enabled quirk sequences, the DC blockers, the brownout block from the boot loader's ADT copies, the TDM setup) except for three writes:

  • page 0 0x07 = 0x68
  • page 1 0x19 = 0x40
  • page 1 0x47 = 0x02

These patches add apple,init-writes, a list of (page, register, value) byte triples applied after the built-in quirks. Each triple is checked against the writeable-register list, which gains page 1 0x19. The J604's amplifiers get macOS's three.

Machines without either property are unchanged.

Checked on top of integration/aurora 1f5037a:

  • checkpatch --strict: 0/0/0 on all six patches
  • dt_binding_check DT_SCHEMA_FILES=sound/ti,tas27xx.yaml passes on the committed tree
  • CHECK_DTBS=y apple/t8132-j604.dtb reports nothing for either property, and the DTB carries both on all six amplifiers
  • the codec builds with no warnings

In our J604 kernel the same changes passed full arm64 builds. They have not run on the J604 under Linux yet; the register values are byte-for-byte what macOS writes.

(Updated 2026-11-14: the binding text in patch 1 had a colon that broke dt_binding_check, now reworded; patches 4-6 added.)

IronsideXXVI added a commit to IronsideXXVI/omarchy-j604 that referenced this pull request Nov 14, 2026
…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.
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.

Assisted-by: LLM
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.

Assisted-by: LLM
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.

Assisted-by: LLM
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
Apple machines can initialise their SN012776 amplifiers with a few
register writes beyond the driver's own sequence. Add a property that
lists them as (page, register, value) byte triples.

Assisted-by: LLM
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
macOS 26B123 initialises each of the J604's six SN012776 amplifiers
with three writes the driver does not make (traced at boot on the J604
with the I2C3 controller recorded from the hypervisor's entry): page 0
register 0x07 = 0x68, page 1 register 0x19 = 0x40 and page 1 register
0x47 = 0x02. Every other write of that init matches the driver: the six
enabled quirk sequences, the DC blockers and the brownout block from
the boot loader's copies of the ADT, and the TDM setup.

Apply the apple,init-writes triples after the built-in quirks at
initialisation, each checked against the writeable-register list (page 1
register 0x19 joins it). With apple,shutdown-dance the dance's init step
writes 0x07 = 0x60 first; a triple can then set another value.

Assisted-by: LLM
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
Set apple,init-writes on the J604's six SN012776 amplifiers to the three
writes macOS 26B123 makes at their initialisation and the driver does
not: page 0 register 0x07 = 0x68, page 1 register 0x19 = 0x40, page 1
register 0x47 = 0x02.

Assisted-by: LLM
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI
IronsideXXVI force-pushed the j604-tas2764-shutdown-dance branch from b8e9ffb to 20e0882 Compare November 14, 2026 13:19
@IronsideXXVI IronsideXXVI changed the title ASoC: tas2764: per-amplifier Apple shutdown dance, on for the J604 ASoC: tas2764: J604 amplifier init and shutdown as macOS does them Nov 14, 2026
IronsideXXVI added a commit to IronsideXXVI/omarchy-j604 that referenced this pull request Nov 14, 2026
…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.
@davishann15-commits

Copy link
Copy Markdown

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 integration/aurora 7c71d6d, plus #1543, #1894, #1895, #1917, #1918, #1919 and #1922. It booted on its own J604 tree as an aura-try trial. Userspace: Hyprland 0.57.2, mesa-aurora 26.3.0_devel.202611130318, speakerguardd-v2 1.0.0alpha.1-40.

I booted the same kernel twice:

J604 tree with apple,init-writes + apple,shutdown-dance (this series) Same kernel, tree without both properties
speakerguardd v2 silent switch test pass pass (record reused)
grant during playback yes, Speaker Volume 201 (0 dB), fault status 0 yes, Speaker Volume 201
amp 0x38 PWR_CTRL (page 0 0x02) during playback 0x99, MUTE set 0x98, active
page 0 0x07 0x68 (the init write) 0x20
audible (test signal at 30-35 %) nothing, three tries clear and clean

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 pmp-report. Without the properties the code paths of this series stay off, so the comparison isolates the two properties together. I did not test apple,init-writes and apple,shutdown-dance separately. I can test a build with only one of them, or with a single init triple, if that helps.


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

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

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 0x99. Your table points at the init writes: page 0 0x07 reads 0x68 on the silent boot.

Next on our side: read amp 0x38 page 0 0x02 and 0x07 during playback on our J604 and post the values here. If ours also reads 0x99, the silence is ours too and comes from these patches. If ours reads 0x98, the difference is in how the unmute reaches the amp, and we'll look at that path.

If you have the time, a build with only apple,shutdown-dance (no apple,init-writes) would split the two properties. That's the test you offered, and it's the useful one.

@davishann15-commits

Copy link
Copy Markdown

@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 aura-try boot of that kernel's own J604 tree, with only the amp properties edited (fdtput -d on the six codec@38..codec@3d nodes). Nothing else in the tree differs between the rows.

amp properties amp 0x38 PWR_CTRL (p0 0x02) p0 0x07 audible amp faults
both (this PR as is) 0x99 during playback (MUTE) 0x68 no, 3 plays at 30-35 % none
apple,shutdown-dance only 0x98 during playback 0x60 no, 2 plays at 30 % and 1 at 45 % fault: bad TDM clock on all six amps at every stream stop (20 lines in two stops), e.g. tas2764 1-003a: other context to the fault: 02,99,00,00,06
neither (control) 0x9a idle 0x20 idle yes, clean (2 plays at 35 %) none

In every boot, speakerguardd v2's silent switch test record was valid, every stream got its grant (Speaker protection granted / withdrawn: released by the owner), and Speaker Volume read 201 (0 dB) while granted. The control boot's 0x02/0x07 are idle values; my read during playback timed out (debugfs regmap reads of these amps take about 5 s each).

Two observations, for what they are worth:

  • With the dance, p0 0x07 reads 0x60, where the control reads 0x20. Bit 0x40 is set without any init write, so something in the dance path seems to reach page 0 0x07.
  • The faults only appear in the dance-only boot. In the full boot the amps stay muted, which may hide them.

I also have the opposite variant (apple,init-writes only) ready if you want that row too. I can also try a single init triple, or log the I2C transactions around a stream stop, if you tell me what would help most.


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

@davishann15-commits

Copy link
Copy Markdown

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

  • amp 0x38 PWR_CTRL during playback: 0x99 (MUTE). Page 0 0x07: 0x68.
  • Nothing audible: two plays at 35 % and two at 50 %.
  • speakerguardd v2's switch test passed on this kernel. Every stream was granted, and there were no amp faults.

So the rows in my previous comment stand with the storm gone: both properties mute, dance-only is silent with bad TDM clock at every stop, and neither plays clean.


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

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@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 tas2764.c matches this PR's head (20e0882) apart from a local boot hook, and our six codec@38..codec@3d nodes carry the same apple,init-writes and apple,shutdown-dance. So the amp code that plays here is the code that stays muted for you.

Our register values (idle only so far). With both playback PCMs closed, all six amps read page 0 0x02 = 0x81 (BOP_SRC, MUTE) and 0x07 = 0x68, on kernels 1.913 to 1.916. We don't have a read during playback yet; it needs Dylan's own audio playing, and we'll post it as soon as we have it. 0x07 = 0x68 matches your full-series row, so the init write lands the same way on both machines.

A note on 0x02: bits 3 and 4 are the VSENSE and ISENSE power-down bits (the inverted "VSENSE Switch" / "ISENSE Switch" DAPM controls). Ours are clear at idle (sense powered). Yours are set in all three rows, including the control that plays, so they don't explain the silence. Between your rows only the MUTE bit differs (0x99 vs 0x98).

Where we think the difference is. Your kernel and ours differ in sound/soc/apple/macaudio.c, not in the amp driver. Upstream's macaudio_j604_cfg sets .tweeter_hpf_granted = true, and playback waits for macaudio_spk_admitted(): speakersafetyd's J604 profile or a speakerguardd v2 lease. Our tree has neither the flag nor the spk_fixed_ceiling path, and our userspace is speakersafetyd, not speakerguardd v2. So our boots never take the grant path, and yours always do. Our best guess, not yet tested, is that the unmute after a grant (with the tweeter corner restore) and the dance's mute handling meet in a way that leaves MUTE set, and that the dance-only row shows the other side of the same race as bad TDM clock at stop.

Two rows that would split it. Either would help a lot:

  1. apple,init-writes only (the variant you have ready).
  2. This PR as is, with speakersafetyd (its J604 profile) in place of speakerguardd v2 for one boot, if your setup allows it. That keeps the amp properties and swaps only what admits playback.

On the stop-time bad TDM clock: we have a candidate change to the dance's stop sequence, but it is not verified. We'll push it here only after a boot that started a stream shows zero of those lines.

@davishann15-commits

Copy link
Copy Markdown

@IronsideXXVI, re your comment: here is row 1. With apple,init-writes alone, the speakers play clean. That leaves the shutdown dance as the property that silences them on this J604.

Same J604 and method as before: one aura-try boot of the 38.1/38.2 J604 tree with only apple,shutdown-dance removed from the six codec@38..codec@3d nodes. The kernel is the 38.2 build from my last reply: alarm-aurora's pkgrel 38 recipe on 7c71d6d plus #1543, this PR at 20e0882, #1895 at its 4th commit (no codec interrupt storm), #1917, #1918, #1919 and #1922. speakerguardd-v2 is 1.0.0alpha.1-41.

amp properties amp 0x38 p0 0x02 p0 0x07 audible amp faults
both (this PR as is) 0x99 during playback 0x68 no none
apple,shutdown-dance only 0x98 during playback 0x60 no bad TDM clock on all six at every stream stop
apple,init-writes only (new) 0x80 during playback 0x68 yes, clean (2 plays at 35 %) none
neither (control) 0x9a idle 0x20 idle yes, clean none

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 0x02, a correction to my earlier table: the control's 0x9a was an idle read (shutdown mode), because my read during playback timed out. So it doesn't show sense powered down while playing. In this row the read landed during playback: 0x80 has bits 3 and 4 clear, so V and I sense are powered, the same as your idle 0x81 apart from MUTE. The two rows with the dance read 0x98/0x99 during playback, with both sense power-down bits set. With the dance, sense is powered down during playback; without it, sense is on. 0x07 = 0x68 here matches the full row, so the init writes land the same with or without the dance.

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

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