# Is there a guide to using ACPI? (mabey on the T40p)

## hadees

I have been looking around the forums and doing alot of searching and i don't see a whole lot on this.  I am not new to linux but i have never used ACPI before and i am not sure what to do.  I own a Thinkpad t40p and installed everything in my 2.6 kernel (they are built in not modules) and i emerged the acpid daemon, started it and added it to start at boot time, but now what? So here are my few questions hopfully someone can answer for me

1.  how do i then connect my Fn+F4 to make my laptop go to sleep or how do i get my Fn+F12 to suspend to disk?  

2.  How do i get my computer to do speed steping or for that matter how do i know if it is working.

3.  How do i get my computer to go to sleep when the computer lid closes?

4.  What is the diffrence between ACPI and APM (and thus do i really need ACPI)

5.   How do i find out how much battery is left, i thought it was acpi -v but i get command not found

6.  I heard about throttling the cpu, if it is what i think it is i want to do this because the computer is gets really hot some times and i want it to cool down so it doesn't get damaged

7.  Is it true that because of speed steping a small process can take longer to do? ans there a way to then force the computer to run at full speed to get a process down as fast as possible?

8.  If ACPI does all the power stuff for my computer does that mean i should disable that in my bios

Thats it and if anyone else can add anything they think might be usefull and if you own a Thinkpad t40 or t40p feel free to include anything else related to the laptop as i still need to get the madwifi drivers working and it isn't going well

Thanks

Hadees

----------

## jetblack

 *hadees wrote:*   

> I have been looking around the forums and doing alot of searching and i don't see a whole lot on this.  I am not new to linux but i have never used ACPI before and i am not sure what to do.  I own a Thinkpad t40p and installed everything in my 2.6 kernel (they are built in not modules) and i emerged the acpid daemon, started it and added it to start at boot time, but now what? So here are my few questions hopfully someone can answer for me

 

Wow, these are some big questions. I'll try to answer what I can  :Smile: 

First off, have a look at /proc/acpi and see what you've got under there. You should have directories for the different ACPI functionality that you included in your kernel. If something is missing that you think should be there, then you may be having some ACPI issues. For example, when I ls /proc/acpi, I get:

```
ls /proc/acpi

ac_adapter

alarm

battery

button

debug_layer

debug_level

dsdt

embedded_controller

event

fadt

fan

info

power_resource

processor

sleep

thermal_zone
```

Secondly, you'll want to install acpid (emerge acpid). This is a daemon that intercepts acpi events. After you emerge it, check out /etc/acpi/default.sh. This is a script that it uses to intercept the events. You should see it print messages to /var/log/messages and /var/log/acpid when it receives ACPI events. There is a thread here where people have contributed some scripts to handle various events.

Finally, check out acpi.sourceforge.net for some good documentation on ACPI, Of particular interest to you will be the sleep states and processor states topics.

 *hadees wrote:*   

> 1.  how do i then connect my Fn+F4 to make my laptop go to sleep or how do i get my Fn+F12 to suspend to disk?  

 

If these keys generate keycodes from X, then you should be able to use xmodmap to connect them to events. If not (if they are ACPI keys), then they may generate events that are captured by acpid. Either way, you'll need to captuere the event and then echo the appropriate value to /proc/acpi/sleep to get the system to suspend. Check that Sleep States document for more details.

Also, a lot of people (myself included) have reported trouble with suspend (and especially with waking up from suspend). You may want to search the forums for ACPI suspend - related threads.

 *hadees wrote:*   

> 2.  How do i get my computer to do speed steping or for that matter how do i know if it is working.

 

