ThinkPad X61 Tablet Tilt Detection and Ubuntu Hardy Heron
It has been quite a long time since I last blogged about my ThinkPad X61, so I think it time for another post. One topic that I skimmed in my review is the setup of the built-in accelerometer that detects when you tilt your laptop. This can be quite useful for several reasons, like stopping your disk from spinning when you are moving around your laptop. Also you can do cool things like rotating your screen automatically or playing Neverball. For this you need the hdaps driver that comes with Ubuntu, but is broken. When you try to load it with modprobe hdaps, you will get the following error:
FATAL: Error inserting hdaps (/lib/modules/2.6.24-3-generic/kernel/drivers/hwmon/hdaps.ko): No such device
The only solution that I found is to recompile the module manually, which is quite easy to do. Just follow a few steps, and you are done.
- Install the necessary build tools. I am not too sure which packages are required, but the following list should get you started. If you encounter any errors about missing commands, please leave a comment and I will update the list.
sudo aptitude install build-essential kernel-header
- Download the tp_smapi package that contains all the necessary sources for the hdaps module from here. In this tutorial I will be using tp_smapi version 0.39. You can find more information about the tp_smapi package at its ThinkWiki page.
- Unpack the package and enter it’s directory
tar -xvzf tp_smapi-0.39.tgz && cd tp_smapi-0.39
- Build the sources
make HDAPS=1 KSRC=/usr/src/linux-headers-`uname -r`
- Install the module
sudo make install HDAPS=1 KSRC=/usr/src/linux-headers-`uname -r`
Now you should have working tilt detection, but you should test it anyways. The first step is to install the hdaps utilities and then run some of them to see interesting results.
- Install the hdaps-utils package by running
sudo aptitude install hdaps-utils
- Run the hdaps-gl command to see a 3D rendering of your laptop in its current orientation.
With older version of tp_smapi (0.34 and older), the axes in the hdaps-gl utility are all mixed up. When I tilt the computer forward, I see it tilt sideways and vice versa. This can be easily fixed by adding the invert option to the hdaps module. I added the following line to /etc/modprobe.d/options to fix the orientation of my ThinkPad X61 Tablet:
options hdaps invert=6
If the invert option 6 does not work for you, try setting it to another number from the following list:
invert=0: R= X P= Y
invert=1: R=-X P=-Y
invert=2: R=-X P= Y
invert=3: R= X P=-Y
invert=4: R= Y P= X
invert=5: R=-Y P=-X
invert=6: R=-Y P= X
invert=7: R= Y P=-X
I believe that this is a known problem because of the following line found in tp_smapi-0.34’s CHANGES file:
– hdaps whitelist: change ThinkPad X61s and T61 default orientation.
X60 Tablet and X61 Tablet remain wrong until someone reports their DMI ID.