[PATCH 2/2] drm/i915: pnv has a backlight polarity control bit, too

Daniel Vetter
2012-04-23T09:31:20Z

So let's use it.

We already correctly ignore bit0 on gen < 4, now we also now why ;-)
I've decided that losing that single bit of precision isn't worth the
trouble to sprinkle IS_PINEVIEW checks all over the backlight control
code - that code is way too fragile imo.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
drivers/gpu/drm/i915/i915_reg.h | 2 ++
drivers/gpu/drm/i915/intel_panel.c | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 67c4ca0..45d5568 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -1805,6 +1805,8 @@
*/
#define BACKLIGHT_DUTY_CYCLE_SHIFT (0)
#define BACKLIGHT_DUTY_CYCLE_MASK (0xffff)
+#define BACKLIGHT_DUTY_CYCLE_MASK_PNV (0xfffe)
+#define BLM_POLARITY_PNV (1 << 0) /* pnv only */

#define BLC_HIST_CTL 0x61260

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 1874517..e519221 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -212,8 +212,9 @@ static u32 intel_panel_compute_brightness(struct drm_device *dev, u32 val)
dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS)
return intel_panel_get_max_backlight(dev) - val;

- /* gen4 has a polarity bit */
- if (IS_GEN4(dev) && (I915_READ(BLC_PWM_CTL2) & BLM_POLARITY_I965))
+ /* gen4/pnv has a polarity bit */
+ if (IS_GEN4(dev) && (I915_READ(BLC_PWM_CTL2) & BLM_POLARITY_I965) ||
+ IS_PINEVIEW(dev) && (I915_READ(BLC_PWM_CTL) & BLM_POLARITY_PNV))
return intel_panel_get_max_backlight(dev) - val;

return val;
--
1.7.10