From: Grazvydas Ignotas Date: Tue, 21 Jun 2016 22:32:46 +0000 (+0300) Subject: pandora-scripts: avoid unblank while lid is closed X-Git-Tag: sz_175~2 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=openpandora.oe.git;a=commitdiff_plain;h=2475a69ed237c3ad1b828a707f073a5a58646d82 pandora-scripts: avoid unblank while lid is closed A slightly tuned patch from Zink from the forums: https://pyra-handheld.com/boards/threads/trying-to-fix-the-backlight-bug.77558 --- diff --git a/recipes/pandora-system/pandora-scripts.bb b/recipes/pandora-system/pandora-scripts.bb index 8309a0e..c99b6ec 100644 --- a/recipes/pandora-system/pandora-scripts.bb +++ b/recipes/pandora-system/pandora-scripts.bb @@ -5,7 +5,7 @@ COMPATIBLE_MACHINE = "omap3-pandora" RDEPENDS = "bash sed gawk grep zenity" -PR = "r169" +PR = "r170" SRC_URI = " \ file://op_bright.sh \ diff --git a/recipes/pandora-system/pandora-scripts/op_power.sh b/recipes/pandora-system/pandora-scripts/op_power.sh index 88ca1a8..d6d4c51 100644 --- a/recipes/pandora-system/pandora-scripts/op_power.sh +++ b/recipes/pandora-system/pandora-scripts/op_power.sh @@ -29,6 +29,34 @@ fi debug && echo "powerstate=$powerstate" +is_lid_open() { + if [ -x /usr/bin/op_lidstate -a ! -e /etc/pandora/my_lid_is_broken ]; then + if [ $(op_lidstate) = "0" ]; then + # lid is open - return true + return 0 + else + # lid is closed - return false + return -1 + fi + else + # op_lidstate program not found, report lid open + # this should cause less trouble + return 0 + fi +} + +powerstate_try_on() { + # if lid is open switch powerstate to "on" + # if lid is closed switch powerstate to "liddisplayoff" + # this prevents screen off lock when shoulder butttons + # are pressed while the lid is closed + if is_lid_open; then + powerstate="on" + else + powerstate="liddisplayoff" + fi +} + suspend_net() { # This is kernel 3.x only, # but ignored since 2.6 only has lowpower anyways (no suspend) @@ -63,6 +91,13 @@ resume_net() { } display_on() { + # only turn on display if lid is open + if ! is_lid_open; then + if [[ "$1" != "force" ]]; then + return 0 + fi + fi + echo 0 > /sys/class/graphics/fb0/blank # only bother restoring brightness if it's 0 @@ -120,7 +155,7 @@ lowPowerOff(){ # switch from lowpower to normal mode /usr/pandora/scripts/op_cpuspeed.sh -n $oldspeed rm -f /tmp/oldspeed - display_on + display_on force resume_net pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p') @@ -228,7 +263,7 @@ Please do not remove SD cards while pandora is suspended, doing so will corrupt # so we reload hwclock here (WizardStan) hwclock -u -s - display_on + display_on force resume_net echo $led_high > /sys/class/leds/pandora\:\:power/brightness @@ -251,7 +286,7 @@ suspend_() { fi } -resume() { +resume() { # only called on 2.6 kernels or when charging if [ "$powerstate" = "on" ]; then # nothing to do echo "resume called unexpectedly" >&2 @@ -282,7 +317,7 @@ if [[ "$2" == "" ]]; then if [[ "$1" -le 2 ]]; then # power button was pressed 1-2sec, "suspend" if [[ "$powerstate" == "buttonlowpower" ]]; then (debug && echo "resume") || resume - powerstate="on" + powerstate_try_on elif [[ "$powerstate" == "on" ]]; then powerstate="buttonlowpower" (debug && echo "suspend") || suspend_ @@ -301,11 +336,11 @@ elif [[ "$2" == "lid" ]]; then case "$lidconfig" in "lowpower") (debug && echo "resume") || resume - powerstate="on" + powerstate_try_on ;; *) (debug && echo "display_on") || display_on_with_checks - powerstate="on" + powerstate_try_on ;; esac fi @@ -334,7 +369,7 @@ elif [[ "$2" == "screensaver" ]]; then if [[ "$1" == 0 ]]; then # deactivate screensaver display_on_with_checks - powerstate="on" + powerstate_try_on elif [[ "$1" == 1 ]]; then # activate screensaver display_off echo $led_idle > /sys/class/leds/pandora\:\:power/brightness diff --git a/recipes/pandora-system/pandora-version.bb b/recipes/pandora-system/pandora-version.bb index 084a237..5c270e8 100644 --- a/recipes/pandora-system/pandora-version.bb +++ b/recipes/pandora-system/pandora-version.bb @@ -1,6 +1,6 @@ DESCRIPTION = "Installs /etc/op-version file." LICENSE = "Public Domain" -PR = "r30" +PR = "r31" do_install() { OLD_PWD=$PWD