Skip to content

drm/apple: Display P3 for an internal panel without a known gamut; cap the panel peak firmware 27 EDR may use - #2087

Draft
chrisohearn wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
chrisohearn:drm-apple-panel-colour-edr-cap
Draft

chrisohearn wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
chrisohearn:drm-apple-panel-colour-edr-cap

Conversation

@chrisohearn

Copy link
Copy Markdown

Written by Claude (an AI agent) working for the owner of a K114s and posted from the owner's account at his direction.

For #2060. Two drm/apple changes for internal panels. Both are built and unit-tested on top of integration/aurora bf423bf0e4 but not booted.

1. A panel without a known gamut is described as Display P3 (no more zero primaries)

The internal panel's synthesised EDID takes its primaries from the firmware or, failing that, from the colour target the ADT's /product artwork-display-gamut names. dcp_adt_gamut() knows only P3 and sRGB. The K114s (MacBook Pro 14-inch OLED, M5 Pro, firmware 27.2) says Rec2020, with a valid version-1 primary-calibration-matrix (read-only from its ADT: 40 bytes, rows sum to 1.0). That leaves no target, so the EDID carries R=G=B=(0,0) with only the D65 white. Hyprland's edid colour preset builds a singular matrix from that, and every frame is black (betizzel/omarchy-m5#21).

dcp_panel_color_target() returns the ADT's space when the driver knows it and Display P3 otherwise. Every untagged RGB surface on an internal panel is already tagged P3-D65 in iomfb_template.c, so the EDID then matches the surface tag. Rec2020 is deliberately not mapped to BT.2020 primaries, because the pixels are handed to the firmware tagged P3. dcp_panel_edid() keeps its contract (a NULL target still gives white only). One dev_info line says when the default is used.

2. fw27_panel_edr_max_nits: a cap on the panel peak EDR may use

On the K114s the ADT gives LmaxProduct 2000 nits and EDRPotentialHeadroom 16. dcp_edr_prepare_v27() would therefore ramp an OLED towards 2000 nits on the first PQ frame, and that path has been validated on the J714s only. The new read-only parameter lowers the peak accepted from the ADT. A cap at or below the panel's SDR maximum leaves no headroom: no peak, no PQ in the EDID, PQ commits refused by dcp_crtc_check_hdr(), and no EDR step in any swap. The default is 0, which keeps the panel's own peak, so nothing changes unless the parameter is set. dcp_edr_peak() takes the decision, and an out-of-range ADT peak stays unusable whatever the cap.

Tests (agent-run on a K114s build host; emulator)

  • Built on bf423bf0e4 with clang 23.1.3 and CONFIG_KUNIT=y. There are no warnings in drivers/gpu/drm/apple. checkpatch --strict reports 0 errors; its only warnings are about the Co-Authored-By trailer.
  • KUnit, booted in QEMU (virt, TCG), loading appledrm and dcp_backlight_test: all 32 Apple display suites pass (299 cases), with no not ok line in the whole run. That includes apple-display-parser 43/43 and apple-dcp-backlight 29/29.
  • New and extended cases:
    • parser_panel_adt_color_target: a Rec2020 ADT gives no target of its own and an EDID with Display P3 primaries, D65 and gamma 2.2. A known gamut keeps its space.
    • edr_peak_test: the cap decision, with the K114s values.
    • edr_peak_bound_test: at every swap of a ramp to the capped headroom, the level asked for is at most SDR white or the capped peak, for caps of 500, 1001 and 1600 nits.
  • Mutation checks:
    • Without the P3 fallback, parser_panel_adt_color_target fails (42/43).
    • Without the cap, both EDR cases fail. This one was run with the driver's dcp_backlight_test.c compiled for the host through stand-in headers.
  • The same two patches are carried in a K114s kernel (v272-11 base), built and packaged there. Only appledrm.ko differs from the running kernel.

Not tested

Anything on hardware: the new EDID on the panel, a compositor with colour management on, the log lines, and EDR itself at any cap. The K114s boot test needs the owner at the Mac, and I'll report it in #2060.

🤖 Generated with Claude Code

…y P3

The EDID built for an internal panel takes its primaries from the
firmware or, without a complete set, from the colour target the ADT's
/product artwork-display-gamut names. A gamut string the driver does
not know leaves no target, and the EDID then carries zero red, green
and blue primaries with only the D65 white.

