80d0c3fcd74ba2551be52da445153ea91355ce47
[openpandora.oe.git] / recipes / pandora-system / pandora-lcd-state / rc.pandora-lcd-state
1 #!/bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides:          pandora-lcd-state
5 # Required-Start:    #adjust
6 # Required-Stop:     #adjust
7 # Default-Start:     S
8 # Default-Stop:      0 1 6
9 ### END INIT INFO
10  
11 DESC="OpenPandora Save and Restore LCD Settings"
12 NAME="pandora-lcd-state"
13
14 d_stop() {
15         echo "Saving LCD and Nub-Settings"
16         cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /etc/pandora/conf/brightness.state
17         cat /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma > /etc/pandora/conf/gamma.state
18         cat cat -v /proc/pandora/vsense66 | sed -n '1p' > /etc/pandora/conf/nubs.state
19         cat cat -v /proc/pandora/vsense67 | sed -n '1p' >> /etc/pandora/conf/nubs.state
20 }
21
22 d_start() {
23         echo "Restoring LCD and Nub-Settings"
24         cat /etc/pandora/conf/brightness.state > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness 
25         cat /etc/pandora/conf/gamma.state > /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma
26         sed -n '1p' /etc/pandora/conf/nubs.state > /proc/pandora/vsense66
27         sed -n '2p' /etc/pandora/conf/nubs.state > /proc/pandora/vsense67
28 }
29
30 case "$1" in
31   start)
32         echo -n "Starting $DESC: $NAME - "
33         d_start
34         echo "."
35         ;;
36   stop)
37         echo -n "Stopping $DESC: $NAME - "
38         d_stop
39         echo "."
40         ;;
41   reload)
42         echo -n "Reloading $DESC: $NAME - "
43         d_start
44         echo "."
45         ;;      
46   restart|force-reload)
47         echo -n "Restarting $DESC: $NAME - "
48         d_stop
49         sleep 1
50         d_start
51         echo "."
52         ;;
53   *)
54         echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
55         exit 1
56         ;;
57 esac
58
59 exit 0