Re: [Intel-gfx] [PATCH 0/1] drm/i915: Allow specifying a minimum brightness level for sysfs control.

2013-03-27 Thread Danny Baumann

Hi,


Well, the ACPI spec says this (section B.5.2):


The OEM may define the number 0 as Zero brightness that can mean
to turn off the lighting (e.g. LCD panel backlight) in the device.
This may be useful in the case of an output device that can still be
viewed using only ambient light, for example, a transflective LCD.


My interpretation of this is that the value 0 is supposed to still
be visible. I'm pretty sure I saw a statement that 0 is supposed to
mean barely visible somewhere, but can't find it at the moment.
I'll search for the source of it.


I think that's a stretch - This may be useful isn't normative
language, The OEM may define is. But even if we do assert it for the
ACPI backlight, it's not true for other interfaces - zero backlight
intensity is supposed to be screen off on Apple hardware, for instance.


OK, I see. And there is user space depending on that behaviour? And 
again - how is user space supposed to know about the behavioral 
differences? Is it something like 'if type is raw, don't expect anything'?
The reason for my question is that I want to determine what a) the 
correct place to fix this and b) the correct fix is. As Xrandr abstracts 
away the used backlight interface, I see no way for user space using 
Xrandr (e.g. KDE) to meaningfully handle this.


Thanks,

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


Re: [Intel-gfx] [PATCH 0/1] drm/i915: Allow specifying a minimum brightness level for sysfs control.

2013-03-27 Thread Danny Baumann

Hi,


Well, the ACPI spec says this (section B.5.2):


The OEM may define the number 0 as Zero brightness that can mean
to turn off the lighting (e.g. LCD panel backlight) in the device.
This may be useful in the case of an output device that can still be
viewed using only ambient light, for example, a transflective LCD.


My interpretation of this is that the value 0 is supposed to still
be visible. I'm pretty sure I saw a statement that 0 is supposed to
mean barely visible somewhere, but can't find it at the moment.
I'll search for the source of it.


BTW, I found the source for that statement: [1], section 
System.Client.BrightnessControls.SmoothBrightness. While formally it's 
not part of the ACPI spec, I'm pretty sure most vendors (except Apple, 
obviously) will follow it as if it were, if not more strictly.



OK, I see. And there is user space depending on that behaviour? And again -
how is user space supposed to know about the behavioral differences? Is it
something like 'if type is raw, don't expect anything'?
The reason for my question is that I want to determine what a) the correct
place to fix this and b) the correct fix is. As Xrandr abstracts away the
used backlight interface, I see no way for user space using Xrandr (e.g.
KDE) to meaningfully handle this.


In practice does it really matter?  As a user if you set the
brightness really low and you either can't see the screen or can
barely make it out does it matter if the screen is off or just really,
really dim?  The 0 brightness setting is probably not practically
usable regardless of what it does.


That's right. I'm not intending to use the laptop with that low 
brightness, though, I'd just like to distinguish between my laptop being 
turned off / suspended or just its display being dimmed down by the 
desktop environment to conserve power. In order to do the latter, KDE 
sets brightness to 0 ([2]), which worked fine for me as long as 
acpi_video was working on this laptop. This isn't the case at present, 
which is why I'm using intel_backlight at the moment. As you may have 
noticed, things aren't working as expected with it, which in turn is 
what brought me over here ;) I'm fine with sending a patch to KDE if 
that's the correct thing to do, but I'm not yet sure what the correct 
thing to do is.


Thanks,

Danny

[1] http://msdn.microsoft.com/en-us/library/windows/hardware/jj128256.aspx
[2] 
https://projects.kde.org/projects/kde/kde-workspace/repository/revisions/master/entry/powerdevil/daemon/actions/bundled/dimdisplay.cpp#L53

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


[Intel-gfx] [PATCH 0/1] drm/i915: Allow specifying a minimum brightness level for sysfs control.

2013-03-26 Thread Danny Baumann
This patch makes the behaviour of the intel_backlight backlight device
consistent to e.g. acpi_videoX: When writing the value 0, the set brightness
makes the panel content barely readable instead of turning the backlight off.
This matches the expectations of user space (e.g. kde-workspace or the Intel
X11 driver), which expects that it can use intel_backlight as a drop-in
replacement for acpi_videoX.
As BIOSes written for Windows 8 support seem to expect the display driver
taking care of the brightness control instead of ACPI methods (see [1]),
I would expect quite a number of people (like me ;) ) having the need of
using intel_backlight instead of acpi_videoX. A quick Google search
indicated that most people are confused by the current behaviour, so I think
it's a good idea to make the default behaviour somehow match acpi_videoX.

