ThinkPad X61 Tablet Tilt Detection and Ubuntu Hardy Heron

Karol Krizka @ January 23, 2008

Linux
Note: If you are using Ubuntu Intrepid Ibex, this guide still applies. However if you are using Ubuntu Hardy Heron, you can just load the hdaps_ec module instead of hdaps.

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.

  1. 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
  2. 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.
  3. Unpack the package and enter it’s directory tar -xvzf tp_smapi-0.39.tgz && cd tp_smapi-0.39
  4. Build the sources make HDAPS=1 KSRC=/usr/src/linux-headers-`uname -r`
  5. 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.

  1. Install the hdaps-utils package by running sudo aptitude install hdaps-utils
  2. Run the hdaps-gl command to see a 3D rendering of your laptop in its current orientation.

Known Problems

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.

Did you enjoy this post? Then why not subscribe to my RSS feed or subscribe by e-mail? Also check out the many other FREE ways to appreciate a blogger.


Related Posts

RSS feed | Trackback URI

14 Comments »

Comment by Farhad Subscribed to comments via email
2008-01-24 04:00:06

Thanks for the info. I have a x61t too and wanted to install Ubuntu. I was looking for such information. Keep posting your experiences with Ubuntu on x61t. By the way which software do you use instead of windows journal or one note?

Comment by Karol Krizka
2008-01-24 07:34:14

I use Xournal for writing notes.

Update: Link fixed, I just realized that I closed it improperly and you couldn’t see it.

 
 
Comment by [RDH]Zerted Subscribed to comments via email
2008-03-15 10:49:29

I hope you don’t mind, but I referenced this page when writing the Tilt Detection section for the X61 Table on .

Thanks for your help. This was the easiest tutorial I found on the subject.

 
Comment by [RDH]Zerted Subscribed to comments via email
2008-03-15 10:52:00

Oops, my link was all messed up. I meant to say that this was the easiest tutorial, not the one I wrote on ThinkWiki.

(A preview button would be nice)

 
Comment by woo
2008-03-25 13:18:49

Unless Ubuntu patched the kernel with the diskprotect patch by default, which I don’t think it does, I hope you all know that this only activates the accelerometer and does not actually park the hard disk. With the above procedure, you can only monitor tilt, do not bump your laptop around too much as it will damage the drive.

In order to park the hard disk, you have to patch and recompile the kernel.

I mentioned this because someone linked from thinkwiki to this site and probably presumed that it would protect the hdd.

Read http://www.thinkwiki.org/wiki/HDAPS carefully for directions on patching the kernel and recompiling.

 
Comment by John
2008-04-11 19:31:26

I made a comment but forgot to type in the captcha. The screen came back telling me to try again BUT HAVING DELETED MY COMMENT TEXT!

Oh, and your ebay ad is obscuring your blog text.

 
Comment by Abhishek
2008-05-01 08:49:01

A Big Thanks for sharing your knowledge in such a clear and simple article.

I followed it, and was able to run the IBM Accelorometer successfully.

Thanks again:)
Abhishek

R61 | Hardy Heron 8.04 | tp_smapi0.37

 
Comment by woo
2008-06-06 20:15:02

hehe, Ubuntu users failed reading comprehension.

 
Comment by ariel Subscribed to comments via email
2008-06-15 13:03:35

This won’t work properly for me unless the lines for Virtual Display (see here) are added to /etc/X11/xorg.conf. The unfortunate consequence is that compiz seems to stop working when I do that. Any ideas?

tp_smapi and hdaps_ec are loaded in /etc/modules and did not need recompiling (as per the note). Tilt detection is accurate with hdaps-gl and running autorotate.py yields no errors and prints integers (between 1 and 4) upon rotation of the laptop.

 
2008-08-01 13:44:37

[...] sure you have a working accelerometer that is reading the proper orientation as tested using the hdaps-gl [...]

 
Comment by jimmy
2008-08-06 08:04:44

thank you very much.. This is just what i needed..

It seems to work now :)

next step is “smackpad” ;)

 
2008-09-26 00:19:51

[...] (for example, does tilting it forward make the picture of the laptop tilt forward?). If not, go HERE and follow the troubleshooting section. Hopefully though, everything will work and you can continue [...]

 
Comment by nicolas roy Subscribed to comments via email
2008-10-11 11:40:13

Hello,

Great stuff. The tilt detection and automatic rotation work very well !
One small problem, nevertheless : if i load the module manually with modprobe hdaps_ec, this works. But at boot, the module is not loaded automatically, even if i add the line
hdaps_ec
to the file
/etc/modules
How can i fix this (sorry for this newbie question …) ?

thanks

Nicolas

Comment by nicolas roy Subscribed to comments via email
2008-10-13 23:12:00

Hej !

The problem with the hdaps_ec module not loaded at boot, was only that in /etc/modules i had the following line :
hdaps_ec # and some comment here
and the comment made a problem !
Sorry for that.

But now, i encounter athe following issue, already mentioned by others : i have (apparently randomly) sometimes 4 available rotations, and sometimes only 2. Did someone managed to fix this ?

Thanks

Nicolas

 
 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line=""> in your comment.

Feed