linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline
@ 2025-09-18  0:43 Nícolas F. R. A. Prado
  2025-09-18  0:43 ` [PATCH RFC v2 01/20] drm/crtc: Add color pipeline to CRTC state Nícolas F. R. A. Prado
                   ` (21 more replies)
  0 siblings, 22 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

This series is based on "Color Pipeline API w/ VKMS" [1]. It reuses the
same concept of a color pipeline API but for the post-blend stage
instead of pre-blend, by attaching the COLOR_PIPELINE property to the
CRTC rather than a plane.

The patches in the series first implement the necessary changes in the
DRM core to allow for post-blend color pipelines and expose it through
the uAPI, and then implement support in both the MediaTek KMS driver and
in VKMS.

This series has been tested with IGT, with the "Support post-blend color
pipeline API" series [2] applied, on top of VKMS, as well as with
Weston, with a WIP branch [3], on a MT8195-Tomato Chromebook, where both
gamma LUT and CTM color transformations have been simultaneously
configured in hardware through the API and validated (test commits for
weston at [4] and for kernel at [5]).

[1] https://lore.kernel.org/all/20250815035047.3319284-1-alex.hung@amd.com/
[2] https://lore.kernel.org/igt-dev/20250912-post-blend-colorops-v1-0-83fc62420cba@collabora.com/T/#t
[3] https://gitlab.collabora.com/nfraprado/weston/-/tree/post-blend-colorops?ref_type=heads
[4] https://gitlab.collabora.com/nfraprado/weston/-/tree/post-blend-color-pipeline-lut-ctm-test?ref_type=tags
[5] https://gitlab.collabora.com/nfraprado/linux/-/tree/debug-ctm-lut-data-post-blend-colorop?ref_type=tags

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
Changes in v2:
- Split core DRM changes for post-blend color pipelines from single
  commit into smaller changes
- Added post-blend color pipeline support in VKMS
- Introduced driver cap, and made client cap depend on it (daniels)
- Made deprecated color props (GAMMA_LUT, DEGAMMA_LUT, CTM) available as
  read-only when post-blend color pipelines are enabled (daniels)
- Created colorop_modeset_lock/unlock to commonize locking pattern for
  colorops (louis.chauvet)
- Added helper for post-blend 1D curve colorop creation
- Link to v1: https://lore.kernel.org/r/20250822-mtk-post-blend-color-pipeline-v1-0-a9446d4aca82@collabora.com

---
Nícolas F. R. A. Prado (20):
      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_CAP_POST_BLEND_COLOR_PIPELINE
      drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
      drm/atomic: Pass post_blend_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/colorop: Export drm_colorop_cleanup() so drivers can extend it
      drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state
      drm/mediatek: Support post-blend colorops for gamma and ctm
      drm/mediatek: ccorr: Support post-blend color pipeline API
      drm/mediatek: gamma: Support post-blend color pipeline API
      drm/mediatek: Set post-blend color pipeline driver cap
      drm/vkms: Rename existing color pipeline helpers to contain "pre_blend"
      drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines
      drm/vkms: Introduce support for post-blend color pipeline
      drm/vkms: Set post-blend color pipeline driver cap

 drivers/gpu/drm/drm_atomic.c              |   9 +-
 drivers/gpu/drm/drm_atomic_uapi.c         |  65 +++++++-
 drivers/gpu/drm/drm_colorop.c             | 245 ++++++++++++++++++++++++------
 drivers/gpu/drm/drm_connector.c           |   1 +
 drivers/gpu/drm/drm_crtc.c                |  77 ++++++++++
 drivers/gpu/drm/drm_crtc_internal.h       |   6 +
 drivers/gpu/drm/drm_ioctl.c               |  12 ++
 drivers/gpu/drm/drm_mode_object.c         |   9 ++
 drivers/gpu/drm/drm_plane.c               |  36 +----
 drivers/gpu/drm/mediatek/mtk_crtc.c       | 208 ++++++++++++++++++++++++-
 drivers/gpu/drm/mediatek/mtk_ddp_comp.c   |   6 +-
 drivers/gpu/drm/mediatek/mtk_ddp_comp.h   |   2 +
 drivers/gpu/drm/mediatek/mtk_disp_ccorr.c | 100 ++++++++++--
 drivers/gpu/drm/mediatek/mtk_disp_drv.h   |   6 +-
 drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 107 ++++++++++---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c    |   3 +-
 drivers/gpu/drm/vkms/vkms_colorop.c       | 106 ++++++++++++-
 drivers/gpu/drm/vkms/vkms_composer.c      |  13 +-
 drivers/gpu/drm/vkms/vkms_crtc.c          |   1 +
 drivers/gpu/drm/vkms/vkms_drv.c           |   3 +-
 drivers/gpu/drm/vkms/vkms_drv.h           |   3 +-
 drivers/gpu/drm/vkms/vkms_plane.c         |   2 +-
 include/drm/drm_atomic.h                  |  20 +++
 include/drm/drm_atomic_uapi.h             |   2 +
 include/drm/drm_colorop.h                 |  22 ++-
 include/drm/drm_crtc.h                    |  27 ++++
 include/drm/drm_drv.h                     |   6 +
 include/drm/drm_file.h                    |   7 +
 include/uapi/drm/drm.h                    |  25 +++
 29 files changed, 994 insertions(+), 135 deletions(-)
---
base-commit: 342e5ee08797cde0e8af30e6110a5dc1cba61e9c
change-id: 20250730-mtk-post-blend-color-pipeline-498e1a9cc53e

Best regards,
-- 
Nícolas F. R. A. Prado <nfraprado@collabora.com>



^ permalink raw reply	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 01/20] drm/crtc: Add color pipeline to CRTC state
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:45   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 02/20] drm/colorop: Allow parenting colorop to CRTC Nícolas F. R. A. Prado
                   ` (20 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Add a color pipeline to the CRTC state to allow post-blend color
pipelines.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 include/drm/drm_crtc.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index caa56e039da2a748cf40ebf45b37158acda439d9..77c0c04a5910a2263923e06cf37535697e20e1c9 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -274,6 +274,14 @@ struct drm_crtc_state {
 	 */
 	struct drm_property_blob *gamma_lut;
 
+	/**
+	 * @color_pipeline:
+	 *
+	 * The first colorop of the active color pipeline, or NULL, if no
+	 * color pipeline is active.
+	 */
+	struct drm_colorop *color_pipeline;
+
 	/**
 	 * @target_vblank:
 	 *

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 02/20] drm/colorop: Allow parenting colorop to CRTC
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
  2025-09-18  0:43 ` [PATCH RFC v2 01/20] drm/crtc: Add color pipeline to CRTC state Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:44   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code Nícolas F. R. A. Prado
                   ` (19 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

In order to allow for post-blend color pipelines, colorops need to be
assigned to a crtc rather than a plane. Add a crtc to the colorop
struct to enable this. Either the plane or the crtc will be set for any
given colorop depending on whether it is part of a pre- or post-blend
color pipeline.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 include/drm/drm_colorop.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index d61c6c40e47162cb8b1e7db58b6746c43ac5d202..7a4e0d0c4a3d594abecef304b1d5990434cdb231 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -206,10 +206,16 @@ struct drm_colorop {
 	/**
 	 * @plane:
 	 *
-	 * The plane on which the colorop sits. A drm_colorop is always unique
-	 * to a plane.
+	 * The plane on which the colorop sits if it is a pre-blend colorop.
+	 * In this case it is unique to the plane.
+	 *
+	 * @crtc:
+	 *
+	 * The CRTC on which the colorop sits if it is a post-blend colorop.
+	 * In this case it is unique to the CRTC.
 	 */
 	struct drm_plane *plane;
+	struct drm_crtc *crtc;
 
 	/**
 	 * @state:

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
  2025-09-18  0:43 ` [PATCH RFC v2 01/20] drm/crtc: Add color pipeline to CRTC state Nícolas F. R. A. Prado
  2025-09-18  0:43 ` [PATCH RFC v2 02/20] drm/colorop: Allow parenting colorop to CRTC Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:43   ` Louis Chauvet
  2025-09-29  8:53   ` Harry Wentland
  2025-09-18  0:43 ` [PATCH RFC v2 04/20] drm/crtc: Add COLOR_PIPELINE property Nícolas F. R. A. Prado
                   ` (18 subsequent siblings)
  21 siblings, 2 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

In preparation for sharing the initialization code for the color
pipeline property between pre- and post-blend color pipelines, factor
out the common initialization to a separate function.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_crtc.c          | 44 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_crtc_internal.h |  5 +++++
 drivers/gpu/drm/drm_plane.c         | 36 +++++-------------------------
 3 files changed, 54 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 46655339003db2a1b43441434839e26f61d79b4e..94e60cffd29972aa979ac2f1932be7a6a97f3ada 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -959,3 +959,47 @@ bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state)
 	return hweight32(crtc_state->encoder_mask) > 1;
 }
 EXPORT_SYMBOL(drm_crtc_in_clone_mode);
+
+struct drm_property *
+drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
+					  const struct drm_prop_enum_list *pipelines,
+					  int num_pipelines)
+{
+	struct drm_prop_enum_list *all_pipelines;
+	struct drm_property *prop;
+	int len = 0;
+	int i;
+
+	all_pipelines = kcalloc(num_pipelines + 1,
+				sizeof(*all_pipelines),
+				GFP_KERNEL);
+
+	if (!all_pipelines) {
+		drm_err(dev, "failed to allocate color pipeline\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	/* Create default Bypass color pipeline */
+	all_pipelines[len].type = 0;
+	all_pipelines[len].name = "Bypass";
+	len++;
+
+	/* Add all other color pipelines */
+	for (i = 0; i < num_pipelines; i++, len++) {
+		all_pipelines[len].type = pipelines[i].type;
+		all_pipelines[len].name = pipelines[i].name;
+	}
+
+	prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
+					"COLOR_PIPELINE",
+					all_pipelines, len);
+	if (IS_ERR(prop)) {
+		kfree(all_pipelines);
+		return prop;
+	}
+
+	drm_object_attach_property(obj, prop, 0);
+
+	kfree(all_pipelines);
+	return prop;
+}
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index c094092296448093c5cd192ecdc8ea9a50769c90..e3dbdcbfa385b940ec0b5476adde6146fe4afde1 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -35,6 +35,7 @@
 #ifndef __DRM_CRTC_INTERNAL_H__
 #define __DRM_CRTC_INTERNAL_H__
 
+#include <drm/drm_property.h>
 #include <linux/err.h>
 #include <linux/types.h>
 
@@ -79,6 +80,10 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
 int drm_crtc_register_all(struct drm_device *dev);
 void drm_crtc_unregister_all(struct drm_device *dev);
 int drm_crtc_force_disable(struct drm_crtc *crtc);
+struct drm_property *
+drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
+					  const struct drm_prop_enum_list *pipelines,
+					  int num_pipelines);
 
 struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc);
 
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index f6cfa8ac090c7bc49c7f276993bba7e9800da140..60dbfcab495600dd44c15260a1fa6135db59c6e2 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -1839,43 +1839,17 @@ int drm_plane_create_color_pipeline_property(struct drm_plane *plane,
 					     const struct drm_prop_enum_list *pipelines,
 					     int num_pipelines)
 {
-	struct drm_prop_enum_list *all_pipelines;
 	struct drm_property *prop;
-	int len = 0;
-	int i;
-
-	all_pipelines = kcalloc(num_pipelines + 1,
-				sizeof(*all_pipelines),
-				GFP_KERNEL);
-
-	if (!all_pipelines) {
-		drm_err(plane->dev, "failed to allocate color pipeline\n");
-		return -ENOMEM;
-	}
 
-	/* Create default Bypass color pipeline */
-	all_pipelines[len].type = 0;
-	all_pipelines[len].name = "Bypass";
-	len++;
-
-	/* Add all other color pipelines */
-	for (i = 0; i < num_pipelines; i++, len++) {
-		all_pipelines[len].type = pipelines[i].type;
-		all_pipelines[len].name = pipelines[i].name;
-	}
-
-	prop = drm_property_create_enum(plane->dev, DRM_MODE_PROP_ATOMIC,
-					"COLOR_PIPELINE",
-					all_pipelines, len);
-	if (IS_ERR(prop)) {
-		kfree(all_pipelines);
+	prop = drm_common_create_color_pipeline_property(plane->dev,
+							 &plane->base,
+							 pipelines,
+							 num_pipelines);
+	if (IS_ERR(prop))
 		return PTR_ERR(prop);
-	}
 
-	drm_object_attach_property(&plane->base, prop, 0);
 	plane->color_pipeline_property = prop;
 
-	kfree(all_pipelines);
 	return 0;
 }
 EXPORT_SYMBOL(drm_plane_create_color_pipeline_property);

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 04/20] drm/crtc: Add COLOR_PIPELINE property
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (2 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:43   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 05/20] drm: Introduce DRM_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
                   ` (17 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Add a COLOR_PIPELINE property to the CRTC to allow userspace to set a
post-blend color pipeline analogously to how pre-blend color pipelines
are set on planes.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c | 49 +++++++++++++++++++++++++++++++++++----
 drivers/gpu/drm/drm_crtc.c        | 33 ++++++++++++++++++++++++++
 include/drm/drm_atomic_uapi.h     |  2 ++
 include/drm/drm_crtc.h            | 11 +++++++++
 4 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index b7cc6945864274bedd21dd5b73494f9aae216888..063c142fd9b656e228cfc660d005a3fbb4640d32 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -287,6 +287,33 @@ drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state,
 }
 EXPORT_SYMBOL(drm_atomic_set_colorop_for_plane);
 
+/**
+ * drm_atomic_set_colorop_for_crtc - set colorop for crtc
+ * @crtc_state: atomic state object for the crtc
+ * @colorop: colorop to use for the crtc
+ *
+ * Helper function to select the color pipeline on a crtc by setting
+ * it to the first drm_colorop element of the pipeline.
+ */
+void
+drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
+				 struct drm_colorop *colorop)
+{
+	struct drm_crtc *crtc = crtc_state->crtc;
+
+	if (colorop)
+		drm_dbg_atomic(crtc->dev,
+			       "Set [COLOROP:%d] for [CRTC:%d:%s] state %p\n",
+			       colorop->base.id, crtc->base.id, crtc->name,
+			       crtc_state);
+	else
+		drm_dbg_atomic(crtc->dev,
+			       "Set [NOCOLOROP] for [CRTC:%d:%s] state %p\n",
+			       crtc->base.id, crtc->name, crtc_state);
+
+	crtc_state->color_pipeline = colorop;
+}
+EXPORT_SYMBOL(drm_atomic_set_colorop_for_crtc);
 
 /**
  * drm_atomic_set_crtc_for_connector - set CRTC for connector
@@ -396,8 +423,8 @@ static s32 __user *get_out_fence_for_connector(struct drm_atomic_state *state,
 }
 
 static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
-		struct drm_crtc_state *state, struct drm_property *property,
-		uint64_t val)
+		struct drm_crtc_state *state, struct drm_file *file_priv,
+		struct drm_property *property, uint64_t val)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_mode_config *config = &dev->mode_config;
@@ -406,7 +433,17 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 
 	if (property == config->prop_active)
 		state->active = val;
-	else if (property == config->prop_mode_id) {
+	else if (property == crtc->color_pipeline_property) {
+		/* find DRM colorop object */
+		struct drm_colorop *colorop = NULL;
+
+		colorop = drm_colorop_find(dev, file_priv, val);
+
+		if (val && !colorop)
+			return -EACCES;
+
+		drm_atomic_set_colorop_for_crtc(state, colorop);
+	} else if (property == config->prop_mode_id) {
 		struct drm_property_blob *mode =
 			drm_property_lookup_blob(dev, val);
 		ret = drm_atomic_set_mode_prop_for_crtc(state, mode);
@@ -487,6 +524,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
 		*val = 0;
 	else if (property == crtc->scaling_filter_property)
 		*val = state->scaling_filter;
+	else if (property == crtc->color_pipeline_property)
+		*val = (state->color_pipeline) ? state->color_pipeline->base.id : 0;
 	else if (crtc->funcs->atomic_get_property)
 		return crtc->funcs->atomic_get_property(crtc, state, property, val);
 	else {
@@ -1047,6 +1086,8 @@ int drm_atomic_get_property(struct drm_mode_object *obj,
 
 		if (colorop->plane)
 			WARN_ON(!drm_modeset_is_locked(&colorop->plane->mutex));
+		else if (colorop->crtc)
+			WARN_ON(!drm_modeset_is_locked(&colorop->crtc->mutex));
 
 		ret = drm_atomic_colorop_get_property(colorop,
 				colorop->state, property, val);
@@ -1204,7 +1245,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
 		}
 
 		ret = drm_atomic_crtc_set_property(crtc,
-				crtc_state, prop, prop_value);
+				crtc_state, file_priv, prop, prop_value);
 		break;
 	}
 	case DRM_MODE_OBJECT_PLANE: {
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 94e60cffd29972aa979ac2f1932be7a6a97f3ada..94238163ff1254c721df39c030bc99a31d3bb92a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1003,3 +1003,36 @@ drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mod
 	kfree(all_pipelines);
 	return prop;
 }
+
+/**
+ * drm_crtc_create_color_pipeline_property - create a new color pipeline
+ * property
+ *
+ * @crtc: drm CRTC
+ * @pipelines: list of pipelines
+ * @num_pipelines: number of pipelines
+ *
+ * Create the COLOR_PIPELINE CRTC property to specify color pipelines on
+ * the CRTC.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_crtc_create_color_pipeline_property(struct drm_crtc *crtc,
+					    const struct drm_prop_enum_list *pipelines,
+					    int num_pipelines)
+{
+	struct drm_property *prop;
+
+	prop = drm_common_create_color_pipeline_property(crtc->dev,
+							 &crtc->base,
+							 pipelines,
+							 num_pipelines);
+	if (IS_ERR(prop))
+		return PTR_ERR(prop);
+
+	crtc->color_pipeline_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_color_pipeline_property);
diff --git a/include/drm/drm_atomic_uapi.h b/include/drm/drm_atomic_uapi.h
index 4363155233267b93767c895fa6085544e2277442..4dc191f6f929d73deee9812025c48275a33cf770 100644
--- a/include/drm/drm_atomic_uapi.h
+++ b/include/drm/drm_atomic_uapi.h
@@ -52,6 +52,8 @@ void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
 				 struct drm_framebuffer *fb);
 void drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state,
 				      struct drm_colorop *colorop);
+void drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
+				     struct drm_colorop *colorop);
 int __must_check
 drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
 				  struct drm_crtc *crtc);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 77c0c04a5910a2263923e06cf37535697e20e1c9..df03637ca25abd45e96b5944229297f776fd046d 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1096,6 +1096,14 @@ struct drm_crtc {
 	 */
 	struct drm_property *scaling_filter_property;
 
