Skip to content

appletbdrm: power the T1 display off over system sleep with SOCW - #58

Open
makoni wants to merge 1 commit into
standardagents:mainfrom
makoni:socw-sleep
Open

makoni wants to merge 1 commit into
standardagents:mainfrom
makoni:socw-sleep

Conversation

@makoni

@makoni makoni commented Nov 3, 2026

Copy link
Copy Markdown

On my MacBookPro14,3, with the lid open, the right-hand part of the Touch Bar strobes for the whole of an s2idle sleep. The suspend callback parks the display (HID feature report 3 = 1), and on the T1 that only sets the display brightness factor to 0: the panel stays powered and keeps refreshing. Writing report 3 = 1 on an awake host gives the same strobe without any sleep (seen on 7.2.8 and 7.2.15).

macOS does not park the display at sleep. It evaluates the ACPI method SOCW on the T1's device with argument 0 before sleep ("host sleep") and with argument 1 after wake ("host awake"), and the T1 powers its display off and back on. The legacy apple-ibridge driver did the same in its suspend and resume callbacks.

This change sends that pair from a system PM notifier:

  • PM_SUSPEND_PREPARE sends SOCW(0), and PM_POST_SUSPEND sends SOCW(1) if this module evaluated SOCW(0) for that sleep, including when the evaluation failed. Hibernation, runtime autosuspend and probe never evaluate SOCW. The module takes a reference to itself for a sleep it answers, so it is still loaded at the post.
  • The method is looked up at T1 probe: the unique single-argument SOCW below the USB host controller's ACPI node, the same way t1_cfgsel finds FRST. It is not evaluated at probe.
  • If SOCW(0) was acknowledged (result 0), the USB suspend callback skips the park, because the panel is already off. Otherwise the notifier logs the result and the callback parks as before.
  • The state is kept per module, not per interface, so SOCW(1) is still sent if the T1 re-enumerates over the sleep.

Sending SOCW(0) and then SOCW(1) on an awake host, with no real sleep between them, left the display dark here until a full power-off, so nothing but the sleep notifier sends it. PM_POST_SUSPEND also follows an aborted suspend; the awake write is still sent then, because skipping it would leave the display off.

How this composes with #47 and #49 is not tested. When SOCW(0) is acknowledged nothing is parked, so there is nothing to unpark; they still apply to the fallback path.

Testing

  • make -C kernel/appletbdrm-t1 test sanitize passes, with new cases for the notifier, the park decision, a re-enumerated device, the module reference and init/exit unwinding.
  • The module builds against 7.2.15 with W=1 without warnings, and make kernel passes. I could not run make quality (no Rust toolchain here), so the Rust and policy stages are left to CI.
  • Hardware: MacBookPro14,3, Linux 7.2.15, s2idle for 20 s, lid open, this module loaded and no SOCW sent from userspace. No SOCW warning was logged (the driver warns on any non-zero result), report 3 read back awake after resume, which is consistent with the park having been skipped, and the strip was dark without a strobe during the sleep and fully lit after it. Earlier, the same sequence sent from a userspace sleep hook behaved the same way.

Not tested: S3, other models, and a re-enumeration across a real sleep.

Refs #18

The driver parks the T1 display at suspend (HID feature report 3 = 1).
On the T1 that only sets the brightness factor to 0: the panel stays
powered and keeps refreshing, and on a MacBookPro14,3 the right-hand part
of the strip strobes for the whole sleep with the lid open.

macOS instead evaluates the ACPI method SOCW on the T1's device before
sleep (argument 0, host sleep) and after wake (argument 1, host awake),
and the T1 powers its display off and back on. Do the same from a system
PM notifier: SOCW(0) at PM_SUSPEND_PREPARE and SOCW(1) at
PM_POST_SUSPEND, never for hibernation, runtime autosuspend or at probe.
The method is discovered once below the T1's USB host controller ACPI
node. When SOCW(0) is acknowledged, the suspend callback skips the park;
otherwise park stays the sleep path. The state lives in the module, so
the awake write is still sent when the USB device re-enumerates over the
sleep.
@hanscnelson

Copy link
Copy Markdown

Reproduced the dark strip after S3 on a MacBookPro14,2 with stock 0.1.12, Omarchy 4.5.0-3, kernel 7.2.15-1-omarchy. Two deep suspends this morning (about 2 minutes, then about 7). display-open did not run again, card0-USB-1 stayed connected/enabled/On, and the pixels stayed off. USB remained 05ac:8600 configuration 2. Details are on #18.

This branch is not installed here, so this is not a test of the SOCW notifier.

@hanscnelson

Copy link
Copy Markdown

On this MacBookPro14,2, stock t1bridge 0.1.12-1 left the strip dark after S3. Report 3 byte 1 was already 0x02, and a later display-open had not relit it. Calling \_SB.PCI0.XHC1.RHUB.ASOC.SOCW 0x1 through acpi_call returned 0x0, and the strip relit.

The method is in SSDT6 on this machine. The DSDT does not contain it. FRST was not called. This was one manual call hours after resume, not a test of this branch.

@makoni

makoni commented Nov 5, 2026

Copy link
Copy Markdown
Author

@hanscnelson, thanks for the manual SOCW call on a 14,2. The method path matches my 14,3, and this PR has so far only been tested with s2idle, so S3 is the missing part.

One difference from your manual call: the PR sends SOCW(1) only after a sleep for which it sent SOCW(0). It doesn't send SOCW(1) on its own, so it wouldn't have relit a strip left dark by a sleep it didn't handle.

If you'd like to try the S3 side without building the branch, the sleep hook in omacom/omarchy#11570 (omacom/omarchy#11570 (comment)) sends the same pair from userspace alongside stock 0.1.12; I ran it that way before s2idle. It logs each result, so journalctl -b -t t1-socw-sleep shows whether the T1 answered 0x0 before and after each sleep. If that shows nothing after a sleep, the hook didn't run: it needs acpi_call-dkms and the executable bit. Don't run the script by hand to try it; let a real suspend run it. Sending SOCW(0) and then SOCW(1) on an awake machine left my strip dark until a full power-off.

What I'd most like to know is whether the strip comes back after a deep suspend without a manual call. I haven't sent SOCW(0) before S3 myself. Please use either the hook or the branch, not both: with both, each sleep would get the pair twice, which I haven't tested.

@hanscnelson

Copy link
Copy Markdown

One deep suspend on this MacBookPro14,2 with the userspace hook from omacom/omarchy#11570, stock t1bridge 0.1.12-1, Omarchy 4.5.0-3, kernel 7.2.15-1-omarchy. The #58 branch is not installed. acpi_call-dkms was already present. The hook is /usr/lib/systemd/system-sleep/t1-socw-sleep.

journalctl -b -t t1-socw-sleep:

  • 2026-11-05 10:51:36 CST pre: SOCW(0x0): 0x0
  • 2026-11-05 10:52:30 CST post: SOCW(0x1): 0x0

The kernel logged PM: suspend entry (deep) and PM: suspend exit at those same times, about 54 seconds apart. No manual SOCW call after this sleep.

The strip was dark at the first look after the lid opened. The keyboard and trackpad were frozen for a bit, then a password login worked. Touch ID was not tried. By the time the session was unlocked the strip was lit. t1-touchbar-hw did not run display-open again. The renderer finished an overlay about two seconds after SOCW(1), and the desktop provider was briefly unavailable before it recovered.

An earlier deep suspend at 10:40 CST was before this hook existed, so it is not part of this result.

This branch has not been deployed

No deployments
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