Bug 12037

Summary: [PATCH] Fix reversed brightness behavior on ThinkPad SL series
Product: ACPI Reporter: Lubomir Rintel (lkundrak)
Component: Power-VideoAssignee: Zhang Rui (rui.zhang)
Status: CLOSED DUPLICATE    
Severity: normal CC: acpi-bugzilla, khashayar.lists, sfstudio, trenn
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.27 Subsystem:
Regression: --- Bisected commit-id:
Attachments: Fix for the ThinkPad SL300 reversed brightness control behavior issue
refreshed patch
ACPI dump from Lenovo ThinkPas SL300
refreshed patch
customized DSDT: new _BCL package
customized DSDT: new _BCL package
original DSDT file (Lenovo SL 500)
dmesg|grep -i acpi on SL500 with custom DSDT
/proc/acpi/event output
other output

Description Lubomir Rintel 2008-11-15 09:08:52 UTC
Section B.6.2 of ACPI 3.0b specification that defines _BCL method
doesn't require the brightness levels returned to be sorted.
At least ThinkPad SL300 (and probably all IdeaPads) returns the
array reversed (i.e. bightest levels have lowest indexes), which
causes the brightness management behave in completely reversed
manner on these machines (brightness increases when the laptop is
idle, while the display dims when used).

Sorting the array by brightness level values after reading the list
fixes the issue.
Comment 1 Lubomir Rintel 2008-11-15 09:11:19 UTC
Created attachment 18875 [details]
Fix for the ThinkPad SL300 reversed brightness control behavior issue

This was originally submitted as bug to Red Hat bugzilla as #470465, but I was advised to submit the patch upstream.
Comment 2 Zhang Rui 2008-11-16 18:23:11 UTC
the patch looks good.
len, please apply this patch to acpi test please?
Comment 3 Zhang Rui 2008-11-24 22:55:25 UTC
Created attachment 19011 [details]
refreshed patch

hmm, we should not sort the first two elements of the brightness levels.
can this patch work for you?
can you attach the acpidump output?
Comment 4 Lubomir Rintel 2008-11-25 14:00:30 UTC
Created attachment 19016 [details]
ACPI dump from Lenovo ThinkPas SL300

(In reply to comment #3)
> Created an attachment (id=19011) [details]
> refreshed patch
> 
> hmm, we should not sort the first two elements of the brightness levels.
> can this patch work for you?
> can you attach the acpidump output?

Right. Your patch works perfectly.
Attaching the ACPI dump.
Comment 5 Zhang Rui 2008-11-25 22:45:54 UTC
Created attachment 19022 [details]
refreshed patch

Name (PCTG, Package (0x10)
                {
                    0x64,
                    0x5A,
                    0x55,
                    0x50,
                    0x4B,
                    0x46,
                    0x41,
                    0x3C,
                    0x37,
                    0x32,
                    0x2D,
                    0x28,
                    0x23,
                    0x1E,
                    0x19,
                    0x14
                }

Method (_BCL, 0, NotSerialized)
                {
                    Return (PCTG)
                }

hmmm, the _BCL method of your BIOS is still buggy.
According to the ACPI spec B.6.2,
"The first number in the package is the level of the panel when full power is connected to the machine. The second number in the package is the level of the panel when the machine is on batteries. All other numbers are treated as a list of levels OSPM will cycle through when the user toggles (via a keystroke) the
brightness level of the display."
With this patch applied, you'll lost the top two brightness levels (0x64 and 0x5a).
Comment 6 Zhang Rui 2008-11-25 23:31:56 UTC
Created attachment 19025 [details]
customized DSDT: new _BCL package

                Name (PCTG, Package (0x10)
                {
                    0x64,
                    0x5A,
                    0x55,
                    0x50,
                    0x4B,
                    0x46,
                    0x41,
                    0x3C,
                    0x37,
                    0x32,
                    0x2D,
                    0x28,
                    0x23,
                    0x1E,
                    0x19,
                    0x14
                })
Method (_BCL, 0, NotSerialized)
{                            
      Return (PCTG)
}

In order to make the brightness work perfectly on this laptop,
I think you need to try this customized DSDT.
how to override a dsdt can be found at:
http://www.lesswatts.org/projects/acpi/overridingDSDT.php
Comment 7 Zhang Rui 2008-11-25 23:44:45 UTC
please attach the result of "grep . /proc/acpi/video/*/*" both w/ and w/o this customized DSDT.
Comment 8 Nicolai Spohrer 2008-11-26 13:51:48 UTC
Hello. The patch works well, thanks. But there's still one minor problem I can notice when changing the brightness: When the OSD Brightness Bar is full and I press "Brightness Up" once again, the screen becomes darker. That does not happen with pressing "Brightness Down" on the lowest level.

My system does not start correctly with the custom DSDT compiled into the kernel. It either hangs after logging in in GDM or GDM does not even show up. Probably a Kernel Oops, I can't change to tty1 etc... But maybe I'm doing something wrong.

I'm using linux 2.6.27.
Comment 9 Nicolai Spohrer 2008-11-26 14:16:32 UTC
Maybe it would help if you uploaded the modified .dsl file so that I can compile it myself (to put it into the initrd) and test it without recompiling the kernel.
Comment 10 Zhang Rui 2008-11-26 17:17:16 UTC
Created attachment 19041 [details]
customized DSDT: new _BCL package

okay, please try this .dsl file.
Comment 11 Nicolai Spohrer 2008-11-27 07:58:54 UTC
That file works. But that little problem remains (maybe it's an application bug?).
After I had changed the brightness about 15 times in a row, dmesg showed an ACPI error and the screen became darker for maybe 0.3s and then showed the wanted brightness, always when I tried to change it.

[  113.968143] ACPI: EC: missing confirmations, switch off interrupt mode.
[  114.472142] ACPI Exception (evregion-0419): AE_TIME, Returned by Handler for [EmbeddedControl] [20080609]
[  114.472173] ACPI Error (psparse-0530): Method parse/execution failed [\_SB_.PCI0.SBRG.EC0_.SADC] (Node f481d960), AE_TIME
[  114.472352] ACPI Error (psparse-0530): Method parse/execution failed [\_SB_.PCI0.SBRG.EC0_.STBR] (Node f481d900), AE_TIME
[  114.472508] ACPI Error (psparse-0530): Method parse/execution failed [\_SB_.PCI0.P0P1.VGA_.LCDD._BCM] (Node f481a1f8), AE_TIME
(reproducible)

I forgot to mention that I'm using a SL500, not a SL300.
Comment 12 Nicolai Spohrer 2008-11-27 08:00:07 UTC
Created attachment 19048 [details]
original DSDT file (Lenovo SL 500)
Comment 13 Nicolai Spohrer 2008-11-27 08:01:10 UTC
Created attachment 19049 [details]
dmesg|grep -i acpi on SL500 with custom DSDT
Comment 14 Zhang Rui 2008-11-27 17:35:06 UTC
(In reply to comment #11)
> [  113.968143] ACPI: EC: missing confirmations, switch off interrupt mode.
> [  114.472142] ACPI Exception (evregion-0419): AE_TIME, Returned by Handler
> for
> [EmbeddedControl] [20080609]
> [  114.472173] ACPI Error (psparse-0530): Method parse/execution failed
> [\_SB_.PCI0.SBRG.EC0_.SADC] (Node f481d960), AE_TIME
> [  114.472352] ACPI Error (psparse-0530): Method parse/execution failed
> [\_SB_.PCI0.SBRG.EC0_.STBR] (Node f481d900), AE_TIME
> [  114.472508] ACPI Error (psparse-0530): Method parse/execution failed
> [\_SB_.PCI0.P0P1.VGA_.LCDD._BCM] (Node f481a1f8), AE_TIME
> (reproducible)
> 
this seems like a EC bug.
I assume that you can also reproduce this bug without the customized DSDT, right?
If yes, please open a new bug for this issue and attach the full dmesg output.
If no, try to reproduce the problem for several times and see if it's related with the brightness levels you want to set.
Comment 15 Nicolai Spohrer 2008-11-29 13:37:36 UTC
Well, strang. Now I can't reproduce this anymore - under the same conditions.

The problem with the "extra level" above the 16th (?) level (OSD bar is shown as full) that makes the screen dark again also occurs without the kernel patch - just the other way round.
Comment 16 Zhang Rui 2008-11-30 17:55:40 UTC
first, please kill acpid and run "cat /proc/acpi/event", attach the output after pressing the hotkey.

second, when the OSD brightness bar is full, please attach the content of /proc/acpi/video/*/brightness and /sys/class/backlight/acpi_video0/actual_brightness both before and after the hotkey pressing
Comment 17 Nicolai Spohrer 2008-12-01 04:48:53 UTC
Created attachment 19090 [details]
/proc/acpi/event output
Comment 18 Nicolai Spohrer 2008-12-01 04:49:53 UTC
Created attachment 19091 [details]
other output
Comment 19 Zhang Rui 2008-12-01 18:00:43 UTC
duplicate video device found on your laptop.
please upgrade to the latest kernel release where this issue has been fixed and retry.
Comment 20 Zhang Rui 2008-12-07 19:32:24 UTC
the original bug is fixed by the patch in comment #5.
close this bug.
For the dark screen issue, please open a new bug report if the problem still exists in the latest kernel.
Comment 21 Len Brown 2008-12-11 13:56:38 UTC
patch in comment #5 applied to acpi test branch
Comment 22 Zhang Rui 2008-12-17 16:47:31 UTC
*** Bug 12235 has been marked as a duplicate of this bug. ***
Comment 23 Evgeniy Manachkin 2008-12-26 01:30:54 UTC
Asus X51L backward brigthess trouble.

/proc/acpi/video/VGA/LCDD/brightness - work fine 0-min 15-max
/sys/class/backlight/acpi_video0/brightness - trouble 0-max 15-min

Kpowersave work bad - 100%-min 1%-max

In dmesg:

Dec 25 23:47:08 sfstudio kernel: 
ACPI: Please implement acpi_video_bus_ROM_seq_show
Dec 26 01:34:14 sfstudio kernel: asus-laptop: Asus Laptop Support version 0.42
Dec 26 01:34:14 sfstudio kernel: asus-laptop:   X51L model detected
Dec 26 01:34:14 sfstudio kernel: asus-laptop: Brightness ignored, must be controlled by ACPI video driver
Dec 26 01:34:14 sfstudio kernel: Registered led device: asus::mail
Dec 26 01:37:29 sfstudio kernel: asus-laptop: Asus Laptop Support version 0.42
Dec 26 01:37:29 sfstudio kernel: asus-laptop:   X51L model detected
Dec 26 01:37:29 sfstudio kernel: asus-laptop: Brightness ignored, must be controlled by ACPI video driver
Dec 26 01:37:29 sfstudio kernel: Registered led device: asus::mail
Dec 26 01:39:20 sfstudio kernel: asus-laptop: Asus Laptop Support version 0.42
Dec 26 01:39:20 sfstudio kernel: asus-laptop:   X51L model detected
Dec 26 01:39:20 sfstudio kernel: asus-laptop: Brightness ignored, must be controlled by ACPI video driver
Dec 26 01:39:20 sfstudio kernel: Registered led device: asus::mail
Dec 26 01:40:31 sfstudio kernel: asus-laptop: Asus Laptop Support version 0.42
Dec 26 01:40:31 sfstudio kernel: asus-laptop:   X51L model detected
Dec 26 01:40:31 sfstudio kernel: asus-laptop: Brightness ignored, must be controlled by ACPI video driver
Dec 26 01:40:31 sfstudio kernel: Registered led device: asus::mail

Kernel:
[root@sfstudio kernel]# uname -a
Linux sfstudio.sadnet.lo 2.6.28 #2 SMP PREEMPT Thu Dec 25 17:14:54 OMST 2008 i686 Intel(R) Celeron(R) CPU          540  @ 1.86GHz GNU/Linux
Comment 24 Zhang Rui 2009-01-05 22:34:48 UTC
Evgeniy,
please follow the suggestion in
http://bugzilla.kernel.org/show_bug.cgi?id=12249#c34 and see if it helps.

*** This bug has been marked as a duplicate of bug 12249 ***
Comment 25 Evgeniy Manachkin 2009-01-09 14:20:23 UTC
Excuse, I very badly feel. Here the second week the temperature does not fall. As soon as I can necessarily all I will check up.
Comment 26 Evgeniy Manachkin 2009-01-10 21:48:28 UTC
Thanks a lot. In 2.6.29rc1 kernel backligth work perfect!!!
Comment 27 Zhang Rui 2009-03-09 23:10:35 UTC
hi, the previous patch you tested is not for upstream kernel.
please follow the instructions in
http://bugzilla.kernel.org/show_bug.cgi?id=12249#c60
Comment 28 Zhang Rui 2009-03-12 01:40:31 UTC
hi, the previous patch you tested is not for upstream kernel.
please follow the instructions in
http://bugzilla.kernel.org/show_bug.cgi?id=12249#c69