power: clang-format
* Using AOSP interface .clang-format
* Clean Android.mk while we are at it
Change-Id: I630f72e3dffb676ca1930e72945e897f62103ada
Signed-off-by: Arian <arian.kulmer@web.de>
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 521574b..9db72de 100644
--- a/Android.mk
+++ b/Android.mk
@@ -2,17 +2,32 @@
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
-# KEYSTONE(I1132378f14428bf511f3cea4f419e90a6e89f823,b/181709127)
-LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libbase libutils libbinder_ndk android.hardware.power-V3-ndk
-LOCAL_HEADER_LIBRARIES += libutils_headers
-LOCAL_HEADER_LIBRARIES += libhardware_headers
-LOCAL_SRC_FILES := power-common.c metadata-parser.c utils.c list.c hint-data.c Power.cpp main.cpp PowerHintSession.cpp
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libcutils \
+ libdl \
+ libbase \
+ libutils \
+ libbinder_ndk \
+ android.hardware.power-V3-ndk
+
+LOCAL_HEADER_LIBRARIES := \
+ libutils_headers \
+ libhardware_headers
+
+LOCAL_SRC_FILES := \
+ power-common.c \
+ metadata-parser.c \
+ utils.c \
+ list.c \
+ hint-data.c \
+ Power.cpp \
+ main.cpp \
+ PowerHintSession.cpp
LOCAL_CFLAGS += -Wall -Wextra -Werror
@@ -53,7 +68,7 @@
LOCAL_SRC_FILES += power-msmnile.c
endif
-endif # End of board specific list
+endif # End of board specific list
ifneq ($(TARGET_POWERHAL_MODE_EXT),)
LOCAL_CFLAGS += -DMODE_EXT
@@ -79,5 +94,6 @@
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
LOCAL_VENDOR_MODULE := true
LOCAL_VINTF_FRAGMENTS := power.xml
+
include $(BUILD_EXECUTABLE)
endif
diff --git a/Power.cpp b/Power.cpp
index 35d49fe..bbdd924 100644
--- a/Power.cpp
+++ b/Power.cpp
@@ -46,9 +46,9 @@
#include <android/binder_process.h>
using ::aidl::android::hardware::power::BnPower;
+using ::aidl::android::hardware::power::Boost;
using ::aidl::android::hardware::power::IPower;
using ::aidl::android::hardware::power::Mode;
-using ::aidl::android::hardware::power::Boost;
using ::ndk::ScopedAStatus;
using ::ndk::SharedRefBase;
@@ -65,7 +65,7 @@
#endif
void setInteractive(bool interactive) {
- set_interactive(interactive ? 1:0);
+ set_interactive(interactive ? 1 : 0);
}
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
@@ -75,7 +75,7 @@
return ndk::ScopedAStatus::ok();
}
#endif
- switch(type){
+ switch (type) {
#ifdef TAP_TO_WAKE_NODE
case Mode::DOUBLE_TAP_TO_WAKE:
::android::base::WriteStringToFile(enabled ? "1" : "0", TAP_TO_WAKE_NODE, true);
@@ -120,7 +120,7 @@
return ndk::ScopedAStatus::ok();
}
#endif
- switch(type){
+ switch (type) {
case Mode::EXPENSIVE_RENDERING:
if (is_expensive_rendering_supported()) {
*_aidl_return = true;
@@ -144,8 +144,7 @@
}
ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
- LOG(INFO) << "Power setBoost: " << static_cast<int32_t>(type)
- << ", duration: " << durationMs;
+ LOG(INFO) << "Power setBoost: " << static_cast<int32_t>(type) << ", duration: " << durationMs;
return ndk::ScopedAStatus::ok();
}
@@ -154,7 +153,9 @@
*_aidl_return = false;
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid, const std::vector<int32_t>& threadIds, int64_t durationNanos,
+ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid,
+ const std::vector<int32_t>& threadIds,
+ int64_t durationNanos,
std::shared_ptr<IPowerHintSession>* _aidl_return) {
LOG(INFO) << "Power createHintSession";
if (threadIds.size() == 0) {
diff --git a/Power.h b/Power.h
index a66f4a2..d349478 100644
--- a/Power.h
+++ b/Power.h
@@ -40,19 +40,17 @@
namespace impl {
class Power : public BnPower {
- public:
- Power() : BnPower(){
- power_init();
- }
- ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
- ndk::ScopedAStatus isModeSupported(Mode type, bool* _aidl_return) override;
- ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
- ndk::ScopedAStatus isBoostSupported(Boost type, bool* _aidl_return) override;
- ndk::ScopedAStatus createHintSession(int32_t tgid, int32_t uid,
- const std::vector<int32_t>& threadIds,
- int64_t durationNanos,
- std::shared_ptr<IPowerHintSession>* _aidl_return) override;
- ndk::ScopedAStatus getHintSessionPreferredRate(int64_t* outNanoseconds) override;
+ public:
+ Power() : BnPower() { power_init(); }
+ ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
+ ndk::ScopedAStatus isModeSupported(Mode type, bool* _aidl_return) override;
+ ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
+ ndk::ScopedAStatus isBoostSupported(Boost type, bool* _aidl_return) override;
+ ndk::ScopedAStatus createHintSession(int32_t tgid, int32_t uid,
+ const std::vector<int32_t>& threadIds,
+ int64_t durationNanos,
+ std::shared_ptr<IPowerHintSession>* _aidl_return) override;
+ ndk::ScopedAStatus getHintSessionPreferredRate(int64_t* outNanoseconds) override;
};
} // namespace impl
diff --git a/PowerHintSession.cpp b/PowerHintSession.cpp
index c466947..6c5e461 100644
--- a/PowerHintSession.cpp
+++ b/PowerHintSession.cpp
@@ -1,33 +1,35 @@
/*
-* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
-* SPDX-License-Identifier: BSD-3-Clause-Clear
-*/
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
#include "PowerHintSession.h"
#include <android-base/logging.h>
#define LOG_TAG "QTI PowerHAL"
-std::shared_ptr<aidl::android::hardware::power::IPowerHintSession> setPowerHintSession(){
- std::shared_ptr<aidl::android::hardware::power::IPowerHintSession> mPowerSession = ndk::SharedRefBase::make<PowerHintSessionImpl>();
+std::shared_ptr<aidl::android::hardware::power::IPowerHintSession> setPowerHintSession() {
+ std::shared_ptr<aidl::android::hardware::power::IPowerHintSession> mPowerSession =
+ ndk::SharedRefBase::make<PowerHintSessionImpl>();
return mPowerSession;
}
-int64_t getSessionPreferredRate(){
+int64_t getSessionPreferredRate() {
return 16666666L;
}
-ndk::ScopedAStatus PowerHintSessionImpl::updateTargetWorkDuration(int64_t in_targetDurationNanos){
- return ndk::ScopedAStatus::ok();
- }
-ndk::ScopedAStatus PowerHintSessionImpl::reportActualWorkDuration(const std::vector<::aidl::android::hardware::power::WorkDuration>& in_durations){
- return ndk::ScopedAStatus::ok();
- }
-ndk::ScopedAStatus PowerHintSessionImpl::pause(){
- return ndk::ScopedAStatus::ok();
- }
-ndk::ScopedAStatus PowerHintSessionImpl::resume(){
- return ndk::ScopedAStatus::ok();
+ndk::ScopedAStatus PowerHintSessionImpl::updateTargetWorkDuration(int64_t in_targetDurationNanos) {
+ return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus PowerHintSessionImpl::close(){
- return ndk::ScopedAStatus::ok();
+ndk::ScopedAStatus PowerHintSessionImpl::reportActualWorkDuration(
+ const std::vector<::aidl::android::hardware::power::WorkDuration>& in_durations) {
+ return ndk::ScopedAStatus::ok();
+}
+ndk::ScopedAStatus PowerHintSessionImpl::pause() {
+ return ndk::ScopedAStatus::ok();
+}
+ndk::ScopedAStatus PowerHintSessionImpl::resume() {
+ return ndk::ScopedAStatus::ok();
+}
+ndk::ScopedAStatus PowerHintSessionImpl::close() {
+ return ndk::ScopedAStatus::ok();
}
diff --git a/PowerHintSession.h b/PowerHintSession.h
index 3491b26..71fa3c5 100644
--- a/PowerHintSession.h
+++ b/PowerHintSession.h
@@ -1,19 +1,19 @@
/*
-* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
-* SPDX-License-Identifier: BSD-3-Clause-Clear
-*/
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
#ifndef __POWERHINTSESSION__
#define __POWERHINTSESSION__
-#include <aidl/android/hardware/power/WorkDuration.h>
#include <aidl/android/hardware/power/BnPowerHintSession.h>
+#include <aidl/android/hardware/power/WorkDuration.h>
std::shared_ptr<aidl::android::hardware::power::IPowerHintSession> setPowerHintSession();
int64_t getSessionPreferredRate();
-class PowerHintSessionImpl : public aidl::android::hardware::power::BnPowerHintSession{
-public:
+class PowerHintSessionImpl : public aidl::android::hardware::power::BnPowerHintSession {
+ public:
ndk::ScopedAStatus updateTargetWorkDuration(int64_t targetDurationNanos) override;
ndk::ScopedAStatus reportActualWorkDuration(
const std::vector<aidl::android::hardware::power::WorkDuration>& durations) override;
diff --git a/hint-data.c b/hint-data.c
index 67da77a..b979693 100644
--- a/hint-data.c
+++ b/hint-data.c
@@ -29,19 +29,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) {
/*ALOGI("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 @@
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 5c90c91..61fa050 100644
--- a/list.c
+++ b/list.c
@@ -31,13 +31,12 @@
#include <stdlib.h>
#include <string.h>
-#include "list.h"
#include <utils/Log.h>
+#include "list.h"
-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;
@@ -59,10 +58,9 @@
/*
* 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;
@@ -92,18 +90,14 @@
return 0;
}
+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 acd02fe..db666f2 100644
--- a/list.h
+++ b/list.h
@@ -28,12 +28,12 @@
*/
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);
};
-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);
-struct list_node *find_node(struct list_node *head, void *comparison_data);
+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);
+struct list_node* find_node(struct list_node* head, void* comparison_data);
diff --git a/main.cpp b/main.cpp
index 5909b71..386cca3 100644
--- a/main.cpp
+++ b/main.cpp
@@ -40,14 +40,15 @@
std::shared_ptr<Power> vib = ndk::SharedRefBase::make<Power>();
const std::string instance = std::string() + Power::descriptor + "/default";
LOG(INFO) << "Instance " << instance;
- if(vib){
- binder_status_t status = AServiceManager_addService(vib->asBinder().get(), instance.c_str());
+ if (vib) {
+ binder_status_t status =
+ AServiceManager_addService(vib->asBinder().get(), instance.c_str());
LOG(INFO) << "Status " << status;
- if(status != STATUS_OK){
+ if (status != STATUS_OK) {
LOG(ERROR) << "Could not register" << instance;
}
}
ABinderProcess_joinThreadPool();
return 1; // should not reach
-}
\ No newline at end of file
+}
diff --git a/metadata-defs.h b/metadata-defs.h
index c464900..7160af4 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 @@
int state;
};
-int parse_metadata(char *metadata, char **metadata_saveptr,
- char *attribute, int attribute_size, char *value, 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, int attribute_size,
+ char* value, 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 c9122a4..30efee8 100644
--- a/metadata-parser.c
+++ b/metadata-parser.c
@@ -28,55 +28,46 @@
*/
#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, int attribute_size, char *value, int value_size)
-{
- char *attribute_string;
- char *attribute_value_delim;
+int parse_metadata(char* metadata, char** metadata_saveptr, char* attribute, int attribute_size,
+ char* value, 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) {
- bytes_to_copy = MIN((attribute_value_delim - attribute_string),
- attribute_size - 1);
+ if ((attribute_value_delim = strchr(attribute_string, ATTRIBUTE_VALUE_DELIM)) != NULL) {
+ bytes_to_copy = MIN((attribute_value_delim - attribute_string), attribute_size - 1);
/* Replace strncpy with strlcpy
* Add +1 to bytes_to_copy as strlcpy copies size-1 bytes */
- strlcpy(attribute, attribute_string,
- bytes_to_copy+1);
+ strlcpy(attribute, attribute_string, bytes_to_copy + 1);
- bytes_to_copy = MIN(strlen(attribute_string) - strlen(attribute) - 1,
- value_size - 1);
+ bytes_to_copy = MIN(strlen(attribute_string) - strlen(attribute) - 1, value_size - 1);
/* Replace strncpy with strlcpy
* Add +1 to bytes_to_copy as strlcpy copies size-1 bytes */
- strlcpy(value, attribute_value_delim + 1,
- bytes_to_copy+1);
+ strlcpy(value, attribute_value_delim + 1, bytes_to_copy + 1);
}
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) {
@@ -94,21 +85,19 @@
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) {
@@ -126,8 +115,7 @@
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 daf8a01..a2c0b6b 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,
diff --git a/power-660.c b/power-660.c
index 50c3eeb..2db4503 100644
--- a/power-660.c
+++ b/power-660.c
@@ -29,38 +29,37 @@
#define LOG_NIDEBUG 0
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/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 display_hint_sent;
static int video_encode_hint_sent;
-static void process_video_encode_hint(void *metadata);
+static void process_video_encode_hint(void* metadata);
/* Returns true is target is SDM630/SDM455 else false*/
-static bool is_target_SDM630()
-{
+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) {
@@ -78,14 +77,11 @@
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;
}
@@ -95,18 +91,17 @@
return HINT_NONE;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
int resource_values[20];
int num_resources;
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;
}
@@ -116,66 +111,55 @@
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
+ 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]);
+ }
+ /*
+ 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
- */
- if(is_target_SDM630()){
- int res[] = { 0x41414000, 0x459,
- 0x41410000, 0x5F,
- 0x41400000, 0x4,
- 0x41820000, 0xA };
+ - 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]);
}
- /*
- 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]);
-
+ 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;
+ }
+ }
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;
@@ -183,19 +167,15 @@
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. */
@@ -204,8 +184,7 @@
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;
}
@@ -214,28 +193,23 @@
}
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]);
}
/*
@@ -246,23 +220,18 @@
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]);
}
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))) {
undo_hint_action(video_encode_metadata.hint_id);
video_encode_hint_sent = 0;
@@ -270,5 +239,3 @@
}
return;
}
-
-
diff --git a/power-710.c b/power-710.c
index ab824af..00fdd86 100644
--- a/power-710.c
+++ b/power-710.c
@@ -26,37 +26,31 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/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"
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
static int set_i_count = 0;
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
-
return HINT_HANDLED; /* Don't excecute this code path, not in use */
}
-
-
diff --git a/power-845.c b/power-845.c
index 82a7f54..a2f92fa 100644
--- a/power-845.c
+++ b/power-845.c
@@ -27,54 +27,53 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#define LOG_NIDEBUG 0
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/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;
@@ -85,7 +84,6 @@
}
static int switch_mode(perf_mode_type_t mode) {
-
int hint_id = 0;
static int perfd_mode_handle = -1;
@@ -97,7 +95,7 @@
}
// 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);
@@ -108,33 +106,32 @@
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;
}
@@ -145,14 +142,12 @@
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.");
@@ -164,21 +159,19 @@
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;
@@ -190,10 +183,9 @@
/* 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;
@@ -203,27 +195,23 @@
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)
-{
+int set_interactive_override(int on) {
static int set_i_count = 0;
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
-
return HINT_HANDLED; /* Don't excecute this code path, not in use */
}
diff --git a/power-8937.c b/power-8937.c
index d82ac9e..9558014 100644
--- a/power-8937.c
+++ b/power-8937.c
@@ -29,31 +29,31 @@
#define LOG_NIDEBUG 0
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/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 display_hint_sent;
static int video_encode_hint_sent;
-static void process_video_encode_hint(void *metadata);
+static void process_video_encode_hint(void* metadata);
static bool is_target_SDM439() /* Returns value=1 if target is Hathi else value 0 */
{
@@ -76,14 +76,11 @@
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;
}
@@ -93,17 +90,16 @@
return HINT_NONE;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
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;
}
@@ -113,38 +109,36 @@
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))) {
+ 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;
+ }
+ }
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- }
- }
-
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
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;
@@ -152,19 +146,15 @@
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. */
@@ -173,8 +163,7 @@
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;
}
@@ -183,80 +172,64 @@
}
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]);
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]);
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]);
- perform_hint_action(video_encode_metadata.hint_id,
- resource_values,num_resources);
+ num_resources = sizeof(res) / sizeof(res[0]);
+ 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)))) {
undo_hint_action(video_encode_metadata.hint_id);
video_encode_hint_sent = 0;
}
}
return;
}
-
diff --git a/power-8953.c b/power-8953.c
index 33c572d..405eaf5 100644
--- a/power-8953.c
+++ b/power-8953.c
@@ -29,32 +29,32 @@
#define LOG_NIDEBUG 0
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/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 display_hint_sent;
static int video_encode_hint_sent;
-static void process_video_encode_hint(void *metadata);
+static void process_video_encode_hint(void* metadata);
static bool is_target_SDM632() /* Returns value=632 if target is SDM632 else value 0 */
{
@@ -77,14 +77,11 @@
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;
}
@@ -94,17 +91,16 @@
return HINT_NONE;
}
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
char governor[80];
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;
}
@@ -114,38 +110,37 @@
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))) {
+ 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;
+ }
+ }
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- }
- }
-
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
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;
@@ -153,19 +148,15 @@
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. */
@@ -174,8 +165,7 @@
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;
}
@@ -184,75 +174,64 @@
}
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]);
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]);
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]);
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)))) {
undo_hint_action(video_encode_metadata.hint_id);
video_encode_hint_sent = 0;
}
}
return;
}
-
-
diff --git a/power-8996.c b/power-8996.c
index d090e8f..3a42c0f 100644
--- a/power-8996.c
+++ b/power-8996.c
@@ -28,27 +28,26 @@
*/
#define LOG_NIDEBUG 0
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/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 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;
@@ -64,8 +63,7 @@
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;
}
@@ -75,7 +73,7 @@
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
@@ -93,18 +91,19 @@
* -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};
- 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))) {
undo_hint_action(video_encode_metadata.hint_id);
ALOGI("Video Encode hint stop");
@@ -114,10 +113,9 @@
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;
@@ -127,7 +125,6 @@
return ret_val;
}
-int set_interactive_override(int UNUSED(on))
-{
+int set_interactive_override(int UNUSED(on)) {
return HINT_HANDLED;
}
diff --git a/power-8998.c b/power-8998.c
index ad453e8..5e54153 100644
--- a/power-8998.c
+++ b/power-8998.c
@@ -28,51 +28,51 @@
*/
#define LOG_NIDEBUG 0
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/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 int switch_mode(perf_mode_type_t mode) {
-
int hint_id = 0;
static int perfd_mode_handle = -1;
@@ -95,7 +94,7 @@
}
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 */
}
diff --git a/power-common.c b/power-common.c
index 4c0fc44..4408df0 100644
--- a/power-common.c
+++ b/power-common.c
@@ -29,75 +29,68 @@
#define LOG_NIDEBUG 0
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/Log.h>
-#include "utils.h"
#include "hint-data.h"
#include "performance.h"
#include "power-common.h"
+#include "utils.h"
static struct hint_handles handles[NUM_HINTS];
static int handleER = 0;
-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 hint,
- void *data)
-{
+int __attribute__((weak)) power_hint_override(power_hint_t hint, void* 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,9 +101,9 @@
ALOGE("Lock for hint: %X was not acquired, cannot be released", hint);
}
}
- break;
+ break;
default:
- break;
+ break;
}
}
@@ -121,8 +114,7 @@
return atoi(property) == 1 ? true : false;
}
-void set_expensive_rendering(bool enabled)
-{
+void set_expensive_rendering(bool enabled) {
if (enabled) {
handleER = perf_hint_enable(PERF_HINT_EXPENSIVE_RENDERING, 0);
} else if (handleER > 0) {
@@ -130,8 +122,7 @@
}
}
-int __attribute__ ((weak)) set_interactive_override(int on)
-{
+int __attribute__((weak)) set_interactive_override(int on) {
return HINT_NONE;
}
@@ -139,8 +130,7 @@
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);
diff --git a/power-common.h b/power-common.h
index d5c6d1e..e8e077c 100644
--- a/power-common.h
+++ b/power-common.h
@@ -44,15 +44,10 @@
#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);
bool is_expensive_rendering_supported();
void set_expensive_rendering(bool enabled);
void set_interactive(int on);
@@ -61,4 +56,4 @@
}
#endif
-#endif //__POWER_COMMON_H___
+#endif //__POWER_COMMON_H___
diff --git a/power-msmnile.c b/power-msmnile.c
index bf3729f..22f9330 100644
--- a/power-msmnile.c
+++ b/power-msmnile.c
@@ -27,46 +27,41 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#define LOG_NIDEBUG 0
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
-#include <utils/Log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <utils/Log.h>
#include "power-common.h"
-int set_interactive_override(int on)
-{
+int set_interactive_override(int on) {
static int set_i_count = 0;
- set_i_count ++;
+ set_i_count++;
ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
-
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/power.xml b/power.xml
index b8c6cba..f77f405 100644
--- a/power.xml
+++ b/power.xml
@@ -35,4 +35,4 @@
<version>3</version>
<fqname>IPower/default</fqname>
</hal>
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/utils.c b/utils.c
index a9bfda2..7828b4d 100644
--- a/utils.c
+++ b/utils.c
@@ -29,54 +29,48 @@
#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 <utils/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 PropVal (*perf_get_prop)(const char *prop , const char *def_val);
+static int (*perf_hint)(int, const char*, int, int);
+static PropVal (*perf_get_prop)(const char* prop, const char* def_val);
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) {
@@ -111,16 +105,13 @@
}
}
-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;
@@ -147,8 +138,7 @@
return ret;
}
-int sysfs_write(char *path, char *s)
-{
+int sysfs_write(char* path, char* s) {
char buf[80];
int len;
int ret = 0;
@@ -157,7 +147,7 @@
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));
@@ -173,10 +163,8 @@
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 {
@@ -185,18 +173,14 @@
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;
}
@@ -204,19 +188,17 @@
// 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;
}
-PropVal perf_get_property(const char *prop , const char *def_val) {
+PropVal perf_get_property(const char* prop, const char* def_val) {
PropVal retVal;
if (qcopt_handle && perf_get_prop) {
retVal = perf_get_prop(prop, def_val);
@@ -226,84 +208,69 @@
return retVal;
}
-void interaction(int duration, int num_args, int opt_list[])
-{
+void interaction(int duration, int num_args, int opt_list[]) {
#ifdef INTERACTION_BOOST
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;
@@ -312,15 +279,13 @@
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.");
}
@@ -329,23 +294,18 @@
}
}
-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)
@@ -369,8 +329,7 @@
* 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 9859bea..5bbbdb2 100644
--- a/utils.h
+++ b/utils.h
@@ -33,17 +33,16 @@
char value[PROP_VALUE_MAX];
} PropVal;
-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 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);
int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]);
int perf_hint_enable(int hint_id, int duration);
-PropVal perf_get_property(const char *prop , const char *def_val);
+PropVal perf_get_property(const char* prop, const char* def_val);