Skip to content

Commit 342c71e

Browse files
jnikulakamalmostafa
authored andcommitted
drm/i915: try not to lose backlight CBLV precision
commit cac6a5a upstream. 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. Reference: https://gist.github.com/aaronlu/6314920 Reported-by: Aaron Lu <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Reviewed-by: Aaron Lu <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> [ kamal: backport to 3.8 (context) ] Signed-off-by: Kamal Mostafa <[email protected]>
1 parent 9987155 commit 342c71e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/i915/intel_opregion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)
165165

166166
max = intel_panel_get_max_backlight(dev);
167167
intel_panel_set_backlight(dev, bclp * max / 255);
168-
iowrite32((bclp*0x64)/0xff | ASLE_CBLV_VALID, &asle->cblv);
168+
iowrite32(DIV_ROUND_UP(bclp * 100, 255) | ASLE_CBLV_VALID, &asle->cblv);
169169

170170
return 0;
171171
}

0 commit comments

Comments
 (0)