potter: back to N power HAL
Change-Id: Ibaf21913ba08750d69479b07a5b31bb31fdb7418
This commit is contained in:
@@ -1,20 +1,101 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
USE_ME := true
|
||||
|
||||
ifneq (,$(filter true,$(USE_ME) $(WITH_QC_PERF)))
|
||||
|
||||
# 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 libxml2
|
||||
LOCAL_SRC_FILES := power.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c
|
||||
LOCAL_C_INCLUDES := external/libxml2/include \
|
||||
external/icu/icu4c/source/common
|
||||
LOCAL_PROPRIETARY_MODULE := true
|
||||
LOCAL_SHARED_LIBRARIES := liblog libcutils libdl
|
||||
LOCAL_SRC_FILES := power.c metadata-parser.c utils.c list.c hint-data.c
|
||||
|
||||
LOCAL_SRC_FILES += power-8953.c
|
||||
ifneq ($(BOARD_POWER_CUSTOM_BOARD_LIB),)
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += $(BOARD_POWER_CUSTOM_BOARD_LIB)
|
||||
else
|
||||
|
||||
LOCAL_MODULE := power.msm8953
|
||||
# Include target-specific files.
|
||||
ifeq ($(call is-board-platform-in-list, msm8974), true)
|
||||
LOCAL_SRC_FILES += power-8974.c
|
||||
endif
|
||||
|
||||
ifeq ($(call is-board-platform-in-list, msm8960), true)
|
||||
LOCAL_SRC_FILES += power-8960.c
|
||||
endif
|
||||
|
||||
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)
|
||||
LOCAL_SRC_FILES += power-8610.c
|
||||
endif
|
||||
|
||||
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)
|
||||
LOCAL_SRC_FILES += power-8916.c
|
||||
endif
|
||||
|
||||
ifeq ($(call is-board-platform-in-list, msm8952), true)
|
||||
LOCAL_SRC_FILES += power-8952.c
|
||||
endif
|
||||
|
||||
ifeq ($(call is-board-platform-in-list, msm8937 msm8953), true)
|
||||
LOCAL_SRC_FILES += power-8937.c
|
||||
LOCAL_CFLAGS += -DMPCTLV3
|
||||
endif
|
||||
|
||||
ifeq ($(call is-board-platform-in-list, apq8084), true)
|
||||
LOCAL_SRC_FILES += power-8084.c
|
||||
endif
|
||||
|
||||
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)
|
||||
LOCAL_SRC_FILES += power-8994.c
|
||||
endif
|
||||
|
||||
ifeq ($(call is-board-platform-in-list, msm8996), true)
|
||||
LOCAL_SRC_FILES += power-8996.c
|
||||
LOCAL_CFLAGS += -DMPCTLV3
|
||||
endif
|
||||
|
||||
ifeq ($(call is-board-platform-in-list, msm8998), true)
|
||||
LOCAL_SRC_FILES += power-8998.c
|
||||
LOCAL_CFLAGS += -DMPCTLV3
|
||||
endif
|
||||
|
||||
endif # End of board specific list
|
||||
|
||||
ifneq ($(TARGET_POWERHAL_SET_INTERACTIVE_EXT),)
|
||||
LOCAL_CFLAGS += -DSET_INTERACTIVE_EXT
|
||||
LOCAL_SRC_FILES += ../../../../$(TARGET_POWERHAL_SET_INTERACTIVE_EXT)
|
||||
endif
|
||||
|
||||
ifneq ($(TARGET_TAP_TO_WAKE_NODE),)
|
||||
LOCAL_CFLAGS += -DTAP_TO_WAKE_NODE=\"$(TARGET_TAP_TO_WAKE_NODE)\"
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_POWER_SET_FEATURE_LIB),)
|
||||
LOCAL_SRC_FILES += power-feature-default.c
|
||||
else
|
||||
LOCAL_STATIC_LIBRARIES += $(TARGET_POWER_SET_FEATURE_LIB)
|
||||
endif
|
||||
|
||||
ifneq ($(CM_POWERHAL_EXTENSION),)
|
||||
LOCAL_MODULE := power.$(CM_POWERHAL_EXTENSION)
|
||||
else
|
||||
LOCAL_MODULE := power.$(TARGET_BOARD_PLATFORM)
|
||||
endif
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -Wno-unused-parameter -Wno-unused-variable
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
endif # TARGET_POWERHAL_VARIANT == qcom || WITH_QC_PERF
|
||||
|
||||
@@ -41,7 +41,7 @@ int hint_compare(struct hint_data *first_hint,
|
||||
}
|
||||
}
|
||||
|
||||
void hint_dump(struct hint_data *hint)
|
||||
void hint_dump(__attribute__((unused)) struct hint_data *hint)
|
||||
{
|
||||
/*ALOGI("hint_id: %lu", hint->hint_id);*/
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, 2015, 2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@@ -32,25 +32,9 @@
|
||||
#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 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 VR_MODE_SUSTAINED_PERF_HINT (0x1301)
|
||||
|
||||
#define DEFAULT_AUDIO_HINT_ID (0x0E00)
|
||||
#define DEFAULT_PROFILE_HINT_ID (0x0F00)
|
||||
#define CAM_PREVIEW_HINT_ID (0x1000)
|
||||
|
||||
struct hint_data {
|
||||
unsigned long hint_id; /* This is our key. */
|
||||
|
||||
@@ -46,9 +46,24 @@ struct video_decode_metadata_t {
|
||||
int state;
|
||||
};
|
||||
|
||||
struct audio_metadata_t {
|
||||
int hint_id;
|
||||
int state;
|
||||
};
|
||||
|
||||
struct cam_preview_metadata_t {
|
||||
int hint_id;
|
||||
int state;
|
||||
};
|
||||
|
||||
int parse_metadata(char *metadata, char **metadata_saveptr,
|
||||
char *attribute, int attribute_size, char *value, int value_size);
|
||||
char *attribute, 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_audio_metadata(char *metadata,
|
||||
struct audio_metadata_t *audio_metadata);
|
||||
int parse_cam_preview_metadata(char *metadata,
|
||||
struct cam_preview_metadata_t *video_decode_metadata);
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
#include "metadata-defs.h"
|
||||
|
||||
int parse_metadata(char *metadata, char **metadata_saveptr,
|
||||
char *attribute, int attribute_size, char *value, int value_size)
|
||||
char *attribute, int attribute_size, char *value,
|
||||
unsigned int value_size)
|
||||
{
|
||||
char *attribute_string;
|
||||
char *attribute_value_delim;
|
||||
@@ -68,6 +69,38 @@ int parse_metadata(char *metadata, char **metadata_saveptr,
|
||||
return METADATA_PARSING_CONTINUE;
|
||||
}
|
||||
|
||||
int parse_cam_preview_metadata(char *metadata,
|
||||
struct cam_preview_metadata_t *cam_preview_metadata)
|
||||
{
|
||||
char attribute[1024], value[1024], *saveptr;
|
||||
char *temp_metadata = metadata;
|
||||
int parsing_status;
|
||||
|
||||
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) {
|
||||
cam_preview_metadata->hint_id = atoi(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(attribute) == strlen("state") &&
|
||||
(strncmp(attribute, "state", strlen("state")) == 0)) {
|
||||
if (strlen(value) > 0) {
|
||||
cam_preview_metadata->state = atoi(value);
|
||||
}
|
||||
}
|
||||
|
||||
temp_metadata = NULL;
|
||||
}
|
||||
|
||||
if (parsing_status == METADATA_PARSING_ERR)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_video_encode_metadata(char *metadata,
|
||||
struct video_encode_metadata_t *video_encode_metadata)
|
||||
{
|
||||
@@ -131,3 +164,35 @@ int parse_video_decode_metadata(char *metadata,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_audio_metadata(char *metadata,
|
||||
struct audio_metadata_t *audio_metadata)
|
||||
{
|
||||
char attribute[1024], value[1024], *saveptr;
|
||||
char *temp_metadata = metadata;
|
||||
int parsing_status;
|
||||
|
||||
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) {
|
||||
audio_metadata->hint_id = atoi(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(attribute) == strlen("state") &&
|
||||
(strncmp(attribute, "state", strlen("state")) == 0)) {
|
||||
if (strlen(value) > 0) {
|
||||
audio_metadata->state = atoi(value);
|
||||
}
|
||||
}
|
||||
|
||||
temp_metadata = NULL;
|
||||
}
|
||||
|
||||
if (parsing_status == METADATA_PARSING_ERR)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
122
power/performance.h
Normal file → Executable file
122
power/performance.h
Normal file → Executable file
@@ -35,17 +35,14 @@ extern "C" {
|
||||
#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 0x00001086
|
||||
#define VENDOR_HINT_DISPLAY_ON 0x00001087
|
||||
|
||||
enum SCREEN_DISPLAY_TYPE {
|
||||
DISPLAY_OFF = 0x00FF,
|
||||
};
|
||||
|
||||
enum PWR_CLSP_TYPE {
|
||||
#ifdef MPCTLV3
|
||||
ALL_CPUS_PWR_CLPS_DIS_V3 = 0x40400000, /* v3 resource */
|
||||
#endif
|
||||
ALL_CPUS_PWR_CLPS_DIS = 0x101,
|
||||
};
|
||||
|
||||
@@ -103,6 +100,10 @@ enum CPU3_MAX_FREQ_LVL {
|
||||
};
|
||||
|
||||
enum MIN_CPUS_ONLINE_LVL {
|
||||
#ifdef MPCTLV3
|
||||
CPUS_ONLINE_MIN_BIG = 0x41000000, /* v3 resource */
|
||||
CPUS_ONLINE_MIN_LITTLE = 0x41000100, /* v3 resource */
|
||||
#endif
|
||||
CPUS_ONLINE_MIN_2 = 0x702,
|
||||
CPUS_ONLINE_MIN_3 = 0x703,
|
||||
CPUS_ONLINE_MIN_4 = 0x704,
|
||||
@@ -111,6 +112,10 @@ enum MIN_CPUS_ONLINE_LVL {
|
||||
};
|
||||
|
||||
enum MAX_CPUS_ONLINE_LVL {
|
||||
#ifdef MPCTLV3
|
||||
CPUS_ONLINE_MAX_LIMIT_BIG = 0x41004000, /* v3 resource */
|
||||
CPUS_ONLINE_MAX_LIMIT_LITTLE = 0x41004100, /* v3 resource */
|
||||
#endif
|
||||
CPUS_ONLINE_MAX_LIMIT_1 = 0x8FE,
|
||||
CPUS_ONLINE_MAX_LIMIT_2 = 0x8FD,
|
||||
CPUS_ONLINE_MAX_LIMIT_3 = 0x8FC,
|
||||
@@ -134,6 +139,7 @@ enum ONDEMAND_SAMPLING_DOWN_FACTOR_LVL {
|
||||
SAMPLING_DOWN_FACTOR_4 = 0xD04,
|
||||
};
|
||||
|
||||
|
||||
enum INTERACTIVE_TIMER_RATE_LVL {
|
||||
TR_MS_500 = 0xECD,
|
||||
TR_MS_100 = 0xEF5,
|
||||
@@ -162,28 +168,9 @@ enum INTERACTIVE_TIMER_RATE_LVL_CPU4_8939 {
|
||||
TR_MS_CPU4_20 = 0x3BFD,
|
||||
};
|
||||
|
||||
/* This timer rate applicable to big.little arch */
|
||||
enum INTERACTIVE_TIMER_RATE_LVL_BIG_LITTLE {
|
||||
BIG_LITTLE_TR_MS_100 = 0x64,
|
||||
BIG_LITTLE_TR_MS_50 = 0x32,
|
||||
BIG_LITTLE_TR_MS_40 = 0x28,
|
||||
BIG_LITTLE_TR_MS_30 = 0x1E,
|
||||
BIG_LITTLE_TR_MS_20 = 0x14,
|
||||
};
|
||||
|
||||
/* INTERACTIVE opcodes */
|
||||
enum INTERACTIVE_OPCODES {
|
||||
INT_OP_CLUSTER0_TIMER_RATE = 0x41424000,
|
||||
INT_OP_CLUSTER1_TIMER_RATE = 0x41424100,
|
||||
INT_OP_CLUSTER0_USE_SCHED_LOAD = 0x41430000,
|
||||
INT_OP_CLUSTER1_USE_SCHED_LOAD = 0x41430100,
|
||||
INT_OP_CLUSTER0_USE_MIGRATION_NOTIF = 0x41434000,
|
||||
INT_OP_CLUSTER1_USE_MIGRATION_NOTIF = 0x41434100,
|
||||
INT_OP_NOTIFY_ON_MIGRATE = 0x4241C000
|
||||
};
|
||||
|
||||
enum INTERACTIVE_HISPEED_FREQ_LVL {
|
||||
HS_FREQ_1026 = 0xF0A,
|
||||
HS_FREQ_800 = 0xF08,
|
||||
};
|
||||
|
||||
enum INTERACTIVE_HISPEED_LOAD_LVL {
|
||||
@@ -213,6 +200,9 @@ enum SCREEN_PWR_CLPS_LVL {
|
||||
|
||||
enum THREAD_MIGRATION_LVL {
|
||||
THREAD_MIGRATION_SYNC_OFF = 0x1400,
|
||||
#ifdef MPCTLV3
|
||||
THREAD_MIGRATION_SYNC_ON_V3 = 0x4241C000
|
||||
#endif
|
||||
};
|
||||
|
||||
enum INTERACTIVE_IO_BUSY_LVL {
|
||||
@@ -221,6 +211,9 @@ enum INTERACTIVE_IO_BUSY_LVL {
|
||||
};
|
||||
|
||||
enum SCHED_BOOST_LVL {
|
||||
#ifdef MPCTLV3
|
||||
SCHED_BOOST_ON_V3 = 0x40C00000, /* v3 resource */
|
||||
#endif
|
||||
SCHED_BOOST_ON = 0x1E01,
|
||||
};
|
||||
|
||||
@@ -260,6 +253,83 @@ enum CPU7_MAX_FREQ_LVL {
|
||||
CPU7_MAX_FREQ_NONTURBO_MAX = 0x260A,
|
||||
};
|
||||
|
||||
enum SCHED_PREFER_IDLE {
|
||||
#ifdef MPCTLV3
|
||||
SCHED_PREFER_IDLE_DIS_V3 = 0x40C04000,
|
||||
#endif
|
||||
SCHED_PREFER_IDLE_DIS = 0x3E01,
|
||||
};
|
||||
|
||||
enum SCHED_MIGRATE_COST_CHNG {
|
||||
SCHED_MIGRATE_COST_SET = 0x3F01,
|
||||
};
|
||||
|
||||
#ifdef MPCTLV3
|
||||
/**
|
||||
* MPCTL v3 opcodes
|
||||
*/
|
||||
enum MAX_FREQ_CLUSTER_BIG {
|
||||
MAX_FREQ_BIG_CORE_0 = 0x40804000,
|
||||
};
|
||||
|
||||
enum MAX_FREQ_CLUSTER_LITTLE {
|
||||
MAX_FREQ_LITTLE_CORE_0 = 0x40804100,
|
||||
};
|
||||
|
||||
enum MIN_FREQ_CLUSTER_BIG {
|
||||
MIN_FREQ_BIG_CORE_0 = 0x40800000,
|
||||
};
|
||||
|
||||
enum MIN_FREQ_CLUSTER_LITTLE {
|
||||
MIN_FREQ_LITTLE_CORE_0 = 0x40800100,
|
||||
};
|
||||
|
||||
enum INTERACTIVE_CLUSTER_BIG {
|
||||
ABOVE_HISPEED_DELAY_BIG = 0x41400000,
|
||||
GO_HISPEED_LOAD_BIG = 0x41410000,
|
||||
HISPEED_FREQ_BIG = 0x41414000,
|
||||
TARGET_LOADS_BIG = 0x41420000,
|
||||
TIMER_RATE_BIG = 0x41424000,
|
||||
USE_SCHED_LOAD_BIG = 0x41430000,
|
||||
USE_MIGRATION_NOTIF_BIG = 0x41434000,
|
||||
IGNORE_HISPEED_NOTIF_BIG = 0x41438000,
|
||||
};
|
||||
|
||||
enum INTERACTIVE_CLUSTER_LITTLE {
|
||||
ABOVE_HISPEED_DELAY_LITTLE = 0x41400100,
|
||||
GO_HISPEED_LOAD_LITTLE = 0x41410100,
|
||||
HISPEED_FREQ_LITTLE = 0x41414100,
|
||||
TARGET_LOADS_LITTLE = 0x41420100,
|
||||
TIMER_RATE_LITTLE = 0x41424100,
|
||||
USE_SCHED_LOAD_LITTLE = 0x41430100,
|
||||
USE_MIGRATION_NOTIF_LITTLE = 0x41434100,
|
||||
IGNORE_HISPEED_NOTIF_LITTLE = 0x41438100,
|
||||
};
|
||||
|
||||
enum CPUBW_HWMON {
|
||||
CPUBW_HWMON_MIN_FREQ = 0x41800000,
|
||||
CPUBW_HWMON_V1 = 0x4180C000,
|
||||
LOW_POWER_CEIL_MBPS = 0x41810000,
|
||||
LOW_POWER_IO_PERCENT = 0x41814000,
|
||||
CPUBW_HWMON_SAMPLE_MS = 0x41820000,
|
||||
};
|
||||
|
||||
enum SCHEDULER {
|
||||
SCHED_SMALL_TASK_DIS = 0x40C0C000,
|
||||
SCHED_IDLE_LOAD_DIS = 0x40C10000,
|
||||
SCHED_IDLE_NR_RUN_DIS = 0x40C14000,
|
||||
SCHED_GROUP_ON = 0x40C28000,
|
||||
};
|
||||
|
||||
enum STORAGE {
|
||||
STOR_CLK_SCALE_DIS = 0x42C10000,
|
||||
};
|
||||
|
||||
enum GPU {
|
||||
GPU_MIN_PWRLVL_BOOST = 0x42804000,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
165
power/power-8084.c
Normal file
165
power/power-8084.c
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
static int first_display_off_hint;
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MIN_4,
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
|
||||
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_POWER_SAVE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_2,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
|
||||
CPU2_MAX_FREQ_NONTURBO_MAX, CPU3_MAX_FREQ_NONTURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
int power_hint_override(__attribute__((unused)) struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
// Skip other hints in custom power modes
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
int duration = *(int32_t *)data / 1000;
|
||||
int resources[] = { CPUS_ONLINE_MIN_2, 0x20B, 0x30B, 0x1C00};
|
||||
|
||||
if (duration > 0)
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int set_interactive_override(struct power_module *module, int on)
|
||||
{
|
||||
char governor[80];
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off. */
|
||||
/*
|
||||
* We need to be able to identify the first display off hint
|
||||
* and release the current lock holder
|
||||
*/
|
||||
if (!first_display_off_hint) {
|
||||
undo_initial_hint_action();
|
||||
first_display_off_hint = 1;
|
||||
}
|
||||
/* Used for all subsequent toggles to the display */
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID_2);
|
||||
|
||||
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};
|
||||
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} else {
|
||||
/* Display on */
|
||||
int resource_values2[] = { CPUS_ONLINE_MIN_2 };
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID_2,
|
||||
resource_values2, ARRAY_SIZE(resource_values2));
|
||||
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
119
power/power-8226.c
Normal file
119
power/power-8226.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014, The CyanogenMod Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MIN_4,
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
|
||||
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
} else if (profile == PROFILE_POWER_SAVE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_2,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
|
||||
CPU2_MAX_FREQ_NONTURBO_MAX, CPU3_MAX_FREQ_NONTURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
int power_hint_override(__attribute__((unused)) struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
// Skip other hints in custom power modes
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
int duration = *(int32_t *)data / 1000;
|
||||
int resources[] = { CPUS_ONLINE_MIN_2, 0x20F, 0x30F};
|
||||
|
||||
if (duration > 0)
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
return HINT_HANDLED;
|
||||
} else if (hint == POWER_HINT_INTERACTION) {
|
||||
int resources[] = {0x702, 0x20B, 0x30B};
|
||||
int duration = 3000;
|
||||
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
117
power/power-8610.c
Normal file
117
power/power-8610.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014, The CyanogenMod Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MIN_2,
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
} else if (profile == PROFILE_POWER_SAVE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_2,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
int power_hint_override(__attribute__((unused)) struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
// Skip other hints in custom power modes
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
int duration = *(int32_t *)data / 1000;
|
||||
int resources[] = { CPUS_ONLINE_MIN_2, 0x20F, 0x30F};
|
||||
|
||||
if (duration > 0)
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
return HINT_HANDLED;
|
||||
} else if (hint == POWER_HINT_INTERACTION) {
|
||||
int resources[] = {0x702, 0x20B, 0x30B};
|
||||
int duration = 3000;
|
||||
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
107
power/power-8909.c
Normal file
107
power/power-8909.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QTI PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
|
||||
static void process_video_encode_hint(void *metadata)
|
||||
{
|
||||
char governor[80];
|
||||
struct video_encode_metadata_t video_encode_metadata;
|
||||
char tmp_str[NODE_MAX];
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize encode metadata struct fields. */
|
||||
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
|
||||
video_encode_metadata.state = -1;
|
||||
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
|
||||
|
||||
if (metadata) {
|
||||
if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
|
||||
-1) {
|
||||
ALOGE("Error occurred while parsing metadata.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (video_encode_metadata.state == 1) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(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, ARRAY_SIZE(resource_values));
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int power_hint_override(struct power_module *module, 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;
|
||||
}
|
||||
447
power/power-8916.c
Normal file
447
power/power-8916.c
Normal file
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014, The CyanogenMod Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
#define MIN_FREQ_CPU0_DISP_OFF 400000
|
||||
#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"
|
||||
};
|
||||
|
||||
static int slack_node_rw_failed = 0;
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
/**
|
||||
* If target is 8916:
|
||||
* return 1
|
||||
* else:
|
||||
* return 0
|
||||
*/
|
||||
static int is_target_8916(void)
|
||||
{
|
||||
static int is_8916 = -1;
|
||||
int soc_id;
|
||||
|
||||
if (is_8916 >= 0)
|
||||
return is_8916;
|
||||
|
||||
soc_id = get_soc_id();
|
||||
if (soc_id == 206 || (soc_id >= 247 && soc_id <= 250))
|
||||
is_8916 = 1;
|
||||
else
|
||||
is_8916 = 0;
|
||||
|
||||
return is_8916;
|
||||
}
|
||||
|
||||
static int profile_high_performance_8916[3] = {
|
||||
0x1C00, 0x0901, CPU0_MIN_FREQ_TURBO_MAX,
|
||||
};
|
||||
|
||||
static int profile_high_performance_8939[11] = {
|
||||
SCHED_BOOST_ON, 0x1C00, 0x0901,
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
|
||||
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX,
|
||||
CPU4_MIN_FREQ_TURBO_MAX, CPU5_MIN_FREQ_TURBO_MAX,
|
||||
CPU6_MIN_FREQ_TURBO_MAX, CPU7_MIN_FREQ_TURBO_MAX,
|
||||
};
|
||||
|
||||
static int profile_power_save_8916[1] = {
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX,
|
||||
};
|
||||
|
||||
static int profile_power_save_8939[5] = {
|
||||
CPUS_ONLINE_MAX_LIMIT_2,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
|
||||
CPU2_MAX_FREQ_NONTURBO_MAX, CPU3_MAX_FREQ_NONTURBO_MAX,
|
||||
};
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int *resource_values = is_target_8916() ?
|
||||
profile_high_performance_8916 : profile_high_performance_8939;
|
||||
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_POWER_SAVE) {
|
||||
int* resource_values = is_target_8916() ?
|
||||
profile_power_save_8916 : profile_power_save_8939;
|
||||
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
static void process_video_decode_hint(void *metadata)
|
||||
{
|
||||
char governor[80];
|
||||
struct video_decode_metadata_t video_decode_metadata;
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (metadata) {
|
||||
ALOGI("Processing video decode hint. Metadata: %s", (char *)metadata);
|
||||
}
|
||||
|
||||
/* Initialize encode metadata struct fields. */
|
||||
memset(&video_decode_metadata, 0, sizeof(struct video_decode_metadata_t));
|
||||
video_decode_metadata.state = -1;
|
||||
video_decode_metadata.hint_id = DEFAULT_VIDEO_DECODE_HINT_ID;
|
||||
|
||||
if (metadata) {
|
||||
if (parse_video_decode_metadata((char *)metadata, &video_decode_metadata) ==
|
||||
-1) {
|
||||
ALOGE("Error occurred while parsing metadata.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (video_decode_metadata.state == 1) {
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
int resource_values[] = {THREAD_MIGRATION_SYNC_OFF};
|
||||
|
||||
perform_hint_action(video_decode_metadata.hint_id,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
int resource_values[] = {TR_MS_30, HISPEED_LOAD_90, HS_FREQ_1026};
|
||||
|
||||
perform_hint_action(video_decode_metadata.hint_id,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
}
|
||||
} else if (video_decode_metadata.state == 0) {
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
undo_hint_action(video_decode_metadata.hint_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void process_video_encode_hint(void *metadata)
|
||||
{
|
||||
char governor[80];
|
||||
struct video_encode_metadata_t video_encode_metadata;
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize encode metadata struct fields. */
|
||||
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
|
||||
video_encode_metadata.state = -1;
|
||||
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
|
||||
|
||||
if (metadata) {
|
||||
if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
|
||||
-1) {
|
||||
ALOGE("Error occurred while parsing metadata.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (video_encode_metadata.state == 1) {
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
int resource_values[] = {IO_BUSY_OFF, SAMPLING_DOWN_FACTOR_1, THREAD_MIGRATION_SYNC_OFF};
|
||||
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
int resource_values[] = {HS_FREQ_800, 0x1C00};
|
||||
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
}
|
||||
} else if (video_encode_metadata.state == 0) {
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
#ifdef __LP64__
|
||||
typedef int64_t hintdata;
|
||||
#else
|
||||
typedef int hintdata;
|
||||
#endif
|
||||
|
||||
int set_interactive_override(struct power_module *module __unused, 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) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off. */
|
||||
if (is_target_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};
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} /* Perf time rate set for 8916 target*/
|
||||
/* End of display hint for 8916 */
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} /* Perf time rate set for CORE0,CORE4 8939 target*/
|
||||
/* End of display hint for 8939 */
|
||||
}
|
||||
|
||||
} else {
|
||||
/* Display on. */
|
||||
if (is_target_8916()) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID);
|
||||
}
|
||||
} else {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
} /* End of check condition during the DISPLAY ON case */
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
int power_hint_override(struct power_module *module __unused, power_hint_t hint, void *data)
|
||||
{
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
}
|
||||
|
||||
// Skip other hints in custom power modes
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_INTERACTION) {
|
||||
int duration = 500, duration_hint = 0;
|
||||
static struct timespec s_previous_boost_timespec;
|
||||
struct timespec cur_boost_timespec;
|
||||
long long elapsed_time;
|
||||
|
||||
if (data) {
|
||||
duration_hint = *((int *)data);
|
||||
}
|
||||
|
||||
duration = duration_hint > 0 ? duration_hint : 500;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||
if (elapsed_time > 750000)
|
||||
elapsed_time = 750000;
|
||||
// don't hint if it's been less than 250ms since last boost
|
||||
// also detect if we're doing anything resembling a fling
|
||||
// support additional boosting in case of flings
|
||||
else if (elapsed_time < 250000 && duration <= 750)
|
||||
return HINT_HANDLED;
|
||||
|
||||
s_previous_boost_timespec = cur_boost_timespec;
|
||||
|
||||
if (duration >= 1500) {
|
||||
int resources[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_BOOST_ON,
|
||||
SCHED_PREFER_IDLE_DIS,
|
||||
0x20D
|
||||
};
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
} else {
|
||||
int resources[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_PREFER_IDLE_DIS,
|
||||
0x20D
|
||||
};
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_LAUNCH) {
|
||||
int duration = 2000;
|
||||
int resources[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_BOOST_ON,
|
||||
SCHED_PREFER_IDLE_DIS,
|
||||
0x20F,
|
||||
0x1C00,
|
||||
0x4001,
|
||||
0x4101,
|
||||
0x4201
|
||||
};
|
||||
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
int duration = *(int32_t *)data / 1000;
|
||||
int resources[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_BOOST_ON,
|
||||
SCHED_PREFER_IDLE_DIS,
|
||||
0x20D
|
||||
};
|
||||
|
||||
if (duration > 0)
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_VIDEO_ENCODE) {
|
||||
process_video_encode_hint(data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_VIDEO_DECODE) {
|
||||
process_video_decode_hint(data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
323
power/power-8937.c
Normal file
323
power/power-8937.c
Normal file
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QTI PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
static int video_encode_hint_sent;
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
static void process_video_encode_hint(void *metadata);
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
static int profile_high_performance[] = {
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
ALL_CPUS_PWR_CLPS_DIS_V3, 0x1,
|
||||
CPUS_ONLINE_MIN_BIG, 0x4,
|
||||
MIN_FREQ_BIG_CORE_0, 0xFFF,
|
||||
MIN_FREQ_LITTLE_CORE_0, 0xFFF,
|
||||
GPU_MIN_PWRLVL_BOOST, 0x1,
|
||||
SCHED_PREFER_IDLE_DIS_V3, 0x1,
|
||||
SCHED_SMALL_TASK_DIS, 0x1,
|
||||
SCHED_IDLE_NR_RUN_DIS, 0x1,
|
||||
SCHED_IDLE_LOAD_DIS, 0x1,
|
||||
};
|
||||
|
||||
static int profile_power_save[] = {
|
||||
CPUS_ONLINE_MAX_LIMIT_BIG, 0x1,
|
||||
MAX_FREQ_BIG_CORE_0, 0x3bf,
|
||||
MAX_FREQ_LITTLE_CORE_0, 0x300,
|
||||
};
|
||||
|
||||
static int profile_bias_power[] = {
|
||||
MAX_FREQ_BIG_CORE_0, 0x4B0,
|
||||
MAX_FREQ_LITTLE_CORE_0, 0x300,
|
||||
};
|
||||
|
||||
static int profile_bias_performance[] = {
|
||||
CPUS_ONLINE_MAX_LIMIT_BIG, 0x4,
|
||||
MIN_FREQ_BIG_CORE_0, 0x540,
|
||||
};
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_high_performance,
|
||||
ARRAY_SIZE(profile_high_performance));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_POWER_SAVE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_power_save,
|
||||
ARRAY_SIZE(profile_power_save));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
} else if (profile == PROFILE_BIAS_POWER) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_power,
|
||||
ARRAY_SIZE(profile_bias_power));
|
||||
ALOGD("%s: Set bias power mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
|
||||
ARRAY_SIZE(profile_bias_performance));
|
||||
ALOGD("%s: Set bias perf mode", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
int power_hint_override(__unused struct power_module *module, power_hint_t hint,
|
||||
void *data)
|
||||
{
|
||||
int duration, duration_hint;
|
||||
static struct timespec s_previous_boost_timespec;
|
||||
struct timespec cur_boost_timespec;
|
||||
long long elapsed_time;
|
||||
int resources_launch[] = {
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
MIN_FREQ_BIG_CORE_0, 0x5DC,
|
||||
ALL_CPUS_PWR_CLPS_DIS_V3, 0x1,
|
||||
CPUS_ONLINE_MIN_BIG, 0x4,
|
||||
GPU_MIN_PWRLVL_BOOST, 0x1,
|
||||
SCHED_PREFER_IDLE_DIS_V3, 0x1,
|
||||
SCHED_SMALL_TASK_DIS, 0x1,
|
||||
SCHED_IDLE_NR_RUN_DIS, 0x1,
|
||||
SCHED_IDLE_LOAD_DIS, 0x1,
|
||||
};
|
||||
|
||||
int resources_cpu_boost[] = {
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
MIN_FREQ_BIG_CORE_0, 0x44C,
|
||||
};
|
||||
|
||||
int resources_interaction_fling_boost[] = {
|
||||
MIN_FREQ_BIG_CORE_0, 0x514,
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
};
|
||||
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
// Skip other hints in power save mode
|
||||
if (current_power_profile == PROFILE_POWER_SAVE) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
switch (hint) {
|
||||
case POWER_HINT_INTERACTION:
|
||||
duration = 500;
|
||||
duration_hint = 0;
|
||||
|
||||
if (data) {
|
||||
duration_hint = *((int *)data);
|
||||
}
|
||||
|
||||
duration = duration_hint > 0 ? duration_hint : 500;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||
if (elapsed_time > 750000)
|
||||
elapsed_time = 750000;
|
||||
// don't hint if it's been less than 250ms since last boost
|
||||
// also detect if we're doing anything resembling a fling
|
||||
// support additional boosting in case of flings
|
||||
else if (elapsed_time < 250000 && duration <= 750)
|
||||
return HINT_HANDLED;
|
||||
|
||||
s_previous_boost_timespec = cur_boost_timespec;
|
||||
|
||||
if (duration >= 1500) {
|
||||
interaction(duration, ARRAY_SIZE(resources_interaction_fling_boost),
|
||||
resources_interaction_fling_boost);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
case POWER_HINT_LAUNCH:
|
||||
duration = 2000;
|
||||
interaction(duration, ARRAY_SIZE(resources_launch),
|
||||
resources_launch);
|
||||
return HINT_HANDLED;
|
||||
case POWER_HINT_CPU_BOOST:
|
||||
duration = *(int32_t *)data / 1000;
|
||||
if (duration > 0) {
|
||||
interaction(duration, ARRAY_SIZE(resources_cpu_boost),
|
||||
resources_cpu_boost);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
case POWER_HINT_VIDEO_ENCODE:
|
||||
process_video_encode_hint(data);
|
||||
return HINT_HANDLED;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int set_interactive_override(__unused struct power_module *module, int on)
|
||||
{
|
||||
char governor[80];
|
||||
|
||||
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) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off. */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
int resource_values[] = {
|
||||
TIMER_RATE_BIG, 0x32,
|
||||
TIMER_RATE_LITTLE, 0x32,
|
||||
THREAD_MIGRATION_SYNC_ON_V3, 0x0,
|
||||
};
|
||||
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} /* 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);
|
||||
}
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
/* Video Encode Hint */
|
||||
static void process_video_encode_hint(void *metadata)
|
||||
{
|
||||
char governor[80];
|
||||
struct video_encode_metadata_t video_encode_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize encode metadata struct fields. */
|
||||
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
|
||||
video_encode_metadata.state = -1;
|
||||
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
|
||||
|
||||
if (metadata) {
|
||||
if (parse_video_encode_metadata((char *)metadata,
|
||||
&video_encode_metadata) == -1) {
|
||||
ALOGE("Error occurred while parsing metadata.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (video_encode_metadata.state == 1) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR,
|
||||
strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
int resource_values[] = {
|
||||
USE_SCHED_LOAD_BIG, 0x1,
|
||||
USE_SCHED_LOAD_LITTLE, 0x1,
|
||||
USE_MIGRATION_NOTIF_BIG, 0x1,
|
||||
USE_MIGRATION_NOTIF_LITTLE, 0x1,
|
||||
TIMER_RATE_BIG, 0x28,
|
||||
TIMER_RATE_LITTLE, 0x28,
|
||||
};
|
||||
if (!video_encode_hint_sent) {
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values,
|
||||
ARRAY_SIZE(resource_values));
|
||||
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))) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
video_encode_hint_sent = 0;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@@ -48,28 +48,145 @@
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
static int saved_interactive_mode = -1;
|
||||
static int display_hint_sent;
|
||||
static int video_encode_hint_sent;
|
||||
static int cam_preview_hint_sent;
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
pthread_mutex_t camera_hint_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int camera_hint_ref_count;
|
||||
static void process_video_encode_hint(void *metadata);
|
||||
//static void process_cam_preview_hint(void *metadata);
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
static int profile_high_performance_8952[11] = {
|
||||
SCHED_BOOST_ON,
|
||||
0x704, 0x4d04, /* Enable all CPUs */
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
|
||||
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX,
|
||||
CPU4_MIN_FREQ_TURBO_MAX, CPU5_MIN_FREQ_TURBO_MAX,
|
||||
CPU6_MIN_FREQ_TURBO_MAX, CPU7_MIN_FREQ_TURBO_MAX,
|
||||
};
|
||||
|
||||
static int profile_power_save_8952[] = {
|
||||
0x8fe, 0x3dfd, /* 1 big core, 2 little cores*/
|
||||
CPUS_ONLINE_MAX_LIMIT_2,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
|
||||
CPU2_MAX_FREQ_NONTURBO_MAX, CPU3_MAX_FREQ_NONTURBO_MAX,
|
||||
};
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int *resource_values = profile_high_performance_8952;
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, resource_values,
|
||||
ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_POWER_SAVE) {
|
||||
int *resource_values = profile_power_save_8952;
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, resource_values,
|
||||
ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
int power_hint_override(struct power_module *module, power_hint_t hint,
|
||||
void *data)
|
||||
{
|
||||
int duration, duration_hint;
|
||||
static struct timespec s_previous_boost_timespec;
|
||||
struct timespec cur_boost_timespec;
|
||||
long long elapsed_time;
|
||||
int resources_launch[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_BOOST_ON,
|
||||
SCHED_PREFER_IDLE_DIS,
|
||||
0x20f,
|
||||
0x4001,
|
||||
0x4101,
|
||||
0x4201,
|
||||
};
|
||||
int resources_cpu_boost[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_BOOST_ON,
|
||||
SCHED_PREFER_IDLE_DIS,
|
||||
0x20d,
|
||||
};
|
||||
int resources_interaction_boost[] = {
|
||||
SCHED_PREFER_IDLE_DIS,
|
||||
0x20d,
|
||||
0x3d01,
|
||||
};
|
||||
|
||||
switch(hint) {
|
||||
case POWER_HINT_VSYNC:
|
||||
break;
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
// Skip other hints in custom power modes
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
switch (hint) {
|
||||
case POWER_HINT_INTERACTION:
|
||||
duration = 500;
|
||||
duration_hint = 0;
|
||||
|
||||
if (data) {
|
||||
duration_hint = *((int *)data);
|
||||
}
|
||||
|
||||
duration = duration_hint > 0 ? duration_hint : 500;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||
if (elapsed_time > 750000)
|
||||
elapsed_time = 750000;
|
||||
// don't hint if it's been less than 250ms since last boost
|
||||
// also detect if we're doing anything resembling a fling
|
||||
// support additional boosting in case of flings
|
||||
else if (elapsed_time < 250000 && duration <= 750)
|
||||
return HINT_HANDLED;
|
||||
|
||||
s_previous_boost_timespec = cur_boost_timespec;
|
||||
|
||||
if (duration >= 1500) {
|
||||
interaction(duration, ARRAY_SIZE(resources_cpu_boost),
|
||||
resources_cpu_boost);
|
||||
} else {
|
||||
interaction(duration, ARRAY_SIZE(resources_interaction_boost),
|
||||
resources_interaction_boost);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
case POWER_HINT_LAUNCH:
|
||||
duration = 2000;
|
||||
interaction(duration, ARRAY_SIZE(resources_launch),
|
||||
resources_launch);
|
||||
return HINT_HANDLED;
|
||||
case POWER_HINT_CPU_BOOST:
|
||||
duration = *(int32_t *)data / 1000;
|
||||
if (duration > 0) {
|
||||
interaction(duration, ARRAY_SIZE(resources_cpu_boost),
|
||||
resources_cpu_boost);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
case POWER_HINT_VIDEO_ENCODE:
|
||||
{
|
||||
process_video_encode_hint(data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
@@ -77,9 +194,6 @@ int power_hint_override(struct power_module *module, power_hint_t hint,
|
||||
int set_interactive_override(struct power_module *module, 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");
|
||||
|
||||
@@ -98,14 +212,10 @@ int set_interactive_override(struct power_module *module, int on)
|
||||
/* Display off. */
|
||||
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;
|
||||
}
|
||||
int resource_values[] = {TR_MS_CPU0_50, TR_MS_CPU4_50};
|
||||
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} /* Perf time rate set for CORE0,CORE4 8952 target*/
|
||||
|
||||
} else {
|
||||
@@ -114,14 +224,11 @@ int set_interactive_override(struct power_module *module, int on)
|
||||
(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)
|
||||
{
|
||||
@@ -139,7 +246,7 @@ static void process_video_encode_hint(void *metadata)
|
||||
if (get_scaling_governor_check_cores(governor,
|
||||
sizeof(governor),CPU3) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
// return HINT_HANDLED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,39 +271,22 @@ static void process_video_encode_hint(void *metadata)
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR,
|
||||
strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
/* Sched_load and migration_notification disable
|
||||
* timer rate - 40mS*/
|
||||
int resource_values[] = {0x41430000, 0x1,
|
||||
0x41434000, 0x1,
|
||||
0x41424000, 0x28,
|
||||
};
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
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,
|
||||
sizeof(resource_values)/sizeof(resource_values[0]));
|
||||
video_encode_hint_sent = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
int resource_values[] = {TR_MS_CPU0_30, TR_MS_CPU4_30};
|
||||
if (!video_encode_hint_sent) {
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values,
|
||||
ARRAY_SIZE(resource_values));
|
||||
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))) {
|
||||
pthread_mutex_lock(&camera_hint_mutex);
|
||||
camera_hint_ref_count--;
|
||||
if (!camera_hint_ref_count) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
video_encode_hint_sent = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&camera_hint_mutex);
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
video_encode_hint_sent = 0;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
141
power/power-8960.c
Normal file
141
power/power-8960.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2015, The CyanogenMod Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* If target is 8064:
|
||||
* return 1
|
||||
* else:
|
||||
* return 0
|
||||
*/
|
||||
static int is_target_8064(void)
|
||||
{
|
||||
static int is_8064 = -1;
|
||||
int soc_id;
|
||||
|
||||
if (is_8064 >= 0)
|
||||
return is_8064;
|
||||
|
||||
soc_id = get_soc_id();
|
||||
if (soc_id == 153)
|
||||
is_8064 = 1;
|
||||
else
|
||||
is_8064 = 0;
|
||||
|
||||
return is_8064;
|
||||
}
|
||||
|
||||
static int profile_high_performance_8960[] = {
|
||||
CPUS_ONLINE_MIN_2,
|
||||
};
|
||||
|
||||
static int profile_high_performance_8064[] = {
|
||||
CPUS_ONLINE_MIN_4,
|
||||
};
|
||||
|
||||
static int profile_power_save_8960[] = {
|
||||
/* Don't do anything for now */
|
||||
};
|
||||
|
||||
static int profile_power_save_8064[] = {
|
||||
CPUS_ONLINE_MAX_LIMIT_2,
|
||||
};
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int *resource_values = is_target_8064() ?
|
||||
profile_high_performance_8064 : profile_high_performance_8960;
|
||||
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
} else if (profile == PROFILE_POWER_SAVE) {
|
||||
int* resource_values = is_target_8064() ?
|
||||
profile_power_save_8064 : profile_power_save_8960;
|
||||
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
int power_hint_override(__attribute__((unused)) struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
/* Skip other hints in power save mode */
|
||||
if (current_power_profile == PROFILE_POWER_SAVE) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
253
power/power-8974.c
Normal file
253
power/power-8974.c
Normal file
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014, The CyanogenMod Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
static int first_display_off_hint;
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* If target is 8974pro:
|
||||
* return 1
|
||||
* else:
|
||||
* return 0
|
||||
*/
|
||||
static int is_target_8974pro(void)
|
||||
{
|
||||
static int is_8974pro = -1;
|
||||
int soc_id;
|
||||
|
||||
if (is_8974pro >= 0)
|
||||
return is_8974pro;
|
||||
|
||||
soc_id = get_soc_id();
|
||||
if (soc_id == 194 || (soc_id >= 208 && soc_id <= 218))
|
||||
is_8974pro = 1;
|
||||
else
|
||||
is_8974pro = 0;
|
||||
|
||||
return is_8974pro;
|
||||
}
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MIN_4, 0x0901,
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
|
||||
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
|
||||
int resource_values[] = {
|
||||
CPU0_MIN_FREQ_NONTURBO_MAX + 1, CPU1_MIN_FREQ_NONTURBO_MAX + 1,
|
||||
CPU2_MIN_FREQ_NONTURBO_MAX + 1, CPU2_MIN_FREQ_NONTURBO_MAX + 1 };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set bias perf mode", __func__);
|
||||
} else if (profile == PROFILE_BIAS_POWER) {
|
||||
int resource_values[] = { 0x0A03,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
|
||||
CPU1_MAX_FREQ_NONTURBO_MAX, CPU2_MAX_FREQ_NONTURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set bias power mode", __func__);
|
||||
} else if (profile == PROFILE_POWER_SAVE) {
|
||||
int resource_values[] = { 0x0A03, CPUS_ONLINE_MAX_LIMIT_2,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX, CPU1_MAX_FREQ_NONTURBO_MAX,
|
||||
CPU2_MAX_FREQ_NONTURBO_MAX, CPU3_MAX_FREQ_NONTURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
int power_hint_override(__attribute__((unused)) struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
// Skip other hints in high/low power modes
|
||||
if (current_power_profile == PROFILE_POWER_SAVE ||
|
||||
current_power_profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_LAUNCH) {
|
||||
int duration = 2000;
|
||||
int resources[] = { CPUS_ONLINE_MIN_3,
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
|
||||
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };
|
||||
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
int duration = *(int32_t *)data / 1000;
|
||||
int resources[] = { CPUS_ONLINE_MIN_2,
|
||||
0x20F, 0x30F, 0x40F, 0x50F };
|
||||
|
||||
if (duration)
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_INTERACTION) {
|
||||
int duration = 500, duration_hint = 0;
|
||||
static struct timespec s_previous_boost_timespec;
|
||||
struct timespec cur_boost_timespec;
|
||||
long long elapsed_time;
|
||||
|
||||
if (data) {
|
||||
duration_hint = *((int *)data);
|
||||
}
|
||||
|
||||
duration = duration_hint > 0 ? duration_hint : 500;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||
if (elapsed_time > 750000)
|
||||
elapsed_time = 750000;
|
||||
// don't hint if it's been less than 250ms since last boost
|
||||
// also detect if we're doing anything resembling a fling
|
||||
// support additional boosting in case of flings
|
||||
else if (elapsed_time < 250000 && duration <= 750)
|
||||
return HINT_HANDLED;
|
||||
|
||||
s_previous_boost_timespec = cur_boost_timespec;
|
||||
|
||||
int resources[] = { (duration >= 2000 ? CPUS_ONLINE_MIN_3 : CPUS_ONLINE_MIN_2),
|
||||
0x20F, 0x30F, 0x40F, 0x50F };
|
||||
|
||||
if (duration)
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int set_interactive_override(struct power_module *module __unused, int on)
|
||||
{
|
||||
char governor[80];
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off. */
|
||||
/*
|
||||
* We need to be able to identify the first display off hint
|
||||
* and release the current lock holder
|
||||
*/
|
||||
if (is_target_8974pro()) {
|
||||
if (!first_display_off_hint) {
|
||||
undo_initial_hint_action();
|
||||
first_display_off_hint = 1;
|
||||
}
|
||||
/* used for all subsequent toggles to the display */
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID_2);
|
||||
}
|
||||
|
||||
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};
|
||||
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} else {
|
||||
/* Display on */
|
||||
if (is_target_8974pro()) {
|
||||
int resource_values2[] = {CPUS_ONLINE_MIN_2};
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID_2,
|
||||
resource_values2, ARRAY_SIZE(resource_values2));
|
||||
}
|
||||
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
267
power/power-8992.c
Normal file
267
power/power-8992.c
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_POWER_SAVE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MPD_OVERRIDE, 0x0A03,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX - 2, CPU1_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU2_MAX_FREQ_NONTURBO_MAX - 2, CPU3_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU4_MAX_FREQ_NONTURBO_MAX - 2, CPU5_MAX_FREQ_NONTURBO_MAX - 2 };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
} else if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int resource_values[] = { SCHED_BOOST_ON, CPUS_ONLINE_MAX,
|
||||
ALL_CPUS_PWR_CLPS_DIS, 0x0901,
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
|
||||
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX,
|
||||
CPU4_MIN_FREQ_TURBO_MAX, CPU5_MIN_FREQ_TURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
} else if (profile == PROFILE_BIAS_POWER) {
|
||||
int resource_values[] = { 0x0A03, 0x0902,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX - 2, CPU1_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU1_MAX_FREQ_NONTURBO_MAX - 2, CPU2_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU4_MAX_FREQ_NONTURBO_MAX, CPU5_MAX_FREQ_NONTURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set bias power mode", __func__);
|
||||
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_MAX,
|
||||
CPU4_MIN_FREQ_NONTURBO_MAX + 1, CPU5_MIN_FREQ_NONTURBO_MAX + 1 };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set bias perf mode", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
static int process_video_encode_hint(void *metadata)
|
||||
{
|
||||
char governor[80];
|
||||
struct video_encode_metadata_t video_encode_metadata;
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
/* Initialize encode metadata struct fields */
|
||||
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
|
||||
video_encode_metadata.state = -1;
|
||||
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
|
||||
|
||||
if (metadata) {
|
||||
if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
|
||||
-1) {
|
||||
ALOGE("Error occurred while parsing metadata.");
|
||||
return HINT_NONE;
|
||||
}
|
||||
} else {
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (video_encode_metadata.state == 1) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
/* sched and cpufreq params
|
||||
* hispeed freq - 768 MHz
|
||||
* target load - 90
|
||||
* above_hispeed_delay - 40ms
|
||||
* sched_small_tsk - 50
|
||||
*/
|
||||
int resource_values[] = {0x2C07, 0x2F5A, 0x2704, 0x4032};
|
||||
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} 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);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int power_hint_override(__attribute__((unused)) struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
// Skip other hints in custom power modes
|
||||
if (current_power_profile == PROFILE_POWER_SAVE) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_INTERACTION) {
|
||||
int duration = 500, duration_hint = 0;
|
||||
static struct timespec s_previous_boost_timespec;
|
||||
struct timespec cur_boost_timespec;
|
||||
long long elapsed_time;
|
||||
|
||||
if (data) {
|
||||
duration_hint = *((int *)data);
|
||||
}
|
||||
|
||||
duration = duration_hint > 0 ? duration_hint : 500;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||
if (elapsed_time > 750000)
|
||||
elapsed_time = 750000;
|
||||
// don't hint if it's been less than 250ms since last boost
|
||||
// also detect if we're doing anything resembling a fling
|
||||
// support additional boosting in case of flings
|
||||
else if (elapsed_time < 250000 && duration <= 750)
|
||||
return HINT_HANDLED;
|
||||
|
||||
s_previous_boost_timespec = cur_boost_timespec;
|
||||
|
||||
if (duration >= 1500) {
|
||||
int resources[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_BOOST_ON,
|
||||
SCHED_PREFER_IDLE_DIS
|
||||
};
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
} else {
|
||||
int resources[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_PREFER_IDLE_DIS
|
||||
};
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_LAUNCH) {
|
||||
int duration = 2000;
|
||||
int resources[] = { SCHED_BOOST_ON, 0x20C };
|
||||
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
int duration = *(int32_t *)data / 1000;
|
||||
int resources[] = { SCHED_BOOST_ON };
|
||||
|
||||
if (duration > 0)
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_VIDEO_ENCODE) {
|
||||
return process_video_encode_hint(data);
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int set_interactive_override(__attribute__((unused)) struct power_module *module, int on)
|
||||
{
|
||||
char governor[80];
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
// sched upmigrate = 99, sched downmigrate = 95
|
||||
// keep the big cores around, but make them very hard to use
|
||||
int resource_values[] = { 0x4E63, 0x4F5F };
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} else {
|
||||
/* Display on */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
277
power/power-8994.c
Normal file
277
power/power-8994.c
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_POWER_SAVE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MPD_OVERRIDE, 0x0A03,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX - 2, CPU1_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU2_MAX_FREQ_NONTURBO_MAX - 2, CPU3_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU4_MAX_FREQ_NONTURBO_MAX - 2, CPU5_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU6_MAX_FREQ_NONTURBO_MAX - 2, CPU7_MAX_FREQ_NONTURBO_MAX - 2 };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set powersave", __func__);
|
||||
} else if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
int resource_values[] = { SCHED_BOOST_ON, CPUS_ONLINE_MAX,
|
||||
ALL_CPUS_PWR_CLPS_DIS, 0x0901,
|
||||
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
|
||||
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX,
|
||||
CPU4_MIN_FREQ_TURBO_MAX, CPU5_MIN_FREQ_TURBO_MAX,
|
||||
CPU6_MIN_FREQ_TURBO_MAX, CPU7_MIN_FREQ_TURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set performance mode", __func__);
|
||||
} else if (profile == PROFILE_BIAS_POWER) {
|
||||
int resource_values[] = { 0x0A03, 0x0902,
|
||||
CPU0_MAX_FREQ_NONTURBO_MAX - 2, CPU1_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU1_MAX_FREQ_NONTURBO_MAX - 2, CPU2_MAX_FREQ_NONTURBO_MAX - 2,
|
||||
CPU4_MAX_FREQ_NONTURBO_MAX, CPU5_MAX_FREQ_NONTURBO_MAX,
|
||||
CPU6_MAX_FREQ_NONTURBO_MAX, CPU7_MAX_FREQ_NONTURBO_MAX };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set bias power mode", __func__);
|
||||
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
|
||||
int resource_values[] = { CPUS_ONLINE_MAX_LIMIT_MAX,
|
||||
CPU4_MIN_FREQ_NONTURBO_MAX + 1, CPU5_MIN_FREQ_NONTURBO_MAX + 1,
|
||||
CPU6_MIN_FREQ_NONTURBO_MAX + 1, CPU7_MIN_FREQ_NONTURBO_MAX + 1 };
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGD("%s: set bias perf mode", __func__);
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
#ifdef __LP64__
|
||||
typedef int64_t hintdata;
|
||||
#else
|
||||
typedef int hintdata;
|
||||
#endif
|
||||
|
||||
static int process_video_encode_hint(void *metadata)
|
||||
{
|
||||
char governor[80];
|
||||
struct video_encode_metadata_t video_encode_metadata;
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
/* Initialize encode metadata struct fields */
|
||||
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
|
||||
video_encode_metadata.state = -1;
|
||||
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
|
||||
|
||||
if (metadata) {
|
||||
if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
|
||||
-1) {
|
||||
ALOGE("Error occurred while parsing metadata.");
|
||||
return HINT_NONE;
|
||||
}
|
||||
} else {
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (video_encode_metadata.state == 1) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
/* sched and cpufreq params
|
||||
* hispeed freq - 768 MHz
|
||||
* target load - 90
|
||||
* above_hispeed_delay - 40ms
|
||||
* sched_small_tsk - 50
|
||||
*/
|
||||
int resource_values[] = {0x2C07, 0x2F5A, 0x2704, 0x4032};
|
||||
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} 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);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int power_hint_override(__attribute__((unused)) struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
// Skip other hints in custom power modes
|
||||
if (current_power_profile == PROFILE_POWER_SAVE) {
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_INTERACTION) {
|
||||
int duration = 500, duration_hint = 0;
|
||||
static struct timespec s_previous_boost_timespec;
|
||||
struct timespec cur_boost_timespec;
|
||||
long long elapsed_time;
|
||||
|
||||
if (data) {
|
||||
duration_hint = *((int *)data);
|
||||
}
|
||||
|
||||
duration = duration_hint > 0 ? duration_hint : 500;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||
if (elapsed_time > 750000)
|
||||
elapsed_time = 750000;
|
||||
// don't hint if it's been less than 250ms since last boost
|
||||
// also detect if we're doing anything resembling a fling
|
||||
// support additional boosting in case of flings
|
||||
else if (elapsed_time < 250000 && duration <= 750)
|
||||
return HINT_HANDLED;
|
||||
|
||||
s_previous_boost_timespec = cur_boost_timespec;
|
||||
|
||||
if (duration >= 1500) {
|
||||
int resources[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_BOOST_ON,
|
||||
SCHED_PREFER_IDLE_DIS
|
||||
};
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
} else {
|
||||
int resources[] = {
|
||||
ALL_CPUS_PWR_CLPS_DIS,
|
||||
SCHED_PREFER_IDLE_DIS
|
||||
};
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_LAUNCH) {
|
||||
int duration = 2000;
|
||||
int resources[] = { SCHED_BOOST_ON, 0x20C };
|
||||
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
int duration = *(int32_t *)data / 1000;
|
||||
int resources[] = { SCHED_BOOST_ON };
|
||||
|
||||
if (duration > 0)
|
||||
interaction(duration, ARRAY_SIZE(resources), resources);
|
||||
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_VIDEO_ENCODE) {
|
||||
return process_video_encode_hint(data);
|
||||
}
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int set_interactive_override(__attribute__((unused)) struct power_module *module, int on)
|
||||
{
|
||||
char governor[80];
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
// sched upmigrate = 99, sched downmigrate = 95
|
||||
// keep the big cores around, but make them very hard to use
|
||||
int resource_values[] = { 0x4E63, 0x4F5F };
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} else {
|
||||
/* Display on */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
323
power/power-8996.c
Normal file
323
power/power-8996.c
Normal file
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
static int profile_high_performance[] = {
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
ALL_CPUS_PWR_CLPS_DIS_V3, 0x1,
|
||||
CPUS_ONLINE_MIN_BIG, 0x2,
|
||||
CPUS_ONLINE_MIN_LITTLE, 0x2,
|
||||
MIN_FREQ_BIG_CORE_0, 0xFFF,
|
||||
MIN_FREQ_LITTLE_CORE_0, 0xFFF,
|
||||
};
|
||||
|
||||
static int profile_power_save[] = {
|
||||
CPUS_ONLINE_MAX_LIMIT_BIG, 0x1,
|
||||
MAX_FREQ_BIG_CORE_0, 0x3E8,
|
||||
MAX_FREQ_LITTLE_CORE_0, 0x3E8,
|
||||
};
|
||||
|
||||
static int profile_bias_power[] = {
|
||||
MAX_FREQ_BIG_CORE_0, 0x514,
|
||||
MAX_FREQ_LITTLE_CORE_0, 0x3E8,
|
||||
};
|
||||
|
||||
static int profile_bias_performance[] = {
|
||||
CPUS_ONLINE_MAX_LIMIT_BIG, 0x2,
|
||||
CPUS_ONLINE_MAX_LIMIT_LITTLE, 0x2,
|
||||
MIN_FREQ_BIG_CORE_0, 0x578,
|
||||
};
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: Profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: Hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_POWER_SAVE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_power_save,
|
||||
ARRAY_SIZE(profile_power_save));
|
||||
ALOGD("%s: Set powersave mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_high_performance,
|
||||
ARRAY_SIZE(profile_high_performance));
|
||||
ALOGD("%s: Set performance mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_BIAS_POWER) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_power,
|
||||
ARRAY_SIZE(profile_bias_power));
|
||||
ALOGD("%s: Set bias power mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
|
||||
ARRAY_SIZE(profile_bias_performance));
|
||||
ALOGD("%s: Set bias perf mode", __func__);
|
||||
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
static int process_video_encode_hint(void *metadata)
|
||||
{
|
||||
char governor[80];
|
||||
struct video_encode_metadata_t video_encode_metadata;
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
/* Initialize encode metadata struct fields */
|
||||
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
|
||||
video_encode_metadata.state = -1;
|
||||
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
|
||||
|
||||
if (metadata) {
|
||||
if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
|
||||
-1) {
|
||||
ALOGE("Error occurred while parsing metadata.");
|
||||
return HINT_NONE;
|
||||
}
|
||||
} else {
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (video_encode_metadata.state == 1) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
/* 1. cpufreq params
|
||||
* -above_hispeed_delay for LVT - 40ms
|
||||
* -go hispeed load for LVT - 95
|
||||
* -hispeed freq for LVT - 556 MHz
|
||||
* -target load for LVT - 90
|
||||
* -above hispeed delay for sLVT - 40ms
|
||||
* -go hispeed load for sLVT - 95
|
||||
* -hispeed freq for sLVT - 806 MHz
|
||||
* -target load for sLVT - 90
|
||||
* 2. bus DCVS set to V2 config:
|
||||
* -low power ceil mpbs - 2500
|
||||
* -low power io percent - 50
|
||||
* 3. hysteresis optimization
|
||||
* -bus dcvs hysteresis tuning
|
||||
* -sample_ms of 10 ms
|
||||
*/
|
||||
int resource_values[] = {
|
||||
ABOVE_HISPEED_DELAY_BIG, 0x4,
|
||||
GO_HISPEED_LOAD_BIG, 0x5F,
|
||||
HISPEED_FREQ_BIG, 0x326,
|
||||
TARGET_LOADS_BIG, 0x5A,
|
||||
ABOVE_HISPEED_DELAY_LITTLE, 0x4,
|
||||
GO_HISPEED_LOAD_LITTLE, 0x5F,
|
||||
HISPEED_FREQ_LITTLE, 0x22C,
|
||||
TARGET_LOADS_LITTLE, 0x5A,
|
||||
LOW_POWER_CEIL_MBPS, 0x9C4,
|
||||
LOW_POWER_IO_PERCENT, 0x32,
|
||||
CPUBW_HWMON_V1, 0x0,
|
||||
CPUBW_HWMON_SAMPLE_MS, 0xA,
|
||||
};
|
||||
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
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))) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
ALOGI("Video Encode hint stop");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int power_hint_override(__unused struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
static struct timespec s_previous_boost_timespec;
|
||||
struct timespec cur_boost_timespec;
|
||||
long long elapsed_time;
|
||||
int duration;
|
||||
|
||||
int resources_launch[] = {
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
MAX_FREQ_BIG_CORE_0, 0xFFF,
|
||||
MAX_FREQ_LITTLE_CORE_0, 0xFFF,
|
||||
MIN_FREQ_BIG_CORE_0, 0xFFF,
|
||||
MIN_FREQ_LITTLE_CORE_0, 0xFFF,
|
||||
CPUBW_HWMON_MIN_FREQ, 0x8C,
|
||||
ALL_CPUS_PWR_CLPS_DIS_V3, 0x1,
|
||||
STOR_CLK_SCALE_DIS, 0x1,
|
||||
};
|
||||
|
||||
int resources_cpu_boost[] = {
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
MIN_FREQ_BIG_CORE_0, 0x3E8,
|
||||
};
|
||||
|
||||
int resources_interaction_fling_boost[] = {
|
||||
CPUBW_HWMON_MIN_FREQ, 0x33,
|
||||
MIN_FREQ_BIG_CORE_0, 0x3E8,
|
||||
MIN_FREQ_LITTLE_CORE_0, 0x3E8,
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
// SCHED_GROUP_ON, 0x1,
|
||||
};
|
||||
|
||||
int resources_interaction_boost[] = {
|
||||
MIN_FREQ_BIG_CORE_0, 0x3E8,
|
||||
};
|
||||
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
/* Skip other hints in power save mode */
|
||||
if (current_power_profile == PROFILE_POWER_SAVE)
|
||||
return HINT_HANDLED;
|
||||
|
||||
if (hint == POWER_HINT_INTERACTION) {
|
||||
duration = data ? *((int *)data) : 500;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||
if (elapsed_time > 750000)
|
||||
elapsed_time = 750000;
|
||||
/**
|
||||
* Don't hint if it's been less than 250ms since last boost
|
||||
* also detect if we're doing anything resembling a fling
|
||||
* support additional boosting in case of flings
|
||||
*/
|
||||
else if (elapsed_time < 250000 && duration <= 750)
|
||||
return HINT_HANDLED;
|
||||
|
||||
s_previous_boost_timespec = cur_boost_timespec;
|
||||
|
||||
if (duration >= 1500) {
|
||||
interaction(duration, ARRAY_SIZE(resources_interaction_fling_boost),
|
||||
resources_interaction_fling_boost);
|
||||
} else {
|
||||
interaction(duration, ARRAY_SIZE(resources_interaction_boost),
|
||||
resources_interaction_boost);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_LAUNCH) {
|
||||
duration = 2000;
|
||||
|
||||
interaction(duration, ARRAY_SIZE(resources_launch),
|
||||
resources_launch);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
duration = *(int32_t *)data / 1000;
|
||||
if (duration > 0) {
|
||||
interaction(duration, ARRAY_SIZE(resources_cpu_boost),
|
||||
resources_cpu_boost);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_VIDEO_ENCODE)
|
||||
return process_video_encode_hint(data);
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int set_interactive_override(__unused struct power_module *module, int on)
|
||||
{
|
||||
return HINT_HANDLED; /* Don't excecute this code path, not in use */
|
||||
char governor[80];
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
int resource_values[] = {}; /* dummy node */
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGI("Display Off hint start");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} else {
|
||||
/* Display on */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID);
|
||||
ALOGI("Display Off hint stop");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
321
power/power-8998.c
Normal file
321
power/power-8998.c
Normal file
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
|
||||
static int current_power_profile = PROFILE_BALANCED;
|
||||
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
int get_number_of_profiles() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
static int profile_high_performance[] = {
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
ALL_CPUS_PWR_CLPS_DIS_V3, 0x1,
|
||||
CPUS_ONLINE_MIN_BIG, 0x2,
|
||||
CPUS_ONLINE_MIN_LITTLE, 0x2,
|
||||
MIN_FREQ_BIG_CORE_0, 0xFFF,
|
||||
MIN_FREQ_LITTLE_CORE_0, 0xFFF,
|
||||
};
|
||||
|
||||
static int profile_power_save[] = {
|
||||
CPUS_ONLINE_MAX_LIMIT_BIG, 0x1,
|
||||
MAX_FREQ_BIG_CORE_0, 0x3E8,
|
||||
MAX_FREQ_LITTLE_CORE_0, 0x3E8,
|
||||
};
|
||||
|
||||
static int profile_bias_power[] = {
|
||||
MAX_FREQ_BIG_CORE_0, 0x514,
|
||||
MAX_FREQ_LITTLE_CORE_0, 0x3E8,
|
||||
};
|
||||
|
||||
static int profile_bias_performance[] = {
|
||||
CPUS_ONLINE_MAX_LIMIT_BIG, 0x2,
|
||||
CPUS_ONLINE_MAX_LIMIT_LITTLE, 0x2,
|
||||
MIN_FREQ_BIG_CORE_0, 0x578,
|
||||
};
|
||||
|
||||
static void set_power_profile(int profile) {
|
||||
|
||||
if (profile == current_power_profile)
|
||||
return;
|
||||
|
||||
ALOGV("%s: Profile=%d", __func__, profile);
|
||||
|
||||
if (current_power_profile != PROFILE_BALANCED) {
|
||||
undo_hint_action(DEFAULT_PROFILE_HINT_ID);
|
||||
ALOGV("%s: Hint undone", __func__);
|
||||
}
|
||||
|
||||
if (profile == PROFILE_POWER_SAVE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_power_save,
|
||||
ARRAY_SIZE(profile_power_save));
|
||||
ALOGD("%s: Set powersave mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_HIGH_PERFORMANCE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_high_performance,
|
||||
ARRAY_SIZE(profile_high_performance));
|
||||
ALOGD("%s: Set performance mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_BIAS_POWER) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_power,
|
||||
ARRAY_SIZE(profile_bias_power));
|
||||
ALOGD("%s: Set bias power mode", __func__);
|
||||
|
||||
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
|
||||
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
|
||||
ARRAY_SIZE(profile_bias_performance));
|
||||
ALOGD("%s: Set bias perf mode", __func__);
|
||||
|
||||
}
|
||||
|
||||
current_power_profile = profile;
|
||||
}
|
||||
|
||||
static int process_video_encode_hint(void *metadata)
|
||||
{
|
||||
char governor[80];
|
||||
struct video_encode_metadata_t video_encode_metadata;
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
/* Initialize encode metadata struct fields */
|
||||
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
|
||||
video_encode_metadata.state = -1;
|
||||
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
|
||||
|
||||
if (metadata) {
|
||||
if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
|
||||
-1) {
|
||||
ALOGE("Error occurred while parsing metadata.");
|
||||
return HINT_NONE;
|
||||
}
|
||||
} else {
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (video_encode_metadata.state == 1) {
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
/* 1. cpufreq params
|
||||
* -above_hispeed_delay for LVT - 40ms
|
||||
* -go hispeed load for LVT - 95
|
||||
* -hispeed freq for LVT - 556 MHz
|
||||
* -target load for LVT - 90
|
||||
* -above hispeed delay for sLVT - 40ms
|
||||
* -go hispeed load for sLVT - 95
|
||||
* -hispeed freq for sLVT - 806 MHz
|
||||
* -target load for sLVT - 90
|
||||
* 2. bus DCVS set to V2 config:
|
||||
* -low power ceil mpbs - 2500
|
||||
* -low power io percent - 50
|
||||
* 3. hysteresis optimization
|
||||
* -bus dcvs hysteresis tuning
|
||||
* -sample_ms of 10 ms
|
||||
*/
|
||||
int resource_values[] = {
|
||||
ABOVE_HISPEED_DELAY_BIG, 0x4,
|
||||
GO_HISPEED_LOAD_BIG, 0x5F,
|
||||
HISPEED_FREQ_BIG, 0x326,
|
||||
TARGET_LOADS_BIG, 0x5A,
|
||||
ABOVE_HISPEED_DELAY_LITTLE, 0x4,
|
||||
GO_HISPEED_LOAD_LITTLE, 0x5F,
|
||||
HISPEED_FREQ_LITTLE, 0x22C,
|
||||
TARGET_LOADS_LITTLE, 0x5A,
|
||||
LOW_POWER_CEIL_MBPS, 0x9C4,
|
||||
LOW_POWER_IO_PERCENT, 0x32,
|
||||
CPUBW_HWMON_V1, 0x0,
|
||||
CPUBW_HWMON_SAMPLE_MS, 0xA,
|
||||
};
|
||||
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
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))) {
|
||||
undo_hint_action(video_encode_metadata.hint_id);
|
||||
ALOGI("Video Encode hint stop");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int power_hint_override(__unused struct power_module *module,
|
||||
power_hint_t hint, void *data)
|
||||
{
|
||||
static struct timespec s_previous_boost_timespec;
|
||||
struct timespec cur_boost_timespec;
|
||||
long long elapsed_time;
|
||||
int duration;
|
||||
|
||||
int resources_launch[] = {
|
||||
SCHED_BOOST_ON_V3, 0x1,
|
||||
MAX_FREQ_BIG_CORE_0, 0x939,
|
||||
MAX_FREQ_LITTLE_CORE_0, 0xFFF,
|
||||
MIN_FREQ_BIG_CORE_0, 0xFFF,
|
||||
MIN_FREQ_LITTLE_CORE_0, 0xFFF,
|
||||
CPUBW_HWMON_MIN_FREQ, 0x8C,
|
||||
ALL_CPUS_PWR_CLPS_DIS_V3, 0x1,
|
||||
STOR_CLK_SCALE_DIS, 0x1,
|
||||
};
|
||||
|
||||
int resources_cpu_boost[] = {
|
||||
SCHED_BOOST_ON_V3, 0x2,
|
||||
};
|
||||
|
||||
int resources_interaction_fling_boost[] = {
|
||||
CPUBW_HWMON_MIN_FREQ, 0x33,
|
||||
MIN_FREQ_BIG_CORE_0, 0x3E8,
|
||||
MIN_FREQ_LITTLE_CORE_0, 0x3E8,
|
||||
SCHED_BOOST_ON_V3, 0x2,
|
||||
};
|
||||
|
||||
int resources_interaction_boost[] = {
|
||||
MIN_FREQ_BIG_CORE_0, 0x3E8,
|
||||
};
|
||||
|
||||
if (hint == POWER_HINT_SET_PROFILE) {
|
||||
set_power_profile(*(int32_t *)data);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
/* Skip other hints in power save mode */
|
||||
if (current_power_profile == PROFILE_POWER_SAVE)
|
||||
return HINT_HANDLED;
|
||||
|
||||
if (hint == POWER_HINT_INTERACTION) {
|
||||
duration = data ? *((int *)data) : 500;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||
if (elapsed_time > 750000)
|
||||
elapsed_time = 750000;
|
||||
/**
|
||||
* Don't hint if it's been less than 250ms since last boost
|
||||
* also detect if we're doing anything resembling a fling
|
||||
* support additional boosting in case of flings
|
||||
*/
|
||||
else if (elapsed_time < 250000 && duration <= 750)
|
||||
return HINT_HANDLED;
|
||||
|
||||
s_previous_boost_timespec = cur_boost_timespec;
|
||||
|
||||
if (duration >= 1500) {
|
||||
interaction(duration, ARRAY_SIZE(resources_interaction_fling_boost),
|
||||
resources_interaction_fling_boost);
|
||||
} else {
|
||||
interaction(duration, ARRAY_SIZE(resources_interaction_boost),
|
||||
resources_interaction_boost);
|
||||
}
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_LAUNCH) {
|
||||
duration = 2000;
|
||||
|
||||
interaction(duration, ARRAY_SIZE(resources_launch),
|
||||
resources_launch);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_CPU_BOOST) {
|
||||
duration = *(int32_t *)data / 1000;
|
||||
if (duration > 0) {
|
||||
interaction(duration, ARRAY_SIZE(resources_cpu_boost),
|
||||
resources_cpu_boost);
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (hint == POWER_HINT_VIDEO_ENCODE)
|
||||
return process_video_encode_hint(data);
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int set_interactive_override(__unused struct power_module *module, int on)
|
||||
{
|
||||
return HINT_HANDLED; /* Don't excecute this code path, not in use */
|
||||
char governor[80];
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
int resource_values[] = {}; /* dummy node */
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
ALOGI("Display Off hint start");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
} else {
|
||||
/* Display on */
|
||||
if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID);
|
||||
ALOGI("Display Off hint stop");
|
||||
return HINT_HANDLED;
|
||||
}
|
||||
}
|
||||
return HINT_NONE;
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
#define MPDECISION_SLACK_MAX_NODE "/sys/module/msm_mpdecision/slack_time_max_us"
|
||||
#define MPDECISION_SLACK_MIN_NODE "/sys/module/msm_mpdecision/slack_time_min_us"
|
||||
#define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
|
||||
|
||||
#define ONDEMAND_GOVERNOR "ondemand"
|
||||
#define INTERACTIVE_GOVERNOR "interactive"
|
||||
#define MSMDCVS_GOVERNOR "msm-dcvs"
|
||||
@@ -41,9 +42,19 @@
|
||||
#define HINT_HANDLED (0)
|
||||
#define HINT_NONE (-1)
|
||||
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
|
||||
enum CPU_GOV_CHECK {
|
||||
CPU0 = 0,
|
||||
CPU1 = 1,
|
||||
CPU2 = 2,
|
||||
CPU3 = 3
|
||||
};
|
||||
|
||||
enum {
|
||||
PROFILE_POWER_SAVE = 0,
|
||||
PROFILE_BALANCED,
|
||||
PROFILE_HIGH_PERFORMANCE,
|
||||
PROFILE_BIAS_POWER,
|
||||
PROFILE_BIAS_PERFORMANCE
|
||||
};
|
||||
|
||||
24
power/power-feature-default.c
Normal file
24
power/power-feature-default.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <hardware/power.h>
|
||||
#include "power-feature.h"
|
||||
|
||||
void set_device_specific_feature(struct power_module *module __unused,
|
||||
feature_t feature __unused, int state __unused)
|
||||
{
|
||||
}
|
||||
|
||||
24
power/power-feature.h
Normal file
24
power/power-feature.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _QCOM_POWER_FEATURE_H
|
||||
#define _QCOM_POWER_FEATURE_H
|
||||
|
||||
#include <hardware/power.h>
|
||||
|
||||
void set_device_specific_feature(struct power_module *module, feature_t feature, int state);
|
||||
|
||||
#endif
|
||||
396
power/power.c
396
power/power.c
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014, The CyanogenMod Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@@ -41,48 +42,31 @@
|
||||
#include <utils/Log.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/power.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "metadata-defs.h"
|
||||
#include "hint-data.h"
|
||||
#include "performance.h"
|
||||
#include "power-common.h"
|
||||
#include "power-feature.h"
|
||||
|
||||
static int saved_dcvs_cpu0_slack_max = -1;
|
||||
static int saved_dcvs_cpu0_slack_min = -1;
|
||||
static int saved_mpdecision_slack_max = -1;
|
||||
static int saved_mpdecision_slack_min = -1;
|
||||
static int saved_interactive_mode = -1;
|
||||
static int slack_node_rw_failed = 0;
|
||||
static int display_hint_sent;
|
||||
int display_boost;
|
||||
|
||||
static int power_device_open(const hw_module_t* module, const char* name,
|
||||
hw_device_t** device);
|
||||
|
||||
static struct hw_module_methods_t power_module_methods = {
|
||||
.open = power_device_open,
|
||||
.open = NULL,
|
||||
};
|
||||
|
||||
static void power_init(struct power_module *module)
|
||||
static pthread_mutex_t hint_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static void power_init(__attribute__((unused))struct power_module *module)
|
||||
{
|
||||
ALOGI("QCOM power HAL initing.");
|
||||
|
||||
int fd;
|
||||
char buf[10] = {0};
|
||||
|
||||
fd = open("/sys/devices/soc0/soc_id", O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
if (read(fd, buf, sizeof(buf) - 1) == -1) {
|
||||
ALOGW("Unable to read soc_id");
|
||||
} else {
|
||||
int soc_id = atoi(buf);
|
||||
if (soc_id == 194 || (soc_id >= 208 && soc_id <= 218) || soc_id == 178) {
|
||||
display_boost = 1;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
static void process_video_decode_hint(void *metadata)
|
||||
@@ -121,17 +105,18 @@ static void process_video_decode_hint(void *metadata)
|
||||
int resource_values[] = {THREAD_MIGRATION_SYNC_OFF};
|
||||
|
||||
perform_hint_action(video_decode_metadata.hint_id,
|
||||
resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
int resource_values[] = {TR_MS_30, HISPEED_LOAD_90, HS_FREQ_1026, THREAD_MIGRATION_SYNC_OFF};
|
||||
|
||||
perform_hint_action(video_decode_metadata.hint_id,
|
||||
resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
}
|
||||
} else if (video_decode_metadata.state == 0) {
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
undo_hint_action(video_decode_metadata.hint_id);
|
||||
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
undo_hint_action(video_decode_metadata.hint_id);
|
||||
@@ -171,14 +156,14 @@ static void process_video_encode_hint(void *metadata)
|
||||
int resource_values[] = {IO_BUSY_OFF, SAMPLING_DOWN_FACTOR_1, THREAD_MIGRATION_SYNC_OFF};
|
||||
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
|
||||
int resource_values[] = {TR_MS_30, HISPEED_LOAD_90, HS_FREQ_1026, THREAD_MIGRATION_SYNC_OFF,
|
||||
INTERACTIVE_IO_BUSY_OFF};
|
||||
|
||||
perform_hint_action(video_encode_metadata.hint_id,
|
||||
resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
}
|
||||
} else if (video_encode_metadata.state == 0) {
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
@@ -191,40 +176,33 @@ static void process_video_encode_hint(void *metadata)
|
||||
}
|
||||
}
|
||||
|
||||
int __attribute__ ((weak)) power_hint_override(struct power_module *module, power_hint_t hint,
|
||||
void *data)
|
||||
int __attribute__ ((weak)) power_hint_override(
|
||||
__attribute__((unused)) struct power_module *module,
|
||||
__attribute__((unused)) power_hint_t hint,
|
||||
__attribute__((unused)) void *data)
|
||||
{
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
/* Declare function before use */
|
||||
void interaction(int duration, int num_args, int opt_list[]);
|
||||
extern void interaction(int duration, int num_args, int opt_list[]);
|
||||
|
||||
static void power_hint(struct power_module *module, power_hint_t hint,
|
||||
static void power_hint(__attribute__((unused)) struct power_module *module, power_hint_t hint,
|
||||
void *data)
|
||||
{
|
||||
pthread_mutex_lock(&hint_mutex);
|
||||
|
||||
/* Check if this hint has been overridden. */
|
||||
if (power_hint_override(module, hint, data) == HINT_HANDLED) {
|
||||
/* The power_hint has been handled. We can skip the rest. */
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch(hint) {
|
||||
case POWER_HINT_VSYNC:
|
||||
break;
|
||||
case POWER_HINT_SUSTAINED_PERFORMANCE:
|
||||
ALOGI("Sustained perf power hint not handled in power_hint_override");
|
||||
break;
|
||||
case POWER_HINT_VR_MODE:
|
||||
ALOGI("VR mode power hint not handled in power_hint_override");
|
||||
break;
|
||||
case POWER_HINT_INTERACTION:
|
||||
{
|
||||
int resources[] = {0x702, 0x20F, 0x30F};
|
||||
int duration = 3000;
|
||||
|
||||
interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
|
||||
}
|
||||
case POWER_HINT_CPU_BOOST:
|
||||
case POWER_HINT_SET_PROFILE:
|
||||
case POWER_HINT_LOW_POWER:
|
||||
break;
|
||||
case POWER_HINT_VIDEO_ENCODE:
|
||||
process_video_encode_hint(data);
|
||||
@@ -232,14 +210,30 @@ static void power_hint(struct power_module *module, power_hint_t hint,
|
||||
case POWER_HINT_VIDEO_DECODE:
|
||||
process_video_decode_hint(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
pthread_mutex_unlock(&hint_mutex);
|
||||
}
|
||||
|
||||
int __attribute__ ((weak)) set_interactive_override(struct power_module *module, int on)
|
||||
int __attribute__ ((weak)) set_interactive_override(
|
||||
__attribute__((unused)) struct power_module *module,
|
||||
__attribute__((unused)) int on)
|
||||
{
|
||||
return HINT_NONE;
|
||||
}
|
||||
|
||||
int __attribute__ ((weak)) get_number_of_profiles()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SET_INTERACTIVE_EXT
|
||||
extern void cm_power_set_interactive_ext(int on);
|
||||
#endif
|
||||
|
||||
void set_interactive(struct power_module *module, int on)
|
||||
{
|
||||
char governor[80];
|
||||
@@ -247,137 +241,135 @@ void set_interactive(struct power_module *module, int on)
|
||||
struct video_encode_metadata_t video_encode_metadata;
|
||||
int rc = 0;
|
||||
|
||||
if (!on) {
|
||||
/* Send Display OFF hint to perf HAL */
|
||||
perf_hint_enable(VENDOR_HINT_DISPLAY_OFF, 0);
|
||||
} else {
|
||||
/* Send Display ON hint to perf HAL */
|
||||
perf_hint_enable(VENDOR_HINT_DISPLAY_ON, 0);
|
||||
}
|
||||
pthread_mutex_lock(&hint_mutex);
|
||||
|
||||
/**
|
||||
* Ignore consecutive display-off hints
|
||||
* Consecutive display-on hints are already handled
|
||||
*/
|
||||
if (display_hint_sent && !on)
|
||||
goto out;
|
||||
|
||||
display_hint_sent = !on;
|
||||
|
||||
#ifdef SET_INTERACTIVE_EXT
|
||||
cm_power_set_interactive_ext(on);
|
||||
#endif
|
||||
|
||||
if (set_interactive_override(module, on) == HINT_HANDLED) {
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ALOGI("Got set_interactive hint");
|
||||
|
||||
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
|
||||
ALOGE("Can't obtain scaling governor.");
|
||||
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!on) {
|
||||
/* Display off. */
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
int resource_values[] = {DISPLAY_OFF, MS_500, THREAD_MIGRATION_SYNC_OFF};
|
||||
int resource_values[] = { MS_500, 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;
|
||||
}
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} else 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;
|
||||
}
|
||||
perform_hint_action(DISPLAY_STATE_HINT_ID,
|
||||
resource_values, ARRAY_SIZE(resource_values));
|
||||
} else if ((strncmp(governor, MSMDCVS_GOVERNOR, strlen(MSMDCVS_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(MSMDCVS_GOVERNOR))) {
|
||||
if (saved_interactive_mode == 1){
|
||||
/* Display turned off. */
|
||||
if (sysfs_read(DCVS_CPU0_SLACK_MAX_NODE, tmp_str, NODE_MAX - 1)) {
|
||||
/* Display turned off. */
|
||||
if (sysfs_read(DCVS_CPU0_SLACK_MAX_NODE, tmp_str, NODE_MAX - 1)) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to read from %s", DCVS_CPU0_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
} else {
|
||||
saved_dcvs_cpu0_slack_max = atoi(tmp_str);
|
||||
}
|
||||
|
||||
if (sysfs_read(DCVS_CPU0_SLACK_MIN_NODE, tmp_str, NODE_MAX - 1)) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to read from %s", DCVS_CPU0_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
} else {
|
||||
saved_dcvs_cpu0_slack_min = atoi(tmp_str);
|
||||
}
|
||||
|
||||
if (sysfs_read(MPDECISION_SLACK_MAX_NODE, tmp_str, NODE_MAX - 1)) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to read from %s", MPDECISION_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
} else {
|
||||
saved_mpdecision_slack_max = atoi(tmp_str);
|
||||
}
|
||||
|
||||
if (sysfs_read(MPDECISION_SLACK_MIN_NODE, tmp_str, NODE_MAX - 1)) {
|
||||
if(!slack_node_rw_failed) {
|
||||
ALOGE("Failed to read from %s", MPDECISION_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
} else {
|
||||
saved_mpdecision_slack_min = atoi(tmp_str);
|
||||
}
|
||||
|
||||
/* Write new values. */
|
||||
if (saved_dcvs_cpu0_slack_max != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_dcvs_cpu0_slack_max);
|
||||
|
||||
if (sysfs_write(DCVS_CPU0_SLACK_MAX_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to read from %s", DCVS_CPU0_SLACK_MAX_NODE);
|
||||
ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
} else {
|
||||
saved_dcvs_cpu0_slack_max = atoi(tmp_str);
|
||||
}
|
||||
}
|
||||
|
||||
if (sysfs_read(DCVS_CPU0_SLACK_MIN_NODE, tmp_str, NODE_MAX - 1)) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to read from %s", DCVS_CPU0_SLACK_MIN_NODE);
|
||||
}
|
||||
if (saved_dcvs_cpu0_slack_min != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_dcvs_cpu0_slack_min);
|
||||
|
||||
rc = 1;
|
||||
} else {
|
||||
saved_dcvs_cpu0_slack_min = atoi(tmp_str);
|
||||
}
|
||||
|
||||
if (sysfs_read(MPDECISION_SLACK_MAX_NODE, tmp_str, NODE_MAX - 1)) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to read from %s", MPDECISION_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
} else {
|
||||
saved_mpdecision_slack_max = atoi(tmp_str);
|
||||
}
|
||||
|
||||
if (sysfs_read(MPDECISION_SLACK_MIN_NODE, tmp_str, NODE_MAX - 1)) {
|
||||
if (sysfs_write(DCVS_CPU0_SLACK_MIN_NODE, tmp_str) != 0) {
|
||||
if(!slack_node_rw_failed) {
|
||||
ALOGE("Failed to read from %s", MPDECISION_SLACK_MIN_NODE);
|
||||
ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
} else {
|
||||
saved_mpdecision_slack_min = atoi(tmp_str);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write new values. */
|
||||
if (saved_dcvs_cpu0_slack_max != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_dcvs_cpu0_slack_max);
|
||||
if (saved_mpdecision_slack_max != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_mpdecision_slack_max);
|
||||
|
||||
if (sysfs_write(DCVS_CPU0_SLACK_MAX_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
if (sysfs_write(MPDECISION_SLACK_MAX_NODE, tmp_str) != 0) {
|
||||
if(!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", MPDECISION_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (saved_dcvs_cpu0_slack_min != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_dcvs_cpu0_slack_min);
|
||||
if (saved_mpdecision_slack_min != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_mpdecision_slack_min);
|
||||
|
||||
if (sysfs_write(DCVS_CPU0_SLACK_MIN_NODE, tmp_str) != 0) {
|
||||
if(!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
if (sysfs_write(MPDECISION_SLACK_MIN_NODE, tmp_str) != 0) {
|
||||
if(!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", MPDECISION_SLACK_MIN_NODE);
|
||||
}
|
||||
}
|
||||
|
||||
if (saved_mpdecision_slack_max != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_mpdecision_slack_max);
|
||||
|
||||
if (sysfs_write(MPDECISION_SLACK_MAX_NODE, tmp_str) != 0) {
|
||||
if(!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", MPDECISION_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (saved_mpdecision_slack_min != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_mpdecision_slack_min);
|
||||
|
||||
if (sysfs_write(MPDECISION_SLACK_MIN_NODE, tmp_str) != 0) {
|
||||
if(!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", MPDECISION_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
}
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,61 +380,57 @@ void set_interactive(struct power_module *module, int on)
|
||||
if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
|
||||
undo_hint_action(DISPLAY_STATE_HINT_ID);
|
||||
display_hint_sent = 0;
|
||||
} else 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;
|
||||
} else if ((strncmp(governor, MSMDCVS_GOVERNOR, strlen(MSMDCVS_GOVERNOR)) == 0) &&
|
||||
} else if ((strncmp(governor, MSMDCVS_GOVERNOR, strlen(MSMDCVS_GOVERNOR)) == 0) &&
|
||||
(strlen(governor) == strlen(MSMDCVS_GOVERNOR))) {
|
||||
if (saved_interactive_mode == -1 || saved_interactive_mode == 0) {
|
||||
/* Display turned on. Restore if possible. */
|
||||
if (saved_dcvs_cpu0_slack_max != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", saved_dcvs_cpu0_slack_max);
|
||||
/* Display turned on. Restore if possible. */
|
||||
if (saved_dcvs_cpu0_slack_max != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", saved_dcvs_cpu0_slack_max);
|
||||
|
||||
if (sysfs_write(DCVS_CPU0_SLACK_MAX_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
if (sysfs_write(DCVS_CPU0_SLACK_MAX_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (saved_dcvs_cpu0_slack_min != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", saved_dcvs_cpu0_slack_min);
|
||||
if (saved_dcvs_cpu0_slack_min != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", saved_dcvs_cpu0_slack_min);
|
||||
|
||||
if (sysfs_write(DCVS_CPU0_SLACK_MIN_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
if (sysfs_write(DCVS_CPU0_SLACK_MIN_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (saved_mpdecision_slack_max != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", saved_mpdecision_slack_max);
|
||||
if (saved_mpdecision_slack_max != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", saved_mpdecision_slack_max);
|
||||
|
||||
if (sysfs_write(MPDECISION_SLACK_MAX_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", MPDECISION_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
if (sysfs_write(MPDECISION_SLACK_MAX_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", MPDECISION_SLACK_MAX_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (saved_mpdecision_slack_min != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", saved_mpdecision_slack_min);
|
||||
if (saved_mpdecision_slack_min != -1) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", saved_mpdecision_slack_min);
|
||||
|
||||
if (sysfs_write(MPDECISION_SLACK_MIN_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", MPDECISION_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
if (sysfs_write(MPDECISION_SLACK_MIN_NODE, tmp_str) != 0) {
|
||||
if (!slack_node_rw_failed) {
|
||||
ALOGE("Failed to write to %s", MPDECISION_SLACK_MIN_NODE);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,59 +438,45 @@ void set_interactive(struct power_module *module, int on)
|
||||
}
|
||||
}
|
||||
|
||||
saved_interactive_mode = !!on;
|
||||
out:
|
||||
pthread_mutex_unlock(&hint_mutex);
|
||||
}
|
||||
|
||||
static int power_device_open(const hw_module_t* module, const char* name,
|
||||
hw_device_t** device)
|
||||
void set_feature(struct power_module *module, feature_t feature, int state)
|
||||
{
|
||||
int status = -EINVAL;
|
||||
if (module && name && device) {
|
||||
if (!strcmp(name, POWER_HARDWARE_MODULE_ID)) {
|
||||
power_module_t *dev = (power_module_t *)malloc(sizeof(*dev));
|
||||
|
||||
if(dev) {
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
|
||||
if(dev) {
|
||||
/* initialize the fields */
|
||||
dev->common.module_api_version = POWER_MODULE_API_VERSION_0_2;
|
||||
dev->common.tag = HARDWARE_DEVICE_TAG;
|
||||
dev->init = power_init;
|
||||
dev->powerHint = power_hint;
|
||||
dev->setInteractive = set_interactive;
|
||||
/* At the moment we support 0.2 APIs */
|
||||
dev->setFeature = NULL,
|
||||
dev->get_number_of_platform_modes = NULL,
|
||||
dev->get_platform_low_power_stats = NULL,
|
||||
dev->get_voter_list = NULL,
|
||||
*device = (hw_device_t*)dev;
|
||||
status = 0;
|
||||
} else {
|
||||
status = -ENOMEM;
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = -ENOMEM;
|
||||
}
|
||||
}
|
||||
#ifdef TAP_TO_WAKE_NODE
|
||||
char tmp_str[NODE_MAX];
|
||||
if (feature == POWER_FEATURE_DOUBLE_TAP_TO_WAKE) {
|
||||
snprintf(tmp_str, NODE_MAX, "%d", state);
|
||||
sysfs_write(TAP_TO_WAKE_NODE, tmp_str);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
set_device_specific_feature(module, feature, state);
|
||||
}
|
||||
|
||||
return status;
|
||||
int get_feature(struct power_module *module __unused, feature_t feature)
|
||||
{
|
||||
if (feature == POWER_FEATURE_SUPPORTED_PROFILES) {
|
||||
return get_number_of_profiles();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct power_module HAL_MODULE_INFO_SYM = {
|
||||
.common = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.module_api_version = POWER_MODULE_API_VERSION_0_2,
|
||||
.module_api_version = POWER_MODULE_API_VERSION_0_3,
|
||||
.hal_api_version = HARDWARE_HAL_API_VERSION,
|
||||
.id = POWER_HARDWARE_MODULE_ID,
|
||||
.name = "QCOM Power HAL",
|
||||
.author = "Qualcomm",
|
||||
.author = "Qualcomm/CyanogenMod",
|
||||
.methods = &power_module_methods,
|
||||
},
|
||||
|
||||
.init = power_init,
|
||||
.powerHint = power_hint,
|
||||
.setInteractive = set_interactive,
|
||||
.setFeature = set_feature,
|
||||
.getFeature = get_feature
|
||||
};
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#include <cutils/log.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include "powerhintparser.h"
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
|
||||
int parsePowerhintXML() {
|
||||
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr currNode;
|
||||
const char *opcode_str, *value_str, *type_str;
|
||||
int opcode = 0, value = 0, type = 0;
|
||||
int numParams = 0;
|
||||
static int hintCount;
|
||||
|
||||
if(access(POWERHINT_XML, F_OK) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
doc = xmlReadFile(POWERHINT_XML, "UTF-8", XML_PARSE_RECOVER);
|
||||
if(!doc) {
|
||||
ALOGE("Document not parsed successfully");
|
||||
return -1;
|
||||
}
|
||||
|
||||
currNode = xmlDocGetRootElement(doc);
|
||||
if(!currNode) {
|
||||
ALOGE("Empty document");
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Confirm the root-element of the tree
|
||||
if(xmlStrcmp(currNode->name, BAD_CAST "Powerhint")) {
|
||||
ALOGE("document of the wrong type, root node != root");
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
return -1;
|
||||
}
|
||||
|
||||
currNode = currNode->xmlChildrenNode;
|
||||
|
||||
for(; currNode != NULL; currNode=currNode->next) {
|
||||
|
||||
if(currNode->type != XML_ELEMENT_NODE)
|
||||
continue;
|
||||
|
||||
xmlNodePtr node = currNode;
|
||||
|
||||
if(hintCount == MAX_HINT) {
|
||||
ALOGE("Number of hints exceeded the max count of %d\n",MAX_HINT);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!xmlStrcmp(node->name, BAD_CAST "Hint")) {
|
||||
if(xmlHasProp(node, BAD_CAST "type")) {
|
||||
type_str = (const char*)xmlGetProp(node, BAD_CAST "type");
|
||||
if (type_str == NULL)
|
||||
{
|
||||
ALOGE("xmlGetProp failed on type");
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
return -1;
|
||||
}
|
||||
type = strtol(type_str, NULL, 16);
|
||||
}
|
||||
|
||||
node = node->children;
|
||||
while(node != NULL) {
|
||||
if(!xmlStrcmp(node->name, BAD_CAST "Resource")) {
|
||||
|
||||
if(xmlHasProp(node, BAD_CAST "opcode")) {
|
||||
opcode_str = (const char*)xmlGetProp(node, BAD_CAST "opcode");
|
||||
if (opcode_str == NULL)
|
||||
{
|
||||
ALOGE("xmlGetProp failed on opcode");
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
return -1;
|
||||
}
|
||||
opcode = strtol(opcode_str, NULL, 16);
|
||||
}
|
||||
if(xmlHasProp(node, BAD_CAST "value")) {
|
||||
value_str = (const char*)xmlGetProp(node, BAD_CAST "value");
|
||||
if (value_str == NULL)
|
||||
{
|
||||
ALOGE("xmlGetProp failed on value");
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
return -1;
|
||||
}
|
||||
value = strtol(value_str, NULL, 16);
|
||||
}
|
||||
if(opcode > 0) {
|
||||
if(numParams < (MAX_PARAM-1)) {
|
||||
powerhint[hintCount].paramList[numParams++] = opcode;
|
||||
powerhint[hintCount].paramList[numParams++] = value;
|
||||
} else {
|
||||
ALOGE("Maximum parameters exceeded for Hint ID %x\n",type);
|
||||
opcode = value = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
opcode = value = 0;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
powerhint[hintCount].type = type;
|
||||
powerhint[hintCount].numParams = numParams;
|
||||
numParams = 0;
|
||||
}
|
||||
hintCount++;
|
||||
}
|
||||
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int* getPowerhint(int hint_id, int *params) {
|
||||
|
||||
int *result = NULL;
|
||||
|
||||
if(!hint_id)
|
||||
return result;
|
||||
|
||||
ALOGI("Powerhal hint received=%x\n",hint_id);
|
||||
|
||||
if(!powerhint[0].numParams) {
|
||||
parsePowerhintXML();
|
||||
}
|
||||
|
||||
for(int i = 0; i < MAX_HINT; i++) {
|
||||
if(hint_id == powerhint[i].type) {
|
||||
*params = powerhint[i].numParams;
|
||||
result = powerhint[i].paramList;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*for (int j = 0; j < *params; j++)
|
||||
ALOGI("Powerhal resource again%x = \n", result[j]);*/
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __POWERHINTPARSER__
|
||||
#define __POWERHINTPARSER__
|
||||
|
||||
#define POWERHINT_XML "/vendor/etc/powerhint.xml"
|
||||
#define MAX_HINT 6
|
||||
#define MAX_PARAM 30
|
||||
|
||||
typedef struct perflock_param_t {
|
||||
int type;
|
||||
int numParams;
|
||||
int paramList[MAX_PARAM];//static limit on number of hints - 15
|
||||
}perflock_param_t;
|
||||
|
||||
static perflock_param_t powerhint[MAX_HINT];
|
||||
|
||||
int parsePowerhintXML();
|
||||
int *getPowerhint(int, int*);
|
||||
|
||||
#endif /* __POWERHINTPARSER__ */
|
||||
213
power/utils.c
213
power/utils.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2013,2015-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@@ -31,8 +31,9 @@
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "list.h"
|
||||
@@ -42,6 +43,12 @@
|
||||
#define LOG_TAG "QCOM PowerHAL"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#define USINSEC 1000000L
|
||||
#define NSINUS 1000L
|
||||
|
||||
#define SOC_ID_0 "/sys/devices/soc0/soc_id"
|
||||
#define SOC_ID_1 "/sys/devices/system/soc/soc0/id"
|
||||
|
||||
char scaling_gov_path[4][80] ={
|
||||
"sys/devices/system/cpu/cpu0/cpufreq/scaling_governor",
|
||||
"sys/devices/system/cpu/cpu1/cpufreq/scaling_governor",
|
||||
@@ -49,24 +56,46 @@ char scaling_gov_path[4][80] ={
|
||||
"sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"
|
||||
};
|
||||
|
||||
#define PERF_HAL_PATH "libqti-perfd-client.so"
|
||||
static void *qcopt_handle;
|
||||
static void *iop_handle;
|
||||
static int (*perf_lock_acq)(unsigned long handle, int duration,
|
||||
int list[], int numArgs);
|
||||
static int (*perf_lock_rel)(unsigned long handle);
|
||||
static int (*perf_hint)(int, char *, int, int);
|
||||
static int (*perf_lock_use_profile)(unsigned long handle, int profile);
|
||||
static int (*perf_io_prefetch_start)(int, const char*);
|
||||
static int (*perf_io_prefetch_stop)();
|
||||
static struct list_node active_hint_list_head;
|
||||
static int profile_handle = 0;
|
||||
|
||||
static void *get_qcopt_handle()
|
||||
{
|
||||
char qcopt_lib_path[PATH_MAX] = {0};
|
||||
void *handle = NULL;
|
||||
|
||||
dlerror();
|
||||
|
||||
handle = dlopen(PERF_HAL_PATH, RTLD_NOW);
|
||||
if (property_get("ro.vendor.extension_library", qcopt_lib_path,
|
||||
NULL)) {
|
||||
handle = dlopen(qcopt_lib_path, RTLD_NOW);
|
||||
if (!handle) {
|
||||
ALOGE("Unable to open %s: %s\n", qcopt_lib_path,
|
||||
dlerror());
|
||||
}
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void *get_iop_handle()
|
||||
{
|
||||
char iop_lib_path[PATH_MAX] = {0};
|
||||
void *handle = NULL;
|
||||
|
||||
dlerror();
|
||||
|
||||
handle = dlopen("libqti-iop-client.so", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!handle) {
|
||||
ALOGE("Unable to open %s: %s\n", PERF_HAL_PATH,
|
||||
dlerror());
|
||||
ALOGE("Unable to open prefetcher: %s\n", dlerror());
|
||||
}
|
||||
|
||||
return handle;
|
||||
@@ -84,22 +113,52 @@ static void __attribute__ ((constructor)) initialize(void)
|
||||
* function pointers.
|
||||
*/
|
||||
perf_lock_acq = dlsym(qcopt_handle, "perf_lock_acq");
|
||||
|
||||
if (!perf_lock_acq) {
|
||||
ALOGE("Unable to get perf_lock_acq function handle.\n");
|
||||
goto fail_qcopt;
|
||||
}
|
||||
|
||||
perf_lock_rel = dlsym(qcopt_handle, "perf_lock_rel");
|
||||
|
||||
if (!perf_lock_rel) {
|
||||
ALOGE("Unable to get perf_lock_rel function handle.\n");
|
||||
goto fail_qcopt;
|
||||
}
|
||||
|
||||
perf_hint = dlsym(qcopt_handle, "perf_hint");
|
||||
// optional
|
||||
perf_lock_use_profile = dlsym(qcopt_handle, "perf_lock_use_profile");
|
||||
}
|
||||
|
||||
if (!perf_hint) {
|
||||
ALOGE("Unable to get perf_hint function handle.\n");
|
||||
iop_handle = get_iop_handle();
|
||||
|
||||
if (!iop_handle) {
|
||||
ALOGE("Failed to get prefetcher handle.\n");
|
||||
} else {
|
||||
perf_io_prefetch_start = (int(*)(int, const char *))dlsym(
|
||||
iop_handle, "perf_io_prefetch_start");
|
||||
if (!perf_io_prefetch_start) {
|
||||
goto fail_iop;
|
||||
}
|
||||
|
||||
perf_io_prefetch_stop = (int(*)())dlsym(
|
||||
iop_handle, "perf_io_prefetch_stop");
|
||||
if (!perf_io_prefetch_stop) {
|
||||
goto fail_iop;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
fail_qcopt:
|
||||
perf_lock_acq = NULL;
|
||||
perf_lock_rel = NULL;
|
||||
if (qcopt_handle) {
|
||||
dlclose(qcopt_handle);
|
||||
qcopt_handle = NULL;
|
||||
}
|
||||
|
||||
fail_iop:
|
||||
perf_io_prefetch_start = NULL;
|
||||
perf_io_prefetch_stop = NULL;
|
||||
if (iop_handle) {
|
||||
dlclose(iop_handle);
|
||||
iop_handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +168,10 @@ static void __attribute__ ((destructor)) cleanup(void)
|
||||
if (dlclose(qcopt_handle))
|
||||
ALOGE("Error occurred while closing qc-opt library.");
|
||||
}
|
||||
if (iop_handle) {
|
||||
if (dlclose(iop_handle))
|
||||
ALOGE("Error occurred while closing prefetcher library.");
|
||||
}
|
||||
}
|
||||
|
||||
int sysfs_read(char *path, char *s, int num_bytes)
|
||||
@@ -186,34 +249,25 @@ int get_scaling_governor(char governor[], int size)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (sysfs_read(scaling_gov_path[core_num], governor,
|
||||
size) == -1) {
|
||||
// Can't obtain the scaling governor. Return.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Strip newline at the end.
|
||||
int len = strlen(governor);
|
||||
len--;
|
||||
while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r'))
|
||||
// Strip newline at the end.
|
||||
int len = strlen(governor);
|
||||
len--;
|
||||
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;
|
||||
}
|
||||
|
||||
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] == NULL)
|
||||
if (duration <= 0 || num_args < 1 || opt_list[0] == 0)
|
||||
return;
|
||||
|
||||
if (qcopt_handle) {
|
||||
@@ -223,47 +277,6 @@ void interaction(int duration, int num_args, int opt_list[])
|
||||
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] == NULL)
|
||||
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.");
|
||||
}
|
||||
}
|
||||
return lock_handle;
|
||||
}
|
||||
|
||||
//this is interaction_with_handle using perf_hint instead of
|
||||
//perf_lock_acq
|
||||
int perf_hint_enable(int hint_id , int duration)
|
||||
{
|
||||
int lock_handle = 0;
|
||||
|
||||
if (duration < 0)
|
||||
return 0;
|
||||
|
||||
if (qcopt_handle) {
|
||||
if (perf_hint) {
|
||||
lock_handle = perf_hint(hint_id, NULL, duration, -1);
|
||||
if (lock_handle == -1)
|
||||
ALOGE("Failed to acquire lock.");
|
||||
}
|
||||
}
|
||||
return lock_handle;
|
||||
}
|
||||
|
||||
|
||||
void release_request(int lock_handle) {
|
||||
if (qcopt_handle && perf_lock_rel)
|
||||
perf_lock_rel(lock_handle);
|
||||
}
|
||||
|
||||
void perform_hint_action(int hint_id, int resource_values[], int num_resources)
|
||||
@@ -359,3 +372,55 @@ void undo_initial_hint_action()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set a static profile */
|
||||
void set_profile(int profile)
|
||||
{
|
||||
if (qcopt_handle) {
|
||||
if (perf_lock_use_profile) {
|
||||
profile_handle = perf_lock_use_profile(profile_handle, profile);
|
||||
if (profile_handle == -1)
|
||||
ALOGE("Failed to set profile.");
|
||||
if (profile < 0)
|
||||
profile_handle = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void start_prefetch(int pid, const char* packageName) {
|
||||
if (iop_handle) {
|
||||
if (perf_io_prefetch_start) {
|
||||
perf_io_prefetch_start(pid, packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long long calc_timespan_us(struct timespec start, struct timespec end)
|
||||
{
|
||||
long long diff_in_us = 0;
|
||||
diff_in_us += (end.tv_sec - start.tv_sec) * USINSEC;
|
||||
diff_in_us += (end.tv_nsec - start.tv_nsec) / NSINUS;
|
||||
return diff_in_us;
|
||||
}
|
||||
|
||||
int get_soc_id(void)
|
||||
{
|
||||
int fd;
|
||||
int soc_id = -1;
|
||||
char buf[10] = { 0 };
|
||||
|
||||
if (!access(SOC_ID_0, F_OK))
|
||||
fd = open(SOC_ID_0, O_RDONLY);
|
||||
else
|
||||
fd = open(SOC_ID_1, O_RDONLY);
|
||||
|
||||
if (fd >= 0) {
|
||||
if (read(fd, buf, sizeof(buf) - 1) == -1)
|
||||
ALOGW("Unable to read soc_id");
|
||||
else
|
||||
soc_id = atoi(buf);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return soc_id;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2013,2015-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2012, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@@ -33,7 +33,6 @@ 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 is_interactive_governor(char*);
|
||||
|
||||
void vote_ondemand_io_busy_off();
|
||||
void unvote_ondemand_io_busy_off();
|
||||
@@ -42,6 +41,9 @@ void unvote_ondemand_sdf_low();
|
||||
void perform_hint_action(int hint_id, int resource_values[],
|
||||
int num_resources);
|
||||
void undo_hint_action(int hint_id);
|
||||
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);
|
||||
void undo_initial_hint_action();
|
||||
void set_profile(int profile);
|
||||
void start_prefetch(int pid, const char *packageName);
|
||||
|
||||
long long calc_timespan_us(struct timespec start, struct timespec end);
|
||||
int get_soc_id(void);
|
||||
|
||||
Reference in New Issue
Block a user