diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2019-06-10 07:41:14 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2019-06-10 07:41:14 -0700 |
commit | 0b86470588a5beca1ac9e5bd20a107e7a35bdd9a (patch) | |
tree | ec6b4fe3c7a8ad46607aec899ade3652c9d14176 | |
parent | 0063fe34d4840644fefbf731d63211fa85f1ef45 (diff) | |
parent | 52e7331bd7cdbc20582603c706ff5c56f9159401 (diff) | |
download | vendor_qcom_opensource_power-0b86470588a5beca1ac9e5bd20a107e7a35bdd9a.tar.gz vendor_qcom_opensource_power-0b86470588a5beca1ac9e5bd20a107e7a35bdd9a.tar.bz2 vendor_qcom_opensource_power-0b86470588a5beca1ac9e5bd20a107e7a35bdd9a.zip |
Merge 52e7331bd7cdbc20582603c706ff5c56f9159401 on remote branch
Change-Id: Ic3ba148a50cffca007d0a2440b659d66b2fb4567
-rw-r--r-- | Android.mk | 9 | ||||
-rw-r--r-- | Power.cpp | 102 | ||||
-rw-r--r-- | Power.h | 74 | ||||
-rw-r--r-- | android.hardware.power@1.2-service.rc | 4 | ||||
-rw-r--r-- | config/kona/powerhint.xml | 54 | ||||
-rw-r--r-- | config/msmnile/powerhint.xml | 274 | ||||
-rw-r--r-- | power-common.c (renamed from power.c) | 78 | ||||
-rw-r--r-- | power-common.h | 21 | ||||
-rw-r--r-- | power-msmnile.c | 6 | ||||
-rw-r--r-- | power-vendor-board.mk | 1 | ||||
-rw-r--r-- | power-vendor-product.mk | 10 | ||||
-rw-r--r-- | service.cpp | 81 | ||||
-rw-r--r-- | utils.c | 9 |
13 files changed, 641 insertions, 82 deletions
@@ -7,10 +7,10 @@ ifeq ($(call is-vendor-board-platform,QCOM),true) include $(CLEAR_VARS) LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libxml2 +LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libxml2 libbase libhidlbase libhidltransport libutils android.hardware.power@1.2 LOCAL_HEADER_LIBRARIES += libutils_headers LOCAL_HEADER_LIBRARIES += libhardware_headers -LOCAL_SRC_FILES := power.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c +LOCAL_SRC_FILES := power-common.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c service.cpp Power.cpp LOCAL_C_INCLUDES := external/libxml2/include \ external/icu/icu4c/source/common @@ -79,10 +79,11 @@ ifeq ($(TARGET_USES_INTERACTION_BOOST),true) LOCAL_CFLAGS += -DINTERACTION_BOOST endif -LOCAL_MODULE := power.qcom +LOCAL_MODULE := android.hardware.power@1.2-service +LOCAL_INIT_RC := android.hardware.power@1.2-service.rc LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable LOCAL_VENDOR_MODULE := true -include $(BUILD_SHARED_LIBRARY) +include $(BUILD_EXECUTABLE) endif diff --git a/Power.cpp b/Power.cpp new file mode 100644 index 0000000..81c0a85 --- /dev/null +++ b/Power.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2019, 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_TAG "QTI PowerHAL" + +#include <android/log.h> +#include <utils/Log.h> +#include "Power.h" +#include "power-common.h" + +namespace android { +namespace hardware { +namespace power { +namespace V1_2 { +namespace implementation { + +using ::android::hardware::power::V1_0::Feature; +using ::android::hardware::power::V1_0::PowerHint; +using ::android::hardware::power::V1_0::PowerStatePlatformSleepState; +using ::android::hardware::power::V1_0::Status; +using ::android::hardware::power::V1_1::PowerStateSubsystem; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; + +Power::Power() { + power_init(); +} + +Return<void> Power::setInteractive(bool interactive) { + set_interactive(interactive ? 1:0); + return Void(); +} + +Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) { + + power_hint(static_cast<power_hint_t>(hint), data ? (&data) : NULL); + return Void(); +} + +Return<void> Power::setFeature(Feature feature, bool activate) { + return Void(); +} + +Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) { + + hidl_vec<PowerStatePlatformSleepState> states; + states.resize(0); + + _hidl_cb(states, Status::SUCCESS); + return Void(); +} + +Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) { + + hidl_vec<PowerStateSubsystem> subsystems; + + _hidl_cb(subsystems, Status::SUCCESS); + return Void(); +} + +Return<void> Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) { + + return powerHint(hint, data); +} + +Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) { + + return powerHint(static_cast<PowerHint_1_0> (hint), data); +} + +} // namespace implementation +} // namespace V1_2 +} // namespace power +} // namespace hardware +} // namespace android @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019, 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 ANDROID_HARDWARE_POWER_V1_2_POWER_H +#define ANDROID_HARDWARE_POWER_V1_2_POWER_H + +#include <android/hardware/power/1.2/IPower.h> +#include <hidl/MQDescriptor.h> +#include <hidl/Status.h> +#include <hardware/power.h> + +namespace android { +namespace hardware { +namespace power { +namespace V1_2 { +namespace implementation { + +using ::android::hardware::power::V1_0::Feature; +using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint; +using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint; +using ::android::hardware::power::V1_2::IPower; +using ::android::hardware::Return; +using ::android::hardware::Void; + +struct Power : public IPower { + // Methods from ::android::hardware::power::V1_0::IPower follow. + + Power(); + + Return<void> setInteractive(bool interactive) override; + Return<void> powerHint(PowerHint_1_0 hint, int32_t data) override; + Return<void> setFeature(Feature feature, bool activate) override; + Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override; + + // Methods from ::android::hardware::power::V1_1::IPower follow + Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override; + Return<void> powerHintAsync(PowerHint_1_0 hint, int32_t data) override; + // Methods from ::android::hardware::power::V1_2::IPower follow + Return<void> powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override; +}; + +} // namespace implementation +} // namespace V1_2 +} // namespace power +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_POWER_V1_2_POWER_H diff --git a/android.hardware.power@1.2-service.rc b/android.hardware.power@1.2-service.rc new file mode 100644 index 0000000..8a1c347 --- /dev/null +++ b/android.hardware.power@1.2-service.rc @@ -0,0 +1,4 @@ +service vendor.power-hal-1-2 /vendor/bin/hw/android.hardware.power@1.2-service + class hal + user system + group system diff --git a/config/kona/powerhint.xml b/config/kona/powerhint.xml new file mode 100644 index 0000000..fa338f5 --- /dev/null +++ b/config/kona/powerhint.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8" ?> + +<!-- +/* Copyright (c) 2019, 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. + */ +--> +<HintConfigs> + <Powerhint> + <!--video encode 30 fps--> + <Config + Id="0x00001203" Enable="true" Target="kona" + Resources="" /> + + <!--sustained performance--> + <Config + Id="0x00001206" Enable="true" Target="kona" + Resources=""/> + <!--vr mode--> + <Config + Id="0x00001207" Enable="true" Target="kona" + Resources=""/> + + <!--vr mode sustained performance--> + <Config + Id="0x00001301" Enable="true" Target="kona" + Resources=""/> + </Powerhint> +</HintConfigs> + diff --git a/config/msmnile/powerhint.xml b/config/msmnile/powerhint.xml new file mode 100644 index 0000000..71e9db1 --- /dev/null +++ b/config/msmnile/powerhint.xml @@ -0,0 +1,274 @@ +<?xml version="1.0" encoding="utf-8" ?> + +<!-- +/* Copyright (c) 2019, 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. + */ +--> +<HintConfigs> + <Powerhint> + <!--video encode 30 fps--> + <Config + Id="0x00001203" Enable="true" Target="msmnile" Timeout="0" + Resources="" /> + + <!--sustained performance--> + <!-- B CPU - Cluster min freq ~1.05GHz --> + <!-- L CPU - Cluster min freq ~1.03GHz --> + <!-- B CPU - Cluster max freq ~1.80GHz --> + <!-- GPU - min pwrlevel 2 --> + <!-- GPU - max pwrlevel 0 --> + <!-- Max Prime CPUs 0 --> + <Config + Id="0x00001206" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x420, 0x40800100, 0x40C, 0x40804000, 0x70C, + 0X42804000, 0x2, 0X42808000, 0x0, 0x41004200, 0x0"/> + <!--vr mode--> + <Config + Id="0x00001207" Enable="true" Target="msmnile" Timeout="0" + Resources=""/> + + <!--vr mode sustained performance--> + <Config + Id="0x00001301" Enable="true" Target="msmnile" Timeout="0" + Resources=""/> + + <!-- same settings for all the VR power levels intentionally --> + + <!-- qvr level cpu1 gpu1 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~.2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x0000130A" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- qvr level cpu1 gpu2 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~.2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x0000130B" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- qvr level cpu1 gpu3 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~.2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x0000130C" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- qvr level cpu2 gpu1 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~.2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x0000130D" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- qvr level cpu2 gpu2 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~.2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x0000130E" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- qvr level cpu2 gpu3 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~.2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x0000130F" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- qvr level cpu3 gpu1 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~.2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x00001310" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- qvr level cpu3 gpu2 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~.2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x00001311" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- qvr level cpu3 gpu3 --> + <!-- B CPU - Cluster min freq ~.864 Ghz --> + <!-- B CPU - Cluster max freq ~2.016 Ghz --> + <!-- L CPU - Cluster min freq ~.576 Ghz --> + <!-- L CPU - Cluster max freq ~1.267 Ghz --> + <!-- P CPU - PRIME CPU min freq ~.941 Ghz--> + <!-- P CPU - PRIME CPU max freq ~2.054Ghz --> + <!-- GPU - min pwrlevel 5 (freq 215 Mhz) --> + <!-- GPU - max pwrlevel 0 (freq 600 Mhz) --> + <!-- Min Big CPUs 3 --> + <!-- Min Prime CPUs 1 --> + <!-- Idefinite Duration --> + <Config + Id="0x00001312" Enable="true" Target="msmnile" Timeout="0" + Resources="0x40800000, 0x360, 0x40804000, 0x7E0, 0x40800100, 0x240, 0x40804100, 0x4F3, 0x40800200, 0x3AD, 0x40804200, 0x806, + 0x42804000, 0x5, 0x42808000, 0x0, 0x41000000, 0x3, 0x41000200, 0x1"/> + + <!-- camera general --> + <!--L CPU CORE 0 SCHED LOAD BOOST --> + <!--L CPU CORE 1 SCHED LOAD BOOST --> + <!--L CPU CORE 2 SCHED LOAD BOOST --> + <!--L CPU CORE 3 SCHED LOAD BOOST --> + <!--L CPU - Disable schedutil PL --> + <!--L CPU - Set hispeed load 99 --> + <!--LLC-DDR BWMON - Set sample_ms 10 --> + <!--CPU-LLC BWMON - Set sample_ms 10 --> + <!--LLC-DDR BWMON - Set io_percent 100 --> + <!--CPU-LLC BWMON - Set io_percent 100 --> + <!--CPU-LLC BWMON - Set hyst_length 0 --> + <!--LLC-DDR BWMON - Set hyst_length 0 --> + <!--CPU0-LLC MEM LAT - Set ratio_ceil 100 --> + <Config + Id="0x00001331" Enable="true" Timeout="0" Target="msmnile" + Resources="0x40C68100, 0xFFFFFFF6, 0x40C68110, 0xFFFFFFF6, 0x40C68120, 0xFFFFFFF6, + 0x40C68130, 0xFFFFFFF6,0x41444100, 0, 0x41440100, 0x63, + 0x4300C000, 0xA ,0x41820000, 0xA, 0x43004000, 0x64 ,0x41808000, 0x64, 0x4180C000, 0, 0x43008000, 0, 0x43420000, 0x64"/> + + <!-- camera 60fps --> + <!--L CPU CORE 0 SCHED LOAD BOOST --> + <!--L CPU CORE 1 SCHED LOAD BOOST --> + <!--L CPU CORE 2 SCHED LOAD BOOST --> + <!--L CPU CORE 3 SCHED LOAD BOOST --> + <!--L CPU - Disable schedutil PL --> + <!--L CPU - Set hispeed load 95 --> + <!--LLC-DDR BWMON - Set sample_ms 20 --> + <!--CPU-LLC BWMON - Set sample_ms 20 --> + <Config + Id="0x00001332" Enable="true" Timeout="0" Target="msmnile" + Resources="0x40C68100, 0xFFFFFFF6, 0x40C68110, 0xFFFFFFF6, 0x40C68120, 0xFFFFFFF6, + 0x40C68130, 0xFFFFFFF6,0x41444100, 0, 0x41440100, 0x5F, 0x4300C000, 0x14 ,0x41820000, 0x14"/> + + <!-- camera HFR --> + <!--L CPU CORE 0 SCHED LOAD BOOST --> + <!--L CPU CORE 1 SCHED LOAD BOOST --> + <!--L CPU CORE 2 SCHED LOAD BOOST --> + <!--L CPU CORE 3 SCHED LOAD BOOST --> + <!--LLC-DDR BWMON - Set sample_ms 10 --> + <!--CPU-LLC BWMON - Set sample_ms 10 --> + <Config + Id="0x00001333" Enable="true" Timeout="0" Target="msmnile" + Resources="0x40C68100, 0xFFFFFFF6, 0x40C68110, 0xFFFFFFF6, 0x40C68120, 0xFFFFFFF6, + 0x40C68130, 0xFFFFFFF6, 0x4300C000, 0xA ,0x41820000, 0xA"/> + + <!-- camera 480fps - HFR --> + <!--L CPU CORE 0 SCHED LOAD BOOST --> + <!--L CPU CORE 1 SCHED LOAD BOOST --> + <!--L CPU CORE 2 SCHED LOAD BOOST --> + <!--L CPU CORE 3 SCHED LOAD BOOST --> + <!--LLC-DDR BWMON - Set sample_ms 10 --> + <!--CPU-LLC BWMON - Set sample_ms 10 --> + <Config + Id="0x00001334" Enable="true" Timeout="0" Target="msmnile" + Resources="0x40C68100, 0xFFFFFFF6, 0x40C68110, 0xFFFFFFF6, 0x40C68120, 0xFFFFFFF6, + 0x40C68130, 0xFFFFFFF6, 0x4300C000, 0xA ,0x41820000, 0xA"/> + </Powerhint> +</HintConfigs> + @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2019, 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 @@ -50,14 +50,7 @@ static struct hint_handles handles[NUM_HINTS]; -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, -}; - -static void power_init(struct power_module *module) +void power_init() { ALOGI("Initing"); @@ -67,7 +60,7 @@ static void power_init(struct power_module *module) } } -int __attribute__ ((weak)) power_hint_override(struct power_module *module, power_hint_t hint, +int __attribute__ ((weak)) power_hint_override(power_hint_t hint, void *data) { return HINT_NONE; @@ -76,11 +69,10 @@ int __attribute__ ((weak)) power_hint_override(struct power_module *module, powe /* Declare function before use */ void interaction(int duration, int num_args, int opt_list[]); -static void power_hint(struct power_module *module, power_hint_t hint, - void *data) +void power_hint(power_hint_t hint, void *data) { /* Check if this hint has been overridden. */ - if (power_hint_override(module, hint, data) == HINT_HANDLED) { + if (power_hint_override(hint, data) == HINT_HANDLED) { /* The power_hint has been handled. We can skip the rest. */ return; } @@ -120,12 +112,12 @@ static void power_hint(struct power_module *module, power_hint_t hint, } } -int __attribute__ ((weak)) set_interactive_override(struct power_module *module, int on) +int __attribute__ ((weak)) set_interactive_override(int on) { return HINT_NONE; } -void set_interactive(struct power_module *module, int on) +void set_interactive(int on) { if (!on) { /* Send Display OFF hint to perf HAL */ @@ -135,63 +127,9 @@ void set_interactive(struct power_module *module, int on) perf_hint_enable(VENDOR_HINT_DISPLAY_ON, 0); } - if (set_interactive_override(module, on) == HINT_HANDLED) { + if (set_interactive_override(on) == HINT_HANDLED) { return; } ALOGI("Got set_interactive hint"); } - -static int power_device_open(const hw_module_t* module, const char* name, - hw_device_t** device) -{ - 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; - } - } - } - - return status; -} - -struct power_module HAL_MODULE_INFO_SYM = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .module_api_version = POWER_MODULE_API_VERSION_0_2, - .hal_api_version = HARDWARE_HAL_API_VERSION, - .id = POWER_HARDWARE_MODULE_ID, - .name = "QTI Power HAL", - .author = "QTI", - .methods = &power_module_methods, - }, - - .init = power_init, - .powerHint = power_hint, - .setInteractive = set_interactive, -}; diff --git a/power-common.h b/power-common.h index e374e46..697302a 100644 --- a/power-common.h +++ b/power-common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013, 2018-2019 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 @@ -26,6 +26,13 @@ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef __POWER_COMMON_H__ +#define __POWER_COMMON_H__ + +#ifdef __cplusplus +extern "C" { +#endif + #define NODE_MAX (64) #define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" @@ -42,9 +49,21 @@ #define HINT_HANDLED (0) #define HINT_NONE (-1) +#include <hardware/power.h> + enum CPU_GOV_CHECK { CPU0 = 0, CPU1 = 1, CPU2 = 2, CPU3 = 3 }; + +void power_init(void); +void power_hint(power_hint_t hint, void *data); +void set_interactive(int on); + +#ifdef __cplusplus +} +#endif + +#endif //__POWER_COMMON_H___ diff --git a/power-msmnile.c b/power-msmnile.c index 27a8d25..7000079 100644 --- a/power-msmnile.c +++ b/power-msmnile.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019, 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,7 +48,7 @@ static int display_fd; #define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr" -int set_interactive_override(struct power_module *module, int on) +int set_interactive_override(int on) { static const char *display_on = "1"; static const char *display_off = "0"; @@ -94,7 +94,7 @@ int set_interactive_override(struct power_module *module, int on) void interaction(int duration, int num_args, int opt_list[]); -int power_hint_override(struct power_module *module, power_hint_t hint, void *data) +int power_hint_override(power_hint_t hint, void *data) { int ret_val = HINT_NONE; switch(hint) { diff --git a/power-vendor-board.mk b/power-vendor-board.mk new file mode 100644 index 0000000..23d97aa --- /dev/null +++ b/power-vendor-board.mk @@ -0,0 +1 @@ +TARGET_USES_NON_LEGACY_POWERHAL := true diff --git a/power-vendor-product.mk b/power-vendor-product.mk new file mode 100644 index 0000000..c0dfbc5 --- /dev/null +++ b/power-vendor-product.mk @@ -0,0 +1,10 @@ +#Power product definitions +PRODUCT_PACKAGES += android.hardware.power@1.2-impl +PRODUCT_PACKAGES += android.hardware.power@1.2-service + +#Powerhint File +ifeq ($(TARGET_BOARD_PLATFORM),msmnile) +PRODUCT_COPY_FILES += vendor/qcom/opensource/power/config/msmnile/powerhint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/powerhint.xml +else ifeq ($(TARGET_BOARD_PLATFORM),kona) +PRODUCT_COPY_FILES += vendor/qcom/opensource/power/config/kona/powerhint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/powerhint.xml +endif diff --git a/service.cpp b/service.cpp new file mode 100644 index 0000000..902c661 --- /dev/null +++ b/service.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019, 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_TAG "android.hardware.power@1.2-service" + +#include <android/log.h> +#include <hidl/HidlTransportSupport.h> +#include <hardware/power.h> +#include "Power.h" + +using android::sp; +using android::status_t; +using android::OK; + +// libhwbinder: +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +// Generated HIDL files +using android::hardware::power::V1_2::IPower; +using android::hardware::power::V1_2::implementation::Power; + +int main() { + + status_t status; + android::sp<IPower> service = nullptr; + + ALOGI("Power HAL Service 1.2 is starting."); + + service = new Power(); + if (service == nullptr) { + ALOGE("Can not create an instance of Power HAL interface."); + + goto shutdown; + } + + configureRpcThreadpool(1, true /*callerWillJoin*/); + + status = service->registerAsService(); + if (status != OK) { + ALOGE("Could not register service for Power HAL(%d).", status); + goto shutdown; + } + + ALOGI("Power Service is ready"); + joinRpcThreadpool(); + //Should not pass this line + +shutdown: + // In normal operation, we don't expect the thread pool to exit + + ALOGE("Power Service is shutting down"); + return 1; +} + @@ -52,11 +52,12 @@ char scaling_gov_path[4][80] ={ #define PERF_HAL_PATH "libqti-perfd-client.so" static void *qcopt_handle; -static int (*perf_lock_acq)(unsigned long handle, int duration, +static int (*perf_lock_acq)(int 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_rel)(int handle); +static int (*perf_hint)(int, const char *, int, int); static struct list_node active_hint_list_head; +const char *pkg = "QTI PowerHAL"; static void *get_qcopt_handle() { @@ -253,7 +254,7 @@ int perf_hint_enable(int hint_id , int duration) if (qcopt_handle) { if (perf_hint) { - lock_handle = perf_hint(hint_id, NULL, duration, -1); + lock_handle = perf_hint(hint_id, pkg, duration, -1); if (lock_handle == -1) ALOGE("Failed to acquire lock for hint_id: %X.", hint_id); } |