Hey,

I have been working on gamescope migration from AMD driver-specific
color props to KMS colorop API [1] and, with the fixed-matrix
replacement for COLOR_ENCODING and COLOR_RANGE[2], the only missing
color prop was the CRTC AMD REGAMMA TF (the 1D Curve). I worked on top
of Ariel&Nícolas proposal for post-blend colorop API [3], discarding
patches for DRM_CAP_CRTC_COLOR_PIPELINE driver cap flag, as commented in
this year Linux Display Hackfest, and exposed AMD post-blend colorop
pipeline with CTM -> 1D Curve -> 1D LUT, since post-blend Degamma is not
actually supported by AMD (even though there is a workaround for enable
it in CRTC color mgmt properties).

I've not worked on the gamescope part yet, but decided to share it
upstream to check if it makes sense and I'm in the right path. This
series doesn't take into account the inactive color pipeline work I've
been doing for plane color pipeline. The plan is to apply a similar
approach post-blend when we agree that the plane series is correct.

- Patch 1-12 are Ariel&Nicolas work for DRM post-blend colorop support
- Patch 13 completes deprecation of CRTC color mgmt properties if
  post-blend color pipeline is enabled by hiding them;
- Patch 14 applies the same bug fix logic as Robert did to guard plane
  client cap[4];
- Patch 15-19 add support to post-blend colorop API on AMD driver based
  on plane colorop work.

Just adding `DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE` to `drm_info`, I got
this CRTC color pipeline structure on Steam Deck with this series:

├───CRTC 0
│   ├───Object ID: 399
│   ├───Legacy info
│   │   ├───Mode: 800×[email protected] preferred driver phsync pvsync 
│   │   └───Gamma size: 256
│   └───Properties
│       ├───"ACTIVE" (atomic): range [0, 1] = 1
│       ├───"MODE_ID" (atomic): blob = 512
│       │   └───800×[email protected] preferred driver phsync pvsync 
│       ├───"OUT_FENCE_PTR" (atomic): range [0, UINT64_MAX] = 0
│       ├───"VRR_ENABLED": range [0, 1] = 0
│       └───"COLOR_PIPELINE" (atomic): enum {Bypass, Color Pipeline 400} = 
Bypass
│           ├───Bypass
│           └───Color Pipeline 400
│               ├───Color Operation 400
│               │   └───Properties
│               │       ├───"TYPE" (immutable): enum {1D Curve, 1D LUT, 3x4 
Matrix, Multiplier, 3D LUT, Fixed Matrix} = 3x4 Matrix
│               │       ├───"BYPASS" (atomic): range [0, 1] = 1
│               │       ├───"NEXT" (atomic, immutable): object colorop = 405
│               │       └───"DATA" (atomic): blob = 0
│               ├───Color Operation 405
│               │   └───Properties
│               │       ├───"TYPE" (immutable): enum {1D Curve, 1D LUT, 3x4 
Matrix, Multiplier, 3D LUT, Fixed Matrix} = 1D Curve
│               │       ├───"BYPASS" (atomic): range [0, 1] = 1
│               │       ├───"NEXT" (atomic, immutable): object colorop = 410
│               │       └───"CURVE_1D_TYPE" (atomic): enum {sRGB Inverse EOTF, 
PQ 125 Inverse EOTF, BT.2020 OETF, Gamma 2.2 Inverse, Gamma 2.4 Inverse, Gamma 
2.6 Inverse} = sRGB Inverse EOTF
│               └───Color Operation 410
│                   └───Properties
│                       ├───"TYPE" (immutable): enum {1D Curve, 1D LUT, 3x4 
Matrix, Multiplier, 3D LUT, Fixed Matrix} = 1D LUT
│                       ├───"BYPASS" (atomic): range [0, 1] = 1
│                       ├───"NEXT" (atomic, immutable): object colorop = 0
│                       ├───"SIZE" (atomic, immutable): range [0, UINT32_MAX] = 
4096
│                       ├───"LUT1D_INTERPOLATION": enum {Linear} = Linear
│                       └───"DATA" (atomic): blob = 0

Testing still pending.

