New Startup-Script: Save and Restore LCD Brightness and Gamma settings
authorMichael Mrozek <EvilDragon@openpandora.org>
Mon, 12 Apr 2010 01:16:57 +0000 (03:16 +0200)
committerMichael Mrozek <EvilDragon@openpandora.org>
Mon, 12 Apr 2010 01:16:57 +0000 (03:16 +0200)
recipes/pandora-system/pandora-lcd-state.bb [new file with mode: 0755]
recipes/pandora-system/pandora-lcd-state/brightness.state [new file with mode: 0644]
recipes/pandora-system/pandora-lcd-state/gamma.state [new file with mode: 0644]
recipes/pandora-system/pandora-lcd-state/rc.pandora-lcd-state [new file with mode: 0644]

diff --git a/recipes/pandora-system/pandora-lcd-state.bb b/recipes/pandora-system/pandora-lcd-state.bb
new file mode 100755 (executable)
index 0000000..87d9bdb
--- /dev/null
@@ -0,0 +1,28 @@
+DESCRIPTION = "Save and restore the brightness and gamma state on shutdown / startup"
+LICENSE = "GPLv2"
+
+COMPATIBLE_MACHINE = "omap3-pandora"
+
+PR = "r0"
+inherit update-rc.d
+
+INITSCRIPT_NAME = "pandora-lcd-state"
+INITSCRIPT_PARAMS = "start 39 S . stop 31 0 1 6 ."
+
+SRC_URI = " \
+          file://rc.pandora-lcd-state \
+         file://gamma.state \
+         file://brightness.state \
+"
+
+do_install() {
+          install -d ${D}${sysconfdir}/init.d/
+          install -m 0755 ${WORKDIR}/rc.pandora-lcd-state ${D}${sysconfdir}/init.d/pandora-lcd-state
+         install -d ${D}${sysconfdir}/pandora/conf/
+          install -m 0644 ${WORKDIR}/gamma.state ${D}${sysconfdir}/pandora/conf/gamma.state
+          install -m 0644 ${WORKDIR}/brightness.state ${D}${sysconfdir}/pandora/conf/brightness.state
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+FILES_${PN} += "${prefix} ${datadir}"
diff --git a/recipes/pandora-system/pandora-lcd-state/brightness.state b/recipes/pandora-system/pandora-lcd-state/brightness.state
new file mode 100644 (file)
index 0000000..597975b
--- /dev/null
@@ -0,0 +1 @@
+35
\ No newline at end of file
diff --git a/recipes/pandora-system/pandora-lcd-state/gamma.state b/recipes/pandora-system/pandora-lcd-state/gamma.state
new file mode 100644 (file)
index 0000000..e5edf04
--- /dev/null
@@ -0,0 +1 @@
+105 315 381 431 490 537 579 686 780 837 880 1023
diff --git a/recipes/pandora-system/pandora-lcd-state/rc.pandora-lcd-state b/recipes/pandora-system/pandora-lcd-state/rc.pandora-lcd-state
new file mode 100644 (file)
index 0000000..a11d656
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides:          pandora-lcd-state
+# Required-Start:    #adjust
+# Required-Stop:     #adjust
+# Default-Start:     S
+# Default-Stop:      0 1 6
+### END INIT INFO
+DESC="OpenPandora Save and Restore LCD Settings"
+NAME="pandora-lcd-state"
+
+d_stop() {
+       echo "Saving LCD-Settings"
+       cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /etc/pandora/conf/brightness.state
+       cat /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma > /etc/pandora/conf/gamma.state
+}
+
+d_start() {
+       echo "Restoring LCD-Settings"
+       cat /etc/pandora/conf/brightness.state > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness 
+       cat /etc/pandora/conf/gamma.state > /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma
+}
+
+case "$1" in
+  start)
+       echo -n "Starting $DESC: $NAME - "
+       d_start
+       echo "."
+       ;;
+  stop)
+       echo -n "Stopping $DESC: $NAME - "
+       d_stop
+       echo "."
+       ;;
+  reload)
+       echo -n "Reloading $DESC: $NAME - "
+       d_start
+       echo "."
+       ;;      
+  restart|force-reload)
+       echo -n "Restarting $DESC: $NAME - "
+       d_stop
+       sleep 1
+       d_start
+       echo "."
+       ;;
+  *)
+       echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
+       exit 1
+       ;;
+esac
+
+exit 0