void set_normal_power() { ALOGI("Setting normal power mode"); sysfs_write(RQBALANCE_BALANCE_LEVEL, NORMAL_POWER_BALANCE_LEVEL); sysfs_write(RQBALANCE_UP_THRESHOLD, NORMAL_POWER_UP_THRESHOLD); sysfs_write(RQBALANCE_DOWN_THRESHOLD, NORMAL_POWER_DOWN_THRESHOLD); }
void set_low_power() { ALOGI("Setting low power mode"); sysfs_write(RQBALANCE_BALANCE_LEVEL, LOW_POWER_BALANCE_LEVEL); sysfs_write(RQBALANCE_UP_THRESHOLD, LOW_POWER_UP_THRESHOLD); sysfs_write(RQBALANCE_DOWN_THRESHOLD, LOW_POWER_DOWN_THRESHOLD); }
static void viva_power_init(struct power_module *module) { struct viva_power_module *viva = (struct viva_power_module *) module; int tmp; char freq_buf[MAX_FREQ_NUMBER*10]; tmp = sysfs_read(CPUFREQ_CPU0 "scaling_available_frequencies", freq_buf, sizeof(freq_buf)); if (tmp <= 0) { return; } freq_num = str_to_tokens(freq_buf, freq_list, MAX_FREQ_NUMBER); if (!freq_num) { return; } max_freq = freq_list[freq_num - 1]; tmp = (NOM_FREQ_INDEX > freq_num) ? freq_num : NOM_FREQ_INDEX; nom_freq = freq_list[tmp - 1]; sysfs_write(CPUFREQ_INTERACTIVE "timer_rate", "20000"); sysfs_write(CPUFREQ_INTERACTIVE "min_sample_time","60000"); sysfs_write(CPUFREQ_INTERACTIVE "hispeed_freq", nom_freq); sysfs_write(CPUFREQ_INTERACTIVE "go_hispeed_load", "60"); sysfs_write(CPUFREQ_INTERACTIVE "above_hispeed_delay", "100000"); ALOGI("Initialized successfully"); viva->inited = 1; }
static void cm_power_set_interactive(struct power_module *module, int on) { if (strncmp(governor, ONDEMAND_GOVERNOR, 8) == 0) sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/sampling_rate", on ? SAMPLING_RATE_SCREEN_ON : SAMPLING_RATE_SCREEN_OFF); else if (strncmp(governor, INTERACTIVE_GOVERNOR, 11) == 0) sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate", on ? TIMER_RATE_SCREEN_ON : TIMER_RATE_SCREEN_OFF); }
static void lge_power_set_interactive(struct power_module *module, int on) { if (strncmp(governor, "ondemand", 8) == 0) sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/sampling_rate", on ? SAMPLING_RATE_SCREEN_ON : SAMPLING_RATE_SCREEN_OFF); else if (strncmp(governor, "interactive", 11) == 0) sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate", on ? TIMER_RATE_SCREEN_ON : TIMER_RATE_SCREEN_OFF); }
void set_normal_power() { ALOGI("Setting normal power mode"); // MAX before MIN is intentional sysfs_write(CPUQUIET_MAX_CPUS, normal_max_cpus); sysfs_write(CPUQUIET_MIN_CPUS, normal_min_cpus); sysfs_write(RQBALANCE_BALANCE_LEVEL, normal_balance); sysfs_write(RQBALANCE_UP_THRESHOLD, normal_up); sysfs_write(RQBALANCE_DOWN_THRESHOLD, normal_down); }
static void huawei_power_set_interactive(struct power_module *module, int on) { /* * Lower maximum frequency when screen is off. */ sysfs_write(SCALINGMAXFREQ_PATH, on?"1008000":"600000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/input_boost", on? "1" : "0"); }
void set_low_power() { ALOGI("Setting low power mode"); // MIN before MAX is intentional sysfs_write(CPUQUIET_MIN_CPUS, low_min_cpus); sysfs_write(CPUQUIET_MAX_CPUS, low_max_cpus); sysfs_write(RQBALANCE_BALANCE_LEVEL, low_balance); sysfs_write(RQBALANCE_UP_THRESHOLD, low_up); sysfs_write(RQBALANCE_DOWN_THRESHOLD, low_down); }
int device_enable() { if (sysfs_write(SPI_PREP_FILE,"enable")< 0) { return -1; } if (sysfs_write(SPI_CLK_FILE,"1")< 0) { return -1; } return 1; }
static void rk_power_set_interactive(struct power_module *module, int on) { /* * 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 ? "10000000" : "816000"); sysfs_write(INTERACTIVE_PATH "input_boost", on ? "1" : "0"); //sysfs_write("/sys/devices/system/cpu/cpu1/online", on ? "1" : "0"); }
int device_disable() { if (sysfs_write(SPI_CLK_FILE,"0")< 0) { return -1; } if (sysfs_write(SPI_PREP_FILE,"disable")< 0) { return -1; } return 1; }
void power_set_interactive(struct power_module *, int on) { if (on) { if (hispeed_freq[0]) { sysfs_write(HISPEED_FREQ_PATH, hispeed_freq); } } else { if (sysfs_read(HISPEED_FREQ_PATH, hispeed_freq) < 0) { hispeed_freq[0] = '\0'; } sysfs_write(HISPEED_FREQ_PATH, HISPEED_FREQ_OFF); } }
static int uevent_event() { char msg[UEVENT_MSG_LEN]; char *cp; int n, cpu, ret, retry = RETRY_TIME_CHANGING_FREQ; n = recv(pfd.fd, msg, UEVENT_MSG_LEN, MSG_DONTWAIT); if (n <= 0) { return -1; } if (n >= UEVENT_MSG_LEN) { /* overflow -- discard */ return -1; } cp = msg; if (strstr(cp, UEVENT_STRING)) { n = strlen(cp); errno = 0; cpu = strtol(cp + n - 1, NULL, 10); if (errno == EINVAL || errno == ERANGE || cpu < 0 || cpu >= TOTAL_CPUS) { return -1; } pthread_mutex_lock(&low_power_mode_lock); if (low_power_mode && !freq_set[cpu]) { while (retry) { sysfs_write(cpu_path_min[cpu], LOW_POWER_MIN_FREQ); ret = sysfs_write(cpu_path_max[cpu], LOW_POWER_MAX_FREQ); if (!ret) { freq_set[cpu] = true; break; } usleep(SLEEP_USEC_BETWN_RETRY); retry--; } } else if (!low_power_mode && freq_set[cpu]) { while (retry) { ret = sysfs_write(cpu_path_max[cpu], NORMAL_MAX_FREQ); if (!ret) { freq_set[cpu] = false; break; } usleep(SLEEP_USEC_BETWN_RETRY); retry--; } } pthread_mutex_unlock(&low_power_mode_lock); } return 0; }
static void configure_governor() { s5pc110_power_set_interactive(NULL, 1); if (strncmp(governor, "ondemand", 8) == 0) { sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/up_threshold", "95"); sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/io_is_busy", "1"); sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor", "4"); } else if (strncmp(governor, "interactive", 11) == 0) { sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/min_sample_time", "90000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay", "30000"); } }
int ad_init(int idx) { if (idx >=0 && idx < GPIO_MAP_MAX) { char tmp[256]; sysfs_write(gpio_map[idx], "/sys/class/gpio/export"); snprintf(tmp, 256, "/sys/class/gpio/gpio%s/direction",gpio_map[idx]); sysfs_write("out", tmp); snprintf(tmp, 256, "/sys/class/gpio/gpio%s/value",gpio_map[idx]); sysfs_write("0", tmp); return 0; } else { return -1; } }
static void rk_power_init(struct power_module *module) { /* * cpufreq interactive governor: timer 20ms, min sample 20ms, * hispeed 816MHz at load 85%. */ ALOGD("init\n"); sysfs_write(INTERACTIVE_PATH "timer_rate", "20000"); sysfs_write(INTERACTIVE_PATH "min_sample_time", "20000"); sysfs_write(INTERACTIVE_PATH "hispeed_freq", "816000"); sysfs_write(INTERACTIVE_PATH "go_hispeed_load", "85"); sysfs_write(INTERACTIVE_PATH "above_hispeed_delay", "100000"); }
static void power_set_interactive(struct power_module __unused *module, int on) { ALOGV("power_set_interactive: %d\n", on); /* * Lower maximum frequency when screen is off. */ sysfs_write(CPU_MAX_FREQ_PATH, (!on || low_power_mode) ? low_power_max_cpu_freq : max_cpu_freq); sysfs_write(IO_IS_BUSY_PATH, on ? "1" : "0"); sysfs_write(FACEDOWN_PATH, on ? "0" : "1"); sysfs_write(TOUCH_SYNA_INTERACTIVE_PATH, on ? "1" : "0"); ALOGV("power_set_interactive: %d done\n", on); }
static void m470_power_set_interactive(struct power_module *module, int on) { /* * 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 ? "1300000" : "700000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/boost_factor", on ? "0" : "2"); }
static void cm_power_set_interactive(struct power_module *module, int on) { sysfs_write(NOTIFY_ON_MIGRATE, on ? "1" : "0"); #ifdef SET_INTERACTIVE_EXT cm_power_set_interactive_ext(on); #endif }
void sysfs_write_int(const char *path, int value) { char val[PROPERTY_VALUE_MAX]; snprintf(val, sizeof(val), "%d", value); sysfs_write(path, val); }
void jshPinSetState(Pin pin, JshPinState state) { #ifdef SYSFS_GPIO_DIR if (gpioState[pin] != state) { if (gpioState[pin] == JSHPINSTATE_UNDEFINED) sysfs_write_int(SYSFS_GPIO_DIR"/export", pin); char path[64] = SYSFS_GPIO_DIR"/gpio"; itostr(pin, &path[strlen(path)], 10); strcat(&path[strlen(path)], "/direction"); sysfs_write(path, JSHPINSTATE_IS_OUTPUT(state)?"out":"in"); } #endif #ifdef USE_WIRINGPI if (JSHPINSTATE_IS_OUTPUT(state)) { if (state==JSHPINSTATE_AF_OUT || state==JSHPINSTATE_AF_OUT_OPENDRAIN) pinMode(pin,PWM_OUTPUT); else pinMode(pin,OUTPUT); } else { pinMode(pin,INPUT); if (state==JSHPINSTATE_GPIO_IN_PULLUP) pullUpDnControl (pin, PUD_UP) ; else if (state==JSHPINSTATE_GPIO_IN_PULLDOWN) pullUpDnControl (pin, PUD_DOWN) ; else pullUpDnControl (pin, PUD_OFF) ; } #endif gpioState[pin] = state; }
static void power_init(struct power_module *module) { ALOGI("Simple PowerHAL is alive!."); property_get(LOW_MIN_CPUS, low_min_cpus, "0"); ALOGI("LOW_MIN_CPUS: %s", low_min_cpus); property_get(LOW_MAX_CPUS, low_max_cpus, "0"); ALOGI("LOW_MAX_CPUS: %s", low_max_cpus); property_get(LOW_POWER_BALANCE_LEVEL, low_balance, "0"); ALOGI("LOW_POWER_BALANCE_LEVEL: %s", low_balance); property_get(LOW_POWER_UP_THRESHOLD, low_up, "0"); ALOGI("LOW_POWER_UP_THRESHOLD: %s", low_up); property_get(LOW_POWER_DOWN_THRESHOLD, low_down, "0"); ALOGI("LOW_POWER_DOWN_THRESHOLD: %s", low_down); property_get(NORMAL_MIN_CPUS, normal_min_cpus, "0"); ALOGI("NORMAL_MIN_CPUS: %s", normal_min_cpus); property_get(NORMAL_MAX_CPUS, normal_max_cpus, "0"); ALOGI("NORMAL_MAX_CPUS: %s", normal_max_cpus); property_get(NORMAL_POWER_BALANCE_LEVEL, normal_balance, "0"); ALOGI("NORMAL_POWER_BALANCE_LEVEL: %s", normal_balance); property_get(NORMAL_POWER_UP_THRESHOLD, normal_up, "0"); ALOGI("NORMAL_POWER_UP_THRESHOLD: %s", normal_up); property_get(NORMAL_POWER_DOWN_THRESHOLD, normal_down, "0"); ALOGI("NORMAL_POWER_DOWN_THRESHOLD: %s", normal_down); // init thermal maximum prior to setting normal power profile sysfs_write(CPUQUIET_THERMAL_CPUS, normal_max_cpus); set_normal_power(); }
static void touchboost() { int64_t now = android::uptimeMillis(); if (now - last_touchboost > TOUCHBOOST_MIN_INTERVAL_MS) { sysfs_write(TOUCHBOOST_PATH, "1"); last_touchboost = now; } }
static void m470_power_init(struct power_module *module) { /* * cpufreq interactive governor: timer 20ms, min sample 100ms, * hispeed 700MHz at load 40% */ sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate", "20000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/min_sample_time", "30000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load", "85"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/boost_factor", "0"); }
static void power_set_interactive(struct power_module *module, int on) { ALOGV("power_set_interactive: %d\n", on); sysfs_write(TSP_POWER, on ? "1" : "0"); ALOGV("power_set_interactive: %d done\n", on); }
static void sun4i_power_init(struct power_module *module) { /* * cpufreq interactive governor: timer 20ms, min sample 60ms, * hispeed 700MHz at load 50%. */ sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate", "20000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/min_sample_time", "60000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/hispeed_freq", "700000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load", "50"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay", "100000"); }
/************************************************************ * Set initial govenor values and initialize *pp * *************************************************************/ static void init_freq() { char buf[4] = { 0 }; int pprofile; int fd = open("/data/misc/adrian_pp", O_RDONLY); if( fd >= 0 ) { read(fd, buf, sizeof(buf)-1); close(fd); pprofile = atoi(buf); if(pprofile >= 0 && pprofile < MAX_POWER_PROFILES) { ALOGI("power profile set to %d", pprofile); pp = power_profiles[pprofile]; } } sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/min_sample_time", 30000); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/go_maxspeed_load", 80); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/boost_factor", 0); }
void set_feature(struct power_module *module, feature_t feature, int state) { #ifdef TAP_TO_WAKE_NODE if (feature == POWER_FEATURE_DOUBLE_TAP_TO_WAKE) { ALOGI("Double tap to wake is %s.", state ? "enabled" : "disabled"); sysfs_write(TAP_TO_WAKE_NODE, state ? "1" : "0"); return; } #endif }
static void power_set_interactive(struct power_module *module, int on) { ALOGD("%s: %s input devices", __func__, on ? "enabling" : "disabling"); sysfs_write(TSP_POWER, on ? "1" : "0"); sysfs_write(TOUCHKEY_POWER, on ? "1" : "0"); sysfs_write(INPUT_POWER2, on ? "1" : "0"); sysfs_write(INPUT_POWER3, on ? "1" : "0"); sysfs_write(INPUT_POWER4, on ? "1" : "0"); sysfs_write(INPUT_POWER5, on ? "1" : "0"); sysfs_write(INPUT_POWER6, on ? "1" : "0"); sysfs_write(INPUT_POWER7, on ? "1" : "0"); }
static void configure_governor() { if (strncmp(governor, "ondemand", 8) == 0) { sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/sampling_rate", "50000"); sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/up_threshold", "90"); sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/io_is_busy", "1"); sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor", "4"); sysfs_write("/sys/devices/system/cpu/cpufreq/ondemand/down_differential", "10"); } else if (strncmp(governor, "interactive", 11) == 0) { sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate", "30000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/min_sample_time", "90000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/hispeed_freq", "1008000"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay", "30000"); } }