]> Gentwo Git Trees - linux/.git/commitdiff
drm/colorop: allow non-bypass colorops
authorHarry Wentland <harry.wentland@amd.com>
Sat, 15 Nov 2025 00:02:09 +0000 (17:02 -0700)
committerSimon Ser <contact@emersion.fr>
Wed, 26 Nov 2025 22:09:17 +0000 (23:09 +0100)
Not all HW will be able to do bypass on all color
operations. Introduce an 32 bits 'flags' for all colorop
init functions and DRM_COLOROP_FLAG_ALLOW_BYPASS for creating
the BYPASS property when it's true.

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: Simon Ser <contact@emersion.fr>
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-45-alex.hung@amd.com
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_colorop.c
drivers/gpu/drm/vkms/vkms_colorop.c
include/drm/drm_colorop.h

index e9363814d6667477a9e12fff958003cfa28343ba..cd3b7e802416fe03ea670e5984a6d0f1869abe92 100644 (file)
@@ -65,7 +65,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_degam_tfs);
+       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
+                                             amdgpu_dm_supported_degam_tfs,
+                                             DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -81,7 +83,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_mult_init(dev, ops[i], plane);
+       ret = drm_plane_colorop_mult_init(dev, ops[i], plane, DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -96,7 +98,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane);
+       ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane, DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -111,7 +113,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_shaper_tfs);
+       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
+                                             amdgpu_dm_supported_shaper_tfs,
+                                             DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -127,7 +131,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
        }
 
        ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES,
-                                                 DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR);
+                                                 DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
+                                                 DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -142,7 +147,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_blnd_tfs);
+       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
+                                             amdgpu_dm_supported_blnd_tfs,
+                                             DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -158,7 +165,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
        }
 
        ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES,
-                                                 DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR);
+                                                 DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
+                                                 DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
index e49d2442fa12bad397f2eec7a9c7e804c9a70c3b..436d2a948e4184e491b93a7fb56ac1ea0638bcdf 100644 (file)
@@ -787,7 +787,8 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,
 
        drm_printf(p, "colorop[%u]:\n", colorop->base.id);
        drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type));
-       drm_printf(p, "\tbypass=%u\n", state->bypass);
+       if (colorop->bypass_property)
+               drm_printf(p, "\tbypass=%u\n", state->bypass);
 
        switch (colorop->type) {
        case DRM_COLOROP_1D_CURVE:
index f9717d80982906bf9ee5a6696c536e5021def54f..fd666394f31f52eae34d669056e41d3a56732244 100644 (file)
@@ -85,7 +85,8 @@ static const struct drm_prop_enum_list drm_colorop_lut1d_interpolation_list[] =
 /* Init Helpers */
 
 static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
-                                 struct drm_plane *plane, enum drm_colorop_type type)
+                                 struct drm_plane *plane, enum drm_colorop_type type,
+                                 uint32_t flags)
 {
        struct drm_mode_config *config = &dev->mode_config;
        struct drm_property *prop;
@@ -121,16 +122,18 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co
                                   colorop->type_property,
                                   colorop->type);
 
-       /* bypass */
-       prop = drm_property_create_bool(dev, DRM_MODE_PROP_ATOMIC,
-                                       "BYPASS");
-       if (!prop)
-               return -ENOMEM;
-
-       colorop->bypass_property = prop;
-       drm_object_attach_property(&colorop->base,
-                                  colorop->bypass_property,
-                                  1);
+       if (flags & DRM_COLOROP_FLAG_ALLOW_BYPASS) {
+               /* bypass */
+               prop = drm_property_create_bool(dev, DRM_MODE_PROP_ATOMIC,
+                                               "BYPASS");
+               if (!prop)
+                       return -ENOMEM;
+
+               colorop->bypass_property = prop;
+               drm_object_attach_property(&colorop->base,
+                                       colorop->bypass_property,
+                                       1);
+       }
 
        /* next */
        prop = drm_property_create_object(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC,
@@ -195,10 +198,11 @@ EXPORT_SYMBOL(drm_colorop_pipeline_destroy);
  * @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, u64 supported_tfs)
