Differences between revisions 9 and 10
Revision 9 as of 2005-10-29 15:00:53
Size: 4782
Editor: MartinWilck
Comment:
Revision 10 as of 2007-10-28 15:50:24
Size: 1455
Editor: MartinWilck
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
Most of this works out-of-the-box. [http://faq.pathfinderteam.org/index.php/Samsung_X20 this page on the Samsung X20 (in German)] has many good hints. (!) [[Date(2007-10-28T15:50:24Z)]] updated this page because stuff has become a lot easier with etch final release. (!)

Most of this works out-of-the-box. [http://faq.pathfinderteam.org/index.php/Samsung_X20 this page on the Samsung X20 (in German)] has many good hints, too.

Suspend-to-RAM works (ToDo: check if this works with the fglrx VGA driver, too).
Line 7: Line 11:
== Emergency power off == You can control almost all relevant power-saving features through the excellent ''laptop-mode-tools'' package. {{{/etc/laptop-mode/laptop-mode.conf}}}. With {{{cryptsetup}}}, even suspend-on-encyrpted-swap is working nicely. I use the laptop-mode-tools option {{{ASSUME_SCSI_IS_SATA=1}}} for my hard drive, and it appears to work.
Line 9: Line 13:
React to "battery low" events by shutting down gracefully or suspending. Works with {{{acpid}}}. Action must be written by hand on Debian. Here is mine: == ACPI buttons (power, sleep, lid) ==
Line 11: Line 15:
~-{{{
#! /bin/sh
# /etc/acpid/actions/mw_battery.sh
Both the power and sleep buttons work as expected (you can control their actions through {{{/etc/default/acpi-support}}}).
Line 15: Line 17:
# Don't forget to define an event in /etc/acpi/events that calls
# /etc/acpi/actions/mw_battery.sh %e on battery events

export LC_ALL=C

# dont bother if shutdown is already running
[ -f /var/run/shutdown.pid ] && exit 0

minutes=$(/usr/local/bin/minutes_to_go $2)
[ -z "$minutes" ] && exit 0 # charging or full

if [ $minutes -le 3 ]; then
   /sbin/shutdown -h now "battery running low ($minutes minutes)"
fi

}}}

The {{{minutes_to_go}}} command is here:
{{{
#! /bin/sh
# /usr/local/bin/minutes_to_go BATTERY

BAT=$1
[ -r /proc/acpi/battery/$BAT/state ] || exit 2

awk '
/^charging state:/ { if ($3 !~ /^discharging/) { r=0; exit (0); }}
/^present rate:/ {r=$3}
/^remaining capacity/ {c=$3}
END { if (r) print int(60*c/r); }
' /proc/acpi/battery/$BAT/state
}}}
-~
Instead of poweroff, one could as well do a suspend-to-disk (see below).

Likewise, it should be possible to react to "critical temperature" events. Should be possible with {{{acpid}}} on the X50, too. Not tested (I didn't reach critical temperatures:-).


== ACPI sleep states and software suspend ==

This requires a kernel recompilation. Make the following selections in the kernel configuration:
~-{{{
 -> Power management options (ACPI, APM)
   [*] Software Suspend [EXPERIMENTAL]
   -> ACPI (Advanced Configuration and Power Interface) Support
     -> ACPI Support
     [*] ACPI Sleep States [EXPERIMENTAL]
 }}}-~

Suspend-to-disk ({{{echo disk >/sys/power/state}}}) works fine on the X50 as long as the proprietary ATI graphics driver isn't used.

Suspend-to-RAM didn't work for me yet.


== Power saving ==

'''CPU frequency adjustment''' works very well. There is a large number of tools available ([http://www.gentoo.de/doc/de/power-management-guide.xml see here for a comparison]). My personal favorite under Debian are the light-weight {{{cpufrequtils}}}. They rely mostly on the kernel {{{cpufreq}}} driver to do the adjustments. I am using the {{{ondemand}}} governor under normal conditions and the {{{powersave}}} governor when I really want to save battery.
I put the following into {{{/etc/modules}}} to enable power control:
~-{{{
freq_table
speedstep_centrino
cpufreq_ondemand
cpufreq_powersave
}}}-~
{{{cpufrequtils}}} must be enabled by editing {{{/etc/default/cpufrequtils}}}. I call {{{cpufreq-set}}} upon {{{acpid}}} AC adapter events and etiquette mode keys (see ../InputDevices).

There are also power saving modes for other components besides the CPU. Onfortunately, the {{{hdparm}}} commands to put the disk to sleep don't work with SATA disks underr libata (yet), so the {{{laptop-mode-tools}}} package is currently mostly useless.

== Power button and sleep button ==

The default {{{acpid}}} setup in Etch has a script for the '''power button''' that works as expected.

The '''sleep button''' is detected on the X50 but there is no default action. Here is mine:
~-{{{
#! /bin/sh
# /etc/acpi/actions/mw_sleep.sh
# Create an acpi event that calls this script!

# The resume partition: /dev/sda10 on my laptop
RESUME=8:10

export LC_ALL=C

# Security: be sure that no console is directly accessible after wake-up
kill_console_sessions() {
        wall <<EOF
 *** SLEEP BUTTON PRESSED ***
EOF
        sleep 2
        [ -n "$(dcop --all-users --list-sessions)" ] && {
                dcop --all-users kdesktop KScreensaverIface lock
        }
        ps -eo tty,comm,pid | \
                awk '/tty[0-9]* *login /{print $3}' | \
                xargs -r kill -TERM
}

### CAREFUL! Does this also work with fglrx (ATI proprietary X driver)??
grep -q fglrx /proc/modules && exit 0

## set resume partition
grep -q $RESUME /sys/power/resume || echo $RESUME >/sys/power/resume

kill_console_sessions

chvt 1 # change to text terminal to avoid problems with X
[ -w /sys/power/state ] && {
        /sbin/hwclock --systohc
        echo disk >/sys/power/state
        /sbin/hwclock --hctosys
}
chvt 7 # change back to the console you want activated after wake-up (X Windows)
}}}-~
The LID button behaves a bit weirdly though. After boot it always shows "state: closed". When I actually close the lid, keep it closed for about 20s, and reopen it, the state switches to "open". After that, the switch works, but there seems to be a 15s delay between the time I close the lid and the related ACPI event. There is no delay when the lid is opened. This is probably a BIOS issue.

Power Management and ACPI

(!) ?Date(2007-10-28T15:50:24Z) updated this page because stuff has become a lot easier with etch final release. (!)

Most of this works out-of-the-box. [http://faq.pathfinderteam.org/index.php/Samsung_X20 this page on the Samsung X20 (in German)] has many good hints, too.

Suspend-to-RAM works (ToDo: check if this works with the fglrx VGA driver, too).

The battery lifetime numbers Samsung publishes (6h) are marketing exaggerations. The normal battery in my notebook lasts about 2h when I'm working normally.

You can control almost all relevant power-saving features through the excellent laptop-mode-tools package. /etc/laptop-mode/laptop-mode.conf. With cryptsetup, even suspend-on-encyrpted-swap is working nicely. I use the laptop-mode-tools option ASSUME_SCSI_IS_SATA=1 for my hard drive, and it appears to work.

ACPI buttons (power, sleep, lid)

Both the power and sleep buttons work as expected (you can control their actions through /etc/default/acpi-support).

The LID button behaves a bit weirdly though. After boot it always shows "state: closed". When I actually close the lid, keep it closed for about 20s, and reopen it, the state switches to "open". After that, the switch works, but there seems to be a 15s delay between the time I close the lid and the related ACPI event. There is no delay when the lid is opened. This is probably a BIOS issue.