blob: 71e8ce0e9f7d25d3b37797a7c1629667ff653528 [file] [log] [blame]
From aa130d3668002215a8ac509688c7ea391b62998e Mon Sep 17 00:00:00 2001
From: Jani Nikula <>
Date: Fri, 23 Aug 2013 10:50:39 +0300
Subject: drm/i915: try not to lose backlight CBLV precision
ACPI has _BCM and _BQC methods to set and query the backlight
brightness, respectively. The ACPI opregion has variables BCLP and CBLV
to hold the requested and current backlight brightness, respectively.
The BCLP variable has range 0..255 while the others have range
0..100. This means the _BCM method has to scale the brightness for BCLP,
and the gfx driver has to scale the requested value back for CBLV. If
the _BQC method uses the CBLV variable (apparently some implementations
do, some don't) for current backlight level reporting, there's room for
rounding errors.
Use DIV_ROUND_UP for scaling back to CBLV to get back to the same values
that were passed to _BCM, presuming the _BCM simply uses bclp = (in *
255) / 100 for scaling to BCLP.
Reported-by: Aaron Lu <>
Signed-off-by: Jani Nikula <>
Reviewed-by: Aaron Lu <>
Signed-off-by: Daniel Vetter <>
(cherry picked from commit cac6a5ae0118832936eb162ec4cedb30f2422bcc)
Signed-off-by: Darren Hart <>
drivers/gpu/drm/i915/intel_opregion.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c
index 2ff74912b656..c4fb2ae35401 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -384,7 +384,7 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)
intel_panel_set_backlight(dev, bclp, 255);
- iowrite32((bclp*0x64)/0xff | ASLE_CBLV_VALID, &asle->cblv);
+ iowrite32(DIV_ROUND_UP(bclp * 100, 255) | ASLE_CBLV_VALID, &asle->cblv);
return 0;