[Intel-gfx] [RFC 04/33] drm: Add helper to add color pipeline
Uma Shankar
uma.shankar at intel.com
Tue Aug 29 16:03:53 UTC 2023
From: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
Create a helper function to add a color pipeline for a plane.
Color pipeline is an array of struct drm_color_op which represent
a possible logical combination of color operations. Color
operations can be re-arranged, substracted or added to create
distinct color pipelines to accurately describe the Hardware blocks
present in the display engine.
Co-developed-by: Uma Shankar <uma.shankar at intel.com>
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 42 ++++++++++++++++++++++++++++++++
include/drm/drm_plane.h | 3 +++
2 files changed, 45 insertions(+)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index 026d057d1f1f..43d0187faa98 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -634,6 +634,48 @@ void drm_plane_attach_get_color_pipeline_property(struct drm_plane *plane)
}
EXPORT_SYMBOL(drm_plane_attach_get_color_pipeline_property);
+/**
+ * drm_plane_add_color_pipeline - helper to add a color pipeline
+ * @plane: plane object
+ * @name: name of the color pipeline
+ * @color_pipeline: an array of 'struct drm_color_op' to represent a color pipeline
+ * @len: size of the color pipeline
+ *
+ * This helper can be used to add a distinct color pipeline to a plane. A driver
+ * can provide a meaningful name to the pipeline as it desires.
+ */
+int drm_plane_add_color_pipeline(struct drm_plane *plane, char *name,
+ struct drm_color_op *color_pipeline,
+ size_t len)
+{
+ int ret;
+ struct drm_property *prop;
+ struct drm_property_blob *blob;
+ u32 id = 0;
+
+ prop = plane->get_color_pipeline_prop;
+
+ if (color_pipeline && !len)
+ return -EINVAL;
+
+ if (color_pipeline) {
+ blob = drm_property_create_blob(plane->dev, len, color_pipeline);
+ if (IS_ERR(blob))
+ return PTR_ERR(blob);
+
+ id = blob->base.id;
+ };
+
+ ret = drm_property_add_enum(prop, id, name);
+ if (ret) {
+ if (blob)
+ drm_property_blob_put(blob);
+ return ret;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(drm_plane_add_color_pipeline);
+
/**
* drm_color_lut_check - check validity of lookup table
* @lut: property blob containing LUT to check
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 256c97ead698..ffd7887c2acf 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -955,5 +955,8 @@ int drm_plane_create_get_color_pipeline_property(struct drm_device *dev,
struct drm_plane *plane,
int num_val);
void drm_plane_attach_get_color_pipeline_property(struct drm_plane *plane);
+int drm_plane_add_color_pipeline(struct drm_plane *plane, char *name,
+ struct drm_color_op *color_pipeline,
+ size_t len);
#endif
--
2.38.1
More information about the Intel-gfx
mailing list