rc.pandora-state: Minor: Fixed comments to reflect the new startup order
[openpandora.oe.git] / recipes / pandora-system / pandora-state / rc.pandora-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:     5 3
8 # Default-Stop:      0 1 6
9 ### END INIT INFO
10  
11 DESC="OpenPandora Save and Restore LCD Settings"
12 NAME="pandora-state"
13
14 . /usr/pandora/scripts/op_paths.sh
15
16 d_stop() {
17         echo "Saving Pandora specific settings"
18         bright=$(cat $SYSFS_BACKLIGHT_BRIGHTNESS)
19         if [ $bright != "0" ]; then
20             echo $bright > /etc/pandora/conf/brightness.state
21         fi
22         touch /etc/pandora/shutdown
23         cat $SYSFS_GAMMA > /etc/pandora/conf/gamma.state
24         cat -v /proc/pandora/nub0/mode | sed -n '1p' > /etc/pandora/conf/nubs.state
25         cat -v /proc/pandora/nub0/mouse_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
26         cat -v /proc/pandora/nub0/scrollx_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
27         cat -v /proc/pandora/nub0/scrolly_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
28         cat -v /proc/pandora/nub0/scroll_rate| sed -n '1p' >> /etc/pandora/conf/nubs.state
29         cat -v /proc/pandora/nub0/mbutton_threshold | sed -n '1p' >> /etc/pandora/conf/nubs.state
30         cat -v /proc/pandora/nub1/mode | sed -n '1p' >> /etc/pandora/conf/nubs.state
31         cat -v /proc/pandora/nub1/mouse_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
32         cat -v /proc/pandora/nub1/scrollx_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
33         cat -v /proc/pandora/nub1/scrolly_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
34         cat -v /proc/pandora/nub1/scroll_rate | sed -n '1p' >> /etc/pandora/conf/nubs.state
35         cat -v /proc/pandora/nub1/mbutton_threshold | sed -n '1p' >> /etc/pandora/conf/nubs.state
36         cat -v /proc/pandora/nub0/mbutton_delay | sed -n '1p' >> /etc/pandora/conf/nubs.state
37         cat -v /proc/pandora/nub1/mbutton_delay | sed -n '1p' >> /etc/pandora/conf/nubs.state
38 }
39
40 d_start() {
41         echo "Restoring Pandora specific settings"
42         highpow="$(cat /etc/pandora/conf/led.conf | grep HighPowerLED: | awk -F\: '{print $2}')"
43         echo $highpow > /sys/class/leds/pandora\:\:power/brightness #power LED bright
44         bright=$(cat /etc/pandora/conf/brightness.state)
45         if [ "$bright" -gt "0" ]; then
46                 echo $bright > $SYSFS_BACKLIGHT_BRIGHTNESS
47         fi
48         cat /etc/pandora/conf/dirty_expire_centisecs >  /proc/sys/vm/dirty_expire_centisecs
49         cat /etc/pandora/conf/gamma.state > $SYSFS_GAMMA
50         if [ -f /etc/pandora/conf/dssgamma.state ]; then
51                 dssgamma=$(cat /etc/pandora/conf/dssgamma.state)
52                 dssgamma2=$(echo "scale=2;$dssgamma / 100" | bc)
53                 /usr/pandora/scripts/op_gamma.sh $dssgamma2
54         fi
55         if [ -f /etc/pandora/conf/filter.state ]; then
56                 filter=$(cat /etc/pandora/conf/filter.state)
57                 /usr/pandora/scripts/op_videofir.sh $filter 
58         fi
59         cpuspeed="$(cat /etc/pandora/conf/cpu.conf | grep default | awk -F\: '{print $2}')"
60         oppmax="$(cat /etc/pandora/conf/cpu.conf | grep opp | awk -F\: '{print $2}')"
61         echo $oppmax > /proc/pandora/cpu_opp_max
62         if [ -f /etc/pandora/shutdown ]; then
63               rm /etc/pandora/shutdown
64               sync
65               /usr/pandora/scripts/op_cpuspeed.sh -n $cpuspeed
66         else
67               echo "No clean shutdown - will not set CPU speed"
68               echo "Yes" > /tmp/nocleanwarn
69               chmod 777 /tmp/nocleanwarn
70         fi
71         sed -n '1p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mode
72         sed -n '2p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mouse_sensitivity
73         sed -n '3p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/scrollx_sensitivity
74         sed -n '4p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/scrolly_sensitivity
75         sed -n '5p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/scroll_rate
76         sed -n '6p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mbutton_threshold
77         sed -n '7p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mode
78         sed -n '8p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mouse_sensitivity
79         sed -n '9p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/scrollx_sensitivity
80         sed -n '10p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/scrolly_sensitivity
81         sed -n '11p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/scroll_rate
82         sed -n '12p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mbutton_threshold
83         sed -n '13p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mbutton_delay
84         sed -n '14p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mbutton_delay
85         echo "Enabling ZRAM Swap"
86         mkswap /dev/zram0
87         swapon -p 5 /dev/zram0
88
89         # set audio powerdown delay (ms)
90         if [ -e /sys/devices/platform/soc-audio/PCM1773/pmdown_time ]; then
91                 echo 60000 > /sys/devices/platform/soc-audio/PCM1773/pmdown_time
92         fi
93 }
94
95 case "$1" in
96   start)
97         echo -n "Starting $DESC: $NAME - "
98         d_start
99         echo "."
100         ;;
101   stop)
102         echo -n "Stopping $DESC: $NAME - "
103         d_stop
104         echo "."
105         ;;
106   reload)
107         echo -n "Reloading $DESC: $NAME - "
108         d_start
109         echo "."
110         ;;      
111   restart|force-reload)
112         echo -n "Restarting $DESC: $NAME - "
113         d_stop
114         sleep 1
115         d_start
116         echo "."
117         ;;
118   *)
119         echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
120         exit 1
121         ;;
122 esac
123
124 exit 0