summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAaron Lu <aaron.lu@intel.com>2013-08-02 01:16:03 (GMT)
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-07 09:57:08 (GMT)
commit22505b82a2800bddb67908522833bef96dd15845 (patch)
tree40de131f1ed5a141107afccfaf2ab7a6db0ba535 /drivers
parent9dbd8febb4dbc9199fcf340b882eb930e36b65b6 (diff)
downloadlinux-22505b82a2800bddb67908522833bef96dd15845.tar.xz
drm/i915: avoid brightness overflow when doing scale
Some card's max brightness level is pretty large, e.g. on Acer Aspire 4732Z, the max level is 989910. If user space set a large enough level then the current scale done in intel_panel_set_backlight will cause an integer overflow and the scaled level will be mistakenly small, leaving user with an almost black screen. This patch fixes this problem. Signed-off-by: Aaron Lu <aaron.lu@intel.com> [danvet: Add a comment to explain what's going on.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 67e2c1f..5063ead 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -497,8 +497,11 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level, u32 max)
goto out;
}
- /* scale to hardware */
- level = level * freq / max;
+ /* scale to hardware, but be careful to not overflow */
+ if (freq < max)
+ level = level * freq / max;
+ else
+ level = freq / max * level;
dev_priv->backlight.level = level;
if (dev_priv->backlight.device)