Bug 15064

Summary: [i915GM Brightness] [regression] gdm and opengl apps reset brightness to xbacklight value
Product: xorg Reporter: unggnu
Component: Driver/intelAssignee: Jesse Barnes <jbarnes>
Status: RESOLVED DUPLICATE QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: gordon.jin, nian.wu
Version: gitKeywords: NEEDINFO, regression
Hardware: x86 (IA32)   
OS: Linux (All)   
URL: https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/201933
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Xorg.0.log with ModeDebug
none
xorg.conf
none
xrandr --verbose
none
lspci -vvnn
none
dmesg none

Description unggnu 2008-03-16 11:46:53 UTC
Bug description:
Every time gdm, an OpenGL game like OpenArena or a video file in vlc with xv is started brightness is changed to xbacklight value (which seems to bee 33.3 per default). If I use my laptop brightness keys afterwards it jumps to previous brightness postion +- one.
After changing the value with xbacklight it directly takes effect but could be changed afterward through the laptop brightness keys. If I set xbacklight to 100 brightness goes always to maximum and if I set it to 0 minimum brightness is shown everytime after using the mentioned apps or starting gdm.
If I change the driver from -intel to -vesa the problem is gone.
It seems to be a similar to https://bugs.freedesktop.org/show_bug.cgi?id=11527 except that if I open a video file in Totem or mplayer which both should be use Xv there is no brightness change. Of course this bug was fixed in final Ubuntu 7.10 (Intel driver 2:2.1.1-0ubuntu9.1) but seems to reappear in Ubuntu 8.04 Hardy Heron.

System environment:
-- chipset: i915GM
-- system architecture: 32-bit
-- xf86-video-intel: 2:2.2.1-1ubuntu5
-- xserver: 1.4.1~git20080131-1ubuntu5
-- mesa: 7.0.3~rc2-1ubuntu2
-- drm: 2.3.0-4ubuntu1
-- kernel: 2.6.24-12-generic
-- Linux distribution: current Ubuntu 8.04 Hardy Heron Alpha
-- Machine or mobo model: Sony Vaio VGN-TX2XP


Reproducing steps:

Change brightness to maximum or the center with the laptop keys and restart gdm. The brightness should be directly decreased. If the xbacklight value vary it should be changed with "xbacklight -set" to 0 or 100.
Of course the same should happen after starting an OpenGL game (OpenArena), or SDL (Supertux 2) or vlc.
Comment 1 unggnu 2008-03-16 11:48:08 UTC
Created attachment 15190 [details]
Xorg.0.log with ModeDebug
Comment 2 unggnu 2008-03-16 11:48:33 UTC
Created attachment 15191 [details]
xorg.conf
Comment 3 unggnu 2008-03-16 11:48:55 UTC
Created attachment 15192 [details]
xrandr --verbose
Comment 4 unggnu 2008-03-16 11:49:18 UTC
Created attachment 15193 [details]
lspci -vvnn
Comment 5 unggnu 2008-03-16 11:49:40 UTC
Created attachment 15194 [details]
dmesg
Comment 6 Jesse Barnes 2008-03-17 16:20:07 UTC
I can't reproduce this on any of my machines, but I'm trying to understand the issue.

It sounds like there's a conflict between what brightness level your brightness keys control and what the xbacklight tool reports & controls.

I recently added some code to the X server and driver which should allow xbacklight & xrandr to get the latest backlight values, even if changed by brightness hotkeys, so those changes may fix the problem you're seeing.

You might also try changing your backlight control method:
  xrandr --output LVDS --set BACKLIGHT_CONTROL native
to see if that helps.

And if there's a kernel driver with backlight support available for your platform (either via the ACPI video driver or a sony specific laptop driver), it should provide a /sys/class/backlight interface.  If that's present at startup the X server can use it (see i830_lvds.c for the list of supported /sys/class/backlight interfaces).  That's the best thing to use if you can get it working.
Comment 7 unggnu 2008-03-17 18:53:55 UTC
Thanks for your reply. The main problem isn't xbacklight. I don't use it and it isn't installed by default. It is just everytime gdm starts or I open a video with vlc or start and opengl app the LFP goes dark (nearly darkest brightness setting) which is very annoying. The Intel driver shouldn't change brightness on its own until a tool is used like xbacklight.
I only mentioned xbacklight to probably point to the source of the change since it is related to the value set by xbacklight.

Since Hardy there is a working acpi backlight class for Sony laptops (/sys/class/backlight/sony) but the brightness changes even if I remove the corresponding sony-laptop kernel module.
As I said it is pretty similar to http://bugs.freedesktop.org/show_bug.cgi?id=11527. Maybe it only happens with the current Ubuntu Hardy Intel driver or Sony laptops, I don't know.
Comment 8 Jesse Barnes 2008-03-18 19:13:34 UTC
I think gdm & vlc are calling into the server to adjust the DPMS settings, which causes the driver to save or restore the last known backlight brightness value.  Maybe your machine doesn't like using the 'legacy' interface; I've seen that in a few machines now.  Can you try the following patch?

--- a/src/i830_lvds.c
+++ b/src/i830_lvds.c
@@ -125,6 +125,7 @@ i830_set_lvds_backlight_method(xf86OutputPtr output)
     }

     pI830->backlight_control_method = method;
+    pI830->backlight_control_method = BCM_NATIVE;
 }

 /*

to see if that makes the problem go away?
Comment 9 unggnu 2008-03-19 12:00:37 UTC
It seems to work after a short test. Neither GDM nor VLC nor Supertux2 reset brightness with the patched driver.
Many thanks.
Comment 10 Jesse Barnes 2008-03-19 12:05:38 UTC
Can you try one more thing?  Change the BCM_NATIVE to BCM_COMBO in the patch you tried?  That might be a better default.

Gordon, I think we need some community testing coverage here.  It may be that using BCM_COMBO instead of BCM_LEGACY when the legacy bit is set will result in fewer bug reports (though using kernel is still the best).
Comment 11 unggnu 2008-03-19 12:41:21 UTC
Seems to work fine too.
Comment 12 Jesse Barnes 2008-03-20 14:26:58 UTC
Ok, thanks a lot for testing.  I think I'll push this change upstream:
diff --git a/src/i830_lvds.c b/src/i830_lvds.c
index 0b331ef..a12ffab 100644
--- a/src/i830_lvds.c
+++ b/src/i830_lvds.c
@@ -117,11 +117,11 @@ i830_set_lvds_backlight_method(xf86OutputPtr output)
     } else if (IS_I965GM(pI830) || IS_IGD_GM(pI830)) {
        blc_pwm_ctl2 = INREG(BLC_PWM_CTL2);
        if (blc_pwm_ctl2 & BLM_LEGACY_MODE2)
-           method = BCM_LEGACY;
+           method = BCM_COMBO;
     } else {
        blc_pwm_ctl = INREG(BLC_PWM_CTL);
        if (blc_pwm_ctl & BLM_LEGACY_MODE)
-           method = BCM_LEGACY;
+           method = BCM_COMBO;
     }

     pI830->backlight_control_method = method;

Once I get feedback from a few more people (I don't want to regress anyone).
Comment 13 Jesse Barnes 2008-03-25 15:16:14 UTC

*** This bug has been marked as a duplicate of bug 14721 ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.