All of lore.kernel.org
 help / color / mirror / Atom feed
From: shashank.sharma@intel.com
To: intel-gfx@lists.freedesktop.org, ville.syrjala@linux.intel.com,
	damien.lespiau@intel.com, daniel.vetter@intel.com,
	shobhit.kumar@intel.com, satheeshakrishna.m@intel.com
Cc: =indranil.mukherjee@intel.com
Subject: [PATCH 07/11] drm/i915: Add hue and saturation correction
Date: Wed, 23 Jul 2014 23:35:01 +0530	[thread overview]
Message-ID: <1406138705-17334-8-git-send-email-shashank.sharma@intel.com> (raw)
In-Reply-To: <1406138705-17334-1-git-send-email-shashank.sharma@intel.com>

From: Shashank Sharma <shashank.sharma@intel.com>

This patch adds support for color property to set sprite plane
hue and saturation values, for intel color manager framework.
It adds two functions:
  1. intel_clrmgr_set_hue_sat: This is a wrapper function
     which checks the platform type, and calls the valleyview
     specific set_hue_saturation function. As different platforms have different
     methods of setting hue/saturation, this function is required.The support for
     other platfroms can be plugged-in here in the wrapper function.
     Adding this function as .set_property for hue and saturation color properties.
  2. vlv_set_hs: Core function to program hue/saturation values as per
     vlv specs. This function expects one 32bit value as input, encoded in exact
     register format, and applies it.

Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
---
 drivers/gpu/drm/i915/i915_reg.h     |  3 ++
 drivers/gpu/drm/i915/intel_clrmgr.c | 57 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_clrmgr.h | 17 +++++++++++
 3 files changed, 77 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 414a113..7614a0f 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -6103,6 +6103,9 @@ enum punit_power_well {
 /* Contrast and brightness */
 #define VLV_SPRITE_CB_BASE	(dev_priv->info.display_mmio_offset + 0x721d0)
 
+/* Hue and saturation */
+#define VLV_SPRITE_HS_BASE	(dev_priv->info.display_mmio_offset + 0x721d4)
+
 /* VLV MIPI registers */
 
 #define _MIPIA_PORT_CTRL			(VLV_DISPLAY_BASE + 0x61190)
diff --git a/drivers/gpu/drm/i915/intel_clrmgr.c b/drivers/gpu/drm/i915/intel_clrmgr.c
index 781df59..a4c8f0f 100644
--- a/drivers/gpu/drm/i915/intel_clrmgr.c
+++ b/drivers/gpu/drm/i915/intel_clrmgr.c
@@ -88,10 +88,67 @@ struct clrmgr_property gen6_plane_color_corrections[] = {
 		.min = 0,
 		.len = VLV_HS_MAX_VALS,
 		.name = "hue-saturation",
+		.set_property = intel_clrmgr_set_hue_sat,
 	}
 };
 
 /*
+* vlv_set_hs
+* Valleyview specific hue/saturation setting function.
+* Valleyview supports hue/saturation correction only on
+* sprite planes.
+* inputs:
+* - intel_crtc *
+* - hs: registered property for hue/sat. This encapsulates a drm_property
+*	which is common for all sprite planes. The property has entries equal
+*	to no of sprite planes in valleyview = 2
+* -data: 64 bit encoded values, low 32 bits contain the new contrast/
+	brightness values, whereas the upper 32 bits contain the sprite no.
+*/
+bool vlv_set_hs(struct intel_plane *intel_plane, struct clrmgr_regd_prop *hs,
+	uint64_t *data)
+{
+
+	u32 new_val, reg, sprite;
+	struct drm_device *dev = intel_plane->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_property *property = hs->property;
+
+	sprite = intel_plane->plane;
+
+	/* If plane enabled */
+	if (!(SPCNTR(intel_plane->pipe, sprite) & SP_ENABLE)) {
+			DRM_ERROR("Sprite plane %d not enabled\n", sprite);
+			return false;
+	}
+
+	/* Apply correction */
+	DRM_DEBUG_DRIVER("Applying hs correction on Sprite\n");
+	reg = SPRITE_HS(intel_plane->pipe, sprite);
+	new_val = *data;
+
+	/* Contrast and brightness are single value properties */
+	I915_WRITE(reg, new_val);
+	property->values[property->num_values - 1] = *data;
+	DRM_DEBUG_DRIVER("Set Hue/Saturation to 0x%x successful\n", new_val);
+	return true;
+}
+
+bool intel_clrmgr_set_hue_sat(void *plane,
+	struct clrmgr_regd_prop *hs, u64 *data)
+{
+	struct intel_plane *intel_plane = plane;
+	struct drm_device *dev = intel_plane->base.dev;
+
+	if (IS_VALLEYVIEW(dev))
+		return vlv_set_hs(intel_plane, hs, data);
+
+	/* Todo: Support other gen devices */
+	DRM_ERROR("Color correction is supported only on VLV for now\n");
+	return false;
+}
+
+/*
 * vlv_set_cb
 * Valleyview specific common functtion for contsrast/brightness
 * setting. The method and registes are same for both.
diff --git a/drivers/gpu/drm/i915/intel_clrmgr.h b/drivers/gpu/drm/i915/intel_clrmgr.h
index d1fc787..6d316d2 100644
--- a/drivers/gpu/drm/i915/intel_clrmgr.h
+++ b/drivers/gpu/drm/i915/intel_clrmgr.h
@@ -80,6 +80,9 @@
 
 /* Sprite Hue and Saturation Registers */
 #define VLV_HS_MAX_VALS				1
