power: Remove mutex to hints
* No longer needed. Change-Id: I09fc90b4e5399b3f3b8a409edf3f57361da90100
This commit is contained in:
committed by
Michael Bestas
parent
cd6e36030a
commit
1c368078d1
@@ -36,7 +36,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LOG_TAG "QTI PowerHAL"
|
||||
@@ -57,7 +56,6 @@ static int display_hint_sent;
|
||||
static int video_encode_hint_sent;
|
||||
static int cam_preview_hint_sent;
|
||||
|
||||
pthread_mutex_t camera_hint_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int camera_hint_ref_count;
|
||||
static void process_video_encode_hint(void *metadata);
|
||||
//static void process_cam_preview_hint(void *metadata);
|
||||
@@ -262,7 +260,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
|
||||
num_resources = sizeof(res)/sizeof(res[0]);
|
||||
}
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count++;
|
||||
if (camera_hint_ref_count == 1) {
|
||||
if (!video_encode_hint_sent) {
|
||||
@@ -271,19 +268,16 @@ static void process_video_encode_hint(void *metadata)
|
||||
video_encode_hint_sent = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
}
|
||||
} else if (video_encode_metadata.state == 0) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR,
|
||||
strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count--;
|
||||
if (!camera_hint_ref_count) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
video_encode_hint_sent = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LOG_TAG "QTI PowerHAL"
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LOG_TAG "QTI PowerHAL"
|
||||
@@ -71,7 +70,6 @@ perf_mode_t perf_modes[NUM_PERF_MODES] = { { SUSTAINED_MODE, SUSTAINED_PERF_HINT
|
||||
{ VR_MODE, VR_MODE_HINT },
|
||||
{ VR_SUSTAINED_MODE, VR_MODE_SUSTAINED_PERF_HINT } };
|
||||
|
||||
static pthread_mutex_t perf_mode_switch_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int current_mode = NORMAL_MODE;
|
||||
|
||||
static inline int get_perfd_hint_id(perf_mode_type_t type) {
|
||||
@@ -112,20 +110,16 @@ static int switch_mode(perf_mode_type_t mode) {
|
||||
|
||||
static int process_perf_hint(void *data, perf_mode_type_t mode) {
|
||||
|
||||
pthread_mutex_lock(&perf_mode_switch_lock);
|
||||
|
||||
// enable
|
||||
if (data){
|
||||
ALOGI("Enable request for mode: 0x%x", mode);
|
||||
// check if mode is current mode
|
||||
if ( current_mode & mode ) {
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
ALOGD("Mode 0x%x already enabled", mode);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
// enable requested mode
|
||||
if ( 0 != switch_mode(current_mode | mode)) {
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
ALOGE("Couldn't enable mode 0x%x", mode);
|
||||
return HINT_NONE;
|
||||
}
|
||||
@@ -136,13 +130,11 @@ static int process_perf_hint(void *data, perf_mode_type_t mode) {
|
||||
ALOGI("Disable request for mode: 0x%x", mode);
|
||||
// check if mode is enabled
|
||||
if ( !(current_mode & mode) ) {
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
ALOGD("Mode 0x%x already disabled", mode);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
//disable requested mode
|
||||
if ( 0 != switch_mode(current_mode & ~mode)) {
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
ALOGE("Couldn't disable mode 0x%x", mode);
|
||||
return HINT_NONE;
|
||||
}
|
||||
@@ -150,7 +142,6 @@ static int process_perf_hint(void *data, perf_mode_type_t mode) {
|
||||
ALOGI("Current mode is 0x%x", current_mode);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
10
power-8937.c
10
power-8937.c
@@ -37,7 +37,6 @@
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define LOG_TAG "QTI PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
@@ -55,7 +54,6 @@
|
||||
static int saved_interactive_mode = -1;
|
||||
static int display_hint_sent;
|
||||
static int video_encode_hint_sent;
|
||||
pthread_mutex_t camera_hint_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int camera_hint_ref_count;
|
||||
static void process_video_encode_hint(void *metadata);
|
||||
|
||||
@@ -209,7 +207,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
};
|
||||
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
|
||||
num_resources = sizeof(res)/sizeof(res[0]);
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count++;
|
||||
if (camera_hint_ref_count == 1) {
|
||||
if (!video_encode_hint_sent) {
|
||||
@@ -218,7 +215,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
video_encode_hint_sent = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
}
|
||||
else {
|
||||
/* sample_ms = 10mS */
|
||||
@@ -226,7 +222,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
};
|
||||
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
|
||||
num_resources = sizeof(res)/sizeof(res[0]);
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count++;
|
||||
if (camera_hint_ref_count == 1) {
|
||||
if (!video_encode_hint_sent) {
|
||||
@@ -235,7 +230,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
video_encode_hint_sent = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
}
|
||||
}
|
||||
else if ((strncmp(governor, INTERACTIVE_GOVERNOR,
|
||||
@@ -257,14 +251,12 @@ static void process_video_encode_hint(void *metadata)
|
||||
};
|
||||
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
|
||||
num_resources = sizeof(res)/sizeof(res[0]);
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count++;
|
||||
if (!video_encode_hint_sent) {
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values,num_resources);
|
||||
video_encode_hint_sent = 1;
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
}
|
||||
} else if (video_encode_metadata.state == 0) {
|
||||
if (((strncmp(governor, INTERACTIVE_GOVERNOR,
|
||||
@@ -273,13 +265,11 @@ static void process_video_encode_hint(void *metadata)
|
||||
((strncmp(governor, SCHEDUTIL_GOVERNOR,
|
||||
strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(SCHEDUTIL_GOVERNOR)))) {
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count--;
|
||||
if (!camera_hint_ref_count) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
video_encode_hint_sent = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
10
power-8953.c
10
power-8953.c
@@ -36,7 +36,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LOG_TAG "QTI PowerHAL"
|
||||
@@ -57,7 +56,6 @@ static int display_hint_sent;
|
||||
static int video_encode_hint_sent;
|
||||
static int cam_preview_hint_sent;
|
||||
|
||||
pthread_mutex_t camera_hint_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int camera_hint_ref_count;
|
||||
static void process_video_encode_hint(void *metadata);
|
||||
//static void process_cam_preview_hint(void *metadata);
|
||||
@@ -212,7 +210,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
};
|
||||
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
|
||||
num_resources = sizeof(res)/sizeof(res[0]);
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count++;
|
||||
if (camera_hint_ref_count == 1) {
|
||||
if (!video_encode_hint_sent) {
|
||||
@@ -221,7 +218,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
video_encode_hint_sent = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
}
|
||||
else {
|
||||
/* sample_ms = 10mS */
|
||||
@@ -229,7 +225,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
};
|
||||
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
|
||||
num_resources = sizeof(res)/sizeof(res[0]);
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count++;
|
||||
if (camera_hint_ref_count == 1) {
|
||||
if (!video_encode_hint_sent) {
|
||||
@@ -238,7 +233,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
video_encode_hint_sent = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
}
|
||||
}
|
||||
else if ((strncmp(governor, INTERACTIVE_GOVERNOR,
|
||||
@@ -252,7 +246,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
};
|
||||
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
|
||||
num_resources = sizeof(res)/sizeof(res[0]);
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count++;
|
||||
if (camera_hint_ref_count == 1) {
|
||||
if (!video_encode_hint_sent) {
|
||||
@@ -261,7 +254,6 @@ static void process_video_encode_hint(void *metadata)
|
||||
video_encode_hint_sent = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
}
|
||||
} else if (video_encode_metadata.state == 0) {
|
||||
if (((strncmp(governor, INTERACTIVE_GOVERNOR,
|
||||
@@ -270,13 +262,11 @@ static void process_video_encode_hint(void *metadata)
|
||||
((strncmp(governor, SCHEDUTIL_GOVERNOR,
|
||||
strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(SCHEDUTIL_GOVERNOR)))) {
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count--;
|
||||
if (!camera_hint_ref_count) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
video_encode_hint_sent = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
pthread_mutex_t camera_hint_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int display_hint_sent;
|
||||
static int camera_hint_ref_count;
|
||||
|
||||
@@ -101,25 +100,21 @@ static int process_video_encode_hint(void *metadata)
|
||||
0x41420000, 0x5A, 0x41400100, 0x4, 0x41410100, 0x5F, 0x41414100, 0x22C, 0x41420100, 0x5A,
|
||||
0x41810000, 0x9C4, 0x41814000, 0x32, 0x4180C000, 0x0, 0x41820000, 0xA};
|
||||
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count++;
|
||||
if (camera_hint_ref_count == 1) {
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
ALOGI("Video Encode hint start");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} else if (video_encode_metadata.state == 0) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count--;
|
||||
if (!camera_hint_ref_count) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
|
||||
ALOGI("Video Encode hint stop");
|
||||
return HINT_HANDLED;
|
||||
|
||||
11
power-8998.c
11
power-8998.c
@@ -35,7 +35,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LOG_TAG "QTI PowerHAL"
|
||||
@@ -69,7 +68,6 @@ perf_mode_t perf_modes[NUM_PERF_MODES] = { { SUSTAINED_MODE, SUSTAINED_PERF_HINT
|
||||
{ VR_MODE, VR_MODE_HINT },
|
||||
{ VR_SUSTAINED_MODE, VR_MODE_SUSTAINED_PERF_HINT } };
|
||||
|
||||
static pthread_mutex_t perf_mode_switch_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int current_mode = NORMAL_MODE;
|
||||
|
||||
static inline int get_perfd_hint_id(perf_mode_type_t type) {
|
||||
@@ -110,20 +108,16 @@ static int switch_mode(perf_mode_type_t mode) {
|
||||
|
||||
static int process_perf_hint(void *data, perf_mode_type_t mode) {
|
||||
|
||||
pthread_mutex_lock(&perf_mode_switch_lock);
|
||||
|
||||
// enable
|
||||
if (data){
|
||||
ALOGI("Enable request for mode: 0x%x", mode);
|
||||
// check if mode is current mode
|
||||
if ( current_mode & mode ) {
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
ALOGD("Mode 0x%x already enabled", mode);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
// enable requested mode
|
||||
if ( 0 != switch_mode(current_mode | mode)) {
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
ALOGE("Couldn't enable mode 0x%x", mode);
|
||||
return HINT_NONE;
|
||||
}
|
||||
@@ -134,13 +128,11 @@ static int process_perf_hint(void *data, perf_mode_type_t mode) {
|
||||
ALOGI("Disable request for mode: 0x%x", mode);
|
||||
// check if mode is enabled
|
||||
if ( !(current_mode & mode) ) {
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
ALOGD("Mode 0x%x already disabled", mode);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
//disable requested mode
|
||||
if ( 0 != switch_mode(current_mode & ~mode)) {
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
ALOGE("Couldn't disable mode 0x%x", mode);
|
||||
return HINT_NONE;
|
||||
}
|
||||
@@ -148,7 +140,6 @@ static int process_perf_hint(void *data, perf_mode_type_t mode) {
|
||||
ALOGI("Current mode is 0x%x", current_mode);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
@@ -207,11 +198,9 @@ int power_hint_override(power_hint_t hint, void *data)
|
||||
ret_val = process_perf_hint(data, VR_MODE);
|
||||
break;
|
||||
case POWER_HINT_INTERACTION:
|
||||
pthread_mutex_lock(&perf_mode_switch_lock);
|
||||
if (current_mode != NORMAL_MODE) {
|
||||
ret_val = HINT_HANDLED;
|
||||
}
|
||||
pthread_mutex_unlock(&perf_mode_switch_lock);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user