[RFC v1 5/6] drm: Define helper to set legacy gamma table size

Uma Shankar uma.shankar at intel.com
Tue Sep 26 08:02:57 UTC 2017


Define a helper function to set legacy gamma table
size for planes.

Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
 drivers/gpu/drm/drm_color_mgmt.c |   41 ++++++++++++++++++++++++++++++++++++++
 include/drm/drm_color_mgmt.h     |    3 +++
 include/drm/drm_plane.h          |    4 ++++
 3 files changed, 48 insertions(+)

diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index fe09827..8aef6b5 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -204,6 +204,47 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
 EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size);
 
 /**
+ * drm_mode_plane_set_gamma_size - set the gamma table size
+ * @plane: Plane to set the gamma table size for
+ * @gamma_size: size of the gamma table
+ *
+ * Drivers which support gamma tables should set this to the supported gamma
+ * table size when initializing the Plane. Currently the drm core only supports
+ * a fixed gamma table size.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_mode_plane_set_gamma_size(struct drm_plane *plane,
+				int gamma_size)
+{
+	uint16_t *r_base, *g_base, *b_base;
+	int i;
+
+	plane->gamma_size = gamma_size;
+
+	plane->gamma_store = kcalloc(gamma_size, sizeof(uint16_t) * 3,
+			GFP_KERNEL);
+	if (!plane->gamma_store) {
+		plane->gamma_size = 0;
+		return -ENOMEM;
+	}
+
+	r_base = plane->gamma_store;
+	g_base = r_base + gamma_size;
+	b_base = g_base + gamma_size;
+	for (i = 0; i < gamma_size; i++) {
+		r_base[i] = i << 8;
+		g_base[i] = i << 8;
+		b_base[i] = i << 8;
+	}
+
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_plane_set_gamma_size);
+
+/**
  * drm_mode_gamma_set_ioctl - set the gamma table
  * @dev: DRM device
  * @data: ioctl data
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 155a9ba..2f59c82 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -42,4 +42,7 @@ void drm_plane_enable_color_mgmt(struct drm_plane *plane,
 				 bool plane_has_ctm,
 				 uint plane_gamma_lut_size);
 
+int drm_mode_plane_set_gamma_size(struct drm_plane *plane,
+				  int plane_gamma_size);
+
 #endif
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 172d0c1..7dc8e53 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -575,6 +575,10 @@ struct drm_plane {
 
 	struct drm_property *zpos_property;
 	struct drm_property *rotation_property;
+
+	/* Legacy FB Plane gamma size for reporting to userspace */
+	uint32_t gamma_size;
+	uint16_t *gamma_store;
 };
 
 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
-- 
1.7.9.5



More information about the dri-devel mailing list