Regards,

Danny

[1] https://bugzilla.kernel.org/show_bug.cgi?id=55071

Danny Baumann (1):
  drm/i915: Allow specifying a minimum brightness level for sysfs
control.

 drivers/gpu/drm/i915/intel_panel.c | 48 --
 1 file changed, 41 insertions(+), 7 deletions(-)

-- 
1.8.1.4

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


[Intel-gfx] [PATCH 1/1] drm/i915: Allow specifying a minimum brightness level for sysfs control.

2013-03-26 Thread Danny Baumann
When controlling backlight devices via sysfs interface, user space
generally assumes the minimum level (0) still providing a brightness
that is usable by the user (probably due to the most commonly used
backlight device, acpi_videoX, behaving exactly like that). This doesn't
match the current behaviour of the intel_backlight control, though, as
the value 0 means 'backlight off'.

In order to make intel_backlight consistent to other backlight devices,
introduce a module parameter that allows shifting the 0 level of the
intel_backlight device. It's expressed in percentages of the maximum
level. The default is 5, which provides a backlight level that is barely
readable. Setting it to 0 restores the old behaviour.

Signed-off-by: Danny Baumann dannybaum...@web.de
---
 drivers/gpu/drm/i915/intel_panel.c | 48 --
 1 file changed, 41 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c 
b/drivers/gpu/drm/i915/intel_panel.c
index bee8cb6..5bad49d 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -395,10 +395,35 @@ intel_panel_detect(struct drm_device *dev)
 }
 
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
+
+static int i915_panel_min_brightness_percent = 5;
+MODULE_PARM_DESC(min_sysfs_brightness, Minimum brightness percentage settable 

+   via sysfs. This adjusts the brightness level of the value '0' in the 
+   intel_backlight sysfs backlight interface.);
+module_param_named(min_sysfs_brightness,
+  i915_panel_min_brightness_percent, int, 0400);
+
+static int intel_panel_min_brightness(struct drm_device *dev)
+{
+   int max;
+
+   if (i915_panel_min_brightness_percent = 0)
+   return 0;
+
+   max = intel_panel_get_max_backlight(dev);
+   if (i915_panel_min_brightness_percent = 100)
+   return max;
+
+   return max * i915_panel_min_brightness_percent / 100;
+}
+
 static int intel_panel_update_status(struct backlight_device *bd)
 {
struct drm_device *dev = bl_get_data(bd);
-   intel_panel_set_backlight(dev, bd-props.brightness);
+   int brightness =
+   bd-props.brightness + intel_panel_min_brightness(dev);
+
+   intel_panel_set_backlight(dev, brightness);
return 0;
 }
 
