first-run-wizard: don't enable zram
[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 various settings"
12 NAME="pandora-state"
13
14 . /usr/pandora/scripts/op_common.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
25         # pnd_run.sh and nub configurator depend on nubs.state format
26         cat -v /proc/pandora/nub0/mode | sed -n '1p' > /etc/pandora/conf/nubs.state
27         cat -v /proc/pandora/nub0/mouse_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
28         cat -v /proc/pandora/nub0/scrollx_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
29         cat -v /proc/pandora/nub0/scrolly_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
30         cat -v /proc/pandora/nub0/scroll_rate| sed -n '1p' >> /etc/pandora/conf/nubs.state
31         cat -v /proc/pandora/nub0/mbutton_threshold | sed -n '1p' >> /etc/pandora/conf/nubs.state
32         cat -v /proc/pandora/nub1/mode | sed -n '1p' >> /etc/pandora/conf/nubs.state
33         cat -v /proc/pandora/nub1/mouse_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
34         cat -v /proc/pandora/nub1/scrollx_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
35         cat -v /proc/pandora/nub1/scrolly_sensitivity | sed -n '1p' >> /etc/pandora/conf/nubs.state
36         cat -v /proc/pandora/nub1/scroll_rate | sed -n '1p' >> /etc/pandora/conf/nubs.state
37         cat -v /proc/pandora/nub1/mbutton_threshold | sed -n '1p' >> /etc/pandora/conf/nubs.state
38         cat -v /proc/pandora/nub0/mbutton_delay | sed -n '1p' >> /etc/pandora/conf/nubs.state
39         cat -v /proc/pandora/nub1/mbutton_delay | sed -n '1p' >> /etc/pandora/conf/nubs.state
40
41         # nub tools want to update this file
42         chmod a+w /etc/pandora/conf/nubs.state
43 }
44
45 d_start() {
46         # Determine Pandora type
47         pnd_version=$(dmesg | grep OMAP3 | grep ES | awk '{print $3}')
48         echo $pnd_version > /tmp/pnd_version
49         
50         echo "Restoring Pandora specific settings"
51         
52         # Enable TV Out
53         if [ -f /etc/pandora/conf/tvout.state ]; then
54                 /usr/pandora/scripts/op_tvout.sh
55         fi
56         
57         # Set LEDs
58         highpow="$(cat /etc/pandora/conf/led.conf | grep HighPowerLED: | awk -F\: '{print $2}')"
59         echo $highpow > /sys/class/leds/pandora\:\:power/brightness #power LED bright
60         bright=$(cat /etc/pandora/conf/brightness.state)
61         if [ "$bright" -gt "0" ]; then
62                 echo $bright > $SYSFS_BACKLIGHT_BRIGHTNESS
63         fi
64         
65         # Set Gamma
66         cat /etc/pandora/conf/dirty_expire_centisecs >  /proc/sys/vm/dirty_expire_centisecs
67         cat /etc/pandora/conf/gamma.state > $SYSFS_GAMMA
68         if [ -f /etc/pandora/conf/dssgamma.state ]; then
69                 dssgamma=$(cat /etc/pandora/conf/dssgamma.state)
70                 dssgamma2=$(echo "scale=2;$dssgamma / 100" | bc)
71                 /usr/pandora/scripts/op_gamma.sh $dssgamma2
72         fi
73         
74         # Set Filter
75         if [ -f /etc/pandora/conf/filter.state ]; then
76                 filter=$(cat /etc/pandora/conf/filter.state)
77                 /usr/pandora/scripts/op_videofir.sh $filter 
78         fi
79         
80         # Check for unclean shutdown and set CPU Speed
81         cpuspeed="$(cat /etc/pandora/conf/cpu.conf | grep default | awk -F\: '{print $2}')"
82         oppmax="$(cat /etc/pandora/conf/cpu.conf | grep opp | awk -F\: '{print $2}')"
83         echo $oppmax > /proc/pandora/cpu_opp_max
84         if [ -f /etc/pandora/shutdown ]; then
85               rm /etc/pandora/shutdown
86               sync      
87         else
88               echo "No clean shutdown - will CPU Speed will be set to safe value."
89               echo "Yes" > /tmp/nocleanwarn
90               chmod 777 /tmp/nocleanwarn
91                 if [ "$pnd_version" == "OMAP3630" ]; then
92                   cpuspeed="1000"
93                 else
94                   cpuspeed="600"
95                 fi
96         fi
97         /usr/pandora/scripts/op_cpuspeed.sh -n $cpuspeed
98         
99         # Set DSP Speed
100         
101         if [ "$pnd_version" == "OMAP3630" ]; then
102                   dspspeed="800"
103                 else
104                   dspspeed="430"
105         fi
106         /usr/pandora/scripts/op_dspspeed.sh -n $dspspeed
107         
108         # Set nubs
109         sed -n '1p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mode
110         sed -n '2p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mouse_sensitivity
111         sed -n '3p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/scrollx_sensitivity
112         sed -n '4p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/scrolly_sensitivity
113         sed -n '5p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/scroll_rate
114         sed -n '6p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mbutton_threshold
115         sed -n '7p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mode
116         sed -n '8p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mouse_sensitivity
117         sed -n '9p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/scrollx_sensitivity
118         sed -n '10p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/scrolly_sensitivity
119         sed -n '11p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/scroll_rate
120         sed -n '12p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mbutton_threshold
121         sed -n '13p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mbutton_delay
122         sed -n '14p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mbutton_delay
123         
124         # Enable ZRAM Swap if user has enabled the module in /etc/modules
125         if [ -e /dev/zram0 ]; then
126                 echo "Enabling ZRAM Swap"
127                 mkswap /dev/zram0
128                 swapon -p 5 /dev/zram0
129         fi
130
131         # set audio powerdown delay (ms)
132         if [ -e /sys/devices/platform/soc-audio/PCM1773/pmdown_time ]; then
133                 echo 60000 > /sys/devices/platform/soc-audio/PCM1773/pmdown_time
134         fi
135 }
136
137 case "$1" in
138   start)
139         echo -n "Starting $DESC: $NAME - "
140         d_start
141         echo "."
142         ;;
143   stop)
144         echo -n "Stopping $DESC: $NAME - "
145         d_stop
146         echo "."
147         ;;
148   reload)
149         echo -n "Reloading $DESC: $NAME - "
150         d_start
151         echo "."
152         ;;      
153   restart|force-reload)
154         echo -n "Restarting $DESC: $NAME - "
155         d_stop
156         sleep 1
157         d_start
158         echo "."
159         ;;
160   *)
161         echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
162         exit 1
163         ;;
164 esac
165
166 exit 0