]> Gentwo Git Trees - linux/.git/commitdiff
drm/colorop: Add TYPE property
authorHarry Wentland <harry.wentland@amd.com>
Sat, 15 Nov 2025 00:01:30 +0000 (17:01 -0700)
committerSimon Ser <contact@emersion.fr>
Wed, 26 Nov 2025 22:03:31 +0000 (23:03 +0100)
Add a read-only TYPE property. The TYPE specifies the colorop
type, such as enumerated curve, 1D LUT, CTM, 3D LUT, PWL LUT,
etc.

For now we're only introducing an enumerated 1D LUT type to
illustrate the concept.

Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
Link: https://patch.msgid.link/20251115000237.3561250-6-alex.hung@amd.com
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_atomic_uapi.c
drivers/gpu/drm/drm_colorop.c
include/drm/drm_colorop.h
include/uapi/drm/drm_mode.h

index 6438a3938032a4694e211f6673d7ef6aec87bbef..99545184960f0cc33f0a13a69b4f8a6e164fa798 100644 (file)
@@ -634,8 +634,8 @@ drm_atomic_get_colorop_state(struct drm_atomic_state *state,
        state->colorops[index].new_state = colorop_state;
        colorop_state->state = state;
 
-       drm_dbg_atomic(colorop->dev, "Added [COLOROP:%d] %p state to %p\n",
-                      colorop->base.id, colorop_state, state);
+       drm_dbg_atomic(colorop->dev, "Added [COLOROP:%d:%d] %p state to %p\n",
+                      colorop->base.id, colorop->type, colorop_state, state);
 
        return colorop_state;
 }
index 148f11895b9e5bfa48ea5cd5435874050419750b..55b3046c5f1c604422069ea66001853155f4487c 100644 (file)
@@ -666,7 +666,12 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,
                                const struct drm_colorop_state *state,
                                struct drm_property *property, uint64_t *val)
 {
-       return -EINVAL;
+       if (property == colorop->type_property)
+               *val = colorop->type;
+       else
+               return -EINVAL;
+
+       return 0;
 }
 
 static int drm_atomic_set_writeback_fb_for_connector(
index 59af7ac888d6ac298180cc0f930bce237f98be2b..d0e839a1df7c78f808e1ddbc699b158c3e3e3573 100644 (file)
@@ -101,3 +101,15 @@ void drm_colorop_reset(struct drm_colorop *colorop)
        if (colorop->state)
                __drm_colorop_reset(colorop, colorop->state);
 }
+
+static const char * const colorop_type_name[] = {
+       [DRM_COLOROP_1D_CURVE] = "1D Curve",
+};
+
+const char *drm_get_colorop_type_name(enum drm_colorop_type type)
+{
+       if (WARN_ON(type >= ARRAY_SIZE(colorop_type_name)))
+               return "unknown";
+
+       return colorop_type_name[type];
+}
index 28bb7091ef1f405ca1104d08696a3d3b9b09c5a6..0bda70f4e82a769d3850ac975c071debac4345e3 100644 (file)
@@ -112,6 +112,21 @@ struct drm_colorop {
        /** @properties: property tracking for this colorop */
        struct drm_object_properties properties;
 
+       /**
+        * @type:
+        *
+        * Read-only
+        * Type of color operation
+        */
+       enum drm_colorop_type type;
+
+       /**
+        * @type_property:
+        *
+        * Read-only "TYPE" property for specifying the type of
+        * this color operation. The type is enum drm_colorop_type.
+        */
+       struct drm_property *type_property;
 };
 
 #define obj_to_colorop(x) container_of(x, struct drm_colorop, base)
@@ -166,4 +181,13 @@ static inline unsigned int drm_colorop_index(const struct drm_colorop *colorop)
 #define drm_for_each_colorop(colorop, dev) \
        list_for_each_entry(colorop, &(dev)->mode_config.colorop_list, head)
 
+/**
+ * drm_get_colorop_type_name - return a string for colorop type
+ * @type: colorop type to compute name of
+ *
+ * In contrast to the other drm_get_*_name functions this one here returns a
+ * const pointer and hence is threadsafe.
+ */
+const char *drm_get_colorop_type_name(enum drm_colorop_type type);
+
 #endif /* __DRM_COLOROP_H__ */
index ec27125c292864d6c2c38c8a952bce6432a6c408..c419f93eb94dc4e9ee991fa4e6b37c48c92b60f8 100644 (file)
@@ -858,6 +858,25 @@ struct drm_color_lut {
        __u16 reserved;
 };
 
+/**
+ * enum drm_colorop_type - Type of color operation
+ *
+ * drm_colorops can be of many different types. Each type behaves differently
+ * and defines a different set of properties. This enum defines all types and
+ * gives a high-level description.
+ */
+enum drm_colorop_type {
+       /**
+        * @DRM_COLOROP_1D_CURVE:
+        *
+        * enum string "1D Curve"
+        *
+        * A 1D curve that is being applied to all color channels. The
+        * curve is specified via the CURVE_1D_TYPE colorop property.
+        */
+       DRM_COLOROP_1D_CURVE
+};
+
 /**
  * struct drm_plane_size_hint - Plane size hints
  * @width: The width of the plane in pixel