Skip to contentSkip to conversation

CSC Colorop with COLOR_RANGE and COLOR_ENCODING

RFC PATCH In review Harry Wentland 3 participants 16 messages Mar 17 – Mar 31

Subsystems (5)
lore
Share & tools
lore

Harry Wentland

author maintainer
#0 lore raw

cover CSC Colorop with COLOR_RANGE and COLOR_ENCODING

When we merged the drm_plane color pipeline API the major gap that existed was the lack of a color-space conversion colorop. We deprecated any legacy drm_plane color properties, which means that the COLOR_RANGE and COLOR_ENCODING properties can't be used with the COLOR_PIPELINE property on a drm_plane. In practice this means that we can't use a COLOR_PIPELINE on YCbCr encoded framebuffers.

This patchset adds a CSC colorop with the COLOR_RANGE and COLOR_ENCODING properties and implements support in VKMS and amdgpu.

An alternate way of possibly representing this has been proposed here:
https://patchwork.freedesktop.org/patch/709860

This code has been tested with IGT and an experimental KWin branch.

IGT branch:
https://gitlab.freedesktop.org/hwentland/igt-gpu-tools/-/tree/csc-colorop

KWin branch:
https://invent.kde.org/hwentlan/kwin/-/tree/csc-3dlut

The kernel branch containing these changes, based on drm-misc-next can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop

In order to successfully use this branch you might need a few bugfixes. The kernel tree containing those fixes plus these patches can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop-all

Further background on this work can be found at:
https://hwentland.github.io/2026/03/10/plane-color-pipeline-csc-3d-lut-kwin.html

Cc Alex Hung <[email protected]>
Cc Daniel Stone <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>
Cc Uma Shankar <[email protected]>
Cc Louis Chauvet <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Simon Ser <[email protected]>

Harry Wentland (10):
drm/colorop: Add CSC colorop type
drm/colorop: Add CSC colorop initialization helper drm/atomic: Add CSC colorop state handling
drm/vkms: Add CSC colorop support
drm/vkms: Add atomic check and matrix handling for CSC colorop drm/amd/display: Implement CSC colorop support drm/amd/display: Use GAMCOR for first TF if CSC is used drm/amd/display: Check CSC colorop bypass before programming drm/amd/display: Check actual state during commit_tail drm/amd/display: Set color_space to plane_infos

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  14 ++-
 .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 115 +++++++++++++++++-
 .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c |  25 +++-
 drivers/gpu/drm/drm_atomic.c                  |   6 +
 drivers/gpu/drm/drm_atomic_uapi.c             |   8 ++
 drivers/gpu/drm/drm_colorop.c                 |  91 ++++++++++++++
 drivers/gpu/drm/vkms/vkms_colorop.c           |  64 +++++++---
 drivers/gpu/drm/vkms/vkms_composer.c          |   5 +
 drivers/gpu/drm/vkms/vkms_plane.c             |  50 +++++++-
 include/drm/drm_colorop.h                     |  39 ++++++
 include/uapi/drm/drm_mode.h                   |   1 +
 11 files changed, 388 insertions(+), 30 deletions(-)

--
2.53.0

author maintainer
#1 lore raw

RFC PATCH 1/10 drm/colorop: Add CSC colorop type

Add DRM_COLOROP_CSC to the colorop type enum and register it in the colorop_type_name table for proper type name lookups.

This new colorop type will be used for Color Space Conversion (CSC) operations, primarily for YUV to RGB conversion with configurable color encoding and range properties.

Co-developed by Claude Sonnet 4.5.

---
 drivers/gpu/drm/drm_colorop.c | 2 ++
 include/uapi/drm/drm_mode.h   | 1 +
 2 files changed, 3 insertions(+)