FWIW, here is the `drm_info` diff:

diff --git a/drm_info.h b/drm_info.h
index e61fda7..f7f2017 100644
--- a/drm_info.h
+++ b/drm_info.h
@@ -21,5 +21,6 @@ enum {
 /* Remove after updating libdrm */
 #define DRM_MODE_OBJECT_COLOROP 0xfafafafa
 #define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE    7
+#define DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE     8
 
 #endif
diff --git a/json.c b/json.c
index c9f8c72..b2c306b 100644
--- a/json.c
+++ b/json.c
@@ -29,6 +29,7 @@ static const struct {
        { "WRITEBACK_CONNECTORS", DRM_CLIENT_CAP_WRITEBACK_CONNECTORS },
        { "CURSOR_PLANE_HOTSPOT", DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT },
        { "PLANE_COLOR_PIPELINE", DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE },
+       { "CRTC_COLOR_PIPELINE", DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE },
 };


[1] https://github.com/ValveSoftware/gamescope/pull/2113
[2] 
https://lore.kernel.org/dri-devel/[email protected]/
[3] 
https://lore.kernel.org/dri-devel/20251223-mtk-post-blend-color-pipeline-v3-0-7d969f9a3...@collabora.com/
[4] 
https://lore.kernel.org/dri-devel/[email protected]/

Let me know your thoughts!

Melissa

Ariel D'Alessandro (2):
  drm: Add helper to extract a 3x4 matrix from any CTM matrix dimensions
  drm: Add helper to extract a LUT entry from either 16-bit or 32-bit
    LUT

Melissa Wen (7):
  drm/drm_mode_object: hide deprecated CRTC color mgmt props if colorop
    is set
  drm/drm_ioctl: guard DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE
  drm/amd/display: add support to post-blend CTM colorop
  drm/amd/display: add support to post-blend 1D-Curve colorop
  drm/amd/display: add support to post-blend 1D-LUT colorop
  drm/amd/display: move CRTC CTM color mgmt prop to check helper
  drm/amd/display: enable post-blend colorop properties

Nícolas F. R. A. Prado (10):
  drm/crtc: Add color pipeline to CRTC state
  drm/colorop: Allow parenting colorop to CRTC
  drm: Factor out common color_pipeline property initialization code
  drm/crtc: Add COLOR_PIPELINE property
  drm: Introduce DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE
  drm/atomic: Pass crtc_color_pipeline client cap to atomic check
  drm/atomic: Print the color pipeline as part of the CRTC state print
  drm/colorop: Factor out common paths from colorops helpers
  drm/colorop: Introduce colorop helpers for crtc
  drm/crtc: Track crtc color pipeline client cap in drm_crtc_state

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   3 +
 .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 250 +++++++++++++---
 .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c |  76 +++++
 .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h |   2 +
 .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c    |  42 +++
 drivers/gpu/drm/drm_atomic.c                  |   9 +-
 drivers/gpu/drm/drm_atomic_uapi.c             |  72 ++++-
 drivers/gpu/drm/drm_colorop.c                 | 282 ++++++++++++++----
 drivers/gpu/drm/drm_connector.c               |   1 +
 drivers/gpu/drm/drm_crtc.c                    |  31 ++
 drivers/gpu/drm/drm_crtc_internal.h           |   1 +
 drivers/gpu/drm/drm_ioctl.c                   |  20 ++
 drivers/gpu/drm/drm_mode_object.c             |  18 ++
 drivers/gpu/drm/drm_plane.c                   |  34 +--
 drivers/gpu/drm/drm_property.c                |  44 +++
 include/drm/drm_atomic.h                      |  20 ++
 include/drm/drm_atomic_uapi.h                 |   2 +
 include/drm/drm_color_mgmt.h                  |  61 ++++
 include/drm/drm_colorop.h                     |  32 +-
 include/drm/drm_crtc.h                        |  27 ++
 include/drm/drm_file.h                        |   7 +
 include/drm/drm_property.h                    |   5 +
 include/uapi/drm/drm.h                        |  19 ++
 23 files changed, 920 insertions(+), 138 deletions(-)

-- 
2.53.0

Reply via email to