On Thu, Apr 26, 2012 at 06:48:36PM +0200, Carsten Emde wrote: > Bit #28 of the backlight control BLC_PWM_CTL2 is normally used > to indicate whether the brightness of the panel backlight is > inverted. Sometimes, however, bit #29 is used for this purpose. > Add a quirk to mark machines that do so. > > Signed-off-by: Carsten Emde <C.Emde at osadl.org> > > --- > drivers/gpu/drm/i915/i915_drv.h | 1 + > drivers/gpu/drm/i915/i915_reg.h | 1 + > drivers/gpu/drm/i915/intel_display.c | 10 ++++++++++ > drivers/gpu/drm/i915/intel_panel.c | 12 ++++++++++-- > 4 files changed, 22 insertions(+), 2 deletions(-) > > Index: linux-tip/drivers/gpu/drm/i915/i915_drv.h > =================================================================== > --- linux-tip.orig/drivers/gpu/drm/i915/i915_drv.h > +++ linux-tip/drivers/gpu/drm/i915/i915_drv.h > @@ -295,6 +295,7 @@ enum intel_pch { > > #define QUIRK_PIPEA_FORCE (1<<0) > #define QUIRK_LVDS_SSC_DISABLE (1<<1) > +#define QUIRK_ALT_BIT_FOR_BRIGHTNESS_INVERSION (2<<1) > > struct intel_fbdev; > struct intel_fbc_work; > Index: linux-tip/drivers/gpu/drm/i915/i915_reg.h > =================================================================== > --- linux-tip.orig/drivers/gpu/drm/i915/i915_reg.h > +++ linux-tip/drivers/gpu/drm/i915/i915_reg.h > @@ -1685,6 +1685,7 @@ > /* Backlight control */ > #define BLC_PWM_CTL2 0x61250 /* 965+ only */ > #define BLM_COMBINATION_MODE (1 << 30) > +#define BLM_ALT_POLARITY_I965 (1 << 29) /* quirk only */ bit29 is the pipe select bit, i.e. the backlight controller uses the pixel clock from this pipe as the signal to module the backlight. I need to look some more into this. -Daniel > #define BLM_POLARITY_I965 (1 << 28) /* gen4 only */ > #define BLC_PWM_CTL 0x61254 > /* > Index: linux-tip/drivers/gpu/drm/i915/intel_display.c > =================================================================== > --- linux-tip.orig/drivers/gpu/drm/i915/intel_display.c > +++ linux-tip/drivers/gpu/drm/i915/intel_display.c > @@ -9101,6 +9101,16 @@ static void quirk_ssc_force_disable(stru > dev_priv->quirks |= QUIRK_LVDS_SSC_DISABLE; > } > > +/* > + * A machine may use an alternate bit to indicate panel backlight brightness > + * inversion > + */ > +static void quirk_alt_bit_for_brightness_inversion(struct drm_device *dev) > +{ > + struct drm_i915_private *dev_priv = dev->dev_private; > + dev_priv->quirks |= QUIRK_ALT_BIT_FOR_BRIGHTNESS_INVERSION; > +} > + > struct intel_quirk { > int device; > int subsystem_vendor; > Index: linux-tip/drivers/gpu/drm/i915/intel_panel.c > =================================================================== > --- linux-tip.orig/drivers/gpu/drm/i915/intel_panel.c > +++ linux-tip/drivers/gpu/drm/i915/intel_panel.c > @@ -208,9 +208,17 @@ static u32 intel_panel_compute_brightnes > 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)) > + if (IS_GEN4(dev)) { > + /* gen4 has a - possibly quirked - polarity bit */ > + int mask; > + > + if (dev_priv->quirks & QUIRK_ALT_BIT_FOR_BRIGHTNESS_INVERSION) > + mask = BLM_ALT_POLARITY_I965; > + else > + mask = BLM_POLARITY_I965; > + if (I915_READ(BLC_PWM_CTL2) & mask) > return intel_panel_get_max_backlight(dev) - val; > + } > > return val; > } > -- Daniel Vetter Mail: daniel at ffwll.ch Mobile: +41 (0)79 365 57 48