X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=openpandora.oe.git;a=blobdiff_plain;f=recipes%2Fpandora-system%2Fpandora-scripts%2Fop_power.sh;h=f6e3fee6965ecdf43573695bf68d127fba427e11;hp=8dc1c21c74fcbc3a115421c373137eb42c4b2f8f;hb=0e1c7fef14276a3421a6bbab792ac1ab58f12a40;hpb=afadc0e4570ee55a698f97f832cb3df1c3441407 diff --git a/recipes/pandora-system/pandora-scripts/op_power.sh b/recipes/pandora-system/pandora-scripts/op_power.sh index 8dc1c21..f6e3fee 100644 --- a/recipes/pandora-system/pandora-scripts/op_power.sh +++ b/recipes/pandora-system/pandora-scripts/op_power.sh @@ -5,6 +5,8 @@ # XXX: better use lockfile (or something), but it's not in current firmware test -e /tmp/op_power.lock && exit 2 touch /tmp/op_power.lock +highpow="$(cat /etc/pandora/conf/led.conf | grep HighPowerLED: | awk -F\: '{print $2}')" +lowpow="$(cat /etc/pandora/conf/led.conf | grep LowPowerLED: | awk -F\: '{print $2}')" debug(){ return 1 # 0 when debugging, 1 when not @@ -103,12 +105,13 @@ lowPowerOn(){ #switch from normal to lowpower mode suspend_net cat /proc/pandora/cpu_mhz_max > /tmp/oldspeed - /usr/pandora/scripts/op_cpuspeed.sh 125 + /usr/pandora/scripts/op_cpuspeed.sh -n 125 } lowPowerOff(){ # switch from lowpower to normal mode oldspeed=$(cat /tmp/oldspeed) - /usr/pandora/scripts/op_cpuspeed.sh $oldspeed + /usr/pandora/scripts/op_cpuspeed.sh -n $oldspeed + rm -f /tmp/oldspeed display_on resume_net @@ -118,13 +121,25 @@ lowPowerOff(){ # switch from lowpower to normal mode do kill -CONT $PID done - echo 255 > /sys/class/leds/pandora\:\:power/brightness #power LED bright + echo $highpow > /sys/class/leds/pandora\:\:power/brightness #power LED bright +} + +display_on_with_checks() { + # after turning on the display, we don't want lowpower state + # (which could be active because of some races) + if [ "$powerstate" = "buttonlowpower" -o "$powerstate" = "lidlowpower" -o \ + -e /tmp/oldspeed ] + then + lowPowerOff + else + display_on + fi } show_message() { # TODO: check if desktop is visible; maybe use layer3? xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}') - cmd="DISPLAY=:0.0 zenity --info --text \"$1\"" + cmd="DISPLAY=:0.0 zenity --info --text \"$1\" --timeout 10" su -c "$cmd" $xfceuser } @@ -149,10 +164,6 @@ suspend_real() { return 1 fi - # TODO: we probably want to NOT do real suspend if: - # - cards don't unmount (running PNDs will break) - # - while charging too, since it stops on suspend? - if ! grep -q 'mmc_core.removable=0' /proc/cmdline; then # must unmount cards because they will be "ejected" on suspend # (some filesystems may even deadlock if we don't do this due to bugs) @@ -183,8 +194,9 @@ Please do not remove SD cards while pandora is suspended, doing so will corrupt # get rid of modules that prevent suspend due to bugs modules="$(lsmod | awk '{print $1}' | xargs echo)" - blacklist="ehci_hcd g_zero g_audio g_ether g_serial g_midi gadgetfs g_file_storage - g_mass_storage g_printer g_cdc g_multi g_hid g_dbgp g_nokia g_webcam g_ncm g_acm_ms" + blacklist="g_zero g_audio g_ether g_serial g_midi gadgetfs g_file_storage + g_mass_storage g_printer g_cdc g_multi g_hid g_dbgp g_nokia g_webcam g_ncm g_acm_ms + ehci_hcd bridgedriver" restore_list="" for mod in $modules; do if echo $blacklist | grep -q "\<$mod\>"; then @@ -200,12 +212,14 @@ Please do not remove SD cards while pandora is suspended, doing so will corrupt # if we are here, either we already resumed or the suspend failed if [ -n "$restore_list" ]; then - modprobe $restore_list + for module in $restore_list; do + modprobe $module + done fi display_on resume_net - echo 255 > /sys/class/leds/pandora\:\:power/brightness + echo $highpow > /sys/class/leds/pandora\:\:power/brightness # wait here a bit to prevent this script from running again (keep op_power.lock) # in case user did resume using the power switch. @@ -216,7 +230,7 @@ Please do not remove SD cards while pandora is suspended, doing so will corrupt suspend_() { # dim power LED - echo 16 > /sys/class/leds/pandora\:\:power/brightness + echo $lowpow > /sys/class/leds/pandora\:\:power/brightness if suspend_real; then # resumed already @@ -280,7 +294,7 @@ elif [[ "$2" == "lid" ]]; then powerstate="on" ;; *) - (debug && echo "display_on") || display_on + (debug && echo "display_on") || display_on_with_checks powerstate="on" ;; esac @@ -302,7 +316,19 @@ elif [[ "$2" == "lid" ]]; then esac fi fi - fi +elif [[ "$2" == "screensaver" ]]; then + # warning: don't try to interact with X or do real suspend here - + # will cause various deadlocks + unset DISPLAY + + if [[ "$1" == 0 ]]; then # deactivate screensaver + display_on_with_checks + powerstate="on" + elif [[ "$1" == 1 ]]; then # activate screensaver + display_off + fi +fi + debug && echo "powerstate=$powerstate" echo "$powerstate" > /tmp/powerstate