diff options
Diffstat (limited to 'power-8916.c')
-rw-r--r-- | power-8916.c | 148 |
1 files changed, 66 insertions, 82 deletions
diff --git a/power-8916.c b/power-8916.c index 873c51d..8241aeb 100644 --- a/power-8916.c +++ b/power-8916.c @@ -60,26 +60,20 @@ static int slack_node_rw_failed = 0; static int display_hint_sent; int display_boost; -static int is_target_8916() /* Returns value=8916 if target is 8916 else value 0 */ -{ - int fd; - int is_target_8916 = 0; - char buf[10] = {0}; - - fd = open("/sys/devices/soc0/soc_id", O_RDONLY); - if (fd >= 0) { - if (read(fd, buf, sizeof(buf) - 1) == -1) { - ALOGW("Unable to read soc_id"); - is_target_8916 = 0; - } else { - int soc_id = atoi(buf); - if (soc_id == 206 || (soc_id >= 247 && soc_id <= 250)) { - is_target_8916 = 8916; /* Above SOCID for 8916 */ - } - } - } - close(fd); - return is_target_8916; +/** + * If target is 8916: + * return true + * else: + * return false + */ +static bool is_target_8916(void) { + static bool is_8916 = false; + int soc_id; + + soc_id = get_soc_id(); + if (soc_id == 206 || (soc_id >= 247 && soc_id <= 250)) is_8916 = true; + + return is_8916; } int power_hint_override(power_hint_t hint, void* data) { @@ -123,81 +117,71 @@ int set_interactive_override(int on) { if (!on) { /* Display off. */ - switch (is_target_8916()) { - case 8916: { - if (is_interactive_governor(governor)) { - int resource_values[] = {TR_MS_50, THREAD_MIGRATION_SYNC_OFF}; - - if (!display_hint_sent) { - perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); - display_hint_sent = 1; - } - } /* Perf time rate set for 8916 target*/ - } /* End of Switch case for 8916 */ - break; - - default: { - if (is_interactive_governor(governor)) { - int resource_values[] = {TR_MS_CPU0_50, TR_MS_CPU4_50, - THREAD_MIGRATION_SYNC_OFF}; - - /* Set CPU0 MIN FREQ to 400Mhz avoid extra peak power - impact in volume key press */ - snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_OFF); - if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) { - if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) { - if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) { - if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) { - if (!slack_node_rw_failed) { - ALOGE("Failed to write to %s", SCALING_MIN_FREQ); - } - rc = 1; + if (is_target_8916()) { + if (is_interactive_governor(governor)) { + int resource_values[] = {TR_MS_50, THREAD_MIGRATION_SYNC_OFF}; + + if (!display_hint_sent) { + perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, + sizeof(resource_values) / sizeof(resource_values[0])); + display_hint_sent = 1; + } + } /* Perf time rate set for 8916 target*/ + /* End of display hint for 8916 */ + } else { + if (is_interactive_governor(governor)) { + int resource_values[] = {TR_MS_CPU0_50, TR_MS_CPU4_50, THREAD_MIGRATION_SYNC_OFF}; + + /* Set CPU0 MIN FREQ to 400Mhz avoid extra peak power + impact in volume key press */ + snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_OFF); + if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) { + if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) { + if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) { + if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) { + if (!slack_node_rw_failed) { + ALOGE("Failed to write to %s", SCALING_MIN_FREQ); } + rc = 1; } } } + } - if (!display_hint_sent) { - perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, - sizeof(resource_values) / sizeof(resource_values[0])); - display_hint_sent = 1; - } - } /* Perf time rate set for CORE0,CORE4 8939 target*/ - } /* End of Switch case for 8939 */ - break; + if (!display_hint_sent) { + perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, + sizeof(resource_values) / sizeof(resource_values[0])); + display_hint_sent = 1; + } + } /* Perf time rate set for CORE0,CORE4 8939 target*/ + /* End of display hint for 8939 */ } - } else { /* Display on. */ - switch (is_target_8916()) { - case 8916: { - if (is_interactive_governor(governor)) { - undo_hint_action(DISPLAY_STATE_HINT_ID); - display_hint_sent = 0; - } - } break; - default: { - if (is_interactive_governor(governor)) { - /* Recovering MIN_FREQ in display ON case */ - snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_ON); - if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) { - if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) { - if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) { - if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) { - if (!slack_node_rw_failed) { - ALOGE("Failed to write to %s", SCALING_MIN_FREQ); - } - rc = 1; + if (is_target_8916()) { + if (is_interactive_governor(governor)) { + undo_hint_action(DISPLAY_STATE_HINT_ID); + display_hint_sent = 0; + } + } else { + if (is_interactive_governor(governor)) { + /* Recovering MIN_FREQ in display ON case */ + snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_ON); + if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) { + if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) { + if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) { + if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) { + if (!slack_node_rw_failed) { + ALOGE("Failed to write to %s", SCALING_MIN_FREQ); } + rc = 1; } } } - undo_hint_action(DISPLAY_STATE_HINT_ID); - display_hint_sent = 0; } - - } break; + undo_hint_action(DISPLAY_STATE_HINT_ID); + display_hint_sent = 0; + } } /* End of check condition during the DISPLAY ON case */ } return HINT_HANDLED; |