summaryrefslogtreecommitdiffstats
path: root/power
diff options
context:
space:
mode:
authorPaul Reioux <reioux@gmail.com>2012-08-28 15:35:42 +0200
committerZiyann <jaraidaniel@gmail.com>2014-11-14 09:05:06 +0100
commitd04712d6739ee8f73b5a568c14348e8a975ff653 (patch)
treeb76af51c6e958b08574d50a93947546ba112f297 /power
parentb5882b05a17f800ecdd1732beba92d8173c079e8 (diff)
downloaddevice_samsung_tuna-d04712d6739ee8f73b5a568c14348e8a975ff653.zip
device_samsung_tuna-d04712d6739ee8f73b5a568c14348e8a975ff653.tar.gz
device_samsung_tuna-d04712d6739ee8f73b5a568c14348e8a975ff653.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 32ed3ff..34b488f 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)
{
sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate",
@@ -95,13 +120,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,