If you're using a 2.6 kernel, then compile speedfreq into your kernel. To check if it's working, cat /proc/cpuinfo with the ac adapter plugged in and unplugged. You should see the processor speed change. You can also manuall adjust the speed by writing to /proc/cpu/performance (assuming it's there) as described in the Performance states document above.

 *hadees wrote:*   

> 3.  How do i get my computer to go to sleep when the computer lid closes?

 

Similar to the buttons. The lid closing will generate an event, which can be captured by acpid. When you receive the event, echo the appropriate sleep state number to /proc/acpi/sleep.

 *hadees wrote:*   

> 4.  What is the diffrence between ACPI and APM (and thus do i really need ACPI)

 

From the Intel ACPI FAQ

 *Quote:*   

> Q1.  	What is ACPI?
> 
> A1. 	
> 
> ACPI stands for the Advanced Configuration and Power Interface specification. ACPI defines hardware and software interfaces that enable OS-directed configuration and Power Management (OSPM) to enumerate and configure motherboard devices, and manage their power. ACPI, in conjunction with OSPM, replaces APM and PNPBIOS, as well as the MultiProcessor (MPS) specification. ACPI 1.0 was released in December of 1996. The ACPI 2.0 Specification has been released and is available for download from the ACPI Web site.
> ...

 

 *hadees wrote:*   

> 5.   How do i find out how much battery is left, i thought it was acpi -v but i get command not found

 

cat /proc/acpi/battery/BAT0/state

 *hadees wrote:*   

> 6.  I heard about throttling the cpu, if it is what i think it is i want to do this because the computer is gets really hot some times and i want it to cool down so it doesn't get damaged

 

check /proc/acpi/processor/CPU0/throttling. Write to it as specified in the Processor states page at acpi.sourceforge.net

 *hadees wrote:*   

> 7.  Is it true that because of speed steping a small process can take longer to do? ans there a way to then force the computer to run at full speed to get a process down as fast as possible?

 

No idea  :Smile: 

 *hadees wrote:*   

> 8.  If ACPI does all the power stuff for my computer does that mean i should disable that in my bios

 

I don't think you need APM in your BIOS if you're using ACPI. I imagine that it could interfere with (or subvert) ACPI, but I'm not sure if you'd have to compile APM support into your kernel to actually see a problem. So, not sure.

I hope that helps. It's kind of the quick overview, so please let me know if anything is unclear.

----------

## hadees

Thanks for all the help

I do have another question though, do you happen to know what exactly is the diffrence between PowerNowd and Speedfreq

I think they are the same thing and so i am not sure which one to use

thanks

Hadees

----------

## jetblack

I haven't used Powernowd, but from that page, it sounds like it's intended for CPUs that have more than two speeds available (Intel's centrinos, for example, typically only support two frequencies). It sounds like PowerNow is an AMD thing, so my hunch would be that if you've got an Intel processor, you should use Speedfreq, and if you've got an AMD, you should try PowerNowd.

----------

## steel300

PowerNow is AMD's power management interface. It is ACPI comliant, but with added features for the AMD series

----------

## Wildhoney

hadees search the linux thinkpad mailing list for more infos for ACPI on your T40p. You can gain a lot infos from it.

Info:

http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Archieves:

http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/

I have also a T40p, but i was not able to get ACPI to work. Try  use APM, Suspend to RAM works fine. Suspend to Disk should work too reported a few guys on the list, but i didn't try it yet.

You can also look into http://www.tuxmobile.org/ibm.html

HTH,

Wild

----------

## NiXZe

In my T40p i've got almost everything working perfectly.

1. these keys (most of them anyway) are acpi events... the damn power button don't create one too *grrr*

2. check my /etc/acpi/default.sh http://www.usdata.cjb.net/~NiXZe/T40p/default.sh for some ideas

3. see2

4. already to good answared  :Wink: 

5. emerge acpi and acpid then you will find out with acpi -V (as an extra note please post your output of cat "/proc/acpi/battery/BAT0/*"

```
alarm:                   3175 mWh

present:                 yes

design capacity:         71280 mWh

last full capacity:      63500 mWh

battery technology:      rechargeable

design voltage:          10800 mV

design capacity warning: 3175 mWh

design capacity low:     200 mWh

capacity granularity 1:  1 mWh

capacity granularity 2:  1 mWh

model number:            IBM-08K8201

serial number:            1058

battery type:            LION

OEM info:                SONY

present:                 yes

capacity state:          ok

charging state:          charging

present rate:            3649 mW

remaining capacity:      61920 mWh

present voltage:         12499 mV

```

the acpi command seams to take the presentage from "last full capacity"/"remaining capacity"

6. see answer 2 you will have to emerge speedfreq (ACCEPT_KEYWORDS="~x86" since it is masked)  and also dont forget to start the deamon (why not start it right at boot) i also modified the /etc/init.d/speedfreq script some (http://www.usdata.cjb.net/~NiXZe/T40p/speedfreq) to get it to work good with the laptop

7. see answer 2  :Wink:  you can also use speedfreq -p dynamic to make the cpu go up in speed if it is havily loaded

8.you don't want the bios to interfear with your linux settings do you?  :Wink: 

AND my kernel config for 2.6.1-rc1 (development sources)  http://www.usdata.cjb.net/~NiXZe/T40p/t40p.config

i dont have the FIR irda working.... or more correctly it didnt work directly and i didn't care since i got the bluetooth working instead... and then for the wlan just do an emerge madwifi-driver (also masked)

Suspend to disk worked with almost the same config on my old laptop (Compaq Armada M700) however i haven't edited lilo to suport it yet...

well that's it i guess... happy T40p:ing  :Wink: 

----------

