Skip to content
Jan 23 / kkrizka

ThinkPad X61 Tablet Tilt Detection and Ubuntu Hardy Heron

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.

15 Comments

Leave a comment
  1. Farhad / Jan 24 2008

    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?

    • Karol Krizka / Jan 24 2008

      I use Xournal for writing notes.

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

  2. [RDH]Zerted / Mar 15 2008

    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.

  3. [RDH]Zerted / Mar 15 2008

    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)

  4. woo / Mar 25 2008

    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.

  5. John / Apr 11 2008

    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.

  6. Abhishek / May 1 2008

    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

  7. woo / Jun 6 2008

    hehe, Ubuntu users failed reading comprehension.

  8. ariel / Jun 15 2008

    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.

  9. jimmy / Aug 6 2008

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

    It seems to work now :)

    next step is “smackpad” 😉

  10. nicolas roy / Oct 11 2008

    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

    • nicolas roy / Oct 13 2008

      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

Trackbacks and Pingbacks

  1. ThinkPad X61 Tablet Automatic Screen Rotation Under Linux | Karol Krizka
  2. aliencam dot net blog. » Blog Archive » Ubuntu Setup Guide -Tilt Control and Automatic Rotation
  3. ThinkPad X61 Tablet Tilt Detection and Ubuntu Karmic Koala | Karol Krizka
Leave a comment