[Debian-eeepc-commits] [SCM] Maintenance of eeepc-acpi-scripts debian package branch, shengine, updated. 1.1.0-beta.1-12-ge7d69fd

Darren Salt linux at youmustbejoking.demon.co.uk
Fri May 29 19:32:37 UTC 2009


The following commit has been merged in the shengine branch:
commit e7d69fd36465e6badad3639de6b514e49c5c8f4e
Author: Darren Salt <linux at youmustbejoking.demon.co.uk>
Date:   Tue May 26 21:24:07 2009 +0100

    Allow clocking changes when switching between battery and mains.
    
    This is done via whichever key is configured as "handle_shengine", which
    will now cause cycling through 'performance', 'normal', 'power saving'
    (where applicable) and 'automatic', which uses PWR_CLOCK_AC and
    PWR_CLOCK_BATTERY.
    
    The manual/automatic state is stored in /var/lib/eeepc-acpi-scripts/cpufv.

diff --git a/debian/changelog b/debian/changelog
index 3e557b0..39ed6ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,8 +10,9 @@ eeepc-acpi-scripts (1.1.1) unstable; urgency=low
   * Alter the audio control blacklisting to allow for controls for which
     (for example) muting only should be allowed.
   * Add "Beep" to the audio control blacklist, but only for volume control.
-  * Add support for the 'super hybrid engine', ready for when the kernel
-    gets this support.
+  * Add support for the 'super hybrid engine', which is accessible in kernel
+    2.6.30-rc7 and later, and allow for automatic upclocking when on AC and
+    downclocking when on battery (default is not to do so).
 
  -- Darren Salt <linux at youmustbejoking.demon.co.uk>  Sat, 25 Apr 2009 16:47:17 +0100
 
diff --git a/debian/dirs b/debian/dirs
index 4d094c4..ffb1f0e 100644
--- a/debian/dirs
+++ b/debian/dirs
@@ -5,3 +5,4 @@ etc/acpi/lib
 etc/modprobe.d
 lib/udev/rules.d
 usr/share/eeepc-acpi-scripts
+var/lib/eeepc-acpi-scripts
diff --git a/debian/eeepc-acpi-scripts.default b/debian/eeepc-acpi-scripts.default
index fe86f0e..3fe2cce 100644
--- a/debian/eeepc-acpi-scripts.default
+++ b/debian/eeepc-acpi-scripts.default
@@ -112,3 +112,13 @@ FnF_VOLUMEDOWN='handle_volume_down'
 # F9/F12 - increase volume
 FnF_VOLUMEUP='handle_volume_up'
 
+# Clocking options when on AC or battery
+# 0 = overclocked
+# 1 = standard
+# 2 = underclocked
+# '' = leave as is
+# PWR_CLOCK_AC      should be '0', '1', or ''
+# PWR_CLOCK_BATTERY should be '1', '2', or ''
+# If one is '', so should the other else the state will only be changed one way
+PWR_CLOCK_AC=
+PWR_CLOCK_BATTERY=
diff --git a/debian/eeepc-acpi-scripts.init b/debian/eeepc-acpi-scripts.init
index 1fa8f4f..7b0d8a7 100644
--- a/debian/eeepc-acpi-scripts.init
+++ b/debian/eeepc-acpi-scripts.init
@@ -89,6 +89,22 @@ case "$1" in
     # Done.
 
     log_action_end_msg 0
+
+    if [ -f /etc/default/eeepc-acpi-scripts -a -f /etc/acpi/lib/shengine.sh ]; then
+	log_action_begin_msg 'Setting super hybrid engine according to configuration'
+	. /etc/default/eeepc-acpi-scripts
+	. /etc/acpi/lib/shengine.sh
+	if [ "$SHENGINE_SETTING" != auto ]; then
+	    log_action_cont_msg '(manual)'
+	elif [ "$(cat /sys/class/power_supply/AC0/online 2>/dev/null)" = 0 ]; then
+	    log_action_cont_msg '(battery)'
+	    [ "${PWR_CLOCK_BATTERY:+x}" ] && set_shengine "$PWR_CLOCK_BATTERY" || :
+	else
+	    log_action_cont_msg '(AC)'
+	    [ "${PWR_CLOCK_AC:+x}" ] && set_shengine "$PWR_CLOCK_AC" || :
+	fi
+	log_action_end_msg $?
+    fi
     ;;
 
   stop)
diff --git a/debian/postrm b/debian/postrm
index 0f647a9..7e7f615 100644
--- a/debian/postrm
+++ b/debian/postrm
@@ -5,10 +5,15 @@ PKG=eeepc-acpi-scripts
 set -e
 
 case "$1" in
-    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    upgrade|failed-upgrade|abort-install|abort-upgrade|remove|disappear)
         invoke-rc.d acpid restart>/dev/null
     ;;
 
+    purge)
+        invoke-rc.d acpid restart>/dev/null
+        rm -f /var/lib/eeepc-acpi-scripts/cpufv
+    ;;
+
     *)
         echo "postrm called with unknown argument \`$1'" >&2
         exit 1
