public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Uma Shankar <uma.shankar@intel.com>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: ville.syrjala@intel.com, maarten.lankhorst@intel.com
Subject: [RFC v1 5/6] drm: Define helper to set legacy gamma table size
Date: Tue, 26 Sep 2017 13:32:57 +0530	[thread overview]
Message-ID: <1506412979-22028-6-git-send-email-uma.shankar@intel.com> (raw)
In-Reply-To: <1506412979-22028-1-git-send-email-uma.shankar@intel.com>

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

Signed-off-by: Uma Shankar <uma.shankar@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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-09-26  8:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26  8:02 [RFC V1 0/6] Add Plane Color Properties Uma Shankar
2017-09-26  8:02 ` [RFC v1 1/6] drm: Add Plane Degamma properties Uma Shankar
2017-09-26  8:02 ` [RFC v1 2/6] drm: Add Plane CTM property Uma Shankar
2017-09-26  8:02 ` [RFC v1 3/6] drm: Add Plane Gamma properties Uma Shankar
2017-09-26  8:02 ` [RFC v1 4/6] drm: Define helper function for plane color enabling Uma Shankar
2017-09-26  8:02 ` Uma Shankar [this message]
2017-09-26 10:05   ` [RFC v1 5/6] drm: Define helper to set legacy gamma table size Lankhorst, Maarten
2017-09-26 10:11     ` Shankar, Uma
2017-09-26 10:15       ` Lankhorst, Maarten
2017-09-26 10:20         ` Shankar, Uma
2017-09-26  8:02 ` [RFC v1 6/6] drm/i915: Enable plane color features Uma Shankar
2017-09-26  9:31 ` ✓ Fi.CI.BAT: success for Add Plane Color Properties Patchwork
2017-09-26 11:16 ` [Intel-gfx] [RFC V1 0/6] " Daniel Vetter
2017-09-26 12:53 ` ✓ Fi.CI.IGT: success for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506412979-22028-6-git-send-email-uma.shankar@intel.com \
    --to=uma.shankar@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@intel.com \
    --cc=ville.syrjala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox