diff --git a/BoardConfig.mk b/BoardConfig.mk
index dbbb6ba..568ec69 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -143,6 +143,10 @@ TARGET_OTA_ASSERT_DEVICE := LG8n,TECNO-LG8n
TARGET_BOARD_PLATFORM := mt6789
BOARD_HAS_MTK_HARDWARE := true
+# Power
+TARGET_TAP_TO_WAKE_NODE := /proc/gesture_function
+TARGET_POWERHAL_MODE_EXT := $(COMMON_PATH)/power/power-mode.cpp
+
# Properties
TARGET_SYSTEM_PROP += $(CONFIGS_PATH)/properties/system.prop
TARGET_VENDOR_PROP += $(CONFIGS_PATH)/properties/vendor.prop
diff --git a/configs/perf/power_app_cfg.xml b/configs/perf/power_app_cfg.xml
new file mode 100644
index 0000000..44461be
--- /dev/null
+++ b/configs/perf/power_app_cfg.xml
@@ -0,0 +1,819 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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able.xml b/configs/perf/powercontable.xml
new file mode 100644
index 0000000..99d29a3
--- /dev/null
+++ b/configs/perf/powercontable.xml
@@ -0,0 +1,864 @@
+
+
+
+ more
+ 6
+ 0
+ 6
+
+
+ more
+ 2
+ 0
+ 2
+
+
+
+ less
+ 20
+ 1
+
+
+
+ more
+ 20
+ 1
+
+
+
+ more
+ 31
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 100
+ 0
+ 0
+
+
+
+ more
+ 100
+ 0
+ 0
+
+
+
+ more
+ 100
+ 0
+ 0
+
+
+
+ more
+ 100
+ 0
+ 0
+
+
+
+ more
+ 100
+ 0
+ 0
+
+
+
+ more
+ 100
+ 0
+ 0
+
+
+
+ less
+ 100
+ 0
+ 100
+
+
+
+ less
+ 100
+ 0
+ 100
+
+
+
+ less
+ 100
+ 0
+ 100
+
+
+
+ less
+ 100
+ 0
+ 100
+
+
+
+ less
+ 100
+ 0
+ 100
+
+
+
+ less
+ 100
+ 0
+ 100
+
+
+
+ less
+ 1000000000
+ 0
+ 1000
+
+
+
+ less
+ 1000000000
+ 0
+ 1000
+
+
+
+ more
+ 1000000000
+ 0
+ 1000
+
+
+
+ more
+ 1000000000
+ 0
+ 1000
+
+
+
+ more
+ 1
+ 0
+ 0
+ dsu_mode^
+
+
+
+ more
+ 15
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 6553599
+ 1
+ 130
+
+
+
+ more
+ 60
+ 0
+
+
+
+ more
+ 99
+ 1
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 2
+ 0
+
+
+
+ more
+ 2
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 31
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 10
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 31
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1000000
+ 33
+
+
+
+ more
+ 1
+ 0
+ 0
+ cm_mgr_camera_enable^
+
+
+
+ more
+ 1
+ 0
+ 0
+ cm_mgr_cpu_map_dram_enable^
+
+
+
+ more
+ 2
+ 0
+ cm_aggr^
+
+
+ more
+ 1
+ 0
+ 1
+
+
+ less
+ 31
+ 0
+ 2
+
+
+ less
+ 31
+ 0
+ 2
+
+
+ more
+ 2000
+ 10
+ 200
+
+
+ more
+ 1000
+ 0
+ 100
+
+
+ more
+ 100
+ 0
+ 80
+
+
+ more
+ 1
+ 0
+ 1
+
+
+ less
+ 1000000000
+ 0
+ 0
+
+
+
+ more
+ 2000000000
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 2000000000
+ -1
+ 798
+
+
+
+ more
+ 25855
+ 0
+ 4
+
+
+
+ more
+ 32767
+ 1
+
+
+
+ more
+ 32767
+ 1
+
+
+
+ less
+ 1
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ less
+ 2
+ 0
+
+
+
+ more
+ 100
+ 0
+ 0
+
+
+
+ more
+ 2
+ 0
+ 0
+
+
+
+ more
+ 20
+ 2
+
+
+
+ more
+ 50
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 1000000000
+ 0
+ 1000000000
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 9
+ 1
+
+
+
+ more
+ 5
+ 0
+
+
+
+ more
+ 100
+ 0
+ 25
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 10000
+ 400
+
+
+
+ more
+ 15
+ 1
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 300
+ 10
+
+
+
+ more
+ 1000
+ 0
+
+
+
+ more
+ 1
+ 0
+ 1
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 7
+ -1
+
+
+
+ more
+ 7
+ -1
+
+
+
+ less
+ 1
+ 0
+
+
+
+ more
+ 100
+ 0
+ 95
+
+
+
+ more
+ 50000000
+ -50000000
+ 1000000
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 1
+ 0
+ 0
+
+
+
+ more
+ 3000000
+ 0
+
+
+
+ more
+ 3000000
+ 0
+
+
+
+ more
+ 3000000
+ 0
+
+
+
+ more
+ 3000000
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+ 1
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 2
+ 0
+ 2
+
+
+
+ more
+ 65535
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ less
+ 100
+ -100
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 200
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 200
+ 0
+
+
+
+ more
+ 200
+ 0
+
+
+
+ more
+ 200
+ 0
+
+
+
+ more
+ 200
+ 0
+
+
+
+ more
+ 6000
+ -6000
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 100
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 100
+ -1
+ -1
+
+
+
+ more
+ 1
+ 0
+
+
+
+ more
+ 200
+ 0
+
+
diff --git a/configs/perf/powerscntbl.xml b/configs/perf/powerscntbl.xml
new file mode 100644
index 0000000..9acdc62
--- /dev/null
+++ b/configs/perf/powerscntbl.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/device.mk b/device.mk
index 1e29edc..223299b 100644
--- a/device.mk
+++ b/device.mk
@@ -403,21 +403,19 @@ PRODUCT_COPY_FILES += \
# Power
PRODUCT_PACKAGES += \
- android.hardware.power-service.lineage-libperfmgr
+ android.hardware.power-service-mediatek \
+ android.hardware.power-V2-ndk_platform.vendor \
+ android.hardware.power@1.3.vendor
PRODUCT_PACKAGES += \
- vendor.mediatek.hardware.mtkpower@1.2-service.stub \
vendor.mediatek.hardware.mtkpower@1.0.vendor \
- vendor.mediatek.hardware.mtkpower@1.1.vendor
+ vendor.mediatek.hardware.mtkpower@1.1.vendor \
+ vendor.mediatek.hardware.mtkpower@1.2.vendor
-PRODUCT_PACKAGES += \
- android.hardware.power@1.3.vendor \
- libperfctl_vendor
-
-# Power | Dummy mtkperf lib
-PRODUCT_PACKAGES += \
- libmtkperf_client_vendor \
- libmtkperf_client
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/perf/power_app_cfg.xml:$(TARGET_COPY_OUT_VENDOR)/etc/power_app_cfg.xml \
+ $(LOCAL_PATH)/configs/perf/powercontable.xml:$(TARGET_COPY_OUT_VENDOR)/etc/powercontable.xml \
+ $(LOCAL_PATH)/configs/perf/powerscntbl.xml:$(TARGET_COPY_OUT_VENDOR)/etc/powerscntbl.xml
# Power configurations
PRODUCT_COPY_FILES += \
@@ -473,11 +471,7 @@ PRODUCT_SHIPPING_API_LEVEL := 31
# Soong namespaces
PRODUCT_SOONG_NAMESPACES += \
$(LOCAL_PATH) \
- hardware/lineage/interfaces/power-libperfmgr \
- hardware/google/interfaces \
- hardware/google/pixel \
hardware/mediatek \
- hardware/mediatek/libmtkperf_client \
hardware/transsion
# Thermal
diff --git a/power/power-mode.cpp b/power/power-mode.cpp
new file mode 100644
index 0000000..cad725e
--- /dev/null
+++ b/power/power-mode.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2021 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include
+#include
+#include
+#include
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace power {
+namespace impl {
+namespace mediatek {
+
+using ::aidl::android::hardware::power::Mode;
+
+bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) {
+ switch (type) {
+ case Mode::DOUBLE_TAP_TO_WAKE:
+ *_aidl_return = true;
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool setDeviceSpecificMode(Mode type, bool enabled) {
+ switch (type) {
+ case Mode::DOUBLE_TAP_TO_WAKE: {
+ ::android::base::WriteStringToFile(enabled ? "cc1" : "cc2", TAP_TO_WAKE_NODE, true);
+ return true;
+ }
+ default:
+ return false;
+ }
+}
+
+} // namespace mediatek
+} // namespace impl
+} // namespace power
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/proprietary-files.txt b/proprietary-files.txt
index 0f0a893..f03fb4f 100644
--- a/proprietary-files.txt
+++ b/proprietary-files.txt
@@ -2635,10 +2635,14 @@ vendor/lib64/libvcodecdrv_header_stub.so
# Misc and Potentially Requred Blobs
vendor/bin/hw/vendor.mediatek.hardware.tranHwInfo@1.0-service
+vendor/bin/fpsgo
+vendor/bin/gbe
vendor/bin/md_monitor
vendor/bin/meta_tst
vendor/bin/mt6660_calibration
vendor/bin/rt5512_calibration
+vendor/etc/init/fpsgo.rc
+vendor/etc/init/gbe.rc
vendor/etc/init/init.otg.rc
vendor/etc/init/md_monitor.rc
vendor/etc/init/vendor.mediatek.hardware.tranHwInfo@1.0-service.rc
@@ -2776,11 +2780,28 @@ vendor/lib64/vendor.mediatek.hardware.nvram@1.0.so
vendor/lib64/vendor.mediatek.hardware.nvram@1.1.so
# Power
+vendor/bin/hw/vendor.mediatek.hardware.mtkpower@1.0-service
vendor/etc/init/bootperf.rc
vendor/etc/init/init.fpsgo.rc
+vendor/etc/init/vendor.mediatek.hardware.mtkpower@1.0-init.rc
+vendor/etc/init/vendor.mediatek.hardware.mtkpower@1.0-service.rc
+-vendor/etc/vintf/manifest/power-default.xml:vendor/etc/vintf/manifest/power-mtk.xml
+vendor/lib/hw/power.default.so:vendor/lib/hw/power.mt6789.so
+vendor/lib/hw/vendor.mediatek.hardware.mtkpower@1.2-impl.so
+vendor/lib/libperfctl_vendor.so
vendor/lib/libpower_timer.so
+vendor/lib/libpowerhal.so
+vendor/lib/libpowerhalwrap_vendor.so
+vendor/lib/libmtkperf_client_vendor.so
vendor/lib/vendor.mediatek.hardware.power@2.0.so
+vendor/lib64/hw/power.default.so:vendor/lib64/hw/power.mt6789.so
+vendor/lib64/hw/vendor.mediatek.hardware.mtkpower@1.2-impl.so
+vendor/lib64/android.hardware.power-service-mediatek.so
+vendor/lib64/libperfctl_vendor.so
vendor/lib64/libpower_timer.so
+vendor/lib64/libpowerhal.so
+vendor/lib64/libpowerhalwrap_vendor.so
+vendor/lib64/libmtkperf_client_vendor.so
vendor/lib64/libtranlog.so
vendor/lib64/vendor.mediatek.hardware.power@2.0.so