]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/i915: try not to lose backlight CBLV precision
authorJani Nikula <jani.nikula@intel.com>
Fri, 23 Aug 2013 07:50:39 +0000 (10:50 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 6 Sep 2013 07:41:20 +0000 (09:41 +0200)
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 <aaron.lu@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Aaron Lu <aaron.lu@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_opregion.c

index cfb8fb68f09c87e7da468a57dd2375530ddc0345..119771ff46ab5178047c018efc5f9f31a06f068d 100644 (file)
@@ -173,7 +173,7 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)
                return ASLE_BACKLIGHT_FAILED;
 
        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;
 }