+	/**
+	 * @color_pipeline_property:
+	 *
+	 * Optional "COLOR_PIPELINE" enum property for specifying
+	 * a color pipeline to use on the CRTC.
+	 */
+	struct drm_property *color_pipeline_property;
+
 	/**
 	 * @state:
 	 *
@@ -1331,5 +1339,8 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
 
 int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
 					    unsigned int supported_filters);
+int drm_crtc_create_color_pipeline_property(struct drm_crtc *crtc,
+					     const struct drm_prop_enum_list *pipelines,
+					     int num_pipelines);
 bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state);
 #endif /* __DRM_CRTC_H__ */

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 05/20] drm: Introduce DRM_CAP_POST_BLEND_COLOR_PIPELINE
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (3 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 04/20] drm/crtc: Add COLOR_PIPELINE property Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:42   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
                   ` (16 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Add a new cap that drivers can set to signal they support post-blend
color pipelines.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_ioctl.c | 3 +++
 include/drm/drm_drv.h       | 6 ++++++
 include/uapi/drm/drm.h      | 6 ++++++
 3 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index ff193155129e7e863888d8958458978566b144f8..01592d10e3465ddceddef94bc417f98d3ec12087 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -304,6 +304,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 		req->value = drm_core_check_feature(dev, DRIVER_ATOMIC) &&
 			     dev->mode_config.async_page_flip;
 		break;
+	case DRM_CAP_POST_BLEND_COLOR_PIPELINE:
+		req->value = drm_core_check_feature(dev, DRIVER_POST_BLEND_COLOR_PIPELINE);
+		break;
 	default:
 		return -EINVAL;
 	}
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 42fc085f986dee9261f8b08c4fc7d93b8d6d9769..6b0f4904e69766232283d430c2540d30afef850f 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -122,6 +122,12 @@ enum drm_driver_feature {
 	 * the cursor planes to work correctly).
 	 */
 	DRIVER_CURSOR_HOTSPOT           = BIT(9),
+	/**
+	 * @DRIVER_POST_BLEND_COLOR_PIPELINE:
+	 *
+	 * Driver supports post-blend color pipeline.
+	 */
+	DRIVER_POST_BLEND_COLOR_PIPELINE		= BIT(10),
 
 	/* IMPORTANT: Below are all the legacy flags, add new ones above. */
 
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 27cc159c1d275c7a7fe057840ef792f30a582bb7..c6c53e57958e951204154ce41a69696a6876f0e8 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -812,6 +812,12 @@ struct drm_gem_change_handle {
  * commits.
  */
 #define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP	0x15
+/**
+ * DRM_CAP_POST_BLEND_COLOR_PIPELINE
+ *
+ * If set to 1, the driver supports post-blend color pipelines.
+ */
+#define DRM_CAP_POST_BLEND_COLOR_PIPELINE	0x16
 
 /* DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (4 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 05/20] drm: Introduce DRM_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:42   ` Louis Chauvet
  2025-09-29  9:48   ` Harry Wentland
  2025-09-18  0:43 ` [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check Nícolas F. R. A. Prado
                   ` (15 subsequent siblings)
  21 siblings, 2 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE which a DRM client
can set to enable the usage of post-blend color pipelines instead of the
now deprecated CRTC color management properties: "GAMMA_LUT",
"DEGAMMA_LUT" and "CTM".

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c   | 15 +++++++++++++++
 drivers/gpu/drm/drm_connector.c     |  1 +
 drivers/gpu/drm/drm_crtc_internal.h |  1 +
 drivers/gpu/drm/drm_ioctl.c         |  9 +++++++++
 drivers/gpu/drm/drm_mode_object.c   |  9 +++++++++
 include/drm/drm_file.h              |  7 +++++++
 include/uapi/drm/drm.h              | 19 +++++++++++++++++++
 7 files changed, 61 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 063c142fd9b656e228cfc660d005a3fbb4640d32..f5125fa3fa28ff2a6ff07fd7cf07d4bdf77ab738 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -452,6 +452,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 	} else if (property == config->prop_vrr_enabled) {
 		state->vrr_enabled = val;
 	} else if (property == config->degamma_lut_property) {
+		if (file_priv->post_blend_color_pipeline) {
+			drm_dbg_atomic(dev,
+				"Setting DEGAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
+			return -EINVAL;
+		}
 		ret = drm_property_replace_blob_from_id(dev,
 					&state->degamma_lut,
 					val,
@@ -460,6 +465,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 		state->color_mgmt_changed |= replaced;
 		return ret;
 	} else if (property == config->ctm_property) {
+		if (file_priv->post_blend_color_pipeline) {
+			drm_dbg_atomic(dev,
+				"Setting CTM CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
+			return -EINVAL;
+		}
 		ret = drm_property_replace_blob_from_id(dev,
 					&state->ctm,
 					val,
@@ -468,6 +478,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 		state->color_mgmt_changed |= replaced;
 		return ret;
 	} else if (property == config->gamma_lut_property) {
+		if (file_priv->post_blend_color_pipeline) {
+			drm_dbg_atomic(dev,
+				"Setting GAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
+			return -EINVAL;
+		}
 		ret = drm_property_replace_blob_from_id(dev,
 					&state->gamma_lut,
 					val,
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 4d6dc9ebfdb5bc730b1aff7a184448af7b93f078..f58cfd2131139ff3e613adc4dbb9ddbedf724dc7 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -3440,6 +3440,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
 	 */
 	ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
 			file_priv->plane_color_pipeline,
+			file_priv->post_blend_color_pipeline,
 			(uint32_t __user *)(unsigned long)(out_resp->props_ptr),
 			(uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
 			&out_resp->count_props);
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index e3dbdcbfa385b940ec0b5476adde6146fe4afde1..c53f154e5392a10c326c844b7321666275f9ac02 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -169,6 +169,7 @@ void drm_mode_object_unregister(struct drm_device *dev,
 				struct drm_mode_object *object);
 int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
 				   bool plane_color_pipeline,
+				   bool post_blend_color_pipeline,
 				   uint32_t __user *prop_ptr,
 				   uint64_t __user *prop_values,
 				   uint32_t *arg_count_props);
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 01592d10e3465ddceddef94bc417f98d3ec12087..ea9600f5392f520a2b42ba7ef363d2f08ce19812 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -383,6 +383,15 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
 			return -EINVAL;
 		file_priv->plane_color_pipeline = req->value;
 		break;
+	case DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE:
+		if (!file_priv->atomic)
+			return -EINVAL;
+		if (req->value > 1)
+			return -EINVAL;
+		if (!drm_core_check_feature(dev, DRIVER_POST_BLEND_COLOR_PIPELINE))
+			return -EINVAL;
+		file_priv->post_blend_color_pipeline = req->value;
+		break;
 	default:
 		return -EINVAL;
 	}
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index b45d501b10c868c6d9b7a5a8760eadbd7b372a6a..5e6c3de9456b997985142a68b9cef57771a58bdc 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -388,6 +388,7 @@ EXPORT_SYMBOL(drm_object_property_get_default_value);
 /* helper for getconnector and getproperties ioctls */
 int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
 				   bool plane_color_pipeline,
+				   bool post_blend_color_pipeline,
 				   uint32_t __user *prop_ptr,
 				   uint64_t __user *prop_values,
 				   uint32_t *arg_count_props)
@@ -416,6 +417,13 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
 				continue;
 		}
 
+		if (!post_blend_color_pipeline && obj->type == DRM_MODE_OBJECT_CRTC) {
+			struct drm_crtc *crtc = obj_to_crtc(obj);
+
+			if (prop == crtc->color_pipeline_property)
+				continue;
+		}
+
 		if (*arg_count_props > count) {
 			ret = __drm_object_property_get_value(obj, prop, &val);
 			if (ret)
@@ -475,6 +483,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
 
 	ret = drm_mode_object_get_properties(obj, file_priv->atomic,
 			file_priv->plane_color_pipeline,
+			file_priv->post_blend_color_pipeline,
 			(uint32_t __user *)(unsigned long)(arg->props_ptr),
 			(uint64_t __user *)(unsigned long)(arg->prop_values_ptr),
 			&arg->count_props);
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 1a3018e4a537b3341acb50187d47371f6b781b9d..42b9a43baa18079af8ec2ea5b1484b23c497beb0 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -213,6 +213,13 @@ struct drm_file {
 	 */
 	bool plane_color_pipeline;
 
+	/**
+	 * @post_blend_color_pipeline:
+	 *
+	 * True if client understands post-blend color pipelines
+	 */
+	bool post_blend_color_pipeline;
+
 	/**
 	 * @was_master:
 	 *
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index c6c53e57958e951204154ce41a69696a6876f0e8..f9ac10b3e4876f71005a87dedefa4aed320566f0 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -927,6 +927,25 @@ struct drm_get_cap {
  */
 #define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE	7
 
+/**
+ * DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
+ *
+ * If set to 1 the DRM core will allow setting the COLOR_PIPELINE
+ * property on a &drm_crtc, as well as drm_colorop properties.
+ *
+ * Setting of these crtc properties will be rejected when this client
+ * cap is set:
+ * - GAMMA_LUT
+ * - DEGAMMA_LUT
+ * - CTM
+ *
+ * The client must enable &DRM_CLIENT_CAP_ATOMIC first.
+ *
+ * This client cap can only be set if the driver sets the corresponding driver
+ * cap &DRM_CAP_POST_BLEND_COLOR_PIPELINE.
+ */
+#define DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE	8
+
 /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
 struct drm_set_client_cap {
 	__u64 capability;

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (5 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:41   ` Louis Chauvet
  2025-09-29  9:50   ` Harry Wentland
  2025-09-18  0:43 ` [PATCH RFC v2 08/20] drm/atomic: Print the color pipeline as part of the CRTC state print Nícolas F. R. A. Prado
                   ` (14 subsequent siblings)
  21 siblings, 2 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Pass the state of the post-blend color pipeline client cap to the atomic
state so that drivers can rely on it to enable color pipeline
functionality and ignore the deprecated color management CRTC
properties.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c |  1 +
 include/drm/drm_atomic.h          | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index f5125fa3fa28ff2a6ff07fd7cf07d4bdf77ab738..56a440a9390c7730c4c41b491f29b933a2bbb889 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1660,6 +1660,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 	state->acquire_ctx = &ctx;
 	state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
 	state->plane_color_pipeline = file_priv->plane_color_pipeline;
+	state->post_blend_color_pipeline = file_priv->post_blend_color_pipeline;
 
 retry:
 	copied_objs = 0;
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 678708df9cdb90b4266127193a92183069f18688..8c42c584aefbf0034b2163d90538e80099b0dadb 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -482,6 +482,26 @@ struct drm_atomic_state {
 	 */
 	bool plane_color_pipeline : 1;
 
+	/**
+	 * @post_blend_color_pipeline:
+	 *
+	 * Indicates whether this atomic state originated with a client that
+	 * set the DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE.
+	 *
+	 * Drivers and helper functions should use this to ignore legacy
+	 * properties that are incompatible with the drm_crtc COLOR_PIPELINE
+	 * behavior, such as:
+	 *
+	 *  - GAMMA_LUT
+	 *  - DEGAMMA_LUT
+	 *  - GAMMA_LUT_SIZE
+	 *  - CTM
+	 *
+	 * or any other driver-specific properties that might affect pixel
+	 * values.
+	 */
+	bool post_blend_color_pipeline : 1;
+
 	/**
 	 * @colorops:
 	 *

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 08/20] drm/atomic: Print the color pipeline as part of the CRTC state print
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (6 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:50   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 09/20] drm/colorop: Factor out common paths from colorops helpers Nícolas F. R. A. Prado
                   ` (13 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Print the value of the color pipeline in the CRTC state as part of the
CRTC state print.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_atomic.c  |  8 +++++---
 drivers/gpu/drm/drm_colorop.c | 26 ++++++++++++++++++++++++++
 include/drm/drm_colorop.h     |  3 +++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 3ab32fe7fe1cbf9057c3763d979638dce013d82b..6982c978dc530b838353ace60f748660c3b4524d 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -472,6 +472,8 @@ static void drm_atomic_crtc_print_state(struct drm_printer *p,
 	drm_printf(p, "\tplane_mask=%x\n", state->plane_mask);
 	drm_printf(p, "\tconnector_mask=%x\n", state->connector_mask);
 	drm_printf(p, "\tencoder_mask=%x\n", state->encoder_mask);
+	drm_printf(p, "\tcolor-pipeline=%d\n",
+		   state->color_pipeline ? state->color_pipeline->base.id : 0);
 	drm_printf(p, "\tmode: " DRM_MODE_FMT "\n", DRM_MODE_ARG(&state->mode));
 
 	if (crtc->funcs->atomic_print_state)
@@ -617,7 +619,7 @@ drm_atomic_get_colorop_state(struct drm_atomic_state *state,
 	if (colorop_state)
 		return colorop_state;
 
-	ret = drm_modeset_lock(&colorop->plane->mutex, state->acquire_ctx);
+	ret = drm_colorop_modeset_lock(colorop, state->acquire_ctx);
 	if (ret)
 		return ERR_PTR(ret);
 
@@ -2004,10 +2006,10 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,
 
 	list_for_each_entry(colorop, &config->colorop_list, head) {
 		if (take_locks)
-			drm_modeset_lock(&colorop->plane->mutex, NULL);
+			drm_colorop_modeset_lock(colorop, NULL);
 		drm_atomic_colorop_print_state(p, colorop->state);
 		if (take_locks)
-			drm_modeset_unlock(&colorop->plane->mutex);
+			drm_colorop_modeset_unlock(colorop);
 	}
 
 	list_for_each_entry(plane, &config->plane_list, head) {
diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index a1b36cd488f0a014425a9192ffe5fcc4d2c1afaa..1384a259605fa4945aa74402901886d7e1fde0d1 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -24,6 +24,7 @@
  *
  */
 
+#include <drm/drm_crtc.h>
 #include <drm/drm_colorop.h>
 #include <drm/drm_print.h>
 #include <drm/drm_drv.h>
@@ -595,3 +596,28 @@ void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_color
 	colorop->next = next;
 }
 EXPORT_SYMBOL(drm_colorop_set_next_property);
+
+int drm_colorop_modeset_lock(struct drm_colorop *colorop, struct drm_modeset_acquire_ctx *ctx)
+{
+	if (colorop->plane)
+		return drm_modeset_lock(&colorop->plane->mutex, ctx);
+
+	if (colorop->crtc)
+		return drm_modeset_lock(&colorop->crtc->mutex, ctx);
+
+	drm_err(colorop->dev, "Dangling colorop, it must be attached to a plane or a CRTC\n");
+	return -EINVAL;
+}
+EXPORT_SYMBOL(drm_colorop_modeset_lock);
+
+
+void drm_colorop_modeset_unlock(struct drm_colorop *colorop)
+{
+	if (colorop->plane)
+		drm_modeset_unlock(&colorop->plane->mutex);
+	else if (colorop->crtc)
+		drm_modeset_unlock(&colorop->crtc->mutex);
+	else
+		drm_err(colorop->dev, "Dangling colorop, it must be attached to a plane or a CRTC\n");
+}
+EXPORT_SYMBOL(drm_colorop_modeset_unlock);
diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index 7a4e0d0c4a3d594abecef304b1d5990434cdb231..3e223f3b3597978c5d702ce7622ae30b8aa9dddb 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -29,6 +29,7 @@
 
 #include <drm/drm_mode_object.h>
 #include <drm/drm_mode.h>
+#include <drm/drm_modeset_lock.h>
 #include <drm/drm_property.h>
 
 /* DRM colorop flags */
@@ -444,5 +445,7 @@ const char *drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_inte
 const char *drm_get_colorop_lut3d_interpolation_name(enum drm_colorop_lut3d_interpolation_type type);
 
 void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next);
+int drm_colorop_modeset_lock(struct drm_colorop *colorop, struct drm_modeset_acquire_ctx *ctx);
+void drm_colorop_modeset_unlock(struct drm_colorop *colorop);
 
 #endif /* __DRM_COLOROP_H__ */

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 09/20] drm/colorop: Factor out common paths from colorops helpers
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (7 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 08/20] drm/atomic: Print the color pipeline as part of the CRTC state print Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:51   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 10/20] drm/colorop: Introduce colorop helpers for crtc Nícolas F. R. A. Prado
                   ` (12 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Factor out the common code paths from the colorop helpers so they can be
reused by the post-blend colorop helpers.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_colorop.c | 145 ++++++++++++++++++++++++++++--------------
 1 file changed, 99 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index 1384a259605fa4945aa74402901886d7e1fde0d1..db137169effa6cd9e6d5805f65bdfd1cc6882075 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -91,8 +91,9 @@ static const struct drm_prop_enum_list drm_colorop_lut3d_interpolation_list[] =
 
 /* Init Helpers */
 
-static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
-			    struct drm_plane *plane, enum drm_colorop_type type, uint32_t flags)
+static int drm_common_colorop_init(struct drm_device *dev,
+				   struct drm_colorop *colorop,
+				   enum drm_colorop_type type, uint32_t flags)
 {
 	struct drm_mode_config *config = &dev->mode_config;
 	struct drm_property *prop;
@@ -105,7 +106,6 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co
 	colorop->base.properties = &colorop->properties;
 	colorop->dev = dev;
 	colorop->type = type;
-	colorop->plane = plane;
 	colorop->next = NULL;
 
 	list_add_tail(&colorop->head, &config->colorop_list);
@@ -154,6 +154,20 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co
 	return ret;
 }
 
+static int drm_plane_colorop_init(struct drm_device *dev,
+				  struct drm_colorop *colorop,
+				  struct drm_plane *plane,
+				  enum drm_colorop_type type, uint32_t flags)
+{
+	int ret;
+
+	ret = drm_common_colorop_init(dev, colorop, type, flags);
+
+	colorop->plane = plane;
+
+	return ret;
+}
+
 /**
  * drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline
  *
@@ -206,31 +220,13 @@ EXPORT_SYMBOL(drm_colorop_pipeline_destroy);
  * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
  * @return zero on success, -E value on failure
  */
-int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
-				    struct drm_plane *plane, u64 supported_tfs, uint32_t flags)
+static int drm_common_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
+					    u64 supported_tfs, uint32_t flags)
 {
 	struct drm_prop_enum_list enum_list[DRM_COLOROP_1D_CURVE_COUNT];
 	int i, len;
 
 	struct drm_property *prop;
-	int ret;
-
-	if (!supported_tfs) {
-		drm_err(dev,
-			"No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n",
-			plane->base.id, plane->name);
-		return -EINVAL;
-	}
-
-	if ((supported_tfs & -BIT(DRM_COLOROP_1D_CURVE_COUNT)) != 0) {
-		drm_err(dev, "Unknown TF provided on [PLANE:%d:%s]\n",
-			plane->base.id, plane->name);
-		return -EINVAL;
-	}
-
-	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE, flags);
-	if (ret)
-		return ret;
 
 	len = 0;
 	for (i = 0; i < DRM_COLOROP_1D_CURVE_COUNT; i++) {
@@ -260,6 +256,41 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *
 
 	return 0;
 }
+
+static int drm_colorop_has_supported_tf(struct drm_device *dev, struct drm_mode_object *obj,
+					const char *name, u64 supported_tfs)
+{
+	if (!supported_tfs) {
+		drm_err(dev,
+			"No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n",
+			obj->id, name);
+		return -EINVAL;
+	}
+
+	if ((supported_tfs & -BIT(DRM_COLOROP_1D_CURVE_COUNT)) != 0) {
+		drm_err(dev, "Unknown TF provided on [PLANE:%d:%s]\n",
+			obj->id, name);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
+				    struct drm_plane *plane, u64 supported_tfs, uint32_t flags)
+{
+	int ret;
+
+	ret = drm_colorop_has_supported_tf(dev, &plane->base, plane->name, supported_tfs);
+	if (ret)
+		return ret;
+
+	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE, flags);
+	if (ret)
+		return ret;
+
+	return drm_common_colorop_curve_1d_init(dev, colorop, supported_tfs, flags);
+}
 EXPORT_SYMBOL(drm_plane_colorop_curve_1d_init);
 
 static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_colorop *colorop)
@@ -280,29 +311,16 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color
 	return 0;
 }
 
-/**
- * drm_plane_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT
- *
- * @dev: DRM device
- * @colorop: The drm_colorop object to initialize
- * @plane: The associated drm_plane
- * @lut_size: LUT size supported by driver
- * @lut1d_interpolation: 1D LUT interpolation type
- * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
- * @return zero on success, -E value on failure
- */
-int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
-					struct drm_plane *plane, uint32_t lut_size,
-					enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
-					uint32_t flags)
+static int
+drm_common_colorop_curve_1d_lut_init(struct drm_device *dev,
+				     struct drm_colorop *colorop,
+				     uint32_t lut_size,
+				     enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
+				     uint32_t flags)
 {
 	struct drm_property *prop;
 	int ret;
 
-	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT, flags);
-	if (ret)
-		return ret;
-
 	/* initialize 1D LUT only attribute */
 	/* LUT size */
 	prop = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC,
@@ -334,17 +352,40 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color
 
 	return 0;
 }
-EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_init);
 
-int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
-				   struct drm_plane *plane, uint32_t flags)
+/**
+ * drm_plane_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT
+ *
+ * @dev: DRM device
+ * @colorop: The drm_colorop object to initialize
+ * @plane: The associated drm_plane
+ * @lut_size: LUT size supported by driver
+ * @lut1d_interpolation: 1D LUT interpolation type
+ * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
+ * @return zero on success, -E value on failure
+ */
+int
+drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
+				    struct drm_plane *plane, uint32_t lut_size,
+				    enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
+				    uint32_t flags)
 {
 	int ret;
 
-	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4, flags);
+	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT, flags);
 	if (ret)
 		return ret;
 
+	return drm_common_colorop_curve_1d_lut_init(dev, colorop, lut_size,
+						    lut1d_interpolation, flags);
+}
+EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_init);
+
+static int drm_common_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
+					   uint32_t flags)
+{
+	int ret;
+
 	ret = drm_colorop_create_data_prop(dev, colorop);
 	if (ret)
 		return ret;
@@ -353,6 +394,18 @@ int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *c
 
 	return 0;
 }
+
+int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
+				   struct drm_plane *plane, uint32_t flags)
+{
+	int ret;
+
+	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4, flags);
+	if (ret)
+		return ret;
+
+	return drm_common_colorop_ctm_3x4_init(dev, colorop, flags);
+}
 EXPORT_SYMBOL(drm_plane_colorop_ctm_3x4_init);
 
 /**

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 10/20] drm/colorop: Introduce colorop helpers for crtc
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (8 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 09/20] drm/colorop: Factor out common paths from colorops helpers Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:44   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 11/20] drm/colorop: Export drm_colorop_cleanup() so drivers can extend it Nícolas F. R. A. Prado
                   ` (11 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Introduce colorop helper counterparts for post-blend color pipelines
that take a CRTC instead of a plane.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_colorop.c | 73 +++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_colorop.h     |  8 +++++
 2 files changed, 81 insertions(+)

diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index db137169effa6cd9e6d5805f65bdfd1cc6882075..b0c3216f4dac22f3408cbd537a20f38d03abc0a7 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -168,6 +168,20 @@ static int drm_plane_colorop_init(struct drm_device *dev,
 	return ret;
 }
 
+static int drm_crtc_colorop_init(struct drm_device *dev,
+				 struct drm_colorop *colorop,
+				 struct drm_crtc *crtc,
+				 enum drm_colorop_type type, uint32_t flags)
+{
+	int ret;
+
+	ret = drm_common_colorop_init(dev, colorop, type, flags);
+
+	colorop->crtc = crtc;
+
+	return ret;
+}
+
 /**
  * drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline
  *
@@ -293,6 +307,23 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *
 }
 EXPORT_SYMBOL(drm_plane_colorop_curve_1d_init);
 
+int drm_crtc_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
+				   struct drm_crtc *crtc, u64 supported_tfs, uint32_t flags)
+{
+	int ret;
+
+	ret = drm_colorop_has_supported_tf(dev, &crtc->base, crtc->name, supported_tfs);
+	if (ret)
+		return ret;
+
+	ret = drm_crtc_colorop_init(dev, colorop, crtc, DRM_COLOROP_1D_CURVE, flags);
+	if (ret)
+		return ret;
+
+	return drm_common_colorop_curve_1d_init(dev, colorop, supported_tfs, flags);
+}
+EXPORT_SYMBOL(drm_crtc_colorop_curve_1d_init);
+
 static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_colorop *colorop)
 {
 	struct drm_property *prop;
@@ -381,6 +412,35 @@ drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *
 }
 EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_init);
 
+/**
+ * drm_crtc_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT
+ *
+ * @dev: DRM device
+ * @colorop: The drm_colorop object to initialize
+ * @crtc: The associated drm_crtc
+ * @lut_size: LUT size supported by driver
+ * @lut1d_interpolation: 1D LUT interpolation type
+ * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
+ * @return zero on success, -E value on failure
+ */
+int
+drm_crtc_colorop_curve_1d_lut_init(struct drm_device *dev,
+				   struct drm_colorop *colorop,
+				   struct drm_crtc *crtc, uint32_t lut_size,
+				   enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
+				   uint32_t flags)
+{
+	int ret;
+
+	ret = drm_crtc_colorop_init(dev, colorop, crtc, DRM_COLOROP_1D_LUT, flags);
+	if (ret)
+		return ret;
+
+	return drm_common_colorop_curve_1d_lut_init(dev, colorop, lut_size,
+						    lut1d_interpolation, flags);
+}
+EXPORT_SYMBOL(drm_crtc_colorop_curve_1d_lut_init);
+
 static int drm_common_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
 					   uint32_t flags)
 {
@@ -408,6 +468,19 @@ int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *c
 }
 EXPORT_SYMBOL(drm_plane_colorop_ctm_3x4_init);
 
+int drm_crtc_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
+				   struct drm_crtc *crtc, uint32_t flags)
+{
+	int ret;
+
+	ret = drm_crtc_colorop_init(dev, colorop, crtc, DRM_COLOROP_CTM_3X4, flags);
+	if (ret)
+		return ret;
+
+	return drm_common_colorop_ctm_3x4_init(dev, colorop, flags);
+}
+EXPORT_SYMBOL(drm_crtc_colorop_ctm_3x4_init);
+
 /**
  * drm_plane_colorop_mult_init - Initialize a DRM_COLOROP_MULTIPLIER
  *
diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index 3e223f3b3597978c5d702ce7622ae30b8aa9dddb..e7d1e5e95a901b1bd91fd8580e2fcb367c0253ce 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -377,14 +377,22 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,
 
 void drm_colorop_pipeline_destroy(struct drm_device *dev);
 
+int drm_crtc_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
+				       struct drm_crtc *crtc, uint32_t lut_size,
+				       enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
+				       uint32_t flags);
 int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
 				    struct drm_plane *plane, u64 supported_tfs, uint32_t flags);
+int drm_crtc_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
+				   struct drm_crtc *crtc, u64 supported_tfs, uint32_t flags);
 int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
 					struct drm_plane *plane, uint32_t lut_size,
 					enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
 					uint32_t flags);
 int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
 				   struct drm_plane *plane, uint32_t flags);
+int drm_crtc_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
+				   struct drm_crtc *crtc, uint32_t flags);
 int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
 				struct drm_plane *plane, uint32_t flags);
 int drm_plane_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *colorop,

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 11/20] drm/colorop: Export drm_colorop_cleanup() so drivers can extend it
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (9 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 10/20] drm/colorop: Introduce colorop helpers for crtc Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-18  0:43 ` [PATCH RFC v2 12/20] drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state Nícolas F. R. A. Prado
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Export drm_colorop_cleanup() so drivers subclassing drm_colorop can
reuse this function in subclass cleanup routines.

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_colorop.c | 3 ++-
 include/drm/drm_colorop.h     | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index b0c3216f4dac22f3408cbd537a20f38d03abc0a7..83deb2bc6f50fe030664548365d22de9b45f486b 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -187,7 +187,7 @@ static int drm_crtc_colorop_init(struct drm_device *dev,
  *
  * @colorop: The drm_colorop object to be cleaned
  */
-static void drm_colorop_cleanup(struct drm_colorop *colorop)
+void drm_colorop_cleanup(struct drm_colorop *colorop)
 {
 	struct drm_device *dev = colorop->dev;
 	struct drm_mode_config *config = &dev->mode_config;
@@ -202,6 +202,7 @@ static void drm_colorop_cleanup(struct drm_colorop *colorop)
 
 	kfree(colorop->state);
 }
+EXPORT_SYMBOL(drm_colorop_cleanup);
 
 /**
  * drm_colorop_pipeline_destroy - Helper for color pipeline destruction
diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index e7d1e5e95a901b1bd91fd8580e2fcb367c0253ce..f7472ece00cdb09ae204d0c2339eb35c3246874e 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -375,6 +375,7 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,
 	return mo ? obj_to_colorop(mo) : NULL;
 }
 
+void drm_colorop_cleanup(struct drm_colorop *colorop);
 void drm_colorop_pipeline_destroy(struct drm_device *dev);
 
 int drm_crtc_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 12/20] drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (10 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 11/20] drm/colorop: Export drm_colorop_cleanup() so drivers can extend it Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:51   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 13/20] drm/mediatek: Support post-blend colorops for gamma and ctm Nícolas F. R. A. Prado
                   ` (9 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Some drivers, like VKMS, only have access to the drm_crtc_state but not
the drm_atomic_state during composition of the output framebuffer. Store
the state of the post-blend color pipeline client cap in the
drm_crtc_state so those drivers can decide whether to look at the color
pipeline or the legacy properties for the color management settings to
apply.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/drm_atomic.c | 1 +
 include/drm/drm_crtc.h       | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 6982c978dc530b838353ace60f748660c3b4524d..bbfa35c800240722785a6db440eb3d47ef9c8ed6 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -386,6 +386,7 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
 	state->crtcs[index].new_state = crtc_state;
 	state->crtcs[index].ptr = crtc;
 	crtc_state->state = state;
+	crtc_state->color_pipeline_enabled = state->post_blend_color_pipeline;
 
 	drm_dbg_atomic(state->dev, "Added [CRTC:%d:%s] %p state to %p\n",
 		       crtc->base.id, crtc->name, crtc_state, state);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index df03637ca25abd45e96b5944229297f776fd046d..cb9eda6335e0d6728d99d67cc6916ad2d0e1d94e 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -282,6 +282,14 @@ struct drm_crtc_state {
 	 */
 	struct drm_colorop *color_pipeline;
 
+	/**
+	 * @color_pipeline_enabled:
+	 *
+	 * Whether color management should be done based on the &color_pipeline
+	 * or the legacy color properties (&ctm, &gamma_lut and &degamma_lut).
+	 */
+	bool color_pipeline_enabled;
+
 	/**
 	 * @target_vblank:
 	 *

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 13/20] drm/mediatek: Support post-blend colorops for gamma and ctm
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (11 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 12/20] drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-18  0:43 ` [PATCH RFC v2 14/20] drm/mediatek: ccorr: Support post-blend color pipeline API Nícolas F. R. A. Prado
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Allow configuring the gamma and ccorr blocks through the post-blend
color pipeline API instead of the GAMMA_LUT and CTM properties.

In order to achieve this, initialize the color pipeline property and
colorops on the CRTC based on the DDP components available in the CRTC
path. Then introduce a struct mtk_drm_colorop that extends drm_colorop
and tracks the mtk_ddp_comp that implements it in hardware, and include
new ddp_comp helper functions for setting gamma and ctm through the new
API. These helpers will then be called during commit flush for every
updated colorop if the DRM client supports the post-blend color pipeline
API.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/mediatek/mtk_crtc.c     | 208 +++++++++++++++++++++++++++++++-
 drivers/gpu/drm/mediatek/mtk_ddp_comp.h |   2 +
 2 files changed, 205 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c b/drivers/gpu/drm/mediatek/mtk_crtc.c
index bc7527542fdc6fb89fc36794cee7d6dc26f7dcce..9ab2c2b77392839a1b03d6cb01670bf252bf68a5 100644
--- a/drivers/gpu/drm/mediatek/mtk_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
@@ -82,6 +82,12 @@ struct mtk_crtc_state {
 	unsigned int			pending_vrefresh;
 };
 
+struct mtk_drm_colorop {
+	struct drm_colorop colorop;
+	struct mtk_ddp_comp *comp;
+	uint32_t data_id;
+};
+
 static inline struct mtk_crtc *to_mtk_crtc(struct drm_crtc *c)
 {
 	return container_of(c, struct mtk_crtc, base);
@@ -92,6 +98,11 @@ static inline struct mtk_crtc_state *to_mtk_crtc_state(struct drm_crtc_state *s)
 	return container_of(s, struct mtk_crtc_state, base);
 }
 
+static inline struct mtk_drm_colorop *to_mtk_colorop(struct drm_colorop *colorop)
+{
+	return container_of(colorop, struct mtk_drm_colorop, colorop);
+}
+
 static void mtk_crtc_finish_page_flip(struct mtk_crtc *mtk_crtc)
 {
 	struct drm_crtc *crtc = &mtk_crtc->base;
@@ -125,6 +136,19 @@ static void mtk_drm_finish_page_flip(struct mtk_crtc *mtk_crtc)
 	spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
 }
 
+static void mtk_drm_colorop_pipeline_destroy(struct drm_device *dev)
+{
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_colorop *colorop, *next;
+	struct mtk_drm_colorop *mtk_colorop;
+
+	list_for_each_entry_safe(colorop, next, &config->colorop_list, head) {
+		drm_colorop_cleanup(colorop);
+		mtk_colorop = to_mtk_colorop(colorop);
+		kfree(mtk_colorop);
+	}
+}
+
 static void mtk_crtc_destroy(struct drm_crtc *crtc)
 {
 	struct mtk_crtc *mtk_crtc = to_mtk_crtc(crtc);
@@ -146,6 +170,8 @@ static void mtk_crtc_destroy(struct drm_crtc *crtc)
 		mtk_ddp_comp_unregister_vblank_cb(comp);
 	}
 
+	mtk_drm_colorop_pipeline_destroy(crtc->dev);
+
 	drm_crtc_cleanup(crtc);
 }
 
@@ -854,20 +880,103 @@ static void mtk_crtc_atomic_begin(struct drm_crtc *crtc,
 	}
 }
 
+static bool colorop_data_update_flush_status(struct drm_colorop_state *colorop_state)
+{
+	struct drm_colorop *colorop = colorop_state->colorop;
+	struct mtk_drm_colorop *mtk_colorop = to_mtk_colorop(colorop);
+	struct drm_property_blob *data_blob = colorop_state->data;
+	uint32_t data_id = colorop_state->bypass ? 0 : data_blob->base.id;
+	bool needs_flush = mtk_colorop->data_id != data_id;
+
+	mtk_colorop->data_id = data_id;
+
+	return needs_flush;
+}
+
+static void mtk_crtc_ddp_comp_apply_colorop(struct drm_colorop_state *colorop_state)
+{
+	struct drm_colorop *colorop = colorop_state->colorop;
+	struct mtk_drm_colorop *mtk_colorop = to_mtk_colorop(colorop);
+	struct drm_property_blob *data_blob = colorop_state->data;
+	struct mtk_ddp_comp *ddp_comp = mtk_colorop->comp;
+	struct drm_color_ctm_3x4 *ctm = NULL;
+	struct drm_color_lut32 *lut = NULL;
+
+	switch (colorop->type) {
+	case DRM_COLOROP_1D_LUT:
+		if (!colorop_data_update_flush_status(colorop_state))
+			return;
+
+		if (!colorop_state->bypass)
+			lut = (struct drm_color_lut32 *)data_blob->data;
+
+		ddp_comp->funcs->gamma_set_color_pipeline(ddp_comp->dev, lut);
+		break;
+	case DRM_COLOROP_CTM_3X4:
+		if (!colorop_data_update_flush_status(colorop_state))
+			return;
+
+		if (!colorop_state->bypass)
+			ctm = (struct drm_color_ctm_3x4 *)data_blob->data;
+
+		ddp_comp->funcs->ctm_set_color_pipeline(ddp_comp->dev, ctm);
+		break;
+	default:
+		/* If this happens the driver is broken */
+		drm_WARN(colorop->dev, 1,
+			 "Trying to atomic flush COLOROP of type unsupported by driver: %d\n",
+			 colorop->type);
+		break;
+	}
+}
+
 static void mtk_crtc_atomic_flush(struct drm_crtc *crtc,
 				  struct drm_atomic_state *state)
 {
 	struct mtk_crtc *mtk_crtc = to_mtk_crtc(crtc);
+	struct drm_colorop_state *new_colorop_state;
+	struct drm_colorop *colorop;
 	int i;
 
-	if (crtc->state->color_mgmt_changed)
-		for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
-			mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
-			mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state);
-		}
+	if (state->post_blend_color_pipeline) {
+		for_each_new_colorop_in_state(state, colorop, new_colorop_state, i)
+			mtk_crtc_ddp_comp_apply_colorop(new_colorop_state);
+	} else {
+		if (crtc->state->color_mgmt_changed)
+			for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
+				mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
+				mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state);
+			}
+	}
 	mtk_crtc_update_config(mtk_crtc, !!mtk_crtc->event);
 }
 
+static int mtk_crtc_atomic_check(struct drm_crtc *crtc,
+				 struct drm_atomic_state *state)
+{
+	struct drm_colorop_state *new_colorop_state;
+	struct drm_colorop *colorop;
+	int i;
+
+	for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
+		switch (colorop->type) {
+		case DRM_COLOROP_1D_LUT:
+		case DRM_COLOROP_CTM_3X4:
+			if (!new_colorop_state->bypass && !new_colorop_state->data) {
+				drm_dbg_atomic(crtc->dev,
+					       "Missing required DATA property for COLOROP:%d\n",
+					       colorop->base.id);
+				return -EINVAL;
+			}
+			break;
+		default:
+			break;
+		}
+	}
+
+	return 0;
+}
+
 static const struct drm_crtc_funcs mtk_crtc_funcs = {
 	.set_config		= drm_atomic_helper_set_config,
 	.page_flip		= drm_atomic_helper_page_flip,
@@ -885,6 +994,7 @@ static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
 	.mode_valid	= mtk_crtc_mode_valid,
 	.atomic_begin	= mtk_crtc_atomic_begin,
 	.atomic_flush	= mtk_crtc_atomic_flush,
+	.atomic_check   = mtk_crtc_atomic_check,
 	.atomic_enable	= mtk_crtc_atomic_enable,
 	.atomic_disable	= mtk_crtc_atomic_disable,
 };
