[Intel-gfx] [PATCH v2] drm/i915: Respect the brightness range from VBT.

Shih-Yuan Lee (FourDollars) sylee at canonical.com
Tue Nov 10 00:01:10 PST 2015


Taking Dell XPS 13 (2015) as an example. The lowest PWM brightness is 10
and the highest PWM brightness is 937. Before this change, we can only
use from 37 to 937, and 37 is used to turn off the backlight because it
is mapped to 0 of sysfs brightness however the maximum sysfs brightness
is still 937 so it makes some sysfs brightness values are mapped to the
same PWM brightness values.

After this change, we can use the whole PWM brightness range from 10 to
937, and they are mapped into the range from 0 to 927 in the sysfs
brightness and vice versa because they are 1-1 mapping.

10 is the lowest PWM brightness. We should make users able to use it for
the extreme power saving reason and users can still see the display.

Signed-off-by: Shih-Yuan Lee (FourDollars) <sylee at canonical.com>
---
 drivers/gpu/drm/i915/intel_panel.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index a24df35..57bc2fe 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -1154,8 +1154,7 @@ static int intel_backlight_device_update_status(struct backlight_device *bd)
 	 */
 	if (panel->backlight.enabled) {
 		if (panel->backlight.power) {
-			bool enable = bd->props.power == FB_BLANK_UNBLANK &&
-				bd->props.brightness != 0;
+			bool enable = bd->props.power == FB_BLANK_UNBLANK;
 			panel->backlight.power(connector, enable);
 		}
 	} else {
@@ -1211,7 +1210,7 @@ static int intel_backlight_device_register(struct intel_connector *connector)
 	 * Note: Everything should work even if the backlight device max
 	 * presented to the userspace is arbitrarily chosen.
 	 */
-	props.max_brightness = panel->backlight.max;
+	props.max_brightness = panel->backlight.max - panel->backlight.min;
 	props.brightness = scale_hw_to_user(connector,
 					    panel->backlight.level,
 					    props.max_brightness);
@@ -1429,10 +1428,11 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)
 	if (min != dev_priv->vbt.backlight.min_brightness) {
 		DRM_DEBUG_KMS("clamping VBT min backlight %d/255 to %d/255\n",
 			      dev_priv->vbt.backlight.min_brightness, min);
+		/* vbt value is a coefficient in range [0..255] */
+		return scale(min, 0, 255, 0, panel->backlight.max);
 	}
 
-	/* vbt value is a coefficient in range [0..255] */
-	return scale(min, 0, 255, 0, panel->backlight.max);
+	return min;
 }
 
 static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unused)
-- 
1.9.1



More information about the Intel-gfx mailing list