acpithinkpad
I started working on an ACPI driver this evening to make my ThinkPad X61 work
better under OpenBSD.
I just finished it and so far it matches on the IBM0068
ACPI HID device,
checks it for the appropriate version, enables the Bluetooth device (which is
required before the hardware toggle switch can power it on and let the ubt0
device show up), and sets up a callback to run whenever a special button (e.g.,
Fn+F[1-9], brightness, ThinkLight, etc.) is pressed.
I'm pretty sure it will work on most other ThinkPads but I haven't tried it on
my X40 yet.
I mapped out all of the events that get generated, which on my X61 Tablet include the screen rotating around, the lid opening and closing, and even the pen being ejected from its little slot. When the brightness buttons (Fn+Home and Fn+End) are pressed, it sends a CMOS command through ACPI to actually adjust the screen brightness accordingly, so now it's working just like my X40 did on its own. Being able to turn the brightness down when on battery is the main reason I wrote this.
I'm still not sure what to do with the other key events, though.
I'd like to setup a sysctl
sensor that shows the status of the lid (there is
already one from the aps
device that shows whether it's open or closed, but
not whether it's rotated around) and maybe hook up the brightness stuff to
wscons so wsconsctl
can adjust the screen brightness like it can on the
Zaurus.
The rest of the keys will probably map to regular keycodes so X11 can see them
and get mapped by applications.
Either way, I'd like to set it up so when I rotate the screen around, something
will see that sysctl
value change and automatically run my
rotation script
to call xrandr
to flip the display around and re-map the buttons on the
screen.
Currently I have the physical "rotate" button on the bottom of the screen mapped
to call that script so I have to push it whenever I flip the lid around,
but what's the fun in that?
I could probably even hook into the sysctl
values from the accelerometer on
the X61 and call xrandr
as needed so that the screen is always oriented
properly depending on its physical position in space and the orientation of the
lid.