@@ -987,6 +1097,92 @@ struct device *mtk_crtc_dma_dev_get(struct drm_crtc *crtc)
 	return mtk_crtc->dma_dev;
 }
 
+#define MAX_COLOR_PIPELINE_OPS 2
+#define MAX_COLOR_PIPELINES 1
+
+static int mtk_colorop_init(struct mtk_crtc *mtk_crtc,
+			    struct mtk_drm_colorop *mtk_colorop,
+			    struct mtk_ddp_comp *ddp_comp)
+{
+	struct drm_colorop *colorop = &mtk_colorop->colorop;
+	int ret = 0;
+
+	if (ddp_comp->funcs->gamma_set_color_pipeline) {
+		unsigned int lut_sz = mtk_ddp_gamma_get_lut_size(ddp_comp);
+
+		ret = drm_crtc_colorop_curve_1d_lut_init(mtk_crtc->base.dev, colorop,
+							 &mtk_crtc->base,
+							 lut_sz,
+							 DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
+							 DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	} else if (ddp_comp->funcs->ctm_set_color_pipeline) {
+		ret = drm_crtc_colorop_ctm_3x4_init(mtk_crtc->base.dev,
+						    colorop,
+						    &mtk_crtc->base,
+						    DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	}
+
+	mtk_colorop->comp = ddp_comp;
+
+	return ret;
+}
+
+static int mtk_crtc_init_post_blend_color_pipeline(struct mtk_crtc *mtk_crtc,
+						   unsigned int gamma_lut_size)
+{
+	struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES];
+	struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
+	struct mtk_drm_colorop *mtk_colorop;
+	unsigned int num_pipelines = 0;
+	unsigned int op_idx = 0;
+	int ret;
+
+	memset(ops, 0, sizeof(ops));
+
+	for (unsigned int i = 0;
+	     i < mtk_crtc->ddp_comp_nr && op_idx < MAX_COLOR_PIPELINE_OPS;
+	     i++) {
+		struct mtk_ddp_comp *ddp_comp = mtk_crtc->ddp_comp[i];
+
+		if (!(ddp_comp->funcs->gamma_set_color_pipeline ||
+		      ddp_comp->funcs->ctm_set_color_pipeline))
+			continue;
+
+		mtk_colorop = kzalloc(sizeof(struct mtk_drm_colorop), GFP_KERNEL);
+		if (!mtk_colorop) {
+			ret = -ENOMEM;
+			goto cleanup;
+		}
+
+		ops[op_idx] = &mtk_colorop->colorop;
+
+		ret = mtk_colorop_init(mtk_crtc, mtk_colorop, ddp_comp);
+		if (ret)
+			goto cleanup;
+
+		if (op_idx > 0)
+			drm_colorop_set_next_property(ops[op_idx-1], ops[op_idx]);
+
+		op_idx++;
+	}
+
+	if (op_idx > 0) {
+		pipelines[0].type = ops[0]->base.id;
+		pipelines[0].name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
+		num_pipelines = 1;
+	}
+
+	/* Create COLOR_PIPELINE property and attach */
+	drm_crtc_create_color_pipeline_property(&mtk_crtc->base, pipelines, num_pipelines);
+
+	return 0;
+
+cleanup:
+	mtk_drm_colorop_pipeline_destroy(mtk_crtc->base.dev);
+
+	return ret;
+}
+
 int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,
 		    unsigned int path_len, int priv_data_index,
 		    const struct mtk_drm_route *conn_routes,
@@ -1103,6 +1299,8 @@ int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,
 	if (ret < 0)
 		return ret;
 
+	mtk_crtc_init_post_blend_color_pipeline(mtk_crtc, gamma_lut_size);
+
 	if (gamma_lut_size)
 		drm_mode_crtc_set_gamma_size(&mtk_crtc->base, gamma_lut_size);
 	drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, has_ctm, gamma_lut_size);
diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_ddp_comp.h
index 7289b3dcf22f22f344016beee0c7c144cf7b93c8..554c3cc8ad7b266b8b8eee74ceb8f7383fe2f8df 100644
--- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.h
+++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.h
@@ -75,10 +75,12 @@ struct mtk_ddp_comp_funcs {
 	unsigned int (*gamma_get_lut_size)(struct device *dev);
 	void (*gamma_set)(struct device *dev,
 			  struct drm_crtc_state *state);
+	void (*gamma_set_color_pipeline)(struct device *dev, struct drm_color_lut32 *lut);
 	void (*bgclr_in_on)(struct device *dev);
 	void (*bgclr_in_off)(struct device *dev);
 	void (*ctm_set)(struct device *dev,
 			struct drm_crtc_state *state);
+	void (*ctm_set_color_pipeline)(struct device *dev, struct drm_color_ctm_3x4 *ctm);
 	struct device * (*dma_dev_get)(struct device *dev);
 	u32 (*get_blend_modes)(struct device *dev);
 	const u32 *(*get_formats)(struct device *dev);

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 14/20] drm/mediatek: ccorr: Support post-blend color pipeline API
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (12 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 13/20] drm/mediatek: Support post-blend colorops for gamma and ctm Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-18  0:43 ` [PATCH RFC v2 15/20] drm/mediatek: gamma: " Nícolas F. R. A. Prado
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Implement the ctm_set_color_pipeline DDP component function to allow
configuring the CTM through the color pipeline API.

The color pipeline API only defines a 3x4 matrix, while the driver
currently only supports setting the coefficients for a 3x3 matrix.
However the underlying hardware does support setting the offset
coefficients that make up a 3x4 matrix, so implement support for setting
them so the 3x4 matrix structure for the API can be used as is.

Also make sure to enable or disable the CTM function depending on
whether the block should be bypassed or not.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/mediatek/mtk_ddp_comp.c   |   3 +-
 drivers/gpu/drm/mediatek/mtk_disp_ccorr.c | 100 ++++++++++++++++++++++++++----
 drivers/gpu/drm/mediatek/mtk_disp_drv.h   |   3 +-
 3 files changed, 93 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
index ac6620e10262e3b9a4a82093f13c3101f79520de..c873b527423f51733058cbc3d0ad2a719e26bfe1 100644
--- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
@@ -284,7 +284,8 @@ static const struct mtk_ddp_comp_funcs ddp_ccorr = {
 	.config = mtk_ccorr_config,
 	.start = mtk_ccorr_start,
 	.stop = mtk_ccorr_stop,
-	.ctm_set = mtk_ccorr_ctm_set,
+	.ctm_set = mtk_ccorr_ctm_set_legacy,
+	.ctm_set_color_pipeline = mtk_ccorr_ctm_set_color_pipeline,
 };
 
 static const struct mtk_ddp_comp_funcs ddp_color = {
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c b/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
index 10d60d2c2a568ebbe09f90e8f42a73e4c2366662..f69a7d8b97f741f0c5461e8cd6f38f70b0690e7e 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c
@@ -28,6 +28,11 @@
 #define DISP_CCORR_COEF_2			0x0088
 #define DISP_CCORR_COEF_3			0x008C
 #define DISP_CCORR_COEF_4			0x0090
+#define DISP_CCORR_OFFSET_0			0x0100
+#define CCORR_OFFSET_EN					BIT(31)
+#define DISP_CCORR_OFFSET_1			0x0104
+#define DISP_CCORR_OFFSET_2			0x0108
+#define DISP_CCORR_OFFSET_MASK				GENMASK(26, 14)
 
 struct mtk_disp_ccorr_data {
 	u32 matrix_bits;
@@ -101,25 +106,48 @@ static u16 mtk_ctm_s31_32_to_s1_n(u64 in, u32 n)
 	return r;
 }
 
-void mtk_ccorr_ctm_set(struct device *dev, struct drm_crtc_state *state)
+static void mtk_ccorr_ctm_set(struct device *dev, struct cmdq_pkt *cmdq_pkt,
+			      void *ctm, bool ctm_3x4)
 {
 	struct mtk_disp_ccorr *ccorr = dev_get_drvdata(dev);
-	struct drm_property_blob *blob = state->ctm;
-	struct drm_color_ctm *ctm;
-	const u64 *input;
+	u64 coeffs_in[9];
+	u64 coeffs_offset_in[3];
 	uint16_t coeffs[9] = { 0 };
+	uint16_t coeffs_offset[3];
 	int i;
-	struct cmdq_pkt *cmdq_pkt = NULL;
 	u32 matrix_bits = ccorr->data->matrix_bits;
+	u32 val;
+
+	if (ctm_3x4) {
+		struct drm_color_ctm_3x4 *ctm_3x4 = (struct drm_color_ctm_3x4 *)ctm;
+
+		coeffs_in[0] = ctm_3x4->matrix[0];
+		coeffs_in[1] = ctm_3x4->matrix[1];
+		coeffs_in[2] = ctm_3x4->matrix[2];
+		coeffs_in[3] = ctm_3x4->matrix[4];
+		coeffs_in[4] = ctm_3x4->matrix[5];
+		coeffs_in[5] = ctm_3x4->matrix[6];
+		coeffs_in[6] = ctm_3x4->matrix[8];
+		coeffs_in[7] = ctm_3x4->matrix[9];
+		coeffs_in[8] = ctm_3x4->matrix[10];
+
+		coeffs_offset_in[0] = ctm_3x4->matrix[3];
+		coeffs_offset_in[1] = ctm_3x4->matrix[7];
+		coeffs_offset_in[2] = ctm_3x4->matrix[11];
+	} else {
+		struct drm_color_ctm *ctm_3x3 = (struct drm_color_ctm *)ctm;
 
-	if (!blob)
-		return;
-
-	ctm = (struct drm_color_ctm *)blob->data;
-	input = ctm->matrix;
+		for (i = 0; i < ARRAY_SIZE(coeffs_in); i++)
+			coeffs_in[i] = ctm_3x3->matrix[i];
+	}
 
 	for (i = 0; i < ARRAY_SIZE(coeffs); i++)
-		coeffs[i] = mtk_ctm_s31_32_to_s1_n(input[i], matrix_bits);
+		coeffs[i] = mtk_ctm_s31_32_to_s1_n(coeffs_in[i], matrix_bits);
+
+	if (ctm_3x4) {
+		for (i = 0; i < ARRAY_SIZE(coeffs_offset); i++)
+			coeffs_offset[i] = mtk_ctm_s31_32_to_s1_n(coeffs_offset_in[i], matrix_bits);
+	}
 
 	mtk_ddp_write(cmdq_pkt, coeffs[0] << 16 | coeffs[1],
 		      &ccorr->cmdq_reg, ccorr->regs, DISP_CCORR_COEF_0);
@@ -131,6 +159,56 @@ void mtk_ccorr_ctm_set(struct device *dev, struct drm_crtc_state *state)
 		      &ccorr->cmdq_reg, ccorr->regs, DISP_CCORR_COEF_3);
 	mtk_ddp_write(cmdq_pkt, coeffs[8] << 16,
 		      &ccorr->cmdq_reg, ccorr->regs, DISP_CCORR_COEF_4);
+
+	if (ctm_3x4) {
+		val = CCORR_OFFSET_EN;
+		val |= FIELD_PREP(DISP_CCORR_OFFSET_MASK, coeffs_offset[0]);
+		mtk_ddp_write(cmdq_pkt, val, &ccorr->cmdq_reg,
+			      ccorr->regs, DISP_CCORR_OFFSET_0);
+		val = FIELD_PREP(DISP_CCORR_OFFSET_MASK, coeffs_offset[1]);
+		mtk_ddp_write(cmdq_pkt, val, &ccorr->cmdq_reg,
+			      ccorr->regs, DISP_CCORR_OFFSET_1);
+		val = FIELD_PREP(DISP_CCORR_OFFSET_MASK, coeffs_offset[2]);
+		mtk_ddp_write(cmdq_pkt, val, &ccorr->cmdq_reg,
+			      ccorr->regs, DISP_CCORR_OFFSET_2);
+	} else {
+		mtk_ddp_write_mask(cmdq_pkt, 0, &ccorr->cmdq_reg,
+				   ccorr->regs, DISP_CCORR_OFFSET_0,
+				   CCORR_OFFSET_EN);
+	}
+
+	mtk_ddp_write(cmdq_pkt, CCORR_ENGINE_EN, &ccorr->cmdq_reg,
+		      ccorr->regs, DISP_CCORR_CFG);
+}
+
+void mtk_ccorr_ctm_set_legacy(struct device *dev, struct drm_crtc_state *state)
+{
+	struct drm_property_blob *blob = state->ctm;
+	struct cmdq_pkt *cmdq_pkt = NULL;
+	struct drm_color_ctm *ctm;
+
+	if (!blob)
+		return;
+
+	ctm = (struct drm_color_ctm *)blob->data;
+
+	mtk_ccorr_ctm_set(dev, cmdq_pkt, ctm, false);
+}
+
+void mtk_ccorr_ctm_set_color_pipeline(struct device *dev, struct drm_color_ctm_3x4 *ctm)
+{
+	struct mtk_disp_ccorr *ccorr = dev_get_drvdata(dev);
+	struct cmdq_pkt *cmdq_pkt = NULL;
+
+	/* Configure block to be bypassed */
+	if (!ctm) {
+		mtk_ddp_write_mask(cmdq_pkt, CCORR_RELAY_MODE, &ccorr->cmdq_reg,
+				   ccorr->regs, DISP_CCORR_CFG,
+				   CCORR_RELAY_MODE | CCORR_ENGINE_EN);
+		return;
+	}
+
+	mtk_ccorr_ctm_set(dev, cmdq_pkt, ctm, true);
 }
 
 static int mtk_disp_ccorr_bind(struct device *dev, struct device *master,
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
index 679d413bf10be1e2fc4804a60a3fbe5d734614f6..ac84cf579150fd0535c79f43ad5942f8d412d450 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
@@ -22,7 +22,8 @@ void mtk_aal_gamma_set(struct device *dev, struct drm_crtc_state *state);
 void mtk_aal_start(struct device *dev);
 void mtk_aal_stop(struct device *dev);
 
-void mtk_ccorr_ctm_set(struct device *dev, struct drm_crtc_state *state);
+void mtk_ccorr_ctm_set_legacy(struct device *dev, struct drm_crtc_state *state);
+void mtk_ccorr_ctm_set_color_pipeline(struct device *dev, struct drm_color_ctm_3x4 *ctm);
 int mtk_ccorr_clk_enable(struct device *dev);
 void mtk_ccorr_clk_disable(struct device *dev);
 void mtk_ccorr_config(struct device *dev, unsigned int w,

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 15/20] drm/mediatek: gamma: Support post-blend color pipeline API
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (13 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 14/20] drm/mediatek: ccorr: Support post-blend color pipeline API Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-18  0:43 ` [PATCH RFC v2 16/20] drm/mediatek: Set post-blend color pipeline driver cap Nícolas F. R. A. Prado
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Implement the gamma_set_color_pipeline DDP component function to allow
configuring the gamma LUT through the post-blend color pipeline API.

The color pipeline API uses a 32-bit long, rather than 16-bit long, LUT,
so also update the functions to handle both cases.

Also make sure to enable or disable the LUT function depending on
whether the block should be bypassed or not.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/mediatek/mtk_ddp_comp.c   |   3 +-
 drivers/gpu/drm/mediatek/mtk_disp_drv.h   |   3 +-
 drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 107 +++++++++++++++++++++++++-----
 3 files changed, 94 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
index c873b527423f51733058cbc3d0ad2a719e26bfe1..d253906546506ecf1f1e2a23123b80e774e981ae 100644
--- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
@@ -327,7 +327,8 @@ static const struct mtk_ddp_comp_funcs ddp_gamma = {
 	.clk_enable = mtk_gamma_clk_enable,
 	.clk_disable = mtk_gamma_clk_disable,
 	.gamma_get_lut_size = mtk_gamma_get_lut_size,
-	.gamma_set = mtk_gamma_set,
+	.gamma_set = mtk_gamma_set_legacy,
+	.gamma_set_color_pipeline = mtk_gamma_set_color_pipeline,
 	.config = mtk_gamma_config,
 	.start = mtk_gamma_start,
 	.stop = mtk_gamma_stop,
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
index ac84cf579150fd0535c79f43ad5942f8d412d450..7795aa5bc057fc09597cbd582f04e4dc76d3ecba 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
@@ -58,7 +58,8 @@ void mtk_gamma_config(struct device *dev, unsigned int w,
 		      unsigned int h, unsigned int vrefresh,
 		      unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
 unsigned int mtk_gamma_get_lut_size(struct device *dev);
-void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state);
+void mtk_gamma_set_legacy(struct device *dev, struct drm_crtc_state *state);
+void mtk_gamma_set_color_pipeline(struct device *dev, struct drm_color_lut32 *lut);
 void mtk_gamma_start(struct device *dev);
 void mtk_gamma_stop(struct device *dev);
 
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
index 8afd15006df2a21f3f52fe00eca3c5501f4fb76a..dec9eeb53cb8539e49ecc1087e037645c792ee3d 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
@@ -87,13 +87,34 @@ unsigned int mtk_gamma_get_lut_size(struct device *dev)
 	return 0;
 }
 
-static bool mtk_gamma_lut_is_descending(struct drm_color_lut *lut, u32 lut_size)
+static bool mtk_gamma_lut_is_descending(void *lut, bool bits32, u32 lut_size)
 {
 	u64 first, last;
 	int last_entry = lut_size - 1;
+	u32 lutr_first, lutg_first, lutb_first, lutr_last, lutg_last, lutb_last;
+	struct drm_color_lut32 *lut32;
+	struct drm_color_lut *lut16;
+
+	if (bits32) {
+		lut32 = (struct drm_color_lut32 *)lut;
+		lutr_first = lut32[0].red;
+		lutg_first = lut32[0].green;
+		lutb_first = lut32[0].blue;
+		lutr_last = lut32[last_entry].red;
+		lutg_last = lut32[last_entry].green;
+		lutb_last = lut32[last_entry].blue;
+	} else {
+		lut16 = (struct drm_color_lut *)lut;
+		lutr_first = lut16[0].red;
+		lutg_first = lut16[0].green;
+		lutb_first = lut16[0].blue;
+		lutr_last = lut16[last_entry].red;
+		lutg_last = lut16[last_entry].green;
+		lutb_last = lut16[last_entry].blue;
+	}
 
-	first = lut[0].red + lut[0].green + lut[0].blue;
-	last = lut[last_entry].red + lut[last_entry].green + lut[last_entry].blue;
+	first = lutr_first + lutg_first + lutb_first;
+	last = lutr_last + lutg_last + lutb_last;
 
 	return !!(first > last);
 }
@@ -113,7 +134,7 @@ static bool mtk_gamma_lut_is_descending(struct drm_color_lut *lut, u32 lut_size)
  *     - 12-bits LUT supported
  *     - 10-its LUT not supported
  */
-void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
+static void mtk_gamma_set(struct device *dev, void *lut, bool bits32)
 {
 	struct mtk_disp_gamma *gamma = dev_get_drvdata(dev);
 	void __iomem *lut0_base = gamma->regs + DISP_GAMMA_LUT;
@@ -121,19 +142,20 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
 	u32 cfg_val, data_mode, lbank_val, word[2];
 	u8 lut_bits = gamma->data->lut_bits;
 	int cur_bank, num_lut_banks;
-	struct drm_color_lut *lut;
 	unsigned int i;
-
-	/* If there's no gamma lut there's nothing to do here. */
-	if (!state->gamma_lut)
-		return;
+	struct drm_color_lut32 *lut32;
+	struct drm_color_lut *lut16;
 
 	num_lut_banks = gamma->data->lut_size / gamma->data->lut_bank_size;
-	lut = (struct drm_color_lut *)state->gamma_lut->data;
 
 	/* Switch to 12 bits data mode if supported */
 	data_mode = FIELD_PREP(DISP_GAMMA_BANK_DATA_MODE, !!(lut_bits == 12));
 
+	if (bits32)
+		lut32 = (struct drm_color_lut32 *)lut;
+	else
+		lut16 = (struct drm_color_lut *)lut;
+
 	for (cur_bank = 0; cur_bank < num_lut_banks; cur_bank++) {
 
 		/* Switch gamma bank and set data mode before writing LUT */
@@ -146,10 +168,21 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
 		for (i = 0; i < gamma->data->lut_bank_size; i++) {
 			int n = cur_bank * gamma->data->lut_bank_size + i;
 			struct drm_color_lut diff, hwlut;
+			u32 lutr, lutg, lutb;
+
+			if (bits32) {
+				lutr = lut32[n].red;
+				lutg = lut32[n].green;
+				lutb = lut32[n].blue;
+			} else {
+				lutr = lut16[n].red;
+				lutg = lut16[n].green;
+				lutb = lut16[n].blue;
+			}
 
-			hwlut.red = drm_color_lut_extract(lut[n].red, lut_bits);
-			hwlut.green = drm_color_lut_extract(lut[n].green, lut_bits);
-			hwlut.blue = drm_color_lut_extract(lut[n].blue, lut_bits);
+			hwlut.red = drm_color_lut_extract(lutr, lut_bits);
+			hwlut.green = drm_color_lut_extract(lutg, lut_bits);
+			hwlut.blue = drm_color_lut_extract(lutb, lut_bits);
 
 			if (!gamma->data->lut_diff || (i % 2 == 0)) {
 				if (lut_bits == 12) {
@@ -162,13 +195,25 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
 					word[0] |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, hwlut.blue);
 				}
 			} else {
-				diff.red = lut[n].red - lut[n - 1].red;
+				u32 lutr_prev, lutg_prev, lutb_prev;
+
+				if (bits32) {
+					lutr_prev = lut32[n-1].red;
+					lutg_prev = lut32[n-1].green;
+					lutb_prev = lut32[n-1].blue;
+				} else {
+					lutr_prev = lut16[n-1].red;
+					lutg_prev = lut16[n-1].green;
+					lutb_prev = lut16[n-1].blue;
+				}
+
+				diff.red = lutr - lutr_prev;
 				diff.red = drm_color_lut_extract(diff.red, lut_bits);
 
-				diff.green = lut[n].green - lut[n - 1].green;
+				diff.green = lutg - lutg_prev;
 				diff.green = drm_color_lut_extract(diff.green, lut_bits);
 
-				diff.blue = lut[n].blue - lut[n - 1].blue;
+				diff.blue = lutb - lutb_prev;
 				diff.blue = drm_color_lut_extract(diff.blue, lut_bits);
 
 				if (lut_bits == 12) {
@@ -191,7 +236,7 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
 
 	if (!gamma->data->has_dither) {
 		/* Descending or Rising LUT */
-		if (mtk_gamma_lut_is_descending(lut, gamma->data->lut_size - 1))
+		if (mtk_gamma_lut_is_descending(lut, bits32, gamma->data->lut_size - 1))
 			cfg_val |= FIELD_PREP(GAMMA_LUT_TYPE, 1);
 		else
 			cfg_val &= ~GAMMA_LUT_TYPE;
@@ -206,6 +251,34 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
 	writel(cfg_val, gamma->regs + DISP_GAMMA_CFG);
 }
 
+void mtk_gamma_set_legacy(struct device *dev, struct drm_crtc_state *state)
+{
+	struct drm_color_lut *lut = (struct drm_color_lut *)state->gamma_lut->data;
+
+	/* If there's no gamma lut there's nothing to do here. */
+	if (!state->gamma_lut)
+		return;
+
+	mtk_gamma_set(dev, lut, false);
+}
+
+void mtk_gamma_set_color_pipeline(struct device *dev, struct drm_color_lut32 *lut)
+{
+	struct mtk_disp_gamma *gamma = dev_get_drvdata(dev);
+	u32 cfg_val;
+
+	/* Configure block to be bypassed */
+	if (!lut) {
+		cfg_val = readl(gamma->regs + DISP_GAMMA_CFG);
+		cfg_val &= ~GAMMA_LUT_EN;
+		cfg_val |= GAMMA_RELAY_MODE;
+		writel(cfg_val, gamma->regs + DISP_GAMMA_CFG);
+		return;
+	}
+
+	mtk_gamma_set(dev, lut, true);
+}
+
 void mtk_gamma_config(struct device *dev, unsigned int w,
 		      unsigned int h, unsigned int vrefresh,
 		      unsigned int bpc, struct cmdq_pkt *cmdq_pkt)

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 16/20] drm/mediatek: Set post-blend color pipeline driver cap
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (14 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 15/20] drm/mediatek: gamma: " Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:50   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 17/20] drm/vkms: Rename existing color pipeline helpers to contain "pre_blend" Nícolas F. R. A. Prado
                   ` (5 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Now that the driver implements post-blend color pipelines, set the
driver cap so they can be used from userspace.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index d5e6bab364143540e1f59df481b9a9d559c39199..73c0f448d7fcf25e473e2c3c6ddaaf28446570cf 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -611,7 +611,8 @@ static struct drm_gem_object *mtk_gem_prime_import(struct drm_device *dev,
 }
 
 static const struct drm_driver mtk_drm_driver = {
-	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
+	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC |
+			   DRIVER_POST_BLEND_COLOR_PIPELINE,
 
 	.dumb_create = mtk_gem_dumb_create,
 	DRM_FBDEV_DMA_DRIVER_OPS,

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 17/20] drm/vkms: Rename existing color pipeline helpers to contain "pre_blend"
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (15 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 16/20] drm/mediatek: Set post-blend color pipeline driver cap Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:45   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 18/20] drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines Nícolas F. R. A. Prado
                   ` (4 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Rename the existing color pipeline helpers so they contain "pre_blend"
in the name to make them clearly distinguishable from the post-blend
helpers when they're introduced.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/vkms/vkms_colorop.c | 8 +++++---
 drivers/gpu/drm/vkms/vkms_drv.h     | 2 +-
 drivers/gpu/drm/vkms/vkms_plane.c   | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c
index 0191ac44dec0a9513e001b304f6ead32a96cdb8c..5924ae2bd40fc904048f99bc9b96308140709e25 100644
--- a/drivers/gpu/drm/vkms/vkms_colorop.c
+++ b/drivers/gpu/drm/vkms/vkms_colorop.c
@@ -14,7 +14,9 @@ static const u64 supported_tfs =
 
 #define MAX_COLOR_PIPELINE_OPS 4
 
-static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
+static int
+vkms_initialize_pre_blend_color_pipeline(struct drm_plane *plane,
+					 struct drm_prop_enum_list *list)
 {
 	struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
 	struct drm_device *dev = plane->dev;
@@ -96,13 +98,13 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
 	return ret;
 }
 
-int vkms_initialize_colorops(struct drm_plane *plane)
+int vkms_initialize_pre_blend_colorops(struct drm_plane *plane)
 {
 	struct drm_prop_enum_list pipeline;
 	int ret;
 
 	/* Add color pipeline */
-	ret = vkms_initialize_color_pipeline(plane, &pipeline);
+	ret = vkms_initialize_pre_blend_color_pipeline(plane, &pipeline);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
index 55440ec6db5209741af1443d4e49e9471e6795c9..37ee569474223b2cf01e3cc0e4f119777533ae23 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.h
+++ b/drivers/gpu/drm/vkms/vkms_drv.h
@@ -305,6 +305,6 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer
 int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, struct vkms_output *vkms_out);
 
 /* Colorops */
-int vkms_initialize_colorops(struct drm_plane *plane);
+int vkms_initialize_pre_blend_colorops(struct drm_plane *plane);
 
 #endif /* _VKMS_DRV_H_ */
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index db8d26810afa8d8fcab48a6db2e691255f26a8a6..8e63a07a7e1b0a350361d0b03b7911bfa9ce3dcc 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -232,7 +232,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
 					  DRM_COLOR_YCBCR_BT601,
 					  DRM_COLOR_YCBCR_FULL_RANGE);
 
-	vkms_initialize_colorops(&plane->base);
+	vkms_initialize_pre_blend_colorops(&plane->base);
 
 	return plane;
 }

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 18/20] drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (16 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 17/20] drm/vkms: Rename existing color pipeline helpers to contain "pre_blend" Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:48   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 19/20] drm/vkms: Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (3 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

As a preparatory step for supporting post-blend color pipelines in VKMS,
rename pre_blend_color_transform() to color_transform() and make it take
the first colorop instead of a plane state, so it can be shared by both
pre- and post-blend color pipeline code paths.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/vkms/vkms_composer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 31b1dd3cd115d930ec3ed498403a8f44208d76c3..05e1551d6330e4dc14563d3a399b3544d11c6576 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -189,13 +189,13 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo
 	}
 }
 
