Tuesday, January 22, 2008

Let HAL work with thinkpad_acpi

With the new thinkpad_acpi module succeeding ibm_acpi, there is one great thing going on. Hot key presses are now sent to the input layer, which means you can handle them as real key press/release events and throw those ACPI handlers into garbage bin. The current version of HAL, however, is not working well with the event device created by thinkpad_acpi. Newer kernels come with SW_RADIO switch event which is the only SW bit used by thinkpad_acpi, but HAL fails to follow up the steps. Thus the pre-probing during HAL's process of adding a new input device will fail with no supported SW bits found. Simply put, HAL will not listen on that event device, which most probably renders it useless unless you write your own event handlers for it.

As simple as it is, I spent quite some time digging it up from the source code. Then when I posted it to the HAL mailing list, Ben Liblit kindly pointed me to this bug entry, where he provided a nice patch for HAL. Trust me, I searched around it really hard before getting into the source code, and Google failed to get me this link. Shame for Google. ;)

So if your HAL is 0.5.10, just apply the patch. Make sure your linux/input.h is new enough to contain SW_RADIO. With earlier versions, try searching for every appearance of SW_HEADPHONE_INSERT and make modifications accordingly.

With HAL 0.5.10, you can get quirks from this page to get correct keymaps (and other stuff) for your model. With older versions, like me, you can use my little program to map your keys your way.

thinkpad-acpi-keys.tar.gz

Compile setevkeycodes.c and put it in /usr/local/sbin. Install thinkpad-acpi as a service and copy thinkpad-acpi-keymap to /etc/default. If you prefer to use different paths, modify thinkpad-acpi script accordingly. FYI, the keymaps in thinkpad-acpi-keymap are my current settings, on a T60.

2 comments:

Anonymous said...

"non linuxers, pls ignore this link"

i m gonna ignore this site.

Jason said...

tonni, welcome back whenever you repent. ;)