On Mon, 23 Apr 2012 11:32:15 +0200, Daniel Vetter <daniel.vetter at ffwll.ch> wrote: > 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 at chris-wilson.co.uk> > Signed-Off-by: Daniel Vetter <daniel.vetter at 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)) Now that is just getting ugly. Break this out into a simple and readable predicate function intel_panel_backlight_is_inverted(). > return intel_panel_get_max_backlight(dev) - val; Tabtastic. -Chris -- Chris Wilson, Intel Open Source Technology Centre