-static void pre_blend_color_transform(const struct vkms_plane_state *plane_state,
-				      struct line_buffer *output_buffer)
+static void color_transform(struct drm_colorop *first_colorop,
+			    struct line_buffer *output_buffer)
 {
 	struct pixel_argb_s32 pixel;
 
 	for (size_t x = 0; x < output_buffer->n_pixels; x++) {
-		struct drm_colorop *colorop = plane_state->base.base.color_pipeline;
+		struct drm_colorop *colorop = first_colorop;
 
 		/*
 		 * Some operations, such as applying a BT709 encoding matrix,
@@ -449,7 +449,7 @@ static void blend_line(struct vkms_plane_state *current_plane, int y,
 	 */
 	current_plane->pixel_read_line(current_plane, src_x_start, src_y_start, direction,
 				       pixel_count, &stage_buffer->pixels[dst_x_start]);
-	pre_blend_color_transform(current_plane, stage_buffer);
+	color_transform(current_plane->base.base.color_pipeline, stage_buffer);
 	pre_mul_alpha_blend(stage_buffer, output_buffer,
 			    dst_x_start, pixel_count);
 }

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 19/20] drm/vkms: Introduce support for post-blend color pipeline
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (17 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 18/20] drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:50   ` Louis Chauvet
  2025-09-18  0:43 ` [PATCH RFC v2 20/20] drm/vkms: Set post-blend color pipeline driver cap Nícolas F. R. A. Prado
                   ` (2 subsequent siblings)
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Introduce a post-blend color pipeline with the same colorop blocks as
the pre-blend color pipeline.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/vkms/vkms_colorop.c  | 98 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/vkms/vkms_composer.c |  5 +-
 drivers/gpu/drm/vkms/vkms_crtc.c     |  1 +
 drivers/gpu/drm/vkms/vkms_drv.h      |  1 +
 4 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c
index 5924ae2bd40fc904048f99bc9b96308140709e25..54c512db68eef16435d5f79453784f7784d540fb 100644
--- a/drivers/gpu/drm/vkms/vkms_colorop.c
+++ b/drivers/gpu/drm/vkms/vkms_colorop.c
@@ -98,6 +98,86 @@ vkms_initialize_pre_blend_color_pipeline(struct drm_plane *plane,
 	return ret;
 }
 
+static int
+vkms_initialize_post_blend_color_pipeline(struct drm_crtc *crtc,
+					  struct drm_prop_enum_list *list)
+{
+	struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
+	struct drm_device *dev = crtc->dev;
+	int ret;
+	int i = 0;
+
+	memset(ops, 0, sizeof(ops));
+
+	/* 1st op: 1d curve */
+	ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
+	if (!ops[i]) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	ret = drm_crtc_colorop_curve_1d_init(dev, ops[i], crtc, supported_tfs,
+					     DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	if (ret)
+		goto cleanup;
+
+	list->type = ops[i]->base.id;
+	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id);
+
+	i++;
+
+	/* 2nd op: 3x4 matrix */
+	ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
+	if (!ops[i]) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	if (ret)
+		goto cleanup;
+
+	drm_colorop_set_next_property(ops[i - 1], ops[i]);
+
+	i++;
+
+	/* 3rd op: 3x4 matrix */
+	ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
+	if (!ops[i]) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	if (ret)
+		goto cleanup;
+
+	drm_colorop_set_next_property(ops[i - 1], ops[i]);
+
+	i++;
+
+	/* 4th op: 1d curve */
+	ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
+	if (!ops[i]) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	ret = drm_crtc_colorop_curve_1d_init(dev, ops[i], crtc, supported_tfs,
+					     DRM_COLOROP_FLAG_ALLOW_BYPASS);
+	if (ret)
+		goto cleanup;
+
+	drm_colorop_set_next_property(ops[i - 1], ops[i]);
+
+	return 0;
+
+cleanup:
+	drm_colorop_pipeline_destroy(dev);
+
+	return ret;
+}
+
 int vkms_initialize_pre_blend_colorops(struct drm_plane *plane)
 {
 	struct drm_prop_enum_list pipeline;
@@ -115,3 +195,21 @@ int vkms_initialize_pre_blend_colorops(struct drm_plane *plane)
 
 	return 0;
 }
+
+int vkms_initialize_post_blend_colorops(struct drm_crtc *crtc)
+{
+	struct drm_prop_enum_list pipeline;
+	int ret;
+
+	/* Add color pipeline */
+	ret = vkms_initialize_post_blend_color_pipeline(crtc, &pipeline);
+	if (ret)
+		return ret;
+
+	/* Create COLOR_PIPELINE property and attach */
+	ret = drm_crtc_create_color_pipeline_property(crtc, &pipeline, 1);
+	if (ret)
+		return ret;
+
+	return 0;
+}
diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 05e1551d6330e4dc14563d3a399b3544d11c6576..efe09538768b01108a305f0ace765246220b487b 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -495,7 +495,10 @@ static void blend(struct vkms_writeback_job *wb,
 			blend_line(plane[i], y, crtc_x_limit, stage_buffer, output_buffer);
 		}
 
-		apply_lut(crtc_state, output_buffer);
+		if (crtc_state->base.color_pipeline_enabled)
+			color_transform(crtc_state->base.color_pipeline, output_buffer);
+		else
+			apply_lut(crtc_state, output_buffer);
 
 		*crc32 = crc32_le(*crc32, (void *)output_buffer->pixels, row_size);
 
diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index e60573e0f3e9510252e1f198b00e28bcc7987620..04737c1fb70e4f0aef480a180e57a76fbc279dfa 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -295,6 +295,7 @@ struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane *pri
 	}
 
 	drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE);
+	vkms_initialize_post_blend_colorops(crtc);
 
 	spin_lock_init(&vkms_out->lock);
 	spin_lock_init(&vkms_out->composer_lock);
diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
index 37ee569474223b2cf01e3cc0e4f119777533ae23..a0308c2263d1858a72906853960ea7d1bbecd03e 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.h
+++ b/drivers/gpu/drm/vkms/vkms_drv.h
@@ -306,5 +306,6 @@ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, struct vkms_out
 
 /* Colorops */
 int vkms_initialize_pre_blend_colorops(struct drm_plane *plane);
+int vkms_initialize_post_blend_colorops(struct drm_crtc *crtc);
 
 #endif /* _VKMS_DRV_H_ */

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* [PATCH RFC v2 20/20] drm/vkms: Set post-blend color pipeline driver cap
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (18 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 19/20] drm/vkms: Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
@ 2025-09-18  0:43 ` Nícolas F. R. A. Prado
  2025-09-19 12:49   ` Louis Chauvet
  2025-09-29 10:22 ` [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Harry Wentland
  2025-09-29 12:05 ` Melissa Wen
  21 siblings, 1 reply; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-18  0:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah,
	louis.chauvet, mcanal, kernel, daniels, leandro.ribeiro,
	dri-devel, linux-kernel, linux-mediatek, linux-arm-kernel,
	Nícolas F. R. A. Prado, Simona Vetter

Now that the driver implements post-blend color pipelines, set the
driver cap so they can be used from userspace.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/gpu/drm/vkms/vkms_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index e8472d9b6e3b2b5d6d497763288bf3dc6fde5987..4cc67a789d28288575235b7efc87bc5e45d668cc 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -80,7 +80,8 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state)
 }
 
 static const struct drm_driver vkms_driver = {
-	.driver_features	= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM,
+	.driver_features	= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM |
+				  DRIVER_POST_BLEND_COLOR_PIPELINE,
 	.fops			= &vkms_driver_fops,
 	DRM_GEM_SHMEM_DRIVER_OPS,
 	DRM_FBDEV_SHMEM_DRIVER_OPS,

-- 
2.50.1



^ permalink raw reply related	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check
  2025-09-18  0:43 ` [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check Nícolas F. R. A. Prado
@ 2025-09-19 12:41   ` Louis Chauvet
  2025-09-29  9:50   ` Harry Wentland
  1 sibling, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:41 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Pass the state of the post-blend color pipeline client cap to the atomic
> state so that drivers can rely on it to enable color pipeline
> functionality and ignore the deprecated color management CRTC
> properties.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/drm_atomic_uapi.c |  1 +
>   include/drm/drm_atomic.h          | 20 ++++++++++++++++++++
>   2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index f5125fa3fa28ff2a6ff07fd7cf07d4bdf77ab738..56a440a9390c7730c4c41b491f29b933a2bbb889 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -1660,6 +1660,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
>   	state->acquire_ctx = &ctx;
>   	state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
>   	state->plane_color_pipeline = file_priv->plane_color_pipeline;
> +	state->post_blend_color_pipeline = file_priv->post_blend_color_pipeline;
>   
>   retry:
>   	copied_objs = 0;
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 678708df9cdb90b4266127193a92183069f18688..8c42c584aefbf0034b2163d90538e80099b0dadb 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -482,6 +482,26 @@ struct drm_atomic_state {
>   	 */
>   	bool plane_color_pipeline : 1;
>   
> +	/**
> +	 * @post_blend_color_pipeline:
> +	 *
> +	 * Indicates whether this atomic state originated with a client that
> +	 * set the DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE.
> +	 *
> +	 * Drivers and helper functions should use this to ignore legacy
> +	 * properties that are incompatible with the drm_crtc COLOR_PIPELINE
> +	 * behavior, such as:
> +	 *
> +	 *  - GAMMA_LUT
> +	 *  - DEGAMMA_LUT
> +	 *  - GAMMA_LUT_SIZE
> +	 *  - CTM
> +	 *
> +	 * or any other driver-specific properties that might affect pixel
> +	 * values.
> +	 */
> +	bool post_blend_color_pipeline : 1;
> +
>   	/**
>   	 * @colorops:
>   	 *
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
  2025-09-18  0:43 ` [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
@ 2025-09-19 12:42   ` Louis Chauvet
  2025-09-29  9:48   ` Harry Wentland
  1 sibling, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:42 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE which a DRM client
> can set to enable the usage of post-blend color pipelines instead of the
> now deprecated CRTC color management properties: "GAMMA_LUT",
> "DEGAMMA_LUT" and "CTM".
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/drm_atomic_uapi.c   | 15 +++++++++++++++
>   drivers/gpu/drm/drm_connector.c     |  1 +
>   drivers/gpu/drm/drm_crtc_internal.h |  1 +
>   drivers/gpu/drm/drm_ioctl.c         |  9 +++++++++
>   drivers/gpu/drm/drm_mode_object.c   |  9 +++++++++
>   include/drm/drm_file.h              |  7 +++++++
>   include/uapi/drm/drm.h              | 19 +++++++++++++++++++
>   7 files changed, 61 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 063c142fd9b656e228cfc660d005a3fbb4640d32..f5125fa3fa28ff2a6ff07fd7cf07d4bdf77ab738 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -452,6 +452,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
>   	} else if (property == config->prop_vrr_enabled) {
>   		state->vrr_enabled = val;
>   	} else if (property == config->degamma_lut_property) {
> +		if (file_priv->post_blend_color_pipeline) {
> +			drm_dbg_atomic(dev,
> +				"Setting DEGAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
> +			return -EINVAL;
> +		}
>   		ret = drm_property_replace_blob_from_id(dev,
>   					&state->degamma_lut,
>   					val,
> @@ -460,6 +465,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
>   		state->color_mgmt_changed |= replaced;
>   		return ret;
>   	} else if (property == config->ctm_property) {
> +		if (file_priv->post_blend_color_pipeline) {
> +			drm_dbg_atomic(dev,
> +				"Setting CTM CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
> +			return -EINVAL;
> +		}
>   		ret = drm_property_replace_blob_from_id(dev,
>   					&state->ctm,
>   					val,
> @@ -468,6 +478,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
>   		state->color_mgmt_changed |= replaced;
>   		return ret;
>   	} else if (property == config->gamma_lut_property) {
> +		if (file_priv->post_blend_color_pipeline) {
> +			drm_dbg_atomic(dev,
> +				"Setting GAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
> +			return -EINVAL;
> +		}
>   		ret = drm_property_replace_blob_from_id(dev,
>   					&state->gamma_lut,
>   					val,
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 4d6dc9ebfdb5bc730b1aff7a184448af7b93f078..f58cfd2131139ff3e613adc4dbb9ddbedf724dc7 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -3440,6 +3440,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>   	 */
>   	ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
>   			file_priv->plane_color_pipeline,
> +			file_priv->post_blend_color_pipeline,
>   			(uint32_t __user *)(unsigned long)(out_resp->props_ptr),
>   			(uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
>   			&out_resp->count_props);
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index e3dbdcbfa385b940ec0b5476adde6146fe4afde1..c53f154e5392a10c326c844b7321666275f9ac02 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -169,6 +169,7 @@ void drm_mode_object_unregister(struct drm_device *dev,
>   				struct drm_mode_object *object);
>   int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
>   				   bool plane_color_pipeline,
> +				   bool post_blend_color_pipeline,
>   				   uint32_t __user *prop_ptr,
>   				   uint64_t __user *prop_values,
>   				   uint32_t *arg_count_props);
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 01592d10e3465ddceddef94bc417f98d3ec12087..ea9600f5392f520a2b42ba7ef363d2f08ce19812 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -383,6 +383,15 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
>   			return -EINVAL;
>   		file_priv->plane_color_pipeline = req->value;
>   		break;
> +	case DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE:
> +		if (!file_priv->atomic)
> +			return -EINVAL;
> +		if (req->value > 1)
> +			return -EINVAL;
> +		if (!drm_core_check_feature(dev, DRIVER_POST_BLEND_COLOR_PIPELINE))
> +			return -EINVAL;
> +		file_priv->post_blend_color_pipeline = req->value;
> +		break;
>   	default:
>   		return -EINVAL;
>   	}
> diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
> index b45d501b10c868c6d9b7a5a8760eadbd7b372a6a..5e6c3de9456b997985142a68b9cef57771a58bdc 100644
> --- a/drivers/gpu/drm/drm_mode_object.c
> +++ b/drivers/gpu/drm/drm_mode_object.c
> @@ -388,6 +388,7 @@ EXPORT_SYMBOL(drm_object_property_get_default_value);
>   /* helper for getconnector and getproperties ioctls */
>   int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
>   				   bool plane_color_pipeline,
> +				   bool post_blend_color_pipeline,
>   				   uint32_t __user *prop_ptr,
>   				   uint64_t __user *prop_values,
>   				   uint32_t *arg_count_props)
> @@ -416,6 +417,13 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
>   				continue;
>   		}
>   
> +		if (!post_blend_color_pipeline && obj->type == DRM_MODE_OBJECT_CRTC) {
> +			struct drm_crtc *crtc = obj_to_crtc(obj);
> +
> +			if (prop == crtc->color_pipeline_property)
> +				continue;
> +		}
> +
>   		if (*arg_count_props > count) {
>   			ret = __drm_object_property_get_value(obj, prop, &val);
>   			if (ret)
> @@ -475,6 +483,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
>   
>   	ret = drm_mode_object_get_properties(obj, file_priv->atomic,
>   			file_priv->plane_color_pipeline,
> +			file_priv->post_blend_color_pipeline,
>   			(uint32_t __user *)(unsigned long)(arg->props_ptr),
>   			(uint64_t __user *)(unsigned long)(arg->prop_values_ptr),
>   			&arg->count_props);
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index 1a3018e4a537b3341acb50187d47371f6b781b9d..42b9a43baa18079af8ec2ea5b1484b23c497beb0 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -213,6 +213,13 @@ struct drm_file {
>   	 */
>   	bool plane_color_pipeline;
>   
> +	/**
> +	 * @post_blend_color_pipeline:
> +	 *
> +	 * True if client understands post-blend color pipelines
> +	 */
> +	bool post_blend_color_pipeline;
> +
>   	/**
>   	 * @was_master:
>   	 *
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index c6c53e57958e951204154ce41a69696a6876f0e8..f9ac10b3e4876f71005a87dedefa4aed320566f0 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -927,6 +927,25 @@ struct drm_get_cap {
>    */
>   #define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE	7
>   
> +/**
> + * DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
> + *
> + * If set to 1 the DRM core will allow setting the COLOR_PIPELINE
> + * property on a &drm_crtc, as well as drm_colorop properties.
> + *
> + * Setting of these crtc properties will be rejected when this client
> + * cap is set:
> + * - GAMMA_LUT
> + * - DEGAMMA_LUT
> + * - CTM
> + *
> + * The client must enable &DRM_CLIENT_CAP_ATOMIC first.
> + *
> + * This client cap can only be set if the driver sets the corresponding driver
> + * cap &DRM_CAP_POST_BLEND_COLOR_PIPELINE.
> + */
> +#define DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE	8
> +
>   /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
>   struct drm_set_client_cap {
>   	__u64 capability;
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 05/20] drm: Introduce DRM_CAP_POST_BLEND_COLOR_PIPELINE
  2025-09-18  0:43 ` [PATCH RFC v2 05/20] drm: Introduce DRM_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
@ 2025-09-19 12:42   ` Louis Chauvet
  2025-09-29  9:40     ` Harry Wentland
  0 siblings, 1 reply; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:42 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Add a new cap that drivers can set to signal they support post-blend
> color pipelines.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/drm_ioctl.c | 3 +++
>   include/drm/drm_drv.h       | 6 ++++++
>   include/uapi/drm/drm.h      | 6 ++++++
>   3 files changed, 15 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index ff193155129e7e863888d8958458978566b144f8..01592d10e3465ddceddef94bc417f98d3ec12087 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -304,6 +304,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
>   		req->value = drm_core_check_feature(dev, DRIVER_ATOMIC) &&
>   			     dev->mode_config.async_page_flip;
>   		break;
> +	case DRM_CAP_POST_BLEND_COLOR_PIPELINE:
> +		req->value = drm_core_check_feature(dev, DRIVER_POST_BLEND_COLOR_PIPELINE);
> +		break;
>   	default:
>   		return -EINVAL;
>   	}
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index 42fc085f986dee9261f8b08c4fc7d93b8d6d9769..6b0f4904e69766232283d430c2540d30afef850f 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -122,6 +122,12 @@ enum drm_driver_feature {
>   	 * the cursor planes to work correctly).
>   	 */
>   	DRIVER_CURSOR_HOTSPOT           = BIT(9),
> +	/**
> +	 * @DRIVER_POST_BLEND_COLOR_PIPELINE:
> +	 *
> +	 * Driver supports post-blend color pipeline.
> +	 */
> +	DRIVER_POST_BLEND_COLOR_PIPELINE		= BIT(10),
>   
>   	/* IMPORTANT: Below are all the legacy flags, add new ones above. */
>   
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index 27cc159c1d275c7a7fe057840ef792f30a582bb7..c6c53e57958e951204154ce41a69696a6876f0e8 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -812,6 +812,12 @@ struct drm_gem_change_handle {
>    * commits.
>    */
>   #define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP	0x15
> +/**
> + * DRM_CAP_POST_BLEND_COLOR_PIPELINE
> + *
> + * If set to 1, the driver supports post-blend color pipelines.
> + */
> +#define DRM_CAP_POST_BLEND_COLOR_PIPELINE	0x16
>   
>   /* DRM_IOCTL_GET_CAP ioctl argument type */
>   struct drm_get_cap {
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 04/20] drm/crtc: Add COLOR_PIPELINE property
  2025-09-18  0:43 ` [PATCH RFC v2 04/20] drm/crtc: Add COLOR_PIPELINE property Nícolas F. R. A. Prado
@ 2025-09-19 12:43   ` Louis Chauvet
  2025-12-10 21:00     ` Ariel D'Alessandro
  0 siblings, 1 reply; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:43 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Add a COLOR_PIPELINE property to the CRTC to allow userspace to set a
> post-blend color pipeline analogously to how pre-blend color pipelines
> are set on planes.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   drivers/gpu/drm/drm_atomic_uapi.c | 49 +++++++++++++++++++++++++++++++++++----
>   drivers/gpu/drm/drm_crtc.c        | 33 ++++++++++++++++++++++++++
>   include/drm/drm_atomic_uapi.h     |  2 ++
>   include/drm/drm_crtc.h            | 11 +++++++++
>   4 files changed, 91 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index b7cc6945864274bedd21dd5b73494f9aae216888..063c142fd9b656e228cfc660d005a3fbb4640d32 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -287,6 +287,33 @@ drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state,
>   }
>   EXPORT_SYMBOL(drm_atomic_set_colorop_for_plane);
>   
> +/**
> + * drm_atomic_set_colorop_for_crtc - set colorop for crtc
> + * @crtc_state: atomic state object for the crtc
> + * @colorop: colorop to use for the crtc
> + *
> + * Helper function to select the color pipeline on a crtc by setting
> + * it to the first drm_colorop element of the pipeline.
> + */
> +void
> +drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
> +				 struct drm_colorop *colorop)
> +{
> +	struct drm_crtc *crtc = crtc_state->crtc;
> +
> +	if (colorop)
> +		drm_dbg_atomic(crtc->dev,
> +			       "Set [COLOROP:%d] for [CRTC:%d:%s] state %p\n",
> +			       colorop->base.id, crtc->base.id, crtc->name,
> +			       crtc_state);
> +	else
> +		drm_dbg_atomic(crtc->dev,
> +			       "Set [NOCOLOROP] for [CRTC:%d:%s] state %p\n",
> +			       crtc->base.id, crtc->name, crtc_state);
> +
> +	crtc_state->color_pipeline = colorop;
> +}
> +EXPORT_SYMBOL(drm_atomic_set_colorop_for_crtc);
>   
>   /**
>    * drm_atomic_set_crtc_for_connector - set CRTC for connector
> @@ -396,8 +423,8 @@ static s32 __user *get_out_fence_for_connector(struct drm_atomic_state *state,
>   }
>   
>   static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
> -		struct drm_crtc_state *state, struct drm_property *property,
> -		uint64_t val)
> +		struct drm_crtc_state *state, struct drm_file *file_priv,
> +		struct drm_property *property, uint64_t val)
>   {
>   	struct drm_device *dev = crtc->dev;
>   	struct drm_mode_config *config = &dev->mode_config;
> @@ -406,7 +433,17 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
>   
>   	if (property == config->prop_active)
>   		state->active = val;
> -	else if (property == config->prop_mode_id) {
> +	else if (property == crtc->color_pipeline_property) {
> +		/* find DRM colorop object */
> +		struct drm_colorop *colorop = NULL;
> +
> +		colorop = drm_colorop_find(dev, file_priv, val);
> +
> +		if (val && !colorop)
> +			return -EACCES;
> +
> +		drm_atomic_set_colorop_for_crtc(state, colorop);

I don't know if this is needed, but you added a warning/early return for 
ctm/degamma_lut if file_priv->post_blend_color_pipeline is true.

Does it make sense to add this?

	if (!file_priv->post_blend_color_pipeline) {
			drm_dbg_atomic(dev,
				"Setting COLOR_PIPELINE property not permitted without 
DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
			return -EINVAL;
		}

> +	} else if (property == config->prop_mode_id) {
>   		struct drm_property_blob *mode =
>   			drm_property_lookup_blob(dev, val);
>   		ret = drm_atomic_set_mode_prop_for_crtc(state, mode);
> @@ -487,6 +524,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
>   		*val = 0;
>   	else if (property == crtc->scaling_filter_property)
>   		*val = state->scaling_filter;
> +	else if (property == crtc->color_pipeline_property)
> +		*val = (state->color_pipeline) ? state->color_pipeline->base.id : 0;
>   	else if (crtc->funcs->atomic_get_property)
>   		return crtc->funcs->atomic_get_property(crtc, state, property, val);
>   	else {
> @@ -1047,6 +1086,8 @@ int drm_atomic_get_property(struct drm_mode_object *obj,
>   
>   		if (colorop->plane)
>   			WARN_ON(!drm_modeset_is_locked(&colorop->plane->mutex));
> +		else if (colorop->crtc)
> +			WARN_ON(!drm_modeset_is_locked(&colorop->crtc->mutex));
>   
>   		ret = drm_atomic_colorop_get_property(colorop,
>   				colorop->state, property, val);
> @@ -1204,7 +1245,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
>   		}
>   
>   		ret = drm_atomic_crtc_set_property(crtc,
> -				crtc_state, prop, prop_value);
> +				crtc_state, file_priv, prop, prop_value);
>   		break;
>   	}
>   	case DRM_MODE_OBJECT_PLANE: {
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 94e60cffd29972aa979ac2f1932be7a6a97f3ada..94238163ff1254c721df39c030bc99a31d3bb92a 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1003,3 +1003,36 @@ drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mod
>   	kfree(all_pipelines);
>   	return prop;
>   }
> +
> +/**
> + * drm_crtc_create_color_pipeline_property - create a new color pipeline
> + * property
> + *
> + * @crtc: drm CRTC
> + * @pipelines: list of pipelines
> + * @num_pipelines: number of pipelines
> + *
> + * Create the COLOR_PIPELINE CRTC property to specify color pipelines on
> + * the CRTC.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_crtc_create_color_pipeline_property(struct drm_crtc *crtc,
> +					    const struct drm_prop_enum_list *pipelines,
> +					    int num_pipelines)
> +{
> +	struct drm_property *prop;
> +
> +	prop = drm_common_create_color_pipeline_property(crtc->dev,
> +							 &crtc->base,
> +							 pipelines,
> +							 num_pipelines);
> +	if (IS_ERR(prop))
> +		return PTR_ERR(prop);
> +
> +	crtc->color_pipeline_property = prop;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_crtc_create_color_pipeline_property);
> diff --git a/include/drm/drm_atomic_uapi.h b/include/drm/drm_atomic_uapi.h
> index 4363155233267b93767c895fa6085544e2277442..4dc191f6f929d73deee9812025c48275a33cf770 100644
> --- a/include/drm/drm_atomic_uapi.h
> +++ b/include/drm/drm_atomic_uapi.h
> @@ -52,6 +52,8 @@ void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
>   				 struct drm_framebuffer *fb);
>   void drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state,
>   				      struct drm_colorop *colorop);
> +void drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
> +				     struct drm_colorop *colorop);
>   int __must_check
>   drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
>   				  struct drm_crtc *crtc);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 77c0c04a5910a2263923e06cf37535697e20e1c9..df03637ca25abd45e96b5944229297f776fd046d 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1096,6 +1096,14 @@ struct drm_crtc {
>   	 */
>   	struct drm_property *scaling_filter_property;
>   
> +	/**
> +	 * @color_pipeline_property:
> +	 *
> +	 * Optional "COLOR_PIPELINE" enum property for specifying
> +	 * a color pipeline to use on the CRTC.
> +	 */
> +	struct drm_property *color_pipeline_property;
> +
>   	/**
>   	 * @state:
>   	 *
> @@ -1331,5 +1339,8 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
>   
>   int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
>   					    unsigned int supported_filters);
> +int drm_crtc_create_color_pipeline_property(struct drm_crtc *crtc,
> +					     const struct drm_prop_enum_list *pipelines,
> +					     int num_pipelines);
>   bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state);
>   #endif /* __DRM_CRTC_H__ */
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code
  2025-09-18  0:43 ` [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code Nícolas F. R. A. Prado
@ 2025-09-19 12:43   ` Louis Chauvet
  2025-09-29  8:53   ` Harry Wentland
  1 sibling, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:43 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> In preparation for sharing the initialization code for the color
> pipeline property between pre- and post-blend color pipelines, factor
> out the common initialization to a separate function.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/drm_crtc.c          | 44 +++++++++++++++++++++++++++++++++++++
>   drivers/gpu/drm/drm_crtc_internal.h |  5 +++++
>   drivers/gpu/drm/drm_plane.c         | 36 +++++-------------------------
>   3 files changed, 54 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 46655339003db2a1b43441434839e26f61d79b4e..94e60cffd29972aa979ac2f1932be7a6a97f3ada 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -959,3 +959,47 @@ bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state)
>   	return hweight32(crtc_state->encoder_mask) > 1;
>   }
>   EXPORT_SYMBOL(drm_crtc_in_clone_mode);
> +
> +struct drm_property *
> +drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
> +					  const struct drm_prop_enum_list *pipelines,
> +					  int num_pipelines)
> +{
> +	struct drm_prop_enum_list *all_pipelines;
> +	struct drm_property *prop;
> +	int len = 0;
> +	int i;
> +
> +	all_pipelines = kcalloc(num_pipelines + 1,
> +				sizeof(*all_pipelines),
> +				GFP_KERNEL);
> +
> +	if (!all_pipelines) {
> +		drm_err(dev, "failed to allocate color pipeline\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	/* Create default Bypass color pipeline */
> +	all_pipelines[len].type = 0;
> +	all_pipelines[len].name = "Bypass";
> +	len++;
> +
> +	/* Add all other color pipelines */
> +	for (i = 0; i < num_pipelines; i++, len++) {
> +		all_pipelines[len].type = pipelines[i].type;
> +		all_pipelines[len].name = pipelines[i].name;
> +	}
> +
> +	prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
> +					"COLOR_PIPELINE",
> +					all_pipelines, len);
> +	if (IS_ERR(prop)) {
> +		kfree(all_pipelines);
> +		return prop;
> +	}
> +
> +	drm_object_attach_property(obj, prop, 0);
> +
> +	kfree(all_pipelines);
> +	return prop;
> +}
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index c094092296448093c5cd192ecdc8ea9a50769c90..e3dbdcbfa385b940ec0b5476adde6146fe4afde1 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -35,6 +35,7 @@
>   #ifndef __DRM_CRTC_INTERNAL_H__
>   #define __DRM_CRTC_INTERNAL_H__
>   
> +#include <drm/drm_property.h>
>   #include <linux/err.h>
>   #include <linux/types.h>
>   
> @@ -79,6 +80,10 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
>   int drm_crtc_register_all(struct drm_device *dev);
>   void drm_crtc_unregister_all(struct drm_device *dev);
>   int drm_crtc_force_disable(struct drm_crtc *crtc);
> +struct drm_property *
> +drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
> +					  const struct drm_prop_enum_list *pipelines,
> +					  int num_pipelines);
>   
>   struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc);
>   
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index f6cfa8ac090c7bc49c7f276993bba7e9800da140..60dbfcab495600dd44c15260a1fa6135db59c6e2 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -1839,43 +1839,17 @@ int drm_plane_create_color_pipeline_property(struct drm_plane *plane,
>   					     const struct drm_prop_enum_list *pipelines,
>   					     int num_pipelines)
>   {
> -	struct drm_prop_enum_list *all_pipelines;
>   	struct drm_property *prop;
> -	int len = 0;
> -	int i;
> -
> -	all_pipelines = kcalloc(num_pipelines + 1,
> -				sizeof(*all_pipelines),
> -				GFP_KERNEL);
> -
> -	if (!all_pipelines) {
> -		drm_err(plane->dev, "failed to allocate color pipeline\n");
> -		return -ENOMEM;
> -	}
>   
> -	/* Create default Bypass color pipeline */
> -	all_pipelines[len].type = 0;
> -	all_pipelines[len].name = "Bypass";
> -	len++;
> -
> -	/* Add all other color pipelines */
> -	for (i = 0; i < num_pipelines; i++, len++) {
> -		all_pipelines[len].type = pipelines[i].type;
> -		all_pipelines[len].name = pipelines[i].name;
> -	}
> -
> -	prop = drm_property_create_enum(plane->dev, DRM_MODE_PROP_ATOMIC,
> -					"COLOR_PIPELINE",
> -					all_pipelines, len);
> -	if (IS_ERR(prop)) {
> -		kfree(all_pipelines);
> +	prop = drm_common_create_color_pipeline_property(plane->dev,
> +							 &plane->base,
> +							 pipelines,
> +							 num_pipelines);
> +	if (IS_ERR(prop))
>   		return PTR_ERR(prop);
> -	}
>   
> -	drm_object_attach_property(&plane->base, prop, 0);
>   	plane->color_pipeline_property = prop;
>   
> -	kfree(all_pipelines);
>   	return 0;
>   }
>   EXPORT_SYMBOL(drm_plane_create_color_pipeline_property);
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 10/20] drm/colorop: Introduce colorop helpers for crtc
  2025-09-18  0:43 ` [PATCH RFC v2 10/20] drm/colorop: Introduce colorop helpers for crtc Nícolas F. R. A. Prado
