Underclocking When The Lid Is Closed


Pleng

Well-Known Member
Joined
Dec 28, 2006
Messages
3,030
Generally when the lid is closed on my Pandora I want to be saving as much energy as possible downclocking to 125Mhz and setting OPP to 2 would make sense. However some times I might want to close the lid and still be able to play music - something which current audio players would struggle to achieve at 125.

With this problem in mind I have created an updated op_lid.sh file which does the following if the screen goes down:

IF the CPU is set to a frequency of OVER 250, is is scaled down to 125Mhz/OPP2
IF the CPU is set to 250Mhz or less, nothing happens

When the lid is raised the original setting is restored (if it has been changed in the fist place).

This gives a nice little system where in every day use, the CPU will be downclocked when the lid is closed. If I want to over rule this, all I have to do is set the CPU to 250 (or less) before closing the lid and things will carry away as normal.

You can get the script [url="http://www.strappysolutions.com/demos/pandora/op_lid.sh"]here[/url], and the code is here:

Code:
  #!/bin/bash
  #actions done when the lid is closed
  #only argument is 0 for open 1 for closed
  #may also be called after inactivity, like X DPMS
  
  if [ ! -e /tmp/powerstate ]; then #do nothing when in powersave mode
    if [ "$1" = "1" ]; then #lid was closed
      brightness=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness)
      if [ $brightness -gt 0 ]; then
        echo $brightness > /tmp/oldbright
      fi
      echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
      echo 1 > /sys/devices/platform/omapfb/graphics/fb0/blank
  
      #PLENG - If CPU Speed is
      #greater than 250 then 'sleep'
  
      PLCSPEED=`cat /proc/pandora/cpu_mhz_max`
      PLOPP=`cat /proc/pandora/cpu_opp_max`
      
      if [ "$PLCSPEED" -gt 250 ]; then
        echo $PLCSPEED > /tmp/.OLDSPEED
        echo $PLOPP > /tmp/.OLDOPP
        echo 125 > /proc/pandora/cpu_mhz_max
        echo 2 > /proc/pandora/cpu_opp_max
      fi
      
    elif [ "$1" = "0" ]; then # lid was opened
      echo 0 > /sys/devices/platform/omapfb/graphics/fb0/blank
      sleep 0.1s # looks cleaner, could flicker without
      maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
      oldbright=0
      if [ -f /tmp/oldbright ]; then
        oldbright=$(cat /tmp/oldbright)
      fi
      if [ $oldbright -eq 0 ]; then
        oldbright=$(cat /etc/pandora/conf/brightness.state)
      fi
       if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then 
        /usr/pandora/scripts/op_bright.sh $oldbright 
       else
        /usr/pandora/scripts/op_bright.sh $maxbright
       fi
  
    #PLENG if we've been to sleep then
    #restore old CPU values
  
    if [ -e "/tmp/.OLDSPEED" ]; then
      cat /tmp/.OLDOPP > /proc/pandora/cpu_opp_max
      cat /tmp/.OLDSPEED > /proc/pandora/cpu_mhz_max
      rm /tmp/.OLDOPP
      rm /tmp/.OLDSPEED
    fi   
  
    fi
  
  fi

You need to save the file to /usr/pandora/scripts, overwriting the file that's currently in place. Once you've done that you may need to do a sudo chmod 777 ./op_lid.sh to make sure it's runnable (hard to say I edited and saved mine as SU). You'll soon know if you've done it wrong as suddenly your screen will stop going off when you close the lid.
 
I'm always for everything that saves battery life. :)
Haven't my Pandora yet but I guess I will try stuff like this. Could you test if the pandora really runs longer when set to 125MHz? I've read here somewhere, that underclocking brings actualy nothing at the moment.
And there is no Music-Player that can run with 125MHz onto the Pandora? :blink:
 
fusion_power said:
And there is no Music-Player that can run with 125MHz onto the Pandora? :blink:
mplayer does. gnome-mplayer does not. I'm betting there's something with the guis that slows them down. Some curious things happen to other programs when you close the lid, even though the only thing it supposedly does is turn off the backlight.
 
Last edited by a moderator:
fusion_power said:
I've read here somewhere, that underclocking brings actualy nothing at the moment.

Underclocking brings a little, but nothing worth speaking of. Undervolting does save enough battery to be worth doing, though we're probably talking an extra hour or two on a full charge - nothing spectacular but still worth doing.
 
Last edited by a moderator:
Pleng said:
fusion_power said:
I've read here somewhere, that underclocking brings actualy nothing at the moment.

Underclocking brings a little, but nothing worth speaking of. Undervolting does save enough battery to be worth doing, though we're probably talking an extra hour or two on a full charge - nothing spectacular but still worth doing.
Actually, I've found that undervolting to OPP1 can give as much as 10 hours extra run time. Turn off the backlight for an additional 10 hours longer life, and the battery will last 30 hours. And there are still more things that can be turned off to save even more power, eventually :D
 
Last edited by a moderator:
Awesome, Ill update my script... what is a safe frequency for OPP1?
 
WizardStan said:
Actually, I've found that undervolting to OPP1 can give as much as 10 hours extra run time. Turn off the backlight for an additional 10 hours longer life, and the battery will last 30 hours. And there are still more things that can be turned off to save even more power, eventually :D
What application, if any, is running when it lasts 30 hours? Or do you mean it lasts only 30 hours when doing nothing? If so, that sounds worryingly like there's a long, long way to go with the power optimization. The N900 lasts much longer than that, and I thought it was pretty bad, battery wise.. ;)
 
Last edited by a moderator:
Pleng said:
fusion_power said:
I've read here somewhere, that underclocking brings actualy nothing at the moment.

Underclocking brings a little, but nothing worth speaking of. Undervolting does save enough battery to be worth doing, though we're probably talking an extra hour or two on a full charge - nothing spectacular but still worth doing.
I hope undervolting don't let us loose the warranty like overvolting would if I remember craigix correctly. ^^"

Well, the Data sheets from the OMAP talk about incredible power-saving miracles of the Chipset. At the Moment these HW features are not even touched, I want "real" power saving and stuff like clever auto-clocking as soon as possible. I hope this wasn't just TI marketing-crap. :rolleyes:
 
Last edited by a moderator:
Tor said:
What application, if any, is running when it lasts 30 hours? Or do you mean it lasts only 30 hours when doing nothing? If so, that sounds worryingly like there's a long, long way to go with the power optimization. The N900 lasts much longer than that, and I thought it was pretty bad, battery wise.. ;)
Nothing running gives the 30 hours up time. With mplayer playing an MP3 at 125Mhz OPP1, I'm still seeing about 24 hours of use from full charge, but you're right, there is still a long way to go. There's a lot of stuff that is still powered even in low power mode that can realistically be shut off as soon as we figure out how to do that.
 
Last edited by a moderator:
Pleng said:
Awesome, Ill update my script... what is a safe frequency for OPP1?

I run mine at 500 / opp1 almost constantly and go up from there if necessary. It certainly saves battery at opp1 but changing the mhz within opp1 seems to have little or no effect on battery usage, so I don't really see why everyone is hung up on the 125/opp1 thing.
 
Last edited by a moderator:
The N900 doesn't drop below 250 MHz I believe. People tried 125 MHz but there wasn't much point as I understand. And the N900 still lasts much longer than the Panda, even with its puny battery.. so the power saving must be looked for elsewhere, presumably in shutting off other parts as WizardStan suggested. My 1500 mAh N800 used to (when it had a new battery) last around 9-10 days if idle, and the OMAP3 chipset was supposed to be better at power saving the the N800's OMAP2.. I wouldn't know, but in any case I suspect the N900 would last nearly twice as long as it does if it had been without the GSM radio. So we should, in principle and theoretically, be able to increase the Pandora's battery time to nearly a month, with its huge battery (wasn't something like that even mentioned in the early days of the Pandora project?).

That is, if something unexpected like taking way too much power to keep the RTC going hits us! :)
 
MonkeyChops said:
I don't really see why everyone is hung up on the 125/opp1 thing.
Because its not guaranteed to go faster than that in OPP1. (Like its not supposed to go faster than 600 (at OPP5), etc...)
 
Last edited by a moderator:
im not really sure but I think that GMU should work with 125MHz, it did with 150 MHz when I tested it :)
 
Cmus can handle low clock frequency as well, it worked down to 80MHz (or was it 60MHz?) when I tested it (but then, it was enough to move the moune pointer around to make it struggle.)
 
Back
Top