javispedro.com

hkpanel

Audio LCD controls

This is a little & hackish Linux Kernel Module that allows you to fully control the Audio LCD present on all Acer Travelmate 510 Series notebooks.

I recently got a (used) Acer Travelmate 512T (my very first own laptop!), which happens to have the capability to play audio CDs even while the computer is off. While this may have been cool in 1999 (when everybody had Audio CDs around and no one knew about MP3), in 2007 these keys are more useful as standard hotkeys, like those found in modern laptops. The laptop manual states that these keys can be used to control the media player included in the CD while the computer is on, but of course, the player only works on Windows 9x. I did not want to put Windows 98 on the laptop since then I would not be able to do modern work on it (like running newer, Unicode builds of Firefox), nor I did want to put Windows 2000 on it since it would be very, very slow. As such, I decided to try to write my first loadable linux kernel module.

Actually, there are two modules. hkled is for the LCD itself (exports a misc character device hkled), while hkkey is for the keys (connects to the Linux input system and polls 5 times per second).

I disassembled the Windows driver and had a look at the in/out instructions. In the LCD driver there’s a magic sequence I still don’t understand, but it works nevertheless. The hotkey driver reads key states from CMOS. At first, it looks like the acerhk driver, but in the 510 series, instead of storing “Pending events” in CMOS, the BIOS actually stores the actual key states in a bit field!

As a bonus, the hkkey driver also manages the keys FN+F1 (HELP) and FN+F2 (CONFIG).

Remember these are my very first kernel modules and as such I’m sure they may not work. I’ve only tested them on my 512T. They work pretty well.

License

Licensed under the GPL (so that it does not taint the kernel). You can get a copy of the GPL here. The modules are very simple and as such I don’t think I need the follow the whole GPL release process.

Download

Download from SVN:

You can have a look at the SVN trunk, to get the Makefiles I use to build the modules.

Documentation

hkled

Simple to use. Write a 2-digit number to /dev/hkled to show it on the LCD, or write ‘–’ to show ‘–’. Write ‘0’ to power off the LCD. Read from /dev/hkled to get whatever is currently shown on the LCD.

echo "12" > /dev/hkled  # Shows 12 on the LCD
cat /dev/hkled          #  Writes (to stdout) whatever is shown on the CD

hkkey

Even easier. Automatically registers a input device. You can look for the key codes in the source, or using xev (recommended).