diff --git a/etc/acpi/actions/hotkey.sh b/etc/acpi/actions/hotkey.sh
index dfcd28d..3f58d15 100755
--- a/etc/acpi/actions/hotkey.sh
+++ b/etc/acpi/actions/hotkey.sh
@@ -70,11 +70,17 @@ handle_bluetooth_toggle() {
 handle_shengine() {
     . /etc/acpi/lib/shengine.sh
     if [ -e "$SHENGINE_CTL" ]; then
-	cycle_shengine
-	case $? in
+	if [ "$1" = '' ]; then
+	    cycle_shengine
+	else
+	    set_shengine "$1"
+	fi
+	if [ "$2" != '' ]; then return; fi
+	case $(get_shengine) in
 	    0) notify super_hybrid_engine 'S. H. Engine: Performance'; ;;
 	    1) notify super_hybrid_engine 'S. H. Engine: Standard'; ;;
 	    2) notify super_hybrid_engine 'S. H. Engine: Power-saving'; ;;
+	    255) notify super_hybrid_engine 'S. H. Engine: Automatic'; ;;
 	    *) notify error 'S. H. Engine unavailable'
 	esac
     else
@@ -216,4 +222,27 @@ case $code in
 	    ${SOFTBTN4_ACTION:-handle_bluetooth_toggle}
 	fi
 	;;
+
+    # Other "hotkey" events
+
+    # AC adapter present
+    00000050)
+	. /etc/acpi/lib/shengine.sh
+	if [ "$SHENGINE_SETTING" = auto ]; then
+	    if [ "$PWR_CLOCK_AC" -a $(get_shengine -) -gt "$PWR_CLOCK_AC" ]; then
+		handle_shengine "$PWR_CLOCK_AC" -
+	    fi
+	fi
+	;;
+
+    # AC adapter not present
+    00000051)
+	. /etc/acpi/lib/shengine.sh
+	if [ "$SHENGINE_SETTING" = auto ]; then
+	    if [ "$PWR_CLOCK_BATTERY" -a $(get_shengine -) -lt "$PWR_CLOCK_BATTERY" ]; then
+		handle_shengine "$PWR_CLOCK_BATTERY" -
+	    fi
+	fi
+	;;
+
 esac
diff --git a/etc/acpi/lib/shengine.sh b/etc/acpi/lib/shengine.sh
index 0481a55..3ef28ff 100644
--- a/etc/acpi/lib/shengine.sh
+++ b/etc/acpi/lib/shengine.sh
@@ -3,22 +3,52 @@
 # to be sourced
 
 SHENGINE_CTL=/sys/devices/platform/eeepc/cpufv
-SHENGINE_LIMIT="$(cat "$SHENGINE_CTL" 2>/dev/null)"
+SHENGINE_LIMIT="$(cat "$SHENGINE_CTL" 2>/dev/null || :)"
 SHENGINE_LIMIT=$(( ${SHENGINE_LIMIT:-768} >> 8 ))
 
+SHENGINE_CONFIG=/var/lib/eeepc-acpi-scripts/cpufv
+SHENGINE_SETTING="$(cat "$SHENGINE_CONFIG" 2>/dev/null || :)"
+
 get_shengine()
 {
-    if [ -e "$SHENGINE_CTL" ]; then
-        return $(( $(cat "$SHENGINE_CTL") & 0xFF ))
+    if [ "$SHENGINE_SETTING" = auto -a "$1" = '' ]; then
+	echo 255
+    elif [ -e "$SHENGINE_CTL" ]; then
+        echo $(( $(cat "$SHENGINE_CTL") & 0xFF ))
+    else
+	echo 3
+    fi
+}
+
+set_shengine()
+{
+    if [ -e "$SHENGINE_CTL" -a "$SHENGINE_SETTING" = auto ]; then
+	echo "$1" > "$SHENGINE_CTL"
     fi
-    return 3
 }
 
 cycle_shengine()
 {
     if [ -e "$SHENGINE_CTL" ]; then
-	get_shengine
-	echo $(( ($? + 1) % $SHENGINE_LIMIT)) > "$SHENGINE_CTL"
+	SHENGINE_CLOCKING=$(get_shengine)
+	if [ "$SHENGINE_SETTING" = auto ]; then
+	    SHENGINE_CLOCKING=0
+	    SHENGINE_SETTING=manual
+	    echo manual >"$SHENGINE_CONFIG"
+	else
+	    SHENGINE_CLOCKING=$(( ($SHENGINE_CLOCKING + 1) % $SHENGINE_LIMIT))
+	    if [ "$SHENGINE_CLOCKING" = 0 ]; then
+		if [ "$(cat /sys/class/power_supply/AC0/online 2>/dev/null || echo 1)" != 0 ]; then
+		    SHENGINE_CLOCKING="$PWR_CLOCK_AC"
+		else
+		    SHENGINE_CLOCKING="$PWR_CLOCK_BATTERY"
+		fi
+		if [ "$SHENGINE_CLOCKING:+1" ]; then
+		    SHENGINE_SETTING=auto
+		    echo auto >"$SHENGINE_CONFIG"
+		fi
+	    fi
+	fi
+	echo "${SHENGINE_CLOCKING:-0}" > "$SHENGINE_CTL"
     fi
-    get_shengine
 }

-- 
Maintenance of eeepc-acpi-scripts debian package



More information about the Debian-eeepc-commits mailing list