diff --git a/power/Android.mk b/power/Android.mk index 58c64589..82547a99 100644 --- a/power/Android.mk +++ b/power/Android.mk @@ -9,6 +9,12 @@ include $(CLEAR_VARS) LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/hw LOCAL_SHARED_LIBRARIES := liblog libcutils libdl LOCAL_SRC_FILES := power.c metadata-parser.c utils.c list.c hint-data.c + +# Include target-specific files. +ifeq ($(call is-board-platform-in-list, msm8974), true) +LOCAL_SRC_FILES += power-8974.c +endif + LOCAL_MODULE := power.qcom LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) diff --git a/power/performance.h b/power/performance.h index 457278d5..d7f83bd8 100755 --- a/power/performance.h +++ b/power/performance.h @@ -102,12 +102,14 @@ enum INTERACTIVE_HISPEED_LOAD_LVL { }; enum SYNC_FREQ_LVL { + SYNC_FREQ_300 = 0x1103, SYNC_FREQ_384 = 0x1103, SYNC_FREQ_NONTURBO_MAX = 0x110A, SYNC_FREQ_TURBO = 0x110F, }; enum OPTIMAL_FREQ_LVL { + OPTIMAL_FREQ_300 = 0x1203, OPTIMAL_FREQ_384 = 0x1203, OPTIMAL_FREQ_NONTURBO_MAX = 0x120A, OPTIMAL_FREQ_TURBO = 0x120F, diff --git a/power/power-8974.c b/power/power-8974.c new file mode 100644 index 00000000..5b3a5373 --- /dev/null +++ b/power/power-8974.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 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 + * 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 +#include +#include +#include +#include +#include +#include + +#define LOG_TAG "QCOM PowerHAL" +#include +#include +#include + +#include "utils.h" +#include "metadata-defs.h" +#include "hint-data.h" +#include "performance.h" +#include "power-common.h" + +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. */ + if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) && + (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) { + int resource_values[] = {MS_500, SYNC_FREQ_300, OPTIMAL_FREQ_300}; + + perform_hint_action(DISPLAY_STATE_HINT_ID, + resource_values, sizeof(resource_values)/sizeof(resource_values[0])); + + return HINT_HANDLED; + } + } else { + /* Display on */ + 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; +} diff --git a/power/power-common.h b/power/power-common.h new file mode 100644 index 00000000..c00ce4e3 --- /dev/null +++ b/power/power-common.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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 + * 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 NODE_MAX (64) + +#define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" +#define DCVS_CPU0_SLACK_MAX_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_max_us" +#define DCVS_CPU0_SLACK_MIN_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_min_us" +#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 ONDEMAND_GOVERNOR "ondemand" +#define INTERACTIVE_GOVERNOR "interactive" +#define MSMDCVS_GOVERNOR "msm-dcvs" + +#define HINT_HANDLED (0) +#define HINT_NONE (-1) diff --git a/power/power.c b/power/power.c index 166458d8..488a4b3d 100644 --- a/power/power.c +++ b/power/power.c @@ -46,21 +46,8 @@ #include "metadata-defs.h" #include "hint-data.h" #include "performance.h" +#include "power-common.h" -#define NODE_MAX (64) - -#define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" -#define DCVS_CPU0_SLACK_MAX_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_max_us" -#define DCVS_CPU0_SLACK_MIN_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_min_us" -#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 ONDEMAND_GOVERNOR "ondemand" -#define INTERACTIVE_GOVERNOR "interactive" -#define MSMDCVS_GOVERNOR "msm-dcvs" - -static int saved_ondemand_sampling_down_factor = 4; -static int saved_ondemand_io_is_busy_status = 1; static int saved_dcvs_cpu0_slack_max = -1; static int saved_dcvs_cpu0_slack_min = -1; static int saved_mpdecision_slack_max = -1; @@ -181,14 +168,14 @@ static void process_video_encode_hint(void *metadata) int __attribute__ ((weak)) power_hint_override(struct power_module *module, power_hint_t hint, void *data) { - return -1; + return HINT_NONE; } static void power_hint(struct power_module *module, power_hint_t hint, void *data) { /* Check if this hint has been overridden. */ - if (power_hint_override(module, hint, data) == 0) { + if (power_hint_override(module, hint, data) == HINT_HANDLED) { /* The power_hint has been handled. We can skip the rest. */ return; } @@ -204,13 +191,12 @@ static void power_hint(struct power_module *module, power_hint_t hint, case POWER_HINT_VIDEO_DECODE: process_video_decode_hint(data); break; - } } int __attribute__ ((weak)) set_interactive_override(struct power_module *module, int on) { - return -1; + return HINT_NONE; } void set_interactive(struct power_module *module, int on) @@ -220,7 +206,7 @@ void set_interactive(struct power_module *module, int on) struct video_encode_metadata_t video_encode_metadata; int rc; - if (set_interactive_override(module, on) == 0) { + if (set_interactive_override(module, on) == HINT_HANDLED) { return; } diff --git a/power/utils.c b/power/utils.c index 2c4d4677..87d7bb2f 100644 --- a/power/utils.c +++ b/power/utils.c @@ -26,7 +26,6 @@ * 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 @@ -36,6 +35,7 @@ #include "utils.h" #include "list.h" #include "hint-data.h" +#include "power-common.h" #define LOG_TAG "QCOM PowerHAL" #include diff --git a/power/utils.h b/power/utils.h index 234160f2..cd12c15c 100644 --- a/power/utils.h +++ b/power/utils.h @@ -29,11 +29,6 @@ #include -#define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" -#define ONDEMAND_PATH "/sys/devices/system/cpu/cpufreq/ondemand/" -#define ONDEMAND_IO_BUSY_PATH "/sys/devices/system/cpu/cpufreq/ondemand/io_is_busy" -#define ONDEMAND_SAMPLING_DOWN_PATH "/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor" - 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);