@@ -6100,6 +6100,9 @@ enum punit_power_well {
#define VLV_PIPEB_GCMAX (dev_priv->info.display_mmio_offset + 0x71010)
#define VLV_PIPE_GCMAX(pipe) _PIPE(pipe, VLV_PIPEA_GCMAX, VLV_PIPEB_GCMAX)
+/* Contrast and brightness */
+#define VLV_SPRITE_CB_BASE (dev_priv->info.display_mmio_offset + 0x721d0)
+
/* VLV MIPI registers */
#define _MIPIA_PORT_CTRL (VLV_DISPLAY_BASE + 0x61190)
@@ -70,6 +70,7 @@ struct clrmgr_property gen6_plane_color_corrections[] = {
.min = 0,
.len = VLV_CB_MAX_VALS,
.name = "contrast",
+ .set_property = intel_clrmgr_set_contrast,
},
{
.tweak_id = brightness,
@@ -78,6 +79,7 @@ struct clrmgr_property gen6_plane_color_corrections[] = {
.min = 0,
.len = VLV_CB_MAX_VALS,
.name = "brightness",
+ .set_property = intel_clrmgr_set_brightness,
},
{
.tweak_id = hue_saturation,
@@ -90,6 +92,88 @@ struct clrmgr_property gen6_plane_color_corrections[] = {
};
/*
+* vlv_set_cb
+* Valleyview specific common functtion for contsrast/brightness
+* setting. The method and registes are same for both.
+* Valleyview supports contrast/brightness correction only on
+* sprite planes.
+* inputs:
+* - intel_crtc *
+* - cb: registered property for contrast.
+* - data: value to be applied
+*/
+bool vlv_set_cb(struct intel_plane *intel_plane, struct clrmgr_regd_prop *cb,
+ u64 *data, enum clrmgr_tweaks tweak)
+{
+
+ u32 val, 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 = cb->property;
+
+ sprite = intel_plane->plane;
+ if (!(SPCNTR(intel_plane->pipe, sprite) & SP_ENABLE)) {
+ DRM_ERROR("Sprite plane %d not enabled\n", sprite);
+ return false;
+ }
+
+ /* Apply correction only if sprite is enabled */
+ DRM_DEBUG_DRIVER("Applying cb correction on Sprite\n");
+ reg = SPRITE_CB(intel_plane->pipe, sprite);
+
+ if (tweak == contrast) {
+ /* Contrast value is lower 9 bit value */
+ new_val = *data & VLV_CONTRAST_MASK;
+ DRM_DEBUG_DRIVER("Setting Contrast to 0x%x", new_val);
+
+ /* Contrast correction position is bit [26:18] */
+ val = I915_READ(reg) &
+ ~(VLV_CONTRAST_MASK << VLV_CONTRAST_SHIFT);
+ val |= (new_val << VLV_CONTRAST_SHIFT);
+ } else {
+ new_val = *data & VLV_BRIGHTNESS_MASK;
+ DRM_DEBUG_DRIVER("Setting Brightness to 0x%x", new_val);
+
+ /* Brightness correction is lower 8 [7:0] register bits */
+ val = I915_READ(reg) | new_val;
+ }
+
+ /* Contrast and brightness are single value properties */
+ I915_WRITE(reg, val);
+ property->values[property->num_values - 1] = *data;
+ DRM_DEBUG_DRIVER("Set Contrast/Brightness correction successful");
+ return true;
+}
+
+bool intel_clrmgr_set_brightness(void *plane,
+ struct clrmgr_regd_prop *bright, u64 *data)
+{
+ struct intel_plane *intel_plane = plane;
+ struct drm_device *dev = intel_plane->base.dev;
+
+ if (IS_VALLEYVIEW(dev))
+ return vlv_set_cb(intel_plane, bright, data, brightness);
+
+ /* Todo: Support other gen devices */
+ DRM_ERROR("Color correction is supported only on VLV for now\n");
+ return false;
+}
+
+bool intel_clrmgr_set_contrast(void *plane,
+ struct clrmgr_regd_prop *ctrst, u64 *data)
+{
+ struct intel_plane *intel_plane = plane;
+ struct drm_device *dev = intel_plane->base.dev;
+
+ if (IS_VALLEYVIEW(dev))
+ return vlv_set_cb(intel_plane, ctrst, data, contrast);
+
+ /* Todo: Support other gen devices */
+ DRM_ERROR("Color correction is supported only on VLV for now\n");
+ return false;
+}
+
+/*
* vlv_set_10bit_gamma
* Valleyview specific gamma correction method.
* Programs the palette registers in 10bit method
@@ -67,10 +67,16 @@
#define VLV_GAMMA_GCMAX_MASK 0x1FFFF
#define VLV_CLRMGR_GAMMA_GCMAX_MAX 0x400
+/* Offset for sprite planes */
+#define SPRITE_COLOR_OFFSET 0x100
-
-/* Sprite Contrast and Brightness Registers */
+/* Sprite Contrast and Brightness common defs */
#define VLV_CB_MAX_VALS 1
+#define SPRITE_CB(p, s) (VLV_SPRITE_CB_BASE + \
+ (p * 2 + s) * SPRITE_COLOR_OFFSET)
+#define VLV_CONTRAST_MASK 0x1FF
+#define VLV_CONTRAST_SHIFT 18
+#define VLV_BRIGHTNESS_MASK 0xFF
/* Sprite Hue and Saturation Registers */
#define VLV_HS_MAX_VALS 1
@@ -135,6 +141,34 @@ struct clrmgr_reg_request {
};
/*
+* intel_clrmgr_set_contrast
+* 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*
+* - ctrst: registered color property for contrast
+* - data: new value
+*/
+bool intel_clrmgr_set_contrast(void *plane,
+ struct clrmgr_regd_prop *ctrst, u64 *data);
+
+/*
+* intel_clrmgr_set_brightness
+* Set brightness level.
+* Different gen devices have different methods for
+* brightness setting. This is a wrapper function to
+* call device specific set brightess function
+* inputs:
+* - plane: void*, can be typecasted to intel_plane*
+* - bright: registered color property for brightness
+* - data: new value
+*/
+bool intel_clrmgr_set_brightness(void *plane,
+ struct clrmgr_regd_prop *bright, u64 *data);
+
+/*
* intel_clrmgr_set_gamma
* Gamma correction method is different across various
* gen devices. This is a wrapper function which will call