@ 2025-09-19 12:44   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:44 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Introduce colorop helper counterparts for post-blend color pipelines
> that take a CRTC instead of a plane.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/drm_colorop.c | 73 +++++++++++++++++++++++++++++++++++++++++++
>   include/drm/drm_colorop.h     |  8 +++++
>   2 files changed, 81 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
> index db137169effa6cd9e6d5805f65bdfd1cc6882075..b0c3216f4dac22f3408cbd537a20f38d03abc0a7 100644
> --- a/drivers/gpu/drm/drm_colorop.c
> +++ b/drivers/gpu/drm/drm_colorop.c
> @@ -168,6 +168,20 @@ static int drm_plane_colorop_init(struct drm_device *dev,
>   	return ret;
>   }
>   
> +static int drm_crtc_colorop_init(struct drm_device *dev,
> +				 struct drm_colorop *colorop,
> +				 struct drm_crtc *crtc,
> +				 enum drm_colorop_type type, uint32_t flags)
> +{
> +	int ret;
> +
> +	ret = drm_common_colorop_init(dev, colorop, type, flags);
> +
> +	colorop->crtc = crtc;
> +
> +	return ret;
> +}
> +
>   /**
>    * drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline
>    *
> @@ -293,6 +307,23 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *
>   }
>   EXPORT_SYMBOL(drm_plane_colorop_curve_1d_init);
>   
> +int drm_crtc_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
> +				   struct drm_crtc *crtc, u64 supported_tfs, uint32_t flags)
> +{
> +	int ret;
> +
> +	ret = drm_colorop_has_supported_tf(dev, &crtc->base, crtc->name, supported_tfs);
> +	if (ret)
> +		return ret;
> +
> +	ret = drm_crtc_colorop_init(dev, colorop, crtc, DRM_COLOROP_1D_CURVE, flags);
> +	if (ret)
> +		return ret;
> +
> +	return drm_common_colorop_curve_1d_init(dev, colorop, supported_tfs, flags);
> +}
> +EXPORT_SYMBOL(drm_crtc_colorop_curve_1d_init);
> +
>   static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_colorop *colorop)
>   {
>   	struct drm_property *prop;
> @@ -381,6 +412,35 @@ drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *
>   }
>   EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_init);
>   
> +/**
> + * drm_crtc_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT
> + *
> + * @dev: DRM device
> + * @colorop: The drm_colorop object to initialize
> + * @crtc: The associated drm_crtc
> + * @lut_size: LUT size supported by driver
> + * @lut1d_interpolation: 1D LUT interpolation type
> + * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
> + * @return zero on success, -E value on failure
> + */
> +int
> +drm_crtc_colorop_curve_1d_lut_init(struct drm_device *dev,
> +				   struct drm_colorop *colorop,
> +				   struct drm_crtc *crtc, uint32_t lut_size,
> +				   enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
> +				   uint32_t flags)
> +{
> +	int ret;
> +
> +	ret = drm_crtc_colorop_init(dev, colorop, crtc, DRM_COLOROP_1D_LUT, flags);
> +	if (ret)
> +		return ret;
> +
> +	return drm_common_colorop_curve_1d_lut_init(dev, colorop, lut_size,
> +						    lut1d_interpolation, flags);
> +}
> +EXPORT_SYMBOL(drm_crtc_colorop_curve_1d_lut_init);
> +
>   static int drm_common_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
>   					   uint32_t flags)
>   {
> @@ -408,6 +468,19 @@ int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *c
>   }
>   EXPORT_SYMBOL(drm_plane_colorop_ctm_3x4_init);
>   
> +int drm_crtc_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
> +				   struct drm_crtc *crtc, uint32_t flags)
> +{
> +	int ret;
> +
> +	ret = drm_crtc_colorop_init(dev, colorop, crtc, DRM_COLOROP_CTM_3X4, flags);
> +	if (ret)
> +		return ret;
> +
> +	return drm_common_colorop_ctm_3x4_init(dev, colorop, flags);
> +}
> +EXPORT_SYMBOL(drm_crtc_colorop_ctm_3x4_init);
> +
>   /**
>    * drm_plane_colorop_mult_init - Initialize a DRM_COLOROP_MULTIPLIER
>    *
> diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
> index 3e223f3b3597978c5d702ce7622ae30b8aa9dddb..e7d1e5e95a901b1bd91fd8580e2fcb367c0253ce 100644
> --- a/include/drm/drm_colorop.h
> +++ b/include/drm/drm_colorop.h
> @@ -377,14 +377,22 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,
>   
>   void drm_colorop_pipeline_destroy(struct drm_device *dev);
>   
> +int drm_crtc_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
> +				       struct drm_crtc *crtc, uint32_t lut_size,
> +				       enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
> +				       uint32_t flags);
>   int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
>   				    struct drm_plane *plane, u64 supported_tfs, uint32_t flags);
> +int drm_crtc_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
> +				   struct drm_crtc *crtc, u64 supported_tfs, uint32_t flags);
>   int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
>   					struct drm_plane *plane, uint32_t lut_size,
>   					enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
>   					uint32_t flags);
>   int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
>   				   struct drm_plane *plane, uint32_t flags);
> +int drm_crtc_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
> +				   struct drm_crtc *crtc, uint32_t flags);
>   int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
>   				struct drm_plane *plane, uint32_t flags);
>   int drm_plane_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *colorop,
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 02/20] drm/colorop: Allow parenting colorop to CRTC
  2025-09-18  0:43 ` [PATCH RFC v2 02/20] drm/colorop: Allow parenting colorop to CRTC Nícolas F. R. A. Prado
@ 2025-09-19 12:44   ` Louis Chauvet
  2025-12-10 20:49     ` Ariel D'Alessandro
  0 siblings, 1 reply; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:44 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> In order to allow for post-blend color pipelines, colorops need to be
> assigned to a crtc rather than a plane. Add a crtc to the colorop
> struct to enable this. Either the plane or the crtc will be set for any
> given colorop depending on whether it is part of a pre- or post-blend
> color pipeline.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   include/drm/drm_colorop.h | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
> index d61c6c40e47162cb8b1e7db58b6746c43ac5d202..7a4e0d0c4a3d594abecef304b1d5990434cdb231 100644
> --- a/include/drm/drm_colorop.h
> +++ b/include/drm/drm_colorop.h
> @@ -206,10 +206,16 @@ struct drm_colorop {
>   	/**
>   	 * @plane:
>   	 *
> -	 * The plane on which the colorop sits. A drm_colorop is always unique
> -	 * to a plane.
> +	 * The plane on which the colorop sits if it is a pre-blend colorop.
> +	 * In this case it is unique to the plane.
> +	 *
> +	 * @crtc:
> +	 *
> +	 * The CRTC on which the colorop sits if it is a post-blend colorop.
> +	 * In this case it is unique to the CRTC.
>   	 */

If there is a v3 of this series, I think it could be nice to have 
something like "plane and CRTC are mutually exclusive".

With or without this:
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

>   	struct drm_plane *plane;
> +	struct drm_crtc *crtc;
>   
>   	/**
>   	 * @state:
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 01/20] drm/crtc: Add color pipeline to CRTC state
  2025-09-18  0:43 ` [PATCH RFC v2 01/20] drm/crtc: Add color pipeline to CRTC state Nícolas F. R. A. Prado
@ 2025-09-19 12:45   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:45 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Add a color pipeline to the CRTC state to allow post-blend color
> pipelines.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   include/drm/drm_crtc.h | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index caa56e039da2a748cf40ebf45b37158acda439d9..77c0c04a5910a2263923e06cf37535697e20e1c9 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -274,6 +274,14 @@ struct drm_crtc_state {
>   	 */
>   	struct drm_property_blob *gamma_lut;
>   
> +	/**
> +	 * @color_pipeline:
> +	 *
> +	 * The first colorop of the active color pipeline, or NULL, if no
> +	 * color pipeline is active.
> +	 */
> +	struct drm_colorop *color_pipeline;
> +
>   	/**
>   	 * @target_vblank:
>   	 *
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 17/20] drm/vkms: Rename existing color pipeline helpers to contain "pre_blend"
  2025-09-18  0:43 ` [PATCH RFC v2 17/20] drm/vkms: Rename existing color pipeline helpers to contain "pre_blend" Nícolas F. R. A. Prado
@ 2025-09-19 12:45   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:45 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Rename the existing color pipeline helpers so they contain "pre_blend"
> in the name to make them clearly distinguishable from the post-blend
> helpers when they're introduced.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/vkms/vkms_colorop.c | 8 +++++---
>   drivers/gpu/drm/vkms/vkms_drv.h     | 2 +-
>   drivers/gpu/drm/vkms/vkms_plane.c   | 2 +-
>   3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c
> index 0191ac44dec0a9513e001b304f6ead32a96cdb8c..5924ae2bd40fc904048f99bc9b96308140709e25 100644
> --- a/drivers/gpu/drm/vkms/vkms_colorop.c
> +++ b/drivers/gpu/drm/vkms/vkms_colorop.c
> @@ -14,7 +14,9 @@ static const u64 supported_tfs =
>   
>   #define MAX_COLOR_PIPELINE_OPS 4
>   
> -static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
> +static int
> +vkms_initialize_pre_blend_color_pipeline(struct drm_plane *plane,
> +					 struct drm_prop_enum_list *list)
>   {
>   	struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
>   	struct drm_device *dev = plane->dev;
> @@ -96,13 +98,13 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
>   	return ret;
>   }
>   
> -int vkms_initialize_colorops(struct drm_plane *plane)
> +int vkms_initialize_pre_blend_colorops(struct drm_plane *plane)
>   {
>   	struct drm_prop_enum_list pipeline;
>   	int ret;
>   
>   	/* Add color pipeline */
> -	ret = vkms_initialize_color_pipeline(plane, &pipeline);
> +	ret = vkms_initialize_pre_blend_color_pipeline(plane, &pipeline);
>   	if (ret)
>   		return ret;
>   
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index 55440ec6db5209741af1443d4e49e9471e6795c9..37ee569474223b2cf01e3cc0e4f119777533ae23 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -305,6 +305,6 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer
>   int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, struct vkms_output *vkms_out);
>   
>   /* Colorops */
> -int vkms_initialize_colorops(struct drm_plane *plane);
> +int vkms_initialize_pre_blend_colorops(struct drm_plane *plane);
>   
>   #endif /* _VKMS_DRV_H_ */
> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
> index db8d26810afa8d8fcab48a6db2e691255f26a8a6..8e63a07a7e1b0a350361d0b03b7911bfa9ce3dcc 100644
> --- a/drivers/gpu/drm/vkms/vkms_plane.c
> +++ b/drivers/gpu/drm/vkms/vkms_plane.c
> @@ -232,7 +232,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
>   					  DRM_COLOR_YCBCR_BT601,
>   					  DRM_COLOR_YCBCR_FULL_RANGE);
>   
> -	vkms_initialize_colorops(&plane->base);
> +	vkms_initialize_pre_blend_colorops(&plane->base);
>   
>   	return plane;
>   }
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 18/20] drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines
  2025-09-18  0:43 ` [PATCH RFC v2 18/20] drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines Nícolas F. R. A. Prado
@ 2025-09-19 12:48   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:48 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> As a preparatory step for supporting post-blend color pipelines in VKMS,
> rename pre_blend_color_transform() to color_transform() and make it take
> the first colorop instead of a plane state, so it can be shared by both
> pre- and post-blend color pipeline code paths.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/vkms/vkms_composer.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
> index 31b1dd3cd115d930ec3ed498403a8f44208d76c3..05e1551d6330e4dc14563d3a399b3544d11c6576 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
> @@ -189,13 +189,13 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo
>   	}
>   }
>   
> -static void pre_blend_color_transform(const struct vkms_plane_state *plane_state,
> -				      struct line_buffer *output_buffer)
> +static void color_transform(struct drm_colorop *first_colorop,
> +			    struct line_buffer *output_buffer)
>   {
>   	struct pixel_argb_s32 pixel;
>   
>   	for (size_t x = 0; x < output_buffer->n_pixels; x++) {
> -		struct drm_colorop *colorop = plane_state->base.base.color_pipeline;
> +		struct drm_colorop *colorop = first_colorop;
>   
>   		/*
>   		 * Some operations, such as applying a BT709 encoding matrix,
> @@ -449,7 +449,7 @@ static void blend_line(struct vkms_plane_state *current_plane, int y,
>   	 */
>   	current_plane->pixel_read_line(current_plane, src_x_start, src_y_start, direction,
>   				       pixel_count, &stage_buffer->pixels[dst_x_start]);
> -	pre_blend_color_transform(current_plane, stage_buffer);
> +	color_transform(current_plane->base.base.color_pipeline, stage_buffer);
>   	pre_mul_alpha_blend(stage_buffer, output_buffer,
>   			    dst_x_start, pixel_count);
>   }
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 20/20] drm/vkms: Set post-blend color pipeline driver cap
  2025-09-18  0:43 ` [PATCH RFC v2 20/20] drm/vkms: Set post-blend color pipeline driver cap Nícolas F. R. A. Prado
@ 2025-09-19 12:49   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:49 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Now that the driver implements post-blend color pipelines, set the
> driver cap so they can be used from userspace.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/vkms/vkms_drv.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index e8472d9b6e3b2b5d6d497763288bf3dc6fde5987..4cc67a789d28288575235b7efc87bc5e45d668cc 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.c
> +++ b/drivers/gpu/drm/vkms/vkms_drv.c
> @@ -80,7 +80,8 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state)
>   }
>   
>   static const struct drm_driver vkms_driver = {
> -	.driver_features	= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM,
> +	.driver_features	= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM |
> +				  DRIVER_POST_BLEND_COLOR_PIPELINE,
>   	.fops			= &vkms_driver_fops,
>   	DRM_GEM_SHMEM_DRIVER_OPS,
>   	DRM_FBDEV_SHMEM_DRIVER_OPS,
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 19/20] drm/vkms: Introduce support for post-blend color pipeline
  2025-09-18  0:43 ` [PATCH RFC v2 19/20] drm/vkms: Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
@ 2025-09-19 12:50   ` Louis Chauvet
  2025-12-10 21:15     ` Ariel D'Alessandro
  0 siblings, 1 reply; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:50 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Introduce a post-blend color pipeline with the same colorop blocks as
> the pre-blend color pipeline.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   drivers/gpu/drm/vkms/vkms_colorop.c  | 98 ++++++++++++++++++++++++++++++++++++
>   drivers/gpu/drm/vkms/vkms_composer.c |  5 +-
>   drivers/gpu/drm/vkms/vkms_crtc.c     |  1 +
>   drivers/gpu/drm/vkms/vkms_drv.h      |  1 +
>   4 files changed, 104 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c
> index 5924ae2bd40fc904048f99bc9b96308140709e25..54c512db68eef16435d5f79453784f7784d540fb 100644
> --- a/drivers/gpu/drm/vkms/vkms_colorop.c
> +++ b/drivers/gpu/drm/vkms/vkms_colorop.c
> @@ -98,6 +98,86 @@ vkms_initialize_pre_blend_color_pipeline(struct drm_plane *plane,
>   	return ret;
>   }
>   
> +static int
> +vkms_initialize_post_blend_color_pipeline(struct drm_crtc *crtc,
> +					  struct drm_prop_enum_list *list)
> +{
> +	struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
> +	struct drm_device *dev = crtc->dev;
> +	int ret;
> +	int i = 0;
> +
> +	memset(ops, 0, sizeof(ops));
> +
> +	/* 1st op: 1d curve */
> +	ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
> +	if (!ops[i]) {
> +		ret = -ENOMEM;
> +		goto cleanup;
> +	}
> +
> +	ret = drm_crtc_colorop_curve_1d_init(dev, ops[i], crtc, supported_tfs,
> +					     DRM_COLOROP_FLAG_ALLOW_BYPASS);
> +	if (ret)
> +		goto cleanup;
> +
> +	list->type = ops[i]->base.id;
> +	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id);
> +
> +	i++;
> +
> +	/* 2nd op: 3x4 matrix */
> +	ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
> +	if (!ops[i]) {
> +		ret = -ENOMEM;
> +		goto cleanup;
> +	}
> +
> +	ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, DRM_COLOROP_FLAG_ALLOW_BYPASS);
> +	if (ret)
> +		goto cleanup;
> +
> +	drm_colorop_set_next_property(ops[i - 1], ops[i]);
> +
> +	i++;
> +
> +	/* 3rd op: 3x4 matrix */
> +	ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
> +	if (!ops[i]) {
> +		ret = -ENOMEM;
> +		goto cleanup;
> +	}
> +
> +	ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, DRM_COLOROP_FLAG_ALLOW_BYPASS);
> +	if (ret)
> +		goto cleanup;
> +
> +	drm_colorop_set_next_property(ops[i - 1], ops[i]);
> +
> +	i++;
> +
> +	/* 4th op: 1d curve */
> +	ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
> +	if (!ops[i]) {
> +		ret = -ENOMEM;
> +		goto cleanup;
> +	}
> +
> +	ret = drm_crtc_colorop_curve_1d_init(dev, ops[i], crtc, supported_tfs,
> +					     DRM_COLOROP_FLAG_ALLOW_BYPASS);
> +	if (ret)
> +		goto cleanup;
> +
> +	drm_colorop_set_next_property(ops[i - 1], ops[i]);
> +
> +	return 0;
> +
> +cleanup:
> +	drm_colorop_pipeline_destroy(dev);

Same comment as for pre_blend colorops, it feel strange to destroy all 
the pipelines here.

The suggestion in [1] is better (don't forget to add the kfree).

[1]: 
https://lore.kernel.org/all/73f01810-df2d-4e39-a20b-fc1cec2c5e12@amd.com/

> +	return ret;
> +}
> +
>   int vkms_initialize_pre_blend_colorops(struct drm_plane *plane)
>   {
>   	struct drm_prop_enum_list pipeline;
> @@ -115,3 +195,21 @@ int vkms_initialize_pre_blend_colorops(struct drm_plane *plane)
>   
>   	return 0;
>   }
> +
> +int vkms_initialize_post_blend_colorops(struct drm_crtc *crtc)
> +{
> +	struct drm_prop_enum_list pipeline;
> +	int ret;
> +
> +	/* Add color pipeline */
> +	ret = vkms_initialize_post_blend_color_pipeline(crtc, &pipeline);
> +	if (ret)
> +		return ret;
> +
> +	/* Create COLOR_PIPELINE property and attach */
> +	ret = drm_crtc_create_color_pipeline_property(crtc, &pipeline, 1);
> +	if (ret)
> +		return ret;
> +
> +	return 0;
> +}
> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
> index 05e1551d6330e4dc14563d3a399b3544d11c6576..efe09538768b01108a305f0ace765246220b487b 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
> @@ -495,7 +495,10 @@ static void blend(struct vkms_writeback_job *wb,
>   			blend_line(plane[i], y, crtc_x_limit, stage_buffer, output_buffer);
>   		}
>   
> -		apply_lut(crtc_state, output_buffer);
> +		if (crtc_state->base.color_pipeline_enabled)
> +			color_transform(crtc_state->base.color_pipeline, output_buffer);
> +		else
> +			apply_lut(crtc_state, output_buffer);
>   
>   		*crc32 = crc32_le(*crc32, (void *)output_buffer->pixels, row_size);
>   
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index e60573e0f3e9510252e1f198b00e28bcc7987620..04737c1fb70e4f0aef480a180e57a76fbc279dfa 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -295,6 +295,7 @@ struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane *pri
>   	}
>   
>   	drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE);
> +	vkms_initialize_post_blend_colorops(crtc);
>   
>   	spin_lock_init(&vkms_out->lock);
>   	spin_lock_init(&vkms_out->composer_lock);
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index 37ee569474223b2cf01e3cc0e4f119777533ae23..a0308c2263d1858a72906853960ea7d1bbecd03e 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -306,5 +306,6 @@ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, struct vkms_out
>   
>   /* Colorops */
>   int vkms_initialize_pre_blend_colorops(struct drm_plane *plane);
> +int vkms_initialize_post_blend_colorops(struct drm_crtc *crtc);
>   
>   #endif /* _VKMS_DRV_H_ */
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com





^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 16/20] drm/mediatek: Set post-blend color pipeline driver cap
  2025-09-18  0:43 ` [PATCH RFC v2 16/20] drm/mediatek: Set post-blend color pipeline driver cap Nícolas F. R. A. Prado
@ 2025-09-19 12:50   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:50 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Now that the driver implements post-blend color pipelines, set the
> driver cap so they can be used from userspace.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index d5e6bab364143540e1f59df481b9a9d559c39199..73c0f448d7fcf25e473e2c3c6ddaaf28446570cf 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -611,7 +611,8 @@ static struct drm_gem_object *mtk_gem_prime_import(struct drm_device *dev,
>   }
>   
>   static const struct drm_driver mtk_drm_driver = {
> -	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
> +	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC |
> +			   DRIVER_POST_BLEND_COLOR_PIPELINE,
>   
>   	.dumb_create = mtk_gem_dumb_create,
>   	DRM_FBDEV_DMA_DRIVER_OPS,
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 08/20] drm/atomic: Print the color pipeline as part of the CRTC state print
  2025-09-18  0:43 ` [PATCH RFC v2 08/20] drm/atomic: Print the color pipeline as part of the CRTC state print Nícolas F. R. A. Prado
@ 2025-09-19 12:50   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:50 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Print the value of the color pipeline in the CRTC state as part of the
> CRTC state print.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   drivers/gpu/drm/drm_atomic.c  |  8 +++++---
>   drivers/gpu/drm/drm_colorop.c | 26 ++++++++++++++++++++++++++
>   include/drm/drm_colorop.h     |  3 +++
>   3 files changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 3ab32fe7fe1cbf9057c3763d979638dce013d82b..6982c978dc530b838353ace60f748660c3b4524d 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -472,6 +472,8 @@ static void drm_atomic_crtc_print_state(struct drm_printer *p,
>   	drm_printf(p, "\tplane_mask=%x\n", state->plane_mask);
>   	drm_printf(p, "\tconnector_mask=%x\n", state->connector_mask);
>   	drm_printf(p, "\tencoder_mask=%x\n", state->encoder_mask);
> +	drm_printf(p, "\tcolor-pipeline=%d\n",
> +		   state->color_pipeline ? state->color_pipeline->base.id : 0);
>   	drm_printf(p, "\tmode: " DRM_MODE_FMT "\n", DRM_MODE_ARG(&state->mode));
>   
>   	if (crtc->funcs->atomic_print_state)
> @@ -617,7 +619,7 @@ drm_atomic_get_colorop_state(struct drm_atomic_state *state,
>   	if (colorop_state)
>   		return colorop_state;
>   
> -	ret = drm_modeset_lock(&colorop->plane->mutex, state->acquire_ctx);
> +	ret = drm_colorop_modeset_lock(colorop, state->acquire_ctx);
>   	if (ret)
>   		return ERR_PTR(ret);
>   
> @@ -2004,10 +2006,10 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,
>   
>   	list_for_each_entry(colorop, &config->colorop_list, head) {
>   		if (take_locks)
> -			drm_modeset_lock(&colorop->plane->mutex, NULL);
> +			drm_colorop_modeset_lock(colorop, NULL);
>   		drm_atomic_colorop_print_state(p, colorop->state);
>   		if (take_locks)
> -			drm_modeset_unlock(&colorop->plane->mutex);
> +			drm_colorop_modeset_unlock(colorop);
>   	}
>   
>   	list_for_each_entry(plane, &config->plane_list, head) {
> diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
> index a1b36cd488f0a014425a9192ffe5fcc4d2c1afaa..1384a259605fa4945aa74402901886d7e1fde0d1 100644
> --- a/drivers/gpu/drm/drm_colorop.c
> +++ b/drivers/gpu/drm/drm_colorop.c
> @@ -24,6 +24,7 @@
>    *
>    */
>   
> +#include <drm/drm_crtc.h>
>   #include <drm/drm_colorop.h>
>   #include <drm/drm_print.h>
>   #include <drm/drm_drv.h>
> @@ -595,3 +596,28 @@ void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_color
>   	colorop->next = next;
>   }
>   EXPORT_SYMBOL(drm_colorop_set_next_property);
> +
> +int drm_colorop_modeset_lock(struct drm_colorop *colorop, struct drm_modeset_acquire_ctx *ctx)
> +{
> +	if (colorop->plane)
> +		return drm_modeset_lock(&colorop->plane->mutex, ctx);
> +
> +	if (colorop->crtc)
> +		return drm_modeset_lock(&colorop->crtc->mutex, ctx);
> +
> +	drm_err(colorop->dev, "Dangling colorop, it must be attached to a plane or a CRTC\n");
> +	return -EINVAL;
> +}
> +EXPORT_SYMBOL(drm_colorop_modeset_lock);
> +
> +
> +void drm_colorop_modeset_unlock(struct drm_colorop *colorop)
> +{
> +	if (colorop->plane)
> +		drm_modeset_unlock(&colorop->plane->mutex);
> +	else if (colorop->crtc)
> +		drm_modeset_unlock(&colorop->crtc->mutex);
> +	else
> +		drm_err(colorop->dev, "Dangling colorop, it must be attached to a plane or a CRTC\n");
> +}

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> +EXPORT_SYMBOL(drm_colorop_modeset_unlock);
> diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
> index 7a4e0d0c4a3d594abecef304b1d5990434cdb231..3e223f3b3597978c5d702ce7622ae30b8aa9dddb 100644
> --- a/include/drm/drm_colorop.h
> +++ b/include/drm/drm_colorop.h
> @@ -29,6 +29,7 @@
>   
>   #include <drm/drm_mode_object.h>
>   #include <drm/drm_mode.h>
> +#include <drm/drm_modeset_lock.h>
>   #include <drm/drm_property.h>
>   
>   /* DRM colorop flags */
> @@ -444,5 +445,7 @@ const char *drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_inte
>   const char *drm_get_colorop_lut3d_interpolation_name(enum drm_colorop_lut3d_interpolation_type type);
>   
>   void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next);
> +int drm_colorop_modeset_lock(struct drm_colorop *colorop, struct drm_modeset_acquire_ctx *ctx);
> +void drm_colorop_modeset_unlock(struct drm_colorop *colorop);
>   
>   #endif /* __DRM_COLOROP_H__ */
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 09/20] drm/colorop: Factor out common paths from colorops helpers
  2025-09-18  0:43 ` [PATCH RFC v2 09/20] drm/colorop: Factor out common paths from colorops helpers Nícolas F. R. A. Prado
