Permalink
Browse files

Power_tuna.c scaling squash

Signed-off-by: Stevespear426 <stephen.k.spear@gmail.com>
  • Loading branch information...
1 parent 010d8f5 commit 4e5a2c68bb91eb22330ebcfc0cc6f4c94a64795d @Stevespear426 Stevespear426 committed Nov 20, 2012
Showing with 30 additions and 2 deletions.
  1. +30 −2 power/power_tuna.c
View
@@ -25,8 +25,16 @@
#include <hardware/hardware.h>
#include <hardware/power.h>
+#define SCALINGMAXFREQ_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
+#define SCREENOFFMAXFREQ_PATH "/sys/devices/system/cpu/cpu0/cpufreq/screen_off_max_freq"
#define BOOSTPULSE_PATH "/sys/devices/system/cpu/cpufreq/interactive/boostpulse"
+#define MAX_BUF_SZ 10
+
+/* initialize to something safe */
+static char screen_off_max_freq[MAX_BUF_SZ] = "700000";
+static char scaling_max_freq[MAX_BUF_SZ] = "1200000";
+
struct tuna_power_module {
struct power_module base;
pthread_mutex_t lock;
@@ -55,6 +63,23 @@ static void sysfs_write(char *path, char *s)
close(fd);
}
+int sysfs_read(const char *path, char *buf, size_t size)
+{
+ int fd, len;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ do {
+ len = read(fd, buf, size);
+ } while (len < 0 && errno == EINTR);
+
+ close(fd);
+
+ return len;
+}
+
static void tuna_power_init(struct power_module *module)
{
/*
@@ -98,13 +123,16 @@ static int boostpulse_open(struct tuna_power_module *tuna)
static void tuna_power_set_interactive(struct power_module *module, int on)
{
+ int len;
+
+ char buf[MAX_BUF_SZ];
+
/*
* 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 ? "1200000" : "700000");
+ sysfs_write(SCREENOFFMAXFREQ_PATH,screen_off_max_freq);
}
static void tuna_power_hint(struct power_module *module, power_hint_t hint,

0 comments on commit 4e5a2c6

Please sign in to comment.