* [PATCH v3 01/19] drm/crtc: Add color pipeline to CRTC state
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 02/19] drm/colorop: Allow parenting colorop to CRTC Melissa Wen
` (17 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Louis Chauvet, Melissa Wen
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
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>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
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 be5dca538d87..03991b381dce 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;
+
/**
* @background_color:
*
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 02/19] drm/colorop: Allow parenting colorop to CRTC
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
2026-11-24 18:03 ` [PATCH v3 01/19] drm/crtc: Add color pipeline to CRTC state Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 03/19] drm/atomic: handle CRTC colorops in drm_atomic_commit_set_colorop_state() Melissa Wen
` (16 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Louis Chauvet, Melissa Wen
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
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>
Co-developed-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- minor fix of trailing whitespace <mwen>
- rebase on drm-misc-next
---
drivers/gpu/drm/drm_atomic.c | 6 +++---
drivers/gpu/drm/drm_colorop.c | 25 +++++++++++++++++++++++++
include/drm/drm_colorop.h | 18 ++++++++++++++++--
3 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 324e79152e17..e72e5e7ee76b 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -748,7 +748,7 @@ drm_atomic_get_colorop_state(struct drm_atomic_commit *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);
@@ -2213,10 +2213,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 95da03d6c65c..6b15df55c84f 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>
@@ -774,3 +775,27 @@ 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 26ef67c835e2..3a71cecd8273 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 */
@@ -365,11 +366,21 @@ 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.
+ * NOTE: plane and crtc are mutually exclusive.
*/
struct drm_plane *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.
+ * NOTE: plane and crtc are mutually exclusive.
+ */
+ struct drm_crtc *crtc;
+
/**
* @state:
*
@@ -610,4 +621,7 @@ const char *drm_get_colorop_fixed_matrix_type_name(enum drm_colorop_fixed_matrix
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.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 03/19] drm/atomic: handle CRTC colorops in drm_atomic_commit_set_colorop_state()
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
2026-11-24 18:03 ` [PATCH v3 01/19] drm/crtc: Add color pipeline to CRTC state Melissa Wen
2026-11-24 18:03 ` [PATCH v3 02/19] drm/colorop: Allow parenting colorop to CRTC Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 04/19] drm/atomic: duplicate CRTC colorop states Melissa Wen
` (15 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
Commit 259907fef771 ("drm/atomic: Create function to insert colorop
state into a commit") asserts if the lock of the plane colorop is held.
Now that a colorop can be also parented by a CRTC, colorop->plane is
NULL for a CRTC colorop and drm_atomic_commit_set_colorop_state() has to
check the CRTC mutex instead of plane mutex. Update the helper to assert
the lock of the object that owns the colorop.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- new patch: adapt the lock assert added by commit 259907fef771 to
colorops parented to a CRTC
---
drivers/gpu/drm/drm_atomic.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index e72e5e7ee76b..6d608795f28b 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -710,7 +710,10 @@ static void drm_atomic_commit_set_colorop_state(struct drm_atomic_commit *commit
{
int index = drm_colorop_index(colorop);
- drm_modeset_lock_assert_held(&colorop->plane->mutex);
+ if (colorop->plane)
+ drm_modeset_lock_assert_held(&colorop->plane->mutex);
+ else if (colorop->crtc)
+ drm_modeset_lock_assert_held(&colorop->crtc->mutex);
commit->colorops[index].state_to_destroy = colorop_state;
commit->colorops[index].old_state = colorop->state;
@@ -725,8 +728,8 @@ static void drm_atomic_commit_set_colorop_state(struct drm_atomic_commit *commit
* @colorop: colorop to get state object for
*
* This function returns the colorop state for the given colorop, allocating it
- * if needed. It will also grab the relevant plane lock to make sure that the
- * state is consistent.
+ * if needed. It will also grab the relevant plane or CRTC lock to make sure
+ * that the state is consistent.
*
* Returns:
*
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 04/19] drm/atomic: duplicate CRTC colorop states
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (2 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 03/19] drm/atomic: handle CRTC colorops in drm_atomic_commit_set_colorop_state() Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 05/19] drm: Factor out common color_pipeline property initialization code Melissa Wen
` (14 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
Add the state of every CRTC colorop to the duplicated state, active or
not, so their settings persist on a reset cycle.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- new patch
- Note: if "drm/atomic: duplicate state of all colorops" for colorop
planes [1] lands first, the plane and CRTC loops can be merged into a
single pass over all colorops.
[1] https://lore.kernel.org/dri-devel/20261111160814.21326-8-mwen@igalia.com/
---
drivers/gpu/drm/drm_atomic_helper.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index ccfe3840d505..da908f0266bf 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3730,6 +3730,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
struct drm_connector_list_iter conn_iter;
struct drm_plane *plane;
struct drm_crtc *crtc;
+ struct drm_colorop *colorop;
int err = 0;
state = drm_atomic_commit_alloc(dev);
@@ -3749,6 +3750,23 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
}
}
+ /*
+ * Add all CRTC colorops, active or not, so their settings survive the
+ * colorop reset done on resume.
+ */
+ drm_for_each_colorop(colorop, dev) {
+ struct drm_colorop_state *colorop_state;
+
+ if (!colorop->crtc)
+ continue;
+
+ colorop_state = drm_atomic_get_colorop_state(state, colorop);
+ if (IS_ERR(colorop_state)) {
+ err = PTR_ERR(colorop_state);
+ goto free;
+ }
+ }
+
drm_for_each_plane(plane, dev) {
struct drm_plane_state *plane_state;
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 05/19] drm: Factor out common color_pipeline property initialization code
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (3 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 04/19] drm/atomic: duplicate CRTC colorop states Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 06/19] drm/crtc: Add COLOR_PIPELINE property Melissa Wen
` (13 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Louis Chauvet, Melissa Wen
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
In preparation for sharing the initialization code for the color
pipeline property between pre-blend (plane) and post-blend (crtc) color
pipelines, factor out the common initialization to a separate function.
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Co-developed-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
drivers/gpu/drm/drm_plane.c | 34 ++++----------------------
drivers/gpu/drm/drm_property.c | 44 ++++++++++++++++++++++++++++++++++
include/drm/drm_property.h | 5 ++++
3 files changed, 53 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index bd4a1d678420..199d42b01fc4 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -1837,41 +1837,15 @@ 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 = kzalloc_objs(*all_pipelines, num_pipelines + 1);
+ prop = drm_property_create_color_pipeline(plane->dev, &plane->base,
+ pipelines, num_pipelines);
+ if (IS_ERR(prop))
+ return PTR_ERR(prop);
- 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 (!prop) {
- kfree(all_pipelines);
- return -ENOMEM;
- }
-
- 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);
diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index 91f114cf9f60..8d5c98ceae8c 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -1007,3 +1007,47 @@ void drm_property_change_valid_put(struct drm_property *property,
} else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB))
drm_property_blob_put(obj_to_blob(ref));
}
+
+struct drm_property *
+drm_property_create_color_pipeline(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 (!prop) {
+ kfree(all_pipelines);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ drm_object_attach_property(obj, prop, 0);
+
+ kfree(all_pipelines);
+ return prop;
+}
diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h
index aa49b5a42bb5..2ba4062f8bfa 100644
--- a/include/drm/drm_property.h
+++ b/include/drm/drm_property.h
@@ -297,6 +297,11 @@ bool drm_property_replace_blob(struct drm_property_blob **blob,
struct drm_property_blob *drm_property_blob_get(struct drm_property_blob *blob);
void drm_property_blob_put(struct drm_property_blob *blob);
+struct drm_property *
+drm_property_create_color_pipeline(struct drm_device *dev, struct drm_mode_object *obj,
+ const struct drm_prop_enum_list *pipelines,
+ int num_pipelines);
+
/**
* drm_property_find - find property object
* @dev: DRM device
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 06/19] drm/crtc: Add COLOR_PIPELINE property
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (4 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 05/19] drm: Factor out common color_pipeline property initialization code Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 07/19] drm/atomic: track individual CRTC colorop updates Melissa Wen
` (12 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
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>
Co-developed-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
drivers/gpu/drm/drm_atomic_uapi.c | 50 ++++++++++++++++++++++++++++---
drivers/gpu/drm/drm_crtc.c | 31 +++++++++++++++++++
include/drm/drm_atomic_uapi.h | 2 ++
include/drm/drm_crtc.h | 11 +++++++
4 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index a45e61cd9bc3..9c3889ebda2b 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -294,6 +294,34 @@ 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
* @conn_state: atomic state object for the connector
@@ -402,8 +430,8 @@ static s32 __user *get_out_fence_for_connector(struct drm_atomic_commit *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;
@@ -412,7 +440,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);
@@ -519,6 +557,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = state->scaling_filter;
else if (property == crtc->sharpness_strength_property)
*val = state->sharpness_strength;
+ 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 {
@@ -1106,6 +1146,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);
break;
@@ -1262,7 +1304,7 @@ int drm_atomic_set_property(struct drm_atomic_commit *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 1899b63c730f..f3ccbd6d8d83 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -997,3 +997,34 @@ 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);
+
+/**
+ * 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_property_create_color_pipeline(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 4e7e78f711e2..90e5c207a53b 100644
--- a/include/drm/drm_atomic_uapi.h
+++ b/include/drm/drm_atomic_uapi.h
@@ -54,6 +54,8 @@ void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
struct drm_framebuffer *fb);
bool 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 03991b381dce..aba579cef6b6 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1129,6 +1129,14 @@ struct drm_crtc {
*/
struct drm_property *sharpness_strength_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:
*
@@ -1364,6 +1372,9 @@ 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);
int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc);
#endif /* __DRM_CRTC_H__ */
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 07/19] drm/atomic: track individual CRTC colorop updates
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (5 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 06/19] drm/crtc: Add COLOR_PIPELINE property Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 08/19] drm: Introduce DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE Melissa Wen
` (11 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
As done for plane colorops by commit 2e235e2a2784b ("drm/atomic: track
individual colorop updates"), make drm_atomic_set_colorop_for_crtc()
report whether the CRTC color pipeline changed and set
CRTC color_mgmt_changed flag accordingly.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- new patch: set color_mgmt_changed when the CRTC COLOR_PIPELINE value
changes, as commit 2e235e2a2784 does for planes
---
drivers/gpu/drm/drm_atomic_uapi.c | 12 ++++++++++--
include/drm/drm_atomic_uapi.h | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 9c3889ebda2b..183716cf0db9 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -301,13 +301,18 @@ EXPORT_SYMBOL(drm_atomic_set_colorop_for_plane);
*
* Helper function to select the color pipeline on a crtc by setting
* it to the first drm_colorop element of the pipeline.
+ *
+ * Return: true if CRTC color pipeline value changed, false otherwise.
*/
-void
+bool
drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
struct drm_colorop *colorop)
{
struct drm_crtc *crtc = crtc_state->crtc;
+ if (crtc_state->color_pipeline == colorop)
+ return false;
+
if (colorop)
drm_dbg_atomic(crtc->dev,
"Set [COLOROP:%d] for [CRTC:%d:%s] state %p\n",
@@ -319,6 +324,8 @@ drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
crtc->base.id, crtc->name, crtc_state);
crtc_state->color_pipeline = colorop;
+
+ return true;
}
EXPORT_SYMBOL(drm_atomic_set_colorop_for_crtc);
@@ -449,7 +456,8 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
if (val && !colorop)
return -EACCES;
- drm_atomic_set_colorop_for_crtc(state, colorop);
+ state->color_mgmt_changed |=
+ 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);
diff --git a/include/drm/drm_atomic_uapi.h b/include/drm/drm_atomic_uapi.h
index 90e5c207a53b..04fb32eccd0f 100644
--- a/include/drm/drm_atomic_uapi.h
+++ b/include/drm/drm_atomic_uapi.h
@@ -54,7 +54,7 @@ void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
struct drm_framebuffer *fb);
bool 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,
+bool 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,
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 08/19] drm: Introduce DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (6 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 07/19] drm/atomic: track individual CRTC colorop updates Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 09/19] drm/atomic: Print the color pipeline as part of the CRTC state print Melissa Wen
` (10 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Louis Chauvet, Melissa Wen
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Introduce DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE which a DRM client can set
to enable the usage of CRTC (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>
Co-developed-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
drivers/gpu/drm/drm_atomic_uapi.c | 21 +++++++++++++++++++++
drivers/gpu/drm/drm_connector.c | 1 +
drivers/gpu/drm/drm_crtc_internal.h | 1 +
drivers/gpu/drm/drm_ioctl.c | 7 +++++++
drivers/gpu/drm/drm_mode_object.c | 9 +++++++++
include/drm/drm_file.h | 7 +++++++
include/uapi/drm/drm.h | 19 +++++++++++++++++++
7 files changed, 65 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 183716cf0db9..195aaed55e7a 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -448,6 +448,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
if (property == config->prop_active)
state->active = val;
else if (property == crtc->color_pipeline_property) {
+ if (!file_priv->crtc_color_pipeline) {
+ drm_dbg_atomic(dev,
+ "Setting COLOR_PIPELINE CRTC property not permitted without DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE client cap\n");
+ return -EINVAL;
+ }
/* find DRM colorop object */
struct drm_colorop *colorop = NULL;
@@ -470,6 +475,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
const size_t elem_size = sizeof(struct drm_color_lut);
u64 lut_size;
+ if (file_priv->crtc_color_pipeline) {
+ drm_dbg_atomic(dev,
+ "Setting DEGAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE client cap\n");
+ return -EINVAL;
+ }
ret = drm_object_immutable_property_get_value(&crtc->base,
config->degamma_lut_size_property,
&lut_size);
@@ -484,6 +494,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->crtc_color_pipeline) {
+ drm_dbg_atomic(dev,
+ "Setting CTM CRTC property not permitted with DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE client cap\n");
+ return -EINVAL;
+ }
ret = drm_property_replace_blob_from_id(dev,
&state->ctm,
val,
@@ -495,6 +510,12 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
const size_t elem_size = sizeof(struct drm_color_lut);
u64 lut_size;
+ if (file_priv->crtc_color_pipeline) {
+ drm_dbg_atomic(dev,
+ "Setting GAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE client cap\n");
+ return -EINVAL;
+ }
+
ret = drm_object_immutable_property_get_value(&crtc->base,
config->gamma_lut_size_property,
&lut_size);
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index d66188521881..a9a9aff02d30 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -3767,6 +3767,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->crtc_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 3492787c3697..0e5def171222 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -164,6 +164,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 crtc_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 9039a39c4324..3e57453ef258 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -392,6 +392,13 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
file_priv->plane_color_pipeline = req->value;
break;
}
+ case DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE:
+ if (!file_priv->atomic)
+ return -EINVAL;
+ if (req->value > 1)
+ return -EINVAL;
+ file_priv->crtc_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 21fc9deda437..e9f317126035 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -413,6 +413,7 @@ EXPORT_SYMBOL(drm_object_immutable_property_get_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 crtc_color_pipeline,
uint32_t __user *prop_ptr,
uint64_t __user *prop_values,
uint32_t *arg_count_props)
@@ -441,6 +442,13 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
continue;
}
+ if (!crtc_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)
@@ -500,6 +508,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->crtc_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 6ee70ad65e1f..d0c323378ae4 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -214,6 +214,13 @@ struct drm_file {
*/
bool plane_color_pipeline;
+ /**
+ * @crtc_color_pipeline:
+ *
+ * True if client understands CRTC (post-blend) color pipelines
+ */
+ bool crtc_color_pipeline;
+
/**
* @was_master:
*
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index bc7ef7684099..514c8f4b3aaf 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -903,6 +903,25 @@ struct drm_get_cap {
*/
#define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE 7
+/**
+ * DRM_CLIENT_CAP_CRTC_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_CRTC_COLOR_PIPELINE.
+ */
+#define DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE 8
+
/* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
struct drm_set_client_cap {
__u64 capability;
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 09/19] drm/atomic: Print the color pipeline as part of the CRTC state print
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (7 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 08/19] drm: Introduce DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 10/19] drm/colorop: Factor out common paths from colorops helpers Melissa Wen
` (9 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Louis Chauvet, Melissa Wen
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
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>
Co-developed-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
drivers/gpu/drm/drm_atomic.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 6d608795f28b..430d4a95241b 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -575,6 +575,8 @@ static void drm_atomic_crtc_print_state(struct drm_printer *p,
drm_printf_indent(p, 1, "plane_mask=%x\n", state->plane_mask);
drm_printf_indent(p, 1, "connector_mask=%x\n", state->connector_mask);
drm_printf_indent(p, 1, "encoder_mask=%x\n", state->encoder_mask);
+ drm_printf_indent(p, 1, "color-pipeline=%d\n",
+ state->color_pipeline ? state->color_pipeline->base.id : 0);
drm_printf_indent(p, 1, "mode: " DRM_MODE_FMT "\n", DRM_MODE_ARG(&state->mode));
drm_printf_indent(p, 1, "background_color=%llx\n", state->background_color);
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 10/19] drm/colorop: Factor out common paths from colorops helpers
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (8 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 09/19] drm/atomic: Print the color pipeline as part of the CRTC state print Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:36 ` sashiko-bot
2026-11-24 18:03 ` [PATCH v3 11/19] drm/colorop: Introduce colorop helpers for crtc Melissa Wen
` (8 subsequent siblings)
18 siblings, 1 reply; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Louis Chauvet, Melissa Wen
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
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>
Co-developed-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
drivers/gpu/drm/drm_colorop.c | 180 +++++++++++++++++++++-------------
1 file changed, 114 insertions(+), 66 deletions(-)
diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index 6b15df55c84f..baef70460da9 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -103,10 +103,11 @@ static const char * const colorop_fixed_matrix_type_names[] = {
/* Init Helpers */
-static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
- struct drm_plane *plane, const struct drm_colorop_funcs *funcs,
- enum drm_colorop_type type,
- uint32_t flags)
+static int drm_common_colorop_init(struct drm_device *dev,
+ struct drm_colorop *colorop,
+ const struct drm_colorop_funcs *funcs,
+ enum drm_colorop_type type,
+ uint32_t flags)
{
struct drm_mode_config *config = &dev->mode_config;
struct drm_property *prop;
@@ -119,7 +120,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;
colorop->funcs = funcs;
@@ -169,6 +169,22 @@ 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,
+ const struct drm_colorop_funcs *funcs,
+ enum drm_colorop_type type,
+ uint32_t flags)
+{
+ int ret;
+
+ ret = drm_common_colorop_init(dev, colorop, funcs, type, flags);
+
+ colorop->plane = plane;
+
+ return ret;
+}
+
/**
* drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline
*
@@ -220,45 +236,14 @@ void drm_colorop_pipeline_destroy(struct drm_device *dev)
}
EXPORT_SYMBOL(drm_colorop_pipeline_destroy);
-/**
- * drm_plane_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE
- *
- * @dev: DRM device
- * @colorop: The drm_colorop object to initialize
- * @plane: The associated drm_plane
- * @funcs: control functions for the new colorop
- * @supported_tfs: A bitfield of supported drm_plane_colorop_curve_1d_init enum values,
- * created using BIT(curve_type) and combined with the OR '|'
- * operator.
- * @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, const struct drm_colorop_funcs *funcs,
- 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, funcs, DRM_COLOROP_1D_CURVE, flags);
- if (ret)
- return ret;
len = 0;
for (i = 0; i < DRM_COLOROP_1D_CURVE_COUNT; i++) {
@@ -287,6 +272,45 @@ 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,
+ const struct drm_colorop_funcs *funcs,
+ 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, funcs, 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)
@@ -307,32 +331,15 @@ 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
- * @funcs: control functions for new colorop
- * @lut_size: LUT size supported by driver
- * @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,
- const struct drm_colorop_funcs *funcs,
- uint32_t lut_size,
- enum drm_colorop_lut1d_interpolation_type 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 interpolation,
+ uint32_t flags)
{
struct drm_property *prop;
int ret;
- ret = drm_plane_colorop_init(dev, colorop, plane, funcs, 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,
@@ -363,18 +370,44 @@ 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, const struct drm_colorop_funcs *funcs,
- 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,
+ const struct drm_colorop_funcs *funcs,
+ 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, funcs, DRM_COLOROP_CTM_3X4, flags);
+ ret = drm_plane_colorop_init(dev, colorop, plane, funcs, 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;
@@ -383,6 +416,21 @@ 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,
+ const struct drm_colorop_funcs *funcs,
+ uint32_t flags)
+{
+ int ret;
+
+ ret = drm_plane_colorop_init(dev, colorop, plane, funcs, 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.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v3 10/19] drm/colorop: Factor out common paths from colorops helpers
2026-11-24 18:03 ` [PATCH v3 10/19] drm/colorop: Factor out common paths from colorops helpers Melissa Wen
@ 2026-11-24 18:36 ` sashiko-bot
0 siblings, 0 replies; 26+ messages in thread
From: sashiko-bot @ 2026-11-24 18:36 UTC (permalink / raw)
To: Melissa Wen; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/colorop: missing @funcs kernel-doc and deleted curve_1d_init
kernel-doc
--
commit de778a21ac78648776da670a0d86b55bc392e7de
Author: Nícolas F. R. A. Prado <nfraprado@collabora.com>
drm/colorop: Factor out common paths from colorops helpers
This commit factors out common initialization helpers from the plane
colorop helpers so they can be shared with post-blend colorop helpers.
> diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
> index 6b15df55c84f3..baef70460da93 100644
> --- a/drivers/gpu/drm/drm_colorop.c
> +++ b/drivers/gpu/drm/drm_colorop.c
[ ... ]
> @@ -220,45 +236,14 @@ void drm_colorop_pipeline_destroy(struct drm_device *dev)
> }
> EXPORT_SYMBOL(drm_colorop_pipeline_destroy);
>
> -/**
> - * drm_plane_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE
> - *
> - * @dev: DRM device
> - * @colorop: The drm_colorop object to initialize
> - * @plane: The associated drm_plane
> - * @funcs: control functions for the new colorop
> - * @supported_tfs: A bitfield of supported drm_plane_colorop_curve_1d_init enum values,
> - * created using BIT(curve_type) and combined with the OR '|'
> - * operator.
> - * @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, const struct drm_colorop_funcs *funcs,
> - 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)
[ ... ]
> @@ -363,18 +370,44 @@ 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, const struct drm_colorop_funcs *funcs,
> - 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,
> + const struct drm_colorop_funcs *funcs,
> + uint32_t lut_size,
> + enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
> + uint32_t flags)
[Severity: Low]
The updated kernel-doc comment for drm_plane_colorop_curve_1d_lut_init()
drops @funcs while the function still takes const struct
drm_colorop_funcs *funcs, which triggers a scripts/kernel-doc warning on
W=1 and htmldocs builds. Also, the kernel-doc comment for the exported
drm_plane_colorop_curve_1d_init() function was removed above instead of
being kept on drm_plane_colorop_curve_1d_init().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124181652.1333986-1-mwen@igalia.com?part=10
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v3 11/19] drm/colorop: Introduce colorop helpers for crtc
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (9 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 10/19] drm/colorop: Factor out common paths from colorops helpers Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:36 ` sashiko-bot
2026-11-24 18:03 ` [PATCH v3 12/19] drm/colorop: distinguish whether a colorop belongs to a plane or a CRTC Melissa Wen
` (7 subsequent siblings)
18 siblings, 1 reply; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Louis Chauvet, Melissa Wen
From: Nícolas F. R. A. Prado <nfraprado@collabora.com>
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>
Co-developed-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
drivers/gpu/drm/drm_colorop.c | 81 +++++++++++++++++++++++++++++++++++
include/drm/drm_colorop.h | 14 ++++++
2 files changed, 95 insertions(+)
diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index baef70460da9..2f62050524b2 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -185,6 +185,21 @@ 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,
+ const struct drm_colorop_funcs *funcs,
+ enum drm_colorop_type type, uint32_t flags)
+{
+ int ret;
+
+ ret = drm_common_colorop_init(dev, colorop, funcs, type, flags);
+
+ colorop->crtc = crtc;
+
+ return ret;
+}
+
/**
* drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline
*
@@ -313,6 +328,26 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev,
}
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,
+ const struct drm_colorop_funcs *funcs,
+ 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, funcs, 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;
@@ -402,6 +437,37 @@ drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev,
}
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
+ * @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,
+ const struct drm_colorop_funcs *funcs,
+ uint32_t lut_size,
+ enum drm_colorop_lut1d_interpolation_type interpolation,
+ uint32_t flags)
+{
+ int ret;
+
+ ret = drm_crtc_colorop_init(dev, colorop, crtc, funcs, DRM_COLOROP_1D_LUT, flags);
+ if (ret)
+ return ret;
+
+ return drm_common_colorop_curve_1d_lut_init(dev, colorop, lut_size,
+ 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)
@@ -433,6 +499,21 @@ int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev,
}
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,
+ const struct drm_colorop_funcs *funcs,
+ uint32_t flags)
+{
+ int ret;
+
+ ret = drm_crtc_colorop_init(dev, colorop, crtc, funcs, 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 3a71cecd8273..657a8cff1227 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -535,6 +535,13 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,
void drm_colorop_pipeline_destroy(struct drm_device *dev);
void drm_colorop_cleanup(struct drm_colorop *colorop);
+int drm_crtc_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
+ struct drm_crtc *crtc,
+ const struct drm_colorop_funcs *funcs,
+ uint32_t lut_size,
+ enum drm_colorop_lut1d_interpolation_type interpolation,
+ uint32_t flags);
+
int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, const struct drm_colorop_funcs *funcs,
u64 supported_tfs, uint32_t flags);
@@ -544,9 +551,16 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color
uint32_t lut_size,
enum drm_colorop_lut1d_interpolation_type interpolation,
uint32_t flags);
+int drm_crtc_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
+ struct drm_crtc *crtc,
+ const struct drm_colorop_funcs *funcs,
+ u64 supported_tfs, uint32_t flags);
+
int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, const struct drm_colorop_funcs *funcs,
uint32_t flags);
+int drm_crtc_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
+ struct drm_crtc *crtc, const struct drm_colorop_funcs *funcs, uint32_t flags);
int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, const struct drm_colorop_funcs *funcs,
uint32_t flags);
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v3 11/19] drm/colorop: Introduce colorop helpers for crtc
2026-11-24 18:03 ` [PATCH v3 11/19] drm/colorop: Introduce colorop helpers for crtc Melissa Wen
@ 2026-11-24 18:36 ` sashiko-bot
0 siblings, 0 replies; 26+ messages in thread
From: sashiko-bot @ 2026-11-24 18:36 UTC (permalink / raw)
To: Melissa Wen; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] drm/colorop: missing @funcs doc in
drm_crtc_colorop_curve_1d_lut_init()
- [Low] drm/colorop: hardcoded PLANE log prefix in
drm_colorop_has_supported_tf()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] drm/colorop: missing error cleanup in drm_plane_colorop_init()
[1]
--
commit 31c092228a64133171c742733eb09f34d70d27f6
Author: Nícolas F. R. A. Prado <nfraprado@collabora.com>
drm/colorop: Introduce colorop helpers for crtc
This commit adds CRTC-based colorop initialization helpers for post-blend
1D curve, 1D LUT, and 3x4 CTM color pipelines.
> diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
> index baef70460da93..2f62050524b2c 100644
> --- a/drivers/gpu/drm/drm_colorop.c
> +++ b/drivers/gpu/drm/drm_colorop.c
[ ... ]
> @@ -313,6 +328,26 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev,
> }
> 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,
> + const struct drm_colorop_funcs *funcs,
> + 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;
[Severity: Low]
When drm_colorop_has_supported_tf() rejects supported_tfs here, does it
log the CRTC with a [PLANE:%d:%s] prefix? Both drm_err() messages in
drm_colorop_has_supported_tf() hardcode [PLANE:%d:%s].
> +
> + ret = drm_crtc_colorop_init(dev, colorop, crtc, funcs, 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);
[Severity: High]
This problem wasn't introduced by this patch, but if property creation
fails in drm_common_colorop_init() or in a subtype helper such as
drm_common_colorop_curve_1d_init() [1], does it leave colorop
registered in dev->mode_config.object_idr and linked in
config->colorop_list with colorop->state still NULL?
drm_common_colorop_init() calls drm_mode_object_add() and adds
colorop->head to config->colorop_list before creating the base properties,
while colorop->state is only allocated at the end of the subtype helper by
drm_colorop_reset():
drivers/gpu/drm/drm_colorop.c:drm_common_colorop_init() {
ret = drm_mode_object_add(dev, &colorop->base, DRM_MODE_OBJECT_COLOROP);
if (ret)
return ret;
...
list_add_tail(&colorop->head, &config->colorop_list);
colorop->index = config->num_colorop++;
...
prop = drm_property_create_enum(dev,
DRM_MODE_PROP_IMMUTABLE,
"TYPE", drm_colorop_type_enum_list,
ARRAY_SIZE(drm_colorop_type_enum_list));
if (!prop)
return -ENOMEM;
}
If any property allocation fails, neither drm_common_colorop_init() nor
the subtype helpers unwind the registration, so querying the published
mode object via DRM_IOCTL_MODE_OBJ_GETPROPERTIES will hit a NULL pointer
dereference on colorop->state in drm_atomic_colorop_get_property().
> @@ -402,6 +437,37 @@ drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev,
> }
> 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
> + * @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,
> + const struct drm_colorop_funcs *funcs,
[Severity: Low]
The kernel-doc comment for drm_crtc_colorop_curve_1d_lut_init() omits the
@funcs parameter description (and uses @return instead of Return:), which
triggers a scripts/kernel-doc warning when building documentation or with
W=1.
[1] https://sashiko.dev/#/bug/linux-e4f43398-10d0-4ccc-944b-469733dc5b85
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124181652.1333986-1-mwen@igalia.com?part=11
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v3 12/19] drm/colorop: distinguish whether a colorop belongs to a plane or a CRTC
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (10 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 11/19] drm/colorop: Introduce colorop helpers for crtc Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 13/19] drm/drm_mode_object: hide deprecated CRTC color mgmt props if colorop is set Melissa Wen
` (6 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
To correctly track states and color management changes with the support
of both pre-blend and post-blend colorop.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
drivers/gpu/drm/drm_atomic_uapi.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 195aaed55e7a..0a597b9e8005 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1382,7 +1382,6 @@ int drm_atomic_set_property(struct drm_atomic_commit *state,
break;
}
case DRM_MODE_OBJECT_COLOROP: {
- struct drm_plane_state *plane_state;
struct drm_colorop *colorop = obj_to_colorop(obj);
struct drm_colorop_state *colorop_state;
bool replaced = false;
@@ -1407,12 +1406,26 @@ int drm_atomic_set_property(struct drm_atomic_commit *state,
if (ret || !replaced)
break;
- plane_state = drm_atomic_get_plane_state(state, colorop->plane);
- if (IS_ERR(plane_state)) {
- ret = PTR_ERR(plane_state);
- break;
+ if (colorop->plane) {
+ struct drm_plane_state *plane_state;
+
+ plane_state = drm_atomic_get_plane_state(state, colorop->plane);
+ if (IS_ERR(plane_state)) {
+ ret = PTR_ERR(plane_state);
+ break;
+ }
+ plane_state->color_mgmt_changed |= replaced;
+ } else if (colorop->crtc) {
+ struct drm_crtc_state *crtc_state;
+
+ crtc_state = drm_atomic_get_crtc_state(state, colorop->crtc);
+ if (IS_ERR(crtc_state)) {
+ ret = PTR_ERR(crtc_state);
+ break;
+ }
+ crtc_state->color_mgmt_changed |= replaced;
+
}
- plane_state->color_mgmt_changed |= replaced;
break;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 13/19] drm/drm_mode_object: hide deprecated CRTC color mgmt props if colorop is set
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (11 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 12/19] drm/colorop: distinguish whether a colorop belongs to a plane or a CRTC Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 14/19] drm/atomic: set hidden CRTC color mgmt model to default values Melissa Wen
` (5 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
Stop advertising CRTC color mgmt properties if post-blend colorop is
enabled. Follow the same approach done for plane COLOR_ENCODING and
COLOR_RANGE when pre-blend colorop is enabled.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- rebase on drm-misc-next, no other changes
---
drivers/gpu/drm/drm_mode_object.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index e9f317126035..3b7c94957bf0 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -442,10 +442,19 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
continue;
}
- if (!crtc_color_pipeline && obj->type == DRM_MODE_OBJECT_CRTC) {
+ if (obj->type == DRM_MODE_OBJECT_CRTC) {
struct drm_crtc *crtc = obj_to_crtc(obj);
+ struct drm_mode_config *config = &crtc->dev->mode_config;
- if (prop == crtc->color_pipeline_property)
+ if (!crtc_color_pipeline && prop == crtc->color_pipeline_property)
+ continue;
+
+ if (crtc_color_pipeline &&
+ (prop == config->degamma_lut_property ||
+ prop == config->degamma_lut_size_property ||
+ prop == config->ctm_property ||
+ prop == config->gamma_lut_property ||
+ prop == config->gamma_lut_size_property))
continue;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 14/19] drm/atomic: set hidden CRTC color mgmt model to default values
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (12 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 13/19] drm/drm_mode_object: hide deprecated CRTC color mgmt props if colorop is set Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:42 ` sashiko-bot
2026-11-24 18:03 ` [PATCH v3 15/19] drm/drm_ioctl: guard DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE Melissa Wen
` (4 subsequent siblings)
18 siblings, 1 reply; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
Userspace sees a single CRTC color management model: the colorop
pipeline if DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE is set, or CRTC color
properties otherwise. When the other model is hidden, CRTC still holds
its previous property settings and, without visibility, the userspace
cannot clear it anymore.
Reset the hidden model to its default value on every CRTC included in an
atomic commit: clear blobs if colorop pipeline, and set COLOR_PIPELINE
to Bypass if CRTC color properties are in place. Colorop values aren't
touched, so re-selecting a pipeline later restores them. Only set
color_mgmt_changed flag when something was actually reset.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- new patch, as for planes, drivers now decide from
crtc_state->color_pipeline between colorop or CRTC color properties
and the core sets the properties of the model hidden from the client to
their defaults.
---
drivers/gpu/drm/drm_atomic_uapi.c | 28 ++++++++++++++++++++++++++++
include/drm/drm_crtc.h | 6 ++++--
include/uapi/drm/drm.h | 4 ++++
3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 0a597b9e8005..ca711353fc48 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1695,6 +1695,32 @@ static void complete_signaling(struct drm_device *dev,
kfree(fence_state);
}
+static void
+reset_crtc_color_mgmt_props(struct drm_atomic_commit *state,
+ struct drm_file *file_priv,
+ bool async_flip)
+{
+ struct drm_crtc_state *crtc_state;
+ struct drm_crtc *crtc;
+ bool changed;
+ int i;
+
+ /* Async page flip doesn't change properties */
+ if (async_flip)
+ return;
+
+ for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
+ if (file_priv->crtc_color_pipeline) {
+ changed = drm_property_replace_blob(&crtc_state->degamma_lut, NULL);
+ changed |= drm_property_replace_blob(&crtc_state->ctm, NULL);
+ changed |= drm_property_replace_blob(&crtc_state->gamma_lut, NULL);
+ } else {
+ changed = drm_atomic_set_colorop_for_crtc(crtc_state, NULL);
+ }
+ crtc_state->color_mgmt_changed |= changed;
+ }
+}
+
static void
set_async_flip(struct drm_atomic_commit *state)
{
@@ -1853,6 +1879,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
drm_mode_object_put(obj);
}
+ reset_crtc_color_mgmt_props(state, file_priv, async_flip);
+
ret = prepare_signaling(dev, state, arg, file_priv, &fence_state,
&num_fences);
if (ret)
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index aba579cef6b6..166e80284bdf 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -277,8 +277,10 @@ struct drm_crtc_state {
/**
* @color_pipeline:
*
- * The first colorop of the active color pipeline, or NULL, if no
- * color pipeline is active.
+ * The first colorop of the active color pipeline, or NULL, if no color
+ * pipeline is active. Drivers program CRTC color management from this
+ * pipeline when it is set, and from @degamma_lut, @ctm and @gamma_lut
+ * properties otherwise.
*/
struct drm_colorop *color_pipeline;
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 514c8f4b3aaf..08bd616774a4 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -915,6 +915,10 @@ struct drm_get_cap {
* - DEGAMMA_LUT
* - CTM
*
+ * Userspace can only see one CRTC color management model. On every CRTC
+ * included in an atomic commit, the DRM core resets CRTC color properties of
+ * the hidden model to default values.
+ *
* The client must enable &DRM_CLIENT_CAP_ATOMIC first.
*
* This client cap can only be set if the driver sets the corresponding driver
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v3 14/19] drm/atomic: set hidden CRTC color mgmt model to default values
2026-11-24 18:03 ` [PATCH v3 14/19] drm/atomic: set hidden CRTC color mgmt model to default values Melissa Wen
@ 2026-11-24 18:42 ` sashiko-bot
0 siblings, 0 replies; 26+ messages in thread
From: sashiko-bot @ 2026-11-24 18:42 UTC (permalink / raw)
To: Melissa Wen; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/atomic: hidden CRTC color model not reset outside
drm_mode_atomic_ioctl()
--
commit 988786e967d206ee7e346b8385770656e4c8ad9e
Author: Melissa Wen <mwen@igalia.com>
drm/atomic: set hidden CRTC color mgmt model to default values
This commit resets the hidden CRTC color management properties (either the
legacy LUT/CTM blobs or the colorop pipeline) to default values on each
CRTC included in an atomic ioctl commit.
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index afac90d5d7e0a..fe676e612d414 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -1687,6 +1687,32 @@ static void complete_signaling(struct drm_device *dev,
> kfree(fence_state);
> }
>
> +static void
> +reset_crtc_color_mgmt_props(struct drm_atomic_commit *state,
> + struct drm_file *file_priv,
> + bool async_flip)
> +{
> + struct drm_crtc_state *crtc_state;
> + struct drm_crtc *crtc;
> + bool changed;
> + int i;
> +
> + /* Async page flip doesn't change properties */
> + if (async_flip)
> + return;
> +
> + for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
> + if (file_priv->crtc_color_pipeline) {
> + changed = drm_property_replace_blob(&crtc_state->degamma_lut, NULL);
> + changed |= drm_property_replace_blob(&crtc_state->ctm, NULL);
> + changed |= drm_property_replace_blob(&crtc_state->gamma_lut, NULL);
> + } else {
> + changed = drm_atomic_set_colorop_for_crtc(crtc_state, NULL);
> + }
> + crtc_state->color_mgmt_changed |= changed;
> + }
> +}
> +
> static void
> set_async_flip(struct drm_atomic_commit *state)
> {
> @@ -1845,6 +1871,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
> drm_mode_object_put(obj);
> }
>
> + reset_crtc_color_mgmt_props(state, file_priv, async_flip);
[Severity: Medium]
Does calling reset_crtc_color_mgmt_props() only in drm_mode_atomic_ioctl()
leave crtc_state->color_pipeline active when a later client updates CRTC
color properties through other atomic commit paths?
For example, after a client with DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE sets a
CRTC color pipeline, switching to a client or helper that updates gamma or
CTM via drm_crtc_legacy_gamma_set() (DRM_IOCTL_MODE_SETGAMMA),
set_property_atomic() (DRM_IOCTL_MODE_OBJ_SETPROPERTY), or fbdev's
setcmap_atomic() commits the new LUT/CTM blobs without clearing
crtc_state->color_pipeline. Because drivers program CRTC color management
from color_pipeline whenever it is non-NULL and only fall back to
degamma_lut, ctm, and gamma_lut otherwise, those updates are silently
ignored while the previous client's color pipeline remains active.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124181652.1333986-1-mwen@igalia.com?part=14
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v3 15/19] drm/drm_ioctl: guard DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (13 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 14/19] drm/atomic: set hidden CRTC color mgmt model to default values Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 16/19] drm/amd/display: move CRTC CTM color mgmt prop to check helper Melissa Wen
` (3 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
If the driver doesn't support post-blend colorop, refuse attempts from
userspace to set it. Same approach is taken for pre-blend colorop since
commit ac7c6b4308c5 ("drm: Guard DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE").
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- refuse the cap when no CRTC has a color pipeline as the plane guard
does
- drop the stale DRM_CAP_CRTC_COLOR_PIPELINE requirement from the cap
documentation
---
drivers/gpu/drm/drm_ioctl.c | 15 ++++++++++++++-
include/uapi/drm/drm.h | 3 ---
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 3e57453ef258..9325202f8cbd 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -392,13 +392,26 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
file_priv->plane_color_pipeline = req->value;
break;
}
- case DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE:
+ case DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE: {
+ struct drm_crtc *crtc;
+ bool has_crtc_with_color_pipeline = false;
+
if (!file_priv->atomic)
return -EINVAL;
if (req->value > 1)
return -EINVAL;
+ drm_for_each_crtc(crtc, dev) {
+ if (crtc->color_pipeline_property) {
+ has_crtc_with_color_pipeline = true;
+ break;
+ }
+ }
+ if (!has_crtc_with_color_pipeline)
+ return -EOPNOTSUPP;
+
file_priv->crtc_color_pipeline = req->value;
break;
+ }
default:
return -EINVAL;
}
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 08bd616774a4..c0971de2c0a3 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -920,9 +920,6 @@ struct drm_get_cap {
* the hidden model to default values.
*
* 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_CRTC_COLOR_PIPELINE.
*/
#define DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE 8
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 16/19] drm/amd/display: move CRTC CTM color mgmt prop to check helper
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (14 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 15/19] drm/drm_ioctl: guard DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:03 ` [PATCH v3 17/19] drm/amd/display: enable post-blend CTM colorop Melissa Wen
` (2 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
Move legacy CRTC CTM color mgmt handlers to AMD atomic check helper to
centralize legacy properties in a single place, so that we can reuse the
callers to these helpers for colorop setup.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- move before the post-blend colorop patches, so the previous CTM setup
can't override the CTM colorop once the pipeline is enabled
---
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 66 +++++++++----------
1 file changed, 32 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
index ebb05a20aa0c..220194df84c1 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
@@ -1265,6 +1265,7 @@ int amdgpu_dm_check_crtc_color_mgmt(struct dm_crtc_state *crtc,
uint32_t degamma_size, regamma_size;
bool has_regamma, has_degamma;
enum dc_transfer_func_predefined tf = TRANSFER_FUNCTION_LINEAR;
+ struct drm_color_ctm *ctm = NULL;
bool is_legacy;
int r;
@@ -1334,10 +1335,38 @@ int amdgpu_dm_check_crtc_color_mgmt(struct dm_crtc_state *crtc,
* have to place the CTM in the OCSC in that case.
*/
crtc->cm_has_degamma = has_degamma;
- if (check_only)
+ if (check_only) {
kvfree(out_tf);
+ return r;
+ }
- return r;
+ if (r)
+ return r;
+
+ /* Setup CRTC CTM. */
+ if (crtc->base.ctm) {
+ ctm = (struct drm_color_ctm *)crtc->base.ctm->data;
+
+ /*
+ * Gamut remapping must be used for gamma correction
+ * since it comes before the regamma correction.
+ *
+ * OCSC could be used for gamma correction, but we'd need to
+ * blend the adjustments together with the required output
+ * conversion matrix - so just use the gamut remap block
+ * for now.
+ */
+ __drm_ctm_to_dc_matrix(ctm, stream->gamut_remap_matrix.matrix);
+
+ stream->gamut_remap_matrix.enable_remap = true;
+ stream->csc_color_matrix.enable_adjustment = false;
+ } else {
+ /* Bypass CTM. */
+ stream->gamut_remap_matrix.enable_remap = false;
+ stream->csc_color_matrix.enable_adjustment = false;
+ }
+
+ return 0;
}
EXPORT_IF_KUNIT(amdgpu_dm_check_crtc_color_mgmt);
@@ -1365,38 +1394,7 @@ EXPORT_IF_KUNIT(amdgpu_dm_check_crtc_color_mgmt);
*/
int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc)
{
- struct dc_stream_state *stream = crtc->stream;
- struct drm_color_ctm *ctm = NULL;
- int ret;
-
- ret = amdgpu_dm_check_crtc_color_mgmt(crtc, false);
- if (ret)
- return ret;
-
- /* Setup CRTC CTM. */
- if (crtc->base.ctm) {
- ctm = (struct drm_color_ctm *)crtc->base.ctm->data;
-
- /*
- * Gamut remapping must be used for gamma correction
- * since it comes before the regamma correction.
- *
- * OCSC could be used for gamma correction, but we'd need to
- * blend the adjustments together with the required output
- * conversion matrix - so just use the gamut remap block
- * for now.
- */
- __drm_ctm_to_dc_matrix(ctm, stream->gamut_remap_matrix.matrix);
-
- stream->gamut_remap_matrix.enable_remap = true;
- stream->csc_color_matrix.enable_adjustment = false;
- } else {
- /* Bypass CTM. */
- stream->gamut_remap_matrix.enable_remap = false;
- stream->csc_color_matrix.enable_adjustment = false;
- }
-
- return 0;
+ return amdgpu_dm_check_crtc_color_mgmt(crtc, false);
}
EXPORT_IF_KUNIT(amdgpu_dm_update_crtc_color_mgmt);
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v3 17/19] drm/amd/display: enable post-blend CTM colorop
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (15 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 16/19] drm/amd/display: move CRTC CTM color mgmt prop to check helper Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:46 ` sashiko-bot
2026-11-24 18:03 ` [PATCH v3 18/19] drm/amd/display: add support to post-blend 1D-Curve colorop Melissa Wen
2026-11-24 18:03 ` [PATCH v3 19/19] drm/amd/display: add support to post-blend 1D-LUT colorop Melissa Wen
18 siblings, 1 reply; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
Initialize the AMD post-blend color pipeline with CTM as the first color
operation in the AMD post-blend color pipeline. AMD post-blend color
pipeline for DCN3 is described in `DCN 3.0 family color caps and
mapping` of the kernel doc.
Only enable post-blend colorop properties if there is no AMD private
color prop.
Link: https://dri.freedesktop.org/docs/drm/gpu/amdgpu/display/display-manager.html#dc-color-capabilities-between-dcn-generations
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- merge "drm/amd/display: enable post-blend colorop properties" into this
patch
- choose between the colorop and the CRTC color props from
crtc_state->color_pipeline
- set colorop funcs on the CTM colorop (fixes a NULL pointer dereference
on destroy)
- use the committed state of the CTM colorop when it isn't part of the
commit
- reject a colorop of unexpected type and program bypass explicitly as
in [1].
- reset the CRTC degamma flags when colorop is in use
- make amdgpu_dm_crtc_set_colorop_properties() static
- reject an enabled CTM colorop without a DATA blob. Note: becomes
redundant if [1] is applied first.
[1] https://lore.kernel.org/dri-devel/20261111160814.21326-1-mwen@igalia.com
---
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 97 +++++++++++++++++++
.../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 38 ++++++++
.../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 2 +
.../amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 42 ++++++++
4 files changed, 179 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
index 220194df84c1..243e52766701 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
@@ -1233,6 +1233,96 @@ int amdgpu_dm_verify_lut_sizes(const struct drm_crtc_state *crtc_state)
}
EXPORT_IF_KUNIT(amdgpu_dm_verify_lut_sizes);
+static int
+__set_dm_crtc_colorop_3x4_matrix(struct drm_crtc_state *crtc_state,
+ struct dc_stream_state *dc_stream_state,
+ struct drm_colorop *colorop,
+ bool check_only)
+{
+ struct drm_colorop_state *colorop_state;
+ struct drm_atomic_commit *state = crtc_state->state;
+ const struct drm_property_blob *blob;
+ struct drm_color_ctm_3x4 *ctm = NULL;
+
+ if (colorop->type != DRM_COLOROP_CTM_3X4)
+ return -EINVAL;
+
+ /* A colorop that isn't part of this commit keeps its committed state.
+ * It allows individual colorop changes.
+ */
+ colorop_state = drm_atomic_get_new_colorop_state(state, colorop);
+ if (!colorop_state)
+ colorop_state = colorop->state;
+
+ if (colorop_state->bypass) {
+ if (!check_only) {
+ dc_stream_state->gamut_remap_matrix.enable_remap = false;
+ dc_stream_state->csc_color_matrix.enable_adjustment = false;
+ }
+ return 0;
+ }
+
+ drm_dbg(state->dev, "3x4 matrix colorop with ID: %d\n", colorop->base.id);
+ blob = colorop_state->data;
+ if (!blob) {
+ drm_dbg_atomic(state->dev,
+ "[COLOROP:%d] enabled without a DATA blob\n",
+ colorop->base.id);
+ return -EINVAL;
+ }
+
+ if (blob->length != sizeof(struct drm_color_ctm_3x4)) {
+ drm_warn(state->dev, "blob->length (%zu) isn't equal to drm_color_ctm_3x4 (%zu)\n",
+ blob->length, sizeof(struct drm_color_ctm_3x4));
+ return -EINVAL;
+ }
+
+ if (!check_only) {
+ ctm = (struct drm_color_ctm_3x4 *)blob->data;
+ __drm_ctm_3x4_to_dc_matrix(ctm, dc_stream_state->gamut_remap_matrix.matrix);
+ dc_stream_state->gamut_remap_matrix.enable_remap = true;
+ dc_stream_state->csc_color_matrix.enable_adjustment = false;
+ }
+
+ return 0;
+}
+
+/*
+ * amdgpu_dm_crtc_set_colorop_properties: Set colorop props if programmable by DC.
+ * @crtc_state: DRM crtc state
+ * @dc_stream_state: AMDGPU DC stream state
+ * @check_only: only check color state without update dc stream
+ *
+ * This function verifies post-blend CTM and LUT sizes: if there is enough space, and for
+ * output transfer function, if its parameters can be calculated by AMD
+ * color module. The main difference with CRTC color mgmt properties is that
+ * post-blend degamma is not part of the color pipeline since it's actually
+ * supported pre-blend only.
+ *
+ * If it's not an atomic check, DC resources are checked and updated
+ * accordingly.
+ *
+ * Returns:
+ * 0 on success. Error code if validation fails.
+ */
+static int
+amdgpu_dm_crtc_set_colorop_properties(struct drm_crtc_state *crtc_state,
+ struct dc_stream_state *dc_stream_state,
+ bool check_only)
+{
+ struct drm_colorop *colorop = crtc_state->color_pipeline;
+ struct drm_device *dev = crtc_state->crtc->dev;
+ int ret;
+
+ if (drm_WARN_ON(dev, !colorop))
+ return -EINVAL;
+
+ /* 3x4 matrix */
+ ret = __set_dm_crtc_colorop_3x4_matrix(crtc_state, dc_stream_state, colorop, check_only);
+
+ return ret;
+}
+
/**
* amdgpu_dm_check_crtc_color_mgmt: Check if DRM color props are programmable by DC.
* @crtc: amdgpu_dm crtc state
@@ -1269,6 +1359,13 @@ int amdgpu_dm_check_crtc_color_mgmt(struct dm_crtc_state *crtc,
bool is_legacy;
int r;
+ if (crtc->base.color_pipeline) {
+ crtc->cm_has_degamma = false;
+ crtc->cm_is_degamma_srgb = false;
+ r = amdgpu_dm_crtc_set_colorop_properties(&crtc->base, stream, check_only);
+ return r;
+ }
+
tf = amdgpu_tf_to_dc_tf(crtc->regamma_tf);
r = amdgpu_dm_verify_lut_sizes(&crtc->base);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
index 47d90b67120e..c88c17da1058 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
@@ -301,3 +301,41 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
return amdgpu_dm_build_default_pipeline(dev, plane, hw_3d_lut, list);
}
EXPORT_IF_KUNIT(amdgpu_dm_initialize_default_pipeline);
+
+int amdgpu_dm_initialize_crtc_default_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));
+
+ /* 3x4 matrix */
+ ops[i] = kzalloc_obj(struct drm_colorop);
+ if (!ops[i]) {
+ ret = -ENOMEM;
+ goto cleanup;
+ }
+
+ ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, &dm_colorop_funcs,
+ DRM_COLOROP_FLAG_ALLOW_BYPASS);
+ if (ret)
+ goto cleanup;
+
+ list->type = ops[i]->base.id;
+
+ i++;
+
+ list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
+
+ return 0;
+cleanup:
+ if (ret == -ENOMEM)
+ drm_err(crtc->dev, "KMS: Failed to allocate colorop\n");
+
+ drm_colorop_pipeline_destroy(dev);
+
+ return ret;
+}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h
index edf7df7c19e9..baf45b2bf954 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h
@@ -34,6 +34,8 @@ extern const u64 amdgpu_dm_supported_fm;
int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list);
+int amdgpu_dm_initialize_crtc_default_pipeline(struct drm_crtc *crtc, struct drm_prop_enum_list *list);
+
#if IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
#include <drm/drm_colorop.h>
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
index 5036ac1c4fd5..85ccadc5f33e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
@@ -33,6 +33,7 @@
#include "amdgpu_dm_crtc.h"
#include "amdgpu_dm_irq.h"
#include "amdgpu_dm_plane.h"
+#include "amdgpu_dm_colorop.h"
#include "amdgpu_dm_trace.h"
#include "amdgpu_dm_debugfs.h"
#include "dm_helpers.h"
@@ -577,6 +578,43 @@ amdgpu_dm_atomic_crtc_get_property(struct drm_crtc *crtc,
return 0;
}
+#else
+
+#define MAX_CRTC_COLOR_PIPELINES 5
+
+static int
+dm_crtc_init_colorops(struct drm_crtc *crtc)
+{
+ struct drm_prop_enum_list pipelines[MAX_CRTC_COLOR_PIPELINES] = {};
+ struct drm_device *dev = crtc->dev;
+ struct amdgpu_device *adev = drm_to_adev(dev);
+ struct dc *dc = adev->dm.dc;
+ int len = 0;
+ int ret = 0;
+ int i;
+
+ /* initialize pipeline */
+ if (dc->ctx->dce_version >= DCN_VERSION_3_0) {
+ ret = amdgpu_dm_initialize_crtc_default_pipeline(crtc, &pipelines[len]);
+ if (ret) {
+ drm_err(dev, "Failed to create color pipeline for CRTC %d: %d\n",
+ crtc->base.id, ret);
+ goto out;
+ }
+ len++;
+
+ /* Create COLOR_PIPELINE property and attach */
+ ret = drm_crtc_create_color_pipeline_property(crtc, pipelines, len);
+ }
+
+out:
+ for (i = 0; i < len; i++)
+ kfree(pipelines[i].name);
+
+ return ret;
+}
+
+
#endif
/* Implemented only the options currently available for the driver */
@@ -838,6 +876,10 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
#ifdef AMD_PRIVATE_COLOR
dm_crtc_additional_color_mgmt(&acrtc->base);
+#else
+ res = dm_crtc_init_colorops(&acrtc->base);
+ if (res)
+ return res;
#endif
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v3 17/19] drm/amd/display: enable post-blend CTM colorop
2026-11-24 18:03 ` [PATCH v3 17/19] drm/amd/display: enable post-blend CTM colorop Melissa Wen
@ 2026-11-24 18:46 ` sashiko-bot
0 siblings, 0 replies; 26+ messages in thread
From: sashiko-bot @ 2026-11-24 18:46 UTC (permalink / raw)
To: Melissa Wen; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amd/display: NULL deref on kasprintf() failure in CRTC
pipeline init
- [Medium] drm/amd/display: missing error unwind in
amdgpu_dm_crtc_init()
--
commit a6af21490f0a9bf347d95f27bc66b20a42758591
Author: Melissa Wen <mwen@igalia.com>
drm/amd/display: enable post-blend CTM colorop
This commit initializes the AMD post-blend color pipeline on DCN 3.0 and
newer with a 3x4 CTM colorop and programs it when a CRTC color pipeline is
active.
Link: https://dri.freedesktop.org/docs/drm/gpu/amdgpu/display/display-manager.html#dc-color-capabilities-between-dcn-generations
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> index c6bb9fec92175..dcd497b644c11 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> @@ -305,3 +305,41 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
> return amdgpu_dm_build_default_pipeline(dev, plane, hw_3d_lut, list);
> }
> EXPORT_IF_KUNIT(amdgpu_dm_initialize_default_pipeline);
> +
> +int amdgpu_dm_initialize_crtc_default_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));
> +
> + /* 3x4 matrix */
> + ops[i] = kzalloc_obj(struct drm_colorop);
> + if (!ops[i]) {
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> +
> + ret = drm_crtc_colorop_ctm_3x4_init(dev, ops[i], crtc, &dm_colorop_funcs,
> + DRM_COLOROP_FLAG_ALLOW_BYPASS);
> + if (ret)
> + goto cleanup;
> +
> + list->type = ops[i]->base.id;
> +
> + i++;
> +
> + list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
> +
> + return 0;
[Severity: Medium]
What happens if kasprintf() returns NULL here? Unlike
amdgpu_dm_build_default_pipeline(), this returns 0 with list->name set to
NULL, so dm_crtc_init_colorops() passes pipelines[0].name to
drm_crtc_create_color_pipeline_property() -> drm_property_add_enum(),
causing a NULL pointer dereference in strlen(name) and skipping cleanup of
the initialized colorop.
[ ... ]
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> index 3e0128a29d775..af8be7f8784d3 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
[ ... ]
> @@ -840,6 +878,10 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
>
> #ifdef AMD_PRIVATE_COLOR
> dm_crtc_additional_color_mgmt(&acrtc->base);
> +#else
> + res = dm_crtc_init_colorops(&acrtc->base);
> + if (res)
> + return res;
> #endif
> return 0;
[Severity: Medium]
Should a failure in dm_crtc_init_colorops() clear
dm->adev->mode_info.crtcs[crtc_index] and jump to error_ism_fini instead of
returning directly? Returning early skips amdgpu_dm_ism_flush(),
drm_crtc_cleanup(), drm_plane_cleanup(), and freeing acrtc and
cursor_plane, leaving the partially initialized CRTC registered in
mode_config and stored in mode_info.crtcs[crtc_index].
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124181652.1333986-1-mwen@igalia.com?part=17
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v3 18/19] drm/amd/display: add support to post-blend 1D-Curve colorop
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (16 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 17/19] drm/amd/display: enable post-blend CTM colorop Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:42 ` sashiko-bot
2026-11-24 18:03 ` [PATCH v3 19/19] drm/amd/display: add support to post-blend 1D-LUT colorop Melissa Wen
18 siblings, 1 reply; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
Add Regamma TF operation as 1D Curve colorop to the AMD post-blend color
pipeline. Allow individual changes on colorop properties by using the
committed state of colorops that aren't in the commit.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- use the committed state of the curve colorop when it isn't part of the
commit
- reject a colorop of unexpected type
- drop the NULL colorop path since it's now only called with a colorop
set
---
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 58 +++++++++++++++++++
.../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 20 +++++++
2 files changed, 78 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
index 243e52766701..97bdb8dbddb0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
@@ -1287,6 +1287,41 @@ __set_dm_crtc_colorop_3x4_matrix(struct drm_crtc_state *crtc_state,
return 0;
}
+static int
+__set_dm_crtc_colorop_regamma(struct drm_crtc_state *crtc_state,
+ struct dc_stream_state *dc_stream_state,
+ struct drm_colorop *colorop,
+ struct dc_transfer_func *tf)
+{
+ struct drm_colorop_state *colorop_state = NULL;
+ struct drm_atomic_commit *state = crtc_state->state;
+ enum dc_transfer_func_predefined default_tf = TRANSFER_FUNCTION_LINEAR;
+ struct drm_device *dev = crtc_state->state->dev;
+ int ret = 0;
+
+ tf->type = TF_TYPE_BYPASS;
+
+ /* 1D Curve - Regamma TF */
+ if (colorop->type != DRM_COLOROP_1D_CURVE)
+ return -EINVAL;
+
+ colorop_state = drm_atomic_get_new_colorop_state(state, colorop);
+ if (!colorop_state)
+ colorop_state = colorop->state;
+
+ if (!colorop_state->bypass) {
+ drm_dbg(dev, "Regamma TF colorop with ID: %d\n", colorop->base.id);
+ tf->type = TF_TYPE_DISTRIBUTED_POINTS;
+ tf->tf = default_tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type);
+ tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE;
+ ret = __set_output_tf(tf, 0, 0, false);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
/*
* amdgpu_dm_crtc_set_colorop_properties: Set colorop props if programmable by DC.
* @crtc_state: DRM crtc state
@@ -1312,6 +1347,7 @@ amdgpu_dm_crtc_set_colorop_properties(struct drm_crtc_state *crtc_state,
{
struct drm_colorop *colorop = crtc_state->color_pipeline;
struct drm_device *dev = crtc_state->crtc->dev;
+ struct dc_transfer_func *out_tf;
int ret;
if (drm_WARN_ON(dev, !colorop))
@@ -1319,6 +1355,28 @@ amdgpu_dm_crtc_set_colorop_properties(struct drm_crtc_state *crtc_state,
/* 3x4 matrix */
ret = __set_dm_crtc_colorop_3x4_matrix(crtc_state, dc_stream_state, colorop, check_only);
+ if (ret)
+ return ret;
+
+ /* 1D Curve - REGAMMA TF */
+ colorop = colorop->next;
+ if (!colorop) {
+ drm_dbg(dev, "no regamma TF colorop found\n");
+ return -EINVAL;
+ }
+
+ if (check_only) {
+ out_tf = kvzalloc_obj(*out_tf);
+ if (!out_tf)
+ return -ENOMEM;
+ } else {
+ out_tf = &dc_stream_state->out_transfer_func;
+ }
+
+ ret = __set_dm_crtc_colorop_regamma(crtc_state, dc_stream_state, colorop, out_tf);
+
+ if (check_only)
+ kvfree(out_tf);
return ret;
}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
index c88c17da1058..c97a087682c4 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
@@ -307,6 +307,7 @@ int amdgpu_dm_initialize_crtc_default_pipeline(struct drm_crtc *crtc,
{
struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
struct drm_device *dev = crtc->dev;
+ struct amdgpu_device *adev = drm_to_adev(dev);
int ret;
int i = 0;
@@ -328,6 +329,25 @@ int amdgpu_dm_initialize_crtc_default_pipeline(struct drm_crtc *crtc,
i++;
+ if (adev->dm.dc->caps.color.mpc.ogam_ram) {
+ /* 1D Curve - REGAMMA TF */
+ ops[i] = kzalloc_obj(*ops[0]);
+ if (!ops[i]) {
+ ret = -ENOMEM;
+ goto cleanup;
+ }
+
+ ret = drm_crtc_colorop_curve_1d_init(dev, ops[i], crtc, &dm_colorop_funcs,
+ amdgpu_dm_supported_shaper_tfs,
+ DRM_COLOROP_FLAG_ALLOW_BYPASS);
+ if (ret)
+ goto cleanup;
+
+ drm_colorop_set_next_property(ops[i-1], ops[i]);
+
+ i++;
+ }
+
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v3 18/19] drm/amd/display: add support to post-blend 1D-Curve colorop
2026-11-24 18:03 ` [PATCH v3 18/19] drm/amd/display: add support to post-blend 1D-Curve colorop Melissa Wen
@ 2026-11-24 18:42 ` sashiko-bot
0 siblings, 0 replies; 26+ messages in thread
From: sashiko-bot @ 2026-11-24 18:42 UTC (permalink / raw)
To: Melissa Wen; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] drm/amd/display: missing ogam_ram check when applying CRTC
regamma colorop
- [Medium] drm/amd/display: stale out_transfer_func.tf in
__set_dm_crtc_colorop_regamma()
- [Medium] drm/amd/display: colorop leak in
amdgpu_dm_initialize_crtc_default_pipeline()
- [Medium] drm/amd/display: unchecked kasprintf() in CRTC default
pipeline init
- [Low] drm/amd/display: unused param and variable in
__set_dm_crtc_colorop_regamma()
--
commit a10135e3487a34c61aa5df0ce12f0d6b9ae37b7c
Author: Melissa Wen <mwen@igalia.com>
drm/amd/display: add support to post-blend 1D-Curve colorop
This commit adds a 1D curve regamma transfer function colorop to the AMD
CRTC post-blend color pipeline and applies its state during atomic check
and commit.
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> index 12665810708e2..f807a2e8c0f71 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> @@ -1287,6 +1287,41 @@ __set_dm_crtc_colorop_3x4_matrix(struct drm_crtc_state *crtc_state,
> return 0;
> }
>
> +static int
> +__set_dm_crtc_colorop_regamma(struct drm_crtc_state *crtc_state,
> + struct dc_stream_state *dc_stream_state,
> + struct drm_colorop *colorop,
> + struct dc_transfer_func *tf)
> +{
> + struct drm_colorop_state *colorop_state = NULL;
> + struct drm_atomic_commit *state = crtc_state->state;
> + enum dc_transfer_func_predefined default_tf = TRANSFER_FUNCTION_LINEAR;
> + struct drm_device *dev = crtc_state->state->dev;
> + int ret = 0;
> +
> + tf->type = TF_TYPE_BYPASS;
> +
> + /* 1D Curve - Regamma TF */
> + if (colorop->type != DRM_COLOROP_1D_CURVE)
> + return -EINVAL;
[Severity: Medium]
Does setting only tf->type = TF_TYPE_BYPASS leave a stale transfer
function in dc_stream_state->out_transfer_func.tf when this colorop is
bypassed? Other transfer function helpers use __set_tf_bypass(), which
also resets tf->tf to TRANSFER_FUNCTION_LINEAR. Downstream DC paths such
as set_avi_info_frame() and get_hdr_visual_confirm_color() check
stream->out_transfer_func.tf without checking whether out_transfer_func.type
is TF_TYPE_BYPASS, so a prior TRANSFER_FUNCTION_GAMMA22 or
TRANSFER_FUNCTION_PQ value stays active for AVI InfoFrame colorimetry and
HDR visual confirm even after regamma is bypassed.
> +
> + colorop_state = drm_atomic_get_new_colorop_state(state, colorop);
> + if (!colorop_state)
> + colorop_state = colorop->state;
> +
> + if (!colorop_state->bypass) {
> + drm_dbg(dev, "Regamma TF colorop with ID: %d\n", colorop->base.id);
> + tf->type = TF_TYPE_DISTRIBUTED_POINTS;
> + tf->tf = default_tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type);
[Severity: Low]
dc_stream_state is unused in __set_dm_crtc_colorop_regamma(), and
default_tf is assigned here without being read in this patch, which
triggers -Wunused-but-set-variable under W=1 builds until commit
"drm/amd/display: add support to post-blend 1D-LUT colorop" uses it.
> + tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE;
> + ret = __set_output_tf(tf, 0, 0, false);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> /*
> * amdgpu_dm_crtc_set_colorop_properties: Set colorop props if programmable by DC.
> * @crtc_state: DRM crtc state
> @@ -1312,6 +1347,7 @@ amdgpu_dm_crtc_set_colorop_properties(struct drm_crtc_state *crtc_state,
> {
> struct drm_colorop *colorop = crtc_state->color_pipeline;
> struct drm_device *dev = crtc_state->crtc->dev;
> + struct dc_transfer_func *out_tf;
> int ret;
>
> if (drm_WARN_ON(dev, !colorop))
> @@ -1319,6 +1355,28 @@ amdgpu_dm_crtc_set_colorop_properties(struct drm_crtc_state *crtc_state,
>
> /* 3x4 matrix */
> ret = __set_dm_crtc_colorop_3x4_matrix(crtc_state, dc_stream_state, colorop, check_only);
> + if (ret)
> + return ret;
> +
> + /* 1D Curve - REGAMMA TF */
> + colorop = colorop->next;
> + if (!colorop) {
> + drm_dbg(dev, "no regamma TF colorop found\n");
> + return -EINVAL;
> + }
[Severity: Medium]
Should this check adev->dm.dc->caps.color.mpc.ogam_ram before requiring
the regamma colorop? amdgpu_dm_initialize_crtc_default_pipeline() only
appends the 1D curve colorop when mpc.ogam_ram is set, so when it is false
the pipeline still registers with just the 3x4 CTM (ops[0]->next == NULL)
and every atomic check or commit using that pipeline will fail here with
-EINVAL.
[ ... ]
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> index dcd497b644c11..f5991f29973d5 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> @@ -311,6 +311,7 @@ int amdgpu_dm_initialize_crtc_default_pipeline(struct drm_crtc *crtc,
> {
> struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
> struct drm_device *dev = crtc->dev;
> + struct amdgpu_device *adev = drm_to_adev(dev);
> int ret;
> int i = 0;
>
> @@ -332,6 +333,25 @@ int amdgpu_dm_initialize_crtc_default_pipeline(struct drm_crtc *crtc,
>
> i++;
>
> + if (adev->dm.dc->caps.color.mpc.ogam_ram) {
> + /* 1D Curve - REGAMMA TF */
> + ops[i] = kzalloc_obj(*ops[0]);
> + if (!ops[i]) {
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> +
> + ret = drm_crtc_colorop_curve_1d_init(dev, ops[i], crtc, &dm_colorop_funcs,
> + amdgpu_dm_supported_shaper_tfs,
> + DRM_COLOROP_FLAG_ALLOW_BYPASS);
> + if (ret)
> + goto cleanup;
[Severity: Medium]
Does jumping to cleanup leak ops[i] if drm_crtc_colorop_curve_1d_init()
fails before linking it into dev->mode_config.colorop_list?
drm_common_colorop_init() returns early if drm_mode_object_add() fails
before list_add_tail(&colorop->head, &config->colorop_list), and
drm_colorop_pipeline_destroy() only frees colorops already on
colorop_list.
> +
> + drm_colorop_set_next_property(ops[i-1], ops[i]);
> +
> + i++;
> + }
> +
> list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
>
> return 0;
[Severity: Medium]
This problem wasn't introduced by this patch (it comes from commit
"drm/amd/display: enable post-blend CTM colorop" earlier in the series),
but what happens if kasprintf() returns NULL for list->name? Returning 0
skips drm_colorop_pipeline_destroy() and leaves a NULL name in pipelines[]
when dm_crtc_init_colorops() calls drm_crtc_create_color_pipeline_property(),
leading to a NULL pointer dereference in strlen(name) inside
drm_property_add_enum().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124181652.1333986-1-mwen@igalia.com?part=18
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v3 19/19] drm/amd/display: add support to post-blend 1D-LUT colorop
2026-11-24 18:03 [PATCH v3 00/19] drm/drm_colorop: add post-blend colorop support to AMD display driver Melissa Wen
` (17 preceding siblings ...)
2026-11-24 18:03 ` [PATCH v3 18/19] drm/amd/display: add support to post-blend 1D-Curve colorop Melissa Wen
@ 2026-11-24 18:03 ` Melissa Wen
2026-11-24 18:38 ` sashiko-bot
18 siblings, 1 reply; 26+ messages in thread
From: Melissa Wen @ 2026-11-24 18:03 UTC (permalink / raw)
To: airlied, alexander.deucher, christian.koenig, harry.wentland,
maarten.lankhorst, mripard, simona, siqueira, sunpeng.li,
tzimmermann
Cc: Ariel DAlessandro, nfraprado, Alex Hung, Simon Ser, Uma Shankar,
Chaitanya Kumar Borah, Robert Mader, Xaver Hugl, Pekka Paalanen,
John Harrison, Matthew Schwartz, Daniel Stone, kernel-dev,
amd-gfx, dri-devel, Leandro Ribeiro, Melissa Wen
Add Regamma LUT operation as 1D LUT colorop to AMD post-blend color
pipeline.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
v3:
- use the committed state of the LUT colorop when it isn't part of the
commit
- reject a colorop of unexpected type
- check for the LUT colorop and drop the redundant check from
amdgpu_dm_crtc_set_colorop_properties()
---
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 35 +++++++++++++++++--
.../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 18 ++++++++++
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
index 97bdb8dbddb0..8eaf67a83c37 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
@@ -1297,6 +1297,8 @@ __set_dm_crtc_colorop_regamma(struct drm_crtc_state *crtc_state,
struct drm_atomic_commit *state = crtc_state->state;
enum dc_transfer_func_predefined default_tf = TRANSFER_FUNCTION_LINEAR;
struct drm_device *dev = crtc_state->state->dev;
+ const struct drm_color_lut32 *regamma_lut;
+ u32 regamma_size;
int ret = 0;
tf->type = TF_TYPE_BYPASS;
@@ -1319,6 +1321,36 @@ __set_dm_crtc_colorop_regamma(struct drm_crtc_state *crtc_state,
return ret;
}
+ /* 1D LUT - Regamma LUT */
+ colorop = colorop->next;
+ if (!colorop || colorop->type != DRM_COLOROP_1D_LUT) {
+ drm_dbg(dev, "no Regamma LUT colorop found\n");
+ return -EINVAL;
+ }
+
+ colorop_state = drm_atomic_get_new_colorop_state(state, colorop);
+ if (!colorop_state)
+ colorop_state = colorop->state;
+
+ if (!colorop_state->bypass) {
+ drm_dbg(dev, "Regamma LUT colorop with ID: %d\n", colorop->base.id);
+ tf->type = TF_TYPE_DISTRIBUTED_POINTS;
+ tf->tf = default_tf;
+ tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE;
+ regamma_lut = __extract_blob_lut32(colorop_state->data, ®amma_size);
+ regamma_size = regamma_lut != NULL ? regamma_size : 0;
+
+ /* Custom LUT size must be the same as supported size */
+ if (regamma_size == colorop->size) {
+ ret = __set_output_tf_32(tf, regamma_lut, regamma_size, false);
+ if (ret)
+ return ret;
+ } else {
+ drm_dbg(dev, "Regamma LUT size doesn't match blob size\n");
+ return -EINVAL;
+ }
+ }
+
return 0;
}
@@ -1358,7 +1390,7 @@ amdgpu_dm_crtc_set_colorop_properties(struct drm_crtc_state *crtc_state,
if (ret)
return ret;
- /* 1D Curve - REGAMMA TF */
+ /* 1D Curve & LUT - REGAMMA TF & LUT */
colorop = colorop->next;
if (!colorop) {
drm_dbg(dev, "no regamma TF colorop found\n");
@@ -1401,7 +1433,6 @@ amdgpu_dm_crtc_set_colorop_properties(struct drm_crtc_state *crtc_state,
* Returns:
* 0 on success. Error code if validation fails.
*/
-
int amdgpu_dm_check_crtc_color_mgmt(struct dm_crtc_state *crtc,
bool check_only)
{
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
index c97a087682c4..d909fc46755c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
@@ -346,6 +346,24 @@ int amdgpu_dm_initialize_crtc_default_pipeline(struct drm_crtc *crtc,
drm_colorop_set_next_property(ops[i-1], ops[i]);
i++;
+
+ /* 1D LUT - REGAMMA LUT */
+ ops[i] = kzalloc_obj(*ops[0]);
+ if (!ops[i]) {
+ ret = -ENOMEM;
+ goto cleanup;
+ }
+
+ ret = drm_crtc_colorop_curve_1d_lut_init(dev, ops[i], crtc, &dm_colorop_funcs,
+ MAX_COLOR_LUT_ENTRIES,
+ DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
+ DRM_COLOROP_FLAG_ALLOW_BYPASS);
+ if (ret)
+ goto cleanup;
+
+ drm_colorop_set_next_property(ops[i-1], ops[i]);
+
+ i++;
}
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
--
2.53.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v3 19/19] drm/amd/display: add support to post-blend 1D-LUT colorop
2026-11-24 18:03 ` [PATCH v3 19/19] drm/amd/display: add support to post-blend 1D-LUT colorop Melissa Wen
@ 2026-11-24 18:38 ` sashiko-bot
0 siblings, 0 replies; 26+ messages in thread
From: sashiko-bot @ 2026-11-24 18:38 UTC (permalink / raw)
To: Melissa Wen; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amd/display: leak of ops[i] on init failure in
amdgpu_dm_initialize_crtc_default_pipeline()
- [Medium] drm/amd/display: unchecked kasprintf() in
amdgpu_dm_initialize_crtc_default_pipeline()
--
commit a8178a6daf7c1cd1a2cd47ce46fa81a020bacd1b
Author: Melissa Wen <mwen@igalia.com>
drm/amd/display: add support to post-blend 1D-LUT colorop
This commit adds the Regamma 1D LUT colorop to the AMD CRTC post-blend
color pipeline and wires up its state handling in
__set_dm_crtc_colorop_regamma().
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> index f5991f29973d5..8218a9cbad33b 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> @@ -350,6 +350,24 @@ int amdgpu_dm_initialize_crtc_default_pipeline(struct drm_crtc *crtc,
> drm_colorop_set_next_property(ops[i-1], ops[i]);
>
> i++;
> +
> + /* 1D LUT - REGAMMA LUT */
> + ops[i] = kzalloc_obj(*ops[0]);
> + if (!ops[i]) {
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> +
> + ret = drm_crtc_colorop_curve_1d_lut_init(dev, ops[i], crtc, &dm_colorop_funcs,
> + MAX_COLOR_LUT_ENTRIES,
> + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
> + DRM_COLOROP_FLAG_ALLOW_BYPASS);
> + if (ret)
> + goto cleanup;
[Severity: Medium]
Can jumping to cleanup here leak ops[i] if
drm_crtc_colorop_curve_1d_lut_init() fails?
In drm_crtc_colorop_init() -> drm_common_colorop_init(), if
drm_mode_object_add() fails, the function returns before linking ops[i] into
config->colorop_list. Because cleanup only calls
drm_colorop_pipeline_destroy(dev) to free colorops on config->colorop_list,
ops[i] is leaked.
> +
> + drm_colorop_set_next_property(ops[i-1], ops[i]);
> +
> + i++;
> }
>
> list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
[Severity: Medium]
Should list->name be checked for NULL here, as in
amdgpu_dm_build_default_pipeline()?
If kasprintf() fails, amdgpu_dm_initialize_crtc_default_pipeline() skips
cleanup and returns 0 with list->name set to NULL. The caller
dm_crtc_init_colorops() then passes the NULL pipeline name to
drm_crtc_create_color_pipeline_property(), causing a NULL pointer
dereference in strlen(name) inside drm_property_add_enum().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124181652.1333986-1-mwen@igalia.com?part=19
^ permalink raw reply [flat|nested] 26+ messages in thread