The K114s (MacBook Pro 14-inch OLED, M5 Pro, firmware 27.2) is such a
panel: its ADT says "Rec2020", with a valid version-1
primary-calibration-matrix. Compositors take the zero primaries at
face value. Hyprland's colour management builds its conversion matrix
from them, the matrix is singular, and every frame comes out black
while the firmware completes each swap.

Every untagged RGB surface on an internal panel is already tagged
P3-D65 (iomfb_template.c: "the panel's own primaries (P3-D65, as its
EDID reports)"). Describe a panel whose ADT names no known space in
that same space, so the EDID and the surface tag agree, and log it.
The Rec2020 string is not mapped to BT.2020 primaries: the firmware is
handed P3-tagged surfaces, so BT.2020 primaries in the EDID would make
compositors encode for a wider space than the one the pixels are
shown in. dcp_panel_edid() keeps its contract (no target, white only)
for its other callers and tests.

KUnit: parser_panel_adt_color_target covers a "Rec2020" ADT (no target
of its own, Display P3 primaries, D65 and gamma 2.2 in the EDID) and a
known gamut keeping its own space.

Not booted: built, and the Apple display KUnit suites pass in QEMU.

Link: aurora-silicon#2060
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: chrisohearn <137103567+chrisohearn@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T17:55:14.677437Z 830d9ee New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b7373435d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

dev_info(dcp->dev, "panel peak luminance %u nits (ADT)\n", peak);
u32 adt_peak = panel.lmax_product >> 16;
u32 cap = READ_ONCE(fw27_panel_edr_max_nits);
u32 peak = dcp_edr_peak(adt_peak, dcp->brightness.maximum, cap);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle an unknown SDR maximum before enabling capped EDR

On firmware-27 machines booted from a DT without the optional apple,max-brightness property (the checked panel nodes in t6050-j714s-gpu-panel.dtsi:85-90 and t6050-k116s.dts:430-434 both omit it), dcp_comp_bind_pipe() only logs the failed read and leaves dcp->brightness.maximum at zero. Passing that zero here makes every nonzero cap look like usable headroom, so setting a cap at or below the panel's actual SDR maximum still stores a nonzero peak_nits, advertises PQ, and allows PQ commits instead of disabling EDR as documented; obtain a real SDR maximum or treat an unknown maximum conservatively before making this decision.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 69f33a8239. A cap on a panel whose SDR maximum is unknown (no apple,max-brightness, as on the J714s and K116s trees) can't be compared with that maximum, so dcp_edr_peak() now gives no peak for it: EDR stays off, with the log line panel EDR off: cap N nits set and the SDR maximum is unknown. With no cap (the default), the ADT peak is used as before, so nothing changes unless the parameter is set. edr_peak_test covers both cases, and edr_peak_bound_test now uses a panel with a known 400-nit SDR maximum. KUnit in QEMU: apple-dcp-backlight 29/29, apple-display-parser 43/43, with no not ok in the run.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Follow-up: 830d9ee613 wraps the new log line to keep checkpatch under 100 columns. The code is otherwise the same as 69f33a8239.

@chrisohearn
chrisohearn force-pushed the drm-apple-panel-colour-edr-cap branch from 3b73734 to 69f33a8 Compare November 16, 2026 17:43
A firmware 27 panel shows PQ content as EDR: a swap asks the panel for
SDR white times the headroom, up to the peak the ADT's LmaxProduct
gives (dcp_edr_prepare_v27()). On the K114s (MacBook Pro 14-inch OLED,
M5 Pro) that peak is 2000 nits with a potential headroom of 16, so the
first PQ frame a compositor presents starts a ramp towards 2000 nits
on an OLED panel. The path was validated on the J714s only.

Add fw27_panel_edr_max_nits (read-only, read when the display
processor binds). It lowers the peak the driver accepts from the ADT.
A cap at or below the panel's SDR maximum leaves no headroom: the
panel then has no peak, so its EDID advertises no PQ, PQ commits are
refused (dcp_crtc_check_hdr()) and no swap carries an EDR step. The
default, 0, keeps the panel's own peak, so nothing changes unless the
parameter is set. dcp_edr_peak() takes the decision; an out-of-range
ADT peak stays unusable whatever the cap. A cap on a panel whose SDR
maximum is unknown (no apple,max-brightness, as on the J714s and K116s
trees) cannot be compared with it, so it also leaves EDR off, with a
log line saying so.

KUnit: edr_peak_test (the decision, K114s values) and
edr_peak_bound_test (at every swap of a ramp to the headroom the
capped peak leaves, the level asked for is at most SDR white or the
capped peak, for caps of 500, 1001 and 1600 nits). Run on a build host
through stand-in headers: 30 cases pass, and both new cases fail with
the cap removed.

Not booted: built, and the Apple display KUnit suites pass in QEMU.

Link: aurora-silicon#2060
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: chrisohearn <137103567+chrisohearn@users.noreply.github.com>
@chrisohearn

Copy link
Copy Markdown
Author

Written by Claude (an AI agent) working for the owner of the K114s and posted from the owner's account at his direction.

Booted on hardware: a K114s (14-inch M5 Pro, OLED, T6050, DCP firmware 27.2), the owner watching. The kernel was these two commits, as carried on a 7.3.0-17 base, plus a K114s-only patch that sets the cap's default to 500. The carried cap helper is the version from before this PR's last review fix, which behaves the same on this panel (its SDR maximum is 1000).

  • Kernel log (agent-run): panel ADT: no known colour gamut, EDID primaries default to Display P3 and panel EDR off: cap 500 nits is not above the SDR maximum 1000 nits.
  • edid-decode of the eDP-1 EDID (agent-run): red 0.6796/0.3203, green 0.2646/0.6904, blue 0.1503/0.0595, white 0.3125/0.3291. No HDR static metadata block and no colorimetry block, as expected with EDR off.
  • Hyprland 0.57.2 with colour management on (owner-observed): the eDP-1 presets edid, dp3 and srgb all kept the panel lit with normal colours. Before this change, colour management with the edid preset gave black frames on this panel (K114s OLED: black panel on the DCP hand-off under Hyprland colour management (cm_enabled); off fixes it betizzel/omarchy-m5#21). That issue is now closed with this result.

Not tested: EDR or PQ at any cap above the SDR maximum.

🤖 Generated with Claude Code

@chrisohearn

Copy link
Copy Markdown
Author

Written by Claude (an AI agent) working for the owner of the K114s and posted from the owner's account at his direction.

EDR, too, on the same K114s (OLED, DCP firmware 27.2), with the owner watching. The kernel had these two commits (the cap helper as revised in this PR), plus fw27_panel_edr_max_nits=1200 from modprobe.d.

  • Kernel log (agent-run): panel peak luminance 2000 nits (ADT), panel EDR capped at 1200 nits, panel EDR headroom up to 16.000.
  • edid-decode of the eDP-1 EDID (agent-run): an HDR static metadata block now sits beside the P3 primaries. It lists traditional gamma and SMPTE ST2084, with a desired content maximum of 147 (1207.332 cd/m²).
  • Hyprland 0.57.2 with the eDP-1 preset hdredid (owner-observed):
    • The desktop stayed lit and looked normal.
    • A 10-bit PQ test clip (testsrc2 white mapped to 1000 nits with zscale) played in a window with mpv gpu-next, and looked right.
    • No DCP crash.

So the cap does what it says on this panel in both directions: at 500 there's no PQ, and at 1200 the PQ peak is held at 1200. Not measured: real luminance (no meter), and whether the firmware tone-maps above the cap.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the K114s runs. The Display P3 commit stands on its own and fixes #2060 for every internal panel whose ADT names a gamut the driver doesn't know, so it is carried alone, under your authorship, in #2320 on the current integration/aurora.

On the cap commit: as a module parameter whose default leaves behaviour unchanged, it only does something on a machine that is configured by hand, and the right value differs per panel. If the cap can be derived from what the panel reports (the ADT peak and the SDR maximum the log already prints, or the firmware's own EDR headroom), it can apply by default to every firmware 27 panel; that would be the shape to aim for in this PR once #2320 is in.

@RyanTheTide

Copy link
Copy Markdown
Contributor

fw27_panel_edr_max_nits in dcp.c makes the firmware 27 EDR peak cap a module parameter that defaults to off. The default therefore still uses the full ADT peak, the 2000-nit path the description calls unvalidated on the K114s, and the cap only takes effect if someone sets it by hand. If some panels need a lower peak, dcp_edr_peak() should pick it from what the panel's ADT or the firmware reports. If they don't, the parameter is not needed. The Display P3 default for a panel with an unknown gamut can stand on its own. Until then this should stay a draft.

@RyanTheTide
RyanTheTide marked this pull request as draft November 20, 2026 23:54
@RyanTheTide

Copy link
Copy Markdown
Contributor

@chrisohearn, a tidy-up pass over the open PRs here. These of yours need something:

If any of these are no longer needed, closing them helps; otherwise a merge or rebase onto integration/aurora is usually all they need. Thanks!

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