@ 2025-09-19 12:51   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:51 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Factor out the common code paths from the colorop helpers so they can be
> reused by the post-blend colorop helpers.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
>   drivers/gpu/drm/drm_colorop.c | 145 ++++++++++++++++++++++++++++--------------
>   1 file changed, 99 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
> index 1384a259605fa4945aa74402901886d7e1fde0d1..db137169effa6cd9e6d5805f65bdfd1cc6882075 100644
> --- a/drivers/gpu/drm/drm_colorop.c
> +++ b/drivers/gpu/drm/drm_colorop.c
> @@ -91,8 +91,9 @@ static const struct drm_prop_enum_list drm_colorop_lut3d_interpolation_list[] =
>   
>   /* Init Helpers */
>   
> -static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
> -			    struct drm_plane *plane, enum drm_colorop_type type, uint32_t flags)
> +static int drm_common_colorop_init(struct drm_device *dev,
> +				   struct drm_colorop *colorop,
> +				   enum drm_colorop_type type, uint32_t flags)
>   {
>   	struct drm_mode_config *config = &dev->mode_config;
>   	struct drm_property *prop;
> @@ -105,7 +106,6 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co
>   	colorop->base.properties = &colorop->properties;
>   	colorop->dev = dev;
>   	colorop->type = type;
> -	colorop->plane = plane;
>   	colorop->next = NULL;
>   
>   	list_add_tail(&colorop->head, &config->colorop_list);
> @@ -154,6 +154,20 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co
>   	return ret;
>   }
>   
> +static int drm_plane_colorop_init(struct drm_device *dev,
> +				  struct drm_colorop *colorop,
> +				  struct drm_plane *plane,
> +				  enum drm_colorop_type type, uint32_t flags)
> +{
> +	int ret;
> +
> +	ret = drm_common_colorop_init(dev, colorop, type, flags);
> +
> +	colorop->plane = plane;
> +
> +	return ret;
> +}
> +
>   /**
>    * drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline
>    *
> @@ -206,31 +220,13 @@ EXPORT_SYMBOL(drm_colorop_pipeline_destroy);
>    * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
>    * @return zero on success, -E value on failure
>    */
> -int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
> -				    struct drm_plane *plane, u64 supported_tfs, uint32_t flags)
> +static int drm_common_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
> +					    u64 supported_tfs, uint32_t flags)
>   {
>   	struct drm_prop_enum_list enum_list[DRM_COLOROP_1D_CURVE_COUNT];
>   	int i, len;
>   
>   	struct drm_property *prop;
> -	int ret;
> -
> -	if (!supported_tfs) {
> -		drm_err(dev,
> -			"No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n",
> -			plane->base.id, plane->name);
> -		return -EINVAL;
> -	}
> -
> -	if ((supported_tfs & -BIT(DRM_COLOROP_1D_CURVE_COUNT)) != 0) {
> -		drm_err(dev, "Unknown TF provided on [PLANE:%d:%s]\n",
> -			plane->base.id, plane->name);
> -		return -EINVAL;
> -	}
> -
> -	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE, flags);
> -	if (ret)
> -		return ret;
>   
>   	len = 0;
>   	for (i = 0; i < DRM_COLOROP_1D_CURVE_COUNT; i++) {
> @@ -260,6 +256,41 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *
>   
>   	return 0;
>   }
> +
> +static int drm_colorop_has_supported_tf(struct drm_device *dev, struct drm_mode_object *obj,
> +					const char *name, u64 supported_tfs)
> +{
> +	if (!supported_tfs) {
> +		drm_err(dev,
> +			"No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n",
> +			obj->id, name);
> +		return -EINVAL;
> +	}
> +
> +	if ((supported_tfs & -BIT(DRM_COLOROP_1D_CURVE_COUNT)) != 0) {
> +		drm_err(dev, "Unknown TF provided on [PLANE:%d:%s]\n",
> +			obj->id, name);
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
> +				    struct drm_plane *plane, u64 supported_tfs, uint32_t flags)
> +{
> +	int ret;
> +
> +	ret = drm_colorop_has_supported_tf(dev, &plane->base, plane->name, supported_tfs);
> +	if (ret)
> +		return ret;
> +
> +	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE, flags);
> +	if (ret)
> +		return ret;
> +
> +	return drm_common_colorop_curve_1d_init(dev, colorop, supported_tfs, flags);
> +}
>   EXPORT_SYMBOL(drm_plane_colorop_curve_1d_init);
>   
>   static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_colorop *colorop)
> @@ -280,29 +311,16 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color
>   	return 0;
>   }
>   
> -/**
> - * drm_plane_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT
> - *
> - * @dev: DRM device
> - * @colorop: The drm_colorop object to initialize
> - * @plane: The associated drm_plane
> - * @lut_size: LUT size supported by driver
> - * @lut1d_interpolation: 1D LUT interpolation type
> - * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
> - * @return zero on success, -E value on failure
> - */
> -int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
> -					struct drm_plane *plane, uint32_t lut_size,
> -					enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
> -					uint32_t flags)
> +static int
> +drm_common_colorop_curve_1d_lut_init(struct drm_device *dev,
> +				     struct drm_colorop *colorop,
> +				     uint32_t lut_size,
> +				     enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
> +				     uint32_t flags)
>   {
>   	struct drm_property *prop;
>   	int ret;
>   
> -	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT, flags);
> -	if (ret)
> -		return ret;
> -
>   	/* initialize 1D LUT only attribute */
>   	/* LUT size */
>   	prop = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC,
> @@ -334,17 +352,40 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color
>   
>   	return 0;
>   }
> -EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_init);
>   
> -int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
> -				   struct drm_plane *plane, uint32_t flags)
> +/**
> + * drm_plane_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT
> + *
> + * @dev: DRM device
> + * @colorop: The drm_colorop object to initialize
> + * @plane: The associated drm_plane
> + * @lut_size: LUT size supported by driver
> + * @lut1d_interpolation: 1D LUT interpolation type
> + * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
> + * @return zero on success, -E value on failure
> + */
> +int
> +drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
> +				    struct drm_plane *plane, uint32_t lut_size,
> +				    enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
> +				    uint32_t flags)
>   {
>   	int ret;
>   
> -	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4, flags);
> +	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT, flags);
>   	if (ret)
>   		return ret;
>   
> +	return drm_common_colorop_curve_1d_lut_init(dev, colorop, lut_size,
> +						    lut1d_interpolation, flags);
> +}
> +EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_init);
> +
> +static int drm_common_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
> +					   uint32_t flags)
> +{
> +	int ret;
> +
>   	ret = drm_colorop_create_data_prop(dev, colorop);
>   	if (ret)
>   		return ret;
> @@ -353,6 +394,18 @@ int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *c
>   
>   	return 0;
>   }
> +
> +int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
> +				   struct drm_plane *plane, uint32_t flags)
> +{
> +	int ret;
> +
> +	ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4, flags);
> +	if (ret)
> +		return ret;
> +
> +	return drm_common_colorop_ctm_3x4_init(dev, colorop, flags);
> +}
>   EXPORT_SYMBOL(drm_plane_colorop_ctm_3x4_init);
>   
>   /**
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 12/20] drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state
  2025-09-18  0:43 ` [PATCH RFC v2 12/20] drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state Nícolas F. R. A. Prado
@ 2025-09-19 12:51   ` Louis Chauvet
  0 siblings, 0 replies; 51+ messages in thread
From: Louis Chauvet @ 2025-09-19 12:51 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> Some drivers, like VKMS, only have access to the drm_crtc_state but not
> the drm_atomic_state during composition of the output framebuffer. Store
> the state of the post-blend color pipeline client cap in the
> drm_crtc_state so those drivers can decide whether to look at the color
> pipeline or the legacy properties for the color management settings to
> apply.

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   drivers/gpu/drm/drm_atomic.c | 1 +
>   include/drm/drm_crtc.h       | 8 ++++++++
>   2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 6982c978dc530b838353ace60f748660c3b4524d..bbfa35c800240722785a6db440eb3d47ef9c8ed6 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -386,6 +386,7 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
>   	state->crtcs[index].new_state = crtc_state;
>   	state->crtcs[index].ptr = crtc;
>   	crtc_state->state = state;
> +	crtc_state->color_pipeline_enabled = state->post_blend_color_pipeline;
>   
>   	drm_dbg_atomic(state->dev, "Added [CRTC:%d:%s] %p state to %p\n",
>   		       crtc->base.id, crtc->name, crtc_state, state);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index df03637ca25abd45e96b5944229297f776fd046d..cb9eda6335e0d6728d99d67cc6916ad2d0e1d94e 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -282,6 +282,14 @@ struct drm_crtc_state {
>   	 */
>   	struct drm_colorop *color_pipeline;
>   
> +	/**
> +	 * @color_pipeline_enabled:
> +	 *
> +	 * Whether color management should be done based on the &color_pipeline
> +	 * or the legacy color properties (&ctm, &gamma_lut and &degamma_lut).
> +	 */
> +	bool color_pipeline_enabled;
> +
>   	/**
>   	 * @target_vblank:
>   	 *
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com




^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code
  2025-09-18  0:43 ` [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code Nícolas F. R. A. Prado
  2025-09-19 12:43   ` Louis Chauvet
@ 2025-09-29  8:53   ` Harry Wentland
  2025-12-10 20:19     ` Ariel D'Alessandro
  1 sibling, 1 reply; 51+ messages in thread
From: Harry Wentland @ 2025-09-29  8:53 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, louis.chauvet, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



On 2025-09-17 20:43, Nícolas F. R. A. Prado wrote:
> In preparation for sharing the initialization code for the color
> pipeline property between pre- and post-blend color pipelines, factor
> out the common initialization to a separate function.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   drivers/gpu/drm/drm_crtc.c          | 44 +++++++++++++++++++++++++++++++++++++
>   drivers/gpu/drm/drm_crtc_internal.h |  5 +++++
>   drivers/gpu/drm/drm_plane.c         | 36 +++++-------------------------
>   3 files changed, 54 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 46655339003db2a1b43441434839e26f61d79b4e..94e60cffd29972aa979ac2f1932be7a6a97f3ada 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -959,3 +959,47 @@ bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state)
>   	return hweight32(crtc_state->encoder_mask) > 1;
>   }
>   EXPORT_SYMBOL(drm_crtc_in_clone_mode);
> +
> +struct drm_property *
> +drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
> +					  const struct drm_prop_enum_list *pipelines,
> +					  int num_pipelines)

All other functions I see in drm_crtc seem to be quite crtc
specific. Would there be a better place to put this? Possibly
a new file if nothing else seems to fit?

Not a blocker in any way, though.

Harry

> +{
> +	struct drm_prop_enum_list *all_pipelines;
> +	struct drm_property *prop;
> +	int len = 0;
> +	int i;
> +
> +	all_pipelines = kcalloc(num_pipelines + 1,
> +				sizeof(*all_pipelines),
> +				GFP_KERNEL);
> +
> +	if (!all_pipelines) {
> +		drm_err(dev, "failed to allocate color pipeline\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	/* Create default Bypass color pipeline */
> +	all_pipelines[len].type = 0;
> +	all_pipelines[len].name = "Bypass";
> +	len++;
> +
> +	/* Add all other color pipelines */
> +	for (i = 0; i < num_pipelines; i++, len++) {
> +		all_pipelines[len].type = pipelines[i].type;
> +		all_pipelines[len].name = pipelines[i].name;
> +	}
> +
> +	prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
> +					"COLOR_PIPELINE",
> +					all_pipelines, len);
> +	if (IS_ERR(prop)) {
> +		kfree(all_pipelines);
> +		return prop;
> +	}
> +
> +	drm_object_attach_property(obj, prop, 0);
> +
> +	kfree(all_pipelines);
> +	return prop;
> +}
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index c094092296448093c5cd192ecdc8ea9a50769c90..e3dbdcbfa385b940ec0b5476adde6146fe4afde1 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -35,6 +35,7 @@
>   #ifndef __DRM_CRTC_INTERNAL_H__
>   #define __DRM_CRTC_INTERNAL_H__
>   
> +#include <drm/drm_property.h>
>   #include <linux/err.h>
>   #include <linux/types.h>
>   
> @@ -79,6 +80,10 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
>   int drm_crtc_register_all(struct drm_device *dev);
>   void drm_crtc_unregister_all(struct drm_device *dev);
>   int drm_crtc_force_disable(struct drm_crtc *crtc);
> +struct drm_property *
> +drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
> +					  const struct drm_prop_enum_list *pipelines,
> +					  int num_pipelines);
>   
>   struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc);
>   
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index f6cfa8ac090c7bc49c7f276993bba7e9800da140..60dbfcab495600dd44c15260a1fa6135db59c6e2 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -1839,43 +1839,17 @@ int drm_plane_create_color_pipeline_property(struct drm_plane *plane,
>   					     const struct drm_prop_enum_list *pipelines,
>   					     int num_pipelines)
>   {
> -	struct drm_prop_enum_list *all_pipelines;
>   	struct drm_property *prop;
> -	int len = 0;
> -	int i;
> -
> -	all_pipelines = kcalloc(num_pipelines + 1,
> -				sizeof(*all_pipelines),
> -				GFP_KERNEL);
> -
> -	if (!all_pipelines) {
> -		drm_err(plane->dev, "failed to allocate color pipeline\n");
> -		return -ENOMEM;
> -	}
>   
> -	/* Create default Bypass color pipeline */
> -	all_pipelines[len].type = 0;
> -	all_pipelines[len].name = "Bypass";
> -	len++;
> -
> -	/* Add all other color pipelines */
> -	for (i = 0; i < num_pipelines; i++, len++) {
> -		all_pipelines[len].type = pipelines[i].type;
> -		all_pipelines[len].name = pipelines[i].name;
> -	}
> -
> -	prop = drm_property_create_enum(plane->dev, DRM_MODE_PROP_ATOMIC,
> -					"COLOR_PIPELINE",
> -					all_pipelines, len);
> -	if (IS_ERR(prop)) {
> -		kfree(all_pipelines);
> +	prop = drm_common_create_color_pipeline_property(plane->dev,
> +							 &plane->base,
> +							 pipelines,
> +							 num_pipelines);
> +	if (IS_ERR(prop))
>   		return PTR_ERR(prop);
> -	}
>   
> -	drm_object_attach_property(&plane->base, prop, 0);
>   	plane->color_pipeline_property = prop;
>   
> -	kfree(all_pipelines);
>   	return 0;
>   }
>   EXPORT_SYMBOL(drm_plane_create_color_pipeline_property);
> 



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 05/20] drm: Introduce DRM_CAP_POST_BLEND_COLOR_PIPELINE
  2025-09-19 12:42   ` Louis Chauvet
@ 2025-09-29  9:40     ` Harry Wentland
  2025-09-29 16:00       ` Nícolas F. R. A. Prado
  0 siblings, 1 reply; 51+ messages in thread
From: Harry Wentland @ 2025-09-29  9:40 UTC (permalink / raw)
  To: Louis Chauvet, Nícolas F. R. A. Prado, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, mcanal, kernel, daniels,
	leandro.ribeiro, dri-devel, linux-kernel, linux-mediatek,
	linux-arm-kernel, Simona Vetter



On 2025-09-19 08:42, Louis Chauvet wrote:
> 
> 
> Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
>> Add a new cap that drivers can set to signal they support post-blend
>> color pipelines.
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> 
> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> 
>> ---
>>   drivers/gpu/drm/drm_ioctl.c | 3 +++
>>   include/drm/drm_drv.h       | 6 ++++++
>>   include/uapi/drm/drm.h      | 6 ++++++
>>   3 files changed, 15 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
>> index 
>> ff193155129e7e863888d8958458978566b144f8..01592d10e3465ddceddef94bc417f98d3ec12087 100644
>> --- a/drivers/gpu/drm/drm_ioctl.c
>> +++ b/drivers/gpu/drm/drm_ioctl.c
>> @@ -304,6 +304,9 @@ static int drm_getcap(struct drm_device *dev, void 
>> *data, struct drm_file *file_
>>           req->value = drm_core_check_feature(dev, DRIVER_ATOMIC) &&
>>                    dev->mode_config.async_page_flip;
>>           break;
>> +    case DRM_CAP_POST_BLEND_COLOR_PIPELINE:
>> +        req->value = drm_core_check_feature(dev, 
>> DRIVER_POST_BLEND_COLOR_PIPELINE);
>> +        break;
>>       default:
>>           return -EINVAL;
>>       }
>> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
>> index 
>> 42fc085f986dee9261f8b08c4fc7d93b8d6d9769..6b0f4904e69766232283d430c2540d30afef850f 100644
>> --- a/include/drm/drm_drv.h
>> +++ b/include/drm/drm_drv.h
>> @@ -122,6 +122,12 @@ enum drm_driver_feature {
>>        * the cursor planes to work correctly).
>>        */
>>       DRIVER_CURSOR_HOTSPOT           = BIT(9),
>> +    /**
>> +     * @DRIVER_POST_BLEND_COLOR_PIPELINE:
>> +     *
>> +     * Driver supports post-blend color pipeline.
>> +     */
>> +    DRIVER_POST_BLEND_COLOR_PIPELINE        = BIT(10),

Is this to let userspace know that the driver supports a
post-blending color pipeline? Why couldn't userspace simply
check whether crtc objects have "Color Pipeline" properties?

Harry

>>       /* IMPORTANT: Below are all the legacy flags, add new ones 
>> above. */
>> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
>> index 
>> 27cc159c1d275c7a7fe057840ef792f30a582bb7..c6c53e57958e951204154ce41a69696a6876f0e8 100644
>> --- a/include/uapi/drm/drm.h
>> +++ b/include/uapi/drm/drm.h
>> @@ -812,6 +812,12 @@ struct drm_gem_change_handle {
>>    * commits.
>>    */
>>   #define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP    0x15
>> +/**
>> + * DRM_CAP_POST_BLEND_COLOR_PIPELINE
>> + *
>> + * If set to 1, the driver supports post-blend color pipelines.
>> + */
>> +#define DRM_CAP_POST_BLEND_COLOR_PIPELINE    0x16
>>   /* DRM_IOCTL_GET_CAP ioctl argument type */
>>   struct drm_get_cap {
>>
> 



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
  2025-09-18  0:43 ` [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
  2025-09-19 12:42   ` Louis Chauvet
@ 2025-09-29  9:48   ` Harry Wentland
  2025-12-11 15:26     ` Ariel D'Alessandro
  1 sibling, 1 reply; 51+ messages in thread
From: Harry Wentland @ 2025-09-29  9:48 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, louis.chauvet, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



On 2025-09-17 20:43, Nícolas F. R. A. Prado wrote:
> Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE which a DRM client
> can set to enable the usage of post-blend color pipelines instead of the
> now deprecated CRTC color management properties: "GAMMA_LUT",
> "DEGAMMA_LUT" and "CTM".
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   drivers/gpu/drm/drm_atomic_uapi.c   | 15 +++++++++++++++
>   drivers/gpu/drm/drm_connector.c     |  1 +
>   drivers/gpu/drm/drm_crtc_internal.h |  1 +
>   drivers/gpu/drm/drm_ioctl.c         |  9 +++++++++
>   drivers/gpu/drm/drm_mode_object.c   |  9 +++++++++
>   include/drm/drm_file.h              |  7 +++++++
>   include/uapi/drm/drm.h              | 19 +++++++++++++++++++
>   7 files changed, 61 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 063c142fd9b656e228cfc660d005a3fbb4640d32..f5125fa3fa28ff2a6ff07fd7cf07d4bdf77ab738 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -452,6 +452,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
>   	} else if (property == config->prop_vrr_enabled) {
>   		state->vrr_enabled = val;
>   	} else if (property == config->degamma_lut_property) {
> +		if (file_priv->post_blend_color_pipeline) {
> +			drm_dbg_atomic(dev,
> +				"Setting DEGAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
> +			return -EINVAL;
> +		}
>   		ret = drm_property_replace_blob_from_id(dev,
>   					&state->degamma_lut,
>   					val,
> @@ -460,6 +465,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
>   		state->color_mgmt_changed |= replaced;
>   		return ret;
>   	} else if (property == config->ctm_property) {
> +		if (file_priv->post_blend_color_pipeline) {
> +			drm_dbg_atomic(dev,
> +				"Setting CTM CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
> +			return -EINVAL;
> +		}
>   		ret = drm_property_replace_blob_from_id(dev,
>   					&state->ctm,
>   					val,
> @@ -468,6 +478,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
>   		state->color_mgmt_changed |= replaced;
>   		return ret;
>   	} else if (property == config->gamma_lut_property) {
> +		if (file_priv->post_blend_color_pipeline) {
> +			drm_dbg_atomic(dev,
> +				"Setting GAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
> +			return -EINVAL;
> +		}
>   		ret = drm_property_replace_blob_from_id(dev,
>   					&state->gamma_lut,
>   					val,
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 4d6dc9ebfdb5bc730b1aff7a184448af7b93f078..f58cfd2131139ff3e613adc4dbb9ddbedf724dc7 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -3440,6 +3440,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>   	 */
>   	ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
>   			file_priv->plane_color_pipeline,
> +			file_priv->post_blend_color_pipeline,
>   			(uint32_t __user *)(unsigned long)(out_resp->props_ptr),
>   			(uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
>   			&out_resp->count_props);
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index e3dbdcbfa385b940ec0b5476adde6146fe4afde1..c53f154e5392a10c326c844b7321666275f9ac02 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -169,6 +169,7 @@ void drm_mode_object_unregister(struct drm_device *dev,
>   				struct drm_mode_object *object);
>   int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
>   				   bool plane_color_pipeline,
> +				   bool post_blend_color_pipeline,
>   				   uint32_t __user *prop_ptr,
>   				   uint64_t __user *prop_values,
>   				   uint32_t *arg_count_props);
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 01592d10e3465ddceddef94bc417f98d3ec12087..ea9600f5392f520a2b42ba7ef363d2f08ce19812 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -383,6 +383,15 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
>   			return -EINVAL;
>   		file_priv->plane_color_pipeline = req->value;
>   		break;
> +	case DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE:
> +		if (!file_priv->atomic)
> +			return -EINVAL;
> +		if (req->value > 1)
> +			return -EINVAL;
> +		if (!drm_core_check_feature(dev, DRIVER_POST_BLEND_COLOR_PIPELINE))
> +			return -EINVAL;
> +		file_priv->post_blend_color_pipeline = req->value;
> +		break;
>   	default:
>   		return -EINVAL;
>   	}
> diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
> index b45d501b10c868c6d9b7a5a8760eadbd7b372a6a..5e6c3de9456b997985142a68b9cef57771a58bdc 100644
> --- a/drivers/gpu/drm/drm_mode_object.c
> +++ b/drivers/gpu/drm/drm_mode_object.c
> @@ -388,6 +388,7 @@ EXPORT_SYMBOL(drm_object_property_get_default_value);
>   /* helper for getconnector and getproperties ioctls */
>   int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
>   				   bool plane_color_pipeline,
> +				   bool post_blend_color_pipeline,
>   				   uint32_t __user *prop_ptr,
>   				   uint64_t __user *prop_values,
>   				   uint32_t *arg_count_props)
> @@ -416,6 +417,13 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
>   				continue;
>   		}
>   
> +		if (!post_blend_color_pipeline && obj->type == DRM_MODE_OBJECT_CRTC) {
> +			struct drm_crtc *crtc = obj_to_crtc(obj);
> +
> +			if (prop == crtc->color_pipeline_property)
> +				continue;
> +		}
> +
>   		if (*arg_count_props > count) {
>   			ret = __drm_object_property_get_value(obj, prop, &val);
>   			if (ret)
> @@ -475,6 +483,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
>   
>   	ret = drm_mode_object_get_properties(obj, file_priv->atomic,
>   			file_priv->plane_color_pipeline,
> +			file_priv->post_blend_color_pipeline,
>   			(uint32_t __user *)(unsigned long)(arg->props_ptr),
>   			(uint64_t __user *)(unsigned long)(arg->prop_values_ptr),
>   			&arg->count_props);
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index 1a3018e4a537b3341acb50187d47371f6b781b9d..42b9a43baa18079af8ec2ea5b1484b23c497beb0 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -213,6 +213,13 @@ struct drm_file {
>   	 */
>   	bool plane_color_pipeline;
>   
> +	/**
> +	 * @post_blend_color_pipeline:
> +	 *
> +	 * True if client understands post-blend color pipelines
> +	 */
> +	bool post_blend_color_pipeline;
> +
>   	/**
>   	 * @was_master:
>   	 *
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index c6c53e57958e951204154ce41a69696a6876f0e8..f9ac10b3e4876f71005a87dedefa4aed320566f0 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -927,6 +927,25 @@ struct drm_get_cap {
>    */
>   #define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE	7
>   
> +/**
> + * DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE

DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE might be better to align
terminology between pre- and post-blend pipelines. It would
also make it clear that this is about the color pipeline on
a drm_crtc (which pretty much by definition means post-
blending).

Harry

> + *
> + * If set to 1 the DRM core will allow setting the COLOR_PIPELINE
> + * property on a &drm_crtc, as well as drm_colorop properties.
> + *
> + * Setting of these crtc properties will be rejected when this client
> + * cap is set:
> + * - GAMMA_LUT
> + * - DEGAMMA_LUT
> + * - CTM
> + *
> + * The client must enable &DRM_CLIENT_CAP_ATOMIC first.
> + *
> + * This client cap can only be set if the driver sets the corresponding driver
> + * cap &DRM_CAP_POST_BLEND_COLOR_PIPELINE.
> + */
> +#define DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE	8
> +
>   /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
>   struct drm_set_client_cap {
>   	__u64 capability;
> 



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check
  2025-09-18  0:43 ` [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check Nícolas F. R. A. Prado
  2025-09-19 12:41   ` Louis Chauvet
@ 2025-09-29  9:50   ` Harry Wentland
  2025-12-11 15:16     ` Ariel D'Alessandro
  1 sibling, 1 reply; 51+ messages in thread
From: Harry Wentland @ 2025-09-29  9:50 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, louis.chauvet, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



On 2025-09-17 20:43, Nícolas F. R. A. Prado wrote:
> Pass the state of the post-blend color pipeline client cap to the atomic
> state so that drivers can rely on it to enable color pipeline
> functionality and ignore the deprecated color management CRTC
> properties.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   drivers/gpu/drm/drm_atomic_uapi.c |  1 +
>   include/drm/drm_atomic.h          | 20 ++++++++++++++++++++
>   2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index f5125fa3fa28ff2a6ff07fd7cf07d4bdf77ab738..56a440a9390c7730c4c41b491f29b933a2bbb889 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -1660,6 +1660,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
>   	state->acquire_ctx = &ctx;
>   	state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
>   	state->plane_color_pipeline = file_priv->plane_color_pipeline;
> +	state->post_blend_color_pipeline = file_priv->post_blend_color_pipeline;
>   
>   retry:
>   	copied_objs = 0;
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 678708df9cdb90b4266127193a92183069f18688..8c42c584aefbf0034b2163d90538e80099b0dadb 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -482,6 +482,26 @@ struct drm_atomic_state {
>   	 */
>   	bool plane_color_pipeline : 1;
>   
> +	/**
> +	 * @post_blend_color_pipeline:
> +	 *
> +	 * Indicates whether this atomic state originated with a client that
> +	 * set the DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE.
> +	 *
> +	 * Drivers and helper functions should use this to ignore legacy
> +	 * properties that are incompatible with the drm_crtc COLOR_PIPELINE
> +	 * behavior, such as:
> +	 *
> +	 *  - GAMMA_LUT
> +	 *  - DEGAMMA_LUT
> +	 *  - GAMMA_LUT_SIZE
> +	 *  - CTM
> +	 *
> +	 * or any other driver-specific properties that might affect pixel
> +	 * values.
> +	 */
> +	bool post_blend_color_pipeline : 1;

As with the client cap name, I recommend calling this
crtc_color_pipeline.

Harry

> +
>   	/**
>   	 * @colorops:
>   	 *
> 



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (19 preceding siblings ...)
  2025-09-18  0:43 ` [PATCH RFC v2 20/20] drm/vkms: Set post-blend color pipeline driver cap Nícolas F. R. A. Prado
@ 2025-09-29 10:22 ` Harry Wentland
  2025-09-29 12:05 ` Melissa Wen
  21 siblings, 0 replies; 51+ messages in thread
From: Harry Wentland @ 2025-09-29 10:22 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, louis.chauvet, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



On 2025-09-17 20:43, Nícolas F. R. A. Prado wrote:
> This series is based on "Color Pipeline API w/ VKMS" [1]. It reuses the
> same concept of a color pipeline API but for the post-blend stage
> instead of pre-blend, by attaching the COLOR_PIPELINE property to the
> CRTC rather than a plane.
> 
> The patches in the series first implement the necessary changes in the
> DRM core to allow for post-blend color pipelines and expose it through
> the uAPI, and then implement support in both the MediaTek KMS driver and
> in VKMS.
> 
> This series has been tested with IGT, with the "Support post-blend color
> pipeline API" series [2] applied, on top of VKMS, as well as with
> Weston, with a WIP branch [3], on a MT8195-Tomato Chromebook, where both
> gamma LUT and CTM color transformations have been simultaneously
> configured in hardware through the API and validated (test commits for
> weston at [4] and for kernel at [5]).

Thanks for this work. Great to see the concepts translate well
to drm_crtc.

I haven't looked at the Mediatek or VKMS patches but left some
comments on the core patches.

Patches 1-2, 8-12 are
Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> 
> [1] https://lore.kernel.org/all/20250815035047.3319284-1-alex.hung@amd.com/
> [2] https://lore.kernel.org/igt-dev/20250912-post-blend-colorops-v1-0-83fc62420cba@collabora.com/T/#t
> [3] https://gitlab.collabora.com/nfraprado/weston/-/tree/post-blend-colorops?ref_type=heads
> [4] https://gitlab.collabora.com/nfraprado/weston/-/tree/post-blend-color-pipeline-lut-ctm-test?ref_type=tags
> [5] https://gitlab.collabora.com/nfraprado/linux/-/tree/debug-ctm-lut-data-post-blend-colorop?ref_type=tags
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
> Changes in v2:
> - Split core DRM changes for post-blend color pipelines from single
>    commit into smaller changes
> - Added post-blend color pipeline support in VKMS
> - Introduced driver cap, and made client cap depend on it (daniels)
> - Made deprecated color props (GAMMA_LUT, DEGAMMA_LUT, CTM) available as
>    read-only when post-blend color pipelines are enabled (daniels)
> - Created colorop_modeset_lock/unlock to commonize locking pattern for
>    colorops (louis.chauvet)
> - Added helper for post-blend 1D curve colorop creation
> - Link to v1: https://lore.kernel.org/r/20250822-mtk-post-blend-color-pipeline-v1-0-a9446d4aca82@collabora.com
> 
> ---
> Nícolas F. R. A. Prado (20):
>        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_CAP_POST_BLEND_COLOR_PIPELINE
>        drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
>        drm/atomic: Pass post_blend_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/colorop: Export drm_colorop_cleanup() so drivers can extend it
>        drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state
>        drm/mediatek: Support post-blend colorops for gamma and ctm
>        drm/mediatek: ccorr: Support post-blend color pipeline API
>        drm/mediatek: gamma: Support post-blend color pipeline API
>        drm/mediatek: Set post-blend color pipeline driver cap
>        drm/vkms: Rename existing color pipeline helpers to contain "pre_blend"
>        drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines
>        drm/vkms: Introduce support for post-blend color pipeline
>        drm/vkms: Set post-blend color pipeline driver cap
> 
>   drivers/gpu/drm/drm_atomic.c              |   9 +-
>   drivers/gpu/drm/drm_atomic_uapi.c         |  65 +++++++-
>   drivers/gpu/drm/drm_colorop.c             | 245 ++++++++++++++++++++++++------
>   drivers/gpu/drm/drm_connector.c           |   1 +
>   drivers/gpu/drm/drm_crtc.c                |  77 ++++++++++
>   drivers/gpu/drm/drm_crtc_internal.h       |   6 +
>   drivers/gpu/drm/drm_ioctl.c               |  12 ++
>   drivers/gpu/drm/drm_mode_object.c         |   9 ++
>   drivers/gpu/drm/drm_plane.c               |  36 +----
>   drivers/gpu/drm/mediatek/mtk_crtc.c       | 208 ++++++++++++++++++++++++-
>   drivers/gpu/drm/mediatek/mtk_ddp_comp.c   |   6 +-
>   drivers/gpu/drm/mediatek/mtk_ddp_comp.h   |   2 +
>   drivers/gpu/drm/mediatek/mtk_disp_ccorr.c | 100 ++++++++++--
>   drivers/gpu/drm/mediatek/mtk_disp_drv.h   |   6 +-
>   drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 107 ++++++++++---
>   drivers/gpu/drm/mediatek/mtk_drm_drv.c    |   3 +-
>   drivers/gpu/drm/vkms/vkms_colorop.c       | 106 ++++++++++++-
>   drivers/gpu/drm/vkms/vkms_composer.c      |  13 +-
>   drivers/gpu/drm/vkms/vkms_crtc.c          |   1 +
>   drivers/gpu/drm/vkms/vkms_drv.c           |   3 +-
>   drivers/gpu/drm/vkms/vkms_drv.h           |   3 +-
>   drivers/gpu/drm/vkms/vkms_plane.c         |   2 +-
>   include/drm/drm_atomic.h                  |  20 +++
>   include/drm/drm_atomic_uapi.h             |   2 +
>   include/drm/drm_colorop.h                 |  22 ++-
>   include/drm/drm_crtc.h                    |  27 ++++
>   include/drm/drm_drv.h                     |   6 +
>   include/drm/drm_file.h                    |   7 +
>   include/uapi/drm/drm.h                    |  25 +++
>   29 files changed, 994 insertions(+), 135 deletions(-)
> ---
> base-commit: 342e5ee08797cde0e8af30e6110a5dc1cba61e9c
> change-id: 20250730-mtk-post-blend-color-pipeline-498e1a9cc53e
> 
> Best regards,



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline
  2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
                   ` (20 preceding siblings ...)
  2025-09-29 10:22 ` [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Harry Wentland
@ 2025-09-29 12:05 ` Melissa Wen
  2025-09-29 14:25   ` Harry Wentland
  21 siblings, 1 reply; 51+ messages in thread
From: Melissa Wen @ 2025-09-29 12:05 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, jadahl, sebastian.wick, shashank.sharma,
	agoins, joshua, mdaenzer, aleixpol, xaver.hugl, victoria,
	uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk, marcan,
	Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, louis.chauvet,
	mcanal, kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



On 17/09/2025 21:43, Nícolas F. R. A. Prado wrote:
> This series is based on "Color Pipeline API w/ VKMS" [1]. It reuses the
> same concept of a color pipeline API but for the post-blend stage
> instead of pre-blend, by attaching the COLOR_PIPELINE property to the
> CRTC rather than a plane.

Hi all,

I'm confused about the timing of this series being reviewed.
Hadn't we agreed in past hackfest on discussing post-blending color API 
only after we have sorted out pre-blending color properties?
There are still open questions around color_encoding and color_range, 
for example...
How assertive can we be evaluating the post-blending API now?

Best Regards,

Melissa

>
> The patches in the series first implement the necessary changes in the
> DRM core to allow for post-blend color pipelines and expose it through
> the uAPI, and then implement support in both the MediaTek KMS driver and
> in VKMS.
>
> This series has been tested with IGT, with the "Support post-blend color
> pipeline API" series [2] applied, on top of VKMS, as well as with
> Weston, with a WIP branch [3], on a MT8195-Tomato Chromebook, where both
> gamma LUT and CTM color transformations have been simultaneously
> configured in hardware through the API and validated (test commits for
> weston at [4] and for kernel at [5]).
>
> [1] https://lore.kernel.org/all/20250815035047.3319284-1-alex.hung@amd.com/
> [2] https://lore.kernel.org/igt-dev/20250912-post-blend-colorops-v1-0-83fc62420cba@collabora.com/T/#t
> [3] https://gitlab.collabora.com/nfraprado/weston/-/tree/post-blend-colorops?ref_type=heads
> [4] https://gitlab.collabora.com/nfraprado/weston/-/tree/post-blend-color-pipeline-lut-ctm-test?ref_type=tags
> [5] https://gitlab.collabora.com/nfraprado/linux/-/tree/debug-ctm-lut-data-post-blend-colorop?ref_type=tags
>
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
> Changes in v2:
> - Split core DRM changes for post-blend color pipelines from single
>    commit into smaller changes
> - Added post-blend color pipeline support in VKMS
> - Introduced driver cap, and made client cap depend on it (daniels)
> - Made deprecated color props (GAMMA_LUT, DEGAMMA_LUT, CTM) available as
>    read-only when post-blend color pipelines are enabled (daniels)
> - Created colorop_modeset_lock/unlock to commonize locking pattern for
>    colorops (louis.chauvet)
> - Added helper for post-blend 1D curve colorop creation
> - Link to v1: https://lore.kernel.org/r/20250822-mtk-post-blend-color-pipeline-v1-0-a9446d4aca82@collabora.com
>
> ---
> Nícolas F. R. A. Prado (20):
>        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_CAP_POST_BLEND_COLOR_PIPELINE
>        drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
>        drm/atomic: Pass post_blend_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/colorop: Export drm_colorop_cleanup() so drivers can extend it
>        drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state
>        drm/mediatek: Support post-blend colorops for gamma and ctm
>        drm/mediatek: ccorr: Support post-blend color pipeline API
>        drm/mediatek: gamma: Support post-blend color pipeline API
>        drm/mediatek: Set post-blend color pipeline driver cap
>        drm/vkms: Rename existing color pipeline helpers to contain "pre_blend"
>        drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines
>        drm/vkms: Introduce support for post-blend color pipeline
>        drm/vkms: Set post-blend color pipeline driver cap
>
>   drivers/gpu/drm/drm_atomic.c              |   9 +-
>   drivers/gpu/drm/drm_atomic_uapi.c         |  65 +++++++-
>   drivers/gpu/drm/drm_colorop.c             | 245 ++++++++++++++++++++++++------
>   drivers/gpu/drm/drm_connector.c           |   1 +
>   drivers/gpu/drm/drm_crtc.c                |  77 ++++++++++
>   drivers/gpu/drm/drm_crtc_internal.h       |   6 +
>   drivers/gpu/drm/drm_ioctl.c               |  12 ++
>   drivers/gpu/drm/drm_mode_object.c         |   9 ++
>   drivers/gpu/drm/drm_plane.c               |  36 +----
>   drivers/gpu/drm/mediatek/mtk_crtc.c       | 208 ++++++++++++++++++++++++-
>   drivers/gpu/drm/mediatek/mtk_ddp_comp.c   |   6 +-
>   drivers/gpu/drm/mediatek/mtk_ddp_comp.h   |   2 +
>   drivers/gpu/drm/mediatek/mtk_disp_ccorr.c | 100 ++++++++++--
>   drivers/gpu/drm/mediatek/mtk_disp_drv.h   |   6 +-
>   drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 107 ++++++++++---
>   drivers/gpu/drm/mediatek/mtk_drm_drv.c    |   3 +-
>   drivers/gpu/drm/vkms/vkms_colorop.c       | 106 ++++++++++++-
>   drivers/gpu/drm/vkms/vkms_composer.c      |  13 +-
>   drivers/gpu/drm/vkms/vkms_crtc.c          |   1 +
>   drivers/gpu/drm/vkms/vkms_drv.c           |   3 +-
>   drivers/gpu/drm/vkms/vkms_drv.h           |   3 +-
>   drivers/gpu/drm/vkms/vkms_plane.c         |   2 +-
>   include/drm/drm_atomic.h                  |  20 +++
>   include/drm/drm_atomic_uapi.h             |   2 +
>   include/drm/drm_colorop.h                 |  22 ++-
>   include/drm/drm_crtc.h                    |  27 ++++
>   include/drm/drm_drv.h                     |   6 +
>   include/drm/drm_file.h                    |   7 +
>   include/uapi/drm/drm.h                    |  25 +++
>   29 files changed, 994 insertions(+), 135 deletions(-)
> ---
> base-commit: 342e5ee08797cde0e8af30e6110a5dc1cba61e9c
> change-id: 20250730-mtk-post-blend-color-pipeline-498e1a9cc53e
>
> Best regards,



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline
  2025-09-29 12:05 ` Melissa Wen
@ 2025-09-29 14:25   ` Harry Wentland
  0 siblings, 0 replies; 51+ messages in thread
From: Harry Wentland @ 2025-09-29 14:25 UTC (permalink / raw)
  To: Melissa Wen, Nícolas F. R. A. Prado, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, jadahl, sebastian.wick, shashank.sharma, agoins, joshua,
	mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, louis.chauvet, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter



On 2025-09-29 08:05, Melissa Wen wrote:
> 
> 
> On 17/09/2025 21:43, Nícolas F. R. A. Prado wrote:
>> This series is based on "Color Pipeline API w/ VKMS" [1]. It reuses the
>> same concept of a color pipeline API but for the post-blend stage
>> instead of pre-blend, by attaching the COLOR_PIPELINE property to the
>> CRTC rather than a plane.
> 
> Hi all,
> 
> I'm confused about the timing of this series being reviewed.
> Hadn't we agreed in past hackfest on discussing post-blending color API 
> only after we have sorted out pre-blending color properties?

I don't think it's a problem to have people with bandwidth looking
at the post-blending portion, especially if they weren't involved
in the pre-blending patchset.

I find it helpful to look at this and it proofs (to me) that the
direction of the pre-blending design is correct. I don't (necessarily) 
like how it re-opens questions that we discussed previously, such
as hiding legacy properties, and would be hesitant to change this
on the pre-blending patches and therefore delay the merge even
further.

> There are still open questions around color_encoding and color_range, 
> for example...

I apologize if I missed key bits that might require attention. Could
you elaborate on the open questions?

> How assertive can we be evaluating the post-blending API now?

As people wait on the pre-blending pipeline to merged it makes sense
to start looking at the next steps.

I would like the IGT patches to be reviewed before we merge the pre-
blending pipeline. Otherwise I think it's ready.

Harry

> 
> Best Regards,
> 
> Melissa
> 
>>
>> The patches in the series first implement the necessary changes in the
>> DRM core to allow for post-blend color pipelines and expose it through
>> the uAPI, and then implement support in both the MediaTek KMS driver and
>> in VKMS.
>>
>> This series has been tested with IGT, with the "Support post-blend color
>> pipeline API" series [2] applied, on top of VKMS, as well as with
>> Weston, with a WIP branch [3], on a MT8195-Tomato Chromebook, where both
>> gamma LUT and CTM color transformations have been simultaneously
>> configured in hardware through the API and validated (test commits for
>> weston at [4] and for kernel at [5]).
>>
>> [1] https://lore.kernel.org/all/20250815035047.3319284-1- 
>> alex.hung@amd.com/
>> [2] https://lore.kernel.org/igt-dev/20250912-post-blend-colorops- 
>> v1-0-83fc62420cba@collabora.com/T/#t
>> [3] https://gitlab.collabora.com/nfraprado/weston/-/tree/post-blend- 
>> colorops?ref_type=heads
>> [4] https://gitlab.collabora.com/nfraprado/weston/-/tree/post-blend- 
>> color-pipeline-lut-ctm-test?ref_type=tags
>> [5] https://gitlab.collabora.com/nfraprado/linux/-/tree/debug-ctm-lut- 
>> data-post-blend-colorop?ref_type=tags
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>> ---
>> Changes in v2:
>> - Split core DRM changes for post-blend color pipelines from single
>>    commit into smaller changes
>> - Added post-blend color pipeline support in VKMS
>> - Introduced driver cap, and made client cap depend on it (daniels)
>> - Made deprecated color props (GAMMA_LUT, DEGAMMA_LUT, CTM) available as
>>    read-only when post-blend color pipelines are enabled (daniels)
>> - Created colorop_modeset_lock/unlock to commonize locking pattern for
>>    colorops (louis.chauvet)
>> - Added helper for post-blend 1D curve colorop creation
>> - Link to v1: https://lore.kernel.org/r/20250822-mtk-post-blend-color- 
>> pipeline-v1-0-a9446d4aca82@collabora.com
>>
>> ---
>> Nícolas F. R. A. Prado (20):
>>        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_CAP_POST_BLEND_COLOR_PIPELINE
>>        drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
>>        drm/atomic: Pass post_blend_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/colorop: Export drm_colorop_cleanup() so drivers can extend it
>>        drm/crtc: Track post-blend color pipeline client cap in 
>> drm_crtc_state
>>        drm/mediatek: Support post-blend colorops for gamma and ctm
>>        drm/mediatek: ccorr: Support post-blend color pipeline API
>>        drm/mediatek: gamma: Support post-blend color pipeline API
>>        drm/mediatek: Set post-blend color pipeline driver cap
>>        drm/vkms: Rename existing color pipeline helpers to contain 
>> "pre_blend"
>>        drm/vkms: Prepare pre_blend_color_transform() for post-blend 
>> pipelines
>>        drm/vkms: Introduce support for post-blend color pipeline
>>        drm/vkms: Set post-blend color pipeline driver cap
>>
>>   drivers/gpu/drm/drm_atomic.c              |   9 +-
>>   drivers/gpu/drm/drm_atomic_uapi.c         |  65 +++++++-
>>   drivers/gpu/drm/drm_colorop.c             | 245 ++++++++++++++++++++ 
>> ++++------
>>   drivers/gpu/drm/drm_connector.c           |   1 +
>>   drivers/gpu/drm/drm_crtc.c                |  77 ++++++++++
>>   drivers/gpu/drm/drm_crtc_internal.h       |   6 +
>>   drivers/gpu/drm/drm_ioctl.c               |  12 ++
>>   drivers/gpu/drm/drm_mode_object.c         |   9 ++
>>   drivers/gpu/drm/drm_plane.c               |  36 +----
>>   drivers/gpu/drm/mediatek/mtk_crtc.c       | 208 ++++++++++++++++++++ 
>> ++++-
>>   drivers/gpu/drm/mediatek/mtk_ddp_comp.c   |   6 +-
>>   drivers/gpu/drm/mediatek/mtk_ddp_comp.h   |   2 +
>>   drivers/gpu/drm/mediatek/mtk_disp_ccorr.c | 100 ++++++++++--
>>   drivers/gpu/drm/mediatek/mtk_disp_drv.h   |   6 +-
>>   drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 107 ++++++++++---
>>   drivers/gpu/drm/mediatek/mtk_drm_drv.c    |   3 +-
>>   drivers/gpu/drm/vkms/vkms_colorop.c       | 106 ++++++++++++-
>>   drivers/gpu/drm/vkms/vkms_composer.c      |  13 +-
>>   drivers/gpu/drm/vkms/vkms_crtc.c          |   1 +
>>   drivers/gpu/drm/vkms/vkms_drv.c           |   3 +-
>>   drivers/gpu/drm/vkms/vkms_drv.h           |   3 +-
>>   drivers/gpu/drm/vkms/vkms_plane.c         |   2 +-
>>   include/drm/drm_atomic.h                  |  20 +++
>>   include/drm/drm_atomic_uapi.h             |   2 +
>>   include/drm/drm_colorop.h                 |  22 ++-
>>   include/drm/drm_crtc.h                    |  27 ++++
>>   include/drm/drm_drv.h                     |   6 +
>>   include/drm/drm_file.h                    |   7 +
>>   include/uapi/drm/drm.h                    |  25 +++
>>   29 files changed, 994 insertions(+), 135 deletions(-)
>> ---
>> base-commit: 342e5ee08797cde0e8af30e6110a5dc1cba61e9c
>> change-id: 20250730-mtk-post-blend-color-pipeline-498e1a9cc53e
>>
>> Best regards,
> 



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 05/20] drm: Introduce DRM_CAP_POST_BLEND_COLOR_PIPELINE
  2025-09-29  9:40     ` Harry Wentland
@ 2025-09-29 16:00       ` Nícolas F. R. A. Prado
  0 siblings, 0 replies; 51+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-09-29 16:00 UTC (permalink / raw)
  To: Harry Wentland, Louis Chauvet, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, AngeloGioacchino Del Regno,
	Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, mcanal, kernel, daniels,
	leandro.ribeiro, dri-devel, linux-kernel, linux-mediatek,
	linux-arm-kernel, Simona Vetter

On Mon, 2025-09-29 at 05:40 -0400, Harry Wentland wrote:
> 
> 
> On 2025-09-19 08:42, Louis Chauvet wrote:
> > 
> > 
> > Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> > > Add a new cap that drivers can set to signal they support post-
> > > blend
> > > color pipelines.
> > > 
> > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> > 
> > Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
> > 
> > > ---
> > >   drivers/gpu/drm/drm_ioctl.c | 3 +++
> > >   include/drm/drm_drv.h       | 6 ++++++
> > >   include/uapi/drm/drm.h      | 6 ++++++
> > >   3 files changed, 15 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_ioctl.c
> > > b/drivers/gpu/drm/drm_ioctl.c
> > > index 
> > > ff193155129e7e863888d8958458978566b144f8..01592d10e3465ddceddef94
> > > bc417f98d3ec12087 100644
> > > --- a/drivers/gpu/drm/drm_ioctl.c
> > > +++ b/drivers/gpu/drm/drm_ioctl.c
> > > @@ -304,6 +304,9 @@ static int drm_getcap(struct drm_device *dev,
> > > void 
> > > *data, struct drm_file *file_
> > >           req->value = drm_core_check_feature(dev, DRIVER_ATOMIC)
> > > &&
> > >                    dev->mode_config.async_page_flip;
> > >           break;
> > > +    case DRM_CAP_POST_BLEND_COLOR_PIPELINE:
> > > +        req->value = drm_core_check_feature(dev, 
> > > DRIVER_POST_BLEND_COLOR_PIPELINE);
> > > +        break;
> > >       default:
> > >           return -EINVAL;
> > >       }
> > > diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> > > index 
> > > 42fc085f986dee9261f8b08c4fc7d93b8d6d9769..6b0f4904e69766232283d43
> > > 0c2540d30afef850f 100644
> > > --- a/include/drm/drm_drv.h
> > > +++ b/include/drm/drm_drv.h
> > > @@ -122,6 +122,12 @@ enum drm_driver_feature {
> > >        * the cursor planes to work correctly).
> > >        */
> > >       DRIVER_CURSOR_HOTSPOT           = BIT(9),
> > > +    /**
> > > +     * @DRIVER_POST_BLEND_COLOR_PIPELINE:
> > > +     *
> > > +     * Driver supports post-blend color pipeline.
> > > +     */
> > > +    DRIVER_POST_BLEND_COLOR_PIPELINE        = BIT(10),
> 
> Is this to let userspace know that the driver supports a
> post-blending color pipeline? Why couldn't userspace simply
> check whether crtc objects have "Color Pipeline" properties?

It is, and yes userspace could figure it out that way, though since the
property is only exposed after the client cap is set, it requires a
more involved setup: set the client cap, check for the property, if not
present unset the client cap.

With the driver cap introduced here, setting the client cap would fail
in the first place if the driver cap is not set, so in this case
userspace just tries to set the client cap, if it succeeds it knows it
can use color pipelines, if it fails it knows to use the legacy color
properties.

-- 
Thanks,

Nícolas

> 
> Harry
> 
> > >       /* IMPORTANT: Below are all the legacy flags, add new ones 
> > > above. */
> > > diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> > > index 
> > > 27cc159c1d275c7a7fe057840ef792f30a582bb7..c6c53e57958e951204154ce
> > > 41a69696a6876f0e8 100644
> > > --- a/include/uapi/drm/drm.h
> > > +++ b/include/uapi/drm/drm.h
> > > @@ -812,6 +812,12 @@ struct drm_gem_change_handle {
> > >    * commits.
> > >    */
> > >   #define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP    0x15
> > > +/**
> > > + * DRM_CAP_POST_BLEND_COLOR_PIPELINE
> > > + *
> > > + * If set to 1, the driver supports post-blend color pipelines.
> > > + */
> > > +#define DRM_CAP_POST_BLEND_COLOR_PIPELINE    0x16
> > >   /* DRM_IOCTL_GET_CAP ioctl argument type */
> > >   struct drm_get_cap {
> > > 
> > 


^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code
  2025-09-29  8:53   ` Harry Wentland
@ 2025-12-10 20:19     ` Ariel D'Alessandro
  0 siblings, 0 replies; 51+ messages in thread
From: Ariel D'Alessandro @ 2025-12-10 20:19 UTC (permalink / raw)
  To: Harry Wentland, Nícolas F. R. A. Prado, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, louis.chauvet, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter

Harry,

Following up on Nicolas' series.

On 9/29/25 5:53 AM, Harry Wentland wrote:
> 
> 
> On 2025-09-17 20:43, Nícolas F. R. A. Prado wrote:
>> In preparation for sharing the initialization code for the color
>> pipeline property between pre- and post-blend color pipelines, factor
>> out the common initialization to a separate function.
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>> ---
>>   drivers/gpu/drm/drm_crtc.c          | 44 +++++++++++++++++++++++++++ 
>> ++++++++++
>>   drivers/gpu/drm/drm_crtc_internal.h |  5 +++++
>>   drivers/gpu/drm/drm_plane.c         | 36 +++++-------------------------
>>   3 files changed, 54 insertions(+), 31 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
>> index 
>> 46655339003db2a1b43441434839e26f61d79b4e..94e60cffd29972aa979ac2f1932be7a6a97f3ada 100644
>> --- a/drivers/gpu/drm/drm_crtc.c
>> +++ b/drivers/gpu/drm/drm_crtc.c
>> @@ -959,3 +959,47 @@ bool drm_crtc_in_clone_mode(struct drm_crtc_state 
>> *crtc_state)
>>       return hweight32(crtc_state->encoder_mask) > 1;
>>   }
>>   EXPORT_SYMBOL(drm_crtc_in_clone_mode);
>> +
>> +struct drm_property *
>> +drm_common_create_color_pipeline_property(struct drm_device *dev, 
>> struct drm_mode_object *obj,
>> +                      const struct drm_prop_enum_list *pipelines,
>> +                      int num_pipelines)
> 
> All other functions I see in drm_crtc seem to be quite crtc
> specific. Would there be a better place to put this? Possibly
> a new file if nothing else seems to fit?
> 
> Not a blocker in any way, though.
Agreed. I think drivers/gpu/drm/drm_property.c would be a better place, 
as it contains functions to create the different types of drm_property 
already.

Will submit a proposal in v3.

Thanks,
Ariel

-- 
Ariel D'Alessandro
Software Engineer

Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK 
Registered in England & Wales, no. 5513718



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 02/20] drm/colorop: Allow parenting colorop to CRTC
  2025-09-19 12:44   ` Louis Chauvet
@ 2025-12-10 20:49     ` Ariel D'Alessandro
  0 siblings, 0 replies; 51+ messages in thread
From: Ariel D'Alessandro @ 2025-12-10 20:49 UTC (permalink / raw)
  To: Louis Chauvet, Nícolas F. R. A. Prado, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter

Louis,

Following up on Nicolas' series.

On 9/19/25 9:44 AM, Louis Chauvet wrote:
> 
> 
> Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
>> In order to allow for post-blend color pipelines, colorops need to be
>> assigned to a crtc rather than a plane. Add a crtc to the colorop
>> struct to enable this. Either the plane or the crtc will be set for any
>> given colorop depending on whether it is part of a pre- or post-blend
>> color pipeline.
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>> ---
>>   include/drm/drm_colorop.h | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
>> index 
>> d61c6c40e47162cb8b1e7db58b6746c43ac5d202..7a4e0d0c4a3d594abecef304b1d5990434cdb231 100644
>> --- a/include/drm/drm_colorop.h
>> +++ b/include/drm/drm_colorop.h
>> @@ -206,10 +206,16 @@ struct drm_colorop {
>>       /**
>>        * @plane:
>>        *
>> -     * The plane on which the colorop sits. A drm_colorop is always 
>> unique
>> -     * to a plane.
>> +     * The plane on which the colorop sits if it is a pre-blend colorop.
>> +     * In this case it is unique to the plane.
>> +     *
>> +     * @crtc:
>> +     *
>> +     * The CRTC on which the colorop sits if it is a post-blend colorop.
>> +     * In this case it is unique to the CRTC.
>>        */
> 
> If there is a v3 of this series, I think it could be nice to have 
> something like "plane and CRTC are mutually exclusive".

Sounds good, will add in v3.

> 
> With or without this:
> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

Thanks,

-- 
Ariel D'Alessandro
Software Engineer

Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK 
Registered in England & Wales, no. 5513718



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 04/20] drm/crtc: Add COLOR_PIPELINE property
  2025-09-19 12:43   ` Louis Chauvet
@ 2025-12-10 21:00     ` Ariel D'Alessandro
  0 siblings, 0 replies; 51+ messages in thread
From: Ariel D'Alessandro @ 2025-12-10 21:00 UTC (permalink / raw)
  To: Louis Chauvet, Nícolas F. R. A. Prado, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter

Louis,

On 9/19/25 9:43 AM, Louis Chauvet wrote:
> 
> 
> Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
>> Add a COLOR_PIPELINE property to the CRTC to allow userspace to set a
>> post-blend color pipeline analogously to how pre-blend color pipelines
>> are set on planes.
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>> ---
>>   drivers/gpu/drm/drm_atomic_uapi.c | 49 +++++++++++++++++++++++++++++ 
>> ++++++----
>>   drivers/gpu/drm/drm_crtc.c        | 33 ++++++++++++++++++++++++++
>>   include/drm/drm_atomic_uapi.h     |  2 ++
>>   include/drm/drm_crtc.h            | 11 +++++++++
>>   4 files changed, 91 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/ 
>> drm_atomic_uapi.c
>> index 
>> b7cc6945864274bedd21dd5b73494f9aae216888..063c142fd9b656e228cfc660d005a3fbb4640d32 100644
>> --- a/drivers/gpu/drm/drm_atomic_uapi.c
>> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
>> @@ -287,6 +287,33 @@ drm_atomic_set_colorop_for_plane(struct 
>> drm_plane_state *plane_state,
>>   }
>>   EXPORT_SYMBOL(drm_atomic_set_colorop_for_plane);
>> +/**
>> + * drm_atomic_set_colorop_for_crtc - set colorop for crtc
>> + * @crtc_state: atomic state object for the crtc
>> + * @colorop: colorop to use for the crtc
>> + *
>> + * Helper function to select the color pipeline on a crtc by setting
>> + * it to the first drm_colorop element of the pipeline.
>> + */
>> +void
>> +drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
>> +                 struct drm_colorop *colorop)
>> +{
>> +    struct drm_crtc *crtc = crtc_state->crtc;
>> +
>> +    if (colorop)
>> +        drm_dbg_atomic(crtc->dev,
>> +                   "Set [COLOROP:%d] for [CRTC:%d:%s] state %p\n",
>> +                   colorop->base.id, crtc->base.id, crtc->name,
>> +                   crtc_state);
>> +    else
>> +        drm_dbg_atomic(crtc->dev,
>> +                   "Set [NOCOLOROP] for [CRTC:%d:%s] state %p\n",
>> +                   crtc->base.id, crtc->name, crtc_state);
>> +
>> +    crtc_state->color_pipeline = colorop;
>> +}
>> +EXPORT_SYMBOL(drm_atomic_set_colorop_for_crtc);
>>   /**
>>    * drm_atomic_set_crtc_for_connector - set CRTC for connector
>> @@ -396,8 +423,8 @@ static s32 __user 
>> *get_out_fence_for_connector(struct drm_atomic_state *state,
>>   }
>>   static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
>> -        struct drm_crtc_state *state, struct drm_property *property,
>> -        uint64_t val)
>> +        struct drm_crtc_state *state, struct drm_file *file_priv,
>> +        struct drm_property *property, uint64_t val)
>>   {
>>       struct drm_device *dev = crtc->dev;
>>       struct drm_mode_config *config = &dev->mode_config;
>> @@ -406,7 +433,17 @@ static int drm_atomic_crtc_set_property(struct 
>> drm_crtc *crtc,
>>       if (property == config->prop_active)
>>           state->active = val;
>> -    else if (property == config->prop_mode_id) {
>> +    else if (property == crtc->color_pipeline_property) {
>> +        /* find DRM colorop object */
>> +        struct drm_colorop *colorop = NULL;
>> +
>> +        colorop = drm_colorop_find(dev, file_priv, val);
>> +
>> +        if (val && !colorop)
>> +            return -EACCES;
>> +
>> +        drm_atomic_set_colorop_for_crtc(state, colorop);
> 
> I don't know if this is needed, but you added a warning/early return for 
> ctm/degamma_lut if file_priv->post_blend_color_pipeline is true.
> 
> Does it make sense to add this?
> 
>      if (!file_priv->post_blend_color_pipeline) {
>              drm_dbg_atomic(dev,
>                  "Setting COLOR_PIPELINE property not permitted without 
> DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
>              return -EINVAL;
>          }

Indeed that makes sense. Will add in v3.

Thanks,

-- 
Ariel D'Alessandro
Software Engineer

Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK 
Registered in England & Wales, no. 5513718



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 19/20] drm/vkms: Introduce support for post-blend color pipeline
  2025-09-19 12:50   ` Louis Chauvet
@ 2025-12-10 21:15     ` Ariel D'Alessandro
  0 siblings, 0 replies; 51+ messages in thread
From: Ariel D'Alessandro @ 2025-12-10 21:15 UTC (permalink / raw)
  To: Louis Chauvet, Nícolas F. R. A. Prado, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, harry.wentland, leo.liu, ville.syrjala,
	pekka.paalanen, contact, mwen, jadahl, sebastian.wick,
	shashank.sharma, agoins, joshua, mdaenzer, aleixpol, xaver.hugl,
	victoria, uma.shankar, quic_naseer, quic_cbraga, quic_abhinavk,
	marcan, Liviu.Dudau, sashamcintosh, chaitanya.kumar.borah, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter

Louis,

On 9/19/25 9:50 AM, Louis Chauvet wrote:
> 
> 
> Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
>> Introduce a post-blend color pipeline with the same colorop blocks as
>> the pre-blend color pipeline.
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>> ---
>>   drivers/gpu/drm/vkms/vkms_colorop.c  | 98 ++++++++++++++++++++++++++ 
>> ++++++++++
>>   drivers/gpu/drm/vkms/vkms_composer.c |  5 +-
>>   drivers/gpu/drm/vkms/vkms_crtc.c     |  1 +
>>   drivers/gpu/drm/vkms/vkms_drv.h      |  1 +
>>   4 files changed, 104 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/ 
>> vkms/vkms_colorop.c
>> index 
>> 5924ae2bd40fc904048f99bc9b96308140709e25..54c512db68eef16435d5f79453784f7784d540fb 100644
>> --- a/drivers/gpu/drm/vkms/vkms_colorop.c
>> +++ b/drivers/gpu/drm/vkms/vkms_colorop.c
>> @@ -98,6 +98,86 @@ vkms_initialize_pre_blend_color_pipeline(struct 
>> drm_plane *plane,
>>       return ret;
>>   }
>> +static int
>> +vkms_initialize_post_blend_color_pipeline(struct drm_crtc *crtc,
>> +                      struct drm_prop_enum_list *list)
>> +{
>> +    struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
>> +    struct drm_device *dev = crtc->dev;
>> +    int ret;
>> +    int i = 0;
>> +
>> +    memset(ops, 0, sizeof(ops));
>> +
>> +    /* 1st op: 1d curve */
>> +    ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
>> +    if (!ops[i]) {
>> +        ret = -ENOMEM;
>> +        goto cleanup;
>> +    }
>> +
>> +    ret = drm_crtc_colorop_curve_1d_init(dev, ops[i], crtc, 
>> supported_tfs,
>> +                         DRM_COLOROP_FLAG_ALLOW_BYPASS);
>> +    if (ret)
>> +        goto cleanup;
>> +
>> +    list->type = ops[i]->base.id;
>> +    list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]- 
>> >base.id);
>> +
>> +    i++;
>> +
>> +    /* 2nd op: 3x4 matrix */
>> +    ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
>> +    if (!ops[i]) {
>> +        ret = -ENOMEM;
>> +        goto cleanup;
>> +    }
>> +
>> +    ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, 
>> DRM_COLOROP_FLAG_ALLOW_BYPASS);
>> +    if (ret)
>> +        goto cleanup;
>> +
>> +    drm_colorop_set_next_property(ops[i - 1], ops[i]);
>> +
>> +    i++;
>> +
>> +    /* 3rd op: 3x4 matrix */
>> +    ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
>> +    if (!ops[i]) {
>> +        ret = -ENOMEM;
>> +        goto cleanup;
>> +    }
>> +
>> +    ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, 
>> DRM_COLOROP_FLAG_ALLOW_BYPASS);
>> +    if (ret)
>> +        goto cleanup;
>> +
>> +    drm_colorop_set_next_property(ops[i - 1], ops[i]);
>> +
>> +    i++;
>> +
>> +    /* 4th op: 1d curve */
>> +    ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL);
>> +    if (!ops[i]) {
>> +        ret = -ENOMEM;
>> +        goto cleanup;
>> +    }
>> +
>> +    ret = drm_crtc_colorop_curve_1d_init(dev, ops[i], crtc, 
>> supported_tfs,
>> +                         DRM_COLOROP_FLAG_ALLOW_BYPASS);
>> +    if (ret)
>> +        goto cleanup;
>> +
>> +    drm_colorop_set_next_property(ops[i - 1], ops[i]);
>> +
>> +    return 0;
>> +
>> +cleanup:
>> +    drm_colorop_pipeline_destroy(dev);
> 
> Same comment as for pre_blend colorops, it feel strange to destroy all 
> the pipelines here.
> 
> The suggestion in [1] is better (don't forget to add the kfree).
> 
> [1]: https://lore.kernel.org/all/73f01810-df2d-4e39-a20b- 
> fc1cec2c5e12@amd.com/
Ack, will be addressed in v3.

Regards,

-- 
Ariel D'Alessandro
Software Engineer

Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK 
Registered in England & Wales, no. 5513718



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check
  2025-09-29  9:50   ` Harry Wentland
@ 2025-12-11 15:16     ` Ariel D'Alessandro
  0 siblings, 0 replies; 51+ messages in thread
From: Ariel D'Alessandro @ 2025-12-11 15:16 UTC (permalink / raw)
  To: Harry Wentland, Nícolas F. R. A. Prado, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, louis.chauvet, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter

Harry,

On 9/29/25 6:50 AM, Harry Wentland wrote:
> 
> 
> On 2025-09-17 20:43, Nícolas F. R. A. Prado wrote:
>> Pass the state of the post-blend color pipeline client cap to the atomic
>> state so that drivers can rely on it to enable color pipeline
>> functionality and ignore the deprecated color management CRTC
>> properties.
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>> ---
>>   drivers/gpu/drm/drm_atomic_uapi.c |  1 +
>>   include/drm/drm_atomic.h          | 20 ++++++++++++++++++++
>>   2 files changed, 21 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/ 
>> drm_atomic_uapi.c
>> index 
>> f5125fa3fa28ff2a6ff07fd7cf07d4bdf77ab738..56a440a9390c7730c4c41b491f29b933a2bbb889 100644
>> --- a/drivers/gpu/drm/drm_atomic_uapi.c
>> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
>> @@ -1660,6 +1660,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
>>       state->acquire_ctx = &ctx;
>>       state->allow_modeset = !!(arg->flags & 
>> DRM_MODE_ATOMIC_ALLOW_MODESET);
>>       state->plane_color_pipeline = file_priv->plane_color_pipeline;
>> +    state->post_blend_color_pipeline = file_priv- 
>> >post_blend_color_pipeline;
>>   retry:
>>       copied_objs = 0;
>> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
>> index 
>> 678708df9cdb90b4266127193a92183069f18688..8c42c584aefbf0034b2163d90538e80099b0dadb 100644
>> --- a/include/drm/drm_atomic.h
>> +++ b/include/drm/drm_atomic.h
>> @@ -482,6 +482,26 @@ struct drm_atomic_state {
>>        */
>>       bool plane_color_pipeline : 1;
>> +    /**
>> +     * @post_blend_color_pipeline:
>> +     *
>> +     * Indicates whether this atomic state originated with a client that
>> +     * set the DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE.
>> +     *
>> +     * Drivers and helper functions should use this to ignore legacy
>> +     * properties that are incompatible with the drm_crtc COLOR_PIPELINE
>> +     * behavior, such as:
>> +     *
>> +     *  - GAMMA_LUT
>> +     *  - DEGAMMA_LUT
>> +     *  - GAMMA_LUT_SIZE
>> +     *  - CTM
>> +     *
>> +     * or any other driver-specific properties that might affect pixel
>> +     * values.
>> +     */
>> +    bool post_blend_color_pipeline : 1;
> 
> As with the client cap name, I recommend calling this
> crtc_color_pipeline.

Agreed. As per the rest of the comments, I think it's worth moving all 
naming in this series from post_blend to crtc, matching the criteria 
used in plane (a.k.a. pre-blend) color pipelines.

Will submit the related changes in v3.

Regards,

-- 
Ariel D'Alessandro
Software Engineer

Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK 
Registered in England & Wales, no. 5513718



^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
  2025-09-29  9:48   ` Harry Wentland
@ 2025-12-11 15:26     ` Ariel D'Alessandro
  0 siblings, 0 replies; 51+ messages in thread
From: Ariel D'Alessandro @ 2025-12-11 15:26 UTC (permalink / raw)
  To: Harry Wentland, Nícolas F. R. A. Prado, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Chun-Kuang Hu, Philipp Zabel, Matthias Brugger,
	AngeloGioacchino Del Regno, Haneen Mohammed, Melissa Wen
  Cc: Alex Hung, wayland-devel, leo.liu, ville.syrjala, pekka.paalanen,
	contact, mwen, jadahl, sebastian.wick, shashank.sharma, agoins,
	joshua, mdaenzer, aleixpol, xaver.hugl, victoria, uma.shankar,
	quic_naseer, quic_cbraga, quic_abhinavk, marcan, Liviu.Dudau,
	sashamcintosh, chaitanya.kumar.borah, louis.chauvet, mcanal,
	kernel, daniels, leandro.ribeiro, dri-devel, linux-kernel,
	linux-mediatek, linux-arm-kernel, Simona Vetter

Harry,

On 9/29/25 6:48 AM, Harry Wentland wrote:
> 
> 
> On 2025-09-17 20:43, Nícolas F. R. A. Prado wrote:
>> Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE which a DRM client
>> can set to enable the usage of post-blend color pipelines instead of the
>> now deprecated CRTC color management properties: "GAMMA_LUT",
>> "DEGAMMA_LUT" and "CTM".
>>
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>> ---
>>   drivers/gpu/drm/drm_atomic_uapi.c   | 15 +++++++++++++++
>>   drivers/gpu/drm/drm_connector.c     |  1 +
>>   drivers/gpu/drm/drm_crtc_internal.h |  1 +
>>   drivers/gpu/drm/drm_ioctl.c         |  9 +++++++++
>>   drivers/gpu/drm/drm_mode_object.c   |  9 +++++++++
>>   include/drm/drm_file.h              |  7 +++++++
>>   include/uapi/drm/drm.h              | 19 +++++++++++++++++++
>>   7 files changed, 61 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/ 
>> drm_atomic_uapi.c
>> index 
>> 063c142fd9b656e228cfc660d005a3fbb4640d32..f5125fa3fa28ff2a6ff07fd7cf07d4bdf77ab738 100644
>> --- a/drivers/gpu/drm/drm_atomic_uapi.c
>> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
>> @@ -452,6 +452,11 @@ static int drm_atomic_crtc_set_property(struct 
>> drm_crtc *crtc,
>>       } else if (property == config->prop_vrr_enabled) {
>>           state->vrr_enabled = val;
>>       } else if (property == config->degamma_lut_property) {
>> +        if (file_priv->post_blend_color_pipeline) {
>> +            drm_dbg_atomic(dev,
>> +                "Setting DEGAMMA_LUT CRTC property not permitted with 
>> DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
>> +            return -EINVAL;
>> +        }
>>           ret = drm_property_replace_blob_from_id(dev,
>>                       &state->degamma_lut,
>>                       val,
>> @@ -460,6 +465,11 @@ static int drm_atomic_crtc_set_property(struct 
>> drm_crtc *crtc,
>>           state->color_mgmt_changed |= replaced;
>>           return ret;
>>       } else if (property == config->ctm_property) {
>> +        if (file_priv->post_blend_color_pipeline) {
>> +            drm_dbg_atomic(dev,
>> +                "Setting CTM CRTC property not permitted with 
>> DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
>> +            return -EINVAL;
>> +        }
>>           ret = drm_property_replace_blob_from_id(dev,
>>                       &state->ctm,
>>                       val,
>> @@ -468,6 +478,11 @@ static int drm_atomic_crtc_set_property(struct 
>> drm_crtc *crtc,
>>           state->color_mgmt_changed |= replaced;
>>           return ret;
>>       } else if (property == config->gamma_lut_property) {
>> +        if (file_priv->post_blend_color_pipeline) {
>> +            drm_dbg_atomic(dev,
>> +                "Setting GAMMA_LUT CRTC property not permitted with 
>> DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
>> +            return -EINVAL;
>> +        }
>>           ret = drm_property_replace_blob_from_id(dev,
>>                       &state->gamma_lut,
>>                       val,
>> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/ 
>> drm_connector.c
>> index 
>> 4d6dc9ebfdb5bc730b1aff7a184448af7b93f078..f58cfd2131139ff3e613adc4dbb9ddbedf724dc7 100644
>> --- a/drivers/gpu/drm/drm_connector.c
>> +++ b/drivers/gpu/drm/drm_connector.c
>> @@ -3440,6 +3440,7 @@ int drm_mode_getconnector(struct drm_device 
>> *dev, void *data,
>>        */
>>       ret = drm_mode_object_get_properties(&connector->base, 
>> file_priv->atomic,
>>               file_priv->plane_color_pipeline,
>> +            file_priv->post_blend_color_pipeline,
>>               (uint32_t __user *)(unsigned long)(out_resp->props_ptr),
>>               (uint64_t __user *)(unsigned long)(out_resp- 
>> >prop_values_ptr),
>>               &out_resp->count_props);
>> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/ 
>> drm_crtc_internal.h
>> index 
>> e3dbdcbfa385b940ec0b5476adde6146fe4afde1..c53f154e5392a10c326c844b7321666275f9ac02 100644
>> --- a/drivers/gpu/drm/drm_crtc_internal.h
>> +++ b/drivers/gpu/drm/drm_crtc_internal.h
>> @@ -169,6 +169,7 @@ void drm_mode_object_unregister(struct drm_device 
>> *dev,
>>                   struct drm_mode_object *object);
>>   int drm_mode_object_get_properties(struct drm_mode_object *obj, bool 
>> atomic,
>>                      bool plane_color_pipeline,
>> +                   bool post_blend_color_pipeline,
>>                      uint32_t __user *prop_ptr,
>>                      uint64_t __user *prop_values,
>>                      uint32_t *arg_count_props);
>> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
>> index 
>> 01592d10e3465ddceddef94bc417f98d3ec12087..ea9600f5392f520a2b42ba7ef363d2f08ce19812 100644
>> --- a/drivers/gpu/drm/drm_ioctl.c
>> +++ b/drivers/gpu/drm/drm_ioctl.c
>> @@ -383,6 +383,15 @@ drm_setclientcap(struct drm_device *dev, void 
>> *data, struct drm_file *file_priv)
>>               return -EINVAL;
>>           file_priv->plane_color_pipeline = req->value;
>>           break;
>> +    case DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE:
>> +        if (!file_priv->atomic)
>> +            return -EINVAL;
>> +        if (req->value > 1)
>> +            return -EINVAL;
>> +        if (!drm_core_check_feature(dev, 
>> DRIVER_POST_BLEND_COLOR_PIPELINE))
>> +            return -EINVAL;
>> +        file_priv->post_blend_color_pipeline = req->value;
>> +        break;
>>       default:
>>           return -EINVAL;
>>       }
>> diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/ 
>> drm_mode_object.c
>> index 
>> b45d501b10c868c6d9b7a5a8760eadbd7b372a6a..5e6c3de9456b997985142a68b9cef57771a58bdc 100644
>> --- a/drivers/gpu/drm/drm_mode_object.c
>> +++ b/drivers/gpu/drm/drm_mode_object.c
>> @@ -388,6 +388,7 @@ EXPORT_SYMBOL(drm_object_property_get_default_value);
>>   /* helper for getconnector and getproperties ioctls */
>>   int drm_mode_object_get_properties(struct drm_mode_object *obj, bool 
>> atomic,
>>                      bool plane_color_pipeline,
>> +                   bool post_blend_color_pipeline,
>>                      uint32_t __user *prop_ptr,
>>                      uint64_t __user *prop_values,
>>                      uint32_t *arg_count_props)
>> @@ -416,6 +417,13 @@ int drm_mode_object_get_properties(struct 
>> drm_mode_object *obj, bool atomic,
>>                   continue;
>>           }
>> +        if (!post_blend_color_pipeline && obj->type == 
>> DRM_MODE_OBJECT_CRTC) {
>> +            struct drm_crtc *crtc = obj_to_crtc(obj);
>> +
>> +            if (prop == crtc->color_pipeline_property)
>> +                continue;
>> +        }
>> +
>>           if (*arg_count_props > count) {
>>               ret = __drm_object_property_get_value(obj, prop, &val);
>>               if (ret)
>> @@ -475,6 +483,7 @@ int drm_mode_obj_get_properties_ioctl(struct 
>> drm_device *dev, void *data,
>>       ret = drm_mode_object_get_properties(obj, file_priv->atomic,
>>               file_priv->plane_color_pipeline,
>> +            file_priv->post_blend_color_pipeline,
>>               (uint32_t __user *)(unsigned long)(arg->props_ptr),
>>               (uint64_t __user *)(unsigned long)(arg->prop_values_ptr),
>>               &arg->count_props);
>> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
>> index 
>> 1a3018e4a537b3341acb50187d47371f6b781b9d..42b9a43baa18079af8ec2ea5b1484b23c497beb0 100644
>> --- a/include/drm/drm_file.h
>> +++ b/include/drm/drm_file.h
>> @@ -213,6 +213,13 @@ struct drm_file {
>>        */
>>       bool plane_color_pipeline;
>> +    /**
>> +     * @post_blend_color_pipeline:
>> +     *
>> +     * True if client understands post-blend color pipelines
>> +     */
>> +    bool post_blend_color_pipeline;
>> +
>>       /**
>>        * @was_master:
>>        *
>> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
>> index 
>> c6c53e57958e951204154ce41a69696a6876f0e8..f9ac10b3e4876f71005a87dedefa4aed320566f0 100644
>> --- a/include/uapi/drm/drm.h
>> +++ b/include/uapi/drm/drm.h
>> @@ -927,6 +927,25 @@ struct drm_get_cap {
>>    */
>>   #define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE    7
>> +/**
>> + * DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
> 
> DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE might be better to align
> terminology between pre- and post-blend pipelines. It would
> also make it clear that this is about the color pipeline on
> a drm_crtc (which pretty much by definition means post-
> blending).
Same answer here. Will be replacing s/post_blend/crtc in v3.

Thanks!

-- 
Ariel D'Alessandro
Software Engineer

Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK 
Registered in England & Wales, no. 5513718



^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2025-12-11 15:27 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18  0:43 [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
2025-09-18  0:43 ` [PATCH RFC v2 01/20] drm/crtc: Add color pipeline to CRTC state Nícolas F. R. A. Prado
2025-09-19 12:45   ` Louis Chauvet
2025-09-18  0:43 ` [PATCH RFC v2 02/20] drm/colorop: Allow parenting colorop to CRTC Nícolas F. R. A. Prado
2025-09-19 12:44   ` Louis Chauvet
2025-12-10 20:49     ` Ariel D'Alessandro
2025-09-18  0:43 ` [PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code Nícolas F. R. A. Prado
2025-09-19 12:43   ` Louis Chauvet
2025-09-29  8:53   ` Harry Wentland
2025-12-10 20:19     ` Ariel D'Alessandro
2025-09-18  0:43 ` [PATCH RFC v2 04/20] drm/crtc: Add COLOR_PIPELINE property Nícolas F. R. A. Prado
2025-09-19 12:43   ` Louis Chauvet
2025-12-10 21:00     ` Ariel D'Alessandro
2025-09-18  0:43 ` [PATCH RFC v2 05/20] drm: Introduce DRM_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
2025-09-19 12:42   ` Louis Chauvet
2025-09-29  9:40     ` Harry Wentland
2025-09-29 16:00       ` Nícolas F. R. A. Prado
2025-09-18  0:43 ` [PATCH RFC v2 06/20] drm: Introduce DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE Nícolas F. R. A. Prado
2025-09-19 12:42   ` Louis Chauvet
2025-09-29  9:48   ` Harry Wentland
2025-12-11 15:26     ` Ariel D'Alessandro
2025-09-18  0:43 ` [PATCH RFC v2 07/20] drm/atomic: Pass post_blend_color_pipeline client cap to atomic check Nícolas F. R. A. Prado
2025-09-19 12:41   ` Louis Chauvet
2025-09-29  9:50   ` Harry Wentland
2025-12-11 15:16     ` Ariel D'Alessandro
2025-09-18  0:43 ` [PATCH RFC v2 08/20] drm/atomic: Print the color pipeline as part of the CRTC state print Nícolas F. R. A. Prado
2025-09-19 12:50   ` Louis Chauvet
2025-09-18  0:43 ` [PATCH RFC v2 09/20] drm/colorop: Factor out common paths from colorops helpers Nícolas F. R. A. Prado
2025-09-19 12:51   ` Louis Chauvet
2025-09-18  0:43 ` [PATCH RFC v2 10/20] drm/colorop: Introduce colorop helpers for crtc Nícolas F. R. A. Prado
2025-09-19 12:44   ` Louis Chauvet
2025-09-18  0:43 ` [PATCH RFC v2 11/20] drm/colorop: Export drm_colorop_cleanup() so drivers can extend it Nícolas F. R. A. Prado
2025-09-18  0:43 ` [PATCH RFC v2 12/20] drm/crtc: Track post-blend color pipeline client cap in drm_crtc_state Nícolas F. R. A. Prado
2025-09-19 12:51   ` Louis Chauvet
2025-09-18  0:43 ` [PATCH RFC v2 13/20] drm/mediatek: Support post-blend colorops for gamma and ctm Nícolas F. R. A. Prado
2025-09-18  0:43 ` [PATCH RFC v2 14/20] drm/mediatek: ccorr: Support post-blend color pipeline API Nícolas F. R. A. Prado
2025-09-18  0:43 ` [PATCH RFC v2 15/20] drm/mediatek: gamma: " Nícolas F. R. A. Prado
2025-09-18  0:43 ` [PATCH RFC v2 16/20] drm/mediatek: Set post-blend color pipeline driver cap Nícolas F. R. A. Prado
2025-09-19 12:50   ` Louis Chauvet
2025-09-18  0:43 ` [PATCH RFC v2 17/20] drm/vkms: Rename existing color pipeline helpers to contain "pre_blend" Nícolas F. R. A. Prado
2025-09-19 12:45   ` Louis Chauvet
2025-09-18  0:43 ` [PATCH RFC v2 18/20] drm/vkms: Prepare pre_blend_color_transform() for post-blend pipelines Nícolas F. R. A. Prado
2025-09-19 12:48   ` Louis Chauvet
2025-09-18  0:43 ` [PATCH RFC v2 19/20] drm/vkms: Introduce support for post-blend color pipeline Nícolas F. R. A. Prado
2025-09-19 12:50   ` Louis Chauvet
2025-12-10 21:15     ` Ariel D'Alessandro
2025-09-18  0:43 ` [PATCH RFC v2 20/20] drm/vkms: Set post-blend color pipeline driver cap Nícolas F. R. A. Prado
2025-09-19 12:49   ` Louis Chauvet
2025-09-29 10:22 ` [PATCH RFC v2 00/20] Introduce support for post-blend color pipeline Harry Wentland
2025-09-29 12:05 ` Melissa Wen
2025-09-29 14:25   ` Harry Wentland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).