diff mbox

[RFC,2/2] drm/i915: make intel_backlight sysfs interface have range 0..100

Message ID 1447928976-4922-2-git-send-email-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jani Nikula Nov. 19, 2015, 10:29 a.m. UTC
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 mbox

Patch

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);