https://www.thinkwiki.org/w/api.php?action=feedcontributions&user=Husky69&feedformat=atomThinkWiki - User contributions [en]2024-03-29T00:54:59ZUser contributionsMediaWiki 1.31.12https://www.thinkwiki.org/w/index.php?title=How_to_enable_the_integrated_fingerprint_reader_with_ThinkFinger&diff=36755How to enable the integrated fingerprint reader with ThinkFinger2008-03-01T21:29:50Z<p>Husky69: Added Warning about fingerprint reader security</p>
<hr />
<div>[[How to enable the fingerprint reader]] has a good explanation for using the fingerprint reader with the closed-source binary driver. But there is also an opensource project called [http://thinkfinger.sourceforge.net ThinkFinger] which does the same, but open.<br />
<br />
However: The fingerprint reader is an INSECURE device and gives a false sense of security! There has been quite a bit of research by a hacker named Starbug, a member of the Chaos Computer Club, Berlin, Germany. He outlined in two very good talks how to forge each and every available fingerprint sensor available at the cost of a few euros, using materials from your local hardware store, a digicam and a laser printer! Here's some links:<br />
* [http://www.ccc.de/updates/2007/umsonst-im-supermarkt?language=en Fingerprint recognition in supermarkets]<br />
* [ftp://ftp.ccc.de/pub/video/Fingerabdruck_Hack/fingerabdruck.mpg?language=en Video tutorial for forging fingerprints]<br />
<br />
<br />
== Installing ==<br />
=== From source ===<br />
<br />
Download thinkfinger-0.3.tar.gz from the [http://thinkfinger.sourceforge.net/ homepage] and unpack it somewhere, make sure you have the gcc compiler, libtool, pkg-config, libusb-dev and libpam0g-dev installed, then:<br />
<br />
{{cmduser|cd thinkfinger-0.3}}<br />
<br />
<code style="white-space:nowrap;color:#495988;background-color:white;"><nowiki>$</nowiki> ./configure --prefix=/usr --sysconfdir=/etc --with-securedir=/lib/security --with-birdir=/etc/pam_thinkfinger</code><br />
<br />
{{cmduser|make}}<br />
<br />
{{cmdroot|make install}}<br />
<br />
{{NOTE|/lib/security is the directory, where PAM assumes its modules on Debian and openSUSE, it may vary for your distro!}}<br />
<br />
"make install" doesn't create the birdir we specified (where thinkfinger will store users' biometric info), so create it:<br />
<br />
{{cmdroot|mkdir /etc/pam_thinkfinger}}<br />
<br />
If everything went OK assert that you find pam_thinkfinger.so in /lib/security typing:<br />
<br />
{{cmduser|ls /lib/security}}<br />
<br />
=== From package ===<br />
<br />
==== Debian ====<br />
[http://packages.debian.org/source/experimental/thinkfinger Packages] arrived in Debian experimental on Aug 2nd, 2007 (cf. [http://bugs.debian.org/409563 bug #409563]). To access the experimental packages via apt, add the following lines to your sources.list:<br />
<pre><br />
# experimental<br />
deb ftp://mirrors.kernel.org/debian/ experimental main contrib non-free<br />
deb-src ftp://mirrors.kernel.org/debian/ experimental main contrib non-free<br />
</pre><br />
where of course you may replace mirrors.kernel.org with your mirror of choice. Just make sure that it hosts the experimental repositories.<br />
<pre><br />
aptitude update <br />
aptitude install libthinkfinger0 libpam-thinkfinger thinkfinger-tools<br />
</pre><br />
should then get you up and running.<br />
<br />
==== Ubuntu ====<br />
From https://wiki.ubuntu.com/ThinkFinger<br />
<br />
Add PPA repositories to your sources.list:<br />
<pre><br />
deb http://ppa.launchpad.net/jldugger/ubuntu gutsy main restricted universe multiverse<br />
deb-src http://ppa.launchpad.net/jldugger/ubuntu gutsy main restricted universe multiverse<br />
</pre><br />
<br />
Install necessary packages:<br />
<pre><br />
sudo apt-get install thinkfinger-tools libpam-thinkfinger <br />
</pre><br />
<br />
==== Fedora/Fedora Core ====<br />
*Packages for Fedora Core 6 are available in "extras" repository (# yum install thinkfinger).<br />
*Packages for Fedora 7 are available in the "updates" repository (# yum install thinkfinger).<br />
<br />
==== Gentoo ====<br />
<pre><br />
emerge sys-auth/thinkfinger<br />
</pre><br />
<br />
==== OpenSUSE ====<br />
openSUSE 10.2 includes the package "libthinkfinger" (version 0.1-7) - you will find newer packages [http://beta1.suse.com/private/thoenig/10.2/thinkfinger/ here].<br />
<br />
== Testing the driver ==<br />
<br />
Now the driver is installed and should be working. You can try it (as root) with<br />
<br />
{{cmdroot|tf-tool --acquire}}<br />
<br />
and<br />
<br />
{{cmdroot|tf-tool --verify}}<br />
<br />
This will ask you to swipe your finger three times, save the fingerprint to /tmp/test.bir and then verify your fingerprint with the bir-file.<br />
<br />
<br />
<br />
== Configuring PAM to use ThinkFinger ==<br />
Now you can configure PAM to use ThinkFinger:<br />
<br />
Open {{path|/etc/pam.d/common-auth}} (In FC6, F7, and Gentoo, this file is {{path|/etc/pam.d/system-auth}}):<br />
<br />
{{cmdroot|nano -w /etc/pam.d/common-auth}}<br />
<br />
Add this line before any pam_unix or pam_unix2 directives:<br />
auth sufficient pam_thinkfinger.so<br />
<br />
If your PAM uses the pam_unix and not the pam_unix2 module, you need to pass a specific argument in<br />
the /etc/pam.d/common-auth directive to make it consider the password entered at the pam_thinkfinger prompt.<br />
auth required pam_unix.so try_first_pass<br />
<br />
For instance, {{path|/etc/pam.d/common-auth}} looks like this:<br />
auth sufficient pam_thinkfinger.so<br />
auth required pam_unix.so nullok_secure try_first_pass<br />
<br />
On openSUSE 10.2, it looks like this now:<br />
auth required pam_env.so<br />
auth sufficient pam_thinkfinger.so<br />
auth required pam_unix2.so<br />
<br />
Now we are ready to add users to thinkfinger. You can add a fingerprint for a user with:<br />
<br />
{{cmdroot|tf-tool --add-user $USERNAME}}<br />
<br />
Now the user should be able to login with his finger instead of the password.<br />
<br />
If you would like to use thinkfinger for su, you have to enroll the fingerprint for root user with:<br />
<br />
{{cmdroot|tf-tool --add-user root}}<br />
<br />
{{NOTE|You should see the "Password or swipe finger:" prompt when trying to sudo or su. If you don't, you probably do not have the "User level driver support" compiled into your kernel or the "uinput" module loaded!}}<br />
<br />
== xscreensaver/gnome-screensaver ==<br />
{{NOTE|In Fedora 7, the package has been modified in such a way as to make doing this unnecessary.}}<br />
<br />
If you'd like to be able to unlock your screen using the fingerprint reader, you must have current versions of xscreesaver (>~5.03) or gnome-screensaver (>~2.18.2). Then you must give yourself access to the fingerprint reader and your bir-file, because unlike login/gdm/su/sudo, both gnome-screensaver and xscreensaver do not run as root. The following procedure will make the fingerprint reader accessible to members of the "fingerprint" group.<br />
<br />
Make the group: {{cmdroot|groupadd fingerprint}}<br />
<br />
Save the following as {{path|/etc/udev/rules.d/60-thinkfinger.rules}} (you may need to reboot for this to take effect):<br />
#<br />
# udev rules file for the thinkfinger fingerprint scanner<br />
# <br />
# gives access to the fingerprint reader to those in the "fingerprint" group<br />
#<br />
# Taken from:<br />
# http://www.thinkwiki.org/wiki/How_to_enable_the_fingerprint_reader_with_ThinkFinger<br />
# which was taken and modified from:<br />
# http://article.gmane.org/gmane.linux.drivers.thinkfinger/329<br />
#<br />
<br />
# SGS Thomson Microelectronics Fingerprint Reader<br />
SYSFS{idVendor}=="0483", SYSFS{idProduct}=="2016", SYMLINK+="input/thinkfinger-%k", MODE="0660", GROUP="fingerprint"<br />
<br />
# the also-needed uinput device<br />
KERNEL=="uinput", MODE="0660", GROUP="fingerprint"<br />
<br />
<br />
Finally, edit {{path|/etc/pam.d/gnome-screensaver}} so that it looks like this:<br />
auth sufficient pam_thinkfinger.so<br />
auth required pam_unix.so try_first_pass nullok_secure<br />
<br />
<br />
Per user:<br />
<br />
# Add him to the group: {{cmdroot|gpasswd -a $USERNAME fingerprint}}<br />
# Make him owner of his bir-file: {{cmdroot|chown $USERNAME:root /etc/pam_thinkfinger/$USERNAME.bir}}<br />
# Give him read-only access to his bir-file: {{cmdroot|chmod 400 /etc/pam_thinkfinger/$USERNAME.bir}}<br />
# Give "execute only" access to everyone for the /etc/pam_thinkfinger/ directory: {{cmdroot|chmod o+x /etc/pam_thinkfinger}} (WARNING: this opens up security a little).<br />
<br />
== GNOME ==<br />
<br />
gksu/gksudo doesn't work correctly. It just stays invisible. When starting a su privileged application such as synaptics you will not get prompted for the password. Nevertheless you can swipe your finger and it should authenticate you. Starting synaptics twice makes gksudo visible.<br />
<br />
There are two possibilities to solve it:<br />
* Changing the string "Password or swipe finger:" to a plain "Password:" (like sudo normally would do) in the file pam/pam_thinkfinger.c of the thinkfinger source directory. Of course, in the console you will then only see a "Password:" instead of "Password or swipe finger:" but this is still more usefull than having gksu/gksudo crashing everytime.<br />
* Patching libgksu with the following patch. This is also a nasty hack until a better solution is implemented.<br />
<pre><br />
--- libgksu-2.0.3/libgksu/libgksu.c.orig 2007-06-17 16:00:24.000000000 +0200<br />
+++ libgksu-2.0.3/libgksu/libgksu.c 2007-06-17 16:00:47.000000000 +0200<br />
@@ -2663,7 +2663,7 @@<br />
*/<br />
for (counter = 0; counter < 50; counter++)<br />
{<br />
- if (strncmp (buffer, "GNOME_SUDO_PASS", 15) == 0)<br />
+ if (strncmp (buffer, "GNOME_SUDO_PASS", 15) == 0 || strncmp (buffer, "Password or swi", 15) == 0)<br />
break;<br />
<br />
read_line (parent_pipe[0], buffer, 256);<br />
@@ -2675,7 +2675,7 @@<br />
if (context->debug)<br />
fprintf (stderr, "brute force GNOME_SUDO_PASS ended...\n");<br />
<br />
- if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0)<br />
+ if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0 || strncmp(buffer, "Password or swi", 15) == 0)<br />
{<br />
gchar *password = NULL;<br />
gboolean prompt_grab;<br />
</pre><br />
<br />
== KDE ==<br />
<br />
Integration in KDE and kdm seems not to be easily possible now. There is a filed [https://bugs.kde.org/show_bug.cgi?id=116682 bug] at kde.org where you can vote for this.<br />
<br />
Moreover, kdm in openSUSE 10.3 crashes when pam_thinkfinger is enabled. A possible "workaround" is downgrading to thinkfinger 0.2.2.<br />
<br />
<br />
This Howto was copied from [[Installing Ubuntu 6.06 on a ThinkPad T43#Fingerprint_Reader]] and then slightly modified.</div>Husky69https://www.thinkwiki.org/w/index.php?title=Integrated_Fingerprint_Reader&diff=36754Integrated Fingerprint Reader2008-03-01T21:26:58Z<p>Husky69: /* Integrated Fingerprint Reader */ Added warning about fingerprint reader security</p>
<hr />
<div>{| width="100%"<br />
|style="vertical-align:top;padding-right:20px;width:10px;" | [[Image:fingerprintreader.jpg|IBM Integrated Fingerprint Reader]] __NOTOC__<br />
|style="vertical-align:top" |<br />
<div style="margin: 0; margin-right:10px; border: 1px solid #dfdfdf; padding: 0em 1em 1em 1em; background-color:#F8F8FF; align:right;"><br />
===Integrated Fingerprint Reader===<br />
IBM released a second generation of T42 models in Autumn 2004 featuring Intel Pentium M 765 processors and an integrated fingerprint reader.<br />
<br />
The fingerprint reader is produced by a company called UPEK, which specializes in the manufacture of fingerprint readers. It is integrated as an USB device, and does all the matching in hardware, making it rather easy to use. Furthermore, IBM states that there's an interface with the [[Embedded Security Subsystem]]. UPEK now sells the fingerprint reader as a USB peripheral bundled with the same underlying software for accessing password-protected online accounts and Windows: [http://www.upek.com/solutions/eikon Eikon Digital Privacy Manager]<br />
<br />
However: The fingerprint reader is an INSECURE device and gives a false sense of security! There has been quite a bit of research by a hacker named Starbug, a member of the Chaos Computer Club, Berlin, Germany. He outlined in two very good talks how to forge each and every available fingerprint sensor available at the cost of a few euros, using materials from your local hardware store, a digicam and a laser printer! Here's some links:<br />
* [http://www.ccc.de/updates/2007/umsonst-im-supermarkt?language=en Fingerprint recognition in supermarkets]<br />
* [ftp://ftp.ccc.de/pub/video/Fingerabdruck_Hack/fingerabdruck.mpg?language=en Video tutorial for forging fingerprints]<br />
<br />
==Open Source==<br />
<br />
There is a new GPL driver at http://thinkfinger.sourceforge.net; see the [[How to enable the fingerprint reader with ThinkFinger]] for detailed instructions. This is the recommended option as it integrates more seamlessly with PAM and doesn't produce a tacky graphical prompt.<br />
<br />
==Binary Only==<br />
A closed source driver from the vendor has been released. It interfaces to the hardware as a user-space USB driver through {{path|/proc/bus/usb|}} and provides a BioAPI 1.10 device, which can then be interfaced to pam for authentication by user programs. The driver can be downloaded from http://www.upek.com/support/dl_linux_bsp.asp; see the [[How to enable the fingerprint reader|corresponding HOWTO]] for detailed instructions. It however tends to be less stable than the above opensource driver.<br />
<br />
==Related Links==<br />
* [http://www.trustedreviews.com/article.aspx?page=1643&head=36 Review from TrustedReviews of the fingerprint scanner]<br />
* [http://biomark.org.ru/en/ A (Russian) project that provides support for a (different model) of fingerprint scanner] (also a USB device, though)<br />
* [http://www.upek.com/support/pdf/UPEK_flyer_TCS3_TCD4.pdf TouchStrip TCS3/TCD4 spec sheet]<br />
* [http://www.qrivy.net/~michael/blua/ A branch of the BioAPI reference implementation]<br />
<br />
==Models featuring this Technology==<br />
*ThinkPad {{R52}}, {{R60}}<br />
*ThinkPad {{T42}}, {{T42p}}, {{T43}}, {{T43p}}, {{T60}}, {{T60p}}, {{T61}}, {{T61p}}<br />
*ThinkPad {{X41}}, {{X41T}}, {{X60}}, {{X60s}}, {{X61s}}, {{X61_Tablet}}<br />
*ThinkPad {{Z60m}}, {{Z60t}}, {{Z61m}}, {{Z61p}}, {{Z61t}}<br />
<br />
<br />
[[Category:Glossary]]</div>Husky69https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&diff=35115Sample Fn-F7 script2007-12-11T21:40:11Z<p>Husky69: /* The bash script */ adjust regexp to correctly report display number</p>
<hr />
<div>This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens. This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.<br />
<br />
Works like a charm on X61s with Xubuntu 7.10.<br />
Working with R60e with some modifications noted below.<br />
<br />
==configuring the virtual screen size==<br />
Add a "Virtual" statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):<br />
<br />
Section "Screen"<br />
Identifier "Screen0"<br />
Device "Videocard0"<br />
DefaultDepth 24<br />
SubSection "Display"<br />
Viewport 0 0<br />
Depth 24<br />
<b>Virtual 2624 1200</b><br />
EndSubSection<br />
EndSection<br />
<br />
Restart X server at this point (i.e. logout and login).<br />
<br />
== configuring acpi ==<br />
Create /etc/acpi/events/thinkpad.conf:<br />
<br />
event=ibm/hotkey HKEY 00000080 00001007<br />
action=/usr/local/sbin/thinkpad-fn-f7<br />
<br />
or you may (eg Ubuntu 7.10) already have /etc/acpi/events/ibm-videobtn<br />
# /etc/acpi/events/ibm-videobtn<br />
# This is called when the user presses the video button. It is currently<br />
# a placeholder.<br />
event=ibm/hotkey HKEY 00000080 00001007<br />
action=/bin/true<br />
<br />
in which case modify the line 'action=/bin/true' to run the script as above.<br />
<br />
It may also be necessary to enable acpi events as per [[How to get special keys to work]] with (in root terminal)<br />
{{cmdroot|echo enable,0x084e > /proc/acpi/ibm/hotkey}}<br />
Note this command isn't persistent. so you will also need to add the line to /etc/rc.local to enable hotkeys at boot, and to re-enable the hotkeys after suspend to disk or RAM, create the file<br />
/etc/acpi/resume.d/91-ibm-hotkey-enable.sh consisting of<br />
<br />
#!/bin/bash<br />
# enable ibm-hotkeys (specifically Fn2, Fn7)<br />
# 12 bit mask, little end is F1 default 0x080c = F12+F4+F3<br />
echo enable,0x084e > /proc/acpi/ibm/hotkey<br />
<br />
<br />
ref: [[http://tilmanfrosch.de/wp/index.php/2007/05/05/howto-make-a-ubuntu-linux-on-an-ibm-t41-thinkpad-work-with-an-external-widescreen-wxga-display/ frosch.org.uk]] and [[http://ibm-acpi.sourceforge.net/README ibm-acpi.sourceforge]]<br />
<br />
==identify output devices==<br />
Note the names of your output devices as you will have to change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:<br />
<br />
$ xrandr -q<br />
'''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm<br />
...<br />
'''LVDS''' connected (normal left inverted right x axis y axis)<br />
<br />
==The bash script==<br />
Create /usr/local/sbin/thinkpad-fn-f7, you can set EXTERNAL_LOCATION to one of: left, right, above, or below.<br />
<br />
#!/bin/bash<br />
<br />
# External output may be "VGA" or "VGA-0" or "DVI-0"<br />
EXTERNAL_OUTPUT="'''VGA'''"<br />
INTERNAL_OUTPUT="'''LVDS'''"<br />
EXTERNAL_LOCATION="'''left'''"<br />
<br />
# Figure out which user and X11 display to work on<br />
# TODO there has to be a better way to do this?<br />
X_USER=$(w -h -s | grep ":[0-9]" | head -1 | awk '{print $1}')<br />
export DISPLAY=$(w -h -s | grep ":[0-9]" | head -1 | awk '{print $2}')<br />
<br />
# Switch to X user if necessary<br />
if [ "$X_USER" != "$USER" ]; then<br />
SU="su $X_USER -c"<br />
fi<br />
<br />
case "$EXTERNAL_LOCATION" in<br />
left|LEFT)<br />
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"<br />
;;<br />
right|RIGHT)<br />
EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"<br />
;;<br />
top|TOP|above|ABOVE)<br />
EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"<br />
;;<br />
bottom|BOTTOM|below|BELOW)<br />
EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"<br />
;;<br />
*)<br />
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"<br />
;;<br />
esac<br />
<br />
# Figure out current state<br />
INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")<br />
EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")<br />
<br />
if [ -z "$INTERNAL_STATE" ]; then<br />
STATE="external"<br />
elif [ -z "$EXTERNAL_STATE" ]; then<br />
STATE="internal"<br />
else<br />
INTERNAL_STATE=$(echo $INTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")<br />
EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")<br />
if [ "$INTERNAL_STATE" = "$EXTERNAL_STATE" ]; then<br />
STATE="mirror"<br />
else<br />
STATE="both"<br />
fi<br />
fi<br />
<br />
function screen_external(){<br />
$SU "xrandr --output $INTERNAL_OUTPUT --off"<br />
$SU "xrandr --output $EXTERNAL_OUTPUT --auto"<br />
}<br />
<br />
function screen_internal(){<br />
$SU "xrandr --output $EXTERNAL_OUTPUT --off"<br />
$SU "xrandr --output $INTERNAL_OUTPUT --auto"<br />
}<br />
<br />
function screen_mirror(){<br />
$SU "xrandr --output $INTERNAL_OUTPUT --auto"<br />
$SU "xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT"<br />
}<br />
<br />
function screen_both(){<br />
$SU "xrandr --output $INTERNAL_OUTPUT --auto"<br />
$SU "xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION"<br />
}<br />
<br />
function screen_toggle(){<br />
case "$STATE" in<br />
internal)<br />
screen_mirror<br />
;;<br />
mirror)<br />
screen_external<br />
;;<br />
external)<br />
screen_both<br />
;;<br />
both)<br />
screen_internal<br />
;;<br />
*)<br />
screen_internal<br />
;;<br />
esac<br />
}<br />
<br />
# What should we do?<br />
DO="$1"<br />
if [ -z "$DO" ]; then<br />
if [ $(basename $0) = "thinkpad-fn-f7" ]; then<br />
DO="toggle"<br />
fi<br />
fi<br />
<br />
case "$DO" in<br />
toggle)<br />
screen_toggle<br />
;;<br />
internal)<br />
screen_internal<br />
;;<br />
external)<br />
screen_external<br />
;;<br />
mirror)<br />
screen_mirror<br />
;;<br />
both)<br />
screen_both<br />
;;<br />
status)<br />
echo "Current Fn-F7 state is: $STATE"<br />
echo<br />
echo "Attached monitors:"<br />
$SU xrandr | grep "\Wconnected" | sed "s/^/ /"<br />
;;<br />
*)<br />
echo "usage: $0 <command>" >&2<br />
echo >&2<br />
echo " commands:" >&2<br />
echo " status" >&2<br />
echo " internal" >&2<br />
echo " external" >&2<br />
echo " mirror" >&2<br />
echo " both" >&2<br />
echo " toggle" >&2<br />
echo >&2<br />
;;<br />
esac<br />
<br />
== set permissions and restart acpi ==<br />
As root, or using sudo run the following commands,<br />
<br />
{{cmduser|sudo chmod 755 /usr/local/sbin/thinkpad-fn-f7}}<br />
{{cmduser|sudo service acpid restart}}<br />
OR<br />
{{cmduser|sudo /etc/init.d/acpid restart}}<br />
<br />
You should be ready to go, just press Fn-F7 to try.<br />
<br />
==Alternative script using .Xauthority rather than su ==<br />
Use this script as an alternative <br />
action=/usr/local/sbin/toggle-display.sh<br />
for /etc/acpi/events/ibm-videobtn<br />
<br />
#!/bin/bash<br />
# usr/local/sbin/toggle-display.sh <br />
# based on /etc/acpi/screenblank.sh (Ubuntu 7.10)<br />
#<br />
# . /usr/share/acpi-support/power-funcs # for getXuser<br />
umask 022;<br />
PATH="$PATH:/usr/bin/X11"<br />
getXuser() {<br />
user=`finger| grep -m1 ":$displaynum " | awk '{print $1}'`<br />
if [ x"$user" = x"" ]; then<br />
user=`finger| grep -m1 ":$displaynum" | awk '{print $1}'`<br />
fi<br />
if [ x"$user" != x"" ]; then<br />
userhome=`getent passwd $user | cut -d: -f6`<br />
export XAUTHORITY=$userhome/.Xauthority<br />
else<br />
export XAUTHORITY=""<br />
fi<br />
}<br />
# end of getXuser from /usr/share/acpi-support/power-funcs<br />
#<br />
for x in /tmp/.X11-unix/*; do<br />
displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`<br />
getXuser;<br />
if [ x"$XAUTHORITY" != x"" ]; then<br />
export DISPLAY=":$displaynum"<br />
## . /usr/share/acpi-support/screenblank.sh<br />
/usr/local/bin/toggle.py<br />
fi<br />
done<br />
<br />
Each user has an ~/.Xauthority file with one line for each X display containing a 'magic cookie' (Run {{cmduser| xauth list}} to see the contents). The Xserver reads the record in ~/.Xauthority matching its display. When an X client application starts it also looks for that record and passes the magic cookie to the server. If it matches, the connection to the Xserver is allowed. The above example runs the python script below but could run a modified version of /usr/local/sbin/thinkpad-fn-f7 without the USER, and DISPLAY detection SU commands.<br />
<br />
== A Python Toggle script ==<br />
This is a somewhat over-elaborate script which could be cut down when run by the /usr/local/sbin/toggle-display.sh script above. It was written to explore all the possibilities rather than economy of execution. The functions 'toggle_full', 'position', 'toggle_limited' and the OptionParser in 'main' may be omitted with suitable changes to function7. The appropriate outputs can be specified on the command line and it is not necessary to call it via acpi.<br />
eg you can run it as {{cmduser|/usr/local/bin/toggle.py --help}}<br />
<br />
#! /usr/bin/python<br />
# -*- coding: utf-8 -*-<br />
#<br />
# stinkpad(a)blueyonder.co.uk 2007-11-26<br />
"""Toggle internal and external displays (equivalent to ThinkPad Fn7)<br />
Simple; cloned: on+off, on+on, off+on. <br />
Full; as simple plus xinerama: right, below, left, above. <br />
Limited; as full but display will overlap if virtual screen is too small. <br />
Use 'xrandr -q' to determine output names. <br />
Further information: http://www.thinkwiki.org/wiki/Xorg_RandR_1.2 <br />
"""<br />
__usage__ = "usage: %prog [--help]|[[-i internal][-e external][-d displays]]"<br />
__version__ = "toggle [djclark.eu 2007-11-26]"<br />
#<br />
# Output names; Intel: LVDS VGA TV TMDS-1 TMDS-2<br />
# ATI: LVDS VGA-0 S-video DVI-0<br />
LAPTOP = 'LVDS' <br />
MONITOR = 'VGA'<br />
SEQUENCE = 'simple'<br />
#<br />
import sys<br />
import os<br />
import re<br />
<br />
# "LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm"<br />
REGEX_OUTPUT = re.compile(r"""<br />
(?x) # ignore whitespace<br />
^ # start of string<br />
(?P<output>[A-Za-z0-9\-]*)[ ] # LVDS VGA etc<br />
(?P<connect>(dis)?connected)[ ] # dis/connected<br />
(( # a group<br />
(?P<width>\d+)x # either 1024x768+0+0<br />
(?P<height>\d+)[+] <br />
(?P<horizontal>\d+)[+]<br />
(?P<vertical>\d+)<br />
)|[\D]) # or not a digit<br />
.* # ignore rest of line<br />
""")<br />
<br />
# "Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2624 x 1968"<br />
REGEX_SCREEN = re.compile(r"""<br />
(?x) # ignore whitespace<br />
^ # start of string<br />
Screen[ ] <br />
(?P<screen>\d)[: ]+<br />
minimum[ ]<br />
(?P<minWidth>\d+)[ x]+<br />
(?P<minHeight>\d+)[, ]+<br />
current[ ]+<br />
(?P<curWidth>\d+)[ x]+<br />
(?P<curHeight>\d+)[, ]+<br />
maximum[ ]+<br />
(?P<maxWidth>\d+)[ x]+<br />
(?P<maxHeight>\d+)<br />
""") <br />
<br />
def toggle_simple(d0, d1):<br />
"""Toggle display states: on+off, on+on, off+on"""<br />
if d1['connect'] == 'disconnected': # external unplugged<br />
return ('auto','off',"") # switch off external<br />
if d1['width'] is 0: # external off<br />
return ('auto','auto',"") # both on<br />
if d0['width'] is 0: # laptop off<br />
return ('auto','off',"") # laptop on<br />
return ('off','auto',"") # both on, laptop off<br />
<br />
def toggle_full(d0, d1):<br />
"""Toggle display states: 1+0, 1+1, 0+1, 1+E, 1+S, 1+W, 1+N""" <br />
if d1['connect'] == 'disconnected': # external unplugged<br />
return ('auto','off',"") # switch off external<br />
place = '--%s ' + d0['output']<br />
if d1['width'] == 0: # external off<br />
return ('auto','auto',place%'same-as') # external on<br />
if d0['width'] == 0: # laptop off<br />
return ('auto','off',"") # laptop on<br />
if d1['horizontal'] > 0: # external to right<br />
return ('auto','auto',place%'below') # make below<br />
if d1['vertical'] > 0: # external below<br />
return ('auto','auto',place%'left-of') # make left<br />
if d0['horizontal'] > 0: # external left<br />
return ('auto','auto',place%'above') # make above<br />
if d0['vertical'] > 0: # external above<br />
return ('off','auto',"") # laptop off<br />
return ('auto','auto',place%'right-of') # is same, make right<br />
<br />
def position(orientation, da, db, screen):<br />
"""Calculate offset position of second display"""<br />
p = 'auto --pos %sx%s'<br />
if orientation == 'V':<br />
if (da['height'] + db['height']) <= screen['maxHeight']:<br />
return p%(0, da['height'])<br />
return p%(0, screen['maxHeight'] - db['height'])<br />
else:<br />
if (da['width'] + db['width']) <= screen['maxWidth']:<br />
return p%(da['width'],0)<br />
return p%(screen['maxWidth'] - db['width'],0)<br />
<br />
def toggle_limited(d0, d1, sz):<br />
"""Toggle display states (overlapped): 1+0,1+1,0+1,1+E,1+S,1+W,1+N"""<br />
if d1['connect'] == 'disconnected': # external unplugged<br />
return ('auto','off') # switch off external<br />
if d1['width'] == 0: # external off<br />
return ('auto --pos 0x0','auto --pos 0x0') # both on<br />
if d0['width'] == 0: # laptop off<br />
return ('auto --pos 0x0','off') # laptop on<br />
if d1['horizontal'] > 0: # external to right<br />
return ('auto --pos 0x0',position('V',d0,d1,sz)) # put *below<br />
if d1['vertical'] > 0: # external below<br />
return (position('H',d1,d0,sz),'auto --pos 0x0') # put *left<br />
if d0['horizontal'] > 0: # external left<br />
return (position('V',d1,d0,sz),'auto --pos 0x0') # put *above<br />
if d0['vertical'] > 0: # external above<br />
return ('off','auto --pos 0x0') # laptop off<br />
return ('auto --pos 0x0',position('H',d0,d1,sz)) # both, put*right<br />
<br />
class DisplayNameError(UnboundLocalError):<br />
"""Internal or External Display Name not found by xrandr -q """<br />
<br />
def function7(disp0=LAPTOP, disp1=MONITOR, seq=SEQUENCE):<br />
"""Use xrandr to read current display state and change state"""<br />
for line in os.popen('xrandr -q').read().splitlines():<br />
if line.startswith(disp0,0) :<br />
d0_state = REGEX_OUTPUT.match(line).groupdict()<br />
elif line.startswith(disp1,0):<br />
d1_state = REGEX_OUTPUT.match(line).groupdict()<br />
elif line.startswith('Screen',0):<br />
screen_size = REGEX_SCREEN.match(line).groupdict()<br />
else:<br />
pass<br />
for i in ('width','height','horizontal','vertical'):<br />
try:<br />
d0_state[i] = int(d0_state[i])<br />
except TypeError:<br />
d0_state[i] = 0<br />
except UnboundLocalError:<br />
raise DisplayNameError, 'Internal Display: %s not found'% disp0<br />
try:<br />
d1_state[i] = int(d1_state[i])<br />
except TypeError:<br />
d1_state[i] = 0<br />
except UnboundLocalError:<br />
raise DisplayNameError, 'External Display: %s not found'% disp1<br />
for i in screen_size.keys():<br />
try:<br />
screen_size[i] = int(screen_size[i])<br />
except TypeError:<br />
screen_size[i] = 0<br />
#<br />
toggle = toggle_simple<br />
xrandr ='xrandr --output '+disp0+' --%s --output '+disp1+' --%s %s'<br />
if seq == 'full':<br />
toggle = toggle_full<br />
if seq == 'limited':<br />
toggle = toggle_limited<br />
xrandr ='xrandr --output '+disp0+' --%s --output '+disp1+' --%s'<br />
os.popen(xrandr % toggle(d0_state, d1_state, screen_size))<br />
else:<br />
os.popen(xrandr % toggle(d0_state, d1_state))<br />
<br />
def main():<br />
""" Command line options """<br />
global LAPTOP,MONITOR,SEQUENCE<br />
from optparse import OptionParser<br />
p = OptionParser(usage=__usage__, version=__version__, description=__doc__) <br />
p.set_defaults(internal=LAPTOP, external=MONITOR, displays=SEQUENCE)<br />
p.add_option('-i','--internal', dest="internal", metavar=LAPTOP,<br />
help="internal display")<br />
p.add_option('-e','--external', dest="external", metavar=MONITOR,<br />
help="external display")<br />
p.add_option('-d','--displays', dest="displays", action="store",<br />
choices=('simple', 'limited', 'full'), metavar=SEQUENCE,<br />
help='simple/limited/full')<br />
(opt, args) = p.parse_args()<br />
try:<br />
function7(opt.internal, opt.external, opt.displays)<br />
except DisplayNameError, err:<br />
print '\n'+str(err)+'\n'<br />
print os.popen('xrandr -q').read()<br />
#<br />
if __name__ == '__main__': #only when run from cmd line<br />
main()<br />
<br />
== References ==<br />
[[http://gitweb.freedesktop.org/?p=xorg/app/grandr.git grandr]] graphical interface to xrandr using GTK+ libraries.<br />
<br />
[[https://edge.launchpad.net/python-xrandr python-xrandr]] Python bindings to xrandr which should enable a less clunky version of the python script above. Under development.</div>Husky69https://www.thinkwiki.org/w/index.php?title=Tp_smapi&diff=34129Tp smapi2007-10-26T23:09:51Z<p>Husky69: /* Installation on Ubuntu/Debian */ Adjusted version info for Gutsy Gibbon</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 />
The <tt>tp_smapi</tt> kernel module exposes some features of the ThinkPad hardware/firmware via a <tt>sysfs</tt> interface. Currently, the main implemented functionality is control of battery charging and extended battery status. It also includes an improved version of the [[HDAPS]] driver. The underlying hardware interfaces are [[SMAPI support for Linux|SMAPI]] and direct access to the embedded controller.<br />
<br />
For older ThinkPad models, see also [[tpctl]].<br />
<br />
{{WARN|This driver uses undocumented features and direct hardware access. It thus cannot be guaranteed to work and could conceivably damage your computer (though so far no incidents have been reported).}}<br />
|}<br />
<br />
===Features===<br />
*Battery charge/discharge control<br />
*Battery status information<br />
<br />
===Project Homepage / Availability===<br />
* Project page: http://tpctl.sourceforge.net/<br />
* You need to [http://sourceforge.net/project/showfiles.php?group_id=1212&package_id=171579 download] only the <tt>tp_smapi</tt> package.<br />
<br />
===Installation===<br />
====Installation from source====<br />
You will need the kernel headers and makefiles corresponding to your current kernel version. On {{Fedora}}, this means {{cmdroot|yum install kernel-devel-$(uname -r)}} .<br />
<br />
:{{cmdroot|tar xzvf tp_smapi-0.32.tgz}}<br />
:{{cmdroot|cd tp_smapi-0.32}}<br />
<br />
<br />
Then, either compile and load the driver within the current working directory (for testing):<br />
:{{cmdroot|make load}}<br />
OR compile and install into the kernel's module path:<br />
:{{cmdroot|make install}}<br />
<br />
<br />
If you use the [[HDAPS]] driver, add <tt>HDAPS=1</tt> to also patch the <tt>hdaps</tt> for compatibility with <tt>tp_smapi</tt> (this requires a kernel source tree matching the current kernel).<br />
Again, either load the driver within the current working directory:<br />
:{{cmdroot|1=make load HDAPS=1}}<br />
OR install into the kernel's module path:<br />
:{{cmdroot|1=make install HDAPS=1}}<br />
<br />
<br />
To prepare a stand-alone patch against the current kernel tree (including<br />
a patch against <tt>hdaps</tt> and new <tt>Kconfig</tt> entries):<br />
:{{cmdroot|make patch}}<br />
<br />
To delete all autogenerated files:<br />
:{{cmdroot|make clean}}<br />
<br />
The original kernel tree is never modified by any these commands. <br />
The {{path|/lib/modules}} directory is modified only by {{cmdroot|make install}}.<br />
<br />
====Installation in Gentoo====<br />
The {{Gentoo}} portage system carries a [http://packages.gentoo.org/packages/?category=app-laptop;name=tp_smapi tp_smapi package], which follows the latest version pretty closely. On a Gentoo system, you can install and load as follows.<br />
<br />
If you use the [[HDAPS]] driver, do this first:<br />
<br />
* Configure <tt>hdaps</tt> as module in your kernel<br />
* Add the <tt>HDAPS</tt> use flag in {{path|/etc/make.conf}}<br />
* {{cmdroot|rmmod hdaps}}<br />
<br />
Then:<br />
<br />
* {{cmdroot|emerge tp_smapi}} (or install tp_smapi with hdaps support manually, as above)<br />
* {{cmdroot|echo "tp_smapi" >> /etc/modules.autoload.d/kernel-2.6}}<br />
* {{cmdroot|echo "hdaps" >> /etc/modules.autoload.d/kernel-2.6}}<br />
<br />
Then reboot, or run:<br />
* {{cmdroot|modprobe tp_smapi}}<br />
* {{cmdroot|modprobe hdaps}}<br />
<br />
====Installation on Ubuntu/Debian====<br />
Installation on Ubuntu or Debian is quite easy, but there are a few things to look after:<br />
<br />
To get your system ready for compiling code, install the build-essentials (as root, of course, as all of the following comands; Ubuntu users have to prepend 'sudo' to every line and enter their own password when prompted):<br />
<pre><nowiki>apt-get install build-essential</nowiki></pre><br />
<br />
To get tp_smapi to work, obtain the latest source as mentioned above and unpack it. If you want to use HDAPS, you need to install the kernel source matching te kernel you are running. To do so, issue this:<br />
<pre><nowiki>uname -r</nowiki></pre><br />
This will give you the version of your current kernel. As Ubuntu adds '-generic' to the kernel-version, the following command works for Debian users only:<br />
<pre><nowiki>apt-get install linux-source-`uname -r`</nowiki></pre><br />
Ubuntu users use the kernel-version they got by the command before, e.g. 'linux-source-2.6.20'<br />
<br />
Now change to the tp_smapi dir:<br />
<pre><nowiki>cd tp_smapi-X.YY</nowiki></pre> (X.YY being the version-number of [[tp_smapi]])<br />
and make and install tp_smapi as instructed above.<br />
<br />
If you get an error that the kernel version isn't matching (or that you need to set KSRC/KBUILD), please check that there is a symlink from the modules dir to the kernel source:<br />
<pre><nowiki>root@localhost:~#ls -l /lib/modules/2.6.20-16-generic<br />
lrwxrwxrwx 1 root root 28 2007-02-02 08:39 source -> /usr/src/linux-source-2.6.20</nowiki></pre><br />
Create the link if the line above is not existent:<br />
<pre><nowiki>root@localhost:~#ln -s /usr/src/linux-source-2.6.20 /lib/modules/2.6.20-16-generic/source</nowiki></pre><br />
<br />
Now the following will build and install the correct modules to their locations:<br />
<pre><nowiki>make install HDAPS=1</nowiki></pre><br />
To make sure your system loads the modules at boot time, do this:<br />
<pre><nowiki>echo "tp_smapi" >> /etc/modules<br />
echo "hdaps" >> /etc/modules</nowiki></pre><br />
and update your initramfs:<br />
<pre><nowiki>update-initramfs -u</nowiki></pre><br />
<br />
To get tp_smapi running now, just load the modules:<br />
<pre><nowiki>modprobe -a tp_smapi hdaps</nowiki></pre><br />
<br />
This description was tested on Kubuntu 'Feisty Fawn' and should work on all Debian-based distros with minor tweaks.<br />
<br />
'''EDIT:''' Works on Kubuntu 7.10 ("Gutsy Gibbon"), too<br />
<br />
===Battery charge control features===<br />
To set the thresholds for starting and stopping battery charging (in percent of current full charge capacity):<br />
:{{cmdroot|echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh}}<br />
:{{cmdroot|echo 70 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh}}<br />
:{{cmdroot|cat /sys/devices/platform/smapi/BAT0/*_charge_thresh}}<br />
{{HINT|Battery charging thresholds can be used to keep Li-Ion ad Li-Polymer batteries partially charged, in order to [[Maintenance#Battery_treatment|increase their lifetime]].}}<br />
To prevent charging for 17 minutes (regardless of thresholds):<br />
:{{cmdroot|echo 17 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes}}<br />
{{HINT|Charge inhibiting can be used to reduce the power draw of the laptop, in order to use an under-spec power supply that can't handle the combined power draw of running and charging. It can also be used to control which battery is charged when [[How to use UltraBay batteries|using an Ultrabay battery]].}}<br />
<br />
To cancel charging preventation:<br />
:{{cmdroot|echo 0 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes}}<br />
<br />
To force battery discharging (even if connected to AC):<br />
:{{cmdroot|echo 1 > /sys/devices/platform/smapi/BAT0/force_discharge}}<br />
{{HINT|This can be used to choose which battery is discharged when [[How to use UltraBay batteries|using an UltraBay battery]].}}<br />
<br />
To cancel forced discharge:<br />
:{{cmdroot|echo 0 > /sys/devices/platform/smapi/BAT0/force_discharge}}<br />
<br />
===Battery status features===<br />
To view extended battery status such as charging state, voltage, current, capacity, cycle count and model information:<br />
<br />
<pre><br />
# cat /sys/devices/platform/smapi/BAT0/installed<br />
# cat /sys/devices/platform/smapi/BAT0/state # idle/charging/discharging<br />
# cat /sys/devices/platform/smapi/BAT0/cycle_count<br />
# cat /sys/devices/platform/smapi/BAT0/current_now # instantaneous current<br />
# cat /sys/devices/platform/smapi/BAT0/current_avg # last minute average<br />
# cat /sys/devices/platform/smapi/BAT0/power_now # instantaneous power<br />
# cat /sys/devices/platform/smapi/BAT0/power_avg # last minute average<br />
# cat /sys/devices/platform/smapi/BAT0/last_full_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_percent<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_running_time<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_charging_time<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/design_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/voltage<br />
# cat /sys/devices/platform/smapi/BAT0/design_voltage<br />
# cat /sys/devices/platform/smapi/BAT0/manufacturer<br />
# cat /sys/devices/platform/smapi/BAT0/model<br />
# cat /sys/devices/platform/smapi/BAT0/barcoding<br />
# cat /sys/devices/platform/smapi/BAT0/chemistry<br />
# cat /sys/devices/platform/smapi/BAT0/serial<br />
# cat /sys/devices/platform/smapi/BAT0/manufacture_date<br />
# cat /sys/devices/platform/smapi/BAT0/first_use_date<br />
# cat /sys/devices/platform/smapi/BAT0/temperature # in milli-Celsius<br />
# cat /sys/devices/platform/smapi/ac_connected<br />
</pre><br />
<br />
The raw status data is also available, including some fields not listed above (in case you can figure them out):<br />
<br />
:{{cmdroot|cat /sys/devices/platform/smapi/BAT0/dump}}<br />
<br />
In all of the above, replace <tt>BAT0</tt> with <tt>BAT1</tt> to address the 2nd battery.<br />
<br />
Note that the battery status readout conflicts with the stock [[HDAPS|hdaps]] driver, so if you use <tt>hdaps</tt> you will need to load <tt>tp_smapi</tt> using {{cmdroot|1=make load HDAPS=1}} (see [[#Bundled hdaps driver|Bundled hdaps driver]] below).<br />
<br />
On [[ACPI]]-enabled systems, most of above information is also available through the files under {{path|/proc/acpi/battery}}. However, the ACPI interface does not include the instantaneous power and cycle count readouts, and does not work well when [[How to use UltraBay batteries|hotswapping UltraBay batteries]].<br />
<br />
===Other features===<br />
<br />
There is also [[sysfs]] attribute for making direct SMAPI requests to the SM BIOS firmware. Don't touch it unless you really know what you're doing. Example:<br />
# echo '211a 100 0 0' > /sys/devices/platform/smapi/smapi_request; cat /sys/devices/platform/smapi/smapi_request<br />
211a 34b b2 0 0 0 'OK'<br />
The "4b" in the 2nd value, converted to decimal, is 75: the current charging stop threshold (stop_charge_thresh).<br />
<br />
===Bundled <tt>hdaps</tt> driver===<br />
<br />
The tp_smapi package includes a modified version of the <tt>hdaps</tt> Linux kernel driver used by the [[HDAPS]] system. To use <tt>tp_smapi</tt> and <tt>hdaps</tt> concurrently, you '''must''' use the modified version.<br />
<br />
To build the modified version, simply append the <tt>HDAPS=1</tt> parameter to the <tt>make</tt> command (see [[#Installation|Installation]] above):<br />
:{{cmdroot|1=make load HDAPS=1}}<br />
or<br />
:{{cmdroot|1=make install HDAPS=1}}<br />
<br />
If you don't do that, you will not be able to load <tt>tp_smapi</tt> (and its support module <tt>thinkpad_ec</tt>) when <tt>hdaps</tt> is loaded, and vice versa. You can use <tt>rmmod</tt> to switch between these modules.<br />
<br />
Note that some of the battery status is also visible through ACPI ({{path|/proc/acpi/battery/*}}), independently of <tt>tp_smapi</tt>.<br />
<br />
The modified <tt>hdaps</tt> has several changes:<br />
* The <tt>hdaps</tt> driver in mainline kernels conflicts with the extended battery status (they use the same IO ports). The modified <tt>hdaps</tt> coordinates this access through the bundled <tt>thinkpad_ec</tt> driver.<br />
* The modified <tt>hdaps</tt> driver fixes reliability and improves support for recent ThinkPad models (*60 and newer), since unlike the mainline driver, it correctly follows the Embedded Controller communication protocol.<br />
* Several other improvements, such as the ability to control the polling rate.<br />
<br />
===Troubleshooting===<br />
<br />
If you get "<tt>thinkpad_ec: no ThinkPad embedded controller!</tt>" when trying to load the module on a supported model listed below, you should [[BIOS_Upgrade|upgrade your BIOS]]. Some early BIOS (like 1.x on the X31) don't handle the embedded controller.<br />
<br />
===Model-specific status===<br />
<br />
<br />
<div style="font-size: 92%"><br />
{| border="1" cellspacing="0" cellpadding="2"<br />
|+<tt>tp_smapi</tt> feature support matrix<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" | <br />
=====A series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{A22p}} 2629-USG<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{A30}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
=====G series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{G41}}<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
=====R series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{R31}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || No SMAPI BIOS<br />
|-<br />
! {{R40}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50}}<br />
| {{Cunk}} || {{Cno}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50e}} 1834-JAG<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R51}} 18*<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 3.22 || Machine types 1829, 1830, 1831 and 1836<br />
|-<br />
! {{R51}} 28*<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || 1.29 || Machine types 2883, 2887, 2888, 2889, 2894 and 2495<br />
|-<br />
! {{R52}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 1.29 ||<br />
|-<br />
! {{R60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} ||{{Cyes}} || {{Cunk}} || || ||<br />
|-<br />
<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====T series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{T20}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || Has SMAPI BIOS but no function is supported. EC LPC3 protocol fails.<br />
|-<br />
! {{T22}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || Has SMAPI BIOS but no function is supported. EC LPC3 protocol fails.<br />
|-<br />
! {{T23}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T30}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T40}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T40p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T41}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T41p}} 2373-AM9<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || 3.20 || EC v3.04<br />
|-<br />
! {{T42}}<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T42p}} 2373-KXU<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || 3.21 || Stop charge threshold works in Windows, but dmesg says "__get_real_thresh: cannot get stop_thresh of bat=0: Function is not supported by SMAPI BIOS".<br />
|-<br />
! {{T42p}} 2373-KUU<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T43}} 2686<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 1.27 ||<br />
|-<br />
! {{T43p}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=Y, Y'=-X || 0.32 || ||<br />
|-<br />
! {{T60p}} 8743-CTO<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || ||<br />
|-<br />
! {{T61}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=-X, Y'=-Y || 0.32 || || [http://ubuntuforums.org/showthread.php?p=3146719 ref]<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====X series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{X20}} 2662-31G<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X24}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X31}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X32}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X40}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || 2.08 || EC v1.62<br />
|-<br />
! {{X41}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || ||<br />
|-<br />
! {{X60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=-Y, Y'=X || || 2.07 || EC v1.10, 2.6.20 issue (see discussion)<br />
|-<br />
! {{X61s}}<br />
| {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || || [http://www.slackwiki.org/ThinkPad_X61s ref]<br />
|-<br />
! {{X60T}}<br />
| {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || || || [http://luke.no-ip.org/x60tablet/ ref] [http://rad.bioinfo.ulaval.ca/hardware/x60tablet ref]<br />
|-<br />
! {{X61T}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}}X'=-Y, Y'=X || 0.32 || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====Z series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{Z60m}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{Z60t}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{Z61m}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || ||<br />
|-<br />
! {{Z61t}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || || || [https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.20/+bug/45014 ref]<br />
|}<br />
</div><br />
<br />
<br />
SMAPI capabilities may depend on the BIOS version as well, so upgrading to the latest version of the BIOS might provide more SMAPI functions (especially true for long-lived BIOS with lots of releases, like the TP-1R).<br />
<br />
Please update the above and report your experience on the [[Talk:tp_smapi|discussion]] page. If the module loads but gives a "<tt>not supported</tt>" or "<tt>not implementeded</tt>" error when you try to use some specific file in {{path|/sys/devices/platform/smapi/}}, please report the <tt>dmesg</tt> output and whether the corresponding functionality is available under Windows - maybe your ThinkPad just can't do that. <br />
<br />
While at it, you may also want to add your laptop to the [[list of DMI IDs]].<br />
<br />
=====HDAPS axis orientation=====<br />
HDAPS axis orientation notation: X,Y are the hardware readouts, X',Y' are horizontal and vertical. You can use [[HDAPS#Visualisation_of_ThinkPad_orientation|hdaps visualisation]] to check for correctness.<br />
<br />
Just like the mainline hdaps driver, tp_smapi's hdaps driver supports inverting both axes together (but not separately, and no axis swapping):<br />
modprobe hdaps invert=1<br />
<br />
[[Category:Drivers]] [[Category:Patches]]<br />
<br />
===Tools using this driver===<br />
<br />
The driver's interface can be accessed directly through the files under {{path|/sys/devices/platform/smapi}}, or via the following tools:<br />
* [[KThinkBat]] - display battery status on the KDE <tt>kicker</tt> panel.<br />
* [[gkrellm-ThinkBat]] - battery status plugin for Gkrellm2<br />
* {{CodeRef|thinkpad-smapi.sh}} - script to display various SMAPI information using tp_smapi module.</div>Husky69https://www.thinkwiki.org/w/index.php?title=Tp_smapi&diff=33863Tp smapi2007-10-13T14:33:34Z<p>Husky69: /* Installation on Ubuntu/Debian */ Added hint on Gutsy Gibbon</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 />
The <tt>tp_smapi</tt> kernel module exposes some features of the ThinkPad hardware/firmware via a <tt>sysfs</tt> interface. Currently, the main implemented functionality is control of battery charging and extended battery status. It also includes an improved version of the [[HDAPS]] driver. The underlying hardware interfaces are [[SMAPI support for Linux|SMAPI]] and direct access to the embedded controller.<br />
<br />
For older ThinkPad models, see also [[tpctl]].<br />
<br />
{{WARN|This driver uses undocumented features and direct hardware access. It thus cannot be guaranteed to work and could conceivably damage your computer (though so far no incidents have been reported).}}<br />
|}<br />
<br />
===Features===<br />
*Battery charge/discharge control<br />
*Battery status information<br />
<br />
===Project Homepage / Availability===<br />
* Project page: http://tpctl.sourceforge.net/<br />
* You need to [http://sourceforge.net/project/showfiles.php?group_id=1212&package_id=171579 download] only the <tt>tp_smapi</tt> package.<br />
<br />
===Installation===<br />
====Installation from source====<br />
You will need the kernel headers and makefiles corresponding to your current kernel version. On {{Fedora}}, this means {{cmdroot|yum install kernel-devel-$(uname -r)}} .<br />
<br />
:{{cmdroot|tar xzvf tp_smapi-0.32.tgz}}<br />
:{{cmdroot|cd tp_smapi-0.32}}<br />
<br />
<br />
Then, either compile and load the driver within the current working directory (for testing):<br />
:{{cmdroot|make load}}<br />
OR compile and install into the kernel's module path:<br />
:{{cmdroot|make install}}<br />
<br />
<br />
If you use the [[HDAPS]] driver, add <tt>HDAPS=1</tt> to also patch the <tt>hdaps</tt> for compatibility with <tt>tp_smapi</tt> (this requires a kernel source tree matching the current kernel).<br />
Again, either load the driver within the current working directory:<br />
:{{cmdroot|1=make load HDAPS=1}}<br />
OR install into the kernel's module path:<br />
:{{cmdroot|1=make install HDAPS=1}}<br />
<br />
<br />
To prepare a stand-alone patch against the current kernel tree (including<br />
a patch against <tt>hdaps</tt> and new <tt>Kconfig</tt> entries):<br />
:{{cmdroot|make patch}}<br />
<br />
To delete all autogenerated files:<br />
:{{cmdroot|make clean}}<br />
<br />
The original kernel tree is never modified by any these commands. <br />
The {{path|/lib/modules}} directory is modified only by {{cmdroot|make install}}.<br />
<br />
====Installation in Gentoo====<br />
The {{Gentoo}} portage system carries a [http://packages.gentoo.org/packages/?category=app-laptop;name=tp_smapi tp_smapi package], which follows the latest version pretty closely. On a Gentoo system, you can install and load as follows.<br />
<br />
If you use the [[HDAPS]] driver, do this first:<br />
<br />
* Configure <tt>hdaps</tt> as module in your kernel<br />
* Add the <tt>HDAPS</tt> use flag in {{path|/etc/make.conf}}<br />
* {{cmdroot|rmmod hdaps}}<br />
<br />
Then:<br />
<br />
* {{cmdroot|emerge tp_smapi}} (or install tp_smapi with hdaps support manually, as above)<br />
* {{cmdroot|echo "tp_smapi" >> /etc/modules.autoload.d/kernel-2.6}}<br />
* {{cmdroot|echo "hdaps" >> /etc/modules.autoload.d/kernel-2.6}}<br />
<br />
Then reboot, or run:<br />
* {{cmdroot|modprobe tp_smapi}}<br />
* {{cmdroot|modprobe hdaps}}<br />
<br />
====Installation on Ubuntu/Debian====<br />
Installation on Ubuntu or Debian is quite easy, but there are a few things to look after:<br />
<br />
To get your system ready for compiling code, install the build-essentials (as root, of course, as all of the following comands; Ubuntu users have to prepend 'sudo' to every line and enter their own password when prompted):<br />
<pre><nowiki>apt-get install build-essential</nowiki></pre><br />
<br />
To get tp_smapi to work, obtain the latest source as mentioned above and unpack it. If you want to use HDAPS, you need to install the kernel source matching te kernel you are running. To do so, issue this:<br />
<pre><nowiki>uname -r</nowiki></pre><br />
This will give you the version of your current kernel. As Ubuntu adds '-generic' to the kernel-version, the following command works for Debian users only:<br />
<pre><nowiki>apt-get install linux-source-`uname -r`</nowiki></pre><br />
Ubuntu users use the kernel-version they got by the command before, e.g. 'linux-source-2.6.20'<br />
<br />
Now change to the tp_smapi dir:<br />
<pre><nowiki>cd tp_smapi-X.YY</nowiki></pre> (X.YY being the version-number of [[tp_smapi]])<br />
and make and install tp_smapi as instructed above.<br />
<br />
If you get an error that the kernel version isn't matching (or that you need to set KSRC/KBUILD), please check that there is a symlink from the modules dir to the kernel source:<br />
<pre><nowiki>root@localhost:~#ls -l /lib/modules/2.6.20-16-generic<br />
lrwxrwxrwx 1 root root 28 2007-02-02 08:39 source -> /usr/src/linux-source-2.6.20</nowiki></pre><br />
Create the link if the line above is not existent:<br />
<pre><nowiki>root@localhost:~#ln -s /usr/src/linux-source-2.6.20 /lib/modules/2.6.20-16-generic/source</nowiki></pre><br />
<br />
Now the following will build and install the correct modules to their locations:<br />
<pre><nowiki>make install HDAPS=1</nowiki></pre><br />
To make sure your system loads the modules at boot time, do this:<br />
<pre><nowiki>echo "tp_smapi" >> /etc/modules<br />
echo "hdaps" >> /etc/modules</nowiki></pre><br />
and update your initramfs:<br />
<pre><nowiki>update-initramfs -u</nowiki></pre><br />
<br />
To get tp_smapi running now, just load the modules:<br />
<pre><nowiki>modprobe -a tp_smapi hdaps</nowiki></pre><br />
<br />
This description was tested on Kubuntu 'Feisty Fawn' and should work on all Debian-based distros with minor tweaks.<br />
<br />
'''EDIT:''' Works on Kubuntu 7.10RC1 ("Gutsy Gibbon"), too<br />
<br />
===Battery charge control features===<br />
To set the thresholds for starting and stopping battery charging (in percent of current full charge capacity):<br />
:{{cmdroot|echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh}}<br />
:{{cmdroot|echo 70 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh}}<br />
:{{cmdroot|cat /sys/devices/platform/smapi/BAT0/*_charge_thresh}}<br />
{{HINT|Battery charging thresholds can be used to keep Li-Ion ad Li-Polymer batteries partially charged, in order to [[Maintenance#Battery_treatment|increase their lifetime]].}}<br />
To prevent charging for 17 minutes (regardless of thresholds):<br />
:{{cmdroot|echo 17 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes}}<br />
{{HINT|Charge inhibiting can be used to reduce the power draw of the laptop, in order to use an under-spec power supply that can't handle the combined power draw of running and charging. It can also be used to control which battery is charged when [[How to use UltraBay batteries|using an Ultrabay battery]].}}<br />
<br />
To cancel charging preventation:<br />
:{{cmdroot|echo 0 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes}}<br />
<br />
To force battery discharging (even if connected to AC):<br />
:{{cmdroot|echo 1 > /sys/devices/platform/smapi/BAT0/force_discharge}}<br />
{{HINT|This can be used to choose which battery is discharged when [[How to use UltraBay batteries|using an UltraBay battery]].}}<br />
<br />
To cancel forced discharge:<br />
:{{cmdroot|echo 0 > /sys/devices/platform/smapi/BAT0/force_discharge}}<br />
<br />
===Battery status features===<br />
To view extended battery status such as charging state, voltage, current, capacity, cycle count and model information:<br />
<br />
<pre><br />
# cat /sys/devices/platform/smapi/BAT0/installed<br />
# cat /sys/devices/platform/smapi/BAT0/state # idle/charging/discharging<br />
# cat /sys/devices/platform/smapi/BAT0/cycle_count<br />
# cat /sys/devices/platform/smapi/BAT0/current_now # instantaneous current<br />
# cat /sys/devices/platform/smapi/BAT0/current_avg # last minute average<br />
# cat /sys/devices/platform/smapi/BAT0/power_now # instantaneous power<br />
# cat /sys/devices/platform/smapi/BAT0/power_avg # last minute average<br />
# cat /sys/devices/platform/smapi/BAT0/last_full_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_percent<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_running_time<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_charging_time<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/design_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/voltage<br />
# cat /sys/devices/platform/smapi/BAT0/design_voltage<br />
# cat /sys/devices/platform/smapi/BAT0/manufacturer<br />
# cat /sys/devices/platform/smapi/BAT0/model<br />
# cat /sys/devices/platform/smapi/BAT0/barcoding<br />
# cat /sys/devices/platform/smapi/BAT0/chemistry<br />
# cat /sys/devices/platform/smapi/BAT0/serial<br />
# cat /sys/devices/platform/smapi/BAT0/manufacture_date<br />
# cat /sys/devices/platform/smapi/BAT0/first_use_date<br />
# cat /sys/devices/platform/smapi/BAT0/temperature # in milli-Celsius<br />
# cat /sys/devices/platform/smapi/ac_connected<br />
</pre><br />
<br />
The raw status data is also available, including some fields not listed above (in case you can figure them out):<br />
<br />
:{{cmdroot|cat /sys/devices/platform/smapi/BAT0/dump}}<br />
<br />
In all of the above, replace <tt>BAT0</tt> with <tt>BAT1</tt> to address the 2nd battery.<br />
<br />
Note that the battery status readout conflicts with the stock [[HDAPS|hdaps]] driver, so if you use <tt>hdaps</tt> you will need to load <tt>tp_smapi</tt> using {{cmdroot|1=make load HDAPS=1}} (see [[#Bundled hdaps driver|Bundled hdaps driver]] below).<br />
<br />
On [[ACPI]]-enabled systems, most of above information is also available through the files under {{path|/proc/acpi/battery}}. However, the ACPI interface does not include the instantaneous power and cycle count readouts, and does not work well when [[How to use UltraBay batteries|hotswapping UltraBay batteries]].<br />
<br />
===Other features===<br />
<br />
There is also [[sysfs]] attribute for making direct SMAPI requests to the SM BIOS firmware. Don't touch it unless you really know what you're doing. Example:<br />
# echo '211a 100 0 0' > /sys/devices/platform/smapi/smapi_request; cat /sys/devices/platform/smapi/smapi_request<br />
211a 34b b2 0 0 0 'OK'<br />
The "4b" in the 2nd value, converted to decimal, is 75: the current charging stop threshold (stop_charge_thresh).<br />
<br />
===Bundled <tt>hdaps</tt> driver===<br />
<br />
The tp_smapi package includes a modified version of the <tt>hdaps</tt> Linux kernel driver used by the [[HDAPS]] system. To use <tt>tp_smapi</tt> and <tt>hdaps</tt> concurrently, you '''must''' use the modified version.<br />
<br />
To build the modified version, simply append the <tt>HDAPS=1</tt> parameter to the <tt>make</tt> command (see [[#Installation|Installation]] above):<br />
:{{cmdroot|1=make load HDAPS=1}}<br />
or<br />
:{{cmdroot|1=make install HDAPS=1}}<br />
<br />
If you don't do that, you will not be able to load <tt>tp_smapi</tt> (and its support module <tt>thinkpad_ec</tt>) when <tt>hdaps</tt> is loaded, and vice versa. You can use <tt>rmmod</tt> to switch between these modules.<br />
<br />
Note that some of the battery status is also visible through ACPI ({{path|/proc/acpi/battery/*}}), independently of <tt>tp_smapi</tt>.<br />
<br />
The modified <tt>hdaps</tt> has several changes:<br />
* The <tt>hdaps</tt> driver in mainline kernels conflicts with the extended battery status (they use the same IO ports). The modified <tt>hdaps</tt> coordinates this access through the bundled <tt>thinkpad_ec</tt> driver.<br />
* The modified <tt>hdaps</tt> driver fixes reliability and improves support for recent ThinkPad models (*60 and newer), since unlike the mainline driver, it correctly follows the Embedded Controller communication protocol.<br />
* Several other improvements, such as the ability to control the polling rate.<br />
<br />
===Troubleshooting===<br />
<br />
If you get <tt>thinkpad_ec: no ThinkPad embedded controller!</tt> when trying to load the module on a supported model listed below, you should [[BIOS_Upgrade|upgrade your BIOS]]. Some early BIOS (like 1.x on the X31) don't handle the embedded controller.<br />
<br />
===Model-specific status===<br />
<br />
<br />
<div style="font-size: 92%"><br />
{| border="1" cellspacing="0" cellpadding="2"<br />
|+<tt>tp_smapi</tt> feature support matrix<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" | <br />
=====A series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{A22p}} 2629-USG<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{A30}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
=====G series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{G41}}<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
=====R series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{R31}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || No SMAPI BIOS<br />
|-<br />
! {{R40}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50}}<br />
| {{Cunk}} || {{Cno}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50e}} 1834-JAG<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R51}} 18*<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 3.22 || Machine types 1829, 1830, 1831 and 1836<br />
|-<br />
! {{R51}} 28*<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || 1.29 || Machine types 2883, 2887, 2888, 2889, 2894 and 2495<br />
|-<br />
! {{R52}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 1.29 ||<br />
|-<br />
! {{R60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} ||{{Cyes}} || {{Cunk}} || || ||<br />
|-<br />
<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====T series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{T20}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || Has SMAPI BIOS but no function is supported. EC LPC3 protocol fails.<br />
|-<br />
! {{T22}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || Has SMAPI BIOS but no function is supported. EC LPC3 protocol fails.<br />
|-<br />
! {{T23}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T30}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T40}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T40p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T41}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T41p}} 2373-AM9<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || 3.20 || EC v3.04<br />
|-<br />
! {{T42}}<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T42p}} 2373-KXU<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || 3.21 || Stop charge threshold works in Windows, but dmesg says "__get_real_thresh: cannot get stop_thresh of bat=0: Function is not supported by SMAPI BIOS".<br />
|-<br />
! {{T42p}} 2373-KUU<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T43}} 2686<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 1.27 ||<br />
|-<br />
! {{T43p}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=Y, Y'=-X || 0.32 || ||<br />
|-<br />
! {{T60p}} 8743-CTO<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || ||<br />
|-<br />
! {{T61}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=-X, Y'=-Y || 0.32 || || [http://ubuntuforums.org/showthread.php?p=3146719 ref]<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====X series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{X20}} 2662-31G<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X24}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X31}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X32}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X40}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || 2.08 || EC v1.62<br />
|-<br />
! {{X41}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || ||<br />
|-<br />
! {{X60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=-Y, Y'=X || || 2.07 || EC v1.10, 2.6.20 issue (see discussion)<br />
|-<br />
! {{X61s}}<br />
| {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || || [http://www.slackwiki.org/ThinkPad_X61s ref]<br />
|-<br />
! {{X60T}}<br />
| {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || || || [http://luke.no-ip.org/x60tablet/ ref] [http://rad.bioinfo.ulaval.ca/hardware/x60tablet ref]<br />
|-<br />
! {{X61T}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}}X'=-Y, Y'=X || 0.32 || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====Z series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{Z60m}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{Z60t}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{Z61m}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || ||<br />
|-<br />
! {{Z61t}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || || || [https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.20/+bug/45014 ref]<br />
|}<br />
</div><br />
<br />
<br />
SMAPI capabilities may depend on the BIOS version as well, so upgrading to the latest version of the BIOS might provide more SMAPI functions (especially true for long-lived BIOS with lots of releases, like the TP-1R).<br />
<br />
Please update the above and report your experience on the [[Talk:tp_smapi|discussion]] page. If the module loads but gives a "<tt>not supported</tt>" or "<tt>not implementeded</tt>" error when you try to use some specific file in {{path|/sys/devices/platform/smapi/}}, please report the <tt>dmesg</tt> output and whether the corresponding functionality is available under Windows - maybe your ThinkPad just can't do that. <br />
<br />
While at it, you may also want to add your laptop to the [[list of DMI IDs]].<br />
<br />
=====HDAPS axis orientation=====<br />
HDAPS axis orientation notation: X,Y are the hardware readouts, X',Y' are horizontal and vertical. You can use [[HDAPS#Visualisation_of_ThinkPad_orientation|hdaps visualisation]] to check for correctness.<br />
<br />
Just like the mainline hdaps driver, tp_smapi's hdaps driver supports inverting both axes together (but not separately, and no axis swapping):<br />
modprobe hdaps invert=1<br />
<br />
[[Category:Drivers]] [[Category:Patches]]<br />
<br />
===Tools using this driver===<br />
<br />
The driver's interface can be accessed directly through the files under {{path|/sys/devices/platform/smapi}}, or via the following tools:<br />
* [[KThinkBat]] - display battery status on the KDE <tt>kicker</tt> panel.<br />
* [[gkrellm-ThinkBat]] - battery status plugin for Gkrellm2<br />
* {{CodeRef|thinkpad-smapi.sh}} - script to display various SMAPI information using tp_smapi module.</div>Husky69https://www.thinkwiki.org/w/index.php?title=Tp_smapi&diff=32956Tp smapi2007-09-06T18:19:36Z<p>Husky69: /* Installation on Ubuntu/Debian */ Update build information at top of entry</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 />
The <tt>tp_smapi</tt> kernel module exposes some features of the ThinkPad hardware/firmware via a <tt>sysfs</tt> interface. Currently, the main implemented functionality is control of battery charging and extended battery status. The underlying hardware interfaces are [[SMAPI support for Linux|SMAPI]] and direct access to the embedded controller.<br />
<br />
For older ThinkPad models, see also [[tpctl]].<br />
<br />
{{WARN|This driver uses undocumented features and direct hardware access. It thus cannot be guaranteed to work and could conceivably damage your computer (though so far no incidents have been reported).}}<br />
|}<br />
<br />
===Features===<br />
*Battery charge/discharge control<br />
*Battery status information<br />
<br />
===Project Homepage / Availability===<br />
* Project page: http://tpctl.sourceforge.net/<br />
* You need to [http://sourceforge.net/project/showfiles.php?group_id=1212&package_id=171579 download] only the <tt>tp_smapi</tt> package.<br />
<br />
===Installation===<br />
====Installation from source====<br />
You will need the kernel headers and makefiles corresponding to your current kernel version. On {{Fedora}}, this means {{cmdroot|yum install kernel-devel-$(uname -r)}} .<br />
<br />
For testing, you can simply compile and load the driver within the current<br />
working directory:<br />
:{{cmdroot|tar xzvf tp_smapi-0.32.tgz}}<br />
:{{cmdroot|cd tp_smapi-0.32}}<br />
:{{cmdroot|make load}}<br />
<br />
To compile and install into the kernel's module path:<br />
:{{cmdroot|make install}}<br />
<br />
<br />
If you use the [[HDAPS]] driver, add <tt>HDAPS=1</tt> to also patch the <tt>hdaps</tt> for compatibility with <tt>tp_smapi</tt> (this requires a kernel source tree matching the current kernel):<br />
:{{cmdroot|1=make load HDAPS=1}}<br />
or, to compile and install into the kernel's module path:<br />
:{{cmdroot|1=make install HDAPS=1}}<br />
<br />
<br />
To prepare a stand-alone patch against the current kernel tree (including<br />
a patch against <tt>hdaps</tt> and new <tt>Kconfig</tt> entries):<br />
:{{cmdroot|make patch}}<br />
<br />
To delete all autogenerated files:<br />
:{{cmdroot|make clean}}<br />
<br />
The original kernel tree is never modified by any these commands. <br />
The {{path|/lib/modules}} directory is modified only by {{cmdroot|make install}}.<br />
<br />
====Installation in Gentoo====<br />
The {{Gentoo}} portage system carries a [http://packages.gentoo.org/packages/?category=app-laptop;name=tp_smapi tp_smapi package], which follows the latest version pretty closely. On a Gentoo system, you can install and load as follows.<br />
<br />
If you use the [[HDAPS]] driver, do this first:<br />
<br />
* Configure <tt>hdaps</tt> as module in your kernel<br />
* Add the <tt>HDAPS</tt> use flag in {{path|/etc/make.conf}}<br />
* {{cmdroot|rmmod hdaps}}<br />
<br />
Then:<br />
<br />
* {{cmdroot|emerge tp_smapi}} (or install tp_smapi with hdaps support manually, as above)<br />
* {{cmdroot|echo "tp_smapi" >> /etc/modules.autoload.d/kernel-2.6}}<br />
* {{cmdroot|echo "hdaps" >> /etc/modules.autoload.d/kernel-2.6}}<br />
<br />
Then reboot, or run:<br />
* {{cmdroot|modprobe tp_smapi}}<br />
* {{cmdroot|modprobe hdaps}}<br />
<br />
====Installation on Ubuntu/Debian====<br />
<br />
['''UPDATE''': Looks like the module doesn't compile for the kernel in Ubuntu 7.10 anymore. Bugreport is filed.]<br />
<br />
Installation on Ubuntu or Debian is quite easy, but there are a few things to look after:<br />
<br />
To get your system ready for compiling code, install the build-essentials (as root, of course, as all of the following comands; Ubuntu users have to prepend 'sudo' to every line and enter their own password when prompted):<br />
<pre><nowiki>apt-get install build-essentials</nowiki></pre><br />
<br />
To get tp_smapi to work, obtain the latest source as mentioned above and unpack it. If you want to use HDAPS, you need to install the kernel source matching te kernel you are running. To do so, issue this:<br />
<pre><nowiki>uname -r</nowiki></pre><br />
This will give you the version of your current kernel. As Ubuntu adds '-generic' to the kernel-version, the following command works for Debian users only:<br />
<pre><nowiki>apt-get install linux-source-`uname -r`</nowiki></pre><br />
Ubuntu users use the kernel-version they got by the command before, e.g. 'linux-source-2.6.20'<br />
<br />
Now change to the tp_smapi dir:<br />
<pre><nowiki>cd tp_smapi-X.YY</nowiki></pre> (X.YY being the version-number of [[tp_smapi]])<br />
and make and install tp_smapi as instructed above.<br />
<br />
If you get an error that the kernel version isn't matching, please check that there is a symlink from the modules dir to the kernel source:<br />
<pre><nowiki>root@localhost:~#ls -l /lib/modules/2.6.20-6-generic<br />
lrwxrwxrwx 1 root root 28 2007-02-02 08:39 source -> /usr/src/linux-source-2.6.20</nowiki></pre><br />
Create the link if the line above is not existent:<br />
<pre><nowiki>root@localhost:~#ln -s /usr/src/linux-source-2.6.20 /lib/modules/2.6.20-6-generic/source</nowiki></pre><br />
<br />
Now the following will build and install the correct modules to their locations:<br />
<pre><nowiki>make install HDAPS=1</nowiki></pre><br />
To make sure your system loads the modules at boot time, do this:<br />
<pre><nowiki>echo "tp_smapi" >> /etc/modules<br />
echo "hdaps" >> /etc/modules</nowiki></pre><br />
and update your initramfs:<br />
<pre><nowiki>update-initramfs -u</nowiki></pre><br />
<br />
To get tp_smapi running now, just load the modules:<br />
<pre><nowiki>modprobe -a tp_smapi hdaps</nowiki></pre><br />
<br />
This description was tested on Kubuntu 'Feisty Fawn' and should work on all Debian-based distros with minor tweaks.<br />
<br />
===Battery charge control features===<br />
To set the thresholds for starting and stopping battery charging (in percent of current full charge capacity):<br />
:{{cmdroot|echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh}}<br />
:{{cmdroot|echo 70 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh}}<br />
:{{cmdroot|cat /sys/devices/platform/smapi/BAT0/*_charge_thresh}}<br />
{{HINT|Battery charging thresholds can be used to keep Li-Ion ad Li-Polymer batteries partially charged, in order to [[Maintenance#Battery_treatment|increase their lifetime]].}}<br />
To prevent charging for 17 minutes (regardless of thresholds):<br />
:{{cmdroot|echo 17 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes}}<br />
{{HINT|Charge inhibiting can be used to reduce the power draw of the laptop, in order to use an under-spec power supply that can't handle the combined power draw of running and charging. It can also be used to control which battery is charged when [[How to use UltraBay batteries|using an Ultrabay battery]].}}<br />
<br />
To cancel charging preventation:<br />
:{{cmdroot|echo 0 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes}}<br />
<br />
To force battery discharging (even if connected to AC):<br />
:{{cmdroot|echo 1 > /sys/devices/platform/smapi/BAT0/force_discharge}}<br />
{{HINT|This can be used to choose which battery is discharged when [[How to use UltraBay batteries|using an UltraBay battery]].}}<br />
<br />
To cancel forced discharge:<br />
:{{cmdroot|echo 0 > /sys/devices/platform/smapi/BAT0/force_discharge}}<br />
<br />
===Battery status features===<br />
To view extended battery status such as charging state, voltage, current, capacity, cycle count and model information:<br />
<br />
<pre><br />
# cat /sys/devices/platform/smapi/BAT0/installed<br />
# cat /sys/devices/platform/smapi/BAT0/state # idle/charging/discharging<br />
# cat /sys/devices/platform/smapi/BAT0/cycle_count<br />
# cat /sys/devices/platform/smapi/BAT0/current_now # instantaneous current<br />
# cat /sys/devices/platform/smapi/BAT0/current_avg # last minute average<br />
# cat /sys/devices/platform/smapi/BAT0/power_now # instantaneous power<br />
# cat /sys/devices/platform/smapi/BAT0/power_avg # last minute average<br />
# cat /sys/devices/platform/smapi/BAT0/last_full_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_percent<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_running_time<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_charging_time<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/design_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/voltage<br />
# cat /sys/devices/platform/smapi/BAT0/design_voltage<br />
# cat /sys/devices/platform/smapi/BAT0/manufacturer<br />
# cat /sys/devices/platform/smapi/BAT0/model<br />
# cat /sys/devices/platform/smapi/BAT0/barcoding<br />
# cat /sys/devices/platform/smapi/BAT0/chemistry<br />
# cat /sys/devices/platform/smapi/BAT0/serial<br />
# cat /sys/devices/platform/smapi/BAT0/manufacture_date<br />
# cat /sys/devices/platform/smapi/BAT0/first_use_date<br />
# cat /sys/devices/platform/smapi/BAT0/temperature # in milli-Celsius<br />
# cat /sys/devices/platform/smapi/ac_connected<br />
</pre><br />
<br />
The raw status data is also available, including some fields not listed above (in case you can figure them out):<br />
<br />
:{{cmdroot|cat /sys/devices/platform/smapi/BAT0/dump}}<br />
<br />
In all of the above, replace <tt>BAT0</tt> with <tt>BAT1</tt> to address the 2nd battery.<br />
<br />
Note that the battery status readout conflicts with the stock [[HDAPS|hdaps]] driver, so if you use <tt>hdaps</tt> you will need to load <tt>tp_smapi</tt> using {{cmdroot|1=make load HDAPS=1}} (see [[#Bundled hdaps driver|Bundled hdaps driver]] below).<br />
<br />
On [[ACPI]]-enabled systems, most of above information is also available through the files under {{path|/proc/acpi/battery}}. However, the ACPI interface does not include the instantaneous power and cycle count readouts, and does not work well when [[How to use UltraBay batteries|hotswapping UltraBay batteries]].<br />
<br />
===Other features===<br />
<br />
There is also [[sysfs]] attribute for making direct SMAPI requests to the SM BIOS firmware. Don't touch it unless you really know what you're doing. Example:<br />
# echo '211a 100 0 0 > /sys/devices/platform/smapi/smapi_request; cat /sys/devices/platform/smapi/smapi_request<br />
211a 34b b2 0 0 0 'OK'<br />
The 4b" in the 2nd value, converted to decimal is 75: the current charge stop threshold.<br />
<br />
===Bundled <tt>hdaps</tt> driver===<br />
<br />
The tp_smapi package includes a modified version of the <tt>hdaps</tt> Linux kernel driver used by the [[HDAPS]] system. To use <tt>tp_smapi</tt> and <tt>hdaps</tt> concurrently, you '''must''' use the modified version.<br />
<br />
To build the modified version, simply append the <tt>HDAPS=1</tt> parameter to the <tt>make</tt> command (see [[#Installation|Installation]] above):<br />
:{{cmdroot|1=make load HDAPS=1}}<br />
or<br />
:{{cmdroot|1=make install HDAPS=1}}<br />
<br />
If you don't do that, you will not be able to load <tt>tp_smapi</tt> (and its support module <tt>thinkpad_ec</tt>) when <tt>hdaps</tt> is loaded, and vice versa. You can use <tt>rmmod</tt> to switch between these modules.<br />
<br />
Note that some of the battery status is also visible through ACPI ({{path|/proc/acpi/battery/*}}), independently of <tt>tp_smapi</tt>.<br />
<br />
The modified <tt>hdaps</tt> has several changes:<br />
* The <tt>hdaps</tt> driver in mainline kernels conflicts with the extended battery status (they use the same IO ports). The modified <tt>hdaps</tt> coordinates this access through the bundled <tt>thinkpad_ec</tt> driver.<br />
* The modified <tt>hdaps</tt> driver fixes reliability and improves support for recent ThinkPad models (*60 and newer), since unlike the mainline driver, it correctly follows the Embedded Controller communication protocol.<br />
* Several other improvements, such as the ability to control the polling rate.<br />
<br />
===Troubleshooting===<br />
<br />
If you get <tt>thinkpad_ec: no ThinkPad embedded controller!</tt> when trying to load the module on a supported model listed below, you should [[BIOS_Upgrade|upgrade your BIOS]]. Some early BIOS (like 1.x on the X31) don't handle the embedded controller.<br />
<br />
===Model-specific status===<br />
<br />
<br />
<div style="font-size: 92%"><br />
{| border="1" cellspacing="0" cellpadding="2"<br />
|+<tt>tp_smapi</tt> feature support matrix<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" | <br />
=====A series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{A22p}} 2629-USG<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{A30}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
=====G series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{G41}}<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
=====R series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{R31}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || No SMAPI BIOS<br />
|-<br />
! {{R40}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50}}<br />
| {{Cunk}} || {{Cno}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50e}} 1834-JAG<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R50p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{R51}} 18*<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 3.22 || Machine types 1829, 1830, 1831 and 1836<br />
|-<br />
! {{R51}} 28*<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || 1.29 || Machine types 2883, 2887, 2888, 2889, 2894 and 2495<br />
|-<br />
! {{R52}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 1.29 ||<br />
|-<br />
! {{R60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} ||{{Cyes}} || {{Cunk}} || || ||<br />
|-<br />
<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====T series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{T20}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || Has SMAPI BIOS but no function is supported. EC LPC3 protocol fails.<br />
|-<br />
! {{T22}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || || Has SMAPI BIOS but no function is supported. EC LPC3 protocol fails.<br />
|-<br />
! {{T23}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T30}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T40}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T40p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T41}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T41p}} 2373-AM9<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || 3.20 || EC v3.04<br />
|-<br />
! {{T42}}<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T42p}} 2373-KXU<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || 3.21 || Stop charge threshold works in Windows. dmesg output:<br />
smapi smapi: smapi_request: SMAPI error: Function is not supported by SMAPI BIOS (func=211a)<br />
smapi smapi: __get_real_thresh: cannot get stop_thresh of bat=0: Function is not supported by SMAPI BIOS<br />
|-<br />
! {{T42p}} 2373-KUU<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T43}} 2686<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || 1.27 ||<br />
|-<br />
! {{T43p}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{T60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=Y, Y'=-X || 0.32 || ||<br />
|-<br />
! {{T60p}} 8743-CTO<br />
| {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=-X, Y'=-Y || 0.32 || ||<br />
|-<br />
! {{T61}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=-X, Y'=-Y || 0.32 || || [http://ubuntuforums.org/showthread.php?p=3146719 ref]<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====X series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{X20}} 2662-31G<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X24}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X31}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X32}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{X40}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || 2.08 || EC v1.62<br />
|-<br />
! {{X41}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || ||<br />
|-<br />
! {{X60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || || 2.07 || EC v1.10, 2.6.20 issue (see discussion)<br />
|-<br />
! {{X61s}}<br />
| {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cno|text=}} X'=X, Y'=-Y || 0.32 || || [http://www.slackwiki.org/ThinkPad_X61s ref]<br />
|-<br />
! {{X60T}}<br />
| {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || || || [http://luke.no-ip.org/x60tablet/ ref] [http://rad.bioinfo.ulaval.ca/hardware/x60tablet ref]<br />
|-<br />
! {{X61T}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cyes}} || {{Cno|text=}}X'=-Y, Y'=X || 0.32 || ||<br />
|-<br />
! colspan=11 style="text-align:center;background:#efefef;" |<br />
<br />
=====Z series=====<br />
|-<br />
{{tp_smapi/model_status_table_header}}<br />
|-<br />
! {{Z60m}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{Z60t}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || || ||<br />
|-<br />
! {{Z61m}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes|text=}} X'=X, Y'=Y || 0.32 || ||<br />
|-<br />
! {{Z61t}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || || || [https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.20/+bug/45014 ref]<br />
|}<br />
</div><br />
<br />
<br />
SMAPI capabilities may depend on the BIOS version as well, so upgrading to the latest version of the BIOS might provide more SMAPI functions (especially true for long-lived BIOS with lots of releases, like the TP-1R).<br />
<br />
Please update the above and report your experience on the [[Talk:tp_smapi|discussion]] page. If the module loads but gives a "<tt>not supported</tt>" or "<tt>not implementeded</tt>" error when you try to use some specific file in {{path|/sys/devices/platform/smapi/}}, please report the <tt>dmesg</tt> output and whether the corresponding functionality is available under Windows - maybe your ThinkPad just can't do that. <br />
<br />
While at it, you may also want to add your laptop to the [[list of DMI IDs]].<br />
<br />
=====HDAPS axis orientation=====<br />
HDAPS axis orientation notation: X,Y are the hardware readouts, X',Y' are horizontal and vertical. You can use [[HDAPS#Visualisation_of_ThinkPad_orientation|hdaps visualisation]] to check for correctness.<br />
<br />
[[Category:Drivers]] [[Category:Patches]]<br />
<br />
===Tools using this driver===<br />
<br />
The driver's interface can be accessed directly through the files under {{path|/sys/devices/platform/smapi}}, or via the following tools:<br />
* [[KThinkBat]] - display battery status on the KDE <tt>kicker</tt> panel.<br />
* [[gkrellm-ThinkBat]] - battery status plugin for Gkrellm2<br />
* {{CodeRef|thinkpad-smapi.sh}} - script to display various SMAPI information using tp_smapi module.</div>Husky69https://www.thinkwiki.org/w/index.php?title=Talk:Tp_smapi&diff=29432Talk:Tp smapi2007-04-22T19:04:02Z<p>Husky69: /* battery start/stop thresholds saved after reboot? */ Can't find tpsmapi-utils</p>
<hr />
<div>== Feedback ==<br />
<br />
Great, great work! Really! This completely rocks. I just stopped my battery from charging at 77% and restarted charging a bit later, no problems whatsoever. BTW, this is on kernel 2.6.14.3.<br />
<br />
--[[User:Spiney|spiney]] 21:25, 5 Dec 2005 (CET)<br />
----<br />
None of the fuctions is working on my T40, kernel 2.6.14-mm2.<br />
<br />
--[[User:Lammic|lammic]], 2005.12.05<br />
<br />
Works for me on a T41 running 2.6.12-10-686 (Ubuntu 5.10).<br />
<br />
--[[User:berndtnm|berndtnm]], 2005.12.06<br />
<br />
Including stop_charge_thresh? That one seems to be missing on the T42p.<br />
<br />
--[[User:Thinker|Thinker]] 00:46, 7 Dec 2005 (CET)<br />
----<br />
<br />
tp_smapi works just fine on an R52 with Ubuntu Breezy stock kernel.<br />
<br />
--[[User:Micampe|Micampe]] 12:52, 7 Dec 2005 (CET)<br />
<br />
----<br />
<br />
''To set the thresholds for starting and stopping battery charging (in percent of current capacity):''<br />
<br />
'''current''' really? That'd be weird, I'd expect it to be percent of '''total''' capacity.<br />
<br />
--[[User:Micampe|Micampe]] 14:39, 7 Dec 2005 (CET)<br />
<br />
"Current full charge capacity", as opposed to "current remaining capacity" or "designed full charge capacity"...<br />
<br />
--[[User:Thinker|Thinker]] 15:05, 7 Dec 2005 (CET)<br />
----<br />
<br />
Battery features don't work with my T41p. I can't check this with windows. Can anybody try these features?<br />
<br />
-- Nils, 7 Dec 2005<br />
----<br />
<br />
Nils, does cdrom_speed work for you on the T41p? Could you provide the details requested in the README (dmesg etc.)?<br />
<br />
--[[User:Thinker|Thinker]] 21:57, 7 Dec 2005 (CET)<br />
----<br />
<br />
CDRom Speed seems to work. (I see no warnings, but I have to do a speed test.) Now, I've send all outputs to the email-address in the readme.<br />
<br />
-- Nils, 8 Dec 2005<br />
----<br />
<br />
All the features except the stop_charge_thresh seem to work here on a t42p. <br />
One note, the start_charge_thresh seems to really be stop_charge_thresh. Ie, If I set that to lower than my current battery %, it will never charge, <br />
and if I set it to 100 the battery charges all the way. <br />
<br />
--[[User:Nirik|Nirik]] 16 Dec 2005<br />
----<br />
<br />
Nirik, "all the features" as of which version? For example, do the force_discharge{1,2} in tp_smapi 0.12 also work for you? See the table in the article page. About start_charge, that's odd. Can you send me a log of what you did, what was the result a what was the dmesg output for each operation?<br />
<br />
--[[User:Thinker|Thinker]] 14:16, 16 Dec 2005 (CET)<br />
----<br />
<br />
System T40p:<br />
<br />
<pre><br />
fairlight:/sys/devices/platform/smapi/BAT0# echo 1 > /sys/devices/platform/smapi/BAT0/force_discharge1<br />
fairlight:/sys/devices/platform/smapi/BAT0# echo 1 > /sys/devices/platform/smapi/BAT0/force_discharge2<br />
fairlight:/sys/devices/platform/smapi/BAT0# dmesg <br />
tp_smapi: req_in: BX=2118 CX=100 DI=0 SI=0<br />
tp_smapi: req_out: AX=8680 BX=2118 CX=100 DX=b2 DI=0 SI=0 ret=-38<br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=2118)<br />
tp_smapi: cannot get force_discharge1 of battery 0: Function is not supported by SMAPI BIOS<br />
tp_smapi: req_in: BX=2104 CX=100 DI=0 SI=0<br />
tp_smapi: req_out: AX=80 BX=2103 CX=100 DX=78 DI=0 SI=0 ret=0<br />
tp_smapi: cannot get force_discharge2 of battery 0: bx=2103<br />
</pre><br />
<br />
So it seems force_discharge1 is not supported at all. But force_discharge2? By the way, i think wiki is a _very_ good idea for collecting information, but not for discussion. I would prefer a maillinglist. We can use sourceforge.<br />
<br />
--[[User|StefanSchmidt]]<br />
<br />
force_discharge2 is indicating a real error condition (bx=2103 which has bit 0x02 on), but I have no idea what the error is or how to fix it. Sorry. If you can trigger this function under Windows and have SoftICE or equivalent, maybe it can be worked out.<br />
<br />
About the Wiki discussion, I'm not sure a mailing list is justified yet, but you can use the linux-thinkpad list or the e-mail address in the README. <br />
<br />
--[[User:Thinker|Thinker]] 21:42, 16 Dec 2005 (CET)<br />
<br />
OK, then i use linux-thinkpad to get more people involved. I'am away the next weeks, but i hope to find some time to hacking on tp_smapi.<br />
<br />
--[[User:StefanSchmidt]]<br />
----<br />
<br />
Someone reported cd_speed works on T42 but on mine, it doesn't: this is 2378DXU<br />
<br />
--[[User:eBug]] 22:55, 17 Dec 2005 (CET)<br />
----<br />
<br />
eBug, how does it fail? If the file doesn't exist, it means you didn't enable PROVIDE_CD_SPEED (see the README). If it does exist, can you provide the dmesg output when you read an write to the file?<br />
<br />
--[[User:Thinker|Thinker]] 11:53, 18 Dec 2005 (CET)<br />
----<br />
<br />
To confirm:<br />
tp_smapi 0.13 works with hdaps module loaded on T41 (2373-8RG). However, force_discharge*, inhibit_charge_minutes, start_charge_thresh, stop_charge_thresh don't seem to be implemented on this model.<br />
<br />
--[[User:LJSBRokken|LJSBrokken]] 21 Dec 2005<br />
----<br />
<br />
tp_smapi version 0.13 with T23 (2647-3QG) (I have dual batteries)...<br />
<br />
None of the functions which make any changes work...<br />
<br />
<pre># cd /sys/devices/platform/smapi && cat BAT*/* > /dev/null<br />
cat: BAT0/force_discharge1: Function not implemented<br />
cat: BAT0/force_discharge2: Input/output error<br />
cat: BAT0/inhibit_charge_minutes: Function not implemented<br />
cat: BAT0/start_charge_thresh: Function not implemented<br />
cat: BAT0/stop_charge_thresh: Function not implemented<br />
cat: BAT1/force_discharge1: Function not implemented<br />
cat: BAT1/force_discharge2: Input/output error<br />
cat: BAT1/inhibit_charge_minutes: Function not implemented<br />
cat: BAT1/start_charge_thresh: Function not implemented<br />
cat: BAT1/stop_charge_thresh: Function not implemented</pre><br />
<br />
However, all the battery status information is available, and functions appear for both BAT0 and BAT1, regardless of when the UltraBay battery was inserted or ejected- this is very useful, it is the only way I can monitor my UltraBay battery unless it was present on boot.<br />
<br />
--[[User:SystemParadox|SystemParadox]] 21:51, 4 Jan 2006 (CET)<br />
----<br />
<br />
SystemParadox, what's the dmesg output produced by "cat BAT0/force_discharge2"?<br />
<br />
--[[User:Thinker|Thinker]] 22:02, 4 Jan 2006 (CET)<br />
----<br />
<br />
After the upgrade to 0.14 (with kernel 2.6.15, using the patch) I can't use inhibit_charge and start/stop_charge_thresh any longer (getting an input/output error), the dmesg debug output when {{cmd|cat|}}-ing those three files:<br />
<br />
<pre><br />
tp_smapi: tp_smapi 0.14 loading...<br />
tp_smapi: successfully loaded (smapi_port=0xb2).<br />
tp_smapi: req_in: BX=2114 CX=100 DI=0 SI=0<br />
tp_smapi: req_out: AX=ea210080 BX=ec192114 CX=c18d0700 DX=f7cc00b2 DI=f7f50000 SI=c18d0000 ret=-5<br />
tp_smapi: SMAPI error: Unknown error code (func=2114)<br />
tp_smapi: cannot get inhibit charge of battery 0: Unknown error code<br />
tp_smapi: req_in: BX=2116 CX=100 DI=0 SI=0<br />
tp_smapi: req_out: AX=c03b0080 BX=c18d2116 CX=c0160328 DX=ec7600b2 DI=ec760000 SI=a0810000 ret=-5<br />
tp_smapi: SMAPI error: Unknown error code (func=2116)<br />
tp_smapi: cannot get start thresh of battery 0: Unknown error code<br />
tp_smapi: req_in: BX=211a CX=100 DI=0 SI=0<br />
tp_smapi: req_out: AX=c03b0080 BX=c18d211a CX=c016032c DX=eb4500b2 DI=eb450000 SI=241e0000 ret=-5<br />
tp_smapi: SMAPI error: Unknown error code (func=211a)<br />
tp_smapi: cannot get stop thresh of battery 0: Unknown error code<br />
</pre><br />
<br />
--[[User:Spiney|spiney]] 08:12, 10 Jan 2006 (CET)<br />
----<br />
<br />
Oops, the transition to 32-bit SMAPI calls was broken. Fixed in 0.15. Thanks for the quick report!<br />
<br />
--[[User:Thinker|Thinker]] 12:10, 10 Jan 2006 (CET)<br />
----<br />
<br />
Yep, 0.15 works again. Quick response, bravo! :)<br />
<br />
--[[User:Spiney|spiney]] 12:23, 10 Jan 2006 (CET)<br />
----<br />
<br />
On a T22, nothing seems to work with 0.16.<br />
<br />
[[http://www.rafb.net/paste/results/fcUUDs49.html|dmesg output]] when doing cat *<br />
<br />
I am using an Ultrabay2000 battery, so it would be really usefull to be able to control that<br />
<br />
--[[User:nusse|nusse]]<br />
----<br />
<br />
Nusse: Not even the extended battery status? That does work on T23. About the control features, I believe they're not available on the T23; did you have any kind of (dis)charge control under WindowS?<br />
<br />
--[[User:Thinker|Thinker]] 20:59, 11 Jan 2006 (CET)<br />
----<br />
<br />
I don't really know what 'extended battery' status means, but here an example:<br />
<pre><br />
$ cat current_* /sys/devices/platform/smapi/BAT1<br />
cat: current_avg: Input/output error<br />
cat: current_now: Input/output error<br />
</pre><br />
This is what happens when i cat any file in this directory and also in ../BAT1 :(<br />
<br />
--[[User:nusse|nusse]] Thu Jan 12 22:07:26 CET 2006<br />
----<br />
<br />
Nusse: Yes, that's what I meant. What's the {{cmdroot|dmesg}} output generated by these commands?<br />
<br />
--[[User:Thinker|Thinker]] 00:27, 13 Jan 2006 (CET)<br />
----<br />
<br />
<br />
Thinker: I attached some link to my first comment but it seems to be down and the link was wrong anyway.<br />
<pre><br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=2118)<br />
tp_smapi: cannot get force_discharge of battery 0: Function is not supported by SMAPI BIOS<br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=2114)<br />
tp_smapi: cannot get inhibit charge of battery 0: Function is not supported by SMAPI BIOS<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=2116)<br />
tp_smapi: cannot get start thresh of battery 0: Function is not supported by SMAPI BIOS<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=211a)<br />
tp_smapi: cannot get stop thresh of battery 0: Function is not supported by SMAPI BIOS<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
thinkpad controller read(%hx,%hx): failed writing to 0x1610<br />
</pre><br />
<br />
--[[User:nusse|nusse]] Fri Jan 13 14:35:57 CET 2006<br />
----<br />
<br />
Nusse: Thanks; but there's not much we can do. Maybe the T22 uses a different interface, or doesn't have that feature.<br />
<br />
--[[User:Thinker|Thinker]] 23:23, 15 January 2006 (CET)<br />
----<br />
<br />
Thinker: Is there anything I can do to check if the interface is different? Changing 0x1610 to some random number?<br />
<br />
Is there a chance to get it by try and error?<br />
<br />
--[[User:nusse|nusse]] Mon Jan 16 19:10:12 CET 2006<br />
----<br />
<br />
0x1610 is the number of an IO port it writes to, so changing it to a random number will pretty much guarantee a system crash...<br />
<br />
The only way I can think of for figuring out the T22 interface is to see what the Windows software does.<br />
<br />
--[[User:Thinker|Thinker]] 19:47, 16 January 2006 (CET)<br />
----<br />
<br />
I have a R40 (2722-B3G), and several things don't work with 0.16 on linux 2.6.15.1:<br />
<br />
<pre><br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=2118)<br />
tp_smapi: cannot get force_discharge of battery 0: Function is not supported by SMAPI BIOS<br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=2114)<br />
tp_smapi: cannot get inhibit charge of battery 0: Function is not supported by SMAPI BIOS<br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=2116)<br />
tp_smapi: cannot get start thresh of battery 0: Function is not supported by SMAPI BIOS<br />
tp_smapi: SMAPI error: Function is not supported by SMAPI BIOS (func=211a)<br />
tp_smapi: cannot get stop thresh of battery 0: Function is not supported by SMAPI BIOS<br />
</pre><br />
<br />
Don't know about Windows, haven't booted it for weeks nor used it for years...<br />
<br />
--[[User:Wonka|Wonka]] 19:00, 19 January 2006 (CET)<br />
----<br />
<br />
Wonka: do the other features (i.e., extended battery status) work on your R40?<br />
<br />
--[[User:Thinker|Thinker]] 20:30, 20 January 2006 (CET)<br />
----<br />
<br />
--[[User:lisch|lisch]] 16:14, 11 April 2006 (CDT)<br />
<br />
On my X32, with two batteries, I get just what I expect. Looks good:<br />
<pre>$ cat BAT?/* > /dev/null<br />
cat: BAT0/force_discharge: Function not implemented<br />
cat: BAT0/inhibit_charge_minutes: Function not implemented<br />
cat: BAT0/start_charge_thresh: Function not implemented<br />
cat: BAT0/stop_charge_thresh: Function not implemented<br />
cat: BAT1/force_discharge: Function not implemented<br />
cat: BAT1/inhibit_charge_minutes: Function not implemented<br />
cat: BAT1/start_charge_thresh: Function not implemented<br />
cat: BAT1/stop_charge_thresh: Function not implemented<br />
$<br />
</pre><br />
==Changing the CD speed when the CD is being accessed will hang your computer==<br />
<br />
I don't have this problem on my T40p. CDROM is mounted and file on CD is opened. Change speed do '''not''' hang my system.<br />
<br />
-- Stefan Schmidt<br />
----<br />
<br />
An open file looks fine if you're not reading/writing at that point. But my T43 does hangs on this:<br />
# dd if=/dev/scd0 of=/dev/null &<br />
# echo 1 > /sys/devices/platform/smapi/cdrom_speed<br />
<br />
--[[User:Thinker|Thinker]] 16:41, 7 Dec 2005 (CET)<br />
----<br />
<br />
OK, sorry. I was to fast. My system hangs on this commands, too. :(<br />
<br />
-- Stefan Schmidt<br />
<br />
Works well. Great.<br />
<br />
T42 2373-8zh. Working :cdrom_speed and start_charge_thresh. Untest : inhibit_charge_minutes.<br />
<br />
-- Haifeng Chen<br />
<br />
cdrom_speed works on my T40.<br />
<br />
-- [[User:Lammic|lammic]], 2005.12.09<br />
<br />
== Kernel Patch? ==<br />
<br />
Hello Thinker,<br />
<br />
would it be possible to provide the SMAPI support as kernel patch as well? Something along the lines of: (0.12 against 2.6.15-rc5)<br />
<br />
''(deleted, see below for how to create a patch file)''<br />
<br />
Deleted the tp_smapi.c file at the end, out of obvious reasons, and I'm not sure about the placement in the ACPI section, OTOH there it would be found easily next to ibm_acpi.<br />
<br />
Providing a patch would help when recompiling the kernel often, I hate recompiling external modules every time (even got me a kernel-upgrade script to do most of it automatically). But of course it's up to you. :)<br />
<br />
--[[User:Spiney|spiney]] 09:52, 16 Dec 2005 (CET)<br />
----<br />
<br />
I'll be glad to add this, but I don't want to go through additional manual steps in the release process (there are already quite a few). Can you add a "make patch" functionality to the Makefile, or something of the sort, to automatically generate a full patch (including tp_smapi.c) against current kernel sources?<br />
<br />
Also, this shouldn't be under drivers/acpi, since it doesn't use ACPI at all (that's why I didn't make it a patch to ibm_acpi). I think the right place is drivers/firmware, like the dell_rbu driver for Dell laptops.<br />
<br />
BTW, the convention for kernel patches is to start them once level higher:<br />
diff -Nurp kernel-2.6.14-vanilla kernel-2.6.14-patched<br />
<br />
--[[User:Thinker|Thinker]] 17:12, 16 Dec 2005 (CET)<br />
----<br />
<br />
Of course it's from the wrong level, as usual I was just lazy/inattentive. And at one point I'll remember who likes what patch format, promise. ;)<br />
<br />
A patch target as in "create a new file holding a correct diff to current kernel source" would be rather difficult, since line numbers might change etc., but applying the patch should be straighforward with a bit of sed. Of course I could just do that, create a patch with the diff command and then apply the new patch file in reverse. ;)<br />
<br />
--[[User:Spiney|spiney]] 18:36, 16 Dec 2005 (CET)<br />
----<br />
<br />
If it does that on a local copy (no changes the original kernel tree) and cleans up after itself, that's fine with me. :-)<br />
<br />
--[[User:Thinker|Thinker]] 18:50, 16 Dec 2005 (CET)<br />
----<br />
<br />
Ok, here's a shell script that creates the patch, feel free to use it under the terms of the GPL. For example call it from your Makefile with the patch target: (I didn't want to put all the script into the Makefile, since the rules about escaping in Makefiles, well, escape me ;)<br />
<br />
<pre><br />
#!/bin/bash<br />
<br />
KDIR=/lib/modules/$(uname -r)/build<br />
FDIR=drivers/firmware<br />
OPWD=$(pwd)<br />
<br />
TMPDIR=$(mktemp -d)<br />
cd $TMPDIR<br />
<br />
mkdir -p a/$FDIR<br />
cp $KDIR/$FDIR/{Kconfig,Makefile} a/$FDIR<br />
cp -r a b<br />
sed -i -e '/endmenu/i\<br />
config IBM_SMAPI\<br />
tristate "IBM ThinkPad SMAPI Support"\<br />
depends on X86\<br />
---help---\<br />
This adds SMAPI support on IBM ThinkPads, mostly used for battery\<br />
charge control. For more information about this driver see\<br />
<http://www.thinkwiki.org/wiki/SMAPI_support_for_Linux> .\<br />
\<br />
If you have an IBM ThinkPad laptop, say Y or M here.\<br />
' b/$FDIR/Kconfig<br />
sed -i -e '$a\<br />
obj-$(CONFIG_IBM_SMAPI) += tp_smapi.o' b/$FDIR/Makefile<br />
cp $OPWD/tp_smapi.c b/$FDIR<br />
diff -Nurp a b > $OPWD/tp_smapi-$(uname -r).patch<br />
rm -r a b<br />
cd $OPWD<br />
</pre><br />
<br />
BTW, [http://qbnz.com/highlighter/ GeSHi]-based syntax-highlighting would be great...<br />
<br />
--[[User:Spiney|spiney]] 19:28, 16 Dec 2005 (CET)<br />
----<br />
<br />
Ah, neat sed foo. How about [http://tpctl.sourceforge.net/tmp/Makefile this] escapade, then? <br />
<br />
What's the sed spell needed to replace the Makefile's<br />
VER := 0.13<br />
with auto-parsing of<br />
#define TP_VERSION "0.13"<br />
from tp_smapi.c?<br />
<br />
--[[User:Thinker|Thinker]] 20:37, 16 Dec 2005 (CET)<br />
----<br />
<br />
Hmm, something like<br />
VERFROMC=$(sed -ne 's/^#define TP_VERSION "\(.*\)"/\1/gp' tp_smapi.c)<br />
sed -i -e "s/^VER := .*$/VER := $VERFROMC/" Makefile<br />
should do (untested, from the top of my head, maybe the temporary variable isn't even necessary?). And neat Makefile wizardry, at one point I'll learn the syntax.<br />
<br />
--[[User:Spiney|spiney]] 20:44, 16 Dec 2005 (CET)<br />
----<br />
<br />
Makefile escaping is horrible, keep avoiding it... Anyway, the updated [http://tpctl.sourceforge.net/tmp/Makefile make patch] seems to do the right thing.<br />
<br />
--[[User:Thinker|Thinker]] 21:36, 16 Dec 2005 (CET)<br />
----<br />
<br />
Small documentation request: just needed to create a patch for the not-yet-installed 2.6.16-rc2, which is no problem with<br />
make KSRC=/path/to/linux-2.6.16-rc2 KVER=2.6.16-rc2 patch<br />
but I guess it would be a good addition to the README file. :)<br />
<br />
--[[User:Spiney|spiney]] 10:48, 8 February 2006 (CET)<br />
----<br />
<br />
Right, added (to next release).<br />
<br />
--[[User:Thinker|Thinker]] 13:40, 8 February 2006 (CET)<br />
----<br />
<br />
==Installation questions==<br />
Amazing! I've loaded this module in my T43 which is running SuSE 10 with the kernel of 2.6.13-15. I have three points to share:<br />
<br />
1. The battery control part seems to work but has a minor problem. I set the stop_charge_threshold to 70, but the battery stops charging at 55%. Don't know why and how to fix it. :P<br />
<br />
2. I don't have the cd speed control function. Here is what I have under /sys/devices/platform/smapi/:<br />
<br />
./ ../ ac_connected BAT0/ BAT1/ bus@ driver@ power/<br />
<br />
3. SuSE 10 doesn't have the necessary C files under .../drivers/hwmon/, I copied them from a 2.6.14.5 kernel source. Maybe it causes the two problems above. :(<br />
<br />
When I have time, I'll install the new kernel to see if the problems are gone and report the result.<br />
<br />
--[[User:68.51.153.96|68.51.153.96]] 04:31, 2 Jan 2006 (CET)<br />
----<br />
<br />
1. It should stop charging at 70, but will only ''start'' charging when remaining capacity has dipped below <tt>start_charge_thresh</tt>.<br />
<br />
2. See the note about PROVIDE_CD_SPEED.<br />
<br />
3. That's should be needed only for patching the HDAPS driver in order to make it compatible with tp_smapi. If your kernel (which version is it?) doens't inlude the HDAPS driver anyway, you don't need to patch....<br />
<br />
--[[User:Thinker|Thinker]] 09:28, 2 Jan 2006 (CET)<br />
----<br />
<br />
Thanks Thinker.<br />
<br />
1. I discharged and recharged the battery again. This time, it stops at 68% percent, which is pretty good.<br />
<br />
2. I missed the NOTE in README, for I just followed this wiki. :P<br />
<br />
3. My kernel version is 2.6.13-15.<br />
<br />
By the way, I just got this T43 whose model number is 266896U. I feel that the noise of the fan is much louder than my previous T21. I think it is so since it has a CPU with bigger power but am wondering if other T43 has the same big noise?<br />
<br />
--[[User:Tyne|Tyne]] 00:14, 3 Jan 2006 (CET)<br />
----<br />
<br />
The note about PROVIDE_CD_SPEED is also in the Wiki...<br />
<br />
About the T43 fan noise: yes, this is a very common (and annoying) problem. See [[Problem_with_fan_noise]] and our [[ACPI fan control script]], and send Lenovo a complaint in hope they'll fix this at the firmware level.<br />
<br />
--[[User:Thinker|Thinker]] 08:48, 3 Jan 2006 (CET)<br />
----<br />
I spent hours, trying to compile this on ubuntu edgy without success. It starts with warnings about missing files:<br />
<br />
<pre><br />
root@t40:/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31# make install<br />
make -C /lib/modules/2.6.17-11-386/source M=/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31 O=/lib/modules/2.6.17-11-386/build modules<br />
make[1]: Betrete Verzeichnis '/usr/src/linux-source-2.6.17'<br />
/usr/src/linux-source-2.6.17/Makefile:450: .config: No such file or directory<br />
<br />
WARNING: Symbol version dump /lib/modules/2.6.17-11-386/build/Module.symvers<br />
is missing; modules will have no dependencies and modversions.<br />
<br />
CC [M] /home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31/thinkpad_ec.o<br />
cc1: error: include/linux/autoconf.h: No such file or directory<br />
[...]<br />
</pre><br />
and then many thousand lines later it finally stops:<br />
<pre><br />
[...]<br />
/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31/thinkpad_ec.c:357: error: ‘CONFIG_HZ’ undeclared (first use in this function)<br />
/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31/thinkpad_ec.c: In function ‘thinkpad_ec_invalidate’:<br />
/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31/thinkpad_ec.c:378: error: ‘CONFIG_HZ’ undeclared (first use in this function)<br />
/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31/thinkpad_ec.c: In function ‘thinkpad_ec_init’:<br />
/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31/thinkpad_ec.c:460: error: ‘CONFIG_HZ’ undeclared (first use in this function)<br />
make[3]: *** [/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31/thinkpad_ec.o] Fehler 1<br />
make[2]: *** [_module_/home/bernd/Desktop/tp_smapi-0.31/tp_smapi-0.31] Fehler 2<br />
make[1]: *** [modules] Fehler 2<br />
make[1]: Verlasse Verzeichnis '/usr/src/linux-source-2.6.17'<br />
make: *** [modules] Fehler 2<br />
</pre><br />
<br />
There must be something fundamentally wrong with the makefile. I have for example never seen that a symlink has to point from /lib/modules/someversion/somewhere to /usr/src/linux. I have installed other modules in the past and they all worked with installed linux-headers package. I didn't ever have to download 40MB kernel source, unpack it, configure it to have a .config and compile the whole kernel just to have 2 or three of the other files needed. This cannot be the correct way to install a driver.<br />
<br />
[[User:7bit|7bit]] 07:42, 27 March 2007 (CEST)<br />
----<br />
<br />
== Formatting ==<br />
<br />
Wyrfel, that was some heavy editing you did... I agree with most changes (including the saner color choice). I did like those HINT floats, though - they keep the hints from interrupting the flow of text too much, and this particular text needs any help it can get.<br />
<br />
--[[User:Thinker|Thinker]] 17:04, 3 Jan 2006 (CET)<br />
----<br />
Hei Thinker,<br />
<br />
I'll look into it again. I felt that the floating HINTs were tearing the text apart too much. Maybe we could fix it by placing the clear marks somewhere else.<br />
<br />
[[User:Wyrfel|Wyrfel]] 18:46, 3 Jan 2006 (CET)<br />
----<br />
<br />
== Dual battery operation with tp_smapi ==<br />
<br />
It looks like it is working quite fine with tp_smapi-0.13 and 2.6.15 (it may also work with other versions, but those are the ones I have running right now).<br />
<br />
The juicy details:<br />
<br />
{{cmdroot|cd /sys/devices/platform/smapi/}}<br />
{{cmdroot|cat ac_connected}}<br />
<br />
{{cmdresult|0}}<br />
{{cmdroot|cat BAT{0,1}/state}}<br />
{{cmdresult|discharging}}<br />
{{cmdresult|idle}}<br />
<br />
{{cmdroot|echo 1 > BAT1/force_discharge1}}<br />
{{cmdroot|cat BAT{0,1}/state}}<br />
{{cmdresult|idle}}<br />
{{cmdresult|discharging}}<br />
<br />
Checking capacity values shows that the corrent battery is being depleted.<br />
<br />
And remember, before you yank the CD/DVD drive out, issue:<br />
<br />
{{cmdroot|cat eject > /proc/acpi/ibm/bay}}<br />
<br />
----<br />
<br />
Great! Which ThinkPad model is it? Could you also {{cmdroot|cat /sys/devices/platform/smapi/BAT{0,1}/force_discharge2}} and report the dmesg output (after {{cmdroot|make load}} or {{cmdroot|1=modprobe tp_smapi debug=1}})?<br />
<br />
About the eject command, I think it should be possible to do that automatically when the Ultrabay handle is ejected, via <tt>acpid</tt>.<br />
<br />
--[[User:Thinker|Thinker]] 15:45, 10 Jan 2006 (CET)<br />
----<br />
<br />
It's a T43 (2669). cat'ing force_discharge2 gives me an I/O error and I see<br />
<br />
tp_smapi: cannot get force_discharge2 of battery 0: bx=2103<br />
<br />
tp_smapi: cannot get force_discharge2 of battery 1: bx=2103<br />
<br />
I find these errors irrelevant from the user's point of view, though. <br />
<br />
Indeed, it should be possible to automatise the "eject" command. I should also be noted that once a force_discharge1 is set, it will NOT unset automatically, event when the AC is plugged back in. An obvious fix is to fiddle with the appropriate ACPI event to force_discharge1 back to 0 for all batteries once the AC is attached.<br />
<br />
----<br />
<br />
Thanks, this eliminates the last situation I imagined <tt>force_discharge2</tt> might work. The next tp_smapi version will remove <tt>force_discharge2</tt> and rename <tt>force_discharge1</tt> to <tt>force_discharge</tt>.<br />
<br />
If you write those ACPI scripts, it would be great if you put them on the Wiki.<br />
<br />
--[[User:Thinker|Thinker]] 16:31, 10 Jan 2006 (CET)<br />
----<br />
<br />
Well, I still do not preclude the fact that <tt>force_discharge2</tt> may be useful for something else on other models.<br />
<br />
The ACPI scripts (as well as an installation guide) is underway. It may take a while, though.<br />
<br />
----<br />
<br />
See the new article: [[Using an Ultrabay battery]].<br />
<br />
--[[User:Thinker|Thinker]] 17:05, 10 Jan 2006 (CET)<br />
----<br />
<br />
Hei Thinker,<br />
<br />
i just renamed the new page. Will adjust your links later on. Keeping the redirect page until that's done. Please set any new links you create to the new page (the pages of the individual UltraBay batteries should contain a pointer).<br />
<br />
On a sidenote: I would like to split the SMAPI support under Linux page into a tp_smapi driver page, just listing the features, and a "How to use tp_smapi" page. I would also split the thinkpad/tpctl page off that again. Any objections?<br />
<br />
[[User:Wyrfel|Wyrfel]] 20:42, 10 Jan 2006 (CET)<br />
----<br />
<br />
ACK about the page rename (the old one did sound a bit out of line to my ear, but I couldn't spot why...).<br />
<br />
About the splitting tp_smapi vs. thinkpad/tpctl, no objection.<br />
<br />
About splitting tp_smapi: currently most of that section doubles as both a spec and a HOWTO, which I think is a convenient and concise way to describe things (hey, it must be right, the Perl docs do it!). I'm not sure there's much benefit in duplicating that. Perhaps we should wait for a critical mass of additional lore to accumulate?<br />
<br />
--[[User:Thinker|Thinker]] 21:04, 10 Jan 2006 (CET)<br />
----<br />
Ok, i agree on the latter.<br />
<br />
[[User:Wyrfel|Wyrfel]] 00:57, 11 Jan 2006 (CET)<br />
----<br />
<br />
==Article name capitalization== <br />
<br />
Wikimedia autocapitalizes the article name upon submit. How do I concince Wikimedia that I really want a lowercase "t"? The underline is probably too much too ask...<br />
<br />
--[[User:Thinker|Thinker]] 11:03, 11 Jan 2006 (CET)<br />
----<br />
<br />
Impossible, according to [http://en.wikipedia.org/wiki/Wikipedia:Canonicalization Wikipedia:Canonicalization].<br />
<br />
--[[User:Thinker|Thinker]] 12:04, 11 Jan 2006 (CET)<br />
----<br />
<br />
==Status Table==<br />
For at least the T series i think that charge control was not supported prior to the T42, hardware/BIOS side. Perhaps "N/A" flags would be better here?<br />
<br />
I also created <nowiki>{{Isup}}</nowiki> style templates for status, they just include images, like {{Isup}}.<br />
Not emotional about it, just wanted to let you know in case you want to use them.<br />
<br />
Third and last...would it possibly be better to make the table headers more human readable like i.e. "lower charge threshold" or something like that instead of "start_charge_thresh"?<br />
<br />
[[User:Wyrfel|Wyrfel]] 19:21, 11 Jan 2006 (CET)<br />
----<br />
<br />
About "N/A", sure, if we get reliable data about the hardware capabilities. Alas, most negative reports were just "it doesn't work", and in some cases gave contradictory information (SMAPI interface says a function is unsupported but user says it works under Windows).<br />
<br />
About {{Iyes}} and friends, they're very cute, but I think think they're harder to parse visually and would add some clutter to an already dense table.<br />
<br />
The table headers are just the names of the control files - that's important to keep, sine it's the most natural lookup key. Adding friendly description would be great, if we can fit them in (not everyone has an SXGA+ display...). I tried and failed.<br />
<br />
--[[User:Thinker|Thinker]] 20:38, 11 Jan 2006 (CET)<br />
----<br />
<br />
I have a T41p and the windows tools still don't offer me battery management, even though it's quite a while since the T42 came out.<br />
<br />
I'm ok with the rest.<br />
<br />
[[User:Wyrfel|Wyrfel]] 22:35, 11 Jan 2006 (CET)<br />
----<br />
<br />
For the {{X40}}, I can report success using the stop_charge_thresh feature with BIOS v2.03 (1UETC8WW) and Embedded Controller Program v1.60 (1UHTB0WW).<br />
<br />
[[User:Peterco|Peterco]] 12:07, 28 February 2006 (CET)<br />
----<br />
<br />
== Z60t ==<br />
<br />
Tested on Z60t. No errors using cat. Setting thresholds works. Status and capacity queries work. --[[User:Alon|Alon]] 21:44, 4 May 2006 (CEST)<br />
<br />
== Problem setting thresholds with X40 ==<br />
<br />
My X40, kernel 2.6.16 and tp_smapi 0.20. I try to set the thresholds to 40% and 90% using:<br />
<pre><br />
# echo 90 > stop_charge_thresh<br />
# echo 40 > start_charge_thresh<br />
</pre><br />
which should work, and the kernel reports from dmesg:<br />
<pre><br />
tp_smapi: successfully loaded (smapi_port=0xb2).<br />
tp_smapi: battery 0: changed start threshold to 85(+1)<br />
tp_smapi: battery 0: changed stop threshold to 90<br />
tp_smapi: battery 0: changed start threshold to 39(+1)<br />
</pre><br />
but, on confirmation here is what happens:<br />
<pre><br />
# cat stop_charge_thresh<br />
90<br />
# cat start_charge_thresh<br />
91<br />
</pre><br />
Any clues as to why start doesn't keep? Or why its always at 1 above stop_charge_thresh?<br />
<br />
--[[User:Xmm0|Xmm0]] 15:01, 17 May 2006 (CEST)<br />
----<br />
<br />
Is it any different if you first set start_charge_thresh and then stop_charge_thresh? <br />
<br />
Can you please load tp_smapi with module option "debug=1" and report the dmesg output genereated by each command?<br />
<br />
--[[User:Thinker|Thinker]] 16:31, 17 May 2006 (CEST)<br />
----<br />
<br />
== Battery daemon feedback requested ==<br />
<br />
I am writing a battery-management daemon to control charging and discharging BAT0 and BAT1 in accordance with usage patterns that extend Li-Ion and Li-Py battery life.<br />
<br />
By default, the machine fully discharges BAT1 first, and it is said that deep-cycling all the time dramatically shortens their lifetime.<br />
<br />
My Z61t is the test machine, and it is configured with two batteries, the stock 4-cell, and an "Advanced Ultrabay", which about doubles the runtime of the machine.<br />
<br />
Currently there are two "modes" of the daemon:<br />
<br />
Discharging mode.<br />
<pre><br />
* look at the "remaining_percent" values for both batteries<br />
* if one is more than THRESHOLD percent less than the other one, <br />
force discharge from the battery with more capacity left<br />
(the current value for THRESHOLD is 10%)<br />
</pre><br />
I believe the preceeding will prevent either battery from being deep-cycled disproportionately.<br />
<br />
Charging mode. I am less sure what the "right" algorithm is here. The following is a proposal.<br />
<pre><br />
* look at the "remaining_percent" values for both batteries<br />
* if one is more than THRESHOLD percent less than the other one, <br />
force charging to the battery with less capacity left<br />
* honor pre-set values in stop_charge_thresh and start_charge_thresh<br />
</pre><br />
<br />
I would like to get feedback in the form of "better" algorithms or requests for this daemon.<br />
<br />
--[[User:Zak Smith|Zak]] 19:03, 12 September 2006 (CEST)<br />
<br />
It sounds like your algorithm will indeed minimize wear on both batteries. A side benefit is that charging will toggle between the batteries, which may help keep them cooler while charging and thus prolong their life. OTOH, if you plan to occasionally swap the UltraBay battery for other devices, you may want to fully charge the system battery (up to stop_charge_thresh) first.<br />
<br />
--[[User:Thinker|Thinker]] 22:57, 12 September 2006 (CEST)<br />
<br />
<br />
I have noticed that when force_discharge is set and the batteries switch, the gnome battery monitoring applet gets totally confused about remaining runtime. Besides being a nuisance, this could presumably cause premature emergency shutduwn.<br />
<br />
I have also noticed that the reported remaining runtimes vary greatly between acpi, the applet, and /proc/acpi/battery/*/state<br />
<br />
--[[User:Zak Smith|Zak]] 21:46, 14 September 2006 (CEST)<br />
<br />
What do you mean by "acpi" vs. "/proc/acpi/battery/*/state"? <br />
<br />
The most accurate readout is probably {{path|/sys/devices/platform/smapi/BAT0/remaining_running_time}}, but I don't think any applet uses that yet.<br />
<br />
--[[User:Thinker|Thinker]] 12:07, 15 September 2006 (CEST)<br />
<br />
By acpi, I meant the output of the acpi (1) command. I'll get some comparative numbers later and post them here.<br />
<br />
--[[User:Zak Smith|Zak]] 20:37, 15 September 2006 (CEST)<br />
<br />
Odd, my version of {{path|/usr/bin/acpi}} doesn't report remaining time, just percent (which is the same as {{path|/sys/devices/platform/smapi/BAT0/remaining_percent}}).<br />
<br />
--[[User:Thinker|Thinker]] 21:32, 15 September 2006 (CEST)<br />
<br />
I have been running batteryd for a while with good results. I will upload it here shortly.<br />
<br />
I disabled the preferential charging mode, and only control discharging.<br />
<br />
--[[User:Zak Smith|Zak]] 23:15, 14 November 2006 (CET)<br />
<br />
http://demigod.org/~zak/src/batteryd.cc<br />
<br />
--[[User:Zak Smith|Zak]] 20:18, 5 December 2006 (CET)<br />
<br />
== Instructions for X60 with Bios 1.11 under Debian Etch ==<br />
<br />
Could someone please provide step-by-step instructions of how to make this work with Debian? What have I to do after apt-get install kernel-patch-tpsmapi? Thank you!<br />
<br />
--[[User:PeterBursch|PeterBursch]] 21:39, 15 September 2006 (CEST)<br />
<br />
== tp_smapi 0.30 with kernel 2.6.20? ==<br />
<br />
<pre>T60:~/tp_smapi-0.30# uname -rm<br />
2.6.20 x86_64<br />
<br />
T60:~/tp_smapi-0.30# make load<br />
if lsmod | grep -q '^hdaps '; then rmmod hdaps; fi<br />
if lsmod | grep -q '^tp_smapi '; then rmmod tp_smapi; fi<br />
if lsmod | grep -q '^thinkpad_ec '; then rmmod thinkpad_ec; fi<br />
if lsmod | grep -q '^tp_base '; then rmmod tp_base; fi # old thinkpad_ec<br />
make -C /lib/modules/2.6.20/source M=/root/tp_smapi-0.30 O=/lib/modules/2.6.20/build modules<br />
make[1]: Entering directory `/usr/src/linux-2.6.20'<br />
CC [M] /root/tp_smapi-0.30/thinkpad_ec.o<br />
/root/tp_smapi-0.30/thinkpad_ec.c:83: warning: type defaults to 'int' in declaration of 'DECLARE_MUTEX'<br />
/root/tp_smapi-0.30/thinkpad_ec.c:83: warning: parameter names (without types) in function declaration<br />
/root/tp_smapi-0.30/thinkpad_ec.c: In function 'thinkpad_ec_lock':<br />
/root/tp_smapi-0.30/thinkpad_ec.c:94: warning: implicit declaration of function 'down_interruptible'<br />
/root/tp_smapi-0.30/thinkpad_ec.c:94: error: 'thinkpad_ec_mutex' undeclared (first use in this function)<br />
/root/tp_smapi-0.30/thinkpad_ec.c:94: error: (Each undeclared identifier is reported only once<br />
/root/tp_smapi-0.30/thinkpad_ec.c:94: error: for each function it appears in.)<br />
/root/tp_smapi-0.30/thinkpad_ec.c: In function 'thinkpad_ec_try_lock':<br />
/root/tp_smapi-0.30/thinkpad_ec.c:109: warning: implicit declaration of function 'down_trylock'<br />
/root/tp_smapi-0.30/thinkpad_ec.c:109: error: 'thinkpad_ec_mutex' undeclared (first use in this function)<br />
/root/tp_smapi-0.30/thinkpad_ec.c: In function 'thinkpad_ec_unlock':<br />
/root/tp_smapi-0.30/thinkpad_ec.c:122: warning: implicit declaration of function 'up'<br />
/root/tp_smapi-0.30/thinkpad_ec.c:122: error: 'thinkpad_ec_mutex' undeclared (first use in this function)<br />
make[3]: *** [/root/tp_smapi-0.30/thinkpad_ec.o] Error 1<br />
make[2]: *** [_module_/root/tp_smapi-0.30] Error 2<br />
make[1]: *** [modules] Error 2<br />
make[1]: Leaving directory `/usr/src/linux-2.6.20'<br />
make: *** [modules] Error 2<br />
</pre><br />
<br />
:Works here with 2.6.21-rc1 (didn't try 2.6.20) without problems --[[User:Zhenech|Zhenech]] 14:32, 22 February 2007 (CET)<br />
<br />
:I have this problem when compiling for x86_64 too. It seems to be limited to 64bit kernels though. I've notified the author of tp_smapi about it, so lets hope a solution is found soon. --[[User:Esmil|Esmil]] 20:08, 6 March 2007 (CET)<br />
<br />
The author was happy about the report, but didn't have time too look at it right now, so I thought I'd give it my best shot. Apparently I should have done that sooner, cause this seems to fix it (for me at least):<br />
<pre><br />
diff -Naur tp_smapi-0.30/hdaps.c tp_smapi-0.30-64bit_fix/hdaps.c<br />
--- tp_smapi-0.30/hdaps.c 2006-09-03 12:13:34.000000000 +0200<br />
+++ tp_smapi-0.30-64bit_fix/hdaps.c 2007-03-07 00:43:26.000000000 +0100<br />
@@ -34,6 +34,7 @@<br />
#include <linux/timer.h><br />
#include <linux/dmi.h><br />
#include <linux/thinkpad_ec.h><br />
+#include <linux/jiffies.h><br />
<br />
/* Embedded controller accelerometer read command and its result: */<br />
static const struct thinkpad_ec_row ec_accel_args =<br />
diff -Naur tp_smapi-0.30/thinkpad_ec.c tp_smapi-0.30-64bit_fix/thinkpad_ec.c<br />
--- tp_smapi-0.30/thinkpad_ec.c 2006-09-02 21:46:18.000000000 +0200<br />
+++ tp_smapi-0.30-64bit_fix/thinkpad_ec.c 2007-03-07 00:43:13.000000000 +0100<br />
@@ -34,6 +34,7 @@<br />
#include <linux/delay.h><br />
#include <linux/thinkpad_ec.h><br />
#include <linux/jiffies.h><br />
+#include <asm/semaphore.h><br />
#include <asm/io.h><br />
<br />
#define TP_VERSION "0.30"<br />
</pre><br />
Copy the above to {{path|64bit_fix.patch}}, enter the {{path|tp_smapi-0.30}} directory and type<br />
:{{cmduser|patch -p1 < /path/to/64bit_fix.patch}}<br />
Now cross your fingers and compile as normal.<br />
--[[User:Esmil|Esmil]] 01:06, 7 March 2007 (CET)<br />
: tp_smapi 0.31 fixes this issue --[[User:Esmil|Esmil]] 19:22, 8 March 2007 (CET)<br />
<br />
== X60: tp_smapi 0.31 with kernel 2.6.20 issue ==<br />
[[category:X60]]<br />
1st of all: Thanks alot for your work. I do really appreciate this (tp_smapi/thinkwiki).<br />
<br />
2nd: On a Debian (testing) w/ vanilla 2.6.20+tp_smapi+hdaps (w/ modules loaded) the kernel panics (init oops) on reboot just before resetting the system. It has a minor impact, you need to press power-off for 5 secs to switch off the machine. Just FYI.<br />
<br />
--[[User:Runia|Runia]] 23:48, 16 April 2007 (CEST)<br />
<br />
Is this consistently reproducible? What's the oops message and stackdump (you can snap a digicam shot)? Does this happen when...<br />
* rebooting with tp_smapi loaded but hdaps not loaded?<br />
* rebooting with neither tp_smapi nor hdaps loaded?<br />
* rebooting with vanilla hdaps loaded (instead of the tp_smapi version)?<br />
* removing just these modules ("rmmod") instead of rebooting?<br />
<br />
--[[User:Thinker|Thinker]] 01:56, 17 April 2007 (CEST)<br />
----<br />
<br />
== battery start/stop thresholds saved after reboot? ==<br />
<br />
Hi<br />
<br />
Are the values in stop_charge_thresh and start_charge_thresh just used when Linux is running, or are they saved in the battery? Here after a reboot the values are reset to 96/100. I set these values to 40/85 shut the thinkpad down and charged the battery - sadly it did not use the 85% setting and charged the battery to 100%.<br />
<br />
--[[User:Burp|Burp]] 15:31, 13 March 2007 (CET)<br />
----<br />
<br />
The thresholds are saved in the embedded controller, which keeps them as long as there is AC or battery power. If you take away both, the state is reset. If you use suspend-to-disk, tp_smapi will remember the threholds and restore them during resume; but you'll need to write your own init script to set the thresholds during normal reboot after full power loss.<br />
<br />
--[[User:Thinker|Thinker]] 16:19, 13 March 2007 (CET)<br />
----<br />
<br />
Under Ubuntu, you can set the thresholds under {{path| /etc/default/tpsmapi-utils}}.<br />
<br />
START_CHARGE_THRESH_BAT0=40<br />
#START_CHARGE_THRESH_BAT1=40<br />
<br />
STOP_CHARGE_THRESH_BAT0=95<br />
#STOP_CHARGE_THRESH_BAT1=70<br />
----<br />
<br />
If I set the value, plug in in the power cord to charge it after I have shut down the thinkpad, it will charge to 100%?<br />
So I have to plug in the power cord while the thinkpad is running and then shut it down to make it work?<br />
--[[User:Burp|Burp]] 17:45, 15 March 2007 (CET)<br />
----<br />
<br />
Changes take effect immediately, and last as long as the machine has any power source (battery or AC).<br />
<br />
--[[User:Thinker|Thinker]] 18:59, 15 March 2007 (CET)<br />
----<br />
<br />
I've experienced the same problem. When I poweroff my X60 after setting the thresh-values and then reboot it, the values are set to 96/100. If I want the thresholds to be regarded I have to plug in the power cord when the thinkpad is running and then shut it down. If I turn it off before connect it to AC, the values are ignored. <br />
So, are the values only saved in standby-mode? This isn't clear for me, and I think I'm not alone with it ;)<br />
<br />
--[[User:Alexb|Alexb]] 20:56, 15 March 2007 (CET)<br />
<br />
The values are not '''saved''' anywhere. They are set on the EC, and as long as the EC is kept powered on and not rebooted, they are retained. Sleep cycles and reboots on the main machine do not affect the EC. An EC firmware upgrade reboots the EC. Powering off the ThinkPad while it is on battery also powers down the EC. The ThinkPad does not power down the EC while on AC (it has to be powered up to charge the batteries).<br />
<br />
I hope that answered all your doubts...<br />
<br />
--[[User:Hmh|hmh]] 04:45, 28 March 2007 (CEST)<br />
----<br />
Well, I can't find that file ({{path| /etc/default/tpsmapi-utils}}) on my fresh Ubuntu 7.04 installation, nor is it found in the Ubuntu repositories in any release :( <br />
Where can i get it from? Which packages contains it? Where to get that package?<br />
<br />
Thanks!<br />
<br />
== stop_charge_thres on t42p ==<br />
<br />
Hi,<br />
<br />
'cat /sys/devices/platform/smapi/BAT0/stop_charge_thres' does not work. I get:<br />
'Function not implemented'. Under windows the ibm tool shows me both thresholds. I am using tp_smapi version 0.31 with kernel 2.6.20 (ubuntu feisty).</div>Husky69https://www.thinkwiki.org/w/index.php?title=Installing_Ubuntu_6.06_on_a_ThinkPad_T43&diff=28315Installing Ubuntu 6.06 on a ThinkPad T432007-02-19T23:01:11Z<p>Husky69: /* Fingerprint Reader */ added info about kdm not working with thinkfinger</p>
<hr />
<div>Installation Log of {{Ubuntu}} 6.06 on a {{T43}}<br />
<br />
__TOC__<br />
<br />
<br />
==Overview==<br />
Worked right out of the box<br />
* 1400*1050 resolution<br />
* Battery Management<br />
* Ultra Nav (Trackpoint and synaptic touchpad)<br />
* WLAN (Atheros, IBM 11a/b/g Wireless LAN Mini PCI Adapter II)<br />
* Hibernate and Standby<br />
* Fn keys (switch between monitors untested)<br />
* Audio Keys <br />
* ThinkLight<br />
<br />
Was easy or required some work<br />
* easy ubuntu (includes skype and some codecs) <br />
* middle key of Ultra Nav (Trackpoint)<br />
* ATI 3D Acceleration (Mobility Radeon X300)<br />
* Xgl / Compiz<br />
* Fingerprint reader<br />
* Forward/Backward keys, Access IBM Key<br />
<br />
Untested<br />
* Bluetooth (light indicates working)<br />
* Modem <br />
* IrDA<br />
* TV out, VGA out<br />
<br />
Failed / still requires work<br />
* Active Protection System (acceleration sensor works 'out of the box' in edgy, but hard disk parking needs kernel recompile)<br />
<br />
==Installation==<br />
<br />
===Recovery copy of data===<br />
<br />
Before installing a new OS you should create a security copy of your old system. As the IBM Rescue and Recovery tool quit with an error message I used the Ubuntu live CD, mounted and cd'ed into my external hard drive and ran the following command:<br />
<br />
$ cmduser|sudo dd if=/dev/sda1 | gzip | dd of=./sda1.img<br />
<br />
where /dev/sda1 is the device with my windows partition and sda1.img the gzipped security copy.<br />
In case of problems one can now restore lost information using<br />
<br />
$ sudo dd if=./sda1.img | gzip -d | dd of=/dev/sda1 <br />
<br />
After creating the recovery copy we are ready to resize the existing windows partition. This article assumes you want to keep your IBM Rescue and Recovery Partition, shrink in size, but keep your windows partition and create a new partition for Dapper Drake.<br />
<br />
===Resizing Partitions===<br />
<br />
Probably the best choice is now to boot from the alternate CD (read [http://gawrysiak.org/corvus/?p=4] to know why) and use it to resize the existing NTFS partition. Unfortionately in my case it didn't work. So I booted the Live CD, but gparted and parted refused to resize my Windows, too. If the same happens to you, use the example [http://crashrecovery.org/CrashRecoveryKit/iso/2.4.21/HOWTO.ntfs.html here] to know how to resize it "manually" using ntfsresize and fdisk.<br />
<br />
After resizing your windows partition you should reboot window to check everything's in order. It probably will run checkdisk and reboot two times - according to experieces you can read in the web, you should better let windows do that.<br />
<br />
===Installation of Ubuntu===<br />
<br />
Now it's the time to install Ubuntu. I used the alternate CD for that because I chose to install grub into the Linux partition and not into the Master Boot Record ([http://gawrysiak.org/corvus/?p=4 read why]). The graphical LiveCD installer automatically installs grub to the MBR. If you want to use grub in the MBR read [[Rescue and Recovery]]. There is a description of what you have to do in order to still be able to use the IBM R'n'R partition.<br />
<br />
* remember that you're installing GRUB to an '''sda''' mount, not an hda mount like the GRUB installer will prompt you for what you should enter after you tell GRUB not to install in the MBR will be something like this:<br />
<br />
/dev/sda3<br />
<br />
After the installation is finshed it will reboot your system. Now windows should start. In my case it didn't, but playing around, booting into the R'n'R partition, starting PC Doctor and doing some Diagnostics (no changes) somehow and surprisingly made windows boot again.<br />
<br />
To boot you freshly installed Linux you have to reboot the LiveCD one last time. Use<br />
<br />
$ sudo dd if=/dev/sda5 of=ubuntu.img bs=512 count=1<br />
<br />
to copy the first block of grub into an image file and use e.g. an usb flash drive to transfer it to your newly booted windows. Copy paste the image to C:\ and add the following line to your C:\boot.ini:<br />
<br />
C:\ubuntu.img="Ubuntu Dapper Drake"<br />
<br />
At the next restart the windows boot manager should now welcome you with the choice to boot windows or ubuntu. Choose ubuntu to (finally ;-) boot your newly installed linux for the first time.<br />
<br />
==Configuration==<br />
<br />
===Easyubuntu===<br />
<br />
[http://easyubuntu.freecontrib.org/ Easyubuntu] is a helpful tool to install Skype, codecs, ATi 3D drivers and further things that can make your live easier.<!-- Should this even be here? --><br />
<br />
===Keyboard Layout===<br />
<br />
My T43 has a German keyboard layout. Most worked just fine, but some keys (in my case the "at" and the "tilde" among others) just didn't. If the same happens to you, just go to the Gnome System Preferences menu and choose the right layout for your keyboard (probably named after your language and something like eliminate-dead-keys or no-dead-keys)<br />
<br />
===3D Acceleration and Xgl/Compiz===<br />
<br />
If you have an ATI Radeon X300, use [http://wiki.cchtml.com/index.php/Ubuntu_Dapper_Installation_Guide this explanation] to make your hardware 3d acceleration work.<br />
<br />
To test if it works type<br />
<br />
$ glxinfo | grep rendering<br />
<br />
The answer should be: "direct rendering: Yes". If it says "No", you don't have 3D acceleration.<br />
<br />
<br />
If you want to install Xgl/Compiz like me, [http://www.compiz.net/viewtopic.php?id=389 here] is a great installation help for ATI cards (use way two.) <br />
<br />
<br />
If you have another card you might find a good explanation [http://ubuntuforums.org/showthread.php?t=148351 here].<br />
<br />
<br />
===3D Acceleration using open-source radeon driver and AIGLX/Beryl===<br />
From my experience it was better to use "radeon" driver, the open source one, on top of "drm" driver, <br />
also part of the kernel, instead of fglrx. I get direct rendering and similar performance---maybe fglrx <br />
driver gives 50-100 more fps. The most annoying thing about fglrx driver is that it can cause hard locks <br />
every now and then and your suspend doesn't work properly...believe me I tried the ones that the Thinkwiki <br />
says supposed to work. <br />
<br />
$ glxinfo | grep rendering<br />
direct rendering: Yes<br />
OpenGL renderer string: Mesa DRI R300 20060815 TCL<br />
<br />
Use the directions in the previous section to install fglrx driver, library. (I just installed them from shell<br />
rather than making them into packages, I found the uninstall script in /usr/share/fglrx to work properly). <br />
FYI, I used the version 8.26.18-x86.<br />
<br />
If you don't get rendering use ''LIBGL_DEBUG=verbose glxinfo'' to diagnose the problem. The most common problem<br />
is that xorg looks for DRI library files in ''/usr/X11R6/lib/dri'', which didn't exist for me. A simple way to <br />
solve this is creating a symlink to where those files are located (/usr/lib/dri/):<br />
$ cd /usr/X11R6/lib/<br />
$ ln -s /usr/lib/dri/ .<br />
<br />
Open your ''/etc/modules'' file and add these lines and comment 'fglrx' if there is any:<br />
intel-agp<br />
drm<br />
radeon<br />
<br />
Also, from my experience, it was better to use '''AIGLX''' than Xgl and '''Beryl''' instead of Compiz<br />
in terms of performance and integration---things like suspend and hibernate. And you can use nice <br />
start/shutdown scripts to disable beryl-manager since it can cause hang when you resume from suspension. <br />
For more information about suspend/resume scripts, [http://ubuntuforums.org/showthread.php?p=1656484 here]. <br />
On T43s suspend seems to work great with [http://ubuntuforums.org/showthread.php?p=2092657#post2092657 this script].<br />
<br />
For more information about installing aiglx and beryl, see [http://wiki.beryl-project.org/index.php/Install/Ubuntu/Dapper/AiGLX here].<br />
<br />
ATI X300 is pretty pitiful though...I get around ~570 average FPS when running AIGLX/beryl<br />
$ glxgears<br />
2850 frames in 5.0 seconds = 569.997 FPS<br />
2925 frames in 5.0 seconds = 584.925 FPS<br />
2904 frames in 5.0 seconds = 580.741 FPS<br />
2923 frames in 5.0 seconds = 584.524 FPS...<br />
With metacity (default Gnome window manager) I get around slightly over 1000 FPS<br />
$ glxgears<br />
5073 frames in 5.0 seconds = 1014.423 FPS<br />
5073 frames in 5.0 seconds = 1014.531 FPS<br />
5252 frames in 5.0 seconds = 1049.326 FPS<br />
5803 frames in 5.0 seconds = 1160.502 FPS...<br />
<br />
If anyone know how to get rid of the weird warning, I would really appreciate it:<br />
libGL warning: 3D driver claims to not support visual 0x4b<br />
Seems to be a unresolved bug: [https://bugs.freedesktop.org/show_bug.cgi?id=6624 freedesktop]<br />
<br />
I added the following options under ati Device section of ''/etc/X11/xorg.conf''<br />
Option "EnablePageFlip" "True"<br />
Option "ColorTiling" "True"<br />
Then after that the performance boosted by quite a bit:<br />
7026 frames in 5.0 seconds = 1405.147 FPS<br />
7058 frames in 5.0 seconds = 1411.493 FPS<br />
7062 frames in 5.0 seconds = 1412.393 FPS...<br />
<br />
===Active Protection System===<br />
<br />
See end of this chapter if you have ubuntu edgy eft.<br />
<br />
The T43 has a great system to protect your hard disk, the Active Protection System APS. [[How to protect the harddisk through APS]] describes how you can use it.<br />
<br />
{{WARN|Only follow these instructions if you know what you are doing!}}<br />
<br />
If you didn't until now you will have to install make, libc, gcc, ... Best is you use<br />
<br />
$ sudo apt-get install build-essentials<br />
<br />
Determine your kernel version using <br />
<br />
$ uname -a<br />
<br />
You should see somthing like<br />
<br />
Linux ibm 2.6.15-26-386 #1 PREEMPT Thu Aug 3 02:52:00 UTC 2006 i686 GNU/Linux<br />
<br />
Install the kernel sources "linux-source" e.g. using Synaptic.<br />
Download the right kernel patch from [[HDAPS#Applications]] according to your kernel version and system (I chose "sata/ide disk protection patch for 2.6.15")<br />
adapt following steps to your needs:<br />
<br />
$ cd /usr/src/<br />
$ sudo su<br />
# bunzip2 linux-source-2.6.15.tar.bz2<br />
# tar -xf linux-source-2.6.15.tar<br />
# cd linux-source-2.6.15<br />
# patch -p1 -l < /home/silvan/hdaps_protect.20060118.patch<br />
<br />
You should see several lines with the word "suceeded". If you see many "failed" instead you probably chose the wrong patch for your kernel. You can use the --dry-run option to try it out first. If you get errors in the following steps you should better stop unless you know what you are doing.<br />
<br />
# make clean<br />
# make oldconfig # use old config, ask for new items, only<br />
# make clean<br />
# make # takes quite a long time, several minutes<br />
# make modules<br />
# make modules_install<br />
<br />
Afterwards use the debian sources mentioned in [[How to protect the harddisk through APS]] to install the user space deamon hdapsd and the gnome applet gnome-hdaps-applet, e.g. using Synaptic.<br />
<br />
If this worked for you, you can find some nice applications at [[HDAPS#Applications]] which make use of the APS.<br />
<br />
{{HELP|For me unfortunately it didn't work as making the patched kernel failed. Please update ths section if you have different experiences and a better, more detailed working explanation.}}<br />
<br />
<br />
{{NOTE|After I updated to edgy eft hdaps works without further work: edgy comes with hdaps built in. You can check if it is working by installing hdaps-utils<br />
<br />
# sudo apt-get install hdaps-utils<br />
<br />
and calling <br />
<br />
# hdaps-gl<br />
<br />
for a nice 3D show. If it is not, load the kernel module using <br />
<br />
# sudo modprobe hdaps<br />
<br />
and it should work. But if you want to use hdaps for disk protection, you have to recompile your kernel in edgy, too. Follow this post for an howto:<br />
<br />
}}<br />
[http://ubuntuforums.org/showthread.php?t=122863 Howto for edgy]<br />
<br />
===Track Point Middle Key Scrolling===<br />
<br />
In my case the track point worked out of the box, but the middle mouse button for scrolling did not. [[How to configure the TrackPoint]] explains how to solve this. The steps you need to follow are in section "Using the X server (kernel 2.6.11+)".<br />
However you don't need to follow the steps in "EmulateWheelTimeout temporarily broken (-> fix for Ubuntu Dapper)" as this is fixed already if you have all your packages up-to-date.<br />
<br />
Follow the instructions in the sections "Configure firefox for using trackpoint horizontal scrolling" and "Configure Opera for using trackpoint horizontal scrolling" as well, if you are using one of the two browsers.<br />
<br />
<br />
===Fingerprint Reader===<br />
<br />
[[How to enable the fingerprint reader]] has a good explanation for a very complicated way of activating your fingerprint reader.<br />
<br />
An alternative to this is available at [http://thinkfinger.sourceforge.net]:<br />
Follow these steps if you want to trust and use this software:<br />
<br />
Build and install:<br />
Download the tar.gz and unpack it in your home folder then execute the steps:<br />
$ cd thinkfinger-0.2.2<br />
$ ./configure --with-securedir=/lib/security<br />
$ make <br />
$ sudo checkinstall<br />
<br />
If everything went ok assert that you find pam_thinkfinger.so in /lib/security typing:<br />
$ ls /lib/security<br />
<br />
These steps will activate the fingerprint reader:<br />
Open /etc/pam.d/common-auth:<br />
$ sudo gedit /etc/pam.d/common-auth<br />
<br />
Add this line before any pam_unix or pam_unix2 directives:<br />
auth sufficient pam_thinkfinger.so<br />
<br />
If your PAM uses the pam_unix and not the pam_unix2 module, you need to pass a specific argument in<br />
the /etc/pam.d/common-auth directive to make it consider the password entered at the pam_thinkfinger prompt.<br />
auth required pam_unix.so try_first_pass<br />
<br />
For instance my /etc/pam.d/common-auth looks like this:<br />
# before adding the fingerprint reader work there was only this line:<br />
# auth required pam_unix.so nullok_secure<br />
auth sufficient pam_thinkfinger.so<br />
auth required pam_unix.so try_first_pass<br />
<br />
Now we are ready to add users to thinkfinger. In my case checkinstall did not create the /usr/local/etc/pam_thinkfinger <br />
directory, so first create it, if it is the same in your case, then add you user replacing bob with your username:<br />
sudo mkdir /usr/local/etc/pam_thinkfinger<br />
sudo tf-tool --add-user bob<br />
<br />
Open a new Terminal and try some command where you need sudo rights like sudo apt-get update, you should be promted now with<br />
Password or swipe finger: <br />
<br />
Try both, just to be sure everything works, before you logg off ;-)<br />
<br />
I did not test kdm, but gdm (gnome login promt) worked with the fingerprint reader, too, prompting the same line "Password or swipe finger".<br />
<br />
{{HELP|This doesn't seem to work with kdm. An explanation can be found at the URL given below. Same goes for kscreensaver. If anybody succeeds in solving this problem, pls note it here! Thx!}} <br />
[http://bbs.archlinux.org/viewtopic.php?id=29310&p=2 Information on ThinkFinger not working with kdm at the moment.]<br />
<br />
gksu/gksudo work as well, although its not obvious: If you are prompted for the password, swipe your finger and hit OK, It should authenticate you.<br />
<br />
gnome-screensav seems not to work. Anybody any hints on that?<br />
<br />
===Forward / Backward Keys, Access IBM===<br />
Just follow this HowTo for the configuration you prefer: [[How to get special keys to work]]<br />
<br />
===IrDA===<br />
{{Todo|Needs editing}}<br />
Find information here: [[How to make use of IrDA]]<br />
<br />
<br />
===VGA out ===<br />
{{Todo|Needs editing}}<br />
I didn't try it, but it looks easy: [http://help.nceas.ucsb.edu/index.php/Enable_vga_out_on_ATI_Thinkpads How to enable VGA out]<br />
<br />
==References==<br />
* [http://gawrysiak.org/corvus/?p=4 Dapper Drake on T42]<br />
<br />
==External Sources==<br />
* This guide is listed at the [http://tuxmobil.org/ibm.html TuxMobil Linux laptop and notebook installation survey (IBM/Lenovo)].<br />
<br />
Hope this helped somehow :-)<br />
tec</div>Husky69https://www.thinkwiki.org/w/index.php?title=Tp_smapi&diff=28063Tp smapi2007-02-02T08:38:17Z<p>Husky69: /* Installation */ Added installation instructions for Ubuntu/Debian</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 />
The <tt>tp_smapi</tt> kernel module exposes some features of the ThinkPad hardware/firmware via a <tt>sysfs</tt> interface. Currently, the main implemented functionality is control of battery charging and extended battery status. The underlfying hardware interfaces are [[SMAPI support for Linux|SMAPI]] and direct access to the embedded controller.<br />
<br />
For older ThinkPad models, see also [[tpctl]].<br />
<br />
{{WARN|This driver uses undocumented features and direct hardware access. It thus cannot be guaranteed to work and could conceivably damage your computer (though so far no incidents have been reported).}}<br />
<br />
|}<br />
<br />
===Features===<br />
*Battery charge/discharge control<br />
*Battery status information<br />
*PCI bus power saving control<br />
<br />
===Project Homepage / Availability===<br />
* Project page: http://tpctl.sourceforge.net/<br />
* You need to [http://sourceforge.net/project/showfiles.php?group_id=1212&package_id=171579 download] only the <tt>tp_smapi</tt> package. Versions containing <tt>-test</tt> are experimental, others are stable.<br />
<br />
===Installation===<br />
====Installation from source====<br />
You will need the kernel headers and makefiles corresponding to your current kernel version. On {{Fedora}}, this means {{cmdroot|yum install kernel-devel-$(uname -r)}} .<br />
<br />
For testing, you can simply compile and load the driver within the current<br />
working directory:<br />
:{{cmdroot|tar xzvf tp_smapi-0.30.tgz}}<br />
:{{cmdroot|cd tp_smapi-0.30}}<br />
:{{cmdroot|make load}}<br />
<br />
To compile and install into the kernel's module path:<br />
:{{cmdroot|make install}}<br />
<br />
If you use the [[HDAPS]] driver, add <tt>HDAPS=1</tt> to also patch the <tt>hdaps</tt> for compatibility with <tt>tp_smapi</tt> (this requires a kernel source tree matching the current kernel):<br />
:{{cmdroot|1=make load HDAPS=1}}<br />
or, to compile and install into the kernel's module path:<br />
:{{cmdroot|1=make install HDAPS=1}}<br />
<br />
<br />
To prepare a stand-alone patch against the current kernel tree (including<br />
a patch against <tt>hdaps</tt> and new <tt>Kconfig</tt> entries):<br />
:{{cmdroot|make patch}}<br />
<br />
To delete all autogenerated files:<br />
:{{cmdroot|make clean}}<br />
<br />
The original kernel tree is never modified by any these commands. <br />
The {{path|/lib/modules}} directory is modified only by {{cmdroot|make install}}.<br />
<br />
''Comment: I had to install the complete kernel source tree to make it work (Edgy, T43)''<br />
<br />
====Installation in Gentoo====<br />
The {{Gentoo}} portage system carries a [http://packages.gentoo.org/packages/?category=app-laptop;name=tp_smapi tp_smapi package], which follows the latest version pretty closely. On a Gentoo system, you can install and load as follows.<br />
<br />
If you use the [[HDAPS]] driver, do this first:<br />
<br />
* Configure <tt>hdaps</tt> as module in your kernel<br />
* Add the <tt>HDAPS</tt> use flag in {{path|/etc/make.conf}}<br />
* {{cmdroot|rmmod hdaps}}<br />
<br />
Then:<br />
<br />
* {{cmdroot|emerge tp_smapi}} (or install tp_smapi with hdaps support manually, as above)<br />
* {{cmdroot|echo "tp_smapi" >> /etc/modules.autoload.d/kernel-2.6}}<br />
* {{cmdroot|echo "hdaps" >> /etc/modules.autoload.d/kernel-2.6}}<br />
<br />
Then reboot, or run:<br />
* {{cmdroot|modprobe tp_smapi}}<br />
* {{cmdroot|modprobe hdaps}}<br />
<br />
====Installation on Ubuntu/Debian====<br />
<br />
Installation on Ubuntu or Debian is quite easy, but there are a few things to look after:<br />
<br />
To get your system ready for compiling code, install the build-essentials (as root, of course, as all of the following comands; Ubuntu users have to prepend 'sudo' to every line and enter their own password when prompted):<br />
<pre><nowiki>apt-get install build-essentials</nowiki></pre><br />
<br />
To get tp_smapi to work, obtain the latest source as mentioned above and unpack it. If you want to use HDAPS, you need to install the kernel source matching te kernel you are running. To do so, issue this:<br />
<pre><nowiki>uname -r</nowiki></pre><br />
This will give you the version of your current kernel. As Ubuntu adds '-generic' to the kernel-version, the following command works for Debian users only:<br />
<pre><nowiki>apt-get install linux-source-`uname -r`</nowiki></pre><br />
Ubuntu users use the kernel-version they got by the command before, e.g. 'linux-source-2.6.20'<br />
<br />
Now change to the tp_smapi dir:<br />
<pre><nowiki>cd tp_smapi-X.YY</nowiki></pre> (X.YY being the version-number of [[tp_smapi]])<br />
and make and install tp_smapi as instructed above.<br />
<br />
If you get an error that the kernel version isn't matching, please check that there is a symlink from the modules dir to the kernel source:<br />
<pre><nowiki>root@localhost:~#ls -l /lib/modules/2.6.20-6-generic<br />
lrwxrwxrwx 1 root root 28 2007-02-02 08:39 source -> /usr/src/linux-source-2.6.20</nowiki></pre><br />
Create the link if the line above is not existent:<br />
<pre><nowiki>root@localhost:~#ln -s /usr/src/linux-source-2.6.20 /lib/modules/2.6.20-6-generic/source</nowiki></pre><br />
<br />
Now the following will build and install the correct modules to their locations:<br />
<pre><nowiki>make install HDAPS=1</nowiki></pre><br />
To make sure your system loads the modules at boot time, do this:<br />
<pre><nowiki>echo "tp_smapi" >> /etc/modules<br />
echo "hdaps" >> /etc/modules</nowiki></pre><br />
and update your initramfs:<br />
<pre><nowiki>update-initramfs -u</nowiki></pre><br />
<br />
To get tp_smapi running now, just load the modules:<br />
<pre><nowiki>modprobe tp_smapi hdaps</nowiki></pre><br />
<br />
This description was tested on Kubuntu 'Feisty Fawn' and should work on all Debian-based distros with minor tweaks.<br />
<br />
===Battery charge control features===<br />
To set the thresholds for starting and stopping battery charging (in percent of current full charge capacity):<br />
:{{cmdroot|echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh}}<br />
:{{cmdroot|echo 70 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh}}<br />
:{{cmdroot|cat /sys/devices/platform/smapi/BAT0/*_charge_thresh}}<br />
{{HINT|Battery charging thresholds can be used to keep Li-Ion ad Li-Polymer batteries partially charged, in order to [[Maintenance#Battery_treatment|increase their lifetime]].}}<br />
To unconditionally inhibit charging for 17 minutes:<br />
:{{cmdroot|echo 17 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes}}<br />
{{HINT|Charge inhibiting can be used to reduce the power draw of the laptop, in order to use a an under-spec power supply that can't handle the combined power draw of running and charging. It can also be used to control which battery is charged when [[How to use UltraBay batteries|using an Ultrabay battery]].}}<br />
<br />
To cancel charge inhibiting:<br />
:{{cmdroot|echo 0 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes}}<br />
<br />
To force battery discharging even if connected to AC, use one of these:<br />
:{{cmdroot|echo 1 > /sys/devices/platform/smapi/BAT0/force_discharge}}<br />
{{HINT|This can be used to choose which battery is discharged when [[How to use UltraBay batteries|using an UltraBay battery]].}}<br />
<br />
To cancel forced discharge:<br />
:{{cmdroot|echo 0 > /sys/devices/platform/smapi/BAT0/force_discharge}}<br />
<br />
===Battery status features===<br />
To view extended battery status such as charging state, voltage, current, capacity, cycle count and model information:<br />
<br />
<pre><br />
# cat /sys/devices/platform/smapi/BAT0/installed<br />
# cat /sys/devices/platform/smapi/BAT0/state # idle/charging/discharging<br />
# cat /sys/devices/platform/smapi/BAT0/cycle_count<br />
# cat /sys/devices/platform/smapi/BAT0/current_now # instantaneous current<br />
# cat /sys/devices/platform/smapi/BAT0/current_avg # last minute average<br />
# cat /sys/devices/platform/smapi/BAT0/power_now # instantaneous power<br />
# cat /sys/devices/platform/smapi/BAT0/power_avg # last minute average<br />
# cat /sys/devices/platform/smapi/BAT0/last_full_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_percent<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_running_time<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_charging_time<br />
# cat /sys/devices/platform/smapi/BAT0/remaining_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/design_capacity<br />
# cat /sys/devices/platform/smapi/BAT0/voltage<br />
# cat /sys/devices/platform/smapi/BAT0/design_voltage<br />
# cat /sys/devices/platform/smapi/BAT0/manufacturer<br />
# cat /sys/devices/platform/smapi/BAT0/model<br />
# cat /sys/devices/platform/smapi/BAT0/barcoding<br />
# cat /sys/devices/platform/smapi/BAT0/chemistry<br />
# cat /sys/devices/platform/smapi/BAT0/serial<br />
# cat /sys/devices/platform/smapi/BAT0/manufacture_date<br />
# cat /sys/devices/platform/smapi/BAT0/first_use_date<br />
# cat /sys/devices/platform/smapi/BAT0/temperature # in milli-Celsius<br />
# cat /sys/devices/platform/smapi/ac_connected<br />
</pre><br />
<br />
The raw status data is also available, including some fields not listed above (in case you can figure them out):<br />
<br />
:{{cmdroot|cat /sys/devices/platform/smapi/BAT0/dump}}<br />
<br />
In all of the above, replace <tt>BAT0</tt> with <tt>BAT1</tt> to address the 2nd battery.<br />
<br />
Note that the battery status readout conflicts with the stock [[HDAPS|hdaps]] driver, so if you use <tt>hdaps</tt> you will need to load <tt>tp_smapi</tt> using {{cmdroot|1=make load HDAPS=1}} (see [[#Conflict_with_hdaps|Conflict with hdaps]] below).<br />
<br />
On [[ACPI]]-enabled systems, most of above information is also available through the files under {{path|/proc/acpi/battery}}. However, the ACPI interface does not include the instantaneous power and cycle count readouts, and does not work well when [[How to use UltraBay batteries|hotswapping UltraBay batteries]].<br />
<br />
===Other features===<br />
<br />
This controls the "PCI bus power saving" option in the BIOS, and takes effect at the next boot. On a ThinkPad {{T43}} turning this off increases idle power consumption by about 350mW. Out-of-the-box default is 1.<br />
# cat /sys/devices/platform/smapi/enable_pci_power_saving_on_boot<br />
# echo 1 > /sys/devices/platform/smapi/enable_pci_power_saving_on_boot # on<br />
# echo 0 > /sys/devices/platform/smapi/enable_pci_power_saving_on_boot # off<br />
<br />
There is also [[sysfs]] attribute for making direct SMAPI requests to the SM BIOS firmware. Don't touch it unless you really know what you're doing. Example:<br />
# echo '211a 100 0 0 > /sys/devices/platform/smapi/smapi_request; cat /sys/devices/platform/smapi/smapi_request<br />
211a 34b b2 0 0 0 'OK'<br />
The 4b" in the 2nd value, converted to decimal is 75: the current charge stop threshold.<br />
<br />
===Conflict with <tt>hdaps</tt>===<br />
The extended battery status function conflicts with the [[HDAPS|hdaps]] kernel module (they use the same IO ports). The <tt>tp_smapi</tt> package includes a patch against <tt>hdaps</tt> to make it compatible with <tt>tp_smapi</tt>, and also to fix many problems in the original driver.<br />
<br />
To build the patched version, simply append the <tt>HDAPS=1</tt> parameter to the <tt>make</tt> command, for example: {{cmdroot|1=make load HDAPS=1}} (see [[#Installation|Installation]] above).<br />
<br />
If you don't do that, you will not be able tp load <tt>tp_smapi</tt> (and its support module <tt>tp_base</tt>) when <tt>hdaps</tt> is loaded, and vice versa. You can use <tt>rmmod</tt> to switch between these modules.<br />
<br />
Note that some of the battery status is also visible through ACPI ({{path|/proc/acpi/battery/*}}), independently of <tt>tp_smapi</tt>.<br />
<br />
===Model-specific status===<br />
<br />
<div style="font-size: 92%"><br />
{| border="1" cellspacing="0" cellpadding="2"<br />
|+<tt>tp_smapi</tt> feature support matrix<br />
|-<br />
! &times; <br />
! <tt>start_charge_<br />thresh</tt> <br />
! <tt>stop_charge_<br />thresh</tt><br />
! <tt>inhbit_charge_<br />minutes</tt><br />
! <tt>force_discharge</tt><br />
! battery status files<br />
! <tt>cd_speed</tt><br \><span style="font-size: 90%">(removed)</span><br />
! Notes<br />
|-<br />
! colspan=8 style="text-align:center;background:#efefef;" | <br />
=====A series=====<br />
|-<br />
! {{A22p}} 2629-USG<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} ||<br />
|-<br />
! {{A30}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! colspan=8 style="text-align:center;background:#efefef;" |<br />
=====G series=====<br />
|-<br />
! {{G41}}<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} ||<br />
|-<br />
! colspan=8 style="text-align:center;background:#efefef;" |<br />
=====R series=====<br />
|-<br />
! [[:Category:R31|R31]]<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || No SMAPI BIOS<br />
|-<br />
! {{R40}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} ||<br />
|-<br />
! {{R50}}<br />
| {{Cunk}} || {{Cno}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{R50e}} 1834-JAG<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{R50p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{R51}}<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{R52}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} ||<br />
|-<br />
! {{R60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
<br />
! colspan=8 style="text-align:center;background:#efefef;" |<br />
<br />
=====T series=====<br />
|-<br />
! {{T20}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || Has SMAPI BIOS but no function is supported. EC LPC3 protocol fails.<br />
|-<br />
! {{T22}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || Has SMAPI BIOS but no function is supported. EC LPC3 protocol fails.<br />
|-<br />
! {{T23}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{T30}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{T40}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{T40p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{T41}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{T41p}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{T42}} <br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{T42p}} 2373-KUU<br />
| {{Cyes}} || {{Cno}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{T43}} 2686-DGU<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{T43p}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{T60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! colspan=8 style="text-align:center;background:#efefef;" |<br />
<br />
=====X series=====<br />
|-<br />
! {{X20}} 2662-31G<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || tp_smapi 0.20<br />
|-<br />
! {{X24}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{X31}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cunk}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{X32}}<br />
| {{Cno}} || {{Cno}} || {{Cno}} || {{Cno}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{X40}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cyes}} || {{Cunk}} || BIOS v2.03, EC v1.60<br />
|-<br />
! {{X41}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{X60}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! colspan=8 style="text-align:center;background:#efefef;" |<br />
<br />
=====Z series=====<br />
|-<br />
! {{Z60m}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{Z60t}}<br />
| {{Cyes}} || {{Cyes}} || {{Cunk}} || {{Cunk}} || {{Cyes}} || {{Cunk}} ||<br />
|-<br />
! {{Z61m}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} ||<br />
|-<br />
! {{Z61t}}<br />
| {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} || {{Cyes}} ||<br />
|}<br />
</div><br />
<br />
<br />
Please update the above and report your experience on the [[Talk:tp_smapi|discussion]] page. If the module loads but gives a "<tt>not supported</tt>" or "<tt>not implementeded</tt>" when you try to use some specific file in {{path|/sys/devices/platform/smapi/}}, please report the <tt>dmesg</tt> output and whether the corresponding functionality is available under Windows - maybe your ThinkPad just can't do that. <br />
<br />
While at it, you may also want to add your laptop to the [[list of DMI IDs]].<br />
<br />
[[Category:Drivers]] [[Category:Patches]]<br />
<br />
===Tools using this driver===<br />
<br />
The driver's interface can be accessed directly through the files under {{path|/sys/devices/platform/smapi}}, or via the following tools:<br />
* [[KThinkBat]] - display battery status on the KDE <tt>kicker</tt> panel.<br />
* [[gkrellm-ThinkBat]] - battery status plugin for Gkrellm2</div>Husky69