[3.11.y.z extended stable] Patch "drm/i915: restore backlight precision when converting from ACPI" has been added to staging queue
Luis Henriques
luis.henriques at canonical.com
Fri May 30 09:29:08 UTC 2014
This is a note to let you know that I have just added a patch titled
drm/i915: restore backlight precision when converting from ACPI
to the linux-3.11.y-queue branch of the 3.11.y.z extended stable tree
which can be found at:
http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.11.y-queue
If you, or anyone else, feels it should not be added to this tree, please
reply to this email.
For more information about the 3.11.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
Thanks.
-Luis
------
>From 871d97c637041b54879e6e9961faac26397ee297 Mon Sep 17 00:00:00 2001
From: Aaron Lu <aaron.lu at intel.com>
Date: Mon, 12 May 2014 16:55:45 +0800
Subject: drm/i915: restore backlight precision when converting from ACPI
commit 721e82c08c1afd6b47367b0e0c4a62140b0667f3 upstream.
When we set backlight on behalf of ACPI opregion, we will convert the
backlight value in the 0-255 range defined in opregion to the actual
hardware level. Commit 22505b82a2 (drm/i915: avoid brightness overflow
when doing scale) is meant to fix the overflow problem when doing the
conversion, but it also caused a problem that the converted hardware
level doesn't quite represent the intended value: say user wants maximum
backlight level(255 in opregion's range), then we will calculate the
actual hardware level to be: level = freq / max * level, where freq is
the hardware's max backlight level(937 on an user's box), and max and
level are all 255. The converted value should be 937 but the above
calculation will yield 765.
To fix this issue, just use 64 bits to do the calculation to keep the
precision and avoid overflow at the same time.
Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=72491
Reported-by: Nico Schottelius <nico-bugzilla.kernel.org at schottelius.org>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Aaron Lu <aaron.lu at intel.com>
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
[ luis: backported to 3.11: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
---
drivers/gpu/drm/i915/intel_panel.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 5950888ae1d0..7a66423c93ab 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -488,6 +488,7 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level, u32 max)
struct drm_i915_private *dev_priv = dev->dev_private;
u32 freq;
unsigned long flags;
+ u64 n;
spin_lock_irqsave(&dev_priv->backlight.lock, flags);
@@ -498,10 +499,9 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level, u32 max)
}
/* scale to hardware, but be careful to not overflow */
- if (freq < max)
- level = level * freq / max;
- else
- level = freq / max * level;
+ n = (u64)level * freq;
+ do_div(n, max);
+ level = n;
dev_priv->backlight.level = level;
if (dev_priv->backlight.device)
--
1.9.1
More information about the kernel-team
mailing list