drivers/gpu/drm/drm_colorop.c +2 -0
index 647cf881f413..11b2f11db874 100644
@@ -68,6 +68,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = {
 	{ DRM_COLOROP_CTM_3X4, "3x4 Matrix"},
 	{ DRM_COLOROP_MULTIPLIER, "Multiplier"},
 	{ DRM_COLOROP_3D_LUT, "3D LUT"},
+	{ DRM_COLOROP_CSC, "CSC"},
 };
 
 static const char * const colorop_curve_1d_type_names[] = {
@@ -563,6 +564,7 @@ static const char * const colorop_type_name[] = {
 	[DRM_COLOROP_CTM_3X4] = "3x4 Matrix",
 	[DRM_COLOROP_MULTIPLIER] = "Multiplier",
 	[DRM_COLOROP_3D_LUT] = "3D LUT",
+	[DRM_COLOROP_CSC] = "CSC",
 };
 
 static const char * const colorop_lu3d_interpolation_name[] = {
include/uapi/drm/drm_mode.h +1 -0
index 3693d82b5279..80296dd437e6 100644
@@ -968,6 +968,7 @@ enum drm_colorop_type {
 	 *         color = lut3d[index]
 	 */
 	DRM_COLOROP_3D_LUT,
+	DRM_COLOROP_CSC,
 };
 
 /**
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

RFC PATCH 2/10 drm/colorop: Add CSC colorop initialization helper

In reply to Harry Wentland

Add drm_plane_colorop_csc_init() helper function to initialize a CSC (Color Space Conversion) colorop with COLOR_ENCODING and COLOR_RANGE properties.

This function allows drivers to create CSC colorops with configurable YUV encoding standards (BT.601, BT.709, BT.2020) and range types (limited/full range), which control the YUV-to-RGB conversion matrix.

The colorop state structure is extended with color_encoding and color_range fields to hold the current property values.

Co-developed by Claude Sonnet 4.5.

---
 drivers/gpu/drm/drm_colorop.c | 89 +++++++++++++++++++++++++++++++++++
 include/drm/drm_colorop.h     | 39 +++++++++++++++
 2 files changed, 128 insertions(+)
drivers/gpu/drm/drm_colorop.c +89 -0
index 11b2f11db874..5329eeb0ae1b 100644
@@ -621,6 +621,95 @@ const char *drm_get_colorop_lut3d_interpolation_name(enum drm_colorop_lut3d_inte
 	return colorop_lu3d_interpolation_name[type];
 }
 
+/**
+ * drm_plane_colorop_csc_init - Initialize a CSC colorop
+ * @dev: DRM device
+ * @colorop: the color operation to initialize
+ * @plane: plane object that this colorop will belong to
+ * @supported_encodings: Bitmask of supported encodings (BIT(DRM_COLOR_YCBCR_*))
+ * @supported_ranges: Bitmask of supported ranges (BIT(DRM_COLOR_YCBCR_*_RANGE))
+ * @default_encoding: Default COLOR_ENCODING value
+ * @default_range: Default COLOR_RANGE value
+ * @flags: Flags for this colorop (DRM_COLOROP_FLAG_*)
+ *
+ * Initializes a CSC (Color Space Conversion) colorop suitable for YUV to RGB
+ * conversion. Creates COLOR_ENCODING and COLOR_RANGE properties that control
+ * which conversion matrix is used.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_plane_colorop_csc_init(struct drm_device *dev, struct drm_colorop *colorop,
+			       struct drm_plane *plane, const struct drm_colorop_funcs *funcs,
+			       u32 supported_encodings, u32 supported_ranges,
+			       enum drm_color_encoding default_encoding,
+			       enum drm_color_range default_range,
+			       uint32_t flags)
+{
+	struct drm_property *prop;
+	struct drm_prop_enum_list enum_list[max_t(int, DRM_COLOR_ENCODING_MAX,
+						       DRM_COLOR_RANGE_MAX)];
+	int i, len, ret;
+
+	ret = drm_plane_colorop_init(dev, colorop, plane, funcs, DRM_COLOROP_CSC, flags);
+	if (ret)
+		return ret;
+
+
+	if (WARN_ON(supported_encodings == 0 ||
+		    (supported_encodings & -BIT(DRM_COLOR_ENCODING_MAX)) != 0 ||
+		    (supported_encodings & BIT(default_encoding)) == 0))
+		return -EINVAL;
+
+	if (WARN_ON(supported_ranges == 0 ||
+		    (supported_ranges & -BIT(DRM_COLOR_RANGE_MAX)) != 0 ||
+		    (supported_ranges & BIT(default_range)) == 0))
+		return -EINVAL;
+
+	len = 0;
+	for (i = 0; i < DRM_COLOR_ENCODING_MAX; i++) {
+		if ((supported_encodings & BIT(i)) == 0)
+			continue;
+
+		enum_list[len].type = i;
+		enum_list[len].name = drm_get_color_encoding_name(i);
+		len++;
+	}
+
+	prop = drm_property_create_enum(dev, 0, "COLOR_ENCODING",
+					enum_list, len);
+	if (!prop)
+		return -ENOMEM;
+	colorop->color_encoding_property = prop;
+	drm_object_attach_property(&colorop->base, prop, default_encoding);
+	if (colorop->state)
+		colorop->state->color_encoding = default_encoding;
+
+	len = 0;
+	for (i = 0; i < DRM_COLOR_RANGE_MAX; i++) {
+		if ((supported_ranges & BIT(i)) == 0)
+			continue;
+
+		enum_list[len].type = i;
+		enum_list[len].name = drm_get_color_range_name(i);
+		len++;
+	}
+
+	prop = drm_property_create_enum(dev, 0, "COLOR_RANGE",
+					enum_list, len);
+	if (!prop)
+		return -ENOMEM;
+	colorop->color_range_property = prop;
+	drm_object_attach_property(&colorop->base, prop, default_range);
+	if (colorop->state)
+		colorop->state->color_range = default_range;
+
+	drm_colorop_reset(colorop);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_plane_colorop_csc_init);
+
 /**
  * drm_colorop_set_next_property - sets the next pointer
  * @colorop: drm colorop
include/drm/drm_colorop.h +39 -0
index bd082854ca74..09844e8885e2 100644
@@ -30,6 +30,8 @@
 #include <drm/drm_mode_object.h>
 #include <drm/drm_mode.h>
 #include <drm/drm_property.h>
+#include <drm/drm_color_mgmt.h>
+
 
 /* DRM colorop flags */
 #define DRM_COLOROP_FLAG_ALLOW_BYPASS	(1<<0)	/* Allow bypass on the drm_colorop */
@@ -183,6 +185,20 @@ struct drm_colorop_state {
 	 */
 	struct drm_property_blob *data;
 
+	/**
+	 * @color_encoding:
+	 *
+	 * Color encoding for YUV-to-RGB conversion
+	 */
+	enum drm_color_encoding color_encoding;
+
+	/**
+	 * @color_range:
+	 *
+	 * Color range
+	 */
+	enum drm_color_range color_range;
+
 	/** @state: backpointer to global drm_atomic_state */
 	struct drm_atomic_state *state;
 };
@@ -357,6 +373,23 @@ struct drm_colorop {
 	 */
 	struct drm_property *lut3d_interpolation_property;
 
+	/**
+	 * @color_encoding_property:
+	 *
+	 * "COLOR_ENCODING" enum property for specifying the YUV-to-RGB
+	 * conversion matrix on a DRM_COLOROP_CSC.
+	 */
+
+	struct drm_property *color_encoding_property;
+
+	/**
+	 * @color_range_property:
+	 *
+	 * "COLOR_RANGE" enum property for specifying color range
+	 * for a YUV-to-RGB conversion matrix on DRM_COLOROP_CSC.
+	 */
+	struct drm_property *color_range_property;
+
 	/**
 	 * @data_property:
 	 *
@@ -424,6 +457,12 @@ int drm_plane_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *col
 				 uint32_t lut_size,
 				 enum drm_colorop_lut3d_interpolation_type interpolation,
 				 uint32_t flags);
+int drm_plane_colorop_csc_init(struct drm_device *dev, struct drm_colorop *colorop,
+			       struct drm_plane *plane, const struct drm_colorop_funcs *funcs,
+			       u32 supported_encodings, u32 supported_ranges,
+			       enum drm_color_encoding default_encoding,
+			       enum drm_color_range default_range,
+			       uint32_t flags);
 
 struct drm_colorop_state *
 drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

RFC PATCH 3/10 drm/atomic: Add CSC colorop state handling

In reply to Harry Wentland

Add atomic state property handling for CSC colorop's COLOR_ENCODING and COLOR_RANGE properties in both set and get paths.

Also add state printing support to display the current color encoding and range settings when dumping atomic state.

Co-developed by Claude Sonnet 4.5.

---
 drivers/gpu/drm/drm_atomic.c      | 6 ++++++
 drivers/gpu/drm/drm_atomic_uapi.c | 8 ++++++++
 2 files changed, 14 insertions(+)
drivers/gpu/drm/drm_atomic.c +6 -0
index 04925166df98..2a7963c9676d 100644
@@ -844,6 +844,12 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,
 			   drm_get_colorop_lut3d_interpolation_name(colorop->lut3d_interpolation));
 		drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0);
 		break;
+	case DRM_COLOROP_CSC:
+		drm_printf(p, "\tcolor-encoding=%s\n",
+			drm_get_color_encoding_name(state->color_encoding));
+		drm_printf(p, "\tcolor-range=%s\n",
+			drm_get_color_range_name(state->color_range));
+		break;
 	default:
 		break;
 	}
drivers/gpu/drm/drm_atomic_uapi.c +8 -0
index 87de41fb4459..b760d753573c 100644
@@ -754,6 +754,10 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop,
 		state->multiplier = val;
 	} else if (property == colorop->lut3d_interpolation_property) {
 		colorop->lut3d_interpolation = val;
+	} else if (property == colorop->color_encoding_property) {
+		state->color_encoding = val;
+	} else if (property == colorop->color_range_property) {
+		state->color_range = val;
 	} else if (property == colorop->data_property) {
 		return drm_atomic_color_set_data_property(colorop, state,
 							  property, val);
@@ -787,6 +791,10 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,
 		*val = colorop->size;
 	else if (property == colorop->lut3d_interpolation_property)
 		*val = colorop->lut3d_interpolation;
+	else if (property == colorop->color_encoding_property)
+		*val = state->color_encoding;
+	else if (property == colorop->color_range_property)
+		*val = state->color_range;
 	else if (property == colorop->data_property)
 		*val = (state->data) ? state->data->base.id : 0;
 	else
Signature · 1 line
2.53.0
author maintainer
#4 lore raw

RFC PATCH 4/10 drm/vkms: Add CSC colorop support

In reply to Harry Wentland

Add CSC (Color Space Conversion) colorop as the first operation in the VKMS color pipeline. This colorop handles YUV-to-RGB conversion with support for BT.601, BT.709, and BT.2020 encoding standards and both limited and full range.

The CSC colorop supports bypass mode for RGB-only workflows. The actual YUV conversion is performed by the existing conversion_matrix path in the format reading functions, so the CSC colorop in the compositor is a no-op that just validates the configuration.

Increase MAX_COLOR_PIPELINE_OPS from 4 to 5 to accommodate the new CSC colorop at the front of the pipeline.

Co-developed by Claude Sonnet 4.5.

---
 drivers/gpu/drm/vkms/vkms_colorop.c  | 64 +++++++++++++++++++---------
 drivers/gpu/drm/vkms/vkms_composer.c |  5 +++
 2 files changed, 49 insertions(+), 20 deletions(-)
drivers/gpu/drm/vkms/vkms_colorop.c +44 -20
index 071f3a8d2e7c..429491581008 100644
@@ -16,7 +16,7 @@ static const struct drm_colorop_funcs vkms_colorop_funcs = {
 	.destroy = drm_colorop_destroy,
 };
 
-#define MAX_COLOR_PIPELINE_OPS 4
+#define MAX_COLOR_PIPELINE_OPS 5
 
 static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
 {
@@ -27,7 +27,31 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
 
 	memset(ops, 0, sizeof(ops));
 
-	/* 1st op: 1d curve */
+	/* 1st op: CSC (YUV to RGB conversion) */
+	ops[i] = kzalloc_obj(*ops[i]);
+	if (!ops[i]) {
+		drm_err(dev, "KMS: Failed to allocate colorop\n");
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	ret = drm_plane_colorop_csc_init(dev, ops[i], plane, &vkms_colorop_funcs,
+					 BIT(DRM_COLOR_YCBCR_BT601) |
+					 BIT(DRM_COLOR_YCBCR_BT709) |
+					 BIT(DRM_COLOR_YCBCR_BT2020),
+					 BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+					 BIT(DRM_COLOR_YCBCR_FULL_RANGE),
+					 DRM_COLOR_YCBCR_BT709,
+					 DRM_COLOR_YCBCR_LIMITED_RANGE,
+					 DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	if (ret)
+		goto cleanup;
+
+	list->type = ops[i]->base.id;
+
+	i++;
+
+	/* 2nd op: 1d curve */
 	ops[i] = kzalloc_obj(*ops[i]);
 	if (!ops[i]) {
 		drm_err(dev, "KMS: Failed to allocate colorop\n");
@@ -41,23 +65,6 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
 	if (ret)
 		goto cleanup;
 
-	list->type = ops[i]->base.id;
-
-	i++;
-
-	/* 2nd op: 3x4 matrix */
-	ops[i] = kzalloc_obj(*ops[i]);
-	if (!ops[i]) {
-		drm_err(dev, "KMS: Failed to allocate colorop\n");
-		ret = -ENOMEM;
-		goto cleanup;
-	}
-
-	ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane, &vkms_colorop_funcs,
-					     DRM_COLOROP_FLAG_ALLOW_BYPASS);
-	if (ret)
-		goto cleanup;
-
 	drm_colorop_set_next_property(ops[i - 1], ops[i]);
 
 	i++;
@@ -79,7 +86,24 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
 
 	i++;
 
-	/* 4th op: 1d curve */
+	/* 4th op: 3x4 matrix */
+	ops[i] = kzalloc_obj(*ops[i]);
+	if (!ops[i]) {
+		drm_err(dev, "KMS: Failed to allocate colorop\n");
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane, &vkms_colorop_funcs,
+					     DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	if (ret)
+		goto cleanup;
+
+	drm_colorop_set_next_property(ops[i - 1], ops[i]);
+
+	i++;
+
+	/* 5th op: 1d curve */
 	ops[i] = kzalloc_obj(*ops[i]);
 	if (!ops[i]) {
 		drm_err(dev, "KMS: Failed to allocate colorop\n");
drivers/gpu/drm/vkms/vkms_composer.c +5 -0
index cd85de4ffd03..1c7dba35dc3f 100644
@@ -15,6 +15,7 @@
 #include <kunit/visibility.h>
 
 #include "vkms_composer.h"
+#include "vkms_formats.h"
 #include "vkms_luts.h"
 
 static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha)
@@ -187,6 +188,10 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo
 		if (colorop_state->data)
 			apply_3x4_matrix(pixel,
 					 (struct drm_color_ctm_3x4 *)colorop_state->data->data);
+	} else if (colorop->type == DRM_COLOROP_CSC) {
+		/* CSC conversion already handled by YUV read functions via conversion_matrix.
+		 * By the time we reach this colorop, pixels are already in RGB.
+		 */
 	}
 }
 
Signature · 1 line
2.53.0
author maintainer
#5 lore raw

RFC PATCH 5/10 drm/vkms: Add atomic check and matrix handling for CSC colorop

In reply to Harry Wentland

Add validation in atomic_check to ensure YUV formats are used with an active (non-bypassed) CSC colorop as the first colorop in the pipeline.

Update atomic_update to set the YUV conversion matrix based on the CSC colorop's color_encoding and color_range properties when using the color pipeline. Falls back to legacy COLOR_ENCODING/COLOR_RANGE plane properties when not using color pipeline.

Co-developed by Claude Sonnet 4.5.

---
 drivers/gpu/drm/vkms/vkms_plane.c | 50 +++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)
drivers/gpu/drm/vkms/vkms_plane.c +48 -2
index ca7aee101a95..0be6ec813b4c 100644
@@ -6,10 +6,12 @@
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_blend.h>
+#include <drm/drm_fixed.h>
 #include <drm/drm_fourcc.h>
 #include <drm/drm_gem_atomic_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_print.h>
+#include <drm/drm_colorop.h>
 
 #include "vkms_drv.h"
 #include "vkms_formats.h"
@@ -148,8 +150,27 @@ static void vkms_plane_atomic_update(struct drm_plane *plane,
 	frame_info->rotation = new_state->rotation;
 
 	vkms_plane_state->pixel_read_line = get_pixel_read_line_function(fmt);
-	get_conversion_matrix_to_argb_u16(fmt, new_state->color_encoding, new_state->color_range,
-					  &vkms_plane_state->conversion_matrix);
+
+	if (!new_state->color_pipeline) {
+		get_conversion_matrix_to_argb_u16(fmt, new_state->color_encoding,
+						  new_state->color_range,
+						  &vkms_plane_state->conversion_matrix);
+	} else {
+		struct drm_colorop *colorop = new_state->color_pipeline;
+		struct drm_colorop_state *colorop_state = NULL;
+
+		if (colorop && colorop->type == DRM_COLOROP_CSC) {
+			colorop_state = drm_atomic_get_new_colorop_state(state,
+									  colorop);
+		}
+
+		if (colorop_state && !colorop_state->bypass) {
+			get_conversion_matrix_to_argb_u16(fmt,
+							  colorop_state->color_encoding,
+							  colorop_state->color_range,
+							  &vkms_plane_state->conversion_matrix);
+		}
+	}
 }
 
 static int vkms_plane_atomic_check(struct drm_plane *plane,
@@ -175,6 +196,31 @@ static int vkms_plane_atomic_check(struct drm_plane *plane,
 	if (ret != 0)
 		return ret;
 
+	if (new_plane_state->color_pipeline) {
+		const struct drm_format_info *info = new_plane_state->fb->format;
+
+		if (info->is_yuv) {
+			struct drm_colorop *colorop = new_plane_state->color_pipeline;
+			struct drm_colorop_state *colorop_state = NULL;
+
+			if (!colorop || colorop->type != DRM_COLOROP_CSC) {
+				DRM_DEBUG_ATOMIC("YUV format requires CSC as first colorop\n");
+				return -EINVAL;
+			}
+
+			colorop_state = drm_atomic_get_new_colorop_state(state, colorop);
+			if (!colorop_state) {
+				DRM_DEBUG_ATOMIC("Failed to get CSC colorop state\n");
+				return -EINVAL;
+			}
+
+			if (colorop_state->bypass) {
+				DRM_DEBUG_ATOMIC("YUV format requires active CSC colorop (not bypassed)\n");
+				return -EINVAL;
+			}
+		}
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.53.0
author maintainer
#6 lore raw

RFC PATCH 6/10 drm/amd/display: Implement CSC colorop support

In reply to Harry Wentland

Add CSC (Color Space Conversion) colorop to the AMDGPU color pipeline as the first operation, before DEGAM. This colorop handles YUV-to-RGB conversion with support for:
- BT.601, BT.709, BT.2020 encoding standards
- Limited and full range
- Bypass mode for RGB-only workflows

Implement __set_dm_plane_colorop_csc() which maps the CSC colorop's COLOR_ENCODING and COLOR_RANGE properties to DC's color_space enum. This controls which YUV→RGB conversion matrix DC selects from dpp_input_csc_matrix[] and programs into the DPP hardware.

The implementation forces a full_update to ensure the DPP gets reprogrammed when the CSC colorop settings change.

Co-developed by Claude Sonnet 4.5.

---
 .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 75 ++++++++++++++++++-
 .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 25 ++++++-
 2 files changed, 98 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +74 -1
index cd1e58b8defc..d13b1b2d54cf 100644
@@ -1869,6 +1869,65 @@ amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state,
 	return 0;
 }
 
+/**
+ * __set_dm_plane_colorop_csc - Handle CSC colorop for YUV to RGB conversion
+ * @plane_state: DRM plane state
+ * @dc_plane_state: DC plane state to update
+ * @colorop: The CSC colorop
+ *
+ * Reads COLOR_ENCODING and COLOR_RANGE from the CSC colorop state and maps
+ * them to DC's color_space enum, which controls the YUV→RGB conversion matrix.
+ *
+ * Returns:
+ * 0 on success, negative error code on failure
+ */
+static int
+__set_dm_plane_colorop_csc(struct drm_plane_state *plane_state,
+			   struct dc_plane_state *dc_plane_state,
+			   struct drm_colorop *colorop)
+{
+	struct drm_colorop_state *colorop_state;
+	enum drm_color_encoding encoding;
+	enum drm_color_range range;
+	enum dc_color_space dc_color_space;
+	bool full_range;
+
+	if (colorop->type != DRM_COLOROP_CSC)
+		return -EINVAL;
+
+	colorop_state = drm_atomic_get_colorop_state(plane_state->state, colorop);
+	if (IS_ERR(colorop_state))
+		return PTR_ERR(colorop_state);
+
+	encoding = colorop_state->color_encoding;
+	range = colorop_state->color_range;
+	full_range = (range == DRM_COLOR_YCBCR_FULL_RANGE);
+
+	switch (encoding) {
+	case DRM_COLOR_YCBCR_BT601:
+		dc_color_space = full_range ? COLOR_SPACE_YCBCR601
+					    : COLOR_SPACE_YCBCR601_LIMITED;
+		break;
+	case DRM_COLOR_YCBCR_BT709:
+		dc_color_space = full_range ? COLOR_SPACE_YCBCR709
+					    : COLOR_SPACE_YCBCR709_LIMITED;
+		break;
+	case DRM_COLOR_YCBCR_BT2020:
+		dc_color_space = full_range ? COLOR_SPACE_2020_YCBCR_FULL
+					    : COLOR_SPACE_2020_YCBCR_LIMITED;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	dc_plane_state->color_space = dc_color_space;
+
+	/* Force full update to ensure DPP gets reprogrammed with new CSC matrix */
+	dc_plane_state->update_flags.bits.full_update = 1;
+
+	return 0;
+}
+
 static int
 amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
 				       struct dc_plane_state *dc_plane_state)
@@ -1879,10 +1938,24 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
 	bool has_3dlut = adev->dm.dc->caps.color.dpp.hw_3d_lut || adev->dm.dc->caps.color.mpc.preblend;
 	int ret;
 
-	/* 1D Curve - DEGAM TF */
+	/* CSC - Color Space Conversion (YUV to RGB) */
 	if (!colorop)
 		return -EINVAL;
 
+	if (colorop->type == DRM_COLOROP_CSC) {
+		ret = __set_dm_plane_colorop_csc(plane_state, dc_plane_state, colorop);
+		if (ret)
+			return ret;
+
+		/* Move to next colorop */
+		colorop = colorop->next;
+		if (!colorop) {
+			drm_dbg(dev, "no colorop after CSC found\n");
+			return -EINVAL;
+		}
+	}
+
+	/* 1D Curve - DEGAM TF */
 	ret = __set_dm_plane_colorop_degamma(plane_state, dc_plane_state, colorop);
 	if (ret)
 		return ret;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +24 -1
index 3e05e48a8792..9c24fd1772a6 100644
@@ -70,6 +70,29 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
 
 	memset(ops, 0, sizeof(ops));
 
+	/* CSC - Color Space Conversion (YUV to RGB) */
+	ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
+	if (!ops[i]) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	ret = drm_plane_colorop_csc_init(dev, ops[i], plane, &dm_colorop_funcs,
+				  BIT(DRM_COLOR_YCBCR_BT601) |
+				  BIT(DRM_COLOR_YCBCR_BT709) |
+				  BIT(DRM_COLOR_YCBCR_BT2020),
+				  BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+				  BIT(DRM_COLOR_YCBCR_FULL_RANGE),
+				  DRM_COLOR_YCBCR_BT709,
+				  DRM_COLOR_YCBCR_LIMITED_RANGE,
+				  DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	if (ret)
+		goto cleanup;
+
+	list->type = ops[i]->base.id;
+
+	i++;
+
 	/* 1D curve - DEGAM TF */
 	ops[i] = kzalloc_obj(*ops[0]);
 	if (!ops[i]) {
@@ -83,7 +106,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
 	if (ret)
 		goto cleanup;
 
-	list->type = ops[i]->base.id;
+	drm_colorop_set_next_property(ops[i-1], ops[i]);
 
 	i++;
 
Signature · 1 line
2.53.0
author maintainer
#7 lore raw

RFC PATCH 7/10 drm/amd/display: Use GAMCOR for first TF if CSC is used

In reply to Harry Wentland

For subsampled formats we need to use GAMCOR instead of the DEGAM block. The color module can create a LUT for that if we set map_user_ramp to true. So do that when we have subsampled formats.

Co-developed by Claude Sonnet 4.5.

---
 .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 34 ++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +33 -1
index d13b1b2d54cf..0d58eb45552d 100644
@@ -1471,6 +1471,8 @@ __set_colorop_in_tf_1d_curve(struct dc_plane_state *dc_plane_state,
 	struct dc_transfer_func *tf = &dc_plane_state->in_transfer_func;
 	struct drm_colorop *colorop = colorop_state->colorop;
 	struct drm_device *drm = colorop->dev;
+	struct dc_color_caps *color_caps = NULL;
+	bool is_subsampled_format;
 
 	if (colorop->type != DRM_COLOROP_1D_CURVE)
 		return -EINVAL;
@@ -1486,9 +1488,39 @@ __set_colorop_in_tf_1d_curve(struct dc_plane_state *dc_plane_state,
 
 	drm_dbg(drm, "Degamma colorop with ID: %d\n", colorop->base.id);
 
-	tf->type = TF_TYPE_PREDEFINED;
+	/* Check if format requires post-scale color processing (subsampled formats) */
+	is_subsampled_format = (dc_plane_state->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN &&
+				dc_plane_state->format < SURFACE_PIXEL_FORMAT_SUBSAMPLE_END);
+
 	tf->tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type);
 
+	if (is_subsampled_format) {
+		/*
+		 * For subsampled formats (P010, NV12), we need color processing
+		 * to happen AFTER scaling (to expand UV channels first).
+		 * Convert predefined TF to PWL so DC will use GAMCOR (post-scale)
+		 * instead of PRE_DEGAM (pre-scale).
+		 *
+		 * IMPORTANT: We must pass map_user_ramp=true to force PWL conversion.
+		 * Without it, mod_color_calculate_degamma_params() returns early for
+		 * SRGB/Linear TFs without converting to TF_TYPE_DISTRIBUTED_POINTS.
+		 */
+		tf->type = TF_TYPE_PREDEFINED;
+
+		if (dc_plane_state->ctx && dc_plane_state->ctx->dc)
+			color_caps = &dc_plane_state->ctx->dc->caps.color;
+
+		if (!mod_color_calculate_degamma_params(color_caps, tf, NULL, true)) {
+			drm_err(drm, "Failed to calculate degamma params for subsampled format\n");
+			return -EINVAL;
+		}
+
+		/* mod_color_calculate_degamma_params sets tf->type to TF_TYPE_DISTRIBUTED_POINTS */
+	} else {
+		/* For non-subsampled formats (RGB, XR30), use predefined ROM LUT (PRE_DEGAM) */
+		tf->type = TF_TYPE_PREDEFINED;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.53.0
author maintainer
#8 lore raw

RFC PATCH 8/10 drm/amd/display: Check CSC colorop bypass before programming

In reply to Harry Wentland

The __set_dm_plane_colorop_csc() function was unconditionally programming the CSC (color space conversion) even when the bypass property was set. This meant that even when userspace set BYPASS=1, the hardware would still use the CSC.

Add a check for colorop_state->bypass and reset dc_plane_state->color_space to COLOR_SPACE_UNKNOWN when CSC is bypassed, properly indicating that no YUV->RGB conversion should be performed by the hardware.

This matches the behavior of other colorops in the pipeline which respect the bypass property.

Co-developed by Claude Sonnet 4.5.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +6 -0
index 0d58eb45552d..79ca7e891244 100644
@@ -1931,6 +1931,12 @@ __set_dm_plane_colorop_csc(struct drm_plane_state *plane_state,
 	if (IS_ERR(colorop_state))
 		return PTR_ERR(colorop_state);
 
+	/* If CSC is in bypass, reset color_space to unknown (no conversion) */
+	if (colorop_state->bypass) {
+		dc_plane_state->color_space = COLOR_SPACE_UNKNOWN;
+		return 0;
+	}
+
 	encoding = colorop_state->color_encoding;
 	range = colorop_state->color_range;
 	full_range = (range == DRM_COLOR_YCBCR_FULL_RANGE);
Signature · 1 line
2.53.0
author maintainer
#9 lore raw

RFC PATCH 9/10 drm/amd/display: Check actual state during commit_tail

In reply to Harry Wentland

Previously we checked the plane_state->state's plane_color_pipeline client config when determining whether fill_plane_color_attributes should run, i.e., whether we had a plane color pipeline and should use that code for handling CSC properties, or whether we should look at legacy plane encoding and range.

The problem is that we also call this during commit_tail, during which plane_state doesn't have the state backpointer. This meant that during commit_tail we'd look at the legacy plane COLOR_RANGE and COLOR_ENCODING values and overwrite what we pulled from the CSC colorop in atomic_check previously.

Instead pass the drm_atomic_state in explicitly and check that.

Co-developed by Claude Sonnet 4.5.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -5
index dfe95c9b8746..24569633cb4b 100644
@@ -6003,7 +6003,8 @@ static const struct drm_encoder_funcs amdgpu_dm_encoder_funcs = {
 };
 
 static int
-fill_plane_color_attributes(const struct drm_plane_state *plane_state,
+fill_plane_color_attributes(struct drm_atomic_state *state,
+			    const struct drm_plane_state *plane_state,
 			    const enum surface_pixel_format format,
 			    enum dc_color_space *color_space)
 {
@@ -6012,7 +6013,7 @@ fill_plane_color_attributes(const struct drm_plane_state *plane_state,
 	*color_space = COLOR_SPACE_SRGB;
 
 	/* Ignore properties when DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set */
-	if (plane_state->state && plane_state->state->plane_color_pipeline)
+	if (state && state->plane_color_pipeline)
 		return 0;
 
 	/* DRM color properties only affect non-RGB formats. */
@@ -6052,6 +6053,7 @@ fill_plane_color_attributes(const struct drm_plane_state *plane_state,
 
 static int
 fill_dc_plane_info_and_addr(struct amdgpu_device *adev,
+			    struct drm_atomic_state *state,
 			    const struct drm_plane_state *plane_state,
 			    const u64 tiling_flags,
 			    struct dc_plane_info *plane_info,
@@ -6145,7 +6147,7 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,
 
 	plane_info->layer_index = plane_state->normalized_zpos;
 
-	ret = fill_plane_color_attributes(plane_state, plane_info->format,
+	ret = fill_plane_color_attributes(state, plane_state, plane_info->format,
 					  &plane_info->color_space);
 	if (ret)
 		return ret;
@@ -6186,7 +6188,7 @@ static int fill_dc_plane_attributes(struct amdgpu_device *adev,
 	dc_plane_state->clip_rect = scaling_info.clip_rect;
 	dc_plane_state->scaling_quality = scaling_info.scaling_quality;
 
-	ret = fill_dc_plane_info_and_addr(adev, plane_state,
+	ret = fill_dc_plane_info_and_addr(adev, plane_state->state, plane_state,
 					  afb->tiling_flags,
 					  &plane_info,
 					  &dc_plane_state->address,
@@ -9981,7 +9983,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 		}
 
 		fill_dc_plane_info_and_addr(
-			dm->adev, new_plane_state,
+			dm->adev, state, new_plane_state,
 			afb->tiling_flags,
 			&bundle->plane_infos[planes_count],
 			&bundle->flip_addrs[planes_count].address,
Signature · 1 line
2.53.0
author maintainer
#10 lore raw

RFC PATCH 10/10 drm/amd/display: Set color_space to plane_infos

In reply to Harry Wentland

DC looks at plane_info structs.

For legacy drm_plane COLOR_ENCODING and COLOR_RANGE this was done in fill_dc_plane_info_and_addr's call to fill_plane_color_attributes.

Co-developed by Claude Sonnet 4.5.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -0
index 24569633cb4b..20ccff796d48 100644
@@ -9989,6 +9989,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 			&bundle->flip_addrs[planes_count].address,
 			afb->tmz_surface);
 
+		bundle->plane_infos[planes_count].color_space = dc_plane->color_space;
+
 		drm_dbg_state(state->dev, "plane: id=%d dcc_en=%d\n",
 				 new_plane_state->plane->index,
 				 bundle->plane_infos[planes_count].dcc.enable);
Signature · 1 line
2.53.0
#11 lore raw
In reply to Harry Wentland

Hello,

Personally I think"color space conversion" is quite confusing. What about using "color format conversion"(same as Nicolas' patch series) or just "color encoding conversion" instead?

Best regards,
Shengyu

Quoted 72 lines · Harry Wentland

When we merged the drm_plane color pipeline API the major gap that existed was the lack of a color-space conversion colorop. We deprecated any legacy drm_plane color properties, which means that the COLOR_RANGE and COLOR_ENCODING properties can't be used with the COLOR_PIPELINE property on a drm_plane. In practice this means that we can't use a COLOR_PIPELINE on YCbCr encoded framebuffers.

This patchset adds a CSC colorop with the COLOR_RANGE and COLOR_ENCODING properties and implements support in VKMS and amdgpu.

An alternate way of possibly representing this has been proposed here:
https://patchwork.freedesktop.org/patch/709860

This code has been tested with IGT and an experimental KWin branch.

IGT branch:
https://gitlab.freedesktop.org/hwentland/igt-gpu-tools/-/tree/csc-colorop

KWin branch:
https://invent.kde.org/hwentlan/kwin/-/tree/csc-3dlut

The kernel branch containing these changes, based on drm-misc-next can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop

In order to successfully use this branch you might need a few bugfixes. The kernel tree containing those fixes plus these patches can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop-all

Further background on this work can be found at:
https://hwentland.github.io/2026/03/10/plane-color-pipeline-csc-3d-lut-kwin.html

Cc Alex Hung <[email protected]>
Cc Daniel Stone <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>
Cc Uma Shankar <[email protected]>
Cc Louis Chauvet <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Simon Ser <[email protected]>

Harry Wentland (10):
drm/colorop: Add CSC colorop type
drm/colorop: Add CSC colorop initialization helper drm/atomic: Add CSC colorop state handling
drm/vkms: Add CSC colorop support
drm/vkms: Add atomic check and matrix handling for CSC colorop drm/amd/display: Implement CSC colorop support drm/amd/display: Use GAMCOR for first TF if CSC is used drm/amd/display: Check CSC colorop bypass before programming drm/amd/display: Check actual state during commit_tail drm/amd/display: Set color_space to plane_infos

  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  14 ++-
  .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 115 +++++++++++++++++-
  .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c |  25 +++-
  drivers/gpu/drm/drm_atomic.c                  |   6 +
  drivers/gpu/drm/drm_atomic_uapi.c             |   8 ++
  drivers/gpu/drm/drm_colorop.c                 |  91 ++++++++++++++
  drivers/gpu/drm/vkms/vkms_colorop.c           |  64 +++++++---
  drivers/gpu/drm/vkms/vkms_composer.c          |   5 +
  drivers/gpu/drm/vkms/vkms_plane.c             |  50 +++++++-
  include/drm/drm_colorop.h                     |  39 ++++++
  include/uapi/drm/drm_mode.h                   |   1 +
  11 files changed, 388 insertions(+), 30 deletions(-)

--
2.53.0

#12 lore raw
In reply to Harry Wentland

Hello Harry,

Few thoughts on the series from Intel perspective.

Quoted 8 lines · Harry Wentland

When we merged the drm_plane color pipeline API the major gap that existed was the lack of a color-space conversion colorop. We deprecated any legacy drm_plane color properties, which means that the COLOR_RANGE and COLOR_ENCODING properties can't be used with the COLOR_PIPELINE property on a drm_plane. In practice this means that we can't use a COLOR_PIPELINE on YCbCr encoded framebuffers.

Quoted 4 lines

This patchset adds a CSC colorop with the COLOR_RANGE and COLOR_ENCODING properties and implements support in VKMS and amdgpu.

AFAIU, while COLOR_RANGE and COLOR_ENCODING were plane properties, they were more representative of how the framebuffer provided to the plane should be interpreted, rather than selecting a transformation. So using them to define CSC behavior is bit of a semantic drift.

From, Intel's HW perspective we could re-use this CSC colorop but it would be
preferable to introduce new enums like "YCbCr709 to RGB", "YCbCr601 to RGB" as discussed in [1]. That way we can still represent the "RGB709 to RGB2020" conversion that Intel's fixed matrix CSC supports (instead of inventing a new colorop). We might need to change the name of colorop to something like Fixed Matrix to be inclusive of both YCbCr to RGB conversion and Primary conversion.

Regarding the range property, we could re-use the COLOR_RANGE property as you have done. In the case of Intel, we would only expose DRM_COLOR_YCBCR_FULL_RANGE as supported for this CSC, and use a separate colorop to perform YUV range correction. This allows userspace to still pass limited-range framebuffers. I am assuming here that it matters for user-space if the conversion was done in limited or full range.

[1] https://lore.kernel.org/dri-devel/[email protected]/

==
Chaitanya

Quoted 60 lines

An alternate way of possibly representing this has been proposed here:
https://patchwork.freedesktop.org/patch/709860

This code has been tested with IGT and an experimental KWin branch.

IGT branch:
https://gitlab.freedesktop.org/hwentland/igt-gpu-tools/-/tree/csc-colorop

KWin branch:
https://invent.kde.org/hwentlan/kwin/-/tree/csc-3dlut

The kernel branch containing these changes, based on drm-misc-next can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop

In order to successfully use this branch you might need a few bugfixes. The kernel tree containing those fixes plus these patches can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop-all

Further background on this work can be found at:
https://hwentland.github.io/2026/03/10/plane-color-pipeline-csc-3d-lut-kwin.html

Cc Alex Hung <[email protected]>
Cc Daniel Stone <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>
Cc Uma Shankar <[email protected]>
Cc Louis Chauvet <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Simon Ser <[email protected]>

Harry Wentland (10):
drm/colorop: Add CSC colorop type
drm/colorop: Add CSC colorop initialization helper drm/atomic: Add CSC colorop state handling
drm/vkms: Add CSC colorop support
drm/vkms: Add atomic check and matrix handling for CSC colorop drm/amd/display: Implement CSC colorop support drm/amd/display: Use GAMCOR for first TF if CSC is used drm/amd/display: Check CSC colorop bypass before programming drm/amd/display: Check actual state during commit_tail drm/amd/display: Set color_space to plane_infos

  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  14 ++-
  .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 115 +++++++++++++++++-
  .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c |  25 +++-
  drivers/gpu/drm/drm_atomic.c                  |   6 +
  drivers/gpu/drm/drm_atomic_uapi.c             |   8 ++
  drivers/gpu/drm/drm_colorop.c                 |  91 ++++++++++++++
  drivers/gpu/drm/vkms/vkms_colorop.c           |  64 +++++++---
  drivers/gpu/drm/vkms/vkms_composer.c          |   5 +
  drivers/gpu/drm/vkms/vkms_plane.c             |  50 +++++++-
  include/drm/drm_colorop.h                     |  39 ++++++
  include/uapi/drm/drm_mode.h                   |   1 +
  11 files changed, 388 insertions(+), 30 deletions(-)

--
2.53.0

author maintainer
#13 lore raw
Quoted 13 lines · Chaitanya Kumar

Hello Harry,

Few thoughts on the series from Intel perspective.

Quoted 8 lines · Harry Wentland

When we merged the drm_plane color pipeline API the major gap that existed was the lack of a color-space conversion colorop. We deprecated any legacy drm_plane color properties, which means that the COLOR_RANGE and COLOR_ENCODING properties can't be used with the COLOR_PIPELINE property on a drm_plane. In practice this means that we can't use a COLOR_PIPELINE on YCbCr encoded framebuffers.

Quoted 7 lines
Quoted 4 lines

This patchset adds a CSC colorop with the COLOR_RANGE and COLOR_ENCODING properties and implements support in VKMS and amdgpu.

AFAIU, while COLOR_RANGE and COLOR_ENCODING were plane properties, they were more representative of how the framebuffer provided to the plane should be interpreted, rather than selecting a transformation. So using them to define CSC behavior is bit of a semantic drift.

I guess CSC is misleading for this colorop. YUV conversion would describe it better.

Quoted 3 lines

From, Intel's HW perspective we could re-use this CSC colorop but it would be
preferable to introduce new enums like "YCbCr709 to RGB", "YCbCr601 to RGB" as discussed in [1]. That way we can still represent the "RGB709 to RGB2020" conversion that Intel's fixed matrix CSC supports (instead of inventing a new colorop). We might need to change the name of colorop to something like Fixed Matrix to be inclusive of both YCbCr to RGB conversion and Primary conversion.

At the core your CSC FF colorop and the one I'm trying to introduce are both backed by a fixed matrix. We could even express the range via the CSC FF colorop by introducing full and limited matrix variants for YCbCr to RGB conversion, like "YCbCr709 limited to RGB" (which is probably the norm for SDR/sRGB) and "YCbCr709 full to RGB" for full range YCbCr content.

For BT.601, BT.709, BT.2020 and full and limited range that would give us 6 enum entries, which is quite manageable.

Intel would then only advertise the full-range enums, plus the RGB-to-RGB CSC enums (like RGB709 to RGB2020) while AMD would advertise full and limited range YCbCr to RGB enums only, no RGB-to-RGB variants.

If this makes sense to you I'll be happy to rework my YUV conversion patches based on that. I think that'll work fine.

Quoted 2 lines

Regarding the range property, we could re-use the COLOR_RANGE property as you have done. In the case of Intel, we would only expose DRM_COLOR_YCBCR_FULL_RANGE as supported for this CSC, and use a separate colorop to perform YUV range correction. This allows userspace to still pass limited-range framebuffers. I am assuming here that it matters for user-space if the conversion was done in limited or full range.

It sounds like you'd need another colorop for range conversion. I wonder if it makes sense to also use the CSC FF block for that and introduce a "YUV limited to YUV full" range conversion enum. In that case naming the op named_matrix, might work better, as it can express range conversion, YUV conversion, and color space conversions.

Harry

Quoted 66 lines

[1] https://lore.kernel.org/dri-devel/[email protected]/

==
Chaitanya

Quoted 60 lines

An alternate way of possibly representing this has been proposed here:
https://patchwork.freedesktop.org/patch/709860

This code has been tested with IGT and an experimental KWin branch.

IGT branch:
https://gitlab.freedesktop.org/hwentland/igt-gpu-tools/-/tree/csc-colorop

KWin branch:
https://invent.kde.org/hwentlan/kwin/-/tree/csc-3dlut

The kernel branch containing these changes, based on drm-misc-next can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop

In order to successfully use this branch you might need a few bugfixes. The kernel tree containing those fixes plus these patches can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop-all

Further background on this work can be found at:
https://hwentland.github.io/2026/03/10/plane-color-pipeline-csc-3d-lut-kwin.html

Cc Alex Hung <[email protected]>
Cc Daniel Stone <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>
Cc Uma Shankar <[email protected]>
Cc Louis Chauvet <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Simon Ser <[email protected]>

Harry Wentland (10):
   drm/colorop: Add CSC colorop type
   drm/colorop: Add CSC colorop initialization helper drm/atomic: Add CSC colorop state handling
   drm/vkms: Add CSC colorop support
   drm/vkms: Add atomic check and matrix handling for CSC colorop drm/amd/display: Implement CSC colorop support drm/amd/display: Use GAMCOR for first TF if CSC is used drm/amd/display: Check CSC colorop bypass before programming drm/amd/display: Check actual state during commit_tail drm/amd/display: Set color_space to plane_infos

  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  14 ++- .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 115 +++++++++++++++++- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c |  25 +++- drivers/gpu/drm/drm_atomic.c                  |   6 + drivers/gpu/drm/drm_atomic_uapi.c             |   8 ++ drivers/gpu/drm/drm_colorop.c                 |  91 ++++++++++++++ drivers/gpu/drm/vkms/vkms_colorop.c           |  64 +++++++--- drivers/gpu/drm/vkms/vkms_composer.c          |   5 + drivers/gpu/drm/vkms/vkms_plane.c             |  50 +++++++- include/drm/drm_colorop.h                     |  39 ++++++ include/uapi/drm/drm_mode.h                   |   1 +

  11 files changed, 388 insertions(+), 30 deletions(-)
Signature · 1 line
2.53.0
#14 lore raw
Quoted 41 lines · Harry Wentland
Quoted 13 lines · Chaitanya Kumar

Hello Harry,

Few thoughts on the series from Intel perspective.

Quoted 8 lines · Harry Wentland

When we merged the drm_plane color pipeline API the major gap that existed was the lack of a color-space conversion colorop. We deprecated any legacy drm_plane color properties, which means that the COLOR_RANGE and COLOR_ENCODING properties can't be used with the COLOR_PIPELINE property on a drm_plane. In practice this means that we can't use a COLOR_PIPELINE on YCbCr encoded framebuffers.

Quoted 7 lines
Quoted 4 lines

This patchset adds a CSC colorop with the COLOR_RANGE and COLOR_ENCODING properties and implements support in VKMS and amdgpu.

AFAIU, while COLOR_RANGE and COLOR_ENCODING were plane properties, they were more representative of how the framebuffer provided to the plane should be interpreted, rather than selecting a transformation. So using them to define CSC behavior is bit of a semantic drift.

I guess CSC is misleading for this colorop. YUV conversion would describe it better.

Quoted 3 lines

From, Intel's HW perspective we could re-use this CSC colorop but it would be
preferable to introduce new enums like "YCbCr709 to RGB", "YCbCr601 to RGB" as discussed in [1]. That way we can still represent the "RGB709 to RGB2020" conversion that Intel's fixed matrix CSC supports (instead of inventing a new colorop). We might need to change the name of colorop to something like Fixed Matrix to be inclusive of both YCbCr to RGB conversion and Primary conversion.

At the core your CSC FF colorop and the one I'm trying to introduce are both backed by a fixed matrix. We could even express the range via the CSC FF colorop by introducing full and limited matrix variants for YCbCr to RGB conversion, like "YCbCr709 limited to RGB" (which is probably the norm for SDR/sRGB) and "YCbCr709 full to RGB" for full range YCbCr content.

For BT.601, BT.709, BT.2020 and full and limited range that would give us 6 enum entries, which is quite manageable.

Quoted 7 lines

Intel would then only advertise the full-range enums, plus the RGB-to-RGB CSC enums (like RGB709 to RGB2020) while AMD would advertise full and limited range YCbCr to RGB enums only, no RGB-to-RGB variants.

If this makes sense to you I'll be happy to rework my YUV conversion patches based on that. I think that'll work fine.

I see you already have floated a new version of the series with this change. It should work in principle, I will have a look. Thank you for the changes.

Quoted 9 lines
Quoted 2 lines

Regarding the range property, we could re-use the COLOR_RANGE property as you have done. In the case of Intel, we would only expose DRM_COLOR_YCBCR_FULL_RANGE as supported for this CSC, and use a separate colorop to perform YUV range correction. This allows userspace to still pass limited-range framebuffers. I am assuming here that it matters for user-space if the conversion was done in limited or full range.

It sounds like you'd need another colorop for range conversion. I wonder if it makes sense to also use the CSC FF block for that and introduce a "YUV limited to YUV full" range conversion enum. In that case naming the op named_matrix, might work better, as it can express range conversion, YUV conversion, and color space conversions.

Even though limited to full conversion is not strictly a matrix operation, I guess it can be re-presented as one.

==
Chaitanya

Quoted 69 lines

Harry

Quoted 66 lines

[1] https://lore.kernel.org/dri-devel/[email protected]/

==
Chaitanya

Quoted 60 lines

An alternate way of possibly representing this has been proposed here:
https://patchwork.freedesktop.org/patch/709860

This code has been tested with IGT and an experimental KWin branch.

IGT branch:
https://gitlab.freedesktop.org/hwentland/igt-gpu-tools/-/tree/csc-colorop

KWin branch:
https://invent.kde.org/hwentlan/kwin/-/tree/csc-3dlut

The kernel branch containing these changes, based on drm-misc-next can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop

In order to successfully use this branch you might need a few bugfixes. The kernel tree containing those fixes plus these patches can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop-all

Further background on this work can be found at:
https://hwentland.github.io/2026/03/10/plane-color-pipeline-csc-3d-lut-kwin.html

Cc Alex Hung <[email protected]>
Cc Daniel Stone <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>
Cc Uma Shankar <[email protected]>
Cc Louis Chauvet <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Simon Ser <[email protected]>

Harry Wentland (10):
   drm/colorop: Add CSC colorop type
   drm/colorop: Add CSC colorop initialization helper drm/atomic: Add CSC colorop state handling drm/vkms: Add CSC colorop support
   drm/vkms: Add atomic check and matrix handling for CSC colorop drm/amd/display: Implement CSC colorop support drm/amd/display: Use GAMCOR for first TF if CSC is used drm/amd/display: Check CSC colorop bypass before programming drm/amd/display: Check actual state during commit_tail drm/amd/display: Set color_space to plane_infos

   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  14 ++-
   .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 115 +++++++++++++++++-
   .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c |  25 +++-
   drivers/gpu/drm/drm_atomic.c                  |   6 +
   drivers/gpu/drm/drm_atomic_uapi.c             |   8 ++
   drivers/gpu/drm/drm_colorop.c                 |  91 ++++++++++++++
   drivers/gpu/drm/vkms/vkms_colorop.c           |  64 +++++++---
   drivers/gpu/drm/vkms/vkms_composer.c          |   5 +
   drivers/gpu/drm/vkms/vkms_plane.c             |  50 +++++++-
   include/drm/drm_colorop.h                     |  39 ++++++
   include/uapi/drm/drm_mode.h                   |   1 +
   11 files changed, 388 insertions(+), 30 deletions(-)
Signature · 1 line
2.53.0
author maintainer
#15 lore raw
Quoted 48 lines · Chaitanya Kumar
Quoted 45 lines · Harry Wentland
Quoted 13 lines · Chaitanya Kumar

Hello Harry,

Few thoughts on the series from Intel perspective.

Quoted 8 lines · Harry Wentland

When we merged the drm_plane color pipeline API the major gap that existed was the lack of a color-space conversion colorop. We deprecated any legacy drm_plane color properties, which means that the COLOR_RANGE and COLOR_ENCODING properties can't be used with the COLOR_PIPELINE property on a drm_plane. In practice this means that we can't use a COLOR_PIPELINE on YCbCr encoded framebuffers.

Quoted 7 lines
Quoted 4 lines

This patchset adds a CSC colorop with the COLOR_RANGE and COLOR_ENCODING properties and implements support in VKMS and amdgpu.

AFAIU, while COLOR_RANGE and COLOR_ENCODING were plane properties, they were more representative of how the framebuffer provided to the plane should be interpreted, rather than selecting a transformation. So using them to define CSC behavior is bit of a semantic drift.

I guess CSC is misleading for this colorop. YUV conversion would describe it better.

Quoted 3 lines

From, Intel's HW perspective we could re-use this CSC colorop but it would be
preferable to introduce new enums like "YCbCr709 to RGB", "YCbCr601 to RGB" as discussed in [1]. That way we can still represent the "RGB709 to RGB2020" conversion that Intel's fixed matrix CSC supports (instead of inventing a new colorop). We might need to change the name of colorop to something like Fixed Matrix to be inclusive of both YCbCr to RGB conversion and Primary conversion.

At the core your CSC FF colorop and the one I'm trying to introduce are both backed by a fixed matrix. We could even express the range via the CSC FF colorop by introducing full and limited matrix variants for YCbCr to RGB conversion, like "YCbCr709 limited to RGB" (which is probably the norm for SDR/sRGB) and "YCbCr709 full to RGB" for full range YCbCr content.

For BT.601, BT.709, BT.2020 and full and limited range that would give us 6 enum entries, which is quite manageable.

Intel would then only advertise the full-range enums, plus the RGB-to-RGB CSC enums (like RGB709 to RGB2020) while AMD would advertise full and limited range YCbCr to RGB enums only, no RGB-to-RGB variants.

Quoted 6 lines
Quoted 3 lines

If this makes sense to you I'll be happy to rework my YUV conversion patches based on that. I think that'll work fine.

I see you already have floated a new version of the series with this change. It should work in principle, I will have a look. Thank you for the changes.

Thanks. Looking forward to feedback.

Quoted 12 lines
Quoted 9 lines
Quoted 2 lines

Regarding the range property, we could re-use the COLOR_RANGE property as you have done. In the case of Intel, we would only expose DRM_COLOR_YCBCR_FULL_RANGE as supported for this CSC, and use a separate colorop to perform YUV range correction. This allows userspace to still pass limited-range framebuffers. I am assuming here that it matters for user-space if the conversion was done in limited or full range.

It sounds like you'd need another colorop for range conversion. I wonder if it makes sense to also use the CSC FF block for that and introduce a "YUV limited to YUV full" range conversion enum. In that case naming the op named_matrix, might work better, as it can express range conversion, YUV conversion, and color space conversions.

Even though limited to full conversion is not strictly a matrix operation, I guess it can be re-presented as one.

True. If you have a proposal for enabling range conversion on Intel HW I'll be happy to have a look. At this point I don't have a strong opinion on it.

Harry

Quoted 73 lines

==
Chaitanya

Quoted 69 lines

Harry

Quoted 66 lines

[1] https://lore.kernel.org/dri-devel/[email protected]/

==
Chaitanya

Quoted 60 lines

An alternate way of possibly representing this has been proposed here:
https://patchwork.freedesktop.org/patch/709860

This code has been tested with IGT and an experimental KWin branch.

IGT branch:
https://gitlab.freedesktop.org/hwentland/igt-gpu-tools/-/tree/csc-colorop

KWin branch:
https://invent.kde.org/hwentlan/kwin/-/tree/csc-3dlut

The kernel branch containing these changes, based on drm-misc-next can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop

In order to successfully use this branch you might need a few bugfixes. The kernel tree containing those fixes plus these patches can be found at:
https://gitlab.freedesktop.org/hwentland/linux/-/tree/csc-colorop-all

Further background on this work can be found at:
https://hwentland.github.io/2026/03/10/plane-color-pipeline-csc-3d-lut-kwin.html

Cc Alex Hung <[email protected]>
Cc Daniel Stone <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>
Cc Uma Shankar <[email protected]>
Cc Louis Chauvet <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Simon Ser <[email protected]>

Harry Wentland (10):
    drm/colorop: Add CSC colorop type
    drm/colorop: Add CSC colorop initialization helper drm/atomic: Add CSC colorop state handling drm/vkms: Add CSC colorop support
    drm/vkms: Add atomic check and matrix handling for CSC colorop drm/amd/display: Implement CSC colorop support drm/amd/display: Use GAMCOR for first TF if CSC is used drm/amd/display: Check CSC colorop bypass before programming drm/amd/display: Check actual state during commit_tail drm/amd/display: Set color_space to plane_infos

   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  14 ++- .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 115 +++++++++++++++++- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c |  25 +++- drivers/gpu/drm/drm_atomic.c                  |   6 + drivers/gpu/drm/drm_atomic_uapi.c             |   8 ++ drivers/gpu/drm/drm_colorop.c                 |  91 ++++++++++++++ drivers/gpu/drm/vkms/vkms_colorop.c           |  64 +++++++--- drivers/gpu/drm/vkms/vkms_composer.c          |   5 + drivers/gpu/drm/vkms/vkms_plane.c             |  50 +++++++- include/drm/drm_colorop.h                     |  39 ++++++ include/uapi/drm/drm_mode.h                   |   1 +

   11 files changed, 388 insertions(+), 30 deletions(-)

--
2.53.0