|
|
|
@ -58,8 +58,12 @@ struct samsung_power_module { |
|
|
|
|
bool touchkey_blocked; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/* POWER_HINT_LOW_POWER */ |
|
|
|
|
static bool low_power_mode = false; |
|
|
|
|
enum power_profile_e { |
|
|
|
|
PROFILE_POWER_SAVE = 0, |
|
|
|
|
PROFILE_BALANCED, |
|
|
|
|
PROFILE_HIGH_PERFORMANCE |
|
|
|
|
}; |
|
|
|
|
static enum power_profile_e current_power_profile = PROFILE_BALANCED; |
|
|
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
|
*** HELPER FUNCTIONS |
|
|
|
@ -140,6 +144,51 @@ static int boostpulse_open(struct samsung_power_module *samsung_pwr) |
|
|
|
|
return samsung_pwr->boostpulse_fd; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void set_power_profile(struct samsung_power_module *samsung_pwr, |
|
|
|
|
enum power_profile_e profile) |
|
|
|
|
{ |
|
|
|
|
int rc; |
|
|
|
|
struct stat sb; |
|
|
|
|
|
|
|
|
|
if (current_power_profile == profile) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ALOGV("%s: profile=%d", __func__, profile); |
|
|
|
|
|
|
|
|
|
switch (profile) { |
|
|
|
|
case PROFILE_POWER_SAVE: |
|
|
|
|
// Limit to hispeed freq
|
|
|
|
|
sysfs_write(CPU0_MAX_FREQ_PATH, samsung_pwr->cpu0_hispeed_freq); |
|
|
|
|
rc = stat(CPU4_MAX_FREQ_PATH, &sb); |
|
|
|
|
if (rc == 0) { |
|
|
|
|
sysfs_write(CPU4_MAX_FREQ_PATH, samsung_pwr->cpu4_hispeed_freq); |
|
|
|
|
} |
|
|
|
|
ALOGD("%s: set powersave mode", __func__); |
|
|
|
|
break; |
|
|
|
|
case PROFILE_BALANCED: |
|
|
|
|
// Restore normal max freq
|
|
|
|
|
sysfs_write(CPU0_MAX_FREQ_PATH, samsung_pwr->cpu0_max_freq); |
|
|
|
|
rc = stat(CPU4_MAX_FREQ_PATH, &sb); |
|
|
|
|
if (rc == 0) { |
|
|
|
|
sysfs_write(CPU4_MAX_FREQ_PATH, samsung_pwr->cpu4_max_freq); |
|
|
|
|
} |
|
|
|
|
ALOGD("%s: set balanced mode", __func__); |
|
|
|
|
break; |
|
|
|
|
case PROFILE_HIGH_PERFORMANCE: |
|
|
|
|
// Restore normal max freq
|
|
|
|
|
sysfs_write(CPU0_MAX_FREQ_PATH, samsung_pwr->cpu0_max_freq); |
|
|
|
|
rc = stat(CPU4_MAX_FREQ_PATH, &sb); |
|
|
|
|
if (rc == 0) { |
|
|
|
|
sysfs_write(CPU4_MAX_FREQ_PATH, samsung_pwr->cpu4_max_freq); |
|
|
|
|
} |
|
|
|
|
ALOGD("%s: set performance mode", __func__); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
current_power_profile = profile; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void find_input_nodes(struct samsung_power_module *samsung_pwr, char *dir) |
|
|
|
|
{ |
|
|
|
|
const char filename[] = "name"; |
|
|
|
@ -373,6 +422,13 @@ static void samsung_power_hint(struct power_module *module, |
|
|
|
|
|
|
|
|
|
switch (hint) { |
|
|
|
|
case POWER_HINT_INTERACTION: { |
|
|
|
|
char errno_str[64]; |
|
|
|
|
ssize_t len; |
|
|
|
|
int fd; |
|
|
|
|
|
|
|
|
|
if (current_power_profile == PROFILE_POWER_SAVE) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ALOGV("%s: POWER_HINT_INTERACTION", __func__); |
|
|
|
|
|
|
|
|
@ -390,38 +446,14 @@ static void samsung_power_hint(struct power_module *module, |
|
|
|
|
case POWER_HINT_VSYNC: { |
|
|
|
|
|
|
|
|
|
ALOGV("%s: POWER_HINT_VSYNC", __func__); |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case POWER_HINT_LOW_POWER: { |
|
|
|
|
int rc; |
|
|
|
|
struct stat sb; |
|
|
|
|
case POWER_HINT_SET_PROFILE: { |
|
|
|
|
int profile = *((intptr_t *)data); |
|
|
|
|
|
|
|
|
|
ALOGV("%s: POWER_HINT_LOW_POWER", __func__); |
|
|
|
|
ALOGV("%s: POWER_HINT_SET_PROFILE", __func__); |
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(&samsung_pwr->lock); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* TODO: We fail to restore the max freqs after low power mode has been |
|
|
|
|
* disabled for some reason (big.LITTLE specific issue?) |
|
|
|
|
* |
|
|
|
|
if (data) { |
|
|
|
|
sysfs_write(CPU0_MAX_FREQ_PATH, samsung_pwr->cpu0_hispeed_freq); |
|
|
|
|
rc = stat(CPU4_MAX_FREQ_PATH, &sb); |
|
|
|
|
if (rc == 0) { |
|
|
|
|
sysfs_write(CPU4_MAX_FREQ_PATH, samsung_pwr->cpu4_hispeed_freq); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
sysfs_write(CPU0_MAX_FREQ_PATH, samsung_pwr->cpu0_max_freq); |
|
|
|
|
rc = stat(CPU4_MAX_FREQ_PATH, &sb); |
|
|
|
|
if (rc == 0) { |
|
|
|
|
sysfs_write(CPU4_MAX_FREQ_PATH, samsung_pwr->cpu4_max_freq); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
low_power_mode = data; |
|
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&samsung_pwr->lock); |
|
|
|
|
set_power_profile(samsung_pwr, profile); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
@ -429,6 +461,16 @@ static void samsung_power_hint(struct power_module *module, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int samsung_get_feature(struct power_module *module __unused, |
|
|
|
|
feature_t feature) |
|
|
|
|
{ |
|
|
|
|
if (feature == POWER_FEATURE_SUPPORTED_PROFILES) { |
|
|
|
|
return 3; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static struct hw_module_methods_t power_module_methods = { |
|
|
|
|
.open = NULL, |
|
|
|
|
}; |
|
|
|
@ -448,6 +490,7 @@ struct samsung_power_module HAL_MODULE_INFO_SYM = { |
|
|
|
|
.init = samsung_power_init, |
|
|
|
|
.setInteractive = samsung_power_set_interactive, |
|
|
|
|
.powerHint = samsung_power_hint, |
|
|
|
|
.getFeature = samsung_get_feature |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
.lock = PTHREAD_MUTEX_INITIALIZER, |
|
|
|
|