https://www.thinkwiki.org/w/api.php?action=feedcontributions&user=Ciclo&feedformat=atomThinkWiki - User contributions [en]2024-03-28T13:56:52ZUser contributionsMediaWiki 1.31.12https://www.thinkwiki.org/w/index.php?title=HDAPS&diff=38203HDAPS2008-07-14T11:50:22Z<p>Ciclo: /* Kernel patch */</p>
<hr />
<div>{| width="100%"<br />
|style="vertical-align:top;padding-right:20px;width:10px;white-space:nowrap;" | __TOC__<br />
|style="vertical-align:top" |<br />
=== HDAPS - IBM Active Protection System Linux Driver ===<br />
This is the Linux driver for monitoring the accelerometer known as [[Active Protection System|IBM Active Protection System]].<br />
<br />
The driver only enables reading of the acceleration data. It does '''not''' perform [[#Harddisk Protection|automatic disk head parking]]. But there are already some other useful [[#Applications|applications]] for HDAPS, using the {{path|/sys}} interface it provides.<br />
<br />
{{WARN|There are two versions of the hdaps driver, one in the Linux kernel mainline, and another provided by [[tp_smapi]]. '''Use of the tp_smapi version of hdaps is strongly recommended by the current hdaps developers.'''}}<br />
|}<br />
<br />
=== Features ===<br />
*provides accelerometer values via sysfs<br />
*provides a joystick type input device<br />
<br />
=== Project Homepage / Availability ===<br />
*[http://hdaps.sourceforge.net/ Project Homepage]<br />
*The driver is included in the 2.6-mm series of kernels since August, 26th 2005.<br />
*The driver is now in the mainline (2.6.14).<br />
*The [[tp_smapi]] package contains some patches to this driver. These are necessary for some recent models, and recommended for all.<br />
<br />
=== Status ===<br />
A driver is included in recent Linux kernels and is actively maintained, but it is very inferior to the driver in tp_smapi (which provides its own hdaps module).<br />
<br />
=== How to install the driver ===<br />
Recent Linux kernels include the <tt>hdaps</tt> driver. However, the driver in the mainline Linux kernel has two problems with recent models:<br />
* It doesn't whitelist them (you have to edit hdaps_init() in drivers/hwmon/hdaps.c to include a line like <tt>HDAPS_DMI_MATCH_LENOVO("ThinkPad T60")</tt>)<br />
* It doesn't work reliably, e.g., it may read out constant values (0,0). See [http://sourceforge.net/mailarchive/message.php?msg_id=15350314 here].<br />
<br />
To solve both problems, install the modified hdaps that is bundled with [[tp_smapi]].<br />
<br />
=== Harddisk Protection ===<br />
As mentioned above, the hdaps kernel driver is only responsible for reading the accelerometer data and exporting it through the sysfs interface. In order to use this information to protect the disk, some additional steps are required.<br />
<br />
See [[How to protect the harddisk through APS]].<br />
<br />
=== Input device support ===<br />
In more recent versions of the Linux kernel, the hdaps exports event devices with the accelerometer data. These devices can be used as-is by some programs (e.g. hdapsd), but for most they must be handled by the additional kernel module <code>joydev</code>.<br />
<br />
When both modules are loaded, joydev will provide standard joystick device emulation for hdaps (standard hdaps exports just one joystick device. enhanced hdaps from tp_smapi will export two due to issues still unsolved on joydev, but the second one must not be used as a joystick).<br />
<br />
{{WARN|Letting a program bind to these joystick devices can cause surprising results if you are not aware of it. e.g.: mplayer can act quite strangely. Also, letting a program bind to the second joystick device from enhanced HDAPS is guaranteed to be trouble}}<br />
<br />
Udev can be used to create device nodes in /dev for use by user space programs that access the joystick, and to set appropriate permissions.<br />
<br />
In order for non-root users to access these device files, their permissions must be tweaked a little through an appropriate udev rule and corresponding "joy" group.<br />
<br />
{{cmdroot|addgroup joy}}<br><br />
{{cmdroot|adduser <you> joy}}<br><br />
<code># echo 'SUBSYSTEM=="input", KERNEL=="js*", MODE="0660", GROUP="joy"' >> /etc/udev/hdaps-joy.rules</code><br><br />
{{cmdroot|ln -s ../hdaps-joy.rules /etc/udev/rules.d/z60_hdaps-joy.rules}}<br><br />
<br />
Programs you can use to test and calibrate the device files include <code>jscalibrator</code> (gui) and <code>jstest</code>/<code>jscal</code> (cli) packaged together (at least in Debian) simply as "joystick".<br />
<br />
=== Applications ===<br />
====Disk head parking====<br />
You will need the kernel patch below and the hdapsd userspace daemon. The GUI monitoring is optional.<br />
<br />
See [[How to protect the harddisk through APS]] for more information.<br />
<br />
===== Kernel patch =====<br />
Due to significant changes in the way the libata module which handles disk i/o, applying any of the currently available patches to kernel 2.6.24 will intermittently cause system hangs when the queue is frozen (i.e., the heads are parked). It is recommended either that you stay at kernel [http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.17.tar.bz2 2.6.23] or do without disk protection in 2.6.24 until the kinks have been worked out. There has been significant work on the part of [http://lkml.org/lkml/2008/2/25/478 Elias Oltmanns], author of the more recent patches, to get this worked out and eventually get shock protection built into the mainline kernel.<br />
<br />
Below are some links to patches for various Linux kernel versions. As noted above, your mileage may vary with the 2.6.24-rc3 patch as it was after this release candidate that things stopped working nicely. <br />
{{HINT|To apply a patch, change to the root directory of the kernel tree and run<br><code>patch -p1 -l < hdaps_xx.patch</code>}}<br />
* New interface<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1297 disk-protect patch for kernel 2.6.26-rc9]<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1245 disk-protect patch for kernel 2.6.25-rc9] &mdash; may cause system locks (same as patch for 2.6.24-rc3). Apply [http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/2008-February/042226.html this fix] before.<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1094 disk-protect patch for kernel 2.6.24-rc3] &mdash; may cause system locks (see [http://marc.info/?l=linux-thinkpad&m=120259594519907 here], [http://marc.info/?l=linux-thinkpad&m=120259929023300 here] and try [http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/2008-February/042226.html this fix])<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1092 disk-protect patch for 2.6.23.8] + [http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1113 error check fix]<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1077 disk-protect patch for 2.6.22.9 and 2.6.23-rc9]<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/993 disk-protect patch for 2.6.20-rc6]<br />
* Old interface<br />
**[http://www.nabble.com/attachment/9047418/0/hdaps_protect-2.6.20.patch.bz2 Latest sata/ide disk protection patch for 2.6.20]<br />
**[http://article.gmane.org/gmane.linux.kernel/470413 Latest sata/ide disk protection patch for 2.6.19-rc6]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect-2.6.18.3-2.patch Latest sata/ide disk protection patch for 2.6.18.3]<br />
**[http://exitzero.de/t41p-configs/hdaps_protect-2.6.17.1-20060625.patch Untested patch for 2.6.17.1]: see [http://thread.gmane.org/gmane.linux.drivers.hdaps.devel/708/focus=708]<br />
**[http://whoopie.gmxhome.de/linux/patches/2.6.17.14-tj/03-hdaps_protect-20060430-for-2.6.17-tj.patch Latest sata/ide disk protection patch for use with the libata hotplug 2.6.17.4 patches] - See [[How_to_hotswap_UltraBay_devices]]<br />
**[http://whoopie.gmxhome.de/linux/patches/2.6.16-tj/05-hdaps_protect-20060430-for-2.6.16-tj.patch Latest sata/ide disk protection patch for use with the libata hotplug 2.6.16.16 patches] - See [[How_to_hotswap_UltraBay_devices]]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect.20060430.patch Latest sata/ide disk protection patch for 2.6.16]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect.20060118.patch sata/ide disk protection patch for 2.6.15]<br />
**[http://jenster.dyndns.org/files/blk_freeze-01-nodetection-for-2.6.15.patch disk park patch adapted for the t41p model] <tt> kernel 2.6.15 ([http://sourceforge.net/mailarchive/message.php?msg_id=13214288 capability detection disabled], no libata support)</tt><br />
**[http://jenster.dyndns.org/files/blk_freeze-01-nodetection-for-2.6.14.patch disk park patch adapted for the t41p model] <tt> kernel 2.6.14 ([http://sourceforge.net/mailarchive/message.php?msg_id=13214288 capability detection disabled], no libata support)</tt><br />
**[http://lwn.net/Articles/154923/ disk park patch] <tt>an experimental patch for parking the disk (Linux 2.6.14 for 2.6.15 see below)</tt><br />
<br />
===== Userspace daemon =====<br />
*[http://www.dresco.co.uk/hdaps/hdapsd-20070524.c Recommended version]<br />
*[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1045 Reduced power version] - reduces timer interrupts, as measured by [[PowerTOP]]. This leads to lower power consumption on [[tickless kernel|tickless kernels]]. Interrupt reduction requires the <tt>hdaps</tt> kernel module from [[tp_smapi]] 0.32 or newer, and a [http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1040 udev rule].<br />
*[ftp://rohrmoser-engineering.de/pub Modified adaptive algorithm version] - uses a different (and potentially better) algorithm for the adaptive sensivity threshold.<br />
<br />
===== GUI monitoring =====<br />
*[http://roy.marples.name/node/269 khdapmonitor] KDE System Tray Monitor<br />
*[http://www.dresco.co.uk/hdaps/gnome-hdaps-applet-20060120.tar.gz gnome-hdaps-applet] visual display of disk protection status in gnome panel<br />
*[http://www.kde-look.org/content/show.php/Applet+HDAPS?content=78387 applet_hdaps] KDE4 Plasmoid display disk protection status<br />
*[http://awn.planetblur.org/index.php?shard=forum&action=g_reply&ID=1916&page=1&isLive=true ThinkHDAPS] Avant Window Manager applet for disk protection status<br />
<br />
====Security & safety====<br />
*[[Script for theft alarm using HDAPS]]<br />
<br />
====Tilt monitoring====<br />
*[http://www.mulliner.org/collin/gkibm-acpi.php gkhdaps] <tt>a GKrellM applet displaying tilt data</tt><br />
*[http://rlove.org/log/2005082203.html gnome-tilt] <tt>a gnome applet showing tilt data</tt><br />
<br />
====Visualisation of ThinkPad orientation====<br />
*[http://rlove.org/log/2005082401.html hdaps-gl] <tt>a little app animating a 3D-ThinkPad</tt><br />
*[https://sourceforge.net/project/showfiles.php?group_id=138242 hdapsgl-applet] <tt> a GNOME applet animating a 3D-ThinkPad</tt><br />
*[https://sourceforge.net/project/showfiles.php?group_id=138242 wmadhps] <tt>a WindowMaker DockApp animating a 3D-ThinkPad</tt><br />
*[http://www.cs.cmu.edu/~ecc/gyro.tar.gz OpenGL gyroscope hack] <tt>keeps your display levelled when tilting the ThinkPad</tt> (warning: [http://en.wikipedia.org/wiki/Tarbomb uncompresses in the current directory]!)<br />
<br />
====Games====<br />
*[http://icculus.org/neverball/ Neverball] is quite fun with HDAPS. (You'll need to have the HDAPS joystick device)<br />
*Turn your ThinkPad into a Jedi Weapon (hey, it [http://isnoop.net/blog/2006/05/20/macsaber-turn-your-mac-into-a-jedi-weapon works for Mac laptops])<br />
<br />
====Other====<br />
<br />
*[http://blog.micampe.it/articles/2006/06/04/here-comes-the-smackpad smack.py] - switch workspace by smacking your laptop, inspired by the [http://blog.medallia.com/2006/05/smacbook_pro.html SmackBook] (uses EWMH)<br />
**an [http://weblogs.mozillazine.org/gerv/archives/2006/09/stablilised_smackpad.html improved version] adds stabilization (by comparing smacks to previous ones, uses EWMH)<br />
**another [http://pberndt.com/Programme/Linux/pyhdaps/index.html approach] adds stabilization (by requiring a certain type of value deflection, uses xmacroplay)<br />
**[http://www.gnome.org/~fherrera/gtollina.c GTollina] is another smack program for use with compiz (video [http://www.gnome.org/~fherrera/blog/gtollina.html here]).<br />
*[http://blog.odonnell.nu/61.html xmms-smack.py] - move through your xmms playlist by smacking, based on the two smack scripts above.<br />
*[http://www-128.ibm.com/developerworks/linux/library/l-knockage.html?ca=dgr-lnxw02aKnockBasedCommands KnockBasedCommands] - Execute commands by tapping your laptop.<br />
*[http://people.ksp.sk/~mic/?menu=32&file=rotate.py rotate.py] - rotate desktop by turning your laptop<br />
<br />
=== Interesting links related to this project ===<br />
* [https://lists.sourceforge.net/lists/listinfo/hdaps-devel HDAPS mailinglist and its archive]<br />
* #hdaps channel on irc.freenode.org<br />
* [https://sourceforge.net/projects/hdaps/ hdaps projects] overview of userspace programs using hdaps<br />
* [http://www-307.ibm.com/pc/support/site.wss/document.do?lndocid=TPAD-HDFIRM IBM ThinkPads hardware drive firmware site]<br />
* [http://www.paul.sladen.org/thinkpad-r31/accelerometer.html http://www.paul.sladen.org/thinkpad-r31/accelerometer/]<br />
* http://bugs.gentoo.org/show_bug.cgi?id=119845 Gentoo ebuild for hdaps driver and daemon including a initscript*<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137345 Gentoo ebuild for gkhdaps gkrell plugin<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137350 Gentoo ebuild for hdaps-gl application<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137351 Gentoo ebuild for gnome hdapsgl-applet<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137352 Gentoo ebuild for gnome tilt application<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137353 Gentoo ebuild for wmhdaps<br />
* http://gentoo.o0o.nu Gentoo sectools overlay with fresh hdaps-related ebuilds and patches<br />
* [http://lenovoblogs.com/insidethebox/?p=71 Why the ThinkPad accelerometer is only 2D] - explanation by Lenovo<br />
<br />
[[Category:R50]] [[Category:R50p]] [[Category:R51]] [[Category:R52]] [[Category:R60]] [[Category:T41]] [[Category:T41p]] [[Category:T42]] [[Category:T42p]] [[Category:T43]] [[Category:T43p]] [[Category:T60]] [[Category:T60p]] [[Category:T61]] [[Category:X40]] [[Category:X41]] [[Category:X41 Tablet]] [[Category:X60]] [[Category:X60s]] [[Category:Z60m]] [[Category:Z60t]] [[Category:Drivers]] [[Category:Z61m]]</div>Ciclohttps://www.thinkwiki.org/w/index.php?title=HDAPS&diff=38202HDAPS2008-07-14T11:49:35Z<p>Ciclo: </p>
<hr />
<div>{| width="100%"<br />
|style="vertical-align:top;padding-right:20px;width:10px;white-space:nowrap;" | __TOC__<br />
|style="vertical-align:top" |<br />
=== HDAPS - IBM Active Protection System Linux Driver ===<br />
This is the Linux driver for monitoring the accelerometer known as [[Active Protection System|IBM Active Protection System]].<br />
<br />
The driver only enables reading of the acceleration data. It does '''not''' perform [[#Harddisk Protection|automatic disk head parking]]. But there are already some other useful [[#Applications|applications]] for HDAPS, using the {{path|/sys}} interface it provides.<br />
<br />
{{WARN|There are two versions of the hdaps driver, one in the Linux kernel mainline, and another provided by [[tp_smapi]]. '''Use of the tp_smapi version of hdaps is strongly recommended by the current hdaps developers.'''}}<br />
|}<br />
<br />
=== Features ===<br />
*provides accelerometer values via sysfs<br />
*provides a joystick type input device<br />
<br />
=== Project Homepage / Availability ===<br />
*[http://hdaps.sourceforge.net/ Project Homepage]<br />
*The driver is included in the 2.6-mm series of kernels since August, 26th 2005.<br />
*The driver is now in the mainline (2.6.14).<br />
*The [[tp_smapi]] package contains some patches to this driver. These are necessary for some recent models, and recommended for all.<br />
<br />
=== Status ===<br />
A driver is included in recent Linux kernels and is actively maintained, but it is very inferior to the driver in tp_smapi (which provides its own hdaps module).<br />
<br />
=== How to install the driver ===<br />
Recent Linux kernels include the <tt>hdaps</tt> driver. However, the driver in the mainline Linux kernel has two problems with recent models:<br />
* It doesn't whitelist them (you have to edit hdaps_init() in drivers/hwmon/hdaps.c to include a line like <tt>HDAPS_DMI_MATCH_LENOVO("ThinkPad T60")</tt>)<br />
* It doesn't work reliably, e.g., it may read out constant values (0,0). See [http://sourceforge.net/mailarchive/message.php?msg_id=15350314 here].<br />
<br />
To solve both problems, install the modified hdaps that is bundled with [[tp_smapi]].<br />
<br />
=== Harddisk Protection ===<br />
As mentioned above, the hdaps kernel driver is only responsible for reading the accelerometer data and exporting it through the sysfs interface. In order to use this information to protect the disk, some additional steps are required.<br />
<br />
See [[How to protect the harddisk through APS]].<br />
<br />
=== Input device support ===<br />
In more recent versions of the Linux kernel, the hdaps exports event devices with the accelerometer data. These devices can be used as-is by some programs (e.g. hdapsd), but for most they must be handled by the additional kernel module <code>joydev</code>.<br />
<br />
When both modules are loaded, joydev will provide standard joystick device emulation for hdaps (standard hdaps exports just one joystick device. enhanced hdaps from tp_smapi will export two due to issues still unsolved on joydev, but the second one must not be used as a joystick).<br />
<br />
{{WARN|Letting a program bind to these joystick devices can cause surprising results if you are not aware of it. e.g.: mplayer can act quite strangely. Also, letting a program bind to the second joystick device from enhanced HDAPS is guaranteed to be trouble}}<br />
<br />
Udev can be used to create device nodes in /dev for use by user space programs that access the joystick, and to set appropriate permissions.<br />
<br />
In order for non-root users to access these device files, their permissions must be tweaked a little through an appropriate udev rule and corresponding "joy" group.<br />
<br />
{{cmdroot|addgroup joy}}<br><br />
{{cmdroot|adduser <you> joy}}<br><br />
<code># echo 'SUBSYSTEM=="input", KERNEL=="js*", MODE="0660", GROUP="joy"' >> /etc/udev/hdaps-joy.rules</code><br><br />
{{cmdroot|ln -s ../hdaps-joy.rules /etc/udev/rules.d/z60_hdaps-joy.rules}}<br><br />
<br />
Programs you can use to test and calibrate the device files include <code>jscalibrator</code> (gui) and <code>jstest</code>/<code>jscal</code> (cli) packaged together (at least in Debian) simply as "joystick".<br />
<br />
=== Applications ===<br />
====Disk head parking====<br />
You will need the kernel patch below and the hdapsd userspace daemon. The GUI monitoring is optional.<br />
<br />
See [[How to protect the harddisk through APS]] for more information.<br />
<br />
===== Kernel patch =====<br />
Due to significant changes in the way the libata module which handles disk i/o, applying any of the currently available patches to kernel 2.6.24 will intermittently cause system hangs when the queue is frozen (i.e., the heads are parked). It is recommended either that you stay at kernel [http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.17.tar.bz2 2.6.23] or do without disk protection in 2.6.24 until the kinks have been worked out. There has been significant work on the part of [http://lkml.org/lkml/2008/2/25/478 Elias Oltmanns], author of the more recent patches, to get this worked out and eventually get shock protection built into the mainline kernel.<br />
<br />
Below are some links to patches for various Linux kernel versions. As noted above, your mileage may vary with the 2.6.24-rc3 patch as it was after this release candidate that things stopped working nicely. <br />
{{HINT|To apply a patch, change to the root directory of the kernel tree and run<br><code>patch -p1 -l < hdaps_xx.patch</code>}}<br />
* New interface<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1297 disk-protect patch for kernel 2.6.26-rc9] &mdash;.<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1245 disk-protect patch for kernel 2.6.25-rc9] &mdash; may cause system locks (same as patch for 2.6.24-rc3). Apply [http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/2008-February/042226.html this fix] before.<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1094 disk-protect patch for kernel 2.6.24-rc3] &mdash; may cause system locks (see [http://marc.info/?l=linux-thinkpad&m=120259594519907 here], [http://marc.info/?l=linux-thinkpad&m=120259929023300 here] and try [http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/2008-February/042226.html this fix])<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1092 disk-protect patch for 2.6.23.8] + [http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1113 error check fix]<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1077 disk-protect patch for 2.6.22.9 and 2.6.23-rc9]<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/993 disk-protect patch for 2.6.20-rc6]<br />
* Old interface<br />
**[http://www.nabble.com/attachment/9047418/0/hdaps_protect-2.6.20.patch.bz2 Latest sata/ide disk protection patch for 2.6.20]<br />
**[http://article.gmane.org/gmane.linux.kernel/470413 Latest sata/ide disk protection patch for 2.6.19-rc6]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect-2.6.18.3-2.patch Latest sata/ide disk protection patch for 2.6.18.3]<br />
**[http://exitzero.de/t41p-configs/hdaps_protect-2.6.17.1-20060625.patch Untested patch for 2.6.17.1]: see [http://thread.gmane.org/gmane.linux.drivers.hdaps.devel/708/focus=708]<br />
**[http://whoopie.gmxhome.de/linux/patches/2.6.17.14-tj/03-hdaps_protect-20060430-for-2.6.17-tj.patch Latest sata/ide disk protection patch for use with the libata hotplug 2.6.17.4 patches] - See [[How_to_hotswap_UltraBay_devices]]<br />
**[http://whoopie.gmxhome.de/linux/patches/2.6.16-tj/05-hdaps_protect-20060430-for-2.6.16-tj.patch Latest sata/ide disk protection patch for use with the libata hotplug 2.6.16.16 patches] - See [[How_to_hotswap_UltraBay_devices]]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect.20060430.patch Latest sata/ide disk protection patch for 2.6.16]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect.20060118.patch sata/ide disk protection patch for 2.6.15]<br />
**[http://jenster.dyndns.org/files/blk_freeze-01-nodetection-for-2.6.15.patch disk park patch adapted for the t41p model] <tt> kernel 2.6.15 ([http://sourceforge.net/mailarchive/message.php?msg_id=13214288 capability detection disabled], no libata support)</tt><br />
**[http://jenster.dyndns.org/files/blk_freeze-01-nodetection-for-2.6.14.patch disk park patch adapted for the t41p model] <tt> kernel 2.6.14 ([http://sourceforge.net/mailarchive/message.php?msg_id=13214288 capability detection disabled], no libata support)</tt><br />
**[http://lwn.net/Articles/154923/ disk park patch] <tt>an experimental patch for parking the disk (Linux 2.6.14 for 2.6.15 see below)</tt><br />
<br />
===== Userspace daemon =====<br />
*[http://www.dresco.co.uk/hdaps/hdapsd-20070524.c Recommended version]<br />
*[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1045 Reduced power version] - reduces timer interrupts, as measured by [[PowerTOP]]. This leads to lower power consumption on [[tickless kernel|tickless kernels]]. Interrupt reduction requires the <tt>hdaps</tt> kernel module from [[tp_smapi]] 0.32 or newer, and a [http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1040 udev rule].<br />
*[ftp://rohrmoser-engineering.de/pub Modified adaptive algorithm version] - uses a different (and potentially better) algorithm for the adaptive sensivity threshold.<br />
<br />
===== GUI monitoring =====<br />
*[http://roy.marples.name/node/269 khdapmonitor] KDE System Tray Monitor<br />
*[http://www.dresco.co.uk/hdaps/gnome-hdaps-applet-20060120.tar.gz gnome-hdaps-applet] visual display of disk protection status in gnome panel<br />
*[http://www.kde-look.org/content/show.php/Applet+HDAPS?content=78387 applet_hdaps] KDE4 Plasmoid display disk protection status<br />
*[http://awn.planetblur.org/index.php?shard=forum&action=g_reply&ID=1916&page=1&isLive=true ThinkHDAPS] Avant Window Manager applet for disk protection status<br />
<br />
====Security & safety====<br />
*[[Script for theft alarm using HDAPS]]<br />
<br />
====Tilt monitoring====<br />
*[http://www.mulliner.org/collin/gkibm-acpi.php gkhdaps] <tt>a GKrellM applet displaying tilt data</tt><br />
*[http://rlove.org/log/2005082203.html gnome-tilt] <tt>a gnome applet showing tilt data</tt><br />
<br />
====Visualisation of ThinkPad orientation====<br />
*[http://rlove.org/log/2005082401.html hdaps-gl] <tt>a little app animating a 3D-ThinkPad</tt><br />
*[https://sourceforge.net/project/showfiles.php?group_id=138242 hdapsgl-applet] <tt> a GNOME applet animating a 3D-ThinkPad</tt><br />
*[https://sourceforge.net/project/showfiles.php?group_id=138242 wmadhps] <tt>a WindowMaker DockApp animating a 3D-ThinkPad</tt><br />
*[http://www.cs.cmu.edu/~ecc/gyro.tar.gz OpenGL gyroscope hack] <tt>keeps your display levelled when tilting the ThinkPad</tt> (warning: [http://en.wikipedia.org/wiki/Tarbomb uncompresses in the current directory]!)<br />
<br />
====Games====<br />
*[http://icculus.org/neverball/ Neverball] is quite fun with HDAPS. (You'll need to have the HDAPS joystick device)<br />
*Turn your ThinkPad into a Jedi Weapon (hey, it [http://isnoop.net/blog/2006/05/20/macsaber-turn-your-mac-into-a-jedi-weapon works for Mac laptops])<br />
<br />
====Other====<br />
<br />
*[http://blog.micampe.it/articles/2006/06/04/here-comes-the-smackpad smack.py] - switch workspace by smacking your laptop, inspired by the [http://blog.medallia.com/2006/05/smacbook_pro.html SmackBook] (uses EWMH)<br />
**an [http://weblogs.mozillazine.org/gerv/archives/2006/09/stablilised_smackpad.html improved version] adds stabilization (by comparing smacks to previous ones, uses EWMH)<br />
**another [http://pberndt.com/Programme/Linux/pyhdaps/index.html approach] adds stabilization (by requiring a certain type of value deflection, uses xmacroplay)<br />
**[http://www.gnome.org/~fherrera/gtollina.c GTollina] is another smack program for use with compiz (video [http://www.gnome.org/~fherrera/blog/gtollina.html here]).<br />
*[http://blog.odonnell.nu/61.html xmms-smack.py] - move through your xmms playlist by smacking, based on the two smack scripts above.<br />
*[http://www-128.ibm.com/developerworks/linux/library/l-knockage.html?ca=dgr-lnxw02aKnockBasedCommands KnockBasedCommands] - Execute commands by tapping your laptop.<br />
*[http://people.ksp.sk/~mic/?menu=32&file=rotate.py rotate.py] - rotate desktop by turning your laptop<br />
<br />
=== Interesting links related to this project ===<br />
* [https://lists.sourceforge.net/lists/listinfo/hdaps-devel HDAPS mailinglist and its archive]<br />
* #hdaps channel on irc.freenode.org<br />
* [https://sourceforge.net/projects/hdaps/ hdaps projects] overview of userspace programs using hdaps<br />
* [http://www-307.ibm.com/pc/support/site.wss/document.do?lndocid=TPAD-HDFIRM IBM ThinkPads hardware drive firmware site]<br />
* [http://www.paul.sladen.org/thinkpad-r31/accelerometer.html http://www.paul.sladen.org/thinkpad-r31/accelerometer/]<br />
* http://bugs.gentoo.org/show_bug.cgi?id=119845 Gentoo ebuild for hdaps driver and daemon including a initscript*<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137345 Gentoo ebuild for gkhdaps gkrell plugin<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137350 Gentoo ebuild for hdaps-gl application<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137351 Gentoo ebuild for gnome hdapsgl-applet<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137352 Gentoo ebuild for gnome tilt application<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137353 Gentoo ebuild for wmhdaps<br />
* http://gentoo.o0o.nu Gentoo sectools overlay with fresh hdaps-related ebuilds and patches<br />
* [http://lenovoblogs.com/insidethebox/?p=71 Why the ThinkPad accelerometer is only 2D] - explanation by Lenovo<br />
<br />
[[Category:R50]] [[Category:R50p]] [[Category:R51]] [[Category:R52]] [[Category:R60]] [[Category:T41]] [[Category:T41p]] [[Category:T42]] [[Category:T42p]] [[Category:T43]] [[Category:T43p]] [[Category:T60]] [[Category:T60p]] [[Category:T61]] [[Category:X40]] [[Category:X41]] [[Category:X41 Tablet]] [[Category:X60]] [[Category:X60s]] [[Category:Z60m]] [[Category:Z60t]] [[Category:Drivers]] [[Category:Z61m]]</div>Ciclohttps://www.thinkwiki.org/w/index.php?title=HDAPS&diff=37347HDAPS2008-04-17T10:09:48Z<p>Ciclo: </p>
<hr />
<div>{| width="100%"<br />
|style="vertical-align:top;padding-right:20px;width:10px;white-space:nowrap;" | __TOC__<br />
|style="vertical-align:top" |<br />
=== HDAPS - IBM Active Protection System Linux Driver ===<br />
This is the Linux driver for monitoring the accelerometer known as [[Active Protection System|IBM Active Protection System]].<br />
<br />
The driver only enables reading of the acceleration data. It does '''not''' perform [[#Harddisk Protection|automatic disk head parking]]. But there are already some other useful [[#Applications|applications]] for HDAPS, using the {{path|/sys}} interface it provides.<br />
<br />
{{WARN|There are two versions of the hdaps driver, one in the Linux kernel mainline, and another provided by [[tp_smapi]]. '''Use of the tp_smapi version of hdaps is strongly recommended by the current hdaps developers.'''}}<br />
|}<br />
<br />
=== Features ===<br />
*provides accelerometer values via sysfs<br />
*provides a joystick type input device<br />
<br />
=== Project Homepage / Availability ===<br />
*[http://hdaps.sourceforge.net/ Project Homepage]<br />
*The driver is included in the 2.6-mm series of kernels since August, 26th 2005.<br />
*The driver is now in the mainline (2.6.14).<br />
*The [[tp_smapi]] package contains some patches to this driver. These are necessary for some recent models, and recommended for all.<br />
<br />
=== Status ===<br />
A driver is included in recent Linux kernels and is actively maintained, but it is very inferior to the driver in tp_smapi (which provides its own hdaps module).<br />
<br />
=== How to install the driver ===<br />
Recent Linux kernels include the <tt>hdaps</tt> driver. However, the driver in the mainline Linux kernel has two problems with recent models:<br />
* It doesn't whitelist them (you have to edit hdaps_init() in drivers/hwmon/hdaps.c to include a line like <tt>HDAPS_DMI_MATCH_LENOVO("ThinkPad T60")</tt>)<br />
* It doesn't work reliably, e.g., it may read out constant values (0,0). See [http://sourceforge.net/mailarchive/message.php?msg_id=15350314 here].<br />
<br />
To solve both problems, install the modified hdaps that is bundled with [[tp_smapi]].<br />
<br />
=== Harddisk Protection ===<br />
As mentioned above, the hdaps kernel driver is only responsible for reading the accelerometer data and exporting it through the sysfs interface. In order to use this information to protect the disk, some additional steps are required.<br />
<br />
See [[How to protect the harddisk through APS]].<br />
<br />
=== Input device support ===<br />
In more recent versions of the Linux kernel, the hdaps exports event devices with the accelerometer data. These devices can be used as-is by some programs (e.g. hdapsd), but for most they must be handled by the additional kernel module <code>joydev</code>.<br />
<br />
When both modules are loaded, joydev will provide standard joystick device emulation for hdaps (standard hdaps exports just one joystick device. enhanced hdaps from tp_smapi will export two due to issues still unsolved on joydev, but the second one must not be used as a joystick).<br />
<br />
{{WARN|Letting a program bind to these joystick devices can cause surprising results if you are not aware of it. e.g.: mplayer can act quite strangely. Also, letting a program bind to the second joystick device from enhanced HDAPS is guaranteed to be trouble}}<br />
<br />
Udev can be used to create device nodes in /dev for use by user space programs that access the joystick, and to set appropriate permissions.<br />
<br />
In order for non-root users to access these device files, their permissions must be tweaked a little through an appropriate udev rule and corresponding "joy" group.<br />
<br />
{{cmdroot|addgroup joy}}<br><br />
{{cmdroot|adduser <you> joy}}<br><br />
<code># echo 'SUBSYSTEM=="input", KERNEL=="js*", MODE="0660", GROUP="joy"' >> /etc/udev/hdaps-joy.rules</code><br><br />
{{cmdroot|ln -s ../hdaps-joy.rules /etc/udev/rules.d/z60_hdaps-joy.rules}}<br><br />
<br />
Programs you can use to test and calibrate the device files include <code>jscalibrator</code> (gui) and <code>jstest</code>/<code>jscal</code> (cli) packaged together (at least in Debian) simply as "joystick".<br />
<br />
=== Applications ===<br />
====Disk head parking====<br />
You will need the kernel patch below and the hdapsd userspace daemon. The GUI monitoring is optional.<br />
<br />
See [[How to protect the harddisk through APS]] for more information.<br />
<br />
===== Kernel patch =====<br />
Due to significant changes in the way the libata module which handles disk i/o, applying any of the currently available patches to kernel 2.6.24 will intermittently cause system hangs when the queue is frozen (i.e., the heads are parked). It is recommended either that you stay at kernel [http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.17.tar.bz2 2.6.23] or do without disk protection in 2.6.24 until the kinks have been worked out. There has been significant work on the part of [http://lkml.org/lkml/2008/2/25/478 Elias Oltmanns], author of the more recent patches, to get this worked out and eventually get shock protection built into the mainline kernel.<br />
<br />
Below are some links to patches for various Linux kernel versions. As noted above, your mileage may vary with the 2.6.24-rc3 patch as it was after this release candidate that things stopped working nicely. <br />
{{HINT|To apply a patch, change to the root directory of the kernel tree and run<br><code>patch -p1 -l < hdaps_xx.patch</code>}}<br />
* New interface<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1245 disk-protect patch for kernel 2.6.25-rc9] &mdash; may cause system locks (same as patch for 2.6.24-rc3). Apply [http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/2008-February/042226.html this fix] before.<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1094 disk-protect patch for kernel 2.6.24-rc3] &mdash; may cause system locks (see [http://marc.info/?l=linux-thinkpad&m=120259594519907 here], [http://marc.info/?l=linux-thinkpad&m=120259929023300 here] and try [http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/2008-February/042226.html this fix])<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1092 disk-protect patch for 2.6.23.8] + [http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1113 error check fix]<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1077 disk-protect patch for 2.6.22.9 and 2.6.23-rc9]<br />
**[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/993 disk-protect patch for 2.6.20-rc6]<br />
* Old interface<br />
**[http://www.nabble.com/attachment/9047418/0/hdaps_protect-2.6.20.patch.bz2 Latest sata/ide disk protection patch for 2.6.20]<br />
**[http://article.gmane.org/gmane.linux.kernel/470413 Latest sata/ide disk protection patch for 2.6.19-rc6]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect-2.6.18.3-2.patch Latest sata/ide disk protection patch for 2.6.18.3]<br />
**[http://exitzero.de/t41p-configs/hdaps_protect-2.6.17.1-20060625.patch Untested patch for 2.6.17.1]: see [http://thread.gmane.org/gmane.linux.drivers.hdaps.devel/708/focus=708]<br />
**[http://whoopie.gmxhome.de/linux/patches/2.6.17.14-tj/03-hdaps_protect-20060430-for-2.6.17-tj.patch Latest sata/ide disk protection patch for use with the libata hotplug 2.6.17.4 patches] - See [[How_to_hotswap_UltraBay_devices]]<br />
**[http://whoopie.gmxhome.de/linux/patches/2.6.16-tj/05-hdaps_protect-20060430-for-2.6.16-tj.patch Latest sata/ide disk protection patch for use with the libata hotplug 2.6.16.16 patches] - See [[How_to_hotswap_UltraBay_devices]]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect.20060430.patch Latest sata/ide disk protection patch for 2.6.16]<br />
**[http://www.dresco.co.uk/hdaps/hdaps_protect.20060118.patch sata/ide disk protection patch for 2.6.15]<br />
**[http://jenster.dyndns.org/files/blk_freeze-01-nodetection-for-2.6.15.patch disk park patch adapted for the t41p model] <tt> kernel 2.6.15 ([http://sourceforge.net/mailarchive/message.php?msg_id=13214288 capability detection disabled], no libata support)</tt><br />
**[http://jenster.dyndns.org/files/blk_freeze-01-nodetection-for-2.6.14.patch disk park patch adapted for the t41p model] <tt> kernel 2.6.14 ([http://sourceforge.net/mailarchive/message.php?msg_id=13214288 capability detection disabled], no libata support)</tt><br />
**[http://lwn.net/Articles/154923/ disk park patch] <tt>an experimental patch for parking the disk (Linux 2.6.14 for 2.6.15 see below)</tt><br />
<br />
===== Userspace daemon =====<br />
*[http://www.dresco.co.uk/hdaps/hdapsd-20070524.c Recommended version]<br />
*[http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1045 Reduced power version] - reduces timer interrupts, as measured by [[PowerTOP]]. This leads to lower power consumption on [[tickless kernel|tickless kernels]]. Interrupt reduction requires the <tt>hdaps</tt> kernel module from [[tp_smapi]] 0.32 or newer, and a [http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1040 udev rule].<br />
*[ftp://rohrmoser-engineering.de/pub Modified adaptive algorithm version] - uses a different (and potentially better) algorithm for the adaptive sensivity threshold.<br />
<br />
===== GUI monitoring =====<br />
*[http://roy.marples.name/node/269 khdapmonitor] KDE System Tray Monitor<br />
*[http://www.dresco.co.uk/hdaps/gnome-hdaps-applet-20060120.tar.gz gnome-hdaps-applet] visual display of disk protection status in gnome panel<br />
<br />
====Security & safety====<br />
*[[Script for theft alarm using HDAPS]]<br />
<br />
====Tilt monitoring====<br />
*[http://www.mulliner.org/collin/gkibm-acpi.php gkhdaps] <tt>a GKrellM applet displaying tilt data</tt><br />
*[http://rlove.org/log/2005082203.html gnome-tilt] <tt>a gnome applet showing tilt data</tt><br />
<br />
====Visualisation of ThinkPad orientation====<br />
*[http://rlove.org/log/2005082401.html hdaps-gl] <tt>a little app animating a 3D-ThinkPad</tt><br />
*[https://sourceforge.net/project/showfiles.php?group_id=138242 hdapsgl-applet] <tt> a GNOME applet animating a 3D-ThinkPad</tt><br />
*[https://sourceforge.net/project/showfiles.php?group_id=138242 wmadhps] <tt>a WindowMaker DockApp animating a 3D-ThinkPad</tt><br />
*[http://www.cs.cmu.edu/~ecc/gyro.tar.gz OpenGL gyroscope hack] <tt>keeps your display levelled when tilting the ThinkPad</tt> (warning: [http://en.wikipedia.org/wiki/Tarbomb uncompresses in the current directory]!)<br />
<br />
====Games====<br />
*[http://icculus.org/neverball/ Neverball] is quite fun with HDAPS. (You'll need to have the HDAPS joystick device)<br />
*Turn your ThinkPad into a Jedi Weapon (hey, it [http://isnoop.net/blog/2006/05/20/macsaber-turn-your-mac-into-a-jedi-weapon works for Mac laptops])<br />
<br />
====Other====<br />
<br />
*[http://blog.micampe.it/articles/2006/06/04/here-comes-the-smackpad smack.py] - switch workspace by smacking your laptop, inspired by the [http://blog.medallia.com/2006/05/smacbook_pro.html SmackBook] (uses EWMH)<br />
**an [http://weblogs.mozillazine.org/gerv/archives/2006/09/stablilised_smackpad.html improved version] adds stabilization (by comparing smacks to previous ones, uses EWMH)<br />
**another [http://pberndt.com/Programme/Linux/pyhdaps/index.html approach] adds stabilization (by requiring a certain type of value deflection, uses xmacroplay)<br />
**[http://www.gnome.org/~fherrera/gtollina.c GTollina] is another smack program for use with compiz (video [http://www.gnome.org/~fherrera/blog/gtollina.html here]).<br />
*[http://blog.odonnell.nu/61.html xmms-smack.py] - move through your xmms playlist by smacking, based on the two smack scripts above.<br />
*[http://www-128.ibm.com/developerworks/linux/library/l-knockage.html?ca=dgr-lnxw02aKnockBasedCommands KnockBasedCommands] - Execute commands by tapping your laptop.<br />
*[http://people.ksp.sk/~mic/?menu=32&file=rotate.py rotate.py] - rotate desktop by turning your laptop<br />
<br />
=== Interesting links related to this project ===<br />
* [https://lists.sourceforge.net/lists/listinfo/hdaps-devel HDAPS mailinglist and its archive]<br />
* #hdaps channel on irc.freenode.org<br />
* [https://sourceforge.net/projects/hdaps/ hdaps projects] overview of userspace programs using hdaps<br />
* [http://www-307.ibm.com/pc/support/site.wss/document.do?lndocid=TPAD-HDFIRM IBM ThinkPads hardware drive firmware site]<br />
* [http://www.paul.sladen.org/thinkpad-r31/accelerometer.html http://www.paul.sladen.org/thinkpad-r31/accelerometer/]<br />
* http://bugs.gentoo.org/show_bug.cgi?id=119845 Gentoo ebuild for hdaps driver and daemon including a initscript*<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137345 Gentoo ebuild for gkhdaps gkrell plugin<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137350 Gentoo ebuild for hdaps-gl application<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137351 Gentoo ebuild for gnome hdapsgl-applet<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137352 Gentoo ebuild for gnome tilt application<br />
* http://bugs.gentoo.org/show_bug.cgi?id=137353 Gentoo ebuild for wmhdaps<br />
* [http://lenovoblogs.com/insidethebox/?p=71 Why the ThinkPad accelerometer is only 2D] - explanation by Lenovo<br />
<br />
[[Category:R50]] [[Category:R50p]] [[Category:R51]] [[Category:R52]] [[Category:R60]] [[Category:T41]] [[Category:T41p]] [[Category:T42]] [[Category:T42p]] [[Category:T43]] [[Category:T43p]] [[Category:T60]] [[Category:T60p]] [[Category:T61]] [[Category:X40]] [[Category:X41]] [[Category:X41 Tablet]] [[Category:X60]] [[Category:X60s]] [[Category:Z60m]] [[Category:Z60t]] [[Category:Drivers]] [[Category:Z61m]]</div>Ciclo