diff mbox

drm/i915/panel: Fix application of legacy backlight value

Message ID 1296293440-4660-1-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Jan. 29, 2011, 9:30 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index c65992d..71ba046 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -205,10 +205,11 @@  u32 intel_panel_get_backlight(struct drm_device *dev)
 		if (is_backlight_combination_mode(dev)){
 			u8 lbpc;
 
-			val &= ~1;
 			pci_read_config_byte(dev->pdev, PCI_LBPC, &lbpc);
+			/* Report the value in [0:max] i.e. always multiplied
+			 * by lbpc even if the hardware does not (0xff).
+			 */
 			val *= lbpc;
-			val >>= 1;
 		}
 	}
 
@@ -237,9 +238,12 @@  void intel_panel_set_backlight(struct drm_device *dev, u32 level)
 		u32 max = intel_panel_get_max_backlight(dev);
 		u8 lpbc;
 
-		lpbc = level * 0xfe / max + 1;
-		level /= lpbc;
+		lpbc = (level * 0xfe + max-1) / max + 1;
 		pci_write_config_byte(dev->pdev, PCI_LBPC, lpbc);
+
+		/* The hardware is tricksy and treats lpbc == 0xff specially */
+		max = lpbc == 0xff ? 0xff : 0xff * lpbc;
+		level = (level + max-1) / max;
 	}
 
 	tmp = I915_READ(BLC_PWM_CTL);