[PATCH 07/23] drm: Define helper to initialize segmented 1D LUT
Chaitanya Kumar Borah
chaitanya.kumar.borah at intel.com
Mon Jun 16 11:54:32 UTC 2025
From: Uma Shankar <uma.shankar at intel.com>
This adds helper functions to create 1D multi-segmented Lut
color block capabilities. It exposes the hardware block as segments
which are converted to blob and passed in the property.
This also adds helper to initialize 1D segmented LUT.
v2: Squashed the 1d lut helpers (Dmitry)
v3: Change name space to drm_plane_*
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
drivers/gpu/drm/drm_colorop.c | 68 +++++++++++++++++++++++++++++++++++
include/drm/drm_colorop.h | 4 +++
2 files changed, 72 insertions(+)
diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index d5469365a972..08be029e6526 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -91,6 +91,48 @@ static const struct drm_prop_enum_list drm_colorop_lut3d_interpolation_list[] =
};
/* Init Helpers */
+static int drm_create_colorop_capability_prop(struct drm_device *dev,
+ struct drm_colorop *colorop,
+ struct drm_property_blob *blob)
+{
+ struct drm_property *prop = NULL;
+
+ prop = drm_property_create(dev, DRM_MODE_PROP_BLOB |
+ DRM_MODE_PROP_ATOMIC |
+ DRM_MODE_PROP_IMMUTABLE,
+ "HW_CAPS", 1);
+ if (!prop)
+ return -ENOMEM;
+
+ colorop->hw_caps_property = prop;
+ drm_object_attach_property(&colorop->base,
+ colorop->hw_caps_property,
+ blob->base.id);
+
+ return 0;
+}
+
+static int drm_plane_colorop_lutcaps_init(struct drm_colorop *colorop,
+ struct drm_plane *plane,
+ const struct drm_color_lut_range *ranges,
+ size_t length)
+{
+ struct drm_device *dev = plane->dev;
+ struct drm_property_blob *blob;
+
+ /* Create Color Caps property for multi-segmented 1D LUT */
+ if (colorop->type != DRM_COLOROP_1D_LUT_MULTSEG)
+ return -EINVAL;
+
+ if (WARN_ON(length == 0 || length % sizeof(ranges[0]) != 0))
+ return -EINVAL;
+
+ blob = drm_property_create_blob(plane->dev, length, ranges);
+ if (IS_ERR(blob))
+ return PTR_ERR(blob);
+
+ return drm_create_colorop_capability_prop(dev, colorop, blob);
+}
static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, enum drm_colorop_type type, uint32_t flags)
@@ -338,6 +380,32 @@ 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_curve_1d_lut_multseg_init(struct drm_device *dev, struct drm_colorop *colorop,
+ struct drm_plane *plane,
+ const struct drm_color_lut_range *ranges,
+ size_t length, bool allow_bypass)
+{
+ int ret;
+
+ ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT_MULTSEG, allow_bypass);
+ if (ret)
+ return ret;
+
+ ret = drm_plane_colorop_lutcaps_init(colorop, plane, ranges, length);
+ if (ret)
+ return ret;
+
+ /* data */
+ ret = drm_colorop_create_data_prop(dev, colorop);
+ if (ret)
+ return ret;
+
+ drm_colorop_reset(colorop);
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_multseg_init);
+
int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, uint32_t flags)
{
diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index 423486d64200..c782c6e80e42 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -393,6 +393,10 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color
struct drm_plane *plane, uint32_t lut_size,
enum drm_colorop_lut1d_interpolation_type lut1d_interpolation,
uint32_t flags);
+int drm_plane_colorop_curve_1d_lut_multseg_init(struct drm_device *dev, struct drm_colorop *colorop,
+ struct drm_plane *plane,
+ const struct drm_color_lut_range *ranges,
+ size_t length, bool allow_bypass);
int drm_plane_colorop_ctm_3x3_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, bool allow_bypass);
int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
--
2.25.1
More information about the Intel-gfx-trybot
mailing list