power: Using PerfHAL API
Using the PerfHAL API to comply with Treble
Change-Id: I0ce40bbefb8c867dda8ee5eb1f948af2106e692d
diff --git a/utils.c b/utils.c
index 860ae9d..af8e815 100644
--- a/utils.c
+++ b/utils.c
@@ -49,26 +49,24 @@
"sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"
};
+#define PERF_HAL_PATH "libqti-perfd-client.so"
static void *qcopt_handle;
static int (*perf_lock_acq)(unsigned long handle, int duration,
int list[], int numArgs);
static int (*perf_lock_rel)(unsigned long handle);
+static int (*perf_hint)(int, char *, int, int);
static struct list_node active_hint_list_head;
static void *get_qcopt_handle()
{
- char qcopt_lib_path[PATH_MAX] = {0};
void *handle = NULL;
dlerror();
- if (property_get("ro.vendor.extension_library", qcopt_lib_path,
- NULL)) {
- handle = dlopen(qcopt_lib_path, RTLD_NOW);
- if (!handle) {
- ALOGE("Unable to open %s: %s\n", qcopt_lib_path,
- dlerror());
- }
+ handle = dlopen(PERF_HAL_PATH, RTLD_NOW);
+ if (!handle) {
+ ALOGE("Unable to open %s: %s\n", PERF_HAL_PATH,
+ dlerror());
}
return handle;
@@ -96,6 +94,12 @@
if (!perf_lock_rel) {
ALOGE("Unable to get perf_lock_rel function handle.\n");
}
+
+ perf_hint = dlsym(qcopt_handle, "perf_hint");
+
+ if (!perf_hint) {
+ ALOGE("Unable to get perf_hint function handle.\n");
+ }
}
}
@@ -237,6 +241,26 @@
return lock_handle;
}
+//this is interaction_with_handle using perf_hint instead of
+//perf_lock_acq
+int perf_hint_enable(int hint_id , int duration)
+{
+ int lock_handle = 0;
+
+ if (duration < 0)
+ return 0;
+
+ if (qcopt_handle) {
+ if (perf_hint) {
+ lock_handle = perf_hint(hint_id, NULL, duration, -1);
+ if (lock_handle == -1)
+ ALOGE("Failed to acquire lock.");
+ }
+ }
+ return lock_handle;
+}
+
+
void release_request(int lock_handle) {
if (qcopt_handle && perf_lock_rel)
perf_lock_rel(lock_handle);