Skip to content

Commit

Permalink
drm/i915: avoid brightness overflow when doing scale
Browse files Browse the repository at this point in the history
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 <[email protected]>
[danvet: Add a comment to explain what's going on.]
Signed-off-by: Daniel Vetter <[email protected]>
  • Loading branch information
Aaron Lu authored and danvet committed Aug 7, 2013
1 parent 9dbd8fe commit 22505b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/gpu/drm/i915/intel_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 22505b8

Please sign in to comment.