All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/2] drm/i915: preserve min brightness across backlight disable/enable
@ 2015-11-19 10:29 Jani Nikula
  2015-11-19 10:29 ` [RFC PATCH 2/2] drm/i915: make intel_backlight sysfs interface have range 0..100 Jani Nikula
  0 siblings, 1 reply; 2+ messages in thread
From: Jani Nikula @ 2015-11-19 10:29 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

We try to preserve the backlight brightness across backlight
disable/enable, except for minimum brightness. Currently, if the
backlight is at minimum, we crank the backlight to max on
enable. Preserve the minimum too, and turn the code into a sanity check
instead.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Clint Taylor <clinton.a.taylor@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_panel.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index a24df35e11e7..7ab63486adce 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -1116,8 +1116,9 @@ void intel_panel_enable_backlight(struct intel_connector *connector)
 
 	WARN_ON(panel->backlight.max == 0);
 
-	if (panel->backlight.level <= panel->backlight.min) {
-		panel->backlight.level = panel->backlight.max;
+	if (panel->backlight.level < panel->backlight.min) {
+		DRM_DEBUG_KMS("backlight level was below minimum\n");
+		panel->backlight.level = panel->backlight.min;
 		if (panel->backlight.device)
 			panel->backlight.device->props.brightness =
 				scale_hw_to_user(connector,
-- 
2.1.4

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [RFC PATCH 2/2] drm/i915: make intel_backlight sysfs interface have range 0..100
  2015-11-19 10:29 [RFC PATCH 1/2] drm/i915: preserve min brightness across backlight disable/enable Jani Nikula
@ 2015-11-19 10:29 ` Jani Nikula
  0 siblings, 0 replies; 2+ messages in thread
From: Jani Nikula @ 2015-11-19 10:29 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Historically we have exposed the full backlight PWM duty cycle range
from 0 to the PWM modulation frequency as the backlight range to the
userspace. Since then, we have had to scale that to respect panel
specific minimum duty cycles. Go for fully abstracting the PWM duty
cycles and modulation frequencies from the userspace by exposing a fixed
range 0..100 in the intel_backlight sysfs interface.

In the code, this makes it more obvious that the sysfs max and the
modulation frequency are not the same. It is more clear that we could
change the modulation frequency on the fly (for example to increase
frequency to reduce flickering), while we can't change the sysfs max on
the fly.

There are a few reasons for picking the fixed range 0..100.

First, it's the range defined for Windows drivers in the Windows
Hardware Compatibility Program Requirements. There is no reason to
differ from that with some NIH agenda, especially when said requirements
also tend to guide the choices made in hardware.

Second, it's hard to produce more than that many user distinguishable
brightness levels using PWM anyway. What is the point of supporting,
say, 4882 brightness levels (the value on the laptop I'm writing this
on) when you can't tell them apart?

Also, we currently (and after this change too) expose a linear scale to
the backlight PWM duty cycle. That is usually not the same as a linear
scale of backlight luminance. It may be desirable to expose an API to
allow the userspace to adjust that to a non-linear curve to reach a
linear backlight luminance. It will be easier to do that with a fixed
range.

This change might cause bug reports due to assumptions that the scale
never changes on a machine. However, the ABI is that the brightness is
between 0..max_brightness. Not that the range cast in stone.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Clint Taylor <clinton.a.taylor@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_panel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 7ab63486adce..c155777bd142 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -1212,7 +1212,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 = 100;
 	props.brightness = scale_hw_to_user(connector,
 					    panel->backlight.level,
 					    props.max_brightness);
-- 
2.1.4

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-19 10:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-19 10:29 [RFC PATCH 1/2] drm/i915: preserve min brightness across backlight disable/enable Jani Nikula
2015-11-19 10:29 ` [RFC PATCH 2/2] drm/i915: make intel_backlight sysfs interface have range 0..100 Jani Nikula

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.