Hi again.

Here is a draft patch for adding TuxOnIce support to the pm/defaults and pm/functions files. I'm calling it a draft because I want your feedback on whether it's the right sort of approach. I'm not really keen on adding a variable per sysfs entry, and so have only added the most frequently used ones in this iteration.

Victor, I'm not ignoring your comment about hybrid support. I'd just already written the lines when your email came, and thought it might never-the-less help to have on record how to do hybrid with TuxOnIce. (This is only an RFC anyway).

Regards,

Nigel
diff --git a/pm/defaults b/pm/defaults
index d5b6447..763f436 100644
--- a/pm/defaults
+++ b/pm/defaults
@@ -7,3 +7,8 @@ HIBERNATE_RESUME_POST_VIDEO="no"
 
 SUSPEND_MODULES=""
 
+TUXONICE_USERUI="/usr/lib/tuxonice-userui/tuxoniceui_text"
+TUXONICE_POWERDOWN_METHOD="4"
+TUXONICE_EXTRA_PAGES_ALLOWANCE="500"
+TUXONICE_USERUI_ENABLE_ESCAPE="1"
+TUXONICE_COMPRESSION_ALGORITHM="lzf"
diff --git a/pm/functions b/pm/functions
index 9a82f45..0a6e63b 100755
--- a/pm/functions
+++ b/pm/functions
@@ -132,13 +132,54 @@ do_suspend()
 
 do_hibernate()
 {
-	echo -n "${HIBERNATE_MODE}" > /sys/power/disk
-	echo -n "disk" > /sys/power/state
+	if [ -d /sys/power/tuxonice ]; then
+
+		echo "${TUXONICE_USERUI}" > /sys/power/tuxonice/user_interface/program
+		if [ -n "${TUXONICE_USERUI}" ] ; then
+			echo "1" > /sys/power/tuxonice/user_interface/enabled
+		else
+			echo "0" > /sys/power/tuxonice/user_interface/enabled
+		fi
+
+		echo "1" > /sys/power/tuxonice/userui_interface/enabled
+		echo "${TUXONICE_EXTRA_PAGES_ALLOWANCE}" > /sys/power/tuxonice/extra_pages_allowance
+		echo "${TUXONICE_USERUI_ENABLE_ESCAPE}" > /sys/power/tuxonice/user_interface/enable_escape
+		
+		echo "${TUXONICE_COMPRESSION_ALGORITHM}" > /sys/power/tuxonice/compression/algorithm
+		if [ -n "${TUXONICE_COMPRESSION_ALGORITHM}" ] ; then
+			echo "1" > /sys/power/tuxonice/compression/enabled
+		else
+			echo "0" > /sys/power/tuxonice/compression/enabled
+		fi
+
+		# TuxOnIce has a separate entry for rebooting, with rebooting
+		# trumping powering down. We therefore explicitly disable
+		# rebooting when the user selects a powerdown method.
+		case "${HIBERNATE_MODE}" in
+			"platform")
+				echo "0" > /sys/power/tuxonice/reboot
+				echo "4" > /sys/power/tuxonice/powerdown_method
+				;;
+			"shutdown")
+				echo "0" > /sys/power/tuxonice/reboot
+				echo "5" > /sys/power/tuxonice/powerdown_method
+				;;
+			"reboot")
+				echo "1" > /sys/power/tuxonice/reboot
+				;;
+		esac
+		echo "anything" > /sys/power/tuxonice/do_hibernate
+	else
+		echo -n "${HIBERNATE_MODE}" > /sys/power/disk
+		echo -n "disk" > /sys/power/state
+	fi
 }
 
 do_suspend_hybrid()
 {
-	return 1
+	echo "0" > /sys/power/tuxonice/reboot
+	echo -n "3" > /sys/power/tuxonice/powerdown_method
+	echo "anything" > /sys/power/tuxonice/do_hibernate
 }
 
 pm_main()
_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to