This adds helper functions to create 1D Lut color block
capabilities. It exposes the hardware block as segments
which are converted to blob and passed in the property.

Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.bo...@intel.com>
Signed-off-by: Uma Shankar <uma.shan...@intel.com>
---
 drivers/gpu/drm/drm_colorop.c | 24 +++++++++++++++++++++++-
 include/drm/drm_colorop.h     |  4 +++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index cfdc8e751012..98aef26c0c55 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -43,7 +43,6 @@ static const struct drm_prop_enum_list 
drm_colorop_curve_1d_type_enum_list[] = {
 };
 
 /* Init Helpers */
-__maybe_unused
 static int drm_create_colorop_capability_prop(struct drm_device *dev,
                                              struct drm_colorop *colorop,
                                              struct drm_property_blob *blob)
@@ -65,6 +64,29 @@ static int drm_create_colorop_capability_prop(struct 
drm_device *dev,
        return 0;
 }
 
+int drm_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 1D LUT */
+       if (colorop->type != DRM_COLOROP_1D_LUT)
+               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);
+}
+EXPORT_SYMBOL(drm_colorop_lutcaps_init);
+
 int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
                     struct drm_plane *plane, enum drm_colorop_type type)
 {
diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index f417e109c40a..d15d5b489401 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -233,7 +233,9 @@ static inline struct drm_colorop *drm_colorop_find(struct 
drm_device *dev,
 
 int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
                     struct drm_plane *plane, enum drm_colorop_type type);
-
+int drm_colorop_lutcaps_init(struct drm_colorop *colorop, struct drm_plane 
*plane,
+                            const struct drm_color_lut_range *ranges,
+                            size_t length);
 struct drm_colorop_state *
 drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);
 
-- 
2.42.0

Reply via email to