power: Simplify soc_id checks
- Get soc_id in a common util function - Return boolean values for the target-specific soc_id checks Change-Id: I038c435d28855859f36566de7acf881037d070f2
This commit is contained in:
committed by
Michael Bestas
parent
3fac864721
commit
7ff6620596
33
power-660.c
33
power-660.c
@@ -56,25 +56,20 @@ static int video_encode_hint_sent;
|
|||||||
|
|
||||||
static void process_video_encode_hint(void* metadata);
|
static void process_video_encode_hint(void* metadata);
|
||||||
|
|
||||||
/* Returns true is target is SDM630/SDM455 else false*/
|
/**
|
||||||
static bool is_target_SDM630() {
|
* If target is SDM630/SDM455:
|
||||||
int fd;
|
* return true
|
||||||
bool is_target_SDM630 = false;
|
* else:
|
||||||
char buf[10] = {0};
|
* return false
|
||||||
fd = open("/sys/devices/soc0/soc_id", O_RDONLY);
|
*/
|
||||||
if (fd >= 0) {
|
static bool is_target_SDM630(void) {
|
||||||
if (read(fd, buf, sizeof(buf) - 1) == -1) {
|
static bool is_SDM630 = false;
|
||||||
ALOGW("Unable to read soc_id");
|
int soc_id;
|
||||||
is_target_SDM630 = false;
|
|
||||||
} else {
|
soc_id = get_soc_id();
|
||||||
int soc_id = atoi(buf);
|
if (soc_id == 318 || soc_id == 327 || soc_id == 385) is_SDM630 = true;
|
||||||
if (soc_id == 318 || soc_id == 327 || soc_id == 385) {
|
|
||||||
is_target_SDM630 = true; /* Above SOCID for SDM630/SDM455 */
|
return is_SDM630;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
return is_target_SDM630;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int power_hint_override(power_hint_t hint, void* data) {
|
int power_hint_override(power_hint_t hint, void* data) {
|
||||||
|
|||||||
33
power-8937.c
33
power-8937.c
@@ -55,25 +55,20 @@ static int display_hint_sent;
|
|||||||
static int video_encode_hint_sent;
|
static int video_encode_hint_sent;
|
||||||
static void process_video_encode_hint(void* metadata);
|
static void process_video_encode_hint(void* metadata);
|
||||||
|
|
||||||
static bool is_target_SDM439() /* Returns value=1 if target is Hathi else value 0 */
|
/**
|
||||||
{
|
* If target is SDM439/429:
|
||||||
int fd;
|
* return true
|
||||||
bool is_target_SDM439 = false;
|
* else:
|
||||||
char buf[10] = {0};
|
* return false
|
||||||
fd = open("/sys/devices/soc0/soc_id", O_RDONLY);
|
*/
|
||||||
if (fd >= 0) {
|
static bool is_target_SDM439(void) {
|
||||||
if (read(fd, buf, sizeof(buf) - 1) == -1) {
|
static bool is_SDM439 = false;
|
||||||
ALOGW("Unable to read soc_id");
|
int soc_id;
|
||||||
is_target_SDM439 = false;
|
|
||||||
} else {
|
soc_id = get_soc_id();
|
||||||
int soc_id = atoi(buf);
|
if (soc_id == 353 || soc_id == 363 || soc_id == 354 || soc_id == 364) is_SDM439 = true;
|
||||||
if (soc_id == 353 || soc_id == 363 || soc_id == 354 || soc_id == 364) {
|
|
||||||
is_target_SDM439 = true; /* Above SOCID for SDM439/429 */
|
return is_SDM439;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
return is_target_SDM439;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int power_hint_override(power_hint_t hint, void* data) {
|
int power_hint_override(power_hint_t hint, void* data) {
|
||||||
|
|||||||
33
power-8953.c
33
power-8953.c
@@ -56,25 +56,20 @@ static int video_encode_hint_sent;
|
|||||||
|
|
||||||
static void process_video_encode_hint(void* metadata);
|
static void process_video_encode_hint(void* metadata);
|
||||||
|
|
||||||
static bool is_target_SDM632() /* Returns value=632 if target is SDM632 else value 0 */
|
/**
|
||||||
{
|
* If target is SDM632:
|
||||||
int fd;
|
* return true
|
||||||
bool is_target_SDM632 = false;
|
* else:
|
||||||
char buf[10] = {0};
|
* return false
|
||||||
fd = open("/sys/devices/soc0/soc_id", O_RDONLY);
|
*/
|
||||||
if (fd >= 0) {
|
static bool is_target_SDM632(void) {
|
||||||
if (read(fd, buf, sizeof(buf) - 1) == -1) {
|
static bool is_SDM632 = false;
|
||||||
ALOGW("Unable to read soc_id");
|
int soc_id;
|
||||||
is_target_SDM632 = false;
|
|
||||||
} else {
|
soc_id = get_soc_id();
|
||||||
int soc_id = atoi(buf);
|
if (soc_id == 349 || soc_id == 350) is_SDM632 = true;
|
||||||
if (soc_id == 349 || soc_id == 350) {
|
|
||||||
is_target_SDM632 = true; /* Above SOCID for SDM632 */
|
return is_SDM632;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
return is_target_SDM632;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int power_hint_override(power_hint_t hint, void* data) {
|
int power_hint_override(power_hint_t hint, void* data) {
|
||||||
|
|||||||
24
utils.c
24
utils.c
@@ -43,6 +43,9 @@
|
|||||||
#define LOG_TAG "QTI PowerHAL"
|
#define LOG_TAG "QTI PowerHAL"
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
|
||||||
|
#define SOC_ID_0 "/sys/devices/soc0/soc_id"
|
||||||
|
#define SOC_ID_1 "/sys/devices/system/soc/soc0/id"
|
||||||
|
|
||||||
char scaling_gov_path[4][80] = {"sys/devices/system/cpu/cpu0/cpufreq/scaling_governor",
|
char scaling_gov_path[4][80] = {"sys/devices/system/cpu/cpu0/cpufreq/scaling_governor",
|
||||||
"sys/devices/system/cpu/cpu1/cpufreq/scaling_governor",
|
"sys/devices/system/cpu/cpu1/cpufreq/scaling_governor",
|
||||||
"sys/devices/system/cpu/cpu2/cpufreq/scaling_governor",
|
"sys/devices/system/cpu/cpu2/cpufreq/scaling_governor",
|
||||||
@@ -341,3 +344,24 @@ void undo_initial_hint_action() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_soc_id(void) {
|
||||||
|
int fd;
|
||||||
|
int soc_id = -1;
|
||||||
|
char buf[10] = {0};
|
||||||
|
|
||||||
|
if (!access(SOC_ID_0, F_OK))
|
||||||
|
fd = open(SOC_ID_0, O_RDONLY);
|
||||||
|
else
|
||||||
|
fd = open(SOC_ID_1, O_RDONLY);
|
||||||
|
|
||||||
|
if (fd >= 0) {
|
||||||
|
if (read(fd, buf, sizeof(buf) - 1) == -1)
|
||||||
|
ALOGW("Unable to read soc_id");
|
||||||
|
else
|
||||||
|
soc_id = atoi(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return soc_id;
|
||||||
|
}
|
||||||
|
|||||||
3
utils.h
3
utils.h
@@ -47,4 +47,7 @@ void release_request(int lock_handle);
|
|||||||
void interaction(int duration, int num_args, int opt_list[]);
|
void interaction(int duration, int num_args, int opt_list[]);
|
||||||
int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]);
|
int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]);
|
||||||
int perf_hint_enable(int hint_id, int duration);
|
int perf_hint_enable(int hint_id, int duration);
|
||||||
|
|
||||||
|
int get_soc_id(void);
|
||||||
|
|
||||||
PropVal perf_get_property(const char* prop, const char* def_val);
|
PropVal perf_get_property(const char* prop, const char* def_val);
|
||||||
|
|||||||
Reference in New Issue
Block a user