diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 5eb5ee3..4551a92 100755 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -42,7 +42,7 @@ TARGET_NO_BOOTLOADER := true # Kernel BOARD_KERNEL_BASE := 0x80000000 -BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7464900.sdhci lpm_levels.sleep_disabled=1 rcupdate.rcu_expedited=1 cma=32M@0-0xffffffff +BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7464900.sdhci lpm_levels.sleep_disabled=1 rcupdate.rcu_expedited=1 cma=32M@0-0xffffffff loop.max_part=7 BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb BOARD_KERNEL_PAGESIZE := 4096 @@ -50,8 +50,11 @@ BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x02200000 --tags_offset 0x02000000 BOARD_CUSTOM_BOOTIMG := true BOARD_CUSTOM_BOOTIMG_MK := hardware/samsung/mkbootimg.mk TARGET_KERNEL_ARCH := arm64 +TARGET_KERNEL_VERSION := 3.18 TARGET_KERNEL_SOURCE := kernel/samsung/msm8996 TARGET_COMPILE_WITH_MSM_KERNEL := true +TARGET_KERNEL_ADDITIONAL_FLAGS := \ + HOSTCFLAGS="-fuse-ld=lld -Wno-unused-command-line-argument" # Platform TARGET_BOARD_PLATFORM := msm8996 @@ -85,8 +88,11 @@ USE_DEVICE_SPECIFIC_CAMERA := true BOARD_CHARGER_ENABLE_SUSPEND := true # Display +NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3 MAX_VIRTUAL_DISPLAY_DIMENSION := 4096 TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS := true +TARGET_HAS_HDR_DISPLAY := true +TARGET_HAS_WIDE_COLOR_DISPLAY := true TARGET_SCREEN_DENSITY := 320 TARGET_USES_C2D_COMPOSITION := true TARGET_USES_GRALLOC1 := true @@ -151,7 +157,8 @@ TARGET_PROVIDES_KEYMASTER := true # Power TARGET_USES_INTERACTION_BOOST := true -TARGET_POWERHAL_SET_INTERACTIVE_EXT := $(COMMON_PATH)/power/power_ext.c +TARGET_POWERHAL_SET_INTERACTIVE_EXT := $(COMMON_PATH)/power_ext/power_interactive_ext.c +TARGET_POWERHAL_MODE_EXT := $(COMMON_PATH)/power_ext/power_mode_ext.cpp # Properties TARGET_SYSTEM_PROP += $(COMMON_PATH)/system.prop @@ -180,9 +187,6 @@ TARGET_LD_SHIM_LIBS := \ /vendor/lib/hw/audio.primary.msm8996.so|libaudioprimary_shim.so \ /vendor/lib/hw/camera.msm8996.so|libshims_cameraclient.so -# USB -TARGET_QTI_USB_SUPPORTS_AUDIO_ACCESSORY := true - # Wifi BOARD_HAVE_SAMSUNG_WIFI := true BOARD_HAS_QCOM_WLAN := true diff --git a/configs/msm_irqbalance.conf b/configs/msm_irqbalance.conf new file mode 100644 index 0000000..ab8e566 --- /dev/null +++ b/configs/msm_irqbalance.conf @@ -0,0 +1,3 @@ +PRIO=1,1,0,0 +#arm-pmu, arch_timer, arch_mem_timer, MDSS, smd-rpm, kgsl-3d0 +IGNORED_IRQ=23,27,62,115,200,332 \ No newline at end of file diff --git a/configs/thermal-engine-vr.conf b/configs/thermal-engine-vr.conf deleted file mode 100644 index b185a4b..0000000 --- a/configs/thermal-engine-vr.conf +++ /dev/null @@ -1,26 +0,0 @@ -[SKIN_SHUTDOWN] -algo_type monitor -sampling 1000 -sensor emmc_therm -thresholds 62000 -thresholds_clr 61000 -actions shutdown -action_info 1 - -[VR-EMMC] -algo_type monitor -sensor emmc_therm -sampling 1000 -thresholds 58000 -thresholds_clr 52000 -actions cluster0+cluster1+gpu+report -action_info 691200+691200+214000000+1 - -[BATTERY-MONITOR] -algo_type monitor -sampling 2000 -sensor emmc_therm -thresholds 56000 -thresholds_clr 54000 -actions battery -action_info 3 diff --git a/configs/thermal-engine.conf b/configs/thermal-engine.conf deleted file mode 100644 index d22f240..0000000 --- a/configs/thermal-engine.conf +++ /dev/null @@ -1,95 +0,0 @@ -[SKIN_SHUTDOWN] -algo_type monitor -sampling 1000 -sensor emmc_therm -thresholds 62000 -thresholds_clr 61000 -actions shutdown -action_info 1 - -[THROTTLING-NOTIFY] -algo_type monitor -sampling 2000 -sensor emmc_therm -thresholds 47000 -thresholds_clr 44000 -actions report -action_info 1 - -[SKIN-HIGH-FLOOR] -algo_type ss -sampling 2000 -sensor emmc_therm -device cpu_voltage -set_point 47000 -set_point_clr 44000 -device_perf_floor 1670400 -time_constant 0 - -[SKIN-MID-FLOOR] -algo_type ss -sampling 2000 -sensor emmc_therm -device cpu_voltage -set_point 49000 -set_point_clr 48000 -device_perf_floor 1440000 -time_constant 0 - -[SKIN-LOW-FLOOR] -algo_type ss -sampling 2000 -sensor emmc_therm -device cpu_voltage -set_point 51000 -set_point_clr 50000 -device_perf_floor 1132800 -time_constant 0 - -[SKIN-RESTRICT-FLOOR] -algo_type ss -sampling 2000 -sensor emmc_therm -device cpu_voltage -set_point 54000 -set_point_clr 52000 -device_perf_floor 768000 -time_constant 0 - -[SKIN-CRITICAL] -algo_type monitor -sensor emmc_therm -sampling 1000 -thresholds 56000 58000 -thresholds_clr 55000 57000 -actions cluster0+cluster1+gpu+report cluster0+cluster1+gpu+report -action_info 691200+691200+133000000+1 307200+307200+133000000+1 - -[BATTERY-MONITOR] -algo_type monitor -sampling 2000 -sensor emmc_therm -thresholds 56000 -thresholds_clr 54000 -actions battery -action_info 3 - -[HOT-SKIN-VIRTUAL] -algo_type virtual -trip_sensor emmc_therm -sensors tsens_tz_sensor15 tsens_tz_sensor0 -list_cnt 2 -weights 1 -1 -set_point 47000 -set_point_clr 44000 -sampling 1000 -math 0 - -[VIRTUAL-SS-GPU-SKIN] -algo_type ss -sensor HOT-SKIN-VIRTUAL -device gpu -sampling 2000 -set_point 7000 -set_point_clr 2000 -device_max_limit 400000000 diff --git a/extract-files.sh b/extract-files.sh index 72f3a49..36bd6d7 100755 --- a/extract-files.sh +++ b/extract-files.sh @@ -60,6 +60,12 @@ fi function blob_fixup() { case "${1}" in + vendor/lib64/hw/vulkan.msm8996.so) + sed -i "s/vulkan.msm8953.so/vulkan.msm8996.so/g" "${2}" + ;; + vendor/lib/hw/vulkan.msm8996.so) + sed -i "s/vulkan.msm8953.so/vulkan.msm8996.so/g" "${2}" + ;; vendor/lib/libwvhidl.so) "${PATCHELF}" --replace-needed "libprotobuf-cpp-lite.so" "libprotobuf-cpp-lite-v28.so" "${2}" ;; diff --git a/gts3l.mk b/gts3l.mk index 1d3f093..fd79c09 100755 --- a/gts3l.mk +++ b/gts3l.mk @@ -183,10 +183,6 @@ PRODUCT_PACKAGES += \ android.hardware.drm@1.0-service \ android.hardware.drm@1.3-service.clearkey -# FastCharge -PRODUCT_PACKAGES += \ - vendor.lineage.fastcharge@1.0-service.samsung - # Fingerprint PRODUCT_PACKAGES += \ android.hardware.biometrics.fingerprint@2.1-service.samsung \ @@ -228,6 +224,10 @@ PRODUCT_PACKAGES += \ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/sec_config:$(TARGET_COPY_OUT_VENDOR)/etc/sec_config +# IRQ +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/msm_irqbalance.conf:$(TARGET_COPY_OUT_VENDOR)/etc/msm_irqbalance.conf + # Keylayout PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/keylayout/gpio-keys.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/gpio-keys.kl \ @@ -277,7 +277,6 @@ PRODUCT_PACKAGES += \ # OMX PRODUCT_PACKAGES += \ libc2dcolorconvert \ - libgui_vendor \ libextmedia_jni \ libOmxAacEnc \ libOmxAmrEnc \ @@ -287,7 +286,6 @@ PRODUCT_PACKAGES += \ libOmxQcelp13Enc \ libOmxVdec \ libOmxVenc \ - libOmxVidcCommon \ libstagefrighthw # Power @@ -385,10 +383,6 @@ PRODUCT_PACKAGES += \ android.hardware.thermal@1.0-service \ thermal.msm8996 -PRODUCT_COPY_FILES += \ - $(LOCAL_PATH)/configs/thermal-engine.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine.conf \ - $(LOCAL_PATH)/configs/thermal-engine-vr.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine-vr.conf - # TextClassifier PRODUCT_PACKAGES += \ textclassifier.bundle1 diff --git a/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml b/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml deleted file mode 100644 index 1e83dae..0000000 --- a/overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - 0 - - - 83 - - - 65 - - - 1 - - - 1 - - - - restart - restart_recovery - restart_download - - - diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index 25a6d23..1592f0f 100644 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -841,4 +841,94 @@ Settings.System.RING_VIBRATION_INTENSITY more details on the constant values and meanings. --> 1 + + + 0 + + + 83 + + + 65 + + + 1 + + + 1 diff --git a/power/power_ext.c b/power_ext/power_interactive_ext.c similarity index 100% rename from power/power_ext.c rename to power_ext/power_interactive_ext.c diff --git a/power_ext/power_mode_ext.cpp b/power_ext/power_mode_ext.cpp new file mode 100644 index 0000000..1db0e25 --- /dev/null +++ b/power_ext/power_mode_ext.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2020 The LineageOS 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. + */ + +#define LOG_TAG "PowerHAL_Mode_Ext" +#include +#include + +#include + +#include "power-common.h" + +using ::aidl::android::hardware::power::Mode; + +namespace aidl { +namespace android { +namespace hardware { +namespace power { +namespace impl { + +bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) { + switch (type) { + case Mode::LAUNCH: + *_aidl_return = true; + return true; + default: + return false; + } +} + +bool setDeviceSpecificMode(Mode type, bool enabled) { + switch (type) { + case Mode::LAUNCH: + power_hint(POWER_HINT_LAUNCH, enabled ? &enabled : NULL); + return true; + default: + return false; + } +} + +} // namespace impl +} // namespace power +} // namespace hardware +} // namespace android +} // namespace aidl \ No newline at end of file diff --git a/proprietary-files.txt b/proprietary-files.txt index 1dbf739..5ba8df7 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -163,14 +163,6 @@ etc/firmware/C12QS_Isp0_imx260.bin:vendor/firmware/C12QS_Isp0_imx260.bin etc/firmware/C12QS_Isp1_imx260.bin:vendor/firmware/C12QS_Isp1_imx260.bin etc/firmware/cal_data_LSCmaster.bin:vendor/firmware/cal_data_LSCmaster.bin etc/firmware/cpp_firmware_v1_10_0.fw:vendor/firmware/cpp_firmware_v1_10_0.fw -etc/firmware/cpp_firmware_v1_1_1.fw:vendor/firmware/cpp_firmware_v1_1_1.fw -etc/firmware/cpp_firmware_v1_1_6.fw:vendor/firmware/cpp_firmware_v1_1_6.fw -etc/firmware/cpp_firmware_v1_2_0.fw:vendor/firmware/cpp_firmware_v1_2_0.fw -etc/firmware/cpp_firmware_v1_4_0.fw:vendor/firmware/cpp_firmware_v1_4_0.fw -etc/firmware/cpp_firmware_v1_5_0.fw:vendor/firmware/cpp_firmware_v1_5_0.fw -etc/firmware/cpp_firmware_v1_5_2.fw:vendor/firmware/cpp_firmware_v1_5_2.fw -etc/firmware/cpp_firmware_v1_6_0.fw:vendor/firmware/cpp_firmware_v1_6_0.fw -etc/firmware/cpp_firmware_v1_8_0.fw:vendor/firmware/cpp_firmware_v1_8_0.fw etc/firmware/D12QL_Isp0_s5k2l1sx.bin:vendor/firmware/D12QL_Isp0_s5k2l1sx.bin etc/firmware/D12QS_Isp0_imx260.bin:vendor/firmware/D12QS_Isp0_imx260.bin etc/firmware/Master0.bin:vendor/firmware/Master0.bin @@ -452,26 +444,6 @@ vendor/bin/hw/android.hardware.health@2.0-service.samsung vendor/etc/init/android.hardware.health@2.0-service.samsung.rc lib64/vendor.samsung.hardware.exthealth@1.0.so -# Display (HDR) -vendor/lib64/libhdr_tm.so -vendor/lib/libhdr_tm.so - -# Display (SDM) -vendor/lib/libscalar.so -vendor/lib/libsdedrm.so -vendor/lib/libsdm-color.so -vendor/lib/libsdm-diag.so -vendor/lib/libsdm-disp-vndapis.so -vendor/lib/libsdmextension.so -vendor/lib/libtinyxml2_1.so -vendor/lib64/libscalar.so -vendor/lib64/libsdedrm.so -vendor/lib64/libsdm-color.so -vendor/lib64/libsdm-diag.so -vendor/lib64/libsdm-disp-vndapis.so -vendor/lib64/libsdmextension.so -vendor/lib64/libtinyxml2_1.so - # Display postprocessing vendor/bin/hw/vendor.display.color@1.0-service vendor/etc/init/vendor.display.color@1.0-service.rc @@ -507,7 +479,6 @@ vendor/lib/libwvhidl.so # DSP vendor/lib64/libcdsprpc.so vendor/lib64/libfastcrc.so -vendor/lib64/libfastcvopt.so vendor/lib64/libmdsprpc.so vendor/lib64/libsdsprpc.so vendor/lib/rfsa/adsp/libadsp_fd_skel.so @@ -528,7 +499,6 @@ vendor/lib/rfsa/adsp/libvpp_frc.so vendor/lib/rfsa/adsp/libvpp_svc_skel.so vendor/lib/libcdsprpc.so vendor/lib/libfastcrc.so -vendor/lib/libfastcvopt.so vendor/lib/libmdsprpc.so vendor/lib/libsdsprpc.so @@ -655,45 +625,68 @@ lib/vendor.qti.gnss@2.1.so lib/vendor.samsung.hardware.gnss@1.0.so lib/libxt_native.so -# Graphics (Adreno) -vendor/lib/egl/eglSubDriverAndroid.so -vendor/lib/egl/libEGL_adreno.so -vendor/lib/egl/libGLESv1_CM_adreno.so -vendor/lib/egl/libGLESv2_adreno.so -vendor/lib/egl/libQTapGLES.so -vendor/lib/egl/libq3dtools_adreno.so -vendor/lib/egl/libq3dtools_esx.so -vendor/lib/libC2D2.so -vendor/lib/libCB.so -vendor/lib/libOpenCL.so -vendor/lib/libRSDriver_adreno.so -vendor/lib/libadreno_utils.so -vendor/lib/libbccQTI.so -vendor/lib/libc2d30_bltlib.so -vendor/lib/libgsl.so -vendor/lib/libllvm-glnext.so -vendor/lib/libllvm-qcom.so -vendor/lib/librs_adreno.so -vendor/lib/librs_adreno_sha1.so -vendor/lib64/egl/eglSubDriverAndroid.so -vendor/lib64/egl/libEGL_adreno.so -vendor/lib64/egl/libGLESv1_CM_adreno.so -vendor/lib64/egl/libGLESv2_adreno.so -vendor/lib64/egl/libQTapGLES.so -vendor/lib64/egl/libq3dtools_adreno.so -vendor/lib64/egl/libq3dtools_esx.so -vendor/lib64/libC2D2.so -vendor/lib64/libCB.so -vendor/lib64/libOpenCL.so -vendor/lib64/libRSDriver_adreno.so -vendor/lib64/libadreno_utils.so -vendor/lib64/libbccQTI.so -vendor/lib64/libc2d30_bltlib.so -vendor/lib64/libgsl.so -vendor/lib64/libllvm-glnext.so -vendor/lib64/libllvm-qcom.so -vendor/lib64/librs_adreno.so -vendor/lib64/librs_adreno_sha1.so +# Graphics (Adreno) - from daisy - QKQ1.191002.002 +vendor/lib64/egl/eglSubDriverAndroid.so|8edb19893decd259ba43d752b48e0a69c5788db4 +vendor/lib64/egl/libEGL_adreno.so|c97c8e14d26f53398c50122daf80a599f077398a +vendor/lib64/egl/libGLESv1_CM_adreno.so|0adf2e094afdc3476198ef8ad52101cf9004eb5d +vendor/lib64/egl/libGLESv2_adreno.so|4c9e3f723daf6a3f6d4301e3527472654c8bedf1 +vendor/lib64/egl/libQTapGLES.so|104e9cec67678174b92a698849aa2bcf52ba46ce +vendor/lib64/egl/libq3dtools_adreno.so|8f6043f22c23c76e7e17bc9642957f648bec1e50 +vendor/lib64/egl/libq3dtools_esx.so|4f9b2bb6f492ea05b3da17b68e02effe611de0e8 +vendor/lib64/libC2D2.so|ff2d4947c7924376ff66517461246d238e221e05 +vendor/lib64/libCB.so|df167809abe16674a61742ba6efb208edd069a3b +vendor/lib64/libOpenCL.so|84c7d8be13885c9346f73c09aaaedc3bce7667d9 +vendor/lib64/libRSDriver_adreno.so|e7628b78d034500c64d09fcaf5305971242e1acd +vendor/lib64/libadreno_utils.so|04b3878ea84a99f133934580adfd6905f6cc102b +vendor/lib64/libbccQTI.so|e79ba0450ce215bfb81e518cce310f378314b4e5 +vendor/lib64/libc2d30_bltlib.so|644a88f490cc883492d94b9f581127fb33f51415 +vendor/lib64/libfastcvopt.so|f5e25aa055a57e23530b858bf7dd204a6009effc +vendor/lib64/libgsl.so|5453da1723c3b014850165b42236ba26af11a7ad +vendor/lib64/libllvm-glnext.so|dad8139672a9dcff4270a58599aa1b72d13e62fc +vendor/lib64/libllvm-qcom.so|88f4199538ce887c91936bf70eef31615c938aa2 +vendor/lib64/librs_adreno.so|e41149794e719c7f743c4d800def68a5c8e5f9ca +vendor/lib64/librs_adreno_sha1.so|f9d28682f9c219dfe086da9f3a15aaddbcd38a05 +vendor/lib/egl/eglSubDriverAndroid.so|d0f0f243aeb41720cbc052c2344918c5d588659c +vendor/lib/egl/libEGL_adreno.so|a3bb3c748cc180521a3b0ea173e714a55c01b118 +vendor/lib/egl/libGLESv1_CM_adreno.so|43c864f0c3f384085f9d19a2e1d56e672f319ea6 +vendor/lib/egl/libGLESv2_adreno.so|15104ce575d5fb6282502fcf73ea27b6f52429bc +vendor/lib/egl/libQTapGLES.so|957d9c98f3c29e7bf1da02fedac0789ada49dc70 +vendor/lib/egl/libq3dtools_adreno.so|b4b7bda387620de5f6ea2a29406f9351e855b8ed +vendor/lib/egl/libq3dtools_esx.so|1972c5a7747579d14519681855e6bc4e424fc7f0 +vendor/lib/libC2D2.so|c04a5ac1e576f63ebe91aba14bf917ee9e382be0 +vendor/lib/libCB.so|15986a50f98c979833e5d651eedcffaf19e54e3b +vendor/lib/libOpenCL.so|9ee3900265f9b855f526c0ce4fcfdaed51d62003 +vendor/lib/libRSDriver_adreno.so|51e8ebcd4584726cbee21a4486b6f37ce5e716f1 +vendor/lib/libadreno_utils.so|3a09e6720121f5b459a1fc7f9639b632da5832ec +vendor/lib/libbccQTI.so|124156259b7900ac44c48dd9cf83b210d02d8c9d +vendor/lib/libc2d30_bltlib.so|4a486823ef2a9ea14f4f02c9eb9053ac5fb028af +vendor/lib/libfastcvopt.so|2df00c3827fe1db322084cb3935241f17d1532f4 +vendor/lib/libgsl.so|2ddafd66848dfd146bbaf184b69f92df9f79c99f +vendor/lib/libllvm-glnext.so|a28adae3ae758cdffc889d681b3cdefe24351c32 +vendor/lib/libllvm-qcom.so|3079ae9049c8758664e6ade78837e0fc6c2272d5 +vendor/lib/librs_adreno.so|9f0022a5c38a676a580511749bab3c538ed8b803 +vendor/lib/librs_adreno_sha1.so|28201ce01c442df4389273245be313ff4a741d6e + +# Graphics (HDR) - from daisy - QKQ1.191002.002 +vendor/lib64/libhdr_tm.so|c388a9b14966583cde2c682c129fcf5cfa298239 +vendor/lib/libhdr_tm.so|4c371d0931245a65d0b4df768de8837bbdf4832e + +# Graphics (SDM) - from daisy - QKQ1.191002.002 +vendor/lib/libscalar.so|7ac579768ffd2caee903d69d8fd3f7918b04ffbe +vendor/lib/libsdm-color.so|fa3f8c0062d474fdf6960fcbcc3bf21a5c3fd594 +vendor/lib/libsdm-diag.so|46b5c2d6fab1e655efde1657b2e51dc00c00b763 +vendor/lib/libsdmextension.so|b6a2100c733b7a5c4688bb9bcae581461ada70f3 +vendor/lib/libtinyxml2_1.so|ef2167416f7a5a503256c5e818fcfa660d5146f4 +vendor/lib64/libscalar.so|b7feb3266d5bccab8b26c49eea6ac8e295192f9a +vendor/lib64/libsdm-color.so|993dc946c4aa439280527c13798938c51dd9dee7 +vendor/lib64/libsdm-diag.so|87373a043267b9b3bb923931a910119a9deb425f +vendor/lib64/libsdm-disp-vndapis.so|b1dede9efa81e8d0374343612ad7ad0d967e8e29 +vendor/lib64/libsdmextension.so|47b7fcfb790df4417654c566af1a8a74d4bf3e2f +vendor/lib64/libtinyxml2_1.so|56d4d5d0ea010f951de219c7b9fd2c9695a5b9d2 + +# Graphics (Vulkan) - from daisy - QKQ1.191002.002 +vendor/lib64/hw/vulkan.msm8953.so:vendor/lib64/hw/vulkan.msm8996.so|8c01e237bdc542ca682cb97ce28f264135033fab|b09121b664897181c29ec5a529117772a971229b +vendor/lib/hw/vulkan.msm8953.so:vendor/lib/hw/vulkan.msm8996.so|c24dee59782e94c119e1e6ae00ac05c2d67c3f93|6142249d50da115d9fe3b20581dbeedd961727c3 # Graphics (Adreno firmware) vendor/firmware/a530v1_pfp.fw @@ -706,10 +699,6 @@ vendor/firmware/a530_pm4.fw vendor/firmware/a530v1_pm4.fw vendor/firmware/a540_gpmu.fw2 -# Graphics (Vulkan) -vendor/lib64/hw/vulkan.msm8996.so -vendor/lib/hw/vulkan.msm8996.so - # Image Understanding saiv/face/attr/gae/PmExpModel.bin saiv/face/attr/gae/PmAgeModel.bin @@ -732,128 +721,38 @@ vendor/lib64/libqti-iopd-client.so lib64/vendor.qti.hardware.iop@1.0.so lib64/vendor.qti.hardware.iop@2.0.so -# IRQ Balance -vendor/etc/msm_irqbalance.conf +# IRQ Balance - from oneplus3 +vendor/bin/msm_irqbalance|e70694e0412052cd591389b8c1bf4573e5777257 # Keystore vendor/lib64/hw/keystore.msm8996.so vendor/lib/hw/keystore.msm8996.so -# Media -lib64/libFileMux.so -lib64/libmmosal.so -lib64/libmmparser_lite.so -lib64/libmmrtpdecoder.so -lib64/libmmrtpencoder.so -lib/libFileMux.so -lib/libmmosal.so -lib/libmmparser_lite.so -lib/libmmrtpdecoder.so -lib/libmmrtpencoder.so -vendor/lib64/libI420colorconvert.so -vendor/lib64/libgpustats.so -vendor/lib64/libmm-color-convertor.so -vendor/lib64/libmmosal_proprietary.so -vendor/lib64/libvpphvx.so -vendor/lib64/libvpplibrary.so -vendor/lib/libI420colorconvert.so -vendor/lib/libgpustats.so -vendor/lib/libmm-color-convertor.so -vendor/lib/libmmosal_proprietary.so -vendor/lib/libvpphvx.so -vendor/lib/libvpplibrary.so -vendor/lib/libvqzip.so - -# OMX -etc/somxreg.conf -vendor/lib64/libAlacSwDec.so -vendor/lib64/libApeSwDec.so -vendor/lib64/libFlacSwDec.so -vendor/lib64/libOmxAacDec.so -vendor/lib64/libOmxAlacDec.so -vendor/lib64/libOmxAlacDecSw.so -vendor/lib64/libOmxAmrDec.so -vendor/lib64/libOmxAmrwbplusDec.so -vendor/lib64/libOmxApeDec.so -vendor/lib64/libOmxApeDecSw.so -vendor/lib64/libOmxEvrcDec.so -vendor/lib64/libOmxG711Dec.so -vendor/lib64/libOmxQcelp13Dec.so -vendor/lib64/libOmxVpp.so -vendor/lib64/libOmxWmaDec.so -vendor/lib/libAlacSwDec.so -vendor/lib/libApeSwDec.so -vendor/lib/libFlacSwDec.so -vendor/lib/libdsd2pcm.so -vendor/lib/libOmxAacDec.so -vendor/lib/libOmxAlacDec.so -vendor/lib/libOmxAlacDecSw.so -vendor/lib/libOmxAmrDec.so -vendor/lib/libOmxAmrwbplusDec.so -vendor/lib/libOmxApeDec.so -vendor/lib/libOmxApeDecSw.so -vendor/lib/libOmxDsdDec.so -vendor/lib/libOmxEvrcDec.so -vendor/lib/libOmxG711Dec.so -vendor/lib/libOmxQcelp13Dec.so -vendor/lib/libOmxVpp.so -vendor/lib/libOmxWmaDec.so -lib64/libsomx263dsw.so -lib64/libsomx264dsw.so -lib64/libsomxaacd.so -lib64/libsomxadpcmd.so -lib64/libsomxamrd.so -lib64/libsomxcmn.so -lib64/libsomxcore.so -lib64/libsomxflacd.so -lib64/libsomxhevcdsw.so -lib64/libsomxmp3d.so -lib64/libsomxmp43d.so -lib64/libsomxmp4vdsw.so -lib64/libsomxnaace.so -lib64/libsomxsr263d.so -lib64/libsomxvc1dsw.so -lib64/libsomxvp8d.so -lib64/libsomxwmad.so -lib64/libsomxwmv7d.so -lib64/libsomxwmv8d.so -lib64/libarac.so -lib64/libsavsac.so -lib64/libsavscmn.so -lib64/libsavsff.so -lib64/libsavsmeta.so -lib64/libsavsvc.so -lib64/libsnaace.so -lib64/libsnamrnb.so -lib64/libsnamrwb.so -lib/libsomx263dsw.so -lib/libsomx264dsw.so -lib/libsomxaacd.so -lib/libsomxadpcmd.so -lib/libsomxamrd.so -lib/libsomxcmn.so -lib/libsomxcore.so -lib/libsomxflacd.so -lib/libsomxhevcdsw.so -lib/libsomxmp3d.so -lib/libsomxmp43d.so -lib/libsomxmp4vdsw.so -lib/libsomxnaace.so -lib/libsomxsr263d.so -lib/libsomxvc1dsw.so -lib/libsomxvp8d.so -lib/libsomxwmad.so -lib/libsomxwmv7d.so -lib/libsomxwmv8d.so -lib/libarac.so -lib/libsavsac.so -lib/libsavscmn.so -lib/libsavsff.so -lib/libsavsmeta.so -lib/libsavsvc.so -lib/libsnaace.so -lib/libsnamrnb.so -lib/libsnamrwb.so +# Media - from daisy - QKQ1.191002.002 +lib64/libFileMux.so|8d07dde58a8b629ccce4dd9c778e76a6513ca555 +lib64/libmmosal.so|9ceff2581e86d32bc2795dffb96ebe4bdc88f2f7 +lib64/libmmparser_lite.so|bea6788f2f0924c74a3bb7c1fdd24bc59202550c +lib/libFileMux.so|1c713da8d18f03deb33c3211761fc07dd57d6946 +lib/libOmxMux.so|6f1a1f5fc8f9a8683e6fb719b6fe51a68c6b0e84 +lib/libmmosal.so|9464733295e192301b2577f52fab720e72c0d152 +lib/libmmparser_lite.so|c3656bbcd33d44d5b22743061261989fffd0382f +vendor/lib64/libgpustats.so|a899ae72983277442cdacf8f43271986c91ce710 +vendor/lib/libOmxAacDec.so|55772a6d0cf3e6a5a2c32348fd7096b8737d490b +vendor/lib/libOmxAlacDec.so|adca064b15a7d545075af6f5222db45dec8202b5 +vendor/lib/libOmxAlacDecSw.so|8700268f92a953549e5936af9d5ccd08f99ed50f +vendor/lib/libOmxAmrDec.so|61ca4a96027a610b74621bd3f9caff3f34e4eab5 +vendor/lib/libOmxAmrwbplusDec.so|f0ebf6b19f569862fa8da05653148e867ba38878 +vendor/lib/libOmxApeDec.so|49b4090d2f82963e596dd2fabb30b7fe8551a21b +vendor/lib/libOmxApeDecSw.so|d1276d42ad37fbd263ab96f9f353d4e782bb0fe9 +vendor/lib/libOmxEvrcDec.so|20a6be418df26f48751b4178f5642e3fc6902690 +vendor/lib/libOmxQcelp13Dec.so|27a75185e62e88ea84ac2448a3842c998899ae90 +vendor/lib/libOmxVideoDSMode.so|84a6b99f5ad0c7dbe827eb01258cca4c790c0fe7 +vendor/lib/libOmxVpp.so|46e4928c392716943986a3b490680d3e08fdf3e4 +vendor/lib/libOmxWmaDec.so|c3da756ae14234ae8e56cbc0b32249fbd4c8746a +vendor/lib/libgpustats.so|75fc8f58b071f3c27d708010e1b40eafba091a14 +vendor/lib/libmmosal_proprietary.so|4b0788590e1ecfccd3b20b3181a4add528acb2b6 +vendor/lib/libvpplibrary.so|816a79fe9a6d30e9402acb767119b9ee1c2c8aea +vendor/lib/libvqzip.so|24e5eb30e5a2cdb544c8688d81d7cc75a1d85eaf # Peripheral Manager vendor/bin/pm-proxy @@ -867,31 +766,16 @@ vendor/etc/init/vendor.samsung.hardware.miscpower@1.0-service.rc lib64/vendor.samsung.hardware.miscpower@1.0.so lib/vendor.samsung.hardware.miscpower@1.0.so -# Power (perf) -vendor/bin/energy-awareness -vendor/bin/hw/vendor.qti.hardware.perf@1.0-service -vendor/etc/init/vendor.qti.hardware.perf@1.0-service.rc -vendor/etc/perf/commonresourceconfigs.xml -vendor/etc/perf/perfboostsconfig.xml -vendor/etc/perf/perf-profile0.conf -vendor/etc/perf/perf-profile1.conf -vendor/etc/perf/perf-profile2.conf -vendor/etc/perf/perf-profile3.conf -vendor/etc/perf/perf-profile4.conf -vendor/etc/perf/perf-profile5.conf -vendor/etc/perf/perf-profile6.conf -vendor/etc/perf/targetconfig.xml -vendor/etc/perf/targetresourceconfigs.xml -vendor/lib/libperfgluelayer.so -vendor/lib/libqti-perfd-client.so -vendor/lib/libqti-perfd.so -vendor/lib/libqti-util.so -vendor/lib/libqti-utils.so -vendor/lib64/libperfgluelayer.so -vendor/lib64/libqti-perfd-client.so -vendor/lib64/libqti-perfd.so -vendor/lib64/libqti-util.so -vendor/lib64/libqti-utils.so +# Perf - from oneplus3 - PKQ1.181203.001 +vendor/bin/energy-awareness|3f1aa4d518ff361aa3ed9e41ace3e16d36cf0bbe +vendor/bin/hw/vendor.qti.hardware.perf@1.0-service|7a38f7ef085ddb1a5cd8731e9d2fc1540c3e85ad +vendor/etc/init/vendor.qti.hardware.perf@1.0-service.rc|b50182aadab2e31409df61c523d0fb914a394e43 +vendor/lib64/libperfgluelayer.so|627a324616de86ba90889a7c8dd7a05c46a30aaa +vendor/lib64/libqti-perfd-client.so|1e84aa49a8cff0f69f0261c69dd8843534efd79e +vendor/lib64/libqti-util.so|0c34c7cbb07197841e9f097925fe961f3226e621 +vendor/lib/libperfgluelayer.so|3850d4ea3dbead227b622fcc47fcec29955fcc63 +vendor/lib/libqti-perfd-client.so|a4a6da47ee26fcd5116c514f7fed15b91306aea3 +vendor/lib/libqti-util.so|d65f3ef240cebea73bd1ba8b1132a7e639aa05bb # Power-off charging bin/lpm @@ -989,11 +873,11 @@ lib/libsensorlistener.so vendor/etc/sensors/hals.conf vendor/etc/sensors/sensor_def_qcomdev.conf -# Thermal -vendor/bin/thermal-engine -vendor/lib/libthermalclient.so -vendor/lib64/libthermalclient.so -vendor/lib64/libthermalioctl.so +# Thermal - from op3 - PKQ1.181203.001 +vendor/bin/thermal-engine|b15c9e8fa54ebb15dfeb36c7fbc834a28b4c836e +vendor/lib64/libthermalclient.so|94424d7c8f8daff8bbfd7454fe4d5f1fbf411260 +vendor/lib64/libthermalioctl.so|aa2a0abd8fb9792024efd93f648c129b6a22619e +vendor/lib/libthermalclient.so|270ea373c617584af092dc4ea2aa1c7bf27be7f4 # Time -vendor/app/TimeService/TimeService.apk diff --git a/rootdir/bin/init.qcom.sh b/rootdir/bin/init.qcom.sh index 50b25b0..0b77089 100755 --- a/rootdir/bin/init.qcom.sh +++ b/rootdir/bin/init.qcom.sh @@ -267,7 +267,7 @@ case "$target" in ;; esac ;; - "msm8994" | "msm8992" | "msm8998" | "apq8098_latv" | "sdm845" | "sdm710" | "qcs605" | "sm6150" | "trinket") + "msm8994" | "msm8992" | "msm8996" | "msm8998" | "apq8098_latv" | "sdm845" | "sdm710" | "qcs605" | "sm6150" | "trinket") start_msm_irqbalance ;; "msm8996") diff --git a/rootdir/etc/init.qcom.power.rc b/rootdir/etc/init.qcom.power.rc index 1ba0df8..e30de92 100644 --- a/rootdir/etc/init.qcom.power.rc +++ b/rootdir/etc/init.qcom.power.rc @@ -41,9 +41,6 @@ on boot chown system system /dev/cpuset/camera-daemon/tasks chmod 0664 /dev/cpuset/camera-daemon/tasks - # Enable sched boost - write /proc/sys/kernel/sched_boost 1 - on charger wait /dev/block/platform/soc/${ro.boot.bootdevice} symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice @@ -117,20 +114,21 @@ on enable-low-power # Set sync wakee policy tunable write /proc/sys/kernel/sched_prefer_sync_wakee_to_waker 1 - # Configure governor settings for little cluster - write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "schedutil" - write /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us 500 - write /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us 20000 - write /sys/devices/system/cpu/cpu0/cpufreq/schedutil/iowait_boost_enable 1 - - # Bring CPU2 online + # Bring CPU 0, 2 online + write /sys/devices/system/cpu/cpu0/online 1 write /sys/devices/system/cpu/cpu2/online 1 + # Configure governor settings for little cluster + write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "blu_schedutil" + write /sys/devices/system/cpu/cpu0/cpufreq/blu_schedutil/up_rate_limit_us 250 + write /sys/devices/system/cpu/cpu0/cpufreq/blu_schedutil/down_rate_limit_us 10000 + write /sys/devices/system/cpu/cpu0/cpufreq/blu_schedutil/iowait_boost_enable 1 + # Configure governor settings for big cluster - write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "schedutil" - write /sys/devices/system/cpu/cpu2/cpufreq/schedutil/up_rate_limit_us 500 - write /sys/devices/system/cpu/cpu2/cpufreq/schedutil/down_rate_limit_us 20000 - write /sys/devices/system/cpu/cpu2/cpufreq/schedutil/iowait_boost_enable 1 + write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "blu_schedutil" + write /sys/devices/system/cpu/cpu2/cpufreq/blu_schedutil/up_rate_limit_us 250 + write /sys/devices/system/cpu/cpu2/cpufreq/blu_schedutil/down_rate_limit_us 10000 + write /sys/devices/system/cpu/cpu2/cpufreq/blu_schedutil/iowait_boost_enable 1 # Set boottime stune value write /dev/stune/schedtune.prefer_idle 1 @@ -191,6 +189,9 @@ on property:sys.boot_completed=1 # Set I/O squeduler setprop sys.io.scheduler "bfq" + # Set idle GPU to 133 Mhz + write /sys/class/kgsl/kgsl-3d0/default_pwrlevel 6 + # Update cpusets now that boot is complete and we want better load balancing write /dev/cpuset/top-app/cpus 0-3 write /dev/cpuset/foreground/cpus 0-2 @@ -207,9 +208,3 @@ service charger /system/bin/lpm group system radio graphics input capabilities SYS_BOOT seclabel u:r:charger:s0 - -service energy-awareness /vendor/bin/energy-awareness - class main - user root - group system - oneshot diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc index 8d17907..075bf10 100644 --- a/rootdir/etc/init.qcom.rc +++ b/rootdir/etc/init.qcom.rc @@ -524,18 +524,18 @@ service vendor.netmgrd /system/vendor/bin/netmgrd class main disabled -service vendor.ipacm-diag /system/vendor/bin/ipacm-diag - class main - user radio - socket ipacm_log_file dgram 660 radio radio - group radio diag oem_2901 - disabled - +#service vendor.ipacm-diag /system/vendor/bin/ipacm-diag +# class main +# user radio +# socket ipacm_log_file dgram 660 radio radio +# group radio diag oem_2901 +# disabled +# service vendor.ipacm /system/vendor/bin/ipacm - class main + class late_start user radio group radio inet - disabled + writepid /dev/cpuset/system-background/tasks service vendor.dataqti /system/vendor/bin/qti class main diff --git a/rootdir/etc/init.target.rc b/rootdir/etc/init.target.rc index e8534a4..6a1e222 100644 --- a/rootdir/etc/init.target.rc +++ b/rootdir/etc/init.target.rc @@ -459,12 +459,12 @@ on property:init.svc.zygote=running on property:init.svc.zygote=restarting stop ppd -#service energy-awareness /system/vendor/bin/energy-awareness -# class main -# user system -# group system -# oneshot -# +service vendor.energy-awareness /vendor/bin/energy-awareness + class main + user root + group system + oneshot + #service vendor.hvdcp_opti /system/vendor/bin/hvdcp_opti # class main # user root diff --git a/sepolicy/file.te b/sepolicy/file.te index ce10bff..5d54acb 100644 --- a/sepolicy/file.te +++ b/sepolicy/file.te @@ -54,7 +54,6 @@ type sysfs_fpc, fs_type, sysfs_type; type sysfs_lcd_writable, fs_type, sysfs_type; type sysfs_mdnie_writable, fs_type, sysfs_type; type sysfs_sec_keypad, fs_type, sysfs_type; -type sysfs_sec_switch, fs_type, sysfs_type; type sysfs_tsp, fs_type, sysfs_type; type sysfs_wifi, fs_type, sysfs_type; type sysfs_touchkey, fs_type, sysfs_type; diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index f6f1c4b..79d5f8f 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -177,7 +177,6 @@ /(vendor|system/vendor)/bin/hw/android\.hardware\.keymaster@4\.0-service\.samsung u:object_r:hal_keymaster_default_exec:s0 /(vendor|system/vendor)/bin/hw/android\.hardware\.light@2\.0-service\.samsung u:object_r:hal_light_default_exec:s0 /(vendor|system/vendor)/bin/hw/android\.hardware\.usb@1\.2-service-qti u:object_r:hal_usb_default_exec:s0 -/(vendor|system/vendor)/bin/hw/vendor\.lineage\.fastcharge@1\.0-service\.samsung u:object_r:hal_lineage_fastcharge_default_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service\.gts3l u:object_r:hal_lineage_livedisplay_sysfs_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch@1\.0-service\.gts3l u:object_r:hal_lineage_touch_default_exec:s0 /(vendor|system/vendor)/bin/hw/vendor\.samsung\.hardware\.miscpower@1\.0-service u:object_r:hal_power_default_exec:s0 @@ -205,5 +204,4 @@ /sys/devices/virtual/lcd/panel(/.*)? u:object_r:sysfs_lcd_writable:s0 /sys/devices/virtual/mdnie(/.*)? -- u:object_r:sysfs_mdnie_writable:s0 /sys/devices/virtual/sec/sec_keypad(/.*)? u:object_r:sysfs_sec_keypad:s0 -/sys/devices/virtual/sec/switch(/.*)? u:object_r:sysfs_sec_switch:s0 /sys/devices/virtual/sec/tsp(/.*)? u:object_r:sysfs_tsp:s0 diff --git a/sepolicy/hal_lineage_fastcharge_default.te b/sepolicy/hal_lineage_fastcharge_default.te deleted file mode 100644 index 4420271..0000000 --- a/sepolicy/hal_lineage_fastcharge_default.te +++ /dev/null @@ -1,4 +0,0 @@ -allow hal_lineage_fastcharge_default sysfs_sec_switch:dir search; -allow hal_lineage_fastcharge_default sysfs_sec_switch:file rw_file_perms; - -set_prop(hal_lineage_fastcharge, sec_fastcharge_prop) \ No newline at end of file diff --git a/sepolicy/property.te b/sepolicy/property.te index 8458f95..9af4c5f 100644 --- a/sepolicy/property.te +++ b/sepolicy/property.te @@ -4,7 +4,6 @@ type ina_status_prop, property_type; type receiver_error_prop, property_type; type sec_camera_prop, property_type, file_type; type sec_cnss_diag_prop, property_type; -type sec_fastcharge_prop, property_type; type tzdaemon_prop, property_type; type vendor_factory_prop, property_type; type vendor_members_prop, property_type; diff --git a/sepolicy/property_contexts b/sepolicy/property_contexts index 848a7f8..ae769cc 100644 --- a/sepolicy/property_contexts +++ b/sepolicy/property_contexts @@ -20,7 +20,6 @@ persist.tnr.process.plates u:object_r:sec_camera_prop:s0 persist.vendor.camera. u:object_r:sec_camera_prop:s0 persist.vendor.camera.feature.cac u:object_r:sec_camera_prop:s0 persist.vendor.camera.global.debug u:object_r:sec_camera_prop:s0 -persist.vendor.sec.fastchg_enabled u:object_r:sec_fastcharge_prop:s0 persist.vendor.members. u:object_r:vendor_members_prop:s0 ro.camera.req.fmq.size u:object_r:sec_camera_prop:s0 ro.camera.res.fmq.size u:object_r:sec_camera_prop:s0 diff --git a/thermal/Android.mk b/thermal/Android.mk new file mode 100644 index 0000000..746a4a9 --- /dev/null +++ b/thermal/Android.mk @@ -0,0 +1,28 @@ +# +# Copyright 2016 The Android Open Source 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. +# + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_CFLAGS := -Wno-unused-parameter +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := thermal.c +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := thermal.msm8996 +LOCAL_VENDOR_MODULE := true +LOCAL_HEADER_LIBRARIES := libutils_headers libhardware_headers +include $(BUILD_SHARED_LIBRARY) diff --git a/thermal/thermal.c b/thermal/thermal.c new file mode 100644 index 0000000..84640f6 --- /dev/null +++ b/thermal/thermal.c @@ -0,0 +1,282 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2016 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 +#include +#include +#include +#include + +#define LOG_TAG "ThermalHAL" +#include + +#include +#include + +#define MAX_LENGTH 50 + +#define CPU_USAGE_FILE "/proc/stat" +#define TEMPERATURE_FILE_FORMAT "/sys/class/thermal/thermal_zone%d/temp" +#define CPU_ONLINE_FILE_FORMAT "/sys/devices/system/cpu/cpu%d/online" + +#define BATTERY_SENSOR_NUM 29 +#define GPU_SENSOR_NUM 14 +#define SKIN_SENSOR_NUM 24 + +const int CPU_SENSORS[] = {4, 6, 9, 11}; + +#define CPU_NUM (sizeof(CPU_SENSORS) / sizeof(int)) +// Sum of CPU_NUM + 3 for GPU, BATTERY, and SKIN. +#define TEMPERATURE_NUM 7 + +//qcom, therm-reset-temp +#define CPU_SHUTDOWN_THRESHOLD 115 +//qcom, limit-temp +#define CPU_THROTTLING_THRESHOLD 60 +#define BATTERY_SHUTDOWN_THRESHOLD 60 +// device/google/marlin/thermal-engine-marlin.conf +#define SKIN_THROTTLING_THRESHOLD 44 +#define SKIN_SHUTDOWN_THRESHOLD 70 +#define VR_THROTTLED_BELOW_MIN 58 + +#define GPU_LABEL "GPU" +#define BATTERY_LABEL "battery" +#define SKIN_LABEL "skin" + +const char *CPU_LABEL[] = {"CPU0", "CPU1", "CPU2", "CPU3"}; + +/** + * Reads device temperature. + * + * @param sensor_num Number of sensor file with temperature. + * @param type Device temperature type. + * @param name Device temperature name. + * @param mult Multiplier used to translate temperature to Celsius. + * @param throttling_threshold Throttling threshold for the temperature. + * @param shutdown_threshold Shutdown threshold for the temperature. + * @param out Pointer to temperature_t structure that will be filled with current + * values. + * + * @return 0 on success or negative value -errno on error. + */ +static ssize_t read_temperature(int sensor_num, int type, const char *name, float mult, + float throttling_threshold, float shutdown_threshold, float vr_throttling_threshold, + temperature_t *out) { + FILE *file; + char file_name[MAX_LENGTH]; + float temp; + + sprintf(file_name, TEMPERATURE_FILE_FORMAT, sensor_num); + file = fopen(file_name, "r"); + if (file == NULL) { + ALOGE("%s: failed to open: %s", __func__, strerror(errno)); + return -errno; + } + if (1 != fscanf(file, "%f", &temp)) { + fclose(file); + ALOGE("%s: failed to read a float: %s", __func__, strerror(errno)); + return errno ? -errno : -EIO; + } + + fclose(file); + + (*out) = (temperature_t) { + .type = type, + .name = name, + .current_value = temp * mult, + .throttling_threshold = throttling_threshold, + .shutdown_threshold = shutdown_threshold, + .vr_throttling_threshold = vr_throttling_threshold + }; + + return 0; +} + +static ssize_t get_cpu_temperatures(temperature_t *list, size_t size) { + size_t cpu; + + for (cpu = 0; cpu < CPU_NUM; cpu++) { + if (cpu >= size) { + break; + } + // tsens_tz_sensor[4,6,9,11]: temperature in decidegrees Celsius. + ssize_t result = read_temperature(CPU_SENSORS[cpu], DEVICE_TEMPERATURE_CPU, CPU_LABEL[cpu], + 0.1, CPU_THROTTLING_THRESHOLD, CPU_SHUTDOWN_THRESHOLD, UNKNOWN_TEMPERATURE, + &list[cpu]); + if (result != 0) { + return result; + } + } + return cpu; +} + +static ssize_t get_temperatures(thermal_module_t *module, temperature_t *list, size_t size) { + ssize_t result = 0; + size_t current_index = 0; + + if (list == NULL) { + return TEMPERATURE_NUM; + } + + result = get_cpu_temperatures(list, size); + if (result < 0) { + return result; + } + current_index += result; + + // GPU temperature. + if (current_index < size) { + // tsens_tz_sensor14: temperature in decidegrees Celsius. + result = read_temperature(GPU_SENSOR_NUM, DEVICE_TEMPERATURE_GPU, GPU_LABEL, 0.1, + UNKNOWN_TEMPERATURE, UNKNOWN_TEMPERATURE, UNKNOWN_TEMPERATURE, + &list[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + + // Battery temperature. + if (current_index < size) { + // tsens_tz_sensor29: battery: temperature in millidegrees Celsius. + result = read_temperature(BATTERY_SENSOR_NUM, DEVICE_TEMPERATURE_BATTERY, BATTERY_LABEL, + 0.001, UNKNOWN_TEMPERATURE, BATTERY_SHUTDOWN_THRESHOLD, UNKNOWN_TEMPERATURE, + &list[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + + // Skin temperature. + if (current_index < size) { + // tsens_tz_sensor24: temperature in Celsius. + result = read_temperature(SKIN_SENSOR_NUM, DEVICE_TEMPERATURE_SKIN, SKIN_LABEL, 1., + SKIN_THROTTLING_THRESHOLD, SKIN_SHUTDOWN_THRESHOLD, VR_THROTTLED_BELOW_MIN, + &list[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + return TEMPERATURE_NUM; +} + +static ssize_t get_cpu_usages(thermal_module_t *module, cpu_usage_t *list) { + int vals, cpu_num, online; + ssize_t read; + uint64_t user, nice, system, idle, active, total; + char *line = NULL; + size_t len = 0; + size_t size = 0; + char file_name[MAX_LENGTH]; + FILE *file; + FILE *cpu_file; + + if (list == NULL) { + return CPU_NUM; + } + + file = fopen(CPU_USAGE_FILE, "r"); + if (file == NULL) { + ALOGE("%s: failed to open: %s", __func__, strerror(errno)); + return -errno; + } + + while ((read = getline(&line, &len, file)) != -1) { + // Skip non "cpu[0-9]" lines. + if (strnlen(line, read) < 4 || strncmp(line, "cpu", 3) != 0 || !isdigit(line[3])) { + free(line); + line = NULL; + len = 0; + continue; + } + + vals = sscanf(line, "cpu%d %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64, &cpu_num, &user, + &nice, &system, &idle); + + free(line); + line = NULL; + len = 0; + + if (vals != 5 || size == CPU_NUM) { + if (vals != 5) { + ALOGE("%s: failed to read CPU information from file: %s", __func__, + strerror(errno)); + } else { + ALOGE("/proc/stat file has incorrect format."); + } + fclose(file); + return errno ? -errno : -EIO; + } + + active = user + nice + system; + total = active + idle; + + // Read online CPU information. + snprintf(file_name, MAX_LENGTH, CPU_ONLINE_FILE_FORMAT, cpu_num); + cpu_file = fopen(file_name, "r"); + online = 0; + if (cpu_file == NULL) { + ALOGE("%s: failed to open file: %s (%s)", __func__, file_name, strerror(errno)); + fclose(file); + return -errno; + } + if (1 != fscanf(cpu_file, "%d", &online)) { + ALOGE("%s: failed to read CPU online information from file: %s (%s)", __func__, + file_name, strerror(errno)); + fclose(file); + fclose(cpu_file); + return errno ? -errno : -EIO; + } + fclose(cpu_file); + + list[size] = (cpu_usage_t) { + .name = CPU_LABEL[size], + .active = active, + .total = total, + .is_online = online + }; + + size++; + } + fclose(file); + + if (size != CPU_NUM) { + ALOGE("/proc/stat file has incorrect format."); + return -EIO; + } + return CPU_NUM; +} + +static struct hw_module_methods_t thermal_module_methods = { + .open = NULL, +}; + +thermal_module_t HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = THERMAL_HARDWARE_MODULE_API_VERSION_0_1, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = THERMAL_HARDWARE_MODULE_ID, + .name = "Galaxy Tab S3 Thermal HAL", + .author = "The Android Open Source Project", + .methods = &thermal_module_methods, + }, + .getTemperatures = get_temperatures, + .getCpuUsages = get_cpu_usages, +};