diff options
| -rw-r--r-- | drivers/gpu/drm/i915/i915_reg.h | 10 | ||||
| -rw-r--r-- | drivers/gpu/drm/i915/intel_panel.c | 36 |
2 files changed, 46 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 3e6f486f4605..2abe240dae58 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
| @@ -1553,7 +1553,17 @@ | |||
| 1553 | 1553 | ||
| 1554 | /* Backlight control */ | 1554 | /* Backlight control */ |
| 1555 | #define BLC_PWM_CTL 0x61254 | 1555 | #define BLC_PWM_CTL 0x61254 |
| 1556 | #define BACKLIGHT_MODULATION_FREQ_SHIFT (17) | ||
| 1556 | #define BLC_PWM_CTL2 0x61250 /* 965+ only */ | 1557 | #define BLC_PWM_CTL2 0x61250 /* 965+ only */ |
| 1558 | #define BLM_COMBINATION_MODE (1 << 30) | ||
| 1559 | /* | ||
| 1560 | * This is the most significant 15 bits of the number of backlight cycles in a | ||
| 1561 | * complete cycle of the modulated backlight control. | ||
| 1562 | * | ||
| 1563 | * The actual value is this field multiplied by two. | ||
| 1564 | */ | ||
| 1565 | #define BACKLIGHT_MODULATION_FREQ_MASK (0x7fff << 17) | ||
| 1566 | #define BLM_LEGACY_MODE (1 << 16) | ||
| 1557 | /* | 1567 | /* |
| 1558 | * This is the number of cycles out of the backlight modulation cycle for which | 1568 | * This is the number of cycles out of the backlight modulation cycle for which |
| 1559 | * the backlight is on. | 1569 | * the backlight is on. |
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index d860abeda70f..f8f86e57df22 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c | |||
| @@ -30,6 +30,8 @@ | |||
| 30 | 30 | ||
| 31 | #include "intel_drv.h" | 31 | #include "intel_drv.h" |
| 32 | 32 | ||
| 33 | #define PCI_LBPC 0xf4 /* legacy/combination backlight modes */ | ||
| 34 | |||
| 33 | void | 35 | void |
| 34 | intel_fixed_panel_mode(struct drm_display_mode *fixed_mode, | 36 | intel_fixed_panel_mode(struct drm_display_mode *fixed_mode, |
| 35 | struct drm_display_mode *adjusted_mode) | 37 | struct drm_display_mode *adjusted_mode) |
| @@ -110,6 +112,19 @@ done: | |||
| 110 | dev_priv->pch_pf_size = (width << 16) | height; | 112 | dev_priv->pch_pf_size = (width << 16) | height; |
| 111 | } | 113 | } |
| 112 | 114 | ||
| 115 | static int is_backlight_combination_mode(struct drm_device *dev) | ||
| 116 | { | ||
| 117 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
| 118 | |||
| 119 | if (INTEL_INFO(dev)->gen >= 4) | ||
| 120 | return I915_READ(BLC_PWM_CTL2) & BLM_COMBINATION_MODE; | ||
| 121 | |||
| 122 | if (IS_GEN2(dev)) | ||
| 123 | return I915_READ(BLC_PWM_CTL) & BLM_LEGACY_MODE; | ||
| 124 | |||
| 125 | return 0; | ||
| 126 | } | ||
| 127 | |||
| 113 | static u32 i915_read_blc_pwm_ctl(struct drm_i915_private *dev_priv) | 128 | static u32 i915_read_blc_pwm_ctl(struct drm_i915_private *dev_priv) |
| 114 | { | 129 | { |
| 115 | u32 val; | 130 | u32 val; |
| @@ -166,6 +181,9 @@ u32 intel_panel_get_max_backlight(struct drm_device *dev) | |||
| 166 | if (INTEL_INFO(dev)->gen < 4) | 181 | if (INTEL_INFO(dev)->gen < 4) |
| 167 | max &= ~1; | 182 | max &= ~1; |
| 168 | } | 183 | } |
| 184 | |||
| 185 | if (is_backlight_combination_mode(dev)) | ||
| 186 | max *= 0xff; | ||
| 169 | } | 187 | } |
| 170 | 188 | ||
| 171 | DRM_DEBUG_DRIVER("max backlight PWM = %d\n", max); | 189 | DRM_DEBUG_DRIVER("max backlight PWM = %d\n", max); |
| @@ -183,6 +201,14 @@ u32 intel_panel_get_backlight(struct drm_device *dev) | |||
| 183 | val = I915_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; | 201 | val = I915_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; |
| 184 | if (IS_PINEVIEW(dev)) | 202 | if (IS_PINEVIEW(dev)) |
| 185 | val >>= 1; | 203 | val >>= 1; |
| 204 | |||
| 205 | if (is_backlight_combination_mode(dev)){ | ||
| 206 | u8 lbpc; | ||
| 207 | |||
| 208 | val &= ~1; | ||
| 209 | pci_read_config_byte(dev->pdev, PCI_LBPC, &lbpc); | ||
| 210 | val *= lbpc; | ||
| 211 | } | ||
| 186 | } | 212 | } |
| 187 | 213 | ||
| 188 | DRM_DEBUG_DRIVER("get backlight PWM = %d\n", val); | 214 | DRM_DEBUG_DRIVER("get backlight PWM = %d\n", val); |
| @@ -205,6 +231,16 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level) | |||
| 205 | 231 | ||
| 206 | if (HAS_PCH_SPLIT(dev)) | 232 | if (HAS_PCH_SPLIT(dev)) |
| 207 | return intel_pch_panel_set_backlight(dev, level); | 233 | return intel_pch_panel_set_backlight(dev, level); |
| 234 | |||
| 235 | if (is_backlight_combination_mode(dev)){ | ||
| 236 | u32 max = intel_panel_get_max_backlight(dev); | ||
| 237 | u8 lbpc; | ||
| 238 | |||
| 239 | lbpc = level * 0xfe / max + 1; | ||
| 240 | level /= lbpc; | ||
| 241 | pci_write_config_byte(dev->pdev, PCI_LBPC, lbpc); | ||
| 242 | } | ||
| 243 | |||
| 208 | tmp = I915_READ(BLC_PWM_CTL); | 244 | tmp = I915_READ(BLC_PWM_CTL); |
| 209 | if (IS_PINEVIEW(dev)) { | 245 | if (IS_PINEVIEW(dev)) { |
| 210 | tmp &= ~(BACKLIGHT_DUTY_CYCLE_MASK - 1); | 246 | tmp &= ~(BACKLIGHT_DUTY_CYCLE_MASK - 1); |
