From: "uma.shankar at intel.com (Uma Shankar)" <uma.shan...@intel.com>

Define helper function to enable Plane color features
to attach plane color properties to plane structure.

(am from https://patchwork.kernel.org/patch/9971333/)

Change-Id: I0a6647607fe482786e7cdb5f997faf196b2f59a2
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
 drivers/gpu/drm/drm_plane.c  | 48 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_color_mgmt.h |  5 ++++
 2 files changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 2c90519576a3e..bc2fc5e6771ac 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -143,6 +143,54 @@ static int create_in_format_blob(struct drm_device *dev, 
struct drm_plane *plane
        return 0;
 }
 
+ /**
+ * drm_plane_enable_color_mgmt - enable color management properties
+ * @plane: DRM Plane
+ * @plane_degamma_lut_size: the size of the degamma lut (before CSC)
+ * @plane_has_ctm: whether to attach ctm_property for CSC matrix
+ * @plane_gamma_lut_size: the size of the gamma lut (after CSC)
+ *
+ * This function lets the driver enable the color correction
+ * properties on a plane. This includes 3 degamma, csc and gamma
+ * properties that userspace can set and 2 size properties to inform
+ * the userspace of the lut sizes. Each of the properties are
+ * optional. The gamma and degamma properties are only attached if
+ * their size is not 0 and ctm_property is only attached if has_ctm is
+ * true.
+ *
+ * Drivers should use drm_atomic_helper_legacy_gamma_set() to implement the
+ * legacy &drm_crtc_funcs.gamma_set callback.
+ */
+void drm_plane_enable_color_mgmt(struct drm_plane *plane,
+                               uint plane_degamma_lut_size,
+                               bool plane_has_ctm,
+                               uint plane_gamma_lut_size)
+{
+       struct drm_device *dev = plane->dev;
+       struct drm_mode_config *config = &dev->mode_config;
+
+       if (plane_degamma_lut_size) {
+               drm_object_attach_property(&plane->base,
+                               config->plane_degamma_lut_property, 0);
+               drm_object_attach_property(&plane->base,
+                               config->plane_degamma_lut_size_property,
+                               plane_degamma_lut_size);
+       }
+
+       if (plane_has_ctm)
+               drm_object_attach_property(&plane->base,
+                               config->plane_ctm_property, 0);
+
+       if (plane_gamma_lut_size) {
+               drm_object_attach_property(&plane->base,
+                               config->plane_gamma_lut_property, 0);
+               drm_object_attach_property(&plane->base,
+                               config->plane_gamma_lut_size_property,
+                               plane_gamma_lut_size);
+       }
+}
+EXPORT_SYMBOL(drm_plane_enable_color_mgmt);
+
 /**
  * drm_universal_plane_init - Initialize a new universal plane object
  * @dev: DRM device
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 03a59cbce6212..155a9ba38471c 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -37,4 +37,9 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
 int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
                                 int gamma_size);
 
+void drm_plane_enable_color_mgmt(struct drm_plane *plane,
+                                uint plane_degamma_lut_size,
+                                bool plane_has_ctm,
+                                uint plane_gamma_lut_size);
+
 #endif
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to