Skip to content

drm/apple: advertise HDR only on outputs that can carry PQ - #2951

Draft
RyanTheTide wants to merge 1 commit into
mainfrom
av-fixes/hdr-advertise-pq-only
Draft

RyanTheTide wants to merge 1 commit into
mainfrom
av-fixes/hdr-advertise-pq-only

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem. On a J413 (M2 Air) with an HDR monitor on USB-C, GNOME offers HDR, and turning it on gives a washed-out picture with the monitor still in SDR. The external display processor (firmware 13.5) can't be given a PQ signal: dcp_hdr_output_supported() is false, so the mode set drops the PQ request, keeps the SDR transfer function and sends no HDR metadata. It still honours the BT.2020 colorspace (DCP log: colorimetry:9 eotf:0). The connector carries Colorspace and HDR_OUTPUT_METADATA anyway, so GNOME treats the monitor as HDR-capable and renders a BT.2100 desktop.

Change. Attach the two properties to an external output only when its display processor can carry PQ:

  • a per-DCP connector asks its own processor;
  • a Type-C port connector asks every pipeline that can drive the port, because the connector can't know which one a commit lands on.

Panels that show PQ content as EDR keep the properties, and outputs that can carry PQ don't change.

Testing.

  • J413 on fleet83 plus this change (appledrm loads from the initramfs, so it went in with dracut -f and the stock initramfs was restored afterwards). MSI MPG 325CQRXF on USB-C. An instrumented build showed both processors report no PQ output.
  • gdctl show -v: the monitor's supported color modes go from [default, sdr-native, bt2100] to [default, sdr-native], and it comes up in default. The internal panel stays [default, sdr-native].
  • checkpatch --strict clean; appledrm builds with LLVM=1 W=1 without warnings in the touched files.

Still to run. A Mac whose external output does carry PQ (desktop 26.x or a firmware 27 external processor), to confirm the monitor still lists bt2100 there. Sending PQ and the HDR metadata from the 13.5 external processor would be the real fix for this monitor; that is separate work.

An external connector got the Colorspace and HDR_OUTPUT_METADATA
properties whatever its display processor could do with them. Where
the processor cannot be given a PQ signal (dcp_hdr_output_supported()
is false, e.g. the firmware 13.5 external DCP of the J413), the mode set
drops the PQ request, keeps the SDR transfer function and sends no HDR
metadata, but still honours a BT.2020 colorspace. GNOME offers HDR on
such a monitor because the properties are there, renders a BT.2100
desktop, and the sink stays in SDR: the picture is washed out.

Attach the two properties to an external output only when its display
processor can carry PQ. The per-DCP connector asks its own processor; a
Type-C port connector asks every pipeline that can drive the port, since
the connector cannot know which one a commit lands on. Panels that show
PQ content as EDR keep the properties as before, and outputs that can
carry PQ are unchanged.

Tested on a J413 with an MSI MPG 325CQRXF on USB-C (fleet83 plus this
change in the initramfs): the external processor reports no PQ output,
GNOME's supported color modes for the monitor go from [default,
sdr-native, bt2100] to [default, sdr-native], and the monitor comes up
in the default mode. The internal panel's modes are unchanged.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by the external HDR fix in progress. The J413 should send PQ and HDR static metadata to a capable display, matching macOS. Keep this PR in draft.

@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.

Formal §1–§6 pre-PR technical review on Draft at db1bb9b0c41f8cf6005f8a3fdf321f452ee9c1e0 (COMMENT only — Draft PR).

Checklist Summary

  • §1 No model gating: Pass — reuses the existing dcp_hdr_output_supported() capability predicate so connector property advertisement matches what the mode-set path actually supports.
  • §2 Production-ready: Pass — default command line, no hacks or new parameters.
  • §3 Safety: One logic bug found below (panel_edr fallthrough in apple_connector_attach_hdr()).
  • §4 Clean-room & attribution: Pass — human author/committer (Ryan Murray <[email protected]>) and human Signed-off-by: only, zero AI trailers in commit; PR body includes Assisted-by:.
  • §5 Evidence & CI: host-tests green; J413 negative-control row (external 13.5 DCP drops bt2100, internal panel unchanged) is solid. Appropriately kept Draft pending the positive-control row on a PQ-capable external Mac (desktop 26.x or firmware 27 external DCP) + regression tuple.
  • §6 Naming: Pass.

Technical Findings (to address before undrafting)

  1. panel_edr leaks onto external USB/DisplayPort connectors in apple_connector_attach_hdr() (drivers/gpu/drm/apple/apple_drv.c:999-1010):
    case DRM_MODE_CONNECTOR_eDP:
        if (!panel_edr)
            return 0;
        fallthrough;
    case DRM_MODE_CONNECTOR_USB:
    case DRM_MODE_CONNECTOR_DisplayPort:
        if (!pq_output && !panel_edr)
            return 0;
        ret = drm_mode_create_dp_colorspace_property(connector, colorspaces);
        break;
    apple_connector_create() passes dcp_fw_compat_panel_edr(dcp), which (drivers/gpu/drm/apple/dcp.c:4158) only checks dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP || dcp->fw_compat == DCP_FIRMWARE_V_27_0 without checking dcp_has_panel(dcp). Because eDP falls through and USB/DisplayPort checks if (!pq_output && !panel_edr), any fw_compat 26.6-desktop or 27.0 external USB/DisplayPort connector whose dcp_pq_output_supported(dcp) is false (e.g., iomfb_is_m4(dcp) or a future non-PQ 27.x external pipeline) would still have panel_edr == true and get HDR properties attached anyway.
    Separating the guard cleanly (e.g., if (connector->connector_type != DRM_MODE_CONNECTOR_eDP && !pq_output) return 0;, or keeping eDP and USB/DisplayPort guards independent) closes that hole.
  2. Null-guard nit in dcp_pq_output_supported() (drivers/gpu/drm/apple/iomfb.c:3203-3206):
    dcp_pq_output_supported() passes platform_get_drvdata(pdev) straight to dcp_hdr_output_supported() without checking for NULL. Adding struct apple_dcp *dcp = platform_get_drvdata(pdev); return dcp && dcp_hdr_output_supported(dcp); makes the cross-file helper self-defending and simplifies apple_typec_port_pq_output().
  3. Dual-stream ordered Type-C ports note (drivers/gpu/drm/apple/apple_drv.c:1307-1326, 1385-1393):
    apple_typec_port_pq_output() checks all candidate pipelines for port_idx rather than only the pipelines in mask (same as apple_typec_port_rgb8_only()). Fine as long as all external pipelines on a port share fw_compat, worth keeping in mind if mixed-capability pipelines ever share a port.
  4. Before undrafting (§5):
    Add the positive-control row on a PQ-capable external Mac (desktop 26.x or firmware 27 external DCP) confirming bt2100 remains advertised, along with the regression tuple (0 SELinux denials, 0 failed units, 0 new kernel errors).

Verdict

COMMENT (Draft) — sound direction; fix the panel_edr fallthrough bug in apple_connector_attach_hdr() and add the positive-control external PQ row before marking Ready for Review.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent source review at db1bb9b0c41f. The HDR capability loop can include pipelines excluded from this connector's CRTC mask. In the non-fixed path, the mask is filtered by dcp_fabric_port_crtc_mask(), and a candidate can also have a zero crtc_mask[i]. An SDR-only excluded pipeline can still suppress HDR for an HDR-capable connector. Use the same eligible-pipeline set for the PQ decision and add a mixed-pipeline test. Then verify a positive HDR row against the J413 negative row.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants