Repository navigation
drm/apple: Display P3 for an internal panel without a known gamut; cap the panel peak firmware 27 EDR may use - #2087
Conversation
…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>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Follow-up: 830d9ee613 wraps the new log line to keep checkpatch under 100 columns. The code is otherwise the same as 69f33a8239.
3b73734 to
69f33a8
Compare
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>
69f33a8 to
830d9ee
Compare
|
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).
Not tested: EDR or PQ at any cap above the SDR maximum. 🤖 Generated with Claude Code |
|
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
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 |
|
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 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. |
|
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. |
|
@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! |
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/applechanges for internal panels. Both are built and unit-tested on top ofintegration/aurorabf423bf0e4but 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
/productartwork-display-gamutnames.dcp_adt_gamut()knows onlyP3andsRGB. The K114s (MacBook Pro 14-inch OLED, M5 Pro, firmware 27.2) saysRec2020, with a valid version-1primary-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'sedidcolour 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 iniomfb_template.c, so the EDID then matches the surface tag.Rec2020is 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). Onedev_infoline says when the default is used.2.
fw27_panel_edr_max_nits: a cap on the panel peak EDR may useOn the K114s the ADT gives
LmaxProduct2000 nits andEDRPotentialHeadroom16.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 bydcp_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)
bf423bf0e4with clang 23.1.3 andCONFIG_KUNIT=y. There are no warnings indrivers/gpu/drm/apple.checkpatch --strictreports 0 errors; its only warnings are about theCo-Authored-Bytrailer.virt, TCG), loadingappledrmanddcp_backlight_test: all 32 Apple display suites pass (299 cases), with nonot okline in the whole run. That includesapple-display-parser43/43 andapple-dcp-backlight29/29.parser_panel_adt_color_target: aRec2020ADT 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.parser_panel_adt_color_targetfails (42/43).dcp_backlight_test.ccompiled for the host through stand-in headers.appledrm.kodiffers 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