Skip to content

drm/apple: m4: keep the sink's primaries in the external EDID - #3259

Open
themartiano wants to merge 1 commit into
aurora-silicon:mainfrom
themartiano:fix/m4-ext-edid-primaries
Open

themartiano wants to merge 1 commit into
aurora-silicon:mainfrom
themartiano:fix/m4-ext-edid-primaries

Conversation

@themartiano

@themartiano themartiano commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 with cm = edid at 5120x2880; a person judged the picture sharp and the colours right. The kernel (7.3.0-0.next2) was main ba29027e1580 merged 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 9177b2d474f8 on 2026-12-02 without conflicts; head now ab7b87192d77. Host checks re-run at the new head: W=1 arm64 build of drivers/gpu/drm/apple/, 0 warnings; checkpatch --strict clean; KUnit dcp-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 new dcp_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() is dcp_edid_sdr() plus restoring the ten bytes and the checksum. Everything else dcp_edid_sdr() removes still goes. A helper rather than a flag, because the existing host test pins dcp_edid_sdr()'s zeros; the new function is tested beside it. rate.py inlines 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:

ext-edid  DP-1-chromaticities  r 0.6797,0.3203  g 0.2646,0.6904  b 0.1504,0.0596  w 0.3125,0.3291  (Display P3)
ext-edid  DP-1-hyprland-cm     preset edid, 600x330 mm
ext-edid  DP-1-extensions      blocks 2, hdr static metadata no, colorimetry no
modes     DP-1-current         5120x2880@60 scale 2 dpms on
person    picture sharp and steady: yes; colours right (reds and greens neither neon nor washed out, whites neutral): yes

Host, at the old head 88d9d0c58348 (same tree): build of the touched objects with W=1 clean; checkpatch --strict only asked for the Signed-off-by (now added); apple-dcp host suite 95/95; tools/asahi/run-host-tests.py on base and on the combined tree: 524 ok, 29 FAIL in both, identical FAIL lists (none in apple-dcp), dcpext26-edid-tests.py ok.

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>
@themartiano
themartiano force-pushed the fix/m4-ext-edid-primaries branch from 84035c3 to ab7b871 Compare December 2, 2026 12:08
@themartiano
themartiano marked this pull request as ready for review December 2, 2026 16:15
@themartiano
themartiano requested review from a team and DjDeveloperr as code owners December 2, 2026 16:15
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at ab7b8719: not ready yet

Check Detail
CI at head ok 9 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head no no line with the head SHA ab7b8719, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · M4 (T8132) external outputs on firmware 26.6.2. Other Macs: dcpedidsdr() is unchanged, so every native26 external output keeps the zeroed bytes; only the M4 path calls the new dcpedidsdrnative(). 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.

Areas: area:display, area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@maralcbr maralcbr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at ab7b87192d77

Blockers:

  1. 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) on main. Please post one J713 + Studio Display row at ab7b87192d77 (or a batched M4 candidate containing it unchanged on current main) 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() validates size >= 128 before reading bytes 25..34, restores primaries only when dcp_edid_sdr() returns non-zero (every other size/extension rejection happens inside dcp_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 by tools/asahi/dcpext26-edid-tests.py:71.
  • Tests: dcpext26-edid-tests.py:80-86 checks restored chromaticities, byte-equality with dcp_edid_sdr() elsewhere, checksum, and size bounds; rate.py:1075-1078 marks inlined static inline helpers __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 KUnit pass, Host tests pass, pr-text pass.
  • 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.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed ab7b87192d77. The M4 external path preserves the sink's ten chromaticity bytes and recomputes the base checksum. The common SDR sanitizer still strips the unsupported colour and timing data, and the other call sites keep the sRGB policy. The EDID harness passed at this head under Clang and GCC with ASan and UBSan.

Before merging, run J713 plus Studio Display on firmware 26.6.2 at this head. Check nonzero primaries, a valid checksum and cm = edid before and after an idle-off and wake.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026

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

area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants