All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Shih-Yuan Lee (FourDollars)" <sylee@canonical.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2] drm/i915: Respect the brightness range from VBT.
Date: Tue, 10 Nov 2015 16:01:10 +0800	[thread overview]
Message-ID: <20151110080110.GA8387@localhost> (raw)
In-Reply-To: <1447051331-11829-1-git-send-email-sylee@canonical.com>

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@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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-11-10  8:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  6:42 [PATCH] drm/i915: A better maximum brightness for users Shih-Yuan Lee (FourDollars)
2015-11-09 10:17 ` Jani Nikula
2015-11-09 10:30   ` Shih-Yuan Lee (FourDollars)
2015-11-09 10:51     ` Jani Nikula
2015-11-09 11:54       ` Shih-Yuan Lee (FourDollars)
2015-11-09 12:58         ` Jani Nikula
2015-11-09 14:02           ` Shih-Yuan Lee (FourDollars)
2015-11-09 15:25             ` Ville Syrjälä
2015-11-09 16:02   ` Paulo Zanoni
2015-11-09 16:57     ` Jani Nikula
2015-11-10  1:59       ` Shih-Yuan Lee (FourDollars)
2015-11-10  8:01 ` Shih-Yuan Lee (FourDollars) [this message]
2015-11-10 10:15   ` [PATCH v2] drm/i915: Respect the brightness range from VBT Jani Nikula
2015-11-10 11:26     ` Shih-Yuan Lee (FourDollars)
2015-11-10 12:57       ` Jani Nikula
2015-11-10 16:11         ` Shih-Yuan Lee (FourDollars)
2015-11-11  4:11   ` [PATCH v3] drm/i915: Set brightness maximum to a fixed value 100 Shih-Yuan Lee (FourDollars)
2015-11-11  4:57     ` kbuild test robot
2015-11-11  7:31 ` [PATCH v4] " Shih-Yuan Lee (FourDollars)
2015-11-11 12:05   ` Jani Nikula
2015-11-11 13:09     ` Shih-Yuan Lee (FourDollars)
2015-11-11 14:10 ` [PATCH v5] drm/i915: Set backlight class max to 100 and respect the VBT minimum again Shih-Yuan Lee (FourDollars)
2015-11-12  5:43 ` [PATCH v6] drm/i915: respect the VBT minimum backlight brightness again Shih-Yuan Lee (FourDollars)
2015-11-12  8:08   ` Stéphane ANCELOT
2015-11-12  8:28     ` Shih-Yuan Lee (FourDollars)
2015-11-12  8:40       ` Stéphane ANCELOT
2015-11-12  8:57         ` Shih-Yuan Lee (FourDollars)
2015-11-12  9:05           ` Stéphane ANCELOT
2015-11-12 10:01             ` Shih-Yuan Lee (FourDollars)
2015-11-18  9:06               ` Stéphane ANCELOT
2015-11-18  9:11                 ` Shih-Yuan Lee (FourDollars)
2015-11-12 13:44     ` Jani Nikula
2015-11-13  3:50 ` [PATCH v7] drm/i915: A better backlight class brightness range Shih-Yuan Lee (FourDollars)
2015-11-13  3:50   ` Shih-Yuan Lee (FourDollars)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151110080110.GA8387@localhost \
    --to=sylee@canonical.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.