@@ -406,7 +431,10 @@ static int intel_panel_get_brightness(struct 
backlight_device *bd)
 {
struct drm_device *dev = bl_get_data(bd);
struct drm_i915_private *dev_priv = dev-dev_private;
-   return dev_priv-backlight_level;
+   int brightness =
+   dev_priv-backlight_level - intel_panel_min_brightness(dev);
+
+   return brightness;
 }
 
 static const struct backlight_ops intel_panel_bl_ops = {
@@ -419,16 +447,21 @@ int intel_panel_setup_backlight(struct drm_connector 
*connector)
struct drm_device *dev = connector-dev;
struct drm_i915_private *dev_priv = dev-dev_private;
struct backlight_properties props;
+   int max_brightness;
 
intel_panel_init_backlight(dev);
 
-   memset(props, 0, sizeof(props));
-   props.type = BACKLIGHT_RAW;
-   props.max_brightness = _intel_panel_get_max_backlight(dev);
-   if (props.max_brightness == 0) {
+   max_brightness = _intel_panel_get_max_backlight(dev);
+   if (max_brightness == 0) {
DRM_DEBUG_DRIVER(Failed to get maximum backlight value\n);
return -ENODEV;
}
+
+   memset(props, 0, sizeof(props));
+   props.type = BACKLIGHT_RAW;
+   props.max_brightness =
+   max_brightness - intel_panel_min_brightness(dev);
+
dev_priv-backlight =
backlight_device_register(intel_backlight,
  connector-kdev, dev,
@@ -440,7 +473,8 @@ int intel_panel_setup_backlight(struct drm_connector 
*connector)
dev_priv-backlight = NULL;
return -ENODEV;
}
-   dev_priv-backlight-props.brightness = intel_panel_get_backlight(dev);
+   dev_priv-backlight-props.brightness = intel_panel_get_backlight(dev)
+   - intel_panel_min_brightness(dev);
return 0;
 }
 
-- 
1.8.1.4

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


Re: [Intel-gfx] [PATCH 1/1] drm/i915: Allow specifying a minimum brightness level for sysfs control.

2013-03-26 Thread Danny Baumann

Hi,


Thus far our assumption always was that the acpi backlight works better
than the intel native backlight. So everything only uses the intel
backlight if there's no other backlight driver by default.


There are machines, such as the pnv netbook on my desk, on which
intel_backlight does nothing and the only control is through
acpi_backlight0.


That's fine - but on my machine, (at least currently) it's the other way 
around. acpi_video[0|1] do nothing, while intel_backlight is the only 
method that works. This sucks (please also see my reply to Daniel), but 
it's a fact.



Generalising expected behaviour based on one firmware
implementation is fraught with danger.


I'm not sure what you mean here. I interpret the statement as 'user 
space should treat acpi_videoX and intel_backlight differently'. Is this 
interpretation correct?
If so, how is user space supposed to know how the respective backlight 
device will behave, as this behaviour might change at any point in time 
if there's no understanding in how it _should_ behave? What currently 
happens on my machine is that KDE completely turns off the backlight 
after the dim timeout, because it assumes that the value 0 will keep the 
backlight at a readable level (which would be the case if it used 
acpi_videoX because this behaviour is mandated by the spec there). I 
first thought of sending a patch to KDE, but I couldn't figure out how 
KDE is _supposed_ to correctly handle the situation, especially given 
that the actual sysfs interface used is abstracted away by Xrandr (and 
chosen by the Intel Xorg driver). With my patch, intel_backlight behaves 
in a way that roughly matches the behaviour mandated by the ACPI spec.

Do you have a way in mind that allows fixing this in user space?

Thanks,

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


Re: [Intel-gfx] [PATCH 0/1] drm/i915: Allow specifying a minimum brightness level for sysfs control.

2013-03-26 Thread Danny Baumann

Hi,

Am 26.03.2013 18:02, schrieb Matthew Garrett:

On Tue, Mar 26, 2013 at 12:48:44PM +0100, Danny Baumann wrote:

This patch makes the behaviour of the intel_backlight backlight device
consistent to e.g. acpi_videoX: When writing the value 0, the set brightness
makes the panel content barely readable instead of turning the backlight off.
This matches the expectations of user space (e.g. kde-workspace or the Intel
X11 driver), which expects that it can use intel_backlight as a drop-in
replacement for acpi_videoX.


I'm not quite clear what you mean here. The behaviour of 0 isn't well
defined for the ACPI backlight driver - it's perfectly reasonable for it
to turn the backlight off entirely. Anything assuming that 0 is still
visible is broken.


Well, the ACPI spec says this (section B.5.2):


The OEM may define the number 0 as Zero brightness that can mean to 
turn off the lighting (e.g. LCD panel backlight) in the device. This may 
be useful in the case of an output device that can still be viewed using 
only ambient light, for example, a transflective LCD.



My interpretation of this is that the value 0 is supposed to still be 
visible. I'm pretty sure I saw a statement that 0 is supposed to mean 
barely visible somewhere, but can't find it at the moment. I'll search 
for the source of it.


Regards,

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


Re: [Intel-gfx] [PATCH 1/1] drm/i915: Allow specifying a minimum brightness level for sysfs control.

2013-03-26 Thread Danny Baumann

Hi,


Thus far our assumption always was that the acpi backlight works better
than the intel native backlight. So everything only uses the intel
backlight if there's no other backlight driver by default.

So if I should merge this as a general solution for Windows 8 machines not
working properly, we first need to figure out what windows does on these
machines and either disable the acpi backlight or adapt it.


I fully agree to that. Making acpi_video control usable is preferable 
over using intel_backlight. As I lack the detail knowledge about the 
ACPI video stuff, I'd be great of one (or some) of you guys could look 
at the mentioned bug report ([1]) and comment on what the problem might 
be. I have added the basic needed information already and would be happy 
to provide any needed debugging info.



Adding more kernel options is not a viable solution for the backlight mess
imo.


Actually I'm fine with hardcoding the percentage as well ;) I just 
figured it might make sense to make it controllable for special-case 
uses, while still making intel_backlight usable for the 'normal' use case.


Regards,

Danny

[1] https://bugzilla.kernel.org/show_bug.cgi?id=55071
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx