[ltp] Re: Thinkpad X60s - brightness problems

Jan Gutter linux-thinkpad@linux-thinkpad.org
Thu, 18 Oct 2007 11:07:13 +0200


On Thu, 2007-10-18 at 07:59 +0000, Ondrej Balaz wrote:
> On 2007-10-17, character <char@online.de> wrote:
> > I've got the same problem with my X61 Tablet. You may want to look at my
> > thread from monday (2007-10-15).

I've also got an X61 Tablet, and I got my hotkeys working yesterday.
Don't take my assumptions as gospel, though: they are inferences I drew,
rather than doing the tedious mucking about through the code, or
documentation ;-)

Both acpi-video and thinkpad-acpi provide kernel interfaces to set the
brightness (in /sys, and /proc, though /proc is supposed to be
deprecated and /sys is preferred). Setting the brightness on my laptop
is as easy as doing the following:

echo 50 > /sys/devices/virtual/backlight/acpi_video1/brightness

If you run hald and dbus (I think), you can also set the brightness by
sending an event to hald. In my distribution
the /usr/lib/hal/scripts/hal-system-lcd-set-brightness script
calls /usr/lib/hal/scripts/linux/hal-system-lcd-set-brightness-linux
to do just that.

Ok, so the brightness *changing* worked perfectly on my PC, but my keys
didn't work. First of all, the keys generate ACPI events, which acpid
picks up. In this case, acpid sent the event to two receptors:
gnome-power-manager and xorg (which passed it on to the intel driver).

I had the curious experience of the screen "flickering" every time I
pushed the hotkey. If I added a minor delay to the hal set-brightness
script, the screen would go bright, then go down to the correct level.
This suggested a race condition: one process sets the brightness up
everytime I hit the key, the other sets it to the dimmer level.

So, the only other possibility was that Xorg was doing the bad thing.
This was actually confirmed: when I switch to text mode, dimming works
perfectly (no flickering), because xorg is ignoring the acpi events.
gnome-power-manager's messages still came through, setting the
brightness correctly.

Now finally, the solution. I googled for the sources of the intel driver
for Ubuntu and found a nice little patch:
03_fix_brightness_control.diff

(part of
https://launchpad.net/ubuntu/gutsy/+source/xserver-xorg-video-intel/2:2.1.1-0ubuntu9
)

This fixed it.

Ok, so in order to get your keys working on a non-gnome, non-hal system,
you need to add scripts to change the brightness in /etc/acpi/. Make
sure *nothing else* is receiving those ACPI events and acting on them:
apps connecting to the ACPI event system get ALL the events, not just
the unhandled ones! In my case gnome-power-manager was getting the
events, but the intel driver clashed with this. Certain model thinkpads
actually have an exclusion entry in the hal .fdi to stop them from
trying to set brightness via hal: it assumes brightness is handled in
h/w, not software.

After this long missive, I hope you are either more confused, or steered
in a slightly better direction. I use Gentoo and I'm not afraid to patch
my sources. If you use another distro, you might forward this message to
them. Just note: fixing this on my laptop in this way *might* break
perfectly working brightness keys on a totally different system that
actually relies on the intel driver setting the brightness.

-- Jan