+                                   struct drm_plane *plane, u64 supported_tfs, uint32_t flags)
 {
        struct drm_prop_enum_list enum_list[DRM_COLOROP_1D_CURVE_COUNT];
        int i, len;
@@ -219,7 +223,7 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *
                return -EINVAL;
        }
 
-       ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE);
+       ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE, flags);
        if (ret)
                return ret;
 
@@ -278,16 +282,18 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color
  * @plane: The associated drm_plane
  * @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, uint32_t lut_size,
-                                       enum drm_colorop_lut1d_interpolation_type interpolation)
+                                       enum drm_colorop_lut1d_interpolation_type interpolation,
+                                       uint32_t flags)
 {
        struct drm_property *prop;
        int ret;
 
-       ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT);
+       ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT, flags);
        if (ret)
                return ret;
 
@@ -325,11 +331,11 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color
 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)
+                                  struct drm_plane *plane, uint32_t flags)
 {
        int ret;
 
-       ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4);
+       ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4, flags);
        if (ret)
                return ret;
 
@@ -349,15 +355,16 @@ EXPORT_SYMBOL(drm_plane_colorop_ctm_3x4_init);
  * @dev: DRM device
  * @colorop: The drm_colorop object to initialize
  * @plane: The associated drm_plane
+ * @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
  * @return zero on success, -E value on failure
  */
 int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
-                               struct drm_plane *plane)
+                               struct drm_plane *plane, uint32_t flags)
 {
        struct drm_property *prop;
        int ret;
 
-       ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_MULTIPLIER);
+       ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_MULTIPLIER, flags);
        if (ret)
                return ret;
 
index 7aceb0813b2d7f7919d1dcb09049267f64584283..5c3ffc78aea06fffab56a199fcec30dd9748a0bf 100644 (file)
@@ -31,7 +31,8 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs);
+       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs,
+                                             DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -48,7 +49,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane);
+       ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane, DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -64,7 +65,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane);
+       ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane, DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
@@ -80,7 +81,8 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
        }
 
-       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs);
+       ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs,
+                                             DRM_COLOROP_FLAG_ALLOW_BYPASS);
        if (ret)
                goto cleanup;
 
index 0e1a5e9d26f3e999d1d2c52d626b355d30735f0e..828888861ad9c8f6e569545880ff9530706667ac 100644 (file)
@@ -31,6 +31,9 @@
 #include <drm/drm_mode.h>
 #include <drm/drm_property.h>
 
+/* DRM colorop flags */
+#define DRM_COLOROP_FLAG_ALLOW_BYPASS  (1<<0)  /* Allow bypass on the drm_colorop */
+
 /**
  * enum drm_colorop_curve_1d_type - type of 1D curve
  *
@@ -256,11 +259,12 @@ struct drm_colorop {
         * @bypass_property:
         *
         * Boolean property to control enablement of the color
-        * operation. Setting bypass to "true" shall always be supported
-        * in order to allow compositors to quickly fall back to
-        * alternate methods of color processing. This is important
-        * since setting color operations can fail due to unique
-        * HW constraints.
+        * operation. Only present if DRM_COLOROP_FLAG_ALLOW_BYPASS
+        * flag is set. When present, setting bypass to "true" shall
+        * always be supported to allow compositors to quickly fall
+        * back to alternate methods of color processing. This is
+        * important since setting color operations can fail due to
+        * unique HW constraints.
         */
        struct drm_property *bypass_property;
 
@@ -353,14 +357,15 @@ void drm_colorop_pipeline_destroy(struct drm_device *dev);
 void drm_colorop_cleanup(struct drm_colorop *colorop);
 
 int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
-                                   struct drm_plane *plane, u64 supported_tfs);
+                                   struct drm_plane *plane, u64 supported_tfs, uint32_t flags);
 int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
                                        struct drm_plane *plane, uint32_t lut_size,
-                                       enum drm_colorop_lut1d_interpolation_type interpolation);
+                                       enum drm_colorop_lut1d_interpolation_type interpolation,
+                                       uint32_t flags);
 int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
-                                  struct drm_plane *plane);
+                                  struct drm_plane *plane, uint32_t flags);
 int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
-                               struct drm_plane *plane);
+                               struct drm_plane *plane, uint32_t flags);
 
 struct drm_colorop_state *
 drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);