View Single Post
Old 24-11-2007, 12:29 AM   #5
Ayaz Ahmed Khan
Guest
 
Posts: n/a
Re: ACPI and governors on AMD laptop under Slackware 12

Sylvain Robitaille wrote:

> Ayaz Ahmed Khan wrote:
>
>> ... I've added bits to alter brightness levels of the LCD whenever the
>> special Fn key-sequences to toggle brightness are pressed.

>
> I bet some would appreciate if you shared details. For example, what
> receives the key-presses, and how do you tell which key was pressed?
> I've been wanting to add this functionality to my own laptops (and to
> some extent, a couple of desktops, too) for some time.


I have been meaning to write a detailed mini-HOWTO respecting getting
almost everything working with Slackware-12 on a Dell Inspiron 1501, but
owing to demanding work deadlines, I have not been able to take out
time. I will put the article up on The Slack World and my personal blog
when it is ready.

As Alan noted, the key strokes are logged by acpid in /var/log/
acpid.log. For example, if I press the Fn+Down combination to lower
brightness level, ACPID registers the following in its log file:

[Fri Nov 23 11:08:15 2007] received event "video LCD 00000087 00000000"
[Fri Nov 23 11:08:15 2007] notifying client 3003[82:82]
[Fri Nov 23 11:08:15 2007] notifying client 3162[0:102]
[Fri Nov 23 11:08:15 2007] executing action "/etc/acpi/acpi_handler.sh
video LCD 00000087 00000000"
[Fri Nov 23 11:08:15 2007] BEGIN HANDLER MESSAGES
[Fri Nov 23 11:08:15 2007] END HANDLER MESSAGES
[Fri Nov 23 11:08:15 2007] action exited with status 0
[Fri Nov 23 11:08:15 2007] completed event "video LCD 00000087 00000000"

Similarly, the key combination to increase brightness generates nearly
similar output but with 00000087 replaced with 00000086. So, in effect,
the actual signal that is caught by acpid, and subsequently passed to /
etc/acpi/acpi_handler.sh under Slackware-12, is "video LCD 0000008x
00000000". Once that's identified, it is only a matter of altering BASH
code in /etc/acpi/acpi_handler.sh to react to arguments provided to it
when it is invoked by acpid (indirectly) to get the brightness keys to do
something.

For the time being, I'll only post the part of acpi_handler.sh that deals
with the brightness control signals.

video)
case "$2" in
LCD)
case "$3" in
00000087) echo 12 > /proc/acpi/video/VGA/LCD/brightness
;;
00000086) echo 87 > /proc/acpi/video/VGA/LCD/brightness
;;
*) logger "ACPI [$1]->[$2]->[$3]->[$4] not defined."
;;
esac
;;
*) logger "ACPI [$1]->[$2]->[$3] not defined."
;;
esac
;;


Also, having talked to a couple of people in ##slackware, I came to the
conclusion that the video.ko module behaves weirdly with my hardware (or,
vice versa). For example, if you look at the following output:

root@dante# cat /proc/acpi/video/VGA/LCD/brightness
levels: 100 37 12 25 37 50 62 75 87 100
current: 12

The values in the levels row are arranged in no particular pattern. They
should be, at least from what I've learned. Apparently, for my
particular situation, level 12 happens to be the lowest brightness level
my LCD can be toggled too, and 100 the highest. Knowing that, you might
be wondering why in the acpi_handler.sh script I've only provided for
setting of only two levels. There is no special reason perhaps save for
lack of time for writing a proper BASH script.

And, yes, I've also modified, on Dagmar's suggestion on ##slackware, /etc/
rc.d/rc.modules to load the following modules:

/sbin/modprobe ac
/sbin/modprobe asus_acpi
/sbin/modprobe battery
/sbin/modprobe button
/sbin/modprobe container
/sbin/modprobe dock
/sbin/modprobe fan
/sbin/modprobe processor
/sbin/modprobe thermal
/sbin/modprobe video

--
Ayaz Ahmed Khan
  Reply With Quote