a11d6562b1393190bb415ec6943f16b8e044742f
[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-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 }
19
20 d_start() {
21         echo "Restoring LCD-Settings"
22         cat /etc/pandora/conf/brightness.state > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness 
23         cat /etc/pandora/conf/gamma.state > /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma
24 }
25
26 case "$1" in
27   start)
28         echo -n "Starting $DESC: $NAME - "
29         d_start
30         echo "."
31         ;;
32   stop)
33         echo -n "Stopping $DESC: $NAME - "
34         d_stop
35         echo "."
36         ;;
37   reload)
38         echo -n "Reloading $DESC: $NAME - "
39         d_start
40         echo "."
41         ;;      
42   restart|force-reload)
43         echo -n "Restarting $DESC: $NAME - "
44         d_stop
45         sleep 1
46         d_start
47         echo "."
48         ;;
49   *)
50         echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
51         exit 1
52         ;;
53 esac
54
55 exit 0