Skip to content

Stop the Apple Studio Display flickering at 5K on T2 Macs - #9796

Open
phedoreanu wants to merge 2 commits into
omacom:quattrofrom
phedoreanu:t2-studio-display-hbr3
Open

Stop the Apple Studio Display flickering at 5K on T2 Macs#9796
phedoreanu wants to merge 2 commits into
omacom:quattrofrom
phedoreanu:t2-studio-display-hbr3

Conversation

@phedoreanu

Copy link
Copy Markdown

Problem

Plug an Apple Studio Display into a T2 MacBook Pro with the Radeon Pro (a MacBookPro16,1 here) and it comes up at 5120x2880@60, then flickers, glitches and periodically blacks out. 3840x2160 is stable.

The display advertises an HBR2 DisplayPort link through its Thunderbolt tunnel (Reported: 4 0x14 in amdgpu's debugfs). 5K@60 does not fit HBR2 uncompressed, so amdgpu enables DSC, and that HBR2+DSC path is what glitches: dsc_clock_en is 1 while it flickers. The panel trains fine at HBR3, where 5K needs no compression. Someone hit the same thing on the same machine and worked it out first: https://discuss.cachyos.org/t/29495

Fix

omarchy-hw-apple-display-link looks for connected connectors whose EDID names a StudioDisplay and writes 4 0x1e to that connector's link_settings in debugfs, which retrains the link at HBR3 right away. If the compositor had already set the 5K mode over the compressed link, it simulates a replug through trigger_hotplug so the mode gets set again over the new link. The preferred rate sticks to the connector until reboot, so it survives replugs and suspend.

A oneshot service runs the helper at boot and a udev rule starts it on every DRM hotplug. fix-t2.sh installs both on new T2 installs and a migration installs them on existing ones. The helper does nothing without a Studio Display and skips connectors that have no amdgpu debugfs files, so it is inert on other GPUs and other displays.

Verified

On the MacBookPro16,1: Current: 4 0x1e, dsc_clock_en 0, 5120x2880@60 with no flicker since. Putting the link back to HBR2 with DSC on and firing a real hotplug through trigger_hotplug had udev start the service and land the display on HBR3 without DSC. Simulated unplug/replug and a suspend cycle kept the preference. Camera, speakers, microphone and brightness through omarchy brightness display keep working.

test/shell.d/apple-display-link-test.sh runs the helper against a fake sysfs and debugfs tree (pins only connected Studio Displays, leaves other monitors and internal panels alone, replugs only a stream that stayed compressed) and the migration with stubbed lspci, sudo, systemctl and udevadm (installs, idempotent, skips non-T2). ./test/cli and test/shell.d/t2-hardware-test.sh pass.

The display advertises an HBR2 DisplayPort link through its Thunderbolt
tunnel. 5120x2880@60 does not fit HBR2 uncompressed, so amdgpu turns on DSC,
and that path flickers, glitches and blacks out on the Radeon Pro in T2
MacBooks. The panel trains fine at HBR3, where 5K needs no compression.

omarchy-hw-apple-display-link pins HBR3 on every connector whose EDID names a
Studio Display, through amdgpu's debugfs link_settings, and simulates a replug
when the compositor had already lit the panel over the compressed link. A
oneshot service runs it at boot and a udev rule on every DRM hotplug. The T2
setup installs both; a migration covers existing installs.
When the Studio Display comes back through Thunderbolt, udev raises several
DRM change events within a few milliseconds and each one starts the service.
The early runs find the connector not yet connected and exit at once, and
after five of them systemd's default start rate limit blocks the later ones,
which are exactly the runs that would have pinned the link. The display then
stays on the compressed HBR2 link and flickers. Seen on a MacBookPro16,1
after a resume. Turn the rate limit off; the script is idempotent and cheap.
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.

1 participant