Repository navigation
drm/apple: fall back to safe SDR when auto SDR BT2020_RGB has no match - #3872
Conversation
Compositors such as Hyprland 0.57 (default cm=edid) set Colorspace=BT2020_RGB in SDR mode whenever the sink EDID advertises BT.2020 and the connector exposes the Colorspace property. On bandwidth-limited HDMI 2.0 timings (such as 3840x2160@60 on an LG 4K UHD TV behind T6040 external DCP), the firmware ColorModes catalogue exposes no BT2020_RGB entries and marks all 10/12-bit BT2020_YCC entries as unsafe, leaving only 8-bit YCbCr 4:2:0 sRGB/BT.601 safe. dcp_crtc_check_hdr() -> dcp_select_color_mode() rejected every atomic modeset with -EINVAL, trapping aquamarine/Hyprland in an unpaced retry loop (~1,000 commits/s, ~2,800 GPU mailbox IRQs/s, ~64 W idle power vs ~7.8 W baseline) with the external HDMI display never completing modeset. Fix both gaps without weakening explicit colour requests or HDR checks: 1. In dcp_color_space_matches(), allow DRM_MODE_COLORIMETRY_BT2020_RGB with DRM_CONNECTOR_COLOR_FORMAT_AUTO to match safe DCP_COLORIMETRY_BT2020_YCC entries for SDR as well as HDR (RGB still outranks YCbCr when both exist). 2. Extract dcp_scan_color_modes() and, in dcp_select_color_mode(), if an automatic SDR BT2020_RGB request (color_format == AUTO and broadcast_rgb == AUTO) finds no matching BT.2020 entry, fall back directly through dcp_scan_color_modes() with DRM_MODE_COLORIMETRY_DEFAULT rather than dcp_default_sdr_color(). This preserves unsafe/sdr_usable filtering, EOTF checks, max_bpc, and works even when cached default slots are unpopulated. 3. In dcp_crtc_check_hdr(), accept DRM_MODE_COLORIMETRY_BT2020_RGB alongside DRM_MODE_COLORIMETRY_DEFAULT for fixed 8-bit SDR pipes (!iomfb_template_pq || dcp_is_ext26) under the same AUTO/AUTO and max_bpc >= 8 guards. Explicit format, range, non-BT2020_RGB colorspace, low max_bpc, and HDR/PQ requests continue to return -EINVAL when unsupported. Add unit test coverage in the apple-dcp display.py selftest. Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
This PR addresses Apple DCP modeset failures and compositor retry loops when SDR requests use Colorspace=BT2020_RGB with color_format=AUTO, by introducing safe fallback selection logic and widening BT.2020 matching behavior.
Changes:
- Allow SDR
BT2020_RGB+AUTOrequests to match safeBT2020_YCCcatalog entries when appropriate. - Refactor color-mode selection by extracting a filtered catalog scan helper and adding a one-shot fallback to
DRM_MODE_COLORIMETRY_DEFAULTfor the problematic SDR auto case. - Expand selftest coverage for SDR
BT2020_RGBaliasing and safe SDR fallback behavior across multiple edge cases.
| File | Description |
|---|---|
| tools/testing/selftests/drivers/gpu/apple-dcp/display.py | Adds selftests that exercise the new SDR BT2020_RGB aliasing and safe fallback behavior, including rejection cases. |
| drivers/gpu/drm/apple/iomfb.c | Permits BT2020_RGB requests (under AUTO/AUTO constraints) on fixed 8-bit SDR pipes to avoid erroneous rejection. |
| drivers/gpu/drm/apple/dcp-color.h | Refactors selection logic into dcp_scan_color_modes() and adds SDR fallback from BT2020_RGB to DEFAULT scan; expands BT2020_RGB matching to include SDR. |
Review effort: Lite
| static inline const struct dcp_color_entry * | ||
| dcp_scan_color_modes(const struct dcp_display_mode *mode, | ||
| const struct dcp_color_request *req) | ||
| { | ||
| u8 max_bpc = req->max_bpc ? req->max_bpc : 12; | ||
| bool hdr = req->eotf != HDMI_EOTF_TRADITIONAL_GAMMA_SDR; |
| * Compositors (e.g. Hyprland's default cm=edid) set | ||
| * Colorspace=BT2020_RGB in SDR when the sink EDID advertises | ||
| * BT.2020, even on bandwidth-limited timings (such as 4K60 | ||
| * HDMI 2.0) where only 8-bit sRGB/BT.601 YCbCr 4:2:0 is safe. | ||
| * Rejecting that commit with -EINVAL traps compositors in an | ||
| * unpaced modeset retry loop; fall back through the filtered | ||
| * catalogue so unsafe, EOTF, and max_bpc rules still apply. |
| /* Fixed 8-bit SDR pipes satisfy default or auto BT.2020 SDR with max_bpc >= 8. */ | ||
| if (req.eotf == HDMI_EOTF_TRADITIONAL_GAMMA_SDR && | ||
| req.colorspace == DRM_MODE_COLORIMETRY_DEFAULT && | ||
| (req.colorspace == DRM_MODE_COLORIMETRY_DEFAULT || | ||
| req.colorspace == DRM_MODE_COLORIMETRY_BT2020_RGB) && | ||
| req.color_format == DRM_CONNECTOR_COLOR_FORMAT_AUTO && | ||
| req.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_AUTO && | ||
| (!req.max_bpc || req.max_bpc >= 8)) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed c97b9db. The SDR retry still uses the catalogue filters for link safety, depth and EOTF. An explicit format or range prevents the default-colorspace retry, and HDR retains its existing permission and selection paths. The exact-head color-mode fixture passed with Clang ASan/UBSan, including the 4K60 fallback and rejection controls. The J616s HDMI result exercises the reported failure. The shared fixed-pipe path still needs its cross-generation HDMI control before merge.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Cross-generation HDMI + DP control at exact PR head
|
…DCP SDR fallback (#558) (#4508) Pin linux-aurora and aurora-userpages to immutable tag aurora-7.3.0-5 (omacom/linux-aurora c731018151b1 on carry/aurora-7.3.0-5), built from integration/aurora-7.3 (omacom/linux-aurora 87005e7e5393): - Re-pins aurora-silicon/linux#3490 to 8ba26a7e7edc (omacom/linux-aurora#557): single-consumer G15 stats ring drain, PM suspend/resume ring drain, and M3 receive-ring load/store ordering (resolving the #3490 caveat tracked in #4397) - Adds aurora-silicon/linux#3872 (omacom/linux-aurora#558): DCP auto SDR BT2020_RGB fallback to safe SDR on bandwidth-limited HDMI 2.0 timings - Preserves intake 4a42f3105002 and all 23 carries from 7.3.0.aurora4-1 Signed-off-by: Marcelo Alcantara <maralc@gmail.com>


Summary
Stock compositors such as Hyprland 0.57 (default
cm=edid, no custom monitor color config) setColorspace=BT2020_RGBin SDR mode (EOTF=SDR,color_format=AUTO,Broadcast RGB=Automatic) whenever a sink EDID advertisesBT2020RGBand the connector exposesColorspace.On bandwidth-limited HDMI 2.0 timings such as
3840x2160@60on an LG 4K UHD TV behind T6040 external DCP (m4pro, J616S,Timing ID=72), the firmwareColorModescatalogue exposes:BT2020_RGBentriesUNSAFEentries (including all 10/12-bitBT2020_YCCentries)ID=5, 123, 125), all 8-bitDownstreamFormatYCbCr 4:2:0 SDRsRGB/BT.601Since #3052,
dcp_crtc_check_hdr()->dcp_select_color_mode()rejected every atomic modeset with-EINVAL, trappingaquamarine/Hyprland in an unpaced retry loop (~1,000 atomic commits/s) that leftHDMI-A-1unable to complete modeset and drove idle power to 59–64 W (~2,800 GPU mailbox IRQs/s, ~23,600 timer IRQs/s, 25–43% Hyprland CPU) vs ~7.8 W baseline.Fix
drivers/gpu/drm/apple/dcp-color.h(dcp_color_space_matches): allowDRM_MODE_COLORIMETRY_BT2020_RGBwithDRM_CONNECTOR_COLOR_FORMAT_AUTOto match safeDCP_COLORIMETRY_BT2020_YCCentries in SDR as well as HDR (RGB on the wire still outranks all YCbCr formats when both exist; explicitcolor_format != AUTOstill rejects the alias).drivers/gpu/drm/apple/dcp-color.h(dcp_scan_color_modes,dcp_select_color_mode): extract the filtered catalogue scan intodcp_scan_color_modes(). When an automatic SDRBT2020_RGBrequest (color_format == AUTO,broadcast_rgb == AUTO) has no matching BT.2020 entry, retry once directly throughdcp_scan_color_modes()withDRM_MODE_COLORIMETRY_DEFAULT(never entering the legacydcp_default_sdr_color()cache fast path). This preservesDCP_COLOR_FLAG_UNSAFE/sdr_usable/allow_unsafe_sdrfiltering, EOTF checks, andmax_bpc, and works even when cached default slots are unpopulated. Explicit format, explicit range, non-BT2020_RGBcolorspaces, lowmax_bpc, and HDR/PQ requests continue to return-EINVALwhen unsupported.drivers/gpu/drm/apple/iomfb.c(dcp_crtc_check_hdr): acceptDRM_MODE_COLORIMETRY_BT2020_RGBalongsideDRM_MODE_COLORIMETRY_DEFAULTfor fixed 8-bit SDR pipes (!iomfb_template_pq || dcp_is_ext26) under the sameAUTO/AUTOand(!max_bpc || max_bpc >= 8)guards.tools/testing/selftests/drivers/gpu/apple-dcp/display.py: add unit test coverage for SDRBT2020_RGB + AUTO -> BT2020_YCC, explicit wire format alias rejection (YCBCR420+BT2020_RGB), 4K60 HDMI 2.0 safe SDR fallback with unsafe cached default (max_bpc=0/12/8, unpopulated caches,max_bpc=6), uncapped unsafe-only timing (allow_unsafe_sdr=falsevstrue), PQ-only timing rejection, and explicit format/range/colorspace/HDR rejections.Note: consistent with existing DCP output-based surface tagging, falling back to an sRGB/BT.601 link leaves the plane's base surface tag in place (it avoids a stale BT.2020 tag rather than converting BT.2020-encoded pixels);
ext26's unchanged fixed-pipe fast path still validatessdr_rgbat modeset time just as it does forDRM_MODE_COLORIMETRY_DEFAULT.Before / After on M4 Pro (J616S + LG SMART UHD 4K60 TV on
HDMI-A-1)aurora-silicon/main(6c83a2a64539)c97b9dbff5b2(j1202-144240-c43d)aquamarinefailed to commiterrorsHDMI-A-1active mode3840x2160@60,timing_id=72,color_id=125(8-bit YCbCr 4:2:0 SDR Limited)2,798/s0/s23,648/s851/s(415/s on v1)top)25–43%100.0% id59.0–64.0 W6.96 W(Heatpipe 1.99 W)6.36 W(Heatpipe 1.39 W)Tested: MacBook Pro 16-inch (M4 Pro, J616S, T6040) with LG SMART UHD 4K60 TV on
HDMI-A-1atc97b9dbff5b2(maclabb1202-144026-fde7/j1202-144240-c43d):failed_to_commit=0,HDMI-A-1active at3840x2160@60(timing_id=72,color_id=125), GPU mailbox IRQs2,798/s -> 0/s, idle power64.01 W -> 6.96 W(performance) /6.36 W(balanced);checkpatch.pl --strict0 errors / 0 warnings / 0 checks; Codex round 2 review VERIFIED (01a234ff-9a90-7112-9100-bd8925627971) including checked-indisplay.pyand production-parser probes under LLVM with UBSan.Risk: two-way ·
drivers/gpu/drm/apple/dcp-color.handiomfb.cautomatic SDRBT2020_RGBfallback