summaryrefslogtreecommitdiffstats
path: root/power
diff options
context:
space:
mode:
authorPaul Reioux <reioux@gmail.com>2012-08-28 15:35:42 +0200
committerKalimochoAz <calimochoazucarado@gmail.com>2012-08-29 21:14:46 +0200
commited067655c1475f42800682eb6fe672169c38229e (patch)
tree7cb8645c55250454e2993e144e5e29931d2d93d2 /power
parent221e4b718a26a16c16e9beea6e2fbb13f378ae29 (diff)
downloaddevice_samsung_tuna-ed067655c1475f42800682eb6fe672169c38229e.zip
device_samsung_tuna-ed067655c1475f42800682eb6fe672169c38229e.tar.gz
device_samsung_tuna-ed067655c1475f42800682eb6fe672169c38229e.tar.bz2
Fixed overclocking Power HAL module
Change-Id: I7fc7c517e04eee3933ab7107e788b50e41270b67
Diffstat (limited to 'power')
-rw-r--r--power/power_tuna.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/power/power_tuna.c b/power/power_tuna.c
index 7d06093..0a2aa8f 100644
--- a/power/power_tuna.c
+++ b/power/power_tuna.c
@@ -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,27 @@ 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.
*/
+ if (!on) {
+ /* read the current scaling max freq and save it before updating */
+ len = sysfs_read(SCALINGMAXFREQ_PATH, buf, sizeof(buf));
+
+ if (len != -1)
+ memcpy(scaling_max_freq, buf, sizeof(buf));
- sysfs_write("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
- on ? "1200000" : "700000");
+ sysfs_write("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
+ on ? scaling_max_freq : screen_off_max_freq);
+ }
+ else
+ sysfs_write("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
+ on ? scaling_max_freq : screen_off_max_freq);
}
static void tuna_power_hint(struct power_module *module, power_hint_t hint,