+#define SPRITE_HS(p, s)				(VLV_SPRITE_HS_BASE +  \
+					((p * 2 + s) * SPRITE_COLOR_OFFSET))
+
 
 /* Color manager features */
 enum clrmgr_tweaks {
@@ -169,6 +172,20 @@ bool intel_clrmgr_set_brightness(void *plane,
 	struct clrmgr_regd_prop *bright, u64 *data);
 
 /*
+* intel_clrmgr_set_hue-sat
+* Set contrast level.
+* Different gen devices have different methods for
+* contrast setting. This is a wrapper function to
+* call device specific set contrast function
+* inputs:
+* - plane: void*, can be typecasted to intel_plane*
+* - hs: registered color property for hue and saturation
+* - data: new value
+*/
+bool intel_clrmgr_set_hue_sat(void *plane,
+	struct clrmgr_regd_prop *hs, u64 *data);
+
+/*
 * intel_clrmgr_set_gamma
 * Gamma correction method is different across various
 * gen devices. This is a wrapper function which will call
-- 
1.9.1

  parent reply	other threads:[~2014-07-23 18:02 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23 18:04 [PATCH 00/11]: Color manager framework for I915 driver shashank.sharma
2014-07-23 18:04 ` [PATCH 01/11] drm/i915: Color manager framework for valleyview shashank.sharma
2014-07-23 18:04 ` [PATCH 02/11] drm/i915: Register pipe level color properties shashank.sharma
2014-07-25  0:02   ` Matt Roper
2014-07-23 18:04 ` [PATCH 03/11] drm/i915: Register plane " shashank.sharma
2014-07-23 18:04 ` [PATCH 04/11] drm/i915: Add color manager CSC correction shashank.sharma
2014-07-23 18:04 ` [PATCH 05/11] drm/i915: Add color manager gamma correction shashank.sharma
2014-07-23 18:05 ` [PATCH 06/11] drm/i915: Add contrast and brightness correction shashank.sharma
2014-07-23 18:05 ` shashank.sharma [this message]
2014-07-23 18:05 ` [PATCH 08/11] drm/i915: Add CRTC set property functions shashank.sharma
2014-07-23 18:05 ` [PATCH 09/11] drm/i915: Add set plane " shashank.sharma
2014-07-23 18:05 ` [PATCH 10/11] drm/i915: Plug-in color manager init shashank.sharma
2014-07-23 18:05 ` [PATCH 11/11] drm/i915: Plug-in color manager exit shashank.sharma
2014-07-23 18:34 ` [PATCH 00/11]: Color manager framework for I915 driver Daniel Vetter
2014-07-24  4:08   ` Sharma, Shashank
2014-07-25  0:43     ` Matt Roper
2014-07-25  4:36       ` Sharma, Shashank
2014-07-26  1:58         ` Matt Roper
2014-07-28  4:57           ` Sharma, Shashank
2014-09-09  6:23           ` [PATCH 0/4] Color manager framework shashank.sharma
2014-09-09  6:23             ` [PATCH 1/4] drm/i915: Color manager framework for valleyview shashank.sharma
2014-09-09 22:51               ` Bob Paauwe
2014-09-10  8:40                 ` Sharma, Shashank
2014-09-10 16:25                   ` Bob Paauwe
2014-09-10  1:29               ` Matt Roper
2014-09-10 11:20                 ` Sharma, Shashank
2014-09-10 21:17                   ` Matt Roper
2014-09-11  7:52                     ` Daniel Vetter
2014-09-09  6:23             ` [PATCH 2/4] drm/i915: Plug-in color manager attach shashank.sharma
2014-09-10  1:29               ` Matt Roper
2014-09-10 11:52                 ` Sharma, Shashank
2014-09-09  6:23             ` [PATCH 3/4] drm/i915: CSC color correction shashank.sharma
2014-09-09 22:51               ` Bob Paauwe
2014-09-10  8:55                 ` Sharma, Shashank
2014-09-10 16:03                   ` Bob Paauwe
2014-09-10  1:30               ` Matt Roper
2014-09-10  6:40                 ` Daniel Vetter
2014-09-10 12:05                   ` Sharma, Shashank
2014-09-10 12:13                     ` Daniel Vetter
2014-09-10 22:17               ` Matt Roper
2014-09-11  7:53                 ` Daniel Vetter
2014-09-09  6:23             ` [PATCH 4/4] drm/i915: Add set_protpery function shashank.sharma
2014-09-10  1:28             ` [PATCH 0/4] Color manager framework Matt Roper
2014-09-10 11:08               ` Sharma, Shashank
2014-09-10 18:15                 ` Matt Roper
2014-09-11  7:56                   ` Daniel Vetter
2014-09-11  8:18                     ` Sharma, Shashank
2014-09-11  8:49                       ` Daniel Vetter
2014-09-11  9:23                         ` Ville Syrjälä

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=1406138705-17334-8-git-send-email-shashank.sharma@intel.com \
    --to=shashank.sharma@intel.com \
    --cc==indranil.mukherjee@intel.com \
    --cc=damien.lespiau@intel.com \
    --cc=daniel.vetter@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=satheeshakrishna.m@intel.com \
    --cc=shobhit.kumar@intel.com \
    --cc=ville.syrjala@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.