summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bestas <mkbestas@lineageos.org>2019-09-29 23:59:05 +0300
committerMichael Bestas <mkbestas@lineageos.org>2019-10-23 01:12:56 +0300
commit420f26552469aa8b98692c27de2320a9c1c5dbc2 (patch)
tree31388c8e259c3d606b033c8ec19d40a1a36fdeca
parent434acc2ab4bab9d2407e5167be1dc2c22bfead0f (diff)
downloadvendor_qcom_opensource_power-420f26552469aa8b98692c27de2320a9c1c5dbc2.zip
vendor_qcom_opensource_power-420f26552469aa8b98692c27de2320a9c1c5dbc2.tar.gz
vendor_qcom_opensource_power-420f26552469aa8b98692c27de2320a9c1c5dbc2.tar.bz2
power: clang-format
* Using AOSP interface .clang-format * Clean Android.mk while we are at it Change-Id: I630f72e3dffb676ca1930e72945e897f62103ada
l---------.clang-format1
-rw-r--r--Android.mk48
-rw-r--r--Power.cpp19
-rw-r--r--Power.h4
-rw-r--r--hint-data.c9
-rw-r--r--hint-data.h49
-rw-r--r--list.c42
-rw-r--r--list.h18
-rw-r--r--metadata-defs.h14
-rw-r--r--metadata-parser.c50
-rw-r--r--performance.h12
-rw-r--r--power-660.c212
-rw-r--r--power-710.c66
-rw-r--r--power-8084.c32
-rw-r--r--power-8226.c24
-rw-r--r--power-845.c148
-rw-r--r--power-8610.c24
-rw-r--r--power-8909.c50
-rw-r--r--power-8916.c219
-rw-r--r--power-8952.c240
-rw-r--r--power-8953.c235
-rw-r--r--power-8974.c32
-rw-r--r--power-8992.c40
-rw-r--r--power-8994.c40
-rw-r--r--power-8996.c47
-rw-r--r--power-8998.c92
-rw-r--r--power-common.c60
-rw-r--r--power-common.h13
-rw-r--r--power-msmnile.c69
-rw-r--r--service.cpp10
-rw-r--r--utils.c150
-rw-r--r--utils.h9
32 files changed, 920 insertions, 1158 deletions
diff --git a/.clang-format b/.clang-format
new file mode 120000
index 0000000..0457b53
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1 @@
+../../../../build/soong/scripts/system-clang-format \ No newline at end of file
diff --git a/Android.mk b/Android.mk
index 015db2a..41d1993 100644
--- a/Android.mk
+++ b/Android.mk
@@ -2,53 +2,70 @@ LOCAL_PATH := $(call my-dir)
ifeq ($(call is-vendor-board-platform,QCOM),true)
-# HAL module implemenation stored in
-# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
include $(CLEAR_VARS)
LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libbase libhidlbase libhidltransport libutils android.hardware.power@1.2
-LOCAL_HEADER_LIBRARIES += libhardware_headers
-LOCAL_SRC_FILES := power-common.c metadata-parser.c utils.c list.c hint-data.c service.cpp Power.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libcutils \
+ libdl \
+ libbase \
+ libhidlbase \
+ libhidltransport \
+ libutils \
+ android.hardware.power@1.2
+
+LOCAL_HEADER_LIBRARIES := \
+ libhardware_headers
+
+LOCAL_SRC_FILES := \
+ power-common.c \
+ metadata-parser.c \
+ utils.c \
+ list.c \
+ hint-data.c \
+ service.cpp \
+ Power.cpp
ifneq ($(BOARD_POWER_CUSTOM_BOARD_LIB),)
LOCAL_WHOLE_STATIC_LIBRARIES += $(BOARD_POWER_CUSTOM_BOARD_LIB)
else
# Include target-specific files.
-ifeq ($(call is-board-platform-in-list, msm8974), true)
+ifeq ($(call is-board-platform-in-list,msm8974), true)
LOCAL_SRC_FILES += power-8974.c
endif
-ifeq ($(call is-board-platform-in-list, msm8226), true)
+ifeq ($(call is-board-platform-in-list,msm8226), true)
LOCAL_SRC_FILES += power-8226.c
endif
-ifeq ($(call is-board-platform-in-list, msm8610), true)
+ifeq ($(call is-board-platform-in-list,msm8610), true)
LOCAL_SRC_FILES += power-8610.c
endif
-ifeq ($(call is-board-platform-in-list, apq8084), true)
+ifeq ($(call is-board-platform-in-list,apq8084), true)
LOCAL_SRC_FILES += power-8084.c
endif
-ifeq ($(call is-board-platform-in-list, msm8909), true)
+ifeq ($(call is-board-platform-in-list,msm8909), true)
LOCAL_SRC_FILES += power-8909.c
endif
-ifeq ($(call is-board-platform-in-list, msm8916), true)
+ifeq ($(call is-board-platform-in-list,msm8916), true)
LOCAL_SRC_FILES += power-8916.c
endif
-ifeq ($(call is-board-platform-in-list, msm8992), true)
+ifeq ($(call is-board-platform-in-list,msm8992), true)
LOCAL_SRC_FILES += power-8992.c
endif
-ifeq ($(call is-board-platform-in-list, msm8994), true)
+ifeq ($(call is-board-platform-in-list,msm8994), true)
LOCAL_SRC_FILES += power-8994.c
endif
-ifeq ($(call is-board-platform-in-list, msm8996), true)
+ifeq ($(call is-board-platform-in-list,msm8996), true)
LOCAL_SRC_FILES += power-8996.c
endif
@@ -88,7 +105,7 @@ ifeq ($(call is-board-platform-in-list,msmnile), true)
LOCAL_SRC_FILES += power-msmnile.c
endif
-endif # End of board specific list
+endif # End of board specific list
ifneq ($(TARGET_POWER_SET_FEATURE_LIB),)
LOCAL_STATIC_LIBRARIES += $(TARGET_POWER_SET_FEATURE_LIB)
@@ -111,6 +128,7 @@ LOCAL_MODULE := android.hardware.power@1.2-service-qti
LOCAL_INIT_RC := android.hardware.power@1.2-service-qti.rc
LOCAL_MODULE_TAGS := optional
LOCAL_VENDOR_MODULE := true
+
include $(BUILD_EXECUTABLE)
endif
diff --git a/Power.cpp b/Power.cpp
index 567066a..19e3abe 100644
--- a/Power.cpp
+++ b/Power.cpp
@@ -29,9 +29,9 @@
#define LOG_TAG "android.hardware.power@1.2-service-qti"
+#include "Power.h"
#include <android-base/file.h>
#include <log/log.h>
-#include "Power.h"
#include "power-common.h"
#include "power-feature.h"
@@ -41,31 +41,30 @@ namespace power {
namespace V1_2 {
namespace implementation {
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
using ::android::hardware::power::V1_0::Feature;
using ::android::hardware::power::V1_0::PowerHint;
using ::android::hardware::power::V1_0::PowerStatePlatformSleepState;
using ::android::hardware::power::V1_0::Status;
using ::android::hardware::power::V1_1::PowerStateSubsystem;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
Power::Power() {
power_init();
}
Return<void> Power::setInteractive(bool interactive) {
- set_interactive(interactive ? 1:0);
+ set_interactive(interactive ? 1 : 0);
return Void();
}
Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
-
power_hint(static_cast<power_hint_t>(hint), data ? (&data) : NULL);
return Void();
}
-Return<void> Power::setFeature(Feature feature, bool activate) {
+Return<void> Power::setFeature(Feature feature, bool activate) {
switch (feature) {
#ifdef TAP_TO_WAKE_NODE
case Feature::POWER_FEATURE_DOUBLE_TAP_TO_WAKE:
@@ -80,7 +79,6 @@ Return<void> Power::setFeature(Feature feature, bool activate) {
}
Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) {
-
hidl_vec<PowerStatePlatformSleepState> states;
states.resize(0);
@@ -89,7 +87,6 @@ Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_c
}
Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) {
-
hidl_vec<PowerStateSubsystem> subsystems;
_hidl_cb(subsystems, Status::SUCCESS);
@@ -97,13 +94,11 @@ Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl
}
Return<void> Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) {
-
return powerHint(hint, data);
}
Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
-
- return powerHint(static_cast<PowerHint_1_0> (hint), data);
+ return powerHint(static_cast<PowerHint_1_0>(hint), data);
}
} // namespace implementation
diff --git a/Power.h b/Power.h
index a787590..4ede54b 100644
--- a/Power.h
+++ b/Power.h
@@ -31,9 +31,9 @@
#define ANDROID_HARDWARE_POWER_V1_2_POWER_H
#include <android/hardware/power/1.2/IPower.h>
+#include <hardware/power.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
-#include <hardware/power.h>
namespace android {
namespace hardware {
@@ -44,9 +44,9 @@ namespace implementation {
using ::android::hardware::power::V1_0::Feature;
using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint;
using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint;
-using ::android::hardware::power::V1_2::IPower;
using ::android::hardware::Return;
using ::android::hardware::Void;
+using ::android::hardware::power::V1_2::IPower;
struct Power : public IPower {
// Methods from ::android::hardware::power::V1_0::IPower follow.
diff --git a/hint-data.c b/hint-data.c
index bd41cf0..0aae830 100644
--- a/hint-data.c
+++ b/hint-data.c
@@ -31,19 +31,16 @@
#include "hint-data.h"
-int hint_compare(struct hint_data *first_hint,
- struct hint_data *other_hint) {
+int hint_compare(struct hint_data* first_hint, struct hint_data* other_hint) {
if (first_hint == other_hint) {
return 0;
- } else if ((first_hint && other_hint) &&
- (first_hint->hint_id == other_hint->hint_id)) {
+ } else if ((first_hint && other_hint) && (first_hint->hint_id == other_hint->hint_id)) {
return 0;
} else {
return 1;
}
}
-void hint_dump(struct hint_data *hint)
-{
+void hint_dump(struct hint_data* hint) {
ALOGV("hint_id: %lu", hint->hint_id);
}
diff --git a/hint-data.h b/hint-data.h
index 48909c7..629a01e 100644
--- a/hint-data.h
+++ b/hint-data.h
@@ -28,33 +28,33 @@
*/
/* Default use-case hint IDs */
-#define DEFAULT_VIDEO_ENCODE_HINT_ID (0x0A00)
-#define DEFAULT_VIDEO_DECODE_HINT_ID (0x0B00)
-#define DISPLAY_STATE_HINT_ID (0x0C00)
-#define DISPLAY_STATE_HINT_ID_2 (0x0D00)
-#define CAM_PREVIEW_HINT_ID (0x0E00)
-#define SUSTAINED_PERF_HINT_ID (0x0F00)
-#define VR_MODE_HINT_ID (0x1000)
-#define VR_MODE_SUSTAINED_PERF_HINT_ID (0x1001)
+#define DEFAULT_VIDEO_ENCODE_HINT_ID (0x0A00)
+#define DEFAULT_VIDEO_DECODE_HINT_ID (0x0B00)
+#define DISPLAY_STATE_HINT_ID (0x0C00)
+#define DISPLAY_STATE_HINT_ID_2 (0x0D00)
+#define CAM_PREVIEW_HINT_ID (0x0E00)
+#define SUSTAINED_PERF_HINT_ID (0x0F00)
+#define VR_MODE_HINT_ID (0x1000)
+#define VR_MODE_SUSTAINED_PERF_HINT_ID (0x1001)
-#define AOSP_DELTA (0x1200)
+#define AOSP_DELTA (0x1200)
-#define VSYNC_HINT AOSP_DELTA + POWER_HINT_VSYNC
-#define INTERACTION_HINT AOSP_DELTA + POWER_HINT_INTERACTION
-#define VIDEO_DECODE_HINT AOSP_DELTA + POWER_HINT_VIDEO_DECODE
-#define VIDEO_ENCODE_HINT AOSP_DELTA + POWER_HINT_VIDEO_ENCODE
-#define LOW_POWER_HINT AOSP_DELTA + POWER_HINT_LOW_POWER
-#define SUSTAINED_PERF_HINT AOSP_DELTA + POWER_HINT_SUSTAINED_PERFORMANCE
-#define VR_MODE_HINT AOSP_DELTA + POWER_HINT_VR_MODE
-#define LAUNCH_HINT AOSP_DELTA + POWER_HINT_LAUNCH
-#define DISABLE_TOUCH_HINT AOSP_DELTA + POWER_HINT_DISABLE_TOUCH
+#define VSYNC_HINT AOSP_DELTA + POWER_HINT_VSYNC
+#define INTERACTION_HINT AOSP_DELTA + POWER_HINT_INTERACTION
+#define VIDEO_DECODE_HINT AOSP_DELTA + POWER_HINT_VIDEO_DECODE
+#define VIDEO_ENCODE_HINT AOSP_DELTA + POWER_HINT_VIDEO_ENCODE
+#define LOW_POWER_HINT AOSP_DELTA + POWER_HINT_LOW_POWER
+#define SUSTAINED_PERF_HINT AOSP_DELTA + POWER_HINT_SUSTAINED_PERFORMANCE
+#define VR_MODE_HINT AOSP_DELTA + POWER_HINT_VR_MODE
+#define LAUNCH_HINT AOSP_DELTA + POWER_HINT_LAUNCH
+#define DISABLE_TOUCH_HINT AOSP_DELTA + POWER_HINT_DISABLE_TOUCH
-//update NUM_HINTS if hints are added to AOSP
-#define NUM_HINTS (POWER_HINT_DISABLE_TOUCH +1)
+// update NUM_HINTS if hints are added to AOSP
+#define NUM_HINTS (POWER_HINT_DISABLE_TOUCH + 1)
-#define VR_MODE_SUSTAINED_PERF_HINT (0x1301)
+#define VR_MODE_SUSTAINED_PERF_HINT (0x1301)
-struct hint_handles{
+struct hint_handles {
int handle;
int ref_count;
};
@@ -64,6 +64,5 @@ struct hint_data {
unsigned long perflock_handle;
};
-int hint_compare(struct hint_data *first_hint,
- struct hint_data *other_hint);
-void hint_dump(struct hint_data *hint);
+int hint_compare(struct hint_data* first_hint, struct hint_data* other_hint);
+void hint_dump(struct hint_data* hint);
diff --git a/list.c b/list.c
index 7b9e4d3..d1cceaf 100644
--- a/list.c
+++ b/list.c
@@ -31,23 +31,20 @@
#include <stdlib.h>
#include <string.h>
-#include "list.h"
#include <log/log.h>
+#include "list.h"
-int init_list_head(struct list_node *head)
-{
- if (head == NULL)
- return -1;
+int init_list_head(struct list_node* head) {
+ if (head == NULL) return -1;
memset(head, 0, sizeof(*head));
return 0;
}
-struct list_node *add_list_node(struct list_node *head, void *data)
-{
+struct list_node* add_list_node(struct list_node* head, void* data) {
/* Create a new list_node. And put 'data' into it. */
- struct list_node *new_node;
+ struct list_node* new_node;
if (head == NULL) {
return NULL;
@@ -66,18 +63,16 @@ struct list_node *add_list_node(struct list_node *head, void *data)
return new_node;
}
-int is_list_empty(struct list_node *head)
-{
+int is_list_empty(struct list_node* head) {
return (head == NULL || head->next == NULL);
}
/*
* Delink and de-allocate 'node'.
*/
-int remove_list_node(struct list_node *head, struct list_node *del_node)
-{
- struct list_node *current_node;
- struct list_node *saved_node;
+int remove_list_node(struct list_node* head, struct list_node* del_node) {
+ struct list_node* current_node;
+ struct list_node* saved_node;
if (head == NULL || head->next == NULL) {
return -1;
@@ -107,12 +102,10 @@ int remove_list_node(struct list_node *head, struct list_node *del_node)
return 0;
}
-void dump_list(struct list_node *head)
-{
- struct list_node *current_node = head;
+void dump_list(struct list_node* head) {
+ struct list_node* current_node = head;
- if (head == NULL)
- return;
+ if (head == NULL) return;
ALOGV("List:\n");
@@ -123,17 +116,14 @@ void dump_list(struct list_node *head)
}
}
-struct list_node *find_node(struct list_node *head, void *comparison_data)
-{
- struct list_node *current_node = head;
+struct list_node* find_node(struct list_node* head, void* comparison_data) {
+ struct list_node* current_node = head;
- if (head == NULL)
- return NULL;
+ if (head == NULL) return NULL;
while ((current_node = current_node->next)) {
if (current_node->compare) {
- if (current_node->compare(current_node->data,
- comparison_data) == 0) {
+ if (current_node->compare(current_node->data, comparison_data) == 0) {
/* Match found. Return current_node. */
return current_node;
}
diff --git a/list.h b/list.h
index d68c3df..6e81d98 100644
--- a/list.h
+++ b/list.h
@@ -28,14 +28,14 @@
*/
struct list_node {
- struct list_node *next;
- void *data;
- int (*compare)(void *data1, void *data2);
- void (*dump)(void *data);
+ struct list_node* next;
+ void* data;
+ int (*compare)(void* data1, void* data2);
+ void (*dump)(void* data);
};
-int init_list_head(struct list_node *head);
-struct list_node * add_list_node(struct list_node *head, void *data);
-int remove_list_node(struct list_node *head, struct list_node *del_node);
-void dump_list(struct list_node *head);
-struct list_node *find_node(struct list_node *head, void *comparison_data);
+int init_list_head(struct list_node* head);
+struct list_node* add_list_node(struct list_node* head, void* data);
+int remove_list_node(struct list_node* head, struct list_node* del_node);
+void dump_list(struct list_node* head);
+struct list_node* find_node(struct list_node* head, void* comparison_data);
diff --git a/metadata-defs.h b/metadata-defs.h
index e3ce944..bbc5fbf 100644
--- a/metadata-defs.h
+++ b/metadata-defs.h
@@ -34,7 +34,7 @@
#define METADATA_PARSING_CONTINUE (0)
#define METADATA_PARSING_DONE (1)
-#define MIN(x,y) (((x)>(y))?(y):(x))
+#define MIN(x, y) (((x) > (y)) ? (y) : (x))
struct video_encode_metadata_t {
int hint_id;
@@ -46,9 +46,9 @@ struct video_decode_metadata_t {
int state;
};
-int parse_metadata(char *metadata, char **metadata_saveptr,
- char *attribute, unsigned int attribute_size, char *value, unsigned int value_size);
-int parse_video_encode_metadata(char *metadata,
- struct video_encode_metadata_t *video_encode_metadata);
-int parse_video_decode_metadata(char *metadata,
- struct video_decode_metadata_t *video_decode_metadata);
+int parse_metadata(char* metadata, char** metadata_saveptr, char* attribute,
+ unsigned int attribute_size, char* value, unsigned int value_size);
+int parse_video_encode_metadata(char* metadata,
+ struct video_encode_metadata_t* video_encode_metadata);
+int parse_video_decode_metadata(char* metadata,
+ struct video_decode_metadata_t* video_decode_metadata);
diff --git a/metadata-parser.c b/metadata-parser.c
index ffe092b..4a8bc30 100644
--- a/metadata-parser.c
+++ b/metadata-parser.c
@@ -28,29 +28,25 @@
*/
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include "metadata-defs.h"
-int parse_metadata(char *metadata, char **metadata_saveptr,
- char *attribute, unsigned int attribute_size, char *value, unsigned int value_size)
-{
- char *attribute_string;
- char *attribute_value_delim;
+int parse_metadata(char* metadata, char** metadata_saveptr, char* attribute,
+ unsigned int attribute_size, char* value, unsigned int value_size) {
+ char* attribute_string;
+ char* attribute_value_delim;
unsigned int bytes_to_copy;
- attribute_string = strtok_r(metadata, ATTRIBUTE_STRING_DELIM,
- metadata_saveptr);
+ attribute_string = strtok_r(metadata, ATTRIBUTE_STRING_DELIM, metadata_saveptr);
- if (attribute_string == NULL)
- return METADATA_PARSING_DONE;
+ if (attribute_string == NULL) return METADATA_PARSING_DONE;
attribute[0] = value[0] = '\0';
- if ((attribute_value_delim = strchr(attribute_string,
- ATTRIBUTE_VALUE_DELIM)) != NULL) {
- unsigned int attribute_len = (unsigned int) (attribute_value_delim - attribute_string);
+ if ((attribute_value_delim = strchr(attribute_string, ATTRIBUTE_VALUE_DELIM)) != NULL) {
+ unsigned int attribute_len = (unsigned int)(attribute_value_delim - attribute_string);
/* copy only attribute len + NUL character, or as much as can be fit */
bytes_to_copy = MIN(attribute_len + 1, attribute_size);
@@ -61,15 +57,14 @@ int parse_metadata(char *metadata, char **metadata_saveptr,
return METADATA_PARSING_CONTINUE;
}
-int parse_video_encode_metadata(char *metadata,
- struct video_encode_metadata_t *video_encode_metadata)
-{
+int parse_video_encode_metadata(char* metadata,
+ struct video_encode_metadata_t* video_encode_metadata) {
char attribute[1024], value[1024], *saveptr;
- char *temp_metadata = metadata;
+ char* temp_metadata = metadata;
int parsing_status;
- while ((parsing_status = parse_metadata(temp_metadata, &saveptr,
- attribute, sizeof(attribute), value, sizeof(value))) == METADATA_PARSING_CONTINUE) {
+ while ((parsing_status = parse_metadata(temp_metadata, &saveptr, attribute, sizeof(attribute),
+ value, sizeof(value))) == METADATA_PARSING_CONTINUE) {
if (strlen(attribute) == strlen("hint_id") &&
(strncmp(attribute, "hint_id", strlen("hint_id")) == 0)) {
if (strlen(value) > 0) {
@@ -87,21 +82,19 @@ int parse_video_encode_metadata(char *metadata,
temp_metadata = NULL;
}
- if (parsing_status == METADATA_PARSING_ERR)
- return -1;
+ if (parsing_status == METADATA_PARSING_ERR) return -1;
return 0;
}
-int parse_video_decode_metadata(char *metadata,
- struct video_decode_metadata_t *video_decode_metadata)
-{
+int parse_video_decode_metadata(char* metadata,
+ struct video_decode_metadata_t* video_decode_metadata) {
char attribute[1024], value[1024], *saveptr;
- char *temp_metadata = metadata;
+ char* temp_metadata = metadata;
int parsing_status;
- while ((parsing_status = parse_metadata(temp_metadata, &saveptr,
- attribute, sizeof(attribute), value, sizeof(value))) == METADATA_PARSING_CONTINUE) {
+ while ((parsing_status = parse_metadata(temp_metadata, &saveptr, attribute, sizeof(attribute),
+ value, sizeof(value))) == METADATA_PARSING_CONTINUE) {
if (strlen(attribute) == strlen("hint_id") &&
(strncmp(attribute, "hint_id", strlen("hint_id")) == 0)) {
if (strlen(value) > 0) {
@@ -119,8 +112,7 @@ int parse_video_decode_metadata(char *metadata,
temp_metadata = NULL;
}
- if (parsing_status == METADATA_PARSING_ERR)
- return -1;
+ if (parsing_status == METADATA_PARSING_ERR) return -1;
return 0;
}
diff --git a/performance.h b/performance.h
index 5196076..5d3a08c 100644
--- a/performance.h
+++ b/performance.h
@@ -31,15 +31,15 @@
extern "C" {
#endif
-#define FAILED -1
-#define SUCCESS 0
-#define INDEFINITE_DURATION 0
+#define FAILED -1
+#define SUCCESS 0
+#define INDEFINITE_DURATION 0
/* Hints sent to perf HAL from power HAL
* These have to be kept in sync with Perf HAL side definitions
*/
-#define VENDOR_HINT_DISPLAY_OFF 0x00001040
-#define VENDOR_HINT_DISPLAY_ON 0x00001041
+#define VENDOR_HINT_DISPLAY_OFF 0x00001040
+#define VENDOR_HINT_DISPLAY_ON 0x00001041
enum SCREEN_DISPLAY_TYPE {
DISPLAY_OFF = 0x00FF,
@@ -184,7 +184,7 @@ enum INTERACTIVE_OPCODES {
enum INTERACTIVE_HISPEED_FREQ_LVL {
HS_FREQ_1026 = 0xF0A,
- HS_FREQ_800 = 0xF08,
+ HS_FREQ_800 = 0xF08,
};
enum INTERACTIVE_HISPEED_LOAD_LVL {
diff --git a/power-660.c b/power-660.c
index f6cacf7..ce7c19b 100644
--- a/power-660.c
+++ b/power-660.c
@@ -29,27 +29,27 @@
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
-#define MIN_VAL(X,Y) ((X>Y)?(Y):(X))
+#define MIN_VAL(X, Y) ((X > Y) ? (Y) : (X))
static int saved_interactive_mode = -1;
static int display_hint_sent;
@@ -57,14 +57,13 @@ static int video_encode_hint_sent;
static int cam_preview_hint_sent;
static int camera_hint_ref_count;
-static void process_video_encode_hint(void *metadata);
-//static void process_cam_preview_hint(void *metadata);
+static void process_video_encode_hint(void* metadata);
+// static void process_cam_preview_hint(void *metadata);
/* Returns true is target is SDM630/SDM455 else false*/
-static bool is_target_SDM630()
-{
+static bool is_target_SDM630() {
int fd;
- bool is_target_SDM630=false;
+ bool is_target_SDM630 = false;
char buf[10] = {0};
fd = open("/sys/devices/soc0/soc_id", O_RDONLY);
if (fd >= 0) {
@@ -82,14 +81,11 @@ static bool is_target_SDM630()
return is_target_SDM630;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
-
- switch(hint) {
+int power_hint_override(power_hint_t hint, void* data) {
+ switch (hint) {
case POWER_HINT_VSYNC:
break;
- case POWER_HINT_VIDEO_ENCODE:
- {
+ case POWER_HINT_VIDEO_ENCODE: {
process_video_encode_hint(data);
return HINT_HANDLED;
}
@@ -97,8 +93,7 @@ int power_hint_override(power_hint_t hint, void *data)
return HINT_NONE;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
char tmp_str[NODE_MAX];
int resource_values[20];
@@ -108,10 +103,10 @@ int set_interactive_override(int on)
ALOGI("Got set_interactive hint");
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU3) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
return HINT_HANDLED;
}
@@ -121,67 +116,56 @@ int set_interactive_override(int on)
if (!on) {
/* Display off. */
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- /*
- 1. CPUfreq params
- - hispeed freq for big - 1113Mhz
- - go hispeed load for big - 95
- - above_hispeed_delay for big - 40ms
- 2. BusDCVS V2 params
- - Sample_ms of 10ms
- */
- if(is_target_SDM630()){
- int res[] = { 0x41414000, 0x459,
- 0x41410000, 0x5F,
- 0x41400000, 0x4,
- 0x41820000, 0xA };
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ /*
+ 1. CPUfreq params
+ - hispeed freq for big - 1113Mhz
+ - go hispeed load for big - 95
+ - above_hispeed_delay for big - 40ms
+ 2. BusDCVS V2 params
+ - Sample_ms of 10ms
+ */
+ if (is_target_SDM630()) {
+ int res[] = {0x41414000, 0x459, 0x41410000, 0x5F, 0x41400000, 0x4, 0x41820000, 0xA};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
}
- /*
- 1. CPUfreq params
- - hispeed freq for little - 902Mhz
- - go hispeed load for little - 95
- - above_hispeed_delay for little - 40ms
- 2. BusDCVS V2 params
- - Sample_ms of 10ms
- 3. Sched group upmigrate - 500
- */
- else{
- int res[] = { 0x41414100, 0x386,
- 0x41410100, 0x5F,
- 0x41400100, 0x4,
- 0x41820000, 0xA,
- 0x40C54000, 0x1F4};
+ /*
+ 1. CPUfreq params
+ - hispeed freq for little - 902Mhz
+ - go hispeed load for little - 95
+ - above_hispeed_delay for little - 40ms
+ 2. BusDCVS V2 params
+ - Sample_ms of 10ms
+ 3. Sched group upmigrate - 500
+ */
+ else {
+ int res[] = {0x41414100, 0x386, 0x41410100, 0x5F, 0x41400100,
+ 0x4, 0x41820000, 0xA, 0x40C54000, 0x1F4};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
-
+ num_resources = sizeof(res) / sizeof(res[0]);
}
- if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, num_resources);
- display_hint_sent = 1;
- }
- }
+ if (!display_hint_sent) {
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values, num_resources);
+ display_hint_sent = 1;
+ }
+ }
} else {
/* Display on. */
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
-
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- }
- }
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ undo_hint_action(DISPLAY_STATE_HINT_ID);
+ display_hint_sent = 0;
+ }
+ }
saved_interactive_mode = !!on;
return HINT_HANDLED;
}
-
/* Video Encode Hint */
-static void process_video_encode_hint(void *metadata)
-{
+static void process_video_encode_hint(void* metadata) {
char governor[80];
int resource_values[20];
int num_resources;
@@ -189,19 +173,15 @@ static void process_video_encode_hint(void *metadata)
ALOGI("Got process_video_encode_hint");
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU3) == -1) {
- ALOGE("Can't obtain scaling governor.");
- // return HINT_HANDLED;
- }
- }
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
+ ALOGE("Can't obtain scaling governor.");
+ // return HINT_HANDLED;
+ }
}
+ }
}
/* Initialize encode metadata struct fields. */
@@ -210,8 +190,7 @@ static void process_video_encode_hint(void *metadata)
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
if (metadata) {
- if (parse_video_encode_metadata((char *)metadata,
- &video_encode_metadata) == -1) {
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return;
}
@@ -220,28 +199,23 @@ static void process_video_encode_hint(void *metadata)
}
if (video_encode_metadata.state == 1) {
- if ((strncmp(governor, INTERACTIVE_GOVERNOR,
- strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- /*
- 1. CPUfreq params
- - hispeed freq for big - 1113Mhz
- - go hispeed load for big - 95
- - above_hispeed_delay for big - 40ms
- - target loads - 95
- - nr_run - 5
- 2. BusDCVS V2 params
- - Sample_ms of 10ms
- */
- if(is_target_SDM630()){
- int res[] = { 0x41414000, 0x459,
- 0x41410000, 0x5F,
- 0x41400000, 0x4,
- 0x41420000, 0x5F,
- 0x40C2C000, 0X5,
- 0x41820000, 0xA};
+ /*
+ 1. CPUfreq params
+ - hispeed freq for big - 1113Mhz
+ - go hispeed load for big - 95
+ - above_hispeed_delay for big - 40ms
+ - target loads - 95
+ - nr_run - 5
+ 2. BusDCVS V2 params
+ - Sample_ms of 10ms
+ */
+ if (is_target_SDM630()) {
+ int res[] = {0x41414000, 0x459, 0x41410000, 0x5F, 0x41400000, 0x4,
+ 0x41420000, 0x5F, 0x40C2C000, 0X5, 0x41820000, 0xA};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
}
/*
@@ -252,36 +226,30 @@ static void process_video_encode_hint(void *metadata)
2. BusDCVS V2 params
- Sample_ms of 10ms
*/
- else{
- int res[] = { 0x41414100, 0x386,
- 0x41410100, 0x5F,
- 0x41400100, 0x4,
- 0x41820000, 0xA};
+ else {
+ int res[] = {0x41414100, 0x386, 0x41410100, 0x5F, 0x41400100, 0x4, 0x41820000, 0xA};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
}
camera_hint_ref_count++;
if (camera_hint_ref_count == 1) {
if (!video_encode_hint_sent) {
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, num_resources);
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ num_resources);
video_encode_hint_sent = 1;
}
- }
+ }
}
} else if (video_encode_metadata.state == 0) {
- if ((strncmp(governor, INTERACTIVE_GOVERNOR,
- strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
camera_hint_ref_count--;
if (!camera_hint_ref_count) {
undo_hint_action(video_encode_metadata.hint_id);
video_encode_hint_sent = 0;
}
- return ;
+ return;
}
}
return;
}
-
-
diff --git a/power-710.c b/power-710.c
index e51a06c..75094a0 100644
--- a/power-710.c
+++ b/power-710.c
@@ -26,73 +26,63 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_fd;
#define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr"
-int set_interactive_override(int on)
-{
- static const char *display_on = "1";
- static const char *display_off = "0";
+int set_interactive_override(int on) {
+ static const char* display_on = "1";
+ static const char* display_off = "0";
char err_buf[80];
static int init_interactive_hint = 0;
static int set_i_count = 0;
int rc = 0;
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
- if (init_interactive_hint == 0)
- {
- //First time the display is turned off
+ if (init_interactive_hint == 0) {
+ // First time the display is turned off
display_fd = TEMP_FAILURE_RETRY(open(SYS_DISPLAY_PWR, O_RDWR));
if (display_fd < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
+ strerror_r(errno, err_buf, sizeof(err_buf));
ALOGE("Error opening %s: %s\n", SYS_DISPLAY_PWR, err_buf);
- }
- else
+ } else
init_interactive_hint = 1;
- }
- else
- if (!on ) {
- /* Display off. */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
- }
+ } else if (!on) {
+ /* Display off. */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
}
- else {
- /* Display on */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
- }
+ } else {
+ /* Display on */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
}
+ }
return HINT_HANDLED; /* Don't excecute this code path, not in use */
}
-
-
diff --git a/power-8084.c b/power-8084.c
index b66e09f..677546c 100644
--- a/power-8084.c
+++ b/power-8084.c
@@ -28,32 +28,31 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_hint_sent;
static int display_hint2_sent;
static int first_display_off_hint;
extern int display_boost;
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
@@ -81,12 +80,13 @@ int set_interactive_override(int on)
}
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
- int resource_values[] = {MS_500, SYNC_FREQ_600, OPTIMAL_FREQ_600, THREAD_MIGRATION_SYNC_OFF};
+ (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
+ int resource_values[] = {MS_500, SYNC_FREQ_600, OPTIMAL_FREQ_600,
+ THREAD_MIGRATION_SYNC_OFF};
if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
display_hint_sent = 1;
}
@@ -96,13 +96,13 @@ int set_interactive_override(int on)
/* Display on */
if (display_boost && display_hint2_sent) {
int resource_values2[] = {CPUS_ONLINE_MIN_2};
- perform_hint_action(DISPLAY_STATE_HINT_ID_2,
- resource_values2, sizeof(resource_values2)/sizeof(resource_values2[0]));
+ perform_hint_action(DISPLAY_STATE_HINT_ID_2, resource_values2,
+ sizeof(resource_values2) / sizeof(resource_values2[0]));
display_hint2_sent = 0;
}
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
+ (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
undo_hint_action(DISPLAY_STATE_HINT_ID);
display_hint_sent = 0;
diff --git a/power-8226.c b/power-8226.c
index a5961a2..8c3a445 100644
--- a/power-8226.c
+++ b/power-8226.c
@@ -28,36 +28,34 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_hint_sent;
-int power_hint_override(power_hint_t hint, void *data)
-{
- switch(hint) {
- case POWER_HINT_INTERACTION:
- {
+int power_hint_override(power_hint_t hint, void* data) {
+ switch (hint) {
+ case POWER_HINT_INTERACTION: {
int resources[] = {0x702, 0x20B, 0x30B};
int duration = 3000;
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, sizeof(resources) / sizeof(resources[0]), resources);
return HINT_HANDLED;
}
}
diff --git a/power-845.c b/power-845.c
index 98fec8b..621a882 100644
--- a/power-845.c
+++ b/power-845.c
@@ -27,57 +27,56 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_fd;
#define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr"
-#define CHECK_HANDLE(x) ((x)>0)
-#define NUM_PERF_MODES 3
+#define CHECK_HANDLE(x) ((x) > 0)
+#define NUM_PERF_MODES 3
typedef enum {
- NORMAL_MODE = 0,
- SUSTAINED_MODE = 1,
- VR_MODE = 2,
- VR_SUSTAINED_MODE = (SUSTAINED_MODE|VR_MODE),
- INVALID_MODE = 0xFF
-}perf_mode_type_t;
+ NORMAL_MODE = 0,
+ SUSTAINED_MODE = 1,
+ VR_MODE = 2,
+ VR_SUSTAINED_MODE = (SUSTAINED_MODE | VR_MODE),
+ INVALID_MODE = 0xFF
+} perf_mode_type_t;
typedef struct perf_mode {
perf_mode_type_t type;
int perf_hint_id;
-}perf_mode_t;
+} perf_mode_t;
-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 } };
+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 int current_mode = NORMAL_MODE;
-static inline int get_perfd_hint_id(perf_mode_type_t type) {
+static inline int get_perfd_hint_id(perf_mode_type_t type) {
int i;
- for(i=0; i<NUM_PERF_MODES; i++) {
+ for (i = 0; i < NUM_PERF_MODES; i++) {
if (perf_modes[i].type == type) {
ALOGD("Hint id is 0x%x for mode 0x%x", perf_modes[i].perf_hint_id, type);
return perf_modes[i].perf_hint_id;
@@ -88,7 +87,6 @@ static inline int get_perfd_hint_id(perf_mode_type_t type) {
}
static int switch_mode(perf_mode_type_t mode) {
-
int hint_id = 0;
static int perfd_mode_handle = -1;
@@ -100,7 +98,7 @@ static int switch_mode(perf_mode_type_t mode) {
}
// switch to a perf mode
hint_id = get_perfd_hint_id(mode);
- if(hint_id != 0) {
+ if (hint_id != 0) {
perfd_mode_handle = perf_hint_enable(hint_id, 0);
if (!CHECK_HANDLE(perfd_mode_handle)) {
ALOGE("Failed perf_hint_interaction for mode: 0x%x", mode);
@@ -111,33 +109,32 @@ static int switch_mode(perf_mode_type_t mode) {
return 0;
}
-static int process_perf_hint(void *data, perf_mode_type_t mode) {
-
+static int process_perf_hint(void* data, perf_mode_type_t mode) {
// enable
- if (data){
+ if (data) {
ALOGI("Enable request for mode: 0x%x", mode);
// check if mode is current mode
- if ( current_mode & mode ) {
+ if (current_mode & mode) {
ALOGD("Mode 0x%x already enabled", mode);
return HINT_HANDLED;
}
// enable requested mode
- if ( 0 != switch_mode(current_mode | mode)) {
+ if (0 != switch_mode(current_mode | mode)) {
ALOGE("Couldn't enable mode 0x%x", mode);
return HINT_NONE;
}
current_mode |= mode;
ALOGI("Current mode is 0x%x", current_mode);
- // disable
+ // disable
} else {
ALOGI("Disable request for mode: 0x%x", mode);
// check if mode is enabled
- if ( !(current_mode & mode) ) {
+ if (!(current_mode & mode)) {
ALOGD("Mode 0x%x already disabled", mode);
return HINT_HANDLED;
}
- //disable requested mode
- if ( 0 != switch_mode(current_mode & ~mode)) {
+ // disable requested mode
+ if (0 != switch_mode(current_mode & ~mode)) {
ALOGE("Couldn't disable mode 0x%x", mode);
return HINT_NONE;
}
@@ -148,14 +145,12 @@ static int process_perf_hint(void *data, perf_mode_type_t mode) {
return HINT_HANDLED;
}
-static int process_video_encode_hint(void *metadata)
-{
+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;
+ if (!metadata) return HINT_NONE;
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
@@ -167,21 +162,19 @@ static int process_video_encode_hint(void *metadata)
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
video_encode_metadata.state = -1;
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
- ALOGE("Error occurred while parsing metadata.");
- return HINT_NONE;
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
+ ALOGE("Error occurred while parsing metadata.");
+ return HINT_NONE;
}
if (video_encode_metadata.state == 1) {
- if (is_interactive_governor(governor)) {
- video_encode_handle = perf_hint_enable(
- VIDEO_ENCODE_HINT, 0);
- ALOGI("Video encode hint start");
- return HINT_HANDLED;
+ if (is_interactive_governor(governor)) {
+ video_encode_handle = perf_hint_enable(VIDEO_ENCODE_HINT, 0);
+ ALOGI("Video encode hint start");
+ return HINT_HANDLED;
}
} else if (video_encode_metadata.state == 0) {
- if (is_interactive_governor(governor)) {
+ if (is_interactive_governor(governor)) {
release_request(video_encode_handle);
ALOGI("Video Encode hint stop");
return HINT_HANDLED;
@@ -193,10 +186,9 @@ static int process_video_encode_hint(void *metadata)
/* Declare function before use */
void interaction(int duration, int num_args, int opt_list[]);
-int power_hint_override(power_hint_t hint, void *data)
-{
+int power_hint_override(power_hint_t hint, void* data) {
int ret_val = HINT_NONE;
- switch(hint) {
+ switch (hint) {
case POWER_HINT_VIDEO_ENCODE:
ret_val = process_video_encode_hint(data);
break;
@@ -206,60 +198,52 @@ int power_hint_override(power_hint_t hint, void *data)
case POWER_HINT_VR_MODE:
ret_val = process_perf_hint(data, VR_MODE);
break;
- case POWER_HINT_INTERACTION:
- {
+ case POWER_HINT_INTERACTION: {
int resources[] = {0x40800100, 0x514};
int duration = 100;
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, sizeof(resources) / sizeof(resources[0]), resources);
ret_val = HINT_HANDLED;
- }
- break;
+ } break;
default:
break;
}
return ret_val;
}
-int set_interactive_override(int on)
-{
- static const char *display_on = "1";
- static const char *display_off = "0";
+int set_interactive_override(int on) {
+ static const char* display_on = "1";
+ static const char* display_off = "0";
char err_buf[80];
static int init_interactive_hint = 0;
static int set_i_count = 0;
int rc = 0;
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
- if (init_interactive_hint == 0)
- {
- //First time the display is turned off
+ if (init_interactive_hint == 0) {
+ // First time the display is turned off
display_fd = TEMP_FAILURE_RETRY(open(SYS_DISPLAY_PWR, O_RDWR));
if (display_fd < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
+ strerror_r(errno, err_buf, sizeof(err_buf));
ALOGE("Error opening %s: %s\n", SYS_DISPLAY_PWR, err_buf);
- }
- else
+ } else
init_interactive_hint = 1;
- }
- else
- if (!on ) {
- /* Display off. */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
- }
+ } else if (!on) {
+ /* Display off. */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
}
- else {
- /* Display on */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
- }
+ } else {
+ /* Display on */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
}
+ }
return HINT_HANDLED; /* Don't excecute this code path, not in use */
}
diff --git a/power-8610.c b/power-8610.c
index a5961a2..8c3a445 100644
--- a/power-8610.c
+++ b/power-8610.c
@@ -28,36 +28,34 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_hint_sent;
-int power_hint_override(power_hint_t hint, void *data)
-{
- switch(hint) {
- case POWER_HINT_INTERACTION:
- {
+int power_hint_override(power_hint_t hint, void* data) {
+ switch (hint) {
+ case POWER_HINT_INTERACTION: {
int resources[] = {0x702, 0x20B, 0x30B};
int duration = 3000;
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, sizeof(resources) / sizeof(resources[0]), resources);
return HINT_HANDLED;
}
}
diff --git a/power-8909.c b/power-8909.c
index 5f07841..219117c 100644
--- a/power-8909.c
+++ b/power-8909.c
@@ -28,28 +28,26 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
-
-static void process_video_encode_hint(void *metadata)
-{
+static void process_video_encode_hint(void* metadata) {
char governor[80];
struct video_encode_metadata_t video_encode_metadata;
char tmp_str[NODE_MAX];
@@ -66,8 +64,7 @@ static void process_video_encode_hint(void *metadata)
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
if (metadata) {
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return;
}
@@ -77,31 +74,26 @@ static void process_video_encode_hint(void *metadata)
if (video_encode_metadata.state == 1) {
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {HS_FREQ_800, THREAD_MIGRATION_SYNC_OFF};
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
}
} else if (video_encode_metadata.state == 0) {
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- undo_hint_action(video_encode_metadata.hint_id);
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ undo_hint_action(video_encode_metadata.hint_id);
}
}
}
-int power_hint_override(power_hint_t hint, void *data)
-{
- switch(hint) {
- case POWER_HINT_VIDEO_ENCODE:
- {
- process_video_encode_hint(data);
- return HINT_HANDLED;
- }
- default:
- {
- break;
+int power_hint_override(power_hint_t hint, void* data) {
+ switch (hint) {
+ case POWER_HINT_VIDEO_ENCODE: {
+ process_video_encode_hint(data);
+ return HINT_HANDLED;
}
+ default: { break; }
}
return HINT_NONE;
}
diff --git a/power-8916.c b/power-8916.c
index 6181a27..a685c40 100644
--- a/power-8916.c
+++ b/power-8916.c
@@ -29,34 +29,32 @@
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
#define MIN_FREQ_CPU0_DISP_OFF 400000
-#define MIN_FREQ_CPU0_DISP_ON 960000
+#define MIN_FREQ_CPU0_DISP_ON 960000
-char scaling_min_freq[4][80] ={
- "sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq",
- "sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq",
- "sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq",
- "sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq"
-};
+char scaling_min_freq[4][80] = {"sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq",
+ "sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq",
+ "sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq",
+ "sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq"};
static int saved_dcvs_cpu0_slack_max = -1;
static int saved_dcvs_cpu0_slack_min = -1;
@@ -70,7 +68,7 @@ int display_boost;
static int is_target_8916() /* Returns value=8916 if target is 8916 else value 0 */
{
int fd;
- int is_target_8916=0;
+ int is_target_8916 = 0;
char buf[10] = {0};
fd = open("/sys/devices/soc0/soc_id", O_RDONLY);
@@ -80,8 +78,8 @@ static int is_target_8916() /* Returns value=8916 if target is 8916 else value 0
is_target_8916 = 0;
} else {
int soc_id = atoi(buf);
- if (soc_id == 206 || (soc_id >= 247 && soc_id <= 250)) {
- is_target_8916 = 8916; /* Above SOCID for 8916 */
+ if (soc_id == 206 || (soc_id >= 247 && soc_id <= 250)) {
+ is_target_8916 = 8916; /* Above SOCID for 8916 */
}
}
}
@@ -89,18 +87,15 @@ static int is_target_8916() /* Returns value=8916 if target is 8916 else value 0
return is_target_8916;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
-
- switch(hint) {
+int power_hint_override(power_hint_t hint, void* data) {
+ switch (hint) {
case POWER_HINT_VSYNC:
- break;
- case POWER_HINT_INTERACTION:
- {
+ break;
+ case POWER_HINT_INTERACTION: {
int resources[] = {0x702, 0x20F, 0x30F};
int duration = 3000;
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, sizeof(resources) / sizeof(resources[0]), resources);
}
return HINT_HANDLED;
case POWER_HINT_VIDEO_ENCODE: /* Do nothing for encode case */
@@ -110,21 +105,20 @@ int power_hint_override(power_hint_t hint, void *data)
default:
return HINT_HANDLED;
}
-return HINT_NONE;
+ return HINT_NONE;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
char tmp_str[NODE_MAX];
struct video_encode_metadata_t video_encode_metadata;
int rc;
ALOGI("Got set_interactive hint");
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU3) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
return HINT_HANDLED;
}
@@ -134,96 +128,87 @@ int set_interactive_override(int on)
if (!on) {
/* Display off. */
- switch(is_target_8916()) {
-
- case 8916:
- {
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- int resource_values[] = {TR_MS_50, THREAD_MIGRATION_SYNC_OFF};
-
- if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
- display_hint_sent = 1;
- }
- } /* Perf time rate set for 8916 target*/
- } /* End of Switch case for 8916 */
- break ;
-
- default:
- {
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- int resource_values[] = {TR_MS_CPU0_50,TR_MS_CPU4_50, THREAD_MIGRATION_SYNC_OFF};
-
- /* Set CPU0 MIN FREQ to 400Mhz avoid extra peak power
- impact in volume key press */
- snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_OFF);
- if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) {
- if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) {
- if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) {
- if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) {
- if(!slack_node_rw_failed) {
- ALOGE("Failed to write to %s",SCALING_MIN_FREQ );
- }
- rc = 1;
- }
- }
- }
- }
-
- if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
- display_hint_sent = 1;
- }
- } /* Perf time rate set for CORE0,CORE4 8939 target*/
- }/* End of Switch case for 8939 */
- break ;
- }
+ switch (is_target_8916()) {
+ case 8916: {
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ int resource_values[] = {TR_MS_50, THREAD_MIGRATION_SYNC_OFF};
+
+ if (!display_hint_sent) {
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
+ display_hint_sent = 1;
+ }
+ } /* Perf time rate set for 8916 target*/
+ } /* End of Switch case for 8916 */
+ break;
+
+ default: {
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ int resource_values[] = {TR_MS_CPU0_50, TR_MS_CPU4_50,
+ THREAD_MIGRATION_SYNC_OFF};
+
+ /* Set CPU0 MIN FREQ to 400Mhz avoid extra peak power
+ impact in volume key press */
+ snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_OFF);
+ if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) {
+ if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) {
+ if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) {
+ if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) {
+ if (!slack_node_rw_failed) {
+ ALOGE("Failed to write to %s", SCALING_MIN_FREQ);
+ }
+ rc = 1;
+ }
+ }
+ }
+ }
+
+ if (!display_hint_sent) {
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
+ display_hint_sent = 1;
+ }
+ } /* Perf time rate set for CORE0,CORE4 8939 target*/
+ } /* End of Switch case for 8939 */
+ break;
+ }
} else {
/* Display on. */
- switch(is_target_8916()){
- case 8916:
- {
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- }
- }
- break ;
- default :
- {
-
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
-
- /* Recovering MIN_FREQ in display ON case */
- snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_ON);
- if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) {
- if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) {
- if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) {
- if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) {
- if(!slack_node_rw_failed) {
- ALOGE("Failed to write to %s",SCALING_MIN_FREQ );
- }
- rc = 1;
- }
- }
- }
+ switch (is_target_8916()) {
+ case 8916: {
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ undo_hint_action(DISPLAY_STATE_HINT_ID);
+ display_hint_sent = 0;
+ }
+ } break;
+ default: {
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ /* Recovering MIN_FREQ in display ON case */
+ snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_ON);
+ if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) {
+ if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) {
+ if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) {
+ if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) {
+ if (!slack_node_rw_failed) {
+ ALOGE("Failed to write to %s", SCALING_MIN_FREQ);
+ }
+ rc = 1;
+ }
+ }
+ }
+ }
+ undo_hint_action(DISPLAY_STATE_HINT_ID);
+ display_hint_sent = 0;
}
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- }
- }
- break ;
- } /* End of check condition during the DISPLAY ON case */
- }
+ } break;
+ } /* End of check condition during the DISPLAY ON case */
+ }
saved_interactive_mode = !!on;
return HINT_HANDLED;
}
-
diff --git a/power-8952.c b/power-8952.c
index ec23dd3..9ae1292 100644
--- a/power-8952.c
+++ b/power-8952.c
@@ -29,33 +29,33 @@
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
-#define MIN_VAL(X,Y) ((X>Y)?(Y):(X))
+#define MIN_VAL(X, Y) ((X > Y) ? (Y) : (X))
static int saved_interactive_mode = -1;
static int display_hint_sent;
static int video_encode_hint_sent;
static int camera_hint_ref_count;
-static void process_video_encode_hint(void *metadata);
+static void process_video_encode_hint(void* metadata);
static int display_fd;
#define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr"
@@ -80,14 +80,11 @@ static bool is_target_SDM439() /* Returns value=1 if target is Hathi else value
return is_target_SDM439;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
-
- switch(hint) {
+int power_hint_override(power_hint_t hint, void* data) {
+ switch (hint) {
case POWER_HINT_VSYNC:
break;
- case POWER_HINT_VIDEO_ENCODE:
- {
+ case POWER_HINT_VIDEO_ENCODE: {
process_video_encode_hint(data);
return HINT_HANDLED;
}
@@ -95,25 +92,24 @@ int power_hint_override(power_hint_t hint, void *data)
return HINT_NONE;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
char tmp_str[NODE_MAX];
struct video_encode_metadata_t video_encode_metadata;
int rc = 0;
- static const char *display_on = "1";
- static const char *display_off = "0";
+ static const char* display_on = "1";
+ static const char* display_off = "0";
char err_buf[80];
static int init_interactive_hint = 0;
static int set_i_count = 0;
ALOGI("Got set_interactive hint");
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU3) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
return HINT_HANDLED;
}
@@ -123,69 +119,62 @@ int set_interactive_override(int on)
if (!on) {
/* Display off. */
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- int resource_values[] = {INT_OP_CLUSTER0_TIMER_RATE, BIG_LITTLE_TR_MS_50,
- INT_OP_CLUSTER1_TIMER_RATE, BIG_LITTLE_TR_MS_50,
- INT_OP_NOTIFY_ON_MIGRATE, 0x00};
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ int resource_values[] = {INT_OP_CLUSTER0_TIMER_RATE, BIG_LITTLE_TR_MS_50,
+ INT_OP_CLUSTER1_TIMER_RATE, BIG_LITTLE_TR_MS_50,
+ INT_OP_NOTIFY_ON_MIGRATE, 0x00};
- if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
- display_hint_sent = 1;
- }
- } /* Perf time rate set for CORE0,CORE4 8952 target*/
+ if (!display_hint_sent) {
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
+ display_hint_sent = 1;
+ }
+ } /* Perf time rate set for CORE0,CORE4 8952 target*/
} else {
/* Display on. */
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
-
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- }
- }
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ undo_hint_action(DISPLAY_STATE_HINT_ID);
+ display_hint_sent = 0;
+ }
+ }
saved_interactive_mode = !!on;
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
- if (init_interactive_hint == 0)
- {
- //First time the display is turned off
+ if (init_interactive_hint == 0) {
+ // First time the display is turned off
display_fd = TEMP_FAILURE_RETRY(open(SYS_DISPLAY_PWR, O_RDWR));
if (display_fd < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
+ strerror_r(errno, err_buf, sizeof(err_buf));
ALOGE("Error opening %s: %s\n", SYS_DISPLAY_PWR, err_buf);
return HINT_HANDLED;
- }
- else
+ } else
init_interactive_hint = 1;
- }
- else
- if (!on ) {
- /* Display off. */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
- }
+ } else if (!on) {
+ /* Display off. */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
}
- else {
- /* Display on */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
- }
+ } else {
+ /* Display on */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
}
+ }
return HINT_HANDLED;
}
/* Video Encode Hint */
-static void process_video_encode_hint(void *metadata)
-{
+static void process_video_encode_hint(void* metadata) {
char governor[80] = {0};
int resource_values[20] = {0};
int num_resources = 0;
@@ -193,19 +182,15 @@ static void process_video_encode_hint(void *metadata)
ALOGI("Got process_video_encode_hint");
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU3) == -1) {
- ALOGE("Can't obtain scaling governor.");
- return;
- }
- }
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
+ ALOGE("Can't obtain scaling governor.");
+ return;
+ }
}
+ }
}
/* Initialize encode metadata struct fields. */
@@ -214,8 +199,7 @@ static void process_video_encode_hint(void *metadata)
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
if (metadata) {
- if (parse_video_encode_metadata((char *)metadata,
- &video_encode_metadata) == -1) {
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return;
}
@@ -224,93 +208,77 @@ static void process_video_encode_hint(void *metadata)
}
if (video_encode_metadata.state == 1) {
- if((strncmp(governor, SCHEDUTIL_GOVERNOR,
- strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
+ if ((strncmp(governor, SCHEDUTIL_GOVERNOR, strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
(strlen(governor) == strlen(SCHEDUTIL_GOVERNOR))) {
- if(is_target_SDM439()) {
+ if (is_target_SDM439()) {
/* sample_ms = 10mS
- * SLB for Core0 = -6
- * SLB for Core1 = -6
- * SLB for Core2 = -6
- * SLB for Core3 = -6
- * hispeed load = 95
- * hispeed freq = 998Mhz */
- int res[] = {0x41820000, 0xa,
- 0x40c68100, 0xfffffffa,
- 0x40c68110, 0xfffffffa,
- 0x40c68120, 0xfffffffa,
- 0x40c68130, 0xfffffffa,
- 0x41440100, 0x5f,
- 0x4143c100, 0x3e6,
- };
+ * SLB for Core0 = -6
+ * SLB for Core1 = -6
+ * SLB for Core2 = -6
+ * SLB for Core3 = -6
+ * hispeed load = 95
+ * hispeed freq = 998Mhz */
+ int res[] = {
+ 0x41820000, 0xa, 0x40c68100, 0xfffffffa, 0x40c68110,
+ 0xfffffffa, 0x40c68120, 0xfffffffa, 0x40c68130, 0xfffffffa,
+ 0x41440100, 0x5f, 0x4143c100, 0x3e6,
+ };
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
camera_hint_ref_count++;
if (camera_hint_ref_count == 1) {
if (!video_encode_hint_sent) {
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, num_resources);
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ num_resources);
video_encode_hint_sent = 1;
}
}
- }
- else {
+ } else {
/* sample_ms = 10mS */
- int res[] = {0x41820000, 0xa,
- };
+ int res[] = {
+ 0x41820000,
+ 0xa,
+ };
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
camera_hint_ref_count++;
if (camera_hint_ref_count == 1) {
if (!video_encode_hint_sent) {
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, num_resources);
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ num_resources);
video_encode_hint_sent = 1;
}
}
}
- }
- else if ((strncmp(governor, INTERACTIVE_GOVERNOR,
- strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- /* Sched_load and migration_notif*/
- int res[] = {INT_OP_CLUSTER0_USE_SCHED_LOAD,
- 0x1,
- INT_OP_CLUSTER1_USE_SCHED_LOAD,
- 0x1,
- INT_OP_CLUSTER0_USE_MIGRATION_NOTIF,
- 0x1,
- INT_OP_CLUSTER1_USE_MIGRATION_NOTIF,
- 0x1,
- INT_OP_CLUSTER0_TIMER_RATE,
- BIG_LITTLE_TR_MS_40,
- INT_OP_CLUSTER1_TIMER_RATE,
- BIG_LITTLE_TR_MS_40
- };
+ } else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ /* Sched_load and migration_notif*/
+ int res[] = {INT_OP_CLUSTER0_USE_SCHED_LOAD, 0x1,
+ INT_OP_CLUSTER1_USE_SCHED_LOAD, 0x1,
+ INT_OP_CLUSTER0_USE_MIGRATION_NOTIF, 0x1,
+ INT_OP_CLUSTER1_USE_MIGRATION_NOTIF, 0x1,
+ INT_OP_CLUSTER0_TIMER_RATE, BIG_LITTLE_TR_MS_40,
+ INT_OP_CLUSTER1_TIMER_RATE, BIG_LITTLE_TR_MS_40};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
camera_hint_ref_count++;
if (!video_encode_hint_sent) {
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values,num_resources);
+ perform_hint_action(video_encode_metadata.hint_id, resource_values, num_resources);
video_encode_hint_sent = 1;
}
}
} else if (video_encode_metadata.state == 0) {
- if (((strncmp(governor, INTERACTIVE_GOVERNOR,
- strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) ||
- ((strncmp(governor, SCHEDUTIL_GOVERNOR,
- strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(SCHEDUTIL_GOVERNOR)))) {
+ if (((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) ||
+ ((strncmp(governor, SCHEDUTIL_GOVERNOR, strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(SCHEDUTIL_GOVERNOR)))) {
camera_hint_ref_count--;
if (!camera_hint_ref_count) {
undo_hint_action(video_encode_metadata.hint_id);
video_encode_hint_sent = 0;
}
- return ;
+ return;
}
}
return;
}
-
diff --git a/power-8953.c b/power-8953.c
index 5e98089..1ecd119 100644
--- a/power-8953.c
+++ b/power-8953.c
@@ -29,27 +29,27 @@
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
-#define MIN_VAL(X,Y) ((X>Y)?(Y):(X))
+#define MIN_VAL(X, Y) ((X > Y) ? (Y) : (X))
static int saved_interactive_mode = -1;
static int display_hint_sent;
@@ -57,8 +57,8 @@ static int video_encode_hint_sent;
static int cam_preview_hint_sent;
static int camera_hint_ref_count;
-static void process_video_encode_hint(void *metadata);
-//static void process_cam_preview_hint(void *metadata);
+static void process_video_encode_hint(void* metadata);
+// static void process_cam_preview_hint(void *metadata);
static int display_fd;
#define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr"
@@ -84,14 +84,11 @@ static bool is_target_SDM632() /* Returns value=632 if target is SDM632 else val
return is_target_SDM632;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
-
- switch(hint) {
+int power_hint_override(power_hint_t hint, void* data) {
+ switch (hint) {
case POWER_HINT_VSYNC:
break;
- case POWER_HINT_VIDEO_ENCODE:
- {
+ case POWER_HINT_VIDEO_ENCODE: {
process_video_encode_hint(data);
return HINT_HANDLED;
}
@@ -99,25 +96,24 @@ int power_hint_override(power_hint_t hint, void *data)
return HINT_NONE;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
char tmp_str[NODE_MAX];
struct video_encode_metadata_t video_encode_metadata;
int rc = 0;
- static const char *display_on = "1";
- static const char *display_off = "0";
+ static const char* display_on = "1";
+ static const char* display_off = "0";
char err_buf[80];
static int init_interactive_hint = 0;
static int set_i_count = 0;
ALOGI("Got set_interactive hint");
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU3) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
return HINT_HANDLED;
}
@@ -127,69 +123,63 @@ int set_interactive_override(int on)
if (!on) {
/* Display off. */
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
/* timer rate - 40mS*/
- int resource_values[] = {0x41424000, 0x28,
- };
- if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
- display_hint_sent = 1;
- }
- } /* Perf time rate set for CORE0,CORE4 8952 target*/
+ int resource_values[] = {
+ 0x41424000,
+ 0x28,
+ };
+ if (!display_hint_sent) {
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
+ display_hint_sent = 1;
+ }
+ } /* Perf time rate set for CORE0,CORE4 8952 target*/
} else {
/* Display on. */
- if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
-
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- }
- }
+ if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ undo_hint_action(DISPLAY_STATE_HINT_ID);
+ display_hint_sent = 0;
+ }
+ }
saved_interactive_mode = !!on;
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
- if (init_interactive_hint == 0)
- {
- //First time the display is turned off
+ if (init_interactive_hint == 0) {
+ // First time the display is turned off
display_fd = TEMP_FAILURE_RETRY(open(SYS_DISPLAY_PWR, O_RDWR));
if (display_fd < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
+ strerror_r(errno, err_buf, sizeof(err_buf));
ALOGE("Error opening %s: %s\n", SYS_DISPLAY_PWR, err_buf);
return HINT_HANDLED;
- }
- else
+ } else
init_interactive_hint = 1;
- }
- else
- if (!on ) {
- /* Display off. */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
- }
+ } else if (!on) {
+ /* Display off. */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
}
- else {
- /* Display on */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
- }
+ } else {
+ /* Display on */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
}
+ }
return HINT_HANDLED;
}
-
/* Video Encode Hint */
-static void process_video_encode_hint(void *metadata)
-{
+static void process_video_encode_hint(void* metadata) {
char governor[80] = {0};
int resource_values[20] = {0};
int num_resources = 0;
@@ -197,19 +187,15 @@ static void process_video_encode_hint(void *metadata)
ALOGI("Got process_video_encode_hint");
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU3) == -1) {
- ALOGE("Can't obtain scaling governor.");
- // return HINT_HANDLED;
- }
- }
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
+ ALOGE("Can't obtain scaling governor.");
+ // return HINT_HANDLED;
+ }
}
+ }
}
/* Initialize encode metadata struct fields. */
@@ -218,8 +204,7 @@ static void process_video_encode_hint(void *metadata)
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
if (metadata) {
- if (parse_video_encode_metadata((char *)metadata,
- &video_encode_metadata) == -1) {
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return;
}
@@ -228,88 +213,78 @@ static void process_video_encode_hint(void *metadata)
}
if (video_encode_metadata.state == 1) {
- if((strncmp(governor, SCHEDUTIL_GOVERNOR,
- strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
+ if ((strncmp(governor, SCHEDUTIL_GOVERNOR, strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
(strlen(governor) == strlen(SCHEDUTIL_GOVERNOR))) {
- if(is_target_SDM632()) {
+ if (is_target_SDM632()) {
/* sample_ms = 10mS
- * SLB for Core0 = -6
- * SLB for Core1 = -6
- * SLB for Core2 = -6
- * SLB for Core3 = -6
- * hispeed load = 95
- * hispeed freq = 1036 */
- int res[] = {0x41820000, 0xa,
- 0x40c68100, 0xfffffffa,
- 0x40c68110, 0xfffffffa,
- 0x40c68120, 0xfffffffa,
- 0x40c68130, 0xfffffffa,
- 0x41440100, 0x5f,
- 0x4143c100, 0x40c,
- };
+ * SLB for Core0 = -6
+ * SLB for Core1 = -6
+ * SLB for Core2 = -6
+ * SLB for Core3 = -6
+ * hispeed load = 95
+ * hispeed freq = 1036 */
+ int res[] = {
+ 0x41820000, 0xa, 0x40c68100, 0xfffffffa, 0x40c68110,
+ 0xfffffffa, 0x40c68120, 0xfffffffa, 0x40c68130, 0xfffffffa,
+ 0x41440100, 0x5f, 0x4143c100, 0x40c,
+ };
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
camera_hint_ref_count++;
if (camera_hint_ref_count == 1) {
if (!video_encode_hint_sent) {
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, num_resources);
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ num_resources);
video_encode_hint_sent = 1;
}
}
- }
- else {
+ } else {
/* sample_ms = 10mS */
- int res[] = {0x41820000, 0xa,
- };
+ int res[] = {
+ 0x41820000,
+ 0xa,
+ };
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
camera_hint_ref_count++;
if (camera_hint_ref_count == 1) {
if (!video_encode_hint_sent) {
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, num_resources);
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ num_resources);
video_encode_hint_sent = 1;
}
}
}
- }
- else if ((strncmp(governor, INTERACTIVE_GOVERNOR,
- strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ } else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
/* Sched_load and migration_notification disable
- * timer rate - 40mS*/
- int res[] = {0x41430000, 0x1,
- 0x41434000, 0x1,
- 0x41424000, 0x28,
- };
+ * timer rate - 40mS*/
+ int res[] = {
+ 0x41430000, 0x1, 0x41434000, 0x1, 0x41424000, 0x28,
+ };
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = sizeof(res)/sizeof(res[0]);
+ num_resources = sizeof(res) / sizeof(res[0]);
camera_hint_ref_count++;
if (camera_hint_ref_count == 1) {
if (!video_encode_hint_sent) {
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, num_resources);
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ num_resources);
video_encode_hint_sent = 1;
}
- }
+ }
}
} else if (video_encode_metadata.state == 0) {
- if (((strncmp(governor, INTERACTIVE_GOVERNOR,
- strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) ||
- ((strncmp(governor, SCHEDUTIL_GOVERNOR,
- strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(SCHEDUTIL_GOVERNOR)))) {
+ if (((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) ||
+ ((strncmp(governor, SCHEDUTIL_GOVERNOR, strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
+ (strlen(governor) == strlen(SCHEDUTIL_GOVERNOR)))) {
camera_hint_ref_count--;
if (!camera_hint_ref_count) {
undo_hint_action(video_encode_metadata.hint_id);
video_encode_hint_sent = 0;
}
- return ;
+ return;
}
}
return;
}
-
-
diff --git a/power-8974.c b/power-8974.c
index 152081a..9aa560b 100644
--- a/power-8974.c
+++ b/power-8974.c
@@ -28,32 +28,31 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_hint_sent;
static int display_hint2_sent;
static int first_display_off_hint;
extern int display_boost;
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
@@ -81,12 +80,13 @@ int set_interactive_override(int on)
}
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
- int resource_values[] = {MS_500, SYNC_FREQ_600, OPTIMAL_FREQ_600, THREAD_MIGRATION_SYNC_OFF};
+ (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
+ int resource_values[] = {MS_500, SYNC_FREQ_600, OPTIMAL_FREQ_600,
+ THREAD_MIGRATION_SYNC_OFF};
if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
display_hint_sent = 1;
}
@@ -96,13 +96,13 @@ int set_interactive_override(int on)
/* Display on */
if (display_boost && display_hint2_sent) {
int resource_values2[] = {CPUS_ONLINE_MIN_2};
- perform_hint_action(DISPLAY_STATE_HINT_ID_2,
- resource_values2, sizeof(resource_values2)/sizeof(resource_values2[0]));
+ perform_hint_action(DISPLAY_STATE_HINT_ID_2, resource_values2,
+ sizeof(resource_values2) / sizeof(resource_values2[0]));
display_hint2_sent = 0;
}
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
+ (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
undo_hint_action(DISPLAY_STATE_HINT_ID);
display_hint_sent = 0;
diff --git a/power-8992.c b/power-8992.c
index 4fe15a4..3a6c5d4 100644
--- a/power-8992.c
+++ b/power-8992.c
@@ -28,29 +28,28 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_hint_sent;
-static int process_video_encode_hint(void *metadata)
-{
+static int process_video_encode_hint(void* metadata) {
char governor[80];
struct video_encode_metadata_t video_encode_metadata;
@@ -66,8 +65,7 @@ static int process_video_encode_hint(void *metadata)
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
if (metadata) {
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return HINT_NONE;
}
@@ -77,7 +75,7 @@ static int process_video_encode_hint(void *metadata)
if (video_encode_metadata.state == 1) {
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
/* sched and cpufreq params
* hispeed freq - 768 MHz
* target load - 90
@@ -86,13 +84,13 @@ static int process_video_encode_hint(void *metadata)
*/
int resource_values[] = {0x2C07, 0x2F5A, 0x2704, 0x4032};
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
return HINT_HANDLED;
}
} else if (video_encode_metadata.state == 0) {
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
undo_hint_action(video_encode_metadata.hint_id);
return HINT_HANDLED;
}
@@ -100,10 +98,9 @@ static int process_video_encode_hint(void *metadata)
return HINT_NONE;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
+int power_hint_override(power_hint_t hint, void* data) {
int ret_val = HINT_NONE;
- switch(hint) {
+ switch (hint) {
case POWER_HINT_VIDEO_ENCODE:
ret_val = process_video_encode_hint(data);
break;
@@ -113,8 +110,7 @@ int power_hint_override(power_hint_t hint, void *data)
return ret_val;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
@@ -129,8 +125,8 @@ int set_interactive_override(int on)
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {0x777}; /* 4+0 core config in display off */
if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
display_hint_sent = 1;
return HINT_HANDLED;
}
diff --git a/power-8994.c b/power-8994.c
index 07ed174..7ad7d17 100644
--- a/power-8994.c
+++ b/power-8994.c
@@ -28,29 +28,28 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_hint_sent;
-static int process_video_encode_hint(void *metadata)
-{
+static int process_video_encode_hint(void* metadata) {
char governor[80];
struct video_encode_metadata_t video_encode_metadata;
@@ -66,8 +65,7 @@ static int process_video_encode_hint(void *metadata)
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
if (metadata) {
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return HINT_NONE;
}
@@ -77,7 +75,7 @@ static int process_video_encode_hint(void *metadata)
if (video_encode_metadata.state == 1) {
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
/* sched and cpufreq params
* hispeed freq - 768 MHz
* target load - 90
@@ -86,13 +84,13 @@ static int process_video_encode_hint(void *metadata)
*/
int resource_values[] = {0x2C07, 0x2F5A, 0x2704, 0x4032};
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
return HINT_HANDLED;
}
} else if (video_encode_metadata.state == 0) {
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
undo_hint_action(video_encode_metadata.hint_id);
return HINT_HANDLED;
}
@@ -100,10 +98,9 @@ static int process_video_encode_hint(void *metadata)
return HINT_NONE;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
+int power_hint_override(power_hint_t hint, void* data) {
int ret_val = HINT_NONE;
- switch(hint) {
+ switch (hint) {
case POWER_HINT_VIDEO_ENCODE:
ret_val = process_video_encode_hint(data);
break;
@@ -113,8 +110,7 @@ int power_hint_override(power_hint_t hint, void *data)
return ret_val;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
@@ -129,8 +125,8 @@ int set_interactive_override(int on)
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {0x777}; /* 4+0 core config in display off */
if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
display_hint_sent = 1;
return HINT_HANDLED;
}
diff --git a/power-8996.c b/power-8996.c
index 94bb1cd..440e9be 100644
--- a/power-8996.c
+++ b/power-8996.c
@@ -28,30 +28,29 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static int display_hint_sent;
static int camera_hint_ref_count;
-static int process_video_encode_hint(void *metadata)
-{
+static int process_video_encode_hint(void* metadata) {
char governor[80];
struct video_encode_metadata_t video_encode_metadata;
@@ -67,8 +66,7 @@ static int process_video_encode_hint(void *metadata)
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
if (metadata) {
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return HINT_NONE;
}
@@ -78,7 +76,7 @@ static int process_video_encode_hint(void *metadata)
if (video_encode_metadata.state == 1) {
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
/* 1. cpufreq params
* -above_hispeed_delay for LVT - 40ms
* -go hispeed load for LVT - 95
@@ -96,21 +94,22 @@ static int process_video_encode_hint(void *metadata)
* -sample_ms of 10 ms
* -sLVT hispeed freq to 806MHz
*/
- int resource_values[] = {0x41400000, 0x4, 0x41410000, 0x5F, 0x41414000, 0x326,
- 0x41420000, 0x5A, 0x41400100, 0x4, 0x41410100, 0x5F, 0x41414100, 0x22C, 0x41420100, 0x5A,
- 0x41810000, 0x9C4, 0x41814000, 0x32, 0x4180C000, 0x0, 0x41820000, 0xA};
+ int resource_values[] = {0x41400000, 0x4, 0x41410000, 0x5F, 0x41414000, 0x326,
+ 0x41420000, 0x5A, 0x41400100, 0x4, 0x41410100, 0x5F,
+ 0x41414100, 0x22C, 0x41420100, 0x5A, 0x41810000, 0x9C4,
+ 0x41814000, 0x32, 0x4180C000, 0x0, 0x41820000, 0xA};
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]));
+ perform_hint_action(video_encode_metadata.hint_id, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
}
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))) {
+ (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
camera_hint_ref_count--;
if (!camera_hint_ref_count) {
undo_hint_action(video_encode_metadata.hint_id);
@@ -123,10 +122,9 @@ static int process_video_encode_hint(void *metadata)
return HINT_NONE;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
+int power_hint_override(power_hint_t hint, void* data) {
int ret_val = HINT_NONE;
- switch(hint) {
+ switch (hint) {
case POWER_HINT_VIDEO_ENCODE:
ret_val = process_video_encode_hint(data);
break;
@@ -136,8 +134,7 @@ int power_hint_override(power_hint_t hint, void *data)
return ret_val;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
return HINT_HANDLED; /* Don't excecute this code path, not in use */
char governor[80];
@@ -153,8 +150,8 @@ int set_interactive_override(int on)
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
int resource_values[] = {}; /* dummy node */
if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
+ perform_hint_action(DISPLAY_STATE_HINT_ID, resource_values,
+ sizeof(resource_values) / sizeof(resource_values[0]));
display_hint_sent = 1;
ALOGI("Display Off hint start");
return HINT_HANDLED;
diff --git a/power-8998.c b/power-8998.c
index 913c764..e786f5c 100644
--- a/power-8998.c
+++ b/power-8998.c
@@ -28,51 +28,51 @@
*/
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
-#include "metadata-defs.h"
#include "hint-data.h"
+#include "metadata-defs.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
-#define CHECK_HANDLE(x) ((x)>0)
-#define NUM_PERF_MODES 3
+#define CHECK_HANDLE(x) ((x) > 0)
+#define NUM_PERF_MODES 3
typedef enum {
- NORMAL_MODE = 0,
- SUSTAINED_MODE = 1,
- VR_MODE = 2,
- VR_SUSTAINED_MODE = (SUSTAINED_MODE|VR_MODE),
- INVALID_MODE = 0xFF
-}perf_mode_type_t;
+ NORMAL_MODE = 0,
+ SUSTAINED_MODE = 1,
+ VR_MODE = 2,
+ VR_SUSTAINED_MODE = (SUSTAINED_MODE | VR_MODE),
+ INVALID_MODE = 0xFF
+} perf_mode_type_t;
typedef struct perf_mode {
perf_mode_type_t type;
int perf_hint_id;
-}perf_mode_t;
+} perf_mode_t;
-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 } };
+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 int current_mode = NORMAL_MODE;
-static inline int get_perfd_hint_id(perf_mode_type_t type) {
+static inline int get_perfd_hint_id(perf_mode_type_t type) {
int i;
- for(i=0; i<NUM_PERF_MODES; i++) {
+ for (i = 0; i < NUM_PERF_MODES; i++) {
if (perf_modes[i].type == type) {
ALOGD("Hint id is 0x%x for mode 0x%x", perf_modes[i].perf_hint_id, type);
return perf_modes[i].perf_hint_id;
@@ -83,7 +83,6 @@ static inline int get_perfd_hint_id(perf_mode_type_t type) {
}
static int switch_mode(perf_mode_type_t mode) {
-
int hint_id = 0;
static int perfd_mode_handle = -1;
@@ -95,7 +94,7 @@ static int switch_mode(perf_mode_type_t mode) {
}
// switch to a perf mode
hint_id = get_perfd_hint_id(mode);
- if(hint_id != 0) {
+ if (hint_id != 0) {
perfd_mode_handle = perf_hint_enable(hint_id, 0);
if (!CHECK_HANDLE(perfd_mode_handle)) {
ALOGE("Failed perf_hint_interaction for mode: 0x%x", mode);
@@ -106,33 +105,32 @@ static int switch_mode(perf_mode_type_t mode) {
return 0;
}
-static int process_perf_hint(void *data, perf_mode_type_t mode) {
-
+static int process_perf_hint(void* data, perf_mode_type_t mode) {
// enable
- if (data){
+ if (data) {
ALOGI("Enable request for mode: 0x%x", mode);
// check if mode is current mode
- if ( current_mode & mode ) {
+ if (current_mode & mode) {
ALOGD("Mode 0x%x already enabled", mode);
return HINT_HANDLED;
}
// enable requested mode
- if ( 0 != switch_mode(current_mode | mode)) {
+ if (0 != switch_mode(current_mode | mode)) {
ALOGE("Couldn't enable mode 0x%x", mode);
return HINT_NONE;
}
current_mode |= mode;
ALOGI("Current mode is 0x%x", current_mode);
- // disable
+ // disable
} else {
ALOGI("Disable request for mode: 0x%x", mode);
// check if mode is enabled
- if ( !(current_mode & mode) ) {
+ if (!(current_mode & mode)) {
ALOGD("Mode 0x%x already disabled", mode);
return HINT_HANDLED;
}
- //disable requested mode
- if ( 0 != switch_mode(current_mode & ~mode)) {
+ // disable requested mode
+ if (0 != switch_mode(current_mode & ~mode)) {
ALOGE("Couldn't disable mode 0x%x", mode);
return HINT_NONE;
}
@@ -143,14 +141,12 @@ static int process_perf_hint(void *data, perf_mode_type_t mode) {
return HINT_HANDLED;
}
-static int process_video_encode_hint(void *metadata)
-{
+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;
+ if (!metadata) return HINT_NONE;
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
@@ -162,20 +158,18 @@ static int process_video_encode_hint(void *metadata)
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
video_encode_metadata.state = -1;
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
- ALOGE("Error occurred while parsing metadata.");
- return HINT_NONE;
+ if (parse_video_encode_metadata((char*)metadata, &video_encode_metadata) == -1) {
+ ALOGE("Error occurred while parsing metadata.");
+ return HINT_NONE;
}
if (video_encode_metadata.state == 1) {
- if (is_interactive_governor(governor)) {
- video_encode_handle = perf_hint_enable(
- VIDEO_ENCODE_HINT, 0);
- return HINT_HANDLED;
+ if (is_interactive_governor(governor)) {
+ 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)) {
+ if (is_interactive_governor(governor)) {
release_request(video_encode_handle);
ALOGI("Video Encode hint stop");
return HINT_HANDLED;
@@ -184,10 +178,9 @@ static int process_video_encode_hint(void *metadata)
return HINT_NONE;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
+int power_hint_override(power_hint_t hint, void* data) {
int ret_val = HINT_NONE;
- switch(hint) {
+ switch (hint) {
case POWER_HINT_VIDEO_ENCODE:
ret_val = process_video_encode_hint(data);
break;
@@ -208,7 +201,6 @@ int power_hint_override(power_hint_t hint, void *data)
return ret_val;
}
-int set_interactive_override(int UNUSED(on))
-{
+int set_interactive_override(int UNUSED(on)) {
return HINT_HANDLED; /* Don't excecute this code path, not in use */
}
diff --git a/power-common.c b/power-common.c
index 30ea135..6719158 100644
--- a/power-common.c
+++ b/power-common.c
@@ -29,75 +29,68 @@
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
-#include "utils.h"
#include "hint-data.h"
#include "performance.h"
#include "power-common.h"
#include "power-feature.h"
+#include "utils.h"
static struct hint_handles handles[NUM_HINTS];
-void power_init()
-{
+void power_init() {
ALOGI("Initing");
- for (int i=0; i<NUM_HINTS; i++) {
- handles[i].handle = 0;
- handles[i].ref_count = 0;
+ for (int i = 0; i < NUM_HINTS; i++) {
+ handles[i].handle = 0;
+ handles[i].ref_count = 0;
}
}
-int __attribute__ ((weak)) power_hint_override(power_hint_t UNUSED(hint),
- void *UNUSED(data))
-{
+int __attribute__((weak)) power_hint_override(power_hint_t UNUSED(hint), void* UNUSED(data)) {
return HINT_NONE;
}
/* Declare function before use */
void interaction(int duration, int num_args, int opt_list[]);
-void power_hint(power_hint_t hint, void *data)
-{
+void power_hint(power_hint_t hint, void* data) {
/* Check if this hint has been overridden. */
if (power_hint_override(hint, data) == HINT_HANDLED) {
/* The power_hint has been handled. We can skip the rest. */
return;
}
- switch(hint) {
+ switch (hint) {
case POWER_HINT_VR_MODE:
ALOGI("VR mode power hint not handled in power_hint_override");
- break;
- case POWER_HINT_INTERACTION:
- {
+ break;
+ case POWER_HINT_INTERACTION: {
int resources[] = {0x702, 0x20F, 0x30F};
int duration = 3000;
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
- }
- break;
- //fall through below, hints will fail if not defined in powerhint.xml
+ interaction(duration, sizeof(resources) / sizeof(resources[0]), resources);
+ } break;
+ // fall through below, hints will fail if not defined in powerhint.xml
case POWER_HINT_SUSTAINED_PERFORMANCE:
case POWER_HINT_VIDEO_ENCODE:
if (data) {
if (handles[hint].ref_count == 0)
handles[hint].handle = perf_hint_enable((AOSP_DELTA + hint), 0);
- if (handles[hint].handle > 0)
- handles[hint].ref_count++;
+ if (handles[hint].handle > 0) handles[hint].ref_count++;
} else {
if (handles[hint].handle > 0) {
if (--handles[hint].ref_count == 0) {
@@ -108,14 +101,13 @@ void power_hint(power_hint_t hint, void *data)
ALOGE("Lock for hint: %X was not acquired, cannot be released", hint);
}
}
- break;
+ break;
default:
- break;
+ break;
}
}
-int __attribute__ ((weak)) set_interactive_override(int UNUSED(on))
-{
+int __attribute__((weak)) set_interactive_override(int UNUSED(on)) {
return HINT_NONE;
}
@@ -123,8 +115,7 @@ int __attribute__ ((weak)) set_interactive_override(int UNUSED(on))
extern void power_set_interactive_ext(int on);
#endif
-void set_interactive(int on)
-{
+void set_interactive(int on) {
if (!on) {
/* Send Display OFF hint to perf HAL */
perf_hint_enable(VENDOR_HINT_DISPLAY_OFF, 0);
@@ -144,6 +135,5 @@ void set_interactive(int on)
ALOGI("Got set_interactive hint");
}
-void __attribute__((weak)) set_device_specific_feature(feature_t UNUSED(feature), int UNUSED(state))
-{
-}
+void __attribute__((weak))
+set_device_specific_feature(feature_t UNUSED(feature), int UNUSED(state)) {}
diff --git a/power-common.h b/power-common.h
index f586f09..0ec18ff 100644
--- a/power-common.h
+++ b/power-common.h
@@ -51,21 +51,16 @@ extern "C" {
#include <hardware/power.h>
-enum CPU_GOV_CHECK {
- CPU0 = 0,
- CPU1 = 1,
- CPU2 = 2,
- CPU3 = 3
-};
+enum CPU_GOV_CHECK { CPU0 = 0, CPU1 = 1, CPU2 = 2, CPU3 = 3 };
void power_init(void);
-void power_hint(power_hint_t hint, void *data);
+void power_hint(power_hint_t hint, void* data);
void set_interactive(int on);
-#define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
+#define UNUSED(x) UNUSED_##x __attribute__((__unused__))
#ifdef __cplusplus
}
#endif
-#endif //__POWER_COMMON_H___
+#endif //__POWER_COMMON_H___
diff --git a/power-msmnile.c b/power-msmnile.c
index 7a64b08..3c22138 100644
--- a/power-msmnile.c
+++ b/power-msmnile.c
@@ -27,82 +27,73 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#define LOG_NIDEBUG 0
+#include <dlfcn.h>
#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
-#include <dlfcn.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <log/log.h>
#include "power-common.h"
static int display_fd;
#define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr"
-int set_interactive_override(int on)
-{
- static const char *display_on = "1";
- static const char *display_off = "0";
+int set_interactive_override(int on) {
+ static const char* display_on = "1";
+ static const char* display_off = "0";
char err_buf[80];
static int init_interactive_hint = 0;
static int set_i_count = 0;
int rc = 0;
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
- if (init_interactive_hint == 0)
- {
- //First time the display is turned off
+ if (init_interactive_hint == 0) {
+ // First time the display is turned off
display_fd = TEMP_FAILURE_RETRY(open(SYS_DISPLAY_PWR, O_RDWR));
if (display_fd < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
+ strerror_r(errno, err_buf, sizeof(err_buf));
ALOGE("Error opening %s: %s\n", SYS_DISPLAY_PWR, err_buf);
- }
- else
+ } else
init_interactive_hint = 1;
- }
- else
- if (!on ) {
- /* Display off. */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
- }
+ } else if (!on) {
+ /* Display off. */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
}
- else {
- /* Display on */
- rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
- if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
- ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
- }
+ } else {
+ /* Display on */
+ rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
+ if (rc < 0) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
}
+ }
return HINT_HANDLED;
}
void interaction(int duration, int num_args, int opt_list[]);
-int power_hint_override(power_hint_t hint, void *data)
-{
+int power_hint_override(power_hint_t hint, void* data) {
int ret_val = HINT_NONE;
- switch(hint) {
- case POWER_HINT_INTERACTION:
- {
+ switch (hint) {
+ case POWER_HINT_INTERACTION: {
int resources[] = {0x40800100, 0x514};
int duration = 100;
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+ interaction(duration, sizeof(resources) / sizeof(resources[0]), resources);
ret_val = HINT_HANDLED;
}
default:
diff --git a/service.cpp b/service.cpp
index f36141e..c8100b9 100644
--- a/service.cpp
+++ b/service.cpp
@@ -29,14 +29,14 @@
#define LOG_TAG "android.hardware.power@1.2-service-qti"
-#include <log/log.h>
-#include <hidl/HidlTransportSupport.h>
#include <hardware/power.h>
+#include <hidl/HidlTransportSupport.h>
+#include <log/log.h>
#include "Power.h"
+using android::OK;
using android::sp;
using android::status_t;
-using android::OK;
// libhwbinder:
using android::hardware::configureRpcThreadpool;
@@ -47,7 +47,6 @@ using android::hardware::power::V1_2::IPower;
using android::hardware::power::V1_2::implementation::Power;
int main() {
-
status_t status;
android::sp<IPower> service = nullptr;
@@ -70,7 +69,7 @@ int main() {
ALOGI("Power Service is ready");
joinRpcThreadpool();
- //Should not pass this line
+ // Should not pass this line
shutdown:
// In normal operation, we don't expect the thread pool to exit
@@ -78,4 +77,3 @@ shutdown:
ALOGE("Power Service is shutting down");
return 1;
}
-
diff --git a/utils.c b/utils.c
index 209efc8..7f6229b 100644
--- a/utils.c
+++ b/utils.c
@@ -29,53 +29,47 @@
#define LOG_NIDEBUG 0
#include <dlfcn.h>
-#include <fcntl.h>
#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include "utils.h"
-#include "list.h"
#include "hint-data.h"
+#include "list.h"
#include "power-common.h"
+#include "utils.h"
#define LOG_TAG "QTI PowerHAL"
#include <log/log.h>
-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/cpu2/cpufreq/scaling_governor",
- "sys/devices/system/cpu/cpu3/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/cpu2/cpufreq/scaling_governor",
+ "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)(int handle, int duration,
- int list[], int numArgs);
+static void* qcopt_handle;
+static int (*perf_lock_acq)(int handle, int duration, int list[], int numArgs);
static int (*perf_lock_rel)(int handle);
-static int (*perf_hint)(int, const char *, int, int);
+static int (*perf_hint)(int, const char*, int, int);
static struct list_node active_hint_list_head;
-const char *pkg = "QTI PowerHAL";
+const char* pkg = "QTI PowerHAL";
-static void *get_qcopt_handle()
-{
- void *handle = NULL;
+static void* get_qcopt_handle() {
+ void* handle = NULL;
dlerror();
handle = dlopen(PERF_HAL_PATH, RTLD_NOW);
if (!handle) {
- ALOGE("Unable to open %s: %s\n", PERF_HAL_PATH,
- dlerror());
+ ALOGE("Unable to open %s: %s\n", PERF_HAL_PATH, dlerror());
}
return handle;
}
-static void __attribute__ ((constructor)) initialize(void)
-{
+static void __attribute__((constructor)) initialize(void) {
qcopt_handle = get_qcopt_handle();
if (!qcopt_handle) {
@@ -105,16 +99,13 @@ static void __attribute__ ((constructor)) initialize(void)
}
}
-static void __attribute__ ((destructor)) cleanup(void)
-{
+static void __attribute__((destructor)) cleanup(void) {
if (qcopt_handle) {
- if (dlclose(qcopt_handle))
- ALOGE("Error occurred while closing qc-opt library.");
+ if (dlclose(qcopt_handle)) ALOGE("Error occurred while closing qc-opt library.");
}
}
-int sysfs_read(char *path, char *s, int num_bytes)
-{
+int sysfs_read(char* path, char* s, int num_bytes) {
char buf[80];
int count;
int ret = 0;
@@ -141,8 +132,7 @@ int sysfs_read(char *path, char *s, int num_bytes)
return ret;
}
-int sysfs_write(char *path, char *s)
-{
+int sysfs_write(char* path, char* s) {
char buf[80];
int len;
int ret = 0;
@@ -151,7 +141,7 @@ int sysfs_write(char *path, char *s)
if (fd < 0) {
strerror_r(errno, buf, sizeof(buf));
ALOGE("Error opening %s: %s\n", path, buf);
- return -1 ;
+ return -1;
}
len = write(fd, s, strlen(s));
@@ -167,10 +157,8 @@ int sysfs_write(char *path, char *s)
return ret;
}
-int get_scaling_governor(char governor[], int size)
-{
- if (sysfs_read(SCALING_GOVERNOR_PATH, governor,
- size) == -1) {
+int get_scaling_governor(char governor[], int size) {
+ if (sysfs_read(SCALING_GOVERNOR_PATH, governor, size) == -1) {
// Can't obtain the scaling governor. Return.
return -1;
} else {
@@ -179,18 +167,14 @@ int get_scaling_governor(char governor[], int size)
len--;
- while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r'))
- governor[len--] = '\0';
+ while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r')) governor[len--] = '\0';
}
return 0;
}
-int get_scaling_governor_check_cores(char governor[], int size,int core_num)
-{
-
- if (sysfs_read(scaling_gov_path[core_num], governor,
- size) == -1) {
+int get_scaling_governor_check_cores(char governor[], int size, int core_num) {
+ if (sysfs_read(scaling_gov_path[core_num], governor, size) == -1) {
// Can't obtain the scaling governor. Return.
return -1;
}
@@ -198,99 +182,81 @@ int get_scaling_governor_check_cores(char governor[], int size,int core_num)
// Strip newline at the end.
int len = strlen(governor);
len--;
- while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r'))
- governor[len--] = '\0';
+ while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r')) governor[len--] = '\0';
return 0;
}
int is_interactive_governor(char* governor) {
- if (strncmp(governor, INTERACTIVE_GOVERNOR, (strlen(INTERACTIVE_GOVERNOR)+1)) == 0)
- return 1;
- return 0;
+ if (strncmp(governor, INTERACTIVE_GOVERNOR, (strlen(INTERACTIVE_GOVERNOR) + 1)) == 0) return 1;
+ return 0;
}
#ifndef INTERACTION_BOOST
-void interaction(int UNUSED(duration), int UNUSED(num_args), int UNUSED(opt_list[]))
-{
+void interaction(int UNUSED(duration), int UNUSED(num_args), int UNUSED(opt_list[])) {
#else
-void interaction(int duration, int num_args, int opt_list[])
-{
+void interaction(int duration, int num_args, int opt_list[]) {
static int lock_handle = 0;
- if (duration < 0 || num_args < 1 || opt_list[0] == 0)
- return;
+ if (duration < 0 || num_args < 1 || opt_list[0] == 0) return;
if (qcopt_handle) {
if (perf_lock_acq) {
lock_handle = perf_lock_acq(lock_handle, duration, opt_list, num_args);
- if (lock_handle == -1)
- ALOGE("Failed to acquire lock.");
+ if (lock_handle == -1) ALOGE("Failed to acquire lock.");
}
}
#endif
}
-int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[])
-{
- if (duration < 0 || num_args < 1 || opt_list[0] == 0)
- return 0;
+int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]) {
+ if (duration < 0 || num_args < 1 || opt_list[0] == 0) return 0;
if (qcopt_handle) {
if (perf_lock_acq) {
lock_handle = perf_lock_acq(lock_handle, duration, opt_list, num_args);
- if (lock_handle == -1)
- ALOGE("Failed to acquire lock.");
+ if (lock_handle == -1) ALOGE("Failed to acquire lock.");
}
}
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)
-{
+// 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 (duration < 0) return 0;
if (qcopt_handle) {
if (perf_hint) {
lock_handle = perf_hint(hint_id, pkg, duration, -1);
- if (lock_handle == -1)
- ALOGE("Failed to acquire lock for hint_id: %X.", hint_id);
+ if (lock_handle == -1) ALOGE("Failed to acquire lock for hint_id: %X.", hint_id);
}
}
return lock_handle;
}
-
void release_request(int lock_handle) {
- if (qcopt_handle && perf_lock_rel)
- perf_lock_rel(lock_handle);
+ if (qcopt_handle && perf_lock_rel) perf_lock_rel(lock_handle);
}
-void perform_hint_action(int hint_id, int resource_values[], int num_resources)
-{
+void perform_hint_action(int hint_id, int resource_values[], int num_resources) {
if (qcopt_handle) {
if (perf_lock_acq) {
/* Acquire an indefinite lock for the requested resources. */
- int lock_handle = perf_lock_acq(0, 0, resource_values,
- num_resources);
+ int lock_handle = perf_lock_acq(0, 0, resource_values, num_resources);
if (lock_handle == -1) {
ALOGE("Failed to acquire lock.");
} else {
/* Add this handle to our internal hint-list. */
- struct hint_data *new_hint =
- (struct hint_data *)malloc(sizeof(struct hint_data));
+ struct hint_data* new_hint = (struct hint_data*)malloc(sizeof(struct hint_data));
if (new_hint) {
if (!active_hint_list_head.compare) {
- active_hint_list_head.compare =
- (int (*)(void *, void *))hint_compare;
- active_hint_list_head.dump = (void (*)(void *))hint_dump;
+ active_hint_list_head.compare = (int (*)(void*, void*))hint_compare;
+ active_hint_list_head.dump = (void (*)(void*))hint_dump;
}
new_hint->hint_id = hint_id;
@@ -299,15 +265,13 @@ void perform_hint_action(int hint_id, int resource_values[], int num_resources)
if (add_list_node(&active_hint_list_head, new_hint) == NULL) {
free(new_hint);
/* Can't keep track of this lock. Release it. */
- if (perf_lock_rel)
- perf_lock_rel(lock_handle);
+ if (perf_lock_rel) perf_lock_rel(lock_handle);
ALOGE("Failed to process hint.");
}
} else {
/* Can't keep track of this lock. Release it. */
- if (perf_lock_rel)
- perf_lock_rel(lock_handle);
+ if (perf_lock_rel) perf_lock_rel(lock_handle);
ALOGE("Failed to process hint.");
}
@@ -316,23 +280,18 @@ void perform_hint_action(int hint_id, int resource_values[], int num_resources)
}
}
-void undo_hint_action(int hint_id)
-{
+void undo_hint_action(int hint_id) {
if (qcopt_handle) {
if (perf_lock_rel) {
/* Get hint-data associated with this hint-id */
- struct list_node *found_node;
- struct hint_data temp_hint_data = {
- .hint_id = hint_id
- };
+ struct list_node* found_node;
+ struct hint_data temp_hint_data = {.hint_id = hint_id};
- found_node = find_node(&active_hint_list_head,
- &temp_hint_data);
+ found_node = find_node(&active_hint_list_head, &temp_hint_data);
if (found_node) {
/* Release this lock. */
- struct hint_data *found_hint_data =
- (struct hint_data *)(found_node->data);
+ struct hint_data* found_hint_data = (struct hint_data*)(found_node->data);
if (found_hint_data) {
if (perf_lock_rel(found_hint_data->perflock_handle) == -1)
@@ -356,8 +315,7 @@ void undo_hint_action(int hint_id)
* Used to release initial lock holding
* two cores online when the display is on
*/
-void undo_initial_hint_action()
-{
+void undo_initial_hint_action() {
if (qcopt_handle) {
if (perf_lock_rel) {
perf_lock_rel(1);
diff --git a/utils.h b/utils.h
index 7f8b3dd..c86e15c 100644
--- a/utils.h
+++ b/utils.h
@@ -29,18 +29,17 @@
#include <cutils/properties.h>
-int sysfs_read(char *path, char *s, int num_bytes);
-int sysfs_write(char *path, char *s);
+int sysfs_read(char* path, char* s, int num_bytes);
+int sysfs_write(char* path, char* s);
int get_scaling_governor(char governor[], int size);
-int get_scaling_governor_check_cores(char governor[], int size,int core_num);
+int get_scaling_governor_check_cores(char governor[], int size, int core_num);
int is_interactive_governor(char*);
void vote_ondemand_io_busy_off();
void unvote_ondemand_io_busy_off();
void vote_ondemand_sdf_low();
void unvote_ondemand_sdf_low();
-void perform_hint_action(int hint_id, int resource_values[],
- int num_resources);
+void perform_hint_action(int hint_id, int resource_values[], int num_resources);
void undo_hint_action(int hint_id);
void undo_initial_hint_action();
void release_request(int lock_handle);