From: Shashank Sharma <shashank.sha...@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.sha...@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

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

Reply via email to