diff options
author | Ananth Raghavan Subramanian <sananth@codeaurora.org> | 2017-06-27 21:28:43 -0700 |
---|---|---|
committer | Sathish Ambley <sathishambley@codeaurora.org> | 2017-07-06 22:27:05 -0700 |
commit | 0c226b7921b421dd24363f15aefef1236aa25287 (patch) | |
tree | d43e1d8e6fa356c0aa63691814cc4888e76ec237 /power-8998.c | |
parent | 408ada31b5534816127eaace4e9278ae801e4e77 (diff) | |
download | android_hardware_qcom_power-0c226b7921b421dd24363f15aefef1236aa25287.tar.gz android_hardware_qcom_power-0c226b7921b421dd24363f15aefef1236aa25287.tar.bz2 android_hardware_qcom_power-0c226b7921b421dd24363f15aefef1236aa25287.zip |
power: Using PerfHAL API
Using the PerfHAL API to comply with Treble
Change-Id: I0ce40bbefb8c867dda8ee5eb1f948af2106e692d
Diffstat (limited to 'power-8998.c')
-rw-r--r-- | power-8998.c | 82 |
1 files changed, 17 insertions, 65 deletions
diff --git a/power-8998.c b/power-8998.c index 8c119af..280b3a7 100644 --- a/power-8998.c +++ b/power-8998.c @@ -58,20 +58,12 @@ static pthread_mutex_t s_interaction_lock = PTHREAD_MUTEX_INITIALIZER; static int process_sustained_perf_hint(void *data) { int duration = 0; - int *resource_values = NULL; - int resources = 0; pthread_mutex_lock(&s_interaction_lock); if (data && sustained_performance_mode == 0) { if (vr_mode == 0) { // Sustained mode only. - resource_values = getPowerhint(SUSTAINED_PERF_HINT_ID, &resources); - if (!resource_values) { - ALOGE("Can't get sustained perf hints from xml "); - pthread_mutex_unlock(&s_interaction_lock); - return HINT_NONE; - } - sustained_mode_handle = interaction_with_handle( - sustained_mode_handle, duration, resources, resource_values); + sustained_mode_handle = perf_hint_enable( + SUSTAINED_PERF_HINT, duration); if (!CHECK_HANDLE(sustained_mode_handle)) { ALOGE("Failed interaction_with_handle for sustained_mode_handle"); pthread_mutex_unlock(&s_interaction_lock); @@ -79,14 +71,8 @@ static int process_sustained_perf_hint(void *data) } } else if (vr_mode == 1) { // Sustained + VR mode. release_request(vr_mode_handle); - resource_values = getPowerhint(VR_MODE_SUSTAINED_PERF_HINT_ID, &resources); - if (!resource_values) { - ALOGE("Can't get VR mode sustained perf hints from xml "); - pthread_mutex_unlock(&s_interaction_lock); - return HINT_NONE; - } - sustained_mode_handle = interaction_with_handle( - sustained_mode_handle, duration, resources, resource_values); + sustained_mode_handle = perf_hint_enable( + VR_MODE_SUSTAINED_PERF_HINT, duration); if (!CHECK_HANDLE(sustained_mode_handle)) { ALOGE("Failed interaction_with_handle for sustained_mode_handle"); pthread_mutex_unlock(&s_interaction_lock); @@ -97,14 +83,8 @@ static int process_sustained_perf_hint(void *data) } else if (sustained_performance_mode == 1) { release_request(sustained_mode_handle); if (vr_mode == 1) { // Switch back to VR Mode. - resource_values = getPowerhint(VR_MODE_HINT_ID, &resources); - if (!resource_values) { - ALOGE("Can't get VR mode perf hints from xml "); - pthread_mutex_unlock(&s_interaction_lock); - return HINT_NONE; - } - vr_mode_handle = interaction_with_handle( - vr_mode_handle, duration, resources, resource_values); + vr_mode_handle = perf_hint_enable( + VR_MODE_HINT, duration); if (!CHECK_HANDLE(vr_mode_handle)) { ALOGE("Failed interaction_with_handle for vr_mode_handle"); pthread_mutex_unlock(&s_interaction_lock); @@ -120,20 +100,12 @@ static int process_sustained_perf_hint(void *data) static int process_vr_mode_hint(void *data) { int duration = 0; - int *resource_values = NULL; - int resources = 0; pthread_mutex_lock(&s_interaction_lock); if (data && vr_mode == 0) { if (sustained_performance_mode == 0) { // VR mode only. - resource_values = getPowerhint(VR_MODE_HINT_ID, &resources); - if (!resource_values) { - ALOGE("Can't get VR mode perf hints from xml "); - pthread_mutex_unlock(&s_interaction_lock); - return HINT_NONE; - } - vr_mode_handle = interaction_with_handle( - vr_mode_handle, duration, resources, resource_values); + vr_mode_handle = perf_hint_enable( + VR_MODE_HINT, duration); if (!CHECK_HANDLE(vr_mode_handle)) { ALOGE("Failed interaction_with_handle for vr_mode_handle"); pthread_mutex_unlock(&s_interaction_lock); @@ -141,14 +113,8 @@ static int process_vr_mode_hint(void *data) } } else if (sustained_performance_mode == 1) { // Sustained + VR mode. release_request(sustained_mode_handle); - resource_values = getPowerhint(VR_MODE_SUSTAINED_PERF_HINT_ID, &resources); - if (!resource_values) { - ALOGE("Can't get VR mode sustained perf hints from xml "); - pthread_mutex_unlock(&s_interaction_lock); - return HINT_NONE; - } - vr_mode_handle = interaction_with_handle( - vr_mode_handle, duration, resources, resource_values); + vr_mode_handle = perf_hint_enable( + VR_MODE_SUSTAINED_PERF_HINT, duration); if (!CHECK_HANDLE(vr_mode_handle)) { ALOGE("Failed interaction_with_handle for vr_mode_handle"); pthread_mutex_unlock(&s_interaction_lock); @@ -159,14 +125,8 @@ static int process_vr_mode_hint(void *data) } else if (vr_mode == 1) { release_request(vr_mode_handle); if (sustained_performance_mode == 1) { // Switch back to sustained Mode. - resource_values = getPowerhint(SUSTAINED_PERF_HINT_ID, &resources); - if (!resource_values) { - ALOGE("Can't get sustained perf hints from xml "); - pthread_mutex_unlock(&s_interaction_lock); - return HINT_NONE; - } - sustained_mode_handle = interaction_with_handle( - sustained_mode_handle, duration, resources, resource_values); + sustained_mode_handle = perf_hint_enable( + SUSTAINED_PERF_HINT, duration); if (!CHECK_HANDLE(sustained_mode_handle)) { ALOGE("Failed interaction_with_handle for sustained_mode_handle"); pthread_mutex_unlock(&s_interaction_lock); @@ -184,6 +144,7 @@ static int process_video_encode_hint(void *metadata) { char governor[80]; struct video_encode_metadata_t video_encode_metadata; + static int video_encode_handle = 0; if(!metadata) return HINT_NONE; @@ -197,7 +158,6 @@ static int process_video_encode_hint(void *metadata) /* Initialize encode metadata struct fields */ memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t)); video_encode_metadata.state = -1; - video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID; if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) == -1) { @@ -207,21 +167,13 @@ static int process_video_encode_hint(void *metadata) if (video_encode_metadata.state == 1) { if (is_interactive_governor(governor)) { - - int *resource_values; - int resources; - - /* extract perflock resources */ - resource_values = getPowerhint(video_encode_metadata.hint_id, &resources); - - if (resource_values != NULL) - perform_hint_action(video_encode_metadata.hint_id, resource_values, resources); - ALOGI("Video Encode hint start"); - return HINT_HANDLED; + video_encode_handle = perf_hint_enable( + VIDEO_ENCODE_HINT, 0); + return HINT_HANDLED; } } else if (video_encode_metadata.state == 0) { if (is_interactive_governor(governor)) { - undo_hint_action(video_encode_metadata.hint_id); + release_request(video_encode_handle); ALOGI("Video Encode hint stop"); return HINT_HANDLED; } |