Repository navigation
drm/apple: m4: keep the sink's primaries in the external EDID - #3259
themartiano wants to merge 1 commit into
Conversation
The EDID an M4 external output publishes goes through dcp_edid_sdr(), written for the native26 outputs and their sRGB output contract. Besides the colour capabilities it zeroes the ten chromaticity bytes, so the connector describes a sink whose red, green, blue and white are all 0,0: no gamut at all. A compositor that maps into the EDID's gamut builds its matrix from these bytes, and a zero set is singular. The M4 path has no such contract. Its link uses a colour element of the sink's own timing, which on an Apple Studio Display is Default RGB, the sink's native gamut: its primaries are the ones frames are shown with. Keep them, through dcp_edid_sdr_native(). Everything else dcp_edid_sdr() removes still goes, and the native26 outputs keep the bytes zeroed. Signed-off-by: Eduardo <git@martiano.me>
84035c3 to
ab7b871
Compare
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
maralcbr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at ab7b87192d77
Blockers:
- Hardware row at head: the 2026-11-26 J713 row ran on a batched kernel from
ba29027e1580(2,805 commits behind the rebase base, including unmerged #2807) and predates #3321 (M4 external idle-off) onmain. Please post one J713 + Studio Display row atab7b87192d77(or a batched M4 candidate containing it unchanged on currentmain) showing non-zero published EDID chromaticities, valid checksum,cm = edid, and the same after one idle-off and wake. Once posted, this is ready to approve and merge without a full re-review.
Checked: code is clean with no blockers; no Apple material, no chip/board/firmware gates, no new parameters, DCO matches author; bounds, checksum, memory handling, native26 isolation and #3321 idle-off interaction verified; hosted CI (Apple build and KUnit, Host tests, pr-text) is green at ab7b87192d77.
Evidence
drivers/gpu/drm/apple/dcp-sdr-edid.h:91-104:dcp_edid_sdr_native()validatessize >= 128before reading bytes 25..34, restores primaries only whendcp_edid_sdr()returns non-zero (every other size/extension rejection happens insidedcp_edid_sdr()before any write), and recomputes block-0 checksum afterward; extension compaction only writes at offset >= 128.drivers/gpu/drm/apple/iomfb_m4.c:3342-3358: allocation/free path (kmemdup->drm_edid_alloc->kfree) unchanged; only a 10-byte stack array added.- Non-M4 isolation:
dcp_edid_sdr()is unchanged; its only other caller (iomfb.c:3106) keeps zeroed primaries as pinned bytools/asahi/dcpext26-edid-tests.py:71. - Tests:
dcpext26-edid-tests.py:80-86checks restored chromaticities, byte-equality withdcp_edid_sdr()elsewhere, checksum, and size bounds;rate.py:1075-1078marks inlinedstatic inlinehelpers__attribute__((unused)). - Current
main(6ee70d49c228): merges cleanly; #3321 idle-off EDID re-reads go through the same helper (iomfb_m4_ext_edid_sdr()), so primaries stay consistent across idle-off cycles. - Hosted CI at
ab7b87192d77:Apple build and KUnitpass,Host testspass,pr-textpass. - Non-blocking notes:
- Until #3260 lands,
dcp_m4_ext_color_rank()still prefers sRGB/BT.709 over Default RGB, so the commit message's "its primaries are the ones frames are shown with" holds for Default RGB sinks (like the Studio Display) rather than sinks offering both; #3260 closes that. - Optional follow-up test: assert a failing
dcp_edid_sdr_native()(e.g. non-multiple-of-128 size or invalid extension count) leaves the buffer untouched.
- Until #3260 lands,
There was a problem hiding this comment.
Verdict: MERGE at ab7b871
Checked: The native-gamut EDID path restores exactly the ten sink chromaticity bytes and recomputes the base-block checksum. It still drops the same unsupported colour capability blocks and keeps the same size checks and audio/timing data. The existing sRGB path uses its original helper. The exact EDID suite passed under both Clang and GCC with AddressSanitizer and UndefinedBehaviorSanitizer, including short and inconsistent inputs, native primaries and checksums.
What: The EDID of an M4 external output goes through
dcp_edid_sdr(), which zeroes the ten chromaticity bytes for the native26 outputs' sRGB contract. The M4 link uses the sink's own colour element (Default RGB, the native gamut, on an Apple Studio Display), so a compositor that maps into the EDID's gamut gets all-zero primaries and a singular matrix. Keep the bytes on the M4 path. Fix on top of #2166.Tested: J713 (13-inch M4 MacBook Air, firmware 26.6.2) at
84035c3c66ef, 2026-11-26, Apple Studio Display over Thunderbolt: PASS. The published EDID has the display's Display P3 chromaticities, not zeros; Hyprland 0.57.2 drives it withcm = edidat 5120x2880; a person judged the picture sharp and the colours right. The kernel (7.3.0-0.next2) was mainba29027e1580merged with all our M4 display and other branches and #2814, #2797, #2807, #2672, not this branch alone. This commit's tree is identical to the one booted (88d9d0c58348; only the Signed-off-by was added). Regression on that kernel: 0 failed units, no oops, crash or stall, 10/10 deep sleeps without kernel errors (no SELinux on this image). Host:dcpext26-edid-tests.py(extended) and the apple-dcp host suite 95/95; W=1 build.Rebased onto main
9177b2d474f8on 2026-12-02 without conflicts; head nowab7b87192d77. Host checks re-run at the new head: W=1 arm64 build ofdrivers/gpu/drm/apple/, 0 warnings; checkpatch --strict clean; KUnitdcp-fabric,dcp-topology,dcp-display(the suites CI picks for these files) on arm64 QEMU: no failures (one case skips in each of two suites); apple-dcp host suite, no new failures (14 cases fail to compile with this container's newer compiler on main itself, and the same 14 here). The hardware rows above are from before the rebase.Risk: two-way door · M4 (T8132) external outputs on firmware 26.6.2. Other Macs:
dcp_edid_sdr()is unchanged, so every native26 external output keeps the zeroed bytes; only the M4 path calls the newdcp_edid_sdr_native(). Today's DTs enable the M4 external DCPs on J604, J713 and J715 (the iMac and Mac mini DCP nodes are disabled). On those, a compositor that uses the EDID's gamut gets the sink's real primaries; a sink with wrong primaries in its EDID now passes them on, as with any other source.Not yet: main against this on the same display (the zeroed EDID was not booted for comparison); an HDMI or sRGB sink.
Details
dcp_edid_sdr_native()isdcp_edid_sdr()plus restoring the ten bytes and the checksum. Everything elsedcp_edid_sdr()removes still goes. A helper rather than a flag, because the existing host test pinsdcp_edid_sdr()'s zeros; the new function is tested beside it.rate.pyinlines that header, so the unused function is marked so there (one line).Not changed for the native26 outputs: their link and tag code was not looked at here. If zeroed primaries are wrong there as well it is the same two-line change, but that needs their hardware.
The external colour tag (frames tagged by the published EDID) is a separate PR stacked on this one.
Evidence
J713, Studio Display on DP-1 (Thunderbolt DP tunnel), test run of 2026-11-26 on 7.3.0-0.next2:
Host, at the old head
88d9d0c58348(same tree): build of the touched objects with W=1 clean; checkpatch--strictonly asked for the Signed-off-by (now added); apple-dcp host suite 95/95;tools/asahi/run-host-tests.pyon base and on the combined tree: 524 ok, 29 FAIL in both, identical FAIL lists (none in apple-dcp),dcpext26-edid-tests.pyok.