[Intel-gfx] [PATCH 2/2] Add gamma property to sprite planes.

Bob Paauwe bob.j.paauwe at intel.com
Thu Feb 27 17:38:14 CET 2014


Add a gamma property to sprite planes that enables/disables the
gamma ramp on sprite planes. By default the gamma ramp is enabled to
match the prior behavior.

v2: Rename property variable from "gamma" to "gamma_property" for clarity
    Change property type from range to enum (Matt)
    Add enum definitions for sprite gamma enable/disable
v3: Rename property name to "Sprite Gamma Enabled" (Matt)

Signed-off-by: Bob Paauwe <bob.j.paauwe at intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h     |  5 +++++
 drivers/gpu/drm/i915/intel_drv.h    |  6 ++++++
 drivers/gpu/drm/i915/intel_sprite.c | 28 ++++++++++++++++++++++------
 3 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 8c64831..69934be 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2671,6 +2671,11 @@ void vlv_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine);
 #define INTEL_BROADCAST_RGB_FULL 1
 #define INTEL_BROADCAST_RGB_LIMITED 2
 
+/* Sprite plane "Sprite Gamma" property */
+#define INTEL_GAMMA_DISABLED 0
+#define INTEL_GAMMA_ENABLED 1
+
+
 static inline uint32_t i915_vgacntrl_reg(struct drm_device *dev)
 {
 	if (HAS_PCH_SPLIT(dev))
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index a4ffc02..7d72c49 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -406,6 +406,12 @@ struct intel_plane {
 	uint32_t src_x, src_y;
 	uint32_t src_w, src_h;
 
+	struct {
+		struct drm_property *gamma_property;
+	} properties;
+
+	bool gamma;
+
 	/* Since we need to change the watermarks before/after
 	 * enabling/disabling the planes, we need to store the parameters here
 	 * as the other pieces of the struct may not reflect the values we want
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index f9f81dd..d2173da 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -37,6 +37,7 @@
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
 
+
 static void
 vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 		 struct drm_framebuffer *fb,
@@ -106,9 +107,8 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
-	 * FIXME should be user controllable via propertiesa.
 	 */
-	sprctl |= SP_GAMMA_ENABLE;
+	sprctl |= (intel_plane->gamma) ? SP_GAMMA_ENABLE : 0;
 
 	if (obj->tiling_mode != I915_TILING_NONE)
 		sprctl |= SP_TILED;
@@ -264,9 +264,8 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
-	 * FIXME should be user controllable via propertiesa.
 	 */
-	sprctl |= SPRITE_GAMMA_ENABLE;
+	sprctl |= (intel_plane->gamma) ? SPRITE_GAMMA_ENABLE : 0;
 
 	if (obj->tiling_mode != I915_TILING_NONE)
 		sprctl |= SPRITE_TILED;
@@ -448,9 +447,8 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
-	 * FIXME should be user controllable via propertiesa.
 	 */
-	dvscntr |= DVS_GAMMA_ENABLE;
+	dvscntr |= (intel_plane->gamma) ? DVS_GAMMA_ENABLE : 0;
 
 	if (obj->tiling_mode != I915_TILING_NONE)
 		dvscntr |= DVS_TILED;
@@ -953,6 +951,11 @@ static int intel_set_property(struct drm_plane *plane,
 				struct drm_property *property,
 				uint64_t value)
 {
+	struct intel_plane *intel_plane = to_intel_plane(plane);
+
+	if (property == intel_plane->properties.gamma_property)
+		intel_plane->gamma = (bool)value;
+
 	return 0;
 }
 
@@ -1079,6 +1082,11 @@ static uint32_t vlv_plane_formats[] = {
 	DRM_FORMAT_VYUY,
 };
 
+static const struct drm_prop_enum_list intel_gamma_enum_list[] = {
+	{ INTEL_GAMMA_DISABLED, "Off" },
+	{ INTEL_GAMMA_ENABLED, "On" }
+};
+
 int
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 {
@@ -1158,5 +1166,13 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 	if (ret)
 		kfree(intel_plane);
 
+	/* Initialize the plane properties */
+	intel_plane->properties.gamma_property =
+		drm_property_create_enum(dev, 0, "Sprite Gamma Enabled",
+		intel_gamma_enum_list, ARRAY_SIZE(intel_gamma_enum_list));
+	intel_plane->gamma = true;
+	drm_object_attach_property(&intel_plane->base.base,
+		intel_plane->properties.gamma_property, intel_plane->gamma);
+
 	return ret;
 }
-- 
1.8.3.1




More information about the Intel-gfx mailing list