Skip to content

drm/apple: keep SDR content at the user's brightness when a panel shows PQ - #3367

Closed
RyanTheTide wants to merge 3 commits into
mainfrom
fix/dcp-edr-pq-reference
Closed

RyanTheTide wants to merge 3 commits into
mainfrom
fix/dcp-edr-pq-reference

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Status (draft, held): not the K114s flash-bang fix

  • On the K114s (firmware 27), SDR content in HDR is still far too bright with this change, even with the EDR headroom forced to 1. The ALS rows are in the lane evidence. The remaining gain is in the firmware-27 PQ path and is being measured without the compositor in the loop.
  • Aurora's Mutter (fedora-aurora packages/mutter 0002, "Take the PQ reference white from PQ_REFERENCE_LUMINANCE") already puts SDR white at the connector's PQ_REFERENCE_LUMINANCE and keeps the sysfs backlight in BT.2100. With that Mutter, this change is neutral: the J616s row shows SDR-in-HDR unchanged. It only matters for compositors without that patch (upstream Mutter's ref-white path, KWin). The Mutter paragraph below describes upstream Mutter.

What

Turning HDR on in GNOME makes an EDR panel jump to a blinding level ("flash-bang"). On a K114s set to 835 nits, SDR content goes towards the panel's 2000-nit peak.

The firmware shows PQ 100 cd/m² at SDR white, which is the level a swap's brightness sets, and the driver hands it the user's brightness as SDR white. Compositors put SDR content at the PQ reference white of ITU-R BT.2408, 203 cd/m². Mutter 50/51 in BT.2100 mode stops writing the sysfs backlight and scales that reference white instead (meta-output-kms.c forces its "ref-white" backlight in HDR); KWin's default is the same. SDR content therefore shows at 2.03 times the user's brightness, up to the peak.

While PQ is shown, the firmware now gets SDR white × 100 / 203. PQ 203 lands on the user's brightness, and only brighter PQ levels use the headroom, which is how macOS shows SDR content in EDR. PQ_REFERENCE_LUMINANCE now reports 203 instead of 100. The headroom target follows the lower SDR white, so the peak is still reachable. Nothing changes outside PQ, and the change applies to every panel with EDR headroom (no SoC or board check).

Tested

Tested: KUnit 374 tests (373 pass, 1 skip) incl. new edr_pq_sdr_test; K114s boots 7.3.0 with this commit (k114sdisp test kernel = main + this + #2798 + the zero refresh range change on branch fix/dcp-panel-vrr-range), panel bound, EDR headroom 16. The owner's HDR on/off check on that boot is posted as a comment.

  • KUnit (drivers/gpu/drm/apple/tests/display.kunitconfig + CONFIG_DRM_APPLE_KUNIT_TEST=y, arm64 QEMU): 374 tests, 373 passed, 1 skipped. The new edr_pq_sdr_test checks the mapping, its rounding over 10-1600 nits and the larger headroom target.
  • Before the fix, on the K114s at user brightness 100 with HDR on, the panel ran at headroom about 4.4 (actual_brightness 442) and SDR content was encoded at PQ 203, i.e. 2× the user's level. The owner reports the flash-bang at his usual brightness.

Risk: two-way · every EDR panel (K114s, J616s/J614s, J714s, ...): SDR level in HDR mode only

Not yet

  • Mutter in HDR keeps its own brightness factor on the backlight's range (for example 6-600 on the J616s). At its minimum, SDR is at 6% of the reference ("very dark"). That is Mutter's control, not the driver's; the brightness keys raise it.
  • The CI's apple-drm-kunit job uses display.kunitconfig without CONFIG_DRM_APPLE_KUNIT_TEST, so the EDR tests in dcp_backlight_test.c don't run there. That is a separate CI follow-up.

…ws PQ

With HDR on in GNOME, an EDR panel jumps to a blinding level: on a K114s
at 835 nits, SDR content goes towards the 2000-nit peak.

The firmware shows PQ 100 cd/m^2 at SDR white, the level a swap's
brightness sets, and the driver hands it the user's brightness as SDR
white. Compositors put SDR content at the PQ reference white of ITU-R
BT.2408, 203 cd/m^2: Mutter in BT.2100 mode stops writing the sysfs
backlight and scales that reference white instead, and KWin does the
same by default. SDR content then shows at 2.03 times the user's
brightness, up to the peak.

While PQ is shown, give the firmware SDR white x 100 / 203, so PQ 203
lands on the user's brightness and only brighter PQ levels use the
headroom, as macOS shows SDR content in EDR. Report 203 in
PQ_REFERENCE_LUMINANCE, which said 100. The headroom target follows
the lower SDR white, so the peak is still reachable. Nothing changes
outside PQ, and the step applies to every panel with EDR headroom.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 27, 2026 08:17
Signed-off-by: Ryan Murray <[email protected]>

# Conflicts:
#	drivers/gpu/drm/apple/apple_drv.c
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train status at 773fdb6b: I'll review once two things are in place.

  1. Rebase: it's DIRTY against main.
  2. The J616s regression row your body asks for: the EDR code is shared with every EDR panel (J616s/J614s, J714s and others), and the change moves the SDR level in HDR mode. Please run HDR on/off on a J616s panel at the rebased head, checking the SDR white level at a known brightness and that SDR-only mode is unchanged.

The K114s boot and KUnit (373/374) are noted.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (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 Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at f41f88bd: not ready yet

Check Detail
CI at head running running: kunit, apple-build, host-tests, pr-text / pr-text, KUnit ane-boot, KUnit ane-pm
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA f41f88bd, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · every EDR panel (K114s, J616s/J614s, J714s, ...): SDR level in HDR mode only Not yet - Mutter in HDR keeps its own brightness factor on the backlight's range (for example 6-600 on the J616s). At its minimum, SDR is at 6% of the reference ("very dark"). That is Mutter's control, not the driver's; the brightness keys raise it. - The CI's apple-drm-kunit job uses display.kunitconfig without CONFIG_DRM_APPLE_KUNIT_TEST, so the EDR tests in dcp_backlight_test.c don't run there. That is a separate CI follow-up.

Areas: area:display

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

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J616s regression row (M4 Pro, desktop 26.x firmware, known-gamut mini-LED panel). Test kernel 7.3.0-j6disp = main + linux#3367 (6522d8db) + linux#3369 (ff66aef1) + #2798 (a5ee0c10), merged as d8cf3fe8e04be5. The J616s's fleet89 config, trimmed to its loaded modules; its own Stage 2 and DTB; a GRUB one-shot, then a plain reboot back to fleet89. Before = fleet89 on the same machine, read the same way:

fleet89 with the three PRs
eDP-1 modes 6 (3456x2234 at 120/60/59.94/50/48/47.95) 6 (same)
EDID primaries R/G/B/W, gamma 0.6797,0.3203 / 0.2646,0.6904 / 0.1504,0.0596 / 0.3125,0.3291, 2.20 identical
EDID name Apple Panel Apple Panel
P3 fallback message none (the ADT names a known gamut) none
vrr_capable, vrr_range 1, 24-120 1, 24-120
Colorspace / Mutter colour modes 9 / [0, 2, 1] 9 / [0, 2, 1]
PQ_REFERENCE_LUMINANCE 100 203 (the intended change in #3367)
EDR headroom / peak 16 / 1600 nits 16 / 1600 nits
DCP/DRM error lines, failed units 0, 0 0, 0

Files: traces/display/20261127-k114s-dcp/j616s-fleet89-before.txt and j616s-j6disp-after.txt (lab store).

# Conflicts:
#	drivers/gpu/drm/apple/apple_drv.c
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train review: MERGE once CI is green at f41f88bd. I merged main in (no force push) to drop the inherited #3302 host-test failure; #3302 is reverted on main. The one conflict was apple_drv.c includes: I kept dcp-edr.h and dropped the reverted HDCP header. The PR against main is exactly its 4 files (+53/−7).

Checked

  • In HDR (output_edr), the SDR white handed to the firmware becomes sdr × 100 / 203 in both swap paths (dcp_edr_prepare and _v27). PQ 203 cd/m² (BT.2408 reference white, the Mutter/KWin default) lands on the user's brightness instead of 2.03× it, and only brighter PQ levels use the headroom. PQ_REFERENCE_LUMINANCE reports 203.
  • It's the same panel-agnostic code for every EDR panel, with no gates, and SDR mode is unchanged.
  • KUnit edr_pq_sdr_test covers the mapping, rounding (±2 nits over 10–1600) and the headroom.
  • Rows: K114s HDR on/off (owner). J616s before/after on fleet89: only PQ_REFERENCE_LUMINANCE changes, 100 → 203; modes, EDID, VRR, colour modes and EDR headroom/peak are identical, with 0 errors.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Nov 27, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware row at f41f88bd: K114s (T6050, firmware 27.2) and J616s (M4 Pro, desktop 26.x): PASS.

@RyanTheTide
RyanTheTide marked this pull request as draft November 27, 2026 11:10
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Back to draft: hold the merge. On the K114s with this commit, HDR in GNOME is still far too bright, as the owner reports. The K114s's ambient light sensor picks up the panel's own light, so I measured with it (auto-brightness off, same 300-nit backlight): SDR reads 0.30, HDR reads 2.5, about 8×. The PQ-203 offset is real but small. On firmware 27 the dominant effect is that the panel runs at SDR white × headroom and the desktop is not scaled back. A lab kernel now pins which EDR field the firmware ignores; this PR gets the real fix, or is reshaped, before it comes out of draft.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Measurement update (ALS proxy, details on the lab store): with a lab-only knob on the K114s, any PQ/EDR presentation on firmware 27 is far brighter than SDR at 1000 nits, even with headroom forced to 1 and this remap on. On the J616s (desktop 26.x), SDR content in HDR already sits at the user's level without any remap, so this ×100/203 would halve it there. So this PR is wrong as it stands for the 26.x path and insufficient for 27. It stays draft until the firmware-27 PQ mapping is understood (question to @DjDeveloperr about the macOS 27 trace); expect it to be reshaped or closed.

@github-actions github-actions Bot removed needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train note: my MERGE verdict from 21:4x is superseded by the author's HOLD above (back to draft at 22:10, HDR still too bright on the K114s). I'll re-review when it's back out of draft, with the compositor-free row.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Closing: superseded. On Aurora's Mutter (which reads PQ_REFERENCE_LUMINANCE) this was neutral, and on firmware 27 the flash-bang has a different cause (no PQ decode on the surface path; measured in #3423, which merged as the stop-gap). Real HDR on firmware 27 is being done by the FW27-HDR lane.

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) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant