summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2014-06-02 17:23:10 -0700
committerRuchi Kandoi <kandoiruchi@google.com>2014-06-05 13:09:00 -0700
commited142f24cbf41fecfeadd28dfe2921bf1beed142 (patch)
tree05e9498a6e2feaef1350dbacdb1a540cc47c2da1 /power
parent34012ff954d7f3b87000d9d26a3d58ee25e42855 (diff)
downloadmanta-ed142f24cbf41fecfeadd28dfe2921bf1beed142.tar.gz
powerHAL: Adds the low power mode hint.
when a POWER_HINT_LOW_POWER hint is received max CPU freq is capped for both the CPUs. Refresh rate is reduced by making a system call to the SurfaceFlinger binder. Max CPU frequency on screen on is appropriately set if the device is in low power mode. Bug: 15384638 Change-Id: I10c68cf07d73969bfba5f30dde26338365b843a5 Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Diffstat (limited to 'power')
-rw-r--r--power/power_manta.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/power/power_manta.c b/power/power_manta.c
index f1ba426..330e3d4 100644
--- a/power/power_manta.c
+++ b/power/power_manta.c
@@ -21,6 +21,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <stdlib.h>
#include <linux/time.h>
#include <stdbool.h>
//#define LOG_NDEBUG 0
@@ -33,12 +34,15 @@
#define BOOSTPULSE_PATH "/sys/devices/system/cpu/cpufreq/interactive/boostpulse"
#define BOOST_PATH "/sys/devices/system/cpu/cpufreq/interactive/boost"
+#define CPU_MAX_FREQ_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
//BOOST_PULSE_DURATION and BOOT_PULSE_DURATION_STR should always be in sync
#define BOOST_PULSE_DURATION 1000000
#define BOOST_PULSE_DURATION_STR "1000000"
#define NSEC_PER_SEC 1000000000
#define USEC_PER_SEC 1000000
#define NSEC_PER_USEC 100
+#define LOW_POWER_MAX_FREQ "800000"
+#define NORMAL_MAX_FREQ "1700000"
struct manta_power_module {
struct power_module base;
@@ -51,6 +55,7 @@ struct manta_power_module {
static unsigned int vsync_count;
static struct timespec last_touch_boost;
static bool touch_boost;
+static bool low_power_mode = false;
static void sysfs_write(const char *path, char *s)
{
@@ -146,8 +151,8 @@ static void power_set_interactive(struct power_module *module, int on)
* Lower maximum frequency when screen is off. CPU 0 and 1 share a
* cpufreq policy.
*/
- sysfs_write("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
- on ? "1700000" : "800000");
+ sysfs_write(CPU_MAX_FREQ_PATH,
+ (!on || low_power_mode) ? LOW_POWER_MAX_FREQ : NORMAL_MAX_FREQ);
sysfs_write(manta->touchscreen_power_path, on ? "Y" : "N");
@@ -244,6 +249,21 @@ static void manta_power_hint(struct power_module *module, power_hint_t hint,
}
pthread_mutex_unlock(&manta->lock);
break;
+
+ case POWER_HINT_LOW_POWER:
+ pthread_mutex_lock(&manta->lock);
+ if (data) {
+ sysfs_write(CPU_MAX_FREQ_PATH, LOW_POWER_MAX_FREQ);
+ // reduces the refresh rate
+ system("service call SurfaceFlinger 1016");
+ } else {
+ sysfs_write(CPU_MAX_FREQ_PATH, NORMAL_MAX_FREQ);
+ // restores the refresh rate
+ system("service call SurfaceFlinger 1017");
+ }
+ low_power_mode = data;
+ pthread_mutex_unlock(&manta->lock);
+ break;
default:
break;
}