From b7e365414114cd5419fc075dc69a93b144fb9831 Mon Sep 17 00:00:00 2001 From: Matt Yang Date: Fri, 6 Mar 2020 17:10:44 +0800 Subject: [PATCH] v4 (20200306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增:支持骁龙865和骁龙765/765g 新增:补充骁龙855+和骁龙712的CPUID 新增:高通perf-hal运行状态显示 新增:迁移到Magisk 20.3模板,向下兼容到19.0 新增:兼容上游Linux 4.19触摸升频位点新路径 修复:指纹识别和相机服务性能受到限制 修复:减少均衡模式吃鸡卡顿,恢复性能最高的集群的负载预测 修复:减少MIUI的app启动动画卡顿,1阶段boost=30时长800ms,2阶段boost=10时长2000ms 改进:三集群设备补充设置超大核的访存延迟控制 改进:去除关于sched_boost_enabled的更改,已被上游弃用 Signed-off-by: Matt Yang --- META-INF/com/google/android/update-binary | 180 ++++++++------ README.md | 29 ++- customize.sh | 109 +++++++++ install.sh | 191 --------------- module.prop | 5 +- common/post-fs-data.sh => post-fs-data.sh | 0 profiles/sdm675_730/powercfg_modes.sh | 17 +- .../balance/perfboostsconfig.xml | 18 +- .../perfd_profiles/fast/perfboostsconfig.xml | 18 +- .../performance/perfboostsconfig.xml | 18 +- .../powersave/perfboostsconfig.xml | 18 +- profiles/sdm710/powercfg_modes.sh | 17 +- .../balance/perfboostsconfig.xml | 12 +- .../perfd_profiles/balance/targetconfig.xml | 2 +- .../perfd_profiles/fast/perfboostsconfig.xml | 12 +- .../perf/perfd_profiles/fast/targetconfig.xml | 2 +- .../performance/perfboostsconfig.xml | 12 +- .../performance/targetconfig.xml | 2 +- .../powersave/perfboostsconfig.xml | 12 +- .../perfd_profiles/powersave/targetconfig.xml | 2 +- .../system/vendor/etc/perf/targetconfig.xml | 2 +- profiles/sdm765/powercfg_modes.sh | 122 ++++++++++ .../vendor/etc/perf/commonresourceconfigs.xml | 230 ++++++++++++++++++ .../vendor/etc/perf/perfboostsconfig.xml | 10 + .../balance/perfboostsconfig.xml | 129 ++++++++++ .../perfd_profiles/balance/targetconfig.xml | 61 +++++ .../perfd_profiles/fast/perfboostsconfig.xml | 129 ++++++++++ .../perf/perfd_profiles/fast/targetconfig.xml | 61 +++++ .../performance/perfboostsconfig.xml | 129 ++++++++++ .../performance/targetconfig.xml | 61 +++++ .../powersave/perfboostsconfig.xml | 129 ++++++++++ .../perfd_profiles/powersave/targetconfig.xml | 61 +++++ .../system/vendor/etc/perf/targetconfig.xml | 61 +++++ .../vendor/etc/perf/targetresourceconfigs.xml | 70 ++++++ profiles/sdm845/powercfg_modes.sh | 9 +- .../balance/perfboostsconfig.xml | 8 +- .../perfd_profiles/fast/perfboostsconfig.xml | 8 +- .../performance/perfboostsconfig.xml | 8 +- .../powersave/perfboostsconfig.xml | 8 +- profiles/sdm855/powercfg_modes.sh | 17 +- .../balance/perfboostsconfig.xml | 8 +- .../perfd_profiles/balance/targetconfig.xml | 2 +- .../perfd_profiles/fast/perfboostsconfig.xml | 8 +- .../perf/perfd_profiles/fast/targetconfig.xml | 2 +- .../performance/perfboostsconfig.xml | 8 +- .../performance/targetconfig.xml | 2 +- .../powersave/perfboostsconfig.xml | 8 +- .../perfd_profiles/powersave/targetconfig.xml | 2 +- .../system/vendor/etc/perf/targetconfig.xml | 2 +- profiles/sdm865/powercfg_modes.sh | 131 ++++++++++ .../vendor/etc/perf/commonresourceconfigs.xml | 230 ++++++++++++++++++ .../vendor/etc/perf/perfboostsconfig.xml | 10 + .../balance/perfboostsconfig.xml | 113 +++++++++ .../perfd_profiles/balance/targetconfig.xml | 61 +++++ .../perfd_profiles/fast/perfboostsconfig.xml | 113 +++++++++ .../perf/perfd_profiles/fast/targetconfig.xml | 61 +++++ .../performance/perfboostsconfig.xml | 113 +++++++++ .../performance/targetconfig.xml | 61 +++++ .../powersave/perfboostsconfig.xml | 113 +++++++++ .../perfd_profiles/powersave/targetconfig.xml | 61 +++++ .../system/vendor/etc/perf/targetconfig.xml | 61 +++++ .../vendor/etc/perf/targetresourceconfigs.xml | 68 ++++++ script/libcommon.sh | 37 ++- script/libpowercfg.sh | 30 ++- script/{powercfg.sh => powercfg_main.sh} | 17 +- script/powercfg_once.sh | 8 +- script/settings_override.sh | 2 +- sepolicy.rule | 2 + common/service.sh => service.sh | 4 +- common/system.prop => system.prop | 0 uninstall.sh | 19 ++ 71 files changed, 2906 insertions(+), 440 deletions(-) create mode 100644 customize.sh delete mode 100644 install.sh rename common/post-fs-data.sh => post-fs-data.sh (100%) create mode 100644 profiles/sdm765/powercfg_modes.sh create mode 100644 profiles/sdm765/system/vendor/etc/perf/commonresourceconfigs.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfboostsconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/targetconfig.xml create mode 100644 profiles/sdm765/system/vendor/etc/perf/targetresourceconfigs.xml create mode 100644 profiles/sdm865/powercfg_modes.sh create mode 100644 profiles/sdm865/system/vendor/etc/perf/commonresourceconfigs.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfboostsconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/targetconfig.xml create mode 100644 profiles/sdm865/system/vendor/etc/perf/targetresourceconfigs.xml rename script/{powercfg.sh => powercfg_main.sh} (83%) create mode 100644 sepolicy.rule rename common/service.sh => service.sh (89%) rename common/system.prop => system.prop (100%) create mode 100644 uninstall.sh diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index 112eb28..29240cd 100644 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -1,12 +1,15 @@ #!/sbin/sh -TMPDIR=/dev/tmp -MOUNTPATH=/dev/magisk_img +################# +# Initialization +################# -# Default permissions umask 022 -# Initial cleanup +# Global vars +TMPDIR=/dev/tmp +PERSISTDIR=/sbin/.magisk/mirror/persist + rm -rf $TMPDIR 2>/dev/null mkdir -p $TMPDIR @@ -14,20 +17,33 @@ mkdir -p $TMPDIR ui_print() { echo "$1"; } require_new_magisk() { - ui_print "***********************************" - ui_print " Please install the latest Magisk! " - ui_print "***********************************" + ui_print "*******************************" + ui_print " Please install Magisk v19.0+! " + ui_print "*******************************" exit 1 } -imageless_magisk() { - [ $MAGISK_VER_CODE -gt 18100 ] +is_legacy_script() { + unzip -l "$ZIPFILE" install.sh | grep -q install.sh return $? } -########################################################################################## +print_modname() { + local len + len=`echo -n $MODNAME | wc -c` + len=$((len + 2)) + local pounds=`printf "%${len}s" | tr ' ' '*'` + ui_print "$pounds" + ui_print " $MODNAME " + ui_print "$pounds" + ui_print "*******************" + ui_print " Powered by Magisk " + ui_print "*******************" +} + +############## # Environment -########################################################################################## +############## OUTFD=$2 ZIPFILE=$3 @@ -35,12 +51,9 @@ ZIPFILE=$3 mount /data 2>/dev/null # Load utility functions -if [ -f /data/adb/magisk/util_functions.sh ]; then - . /data/adb/magisk/util_functions.sh - NVBASE=/data/adb -else - require_new_magisk -fi +[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk +. /data/adb/magisk/util_functions.sh +[ $MAGISK_VER_CODE -gt 18100 ] || require_new_magisk # Preperation for flashable zips setup_flashable @@ -54,98 +67,107 @@ api_level_arch_detect # Setup busybox and binaries $BOOTMODE && boot_actions || recovery_actions -########################################################################################## +############## # Preparation -########################################################################################## - -# Extract common files -unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2 - -[ ! -f $TMPDIR/install.sh ] && abort "! Unable to extract zip file!" -# Load install script -. $TMPDIR/install.sh +############## -if imageless_magisk; then - $BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules - MODULEROOT=$NVBASE/$MODDIRNAME -else - $BOOTMODE && IMGNAME=magisk_merge.img || IMGNAME=magisk.img - IMG=$NVBASE/$IMGNAME - request_zip_size_check "$ZIPFILE" - mount_magisk_img - MODULEROOT=$MOUNTPATH -fi +# Extract prop file +unzip -o "$ZIPFILE" module.prop -d $TMPDIR >&2 +[ ! -f $TMPDIR/module.prop ] && abort "! Unable to extract zip file!" +$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules +MODULEROOT=$NVBASE/$MODDIRNAME MODID=`grep_prop id $TMPDIR/module.prop` MODPATH=$MODULEROOT/$MODID - -print_modname - -ui_print "******************************" -ui_print "Powered by Magisk (@topjohnwu)" -ui_print "******************************" - -########################################################################################## -# Install -########################################################################################## +MODNAME=`grep_prop name $TMPDIR/module.prop` # Create mod paths rm -rf $MODPATH 2>/dev/null mkdir -p $MODPATH -on_install +########## +# Install +########## + +if is_legacy_script; then + unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2 + + # Load install script + . $TMPDIR/install.sh -# Remove placeholder -rm -f $MODPATH/system/placeholder 2>/dev/null + # Callbacks + print_modname + on_install -# Custom uninstaller -[ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh + # Custom uninstaller + [ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh -# Auto Mount -if imageless_magisk; then + # Skip mount $SKIPMOUNT && touch $MODPATH/skip_mount + + # prop file + $PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop + + # Module info + cp -af $TMPDIR/module.prop $MODPATH/module.prop + + # post-fs-data scripts + $POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh + + # service scripts + $LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh + + ui_print "- Setting permissions" + set_permissions else - $SKIPMOUNT || touch $MODPATH/auto_mount -fi + print_modname -# prop files -$PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop + unzip -o "$ZIPFILE" customize.sh -d $MODPATH >&2 -# Module info -cp -af $TMPDIR/module.prop $MODPATH/module.prop -if $BOOTMODE; then - # Update info for Magisk Manager - if imageless_magisk; then - mktouch $NVBASE/modules/$MODID/update - cp -af $TMPDIR/module.prop $NVBASE/modules/$MODID/module.prop - else - mktouch /sbin/.magisk/img/$MODID/update - cp -af $TMPDIR/module.prop /sbin/.magisk/img/$MODID/module.prop - fi -fi + if ! grep -q '^SKIPUNZIP=1$' $MODPATH/customize.sh 2>/dev/null; then + ui_print "- Extracting module files" + unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >&2 -# post-fs-data mode scripts -$POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh + # Default permissions + set_perm_recursive $MODPATH 0 0 0755 0644 + fi -# service mode scripts -$LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh + # Load customization script + [ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh +fi # Handle replace folders for TARGET in $REPLACE; do + ui_print "- Replace target: $TARGET" mktouch $MODPATH$TARGET/.replace done -ui_print "- Setting permissions" -set_permissions +if $BOOTMODE; then + # Update info for Magisk Manager + mktouch $NVBASE/modules/$MODID/update + cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop +fi + +# Copy over custom sepolicy rules +if [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then + ui_print "- Installing custom sepolicy patch" + PERSISTMOD=$PERSISTDIR/magisk/$MODID + mkdir -p $PERSISTMOD + cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule +fi + +# Remove stuffs that don't belong to modules +rm -rf \ +$MODPATH/system/placeholder $MODPATH/customize.sh \ +$MODPATH/README.md $MODPATH/.git* 2>/dev/null -########################################################################################## +############## # Finalizing -########################################################################################## +############## cd / -imageless_magisk || unmount_magisk_img $BOOTMODE || recovery_cleanup -rm -rf $TMPDIR $MOUNTPATH +rm -rf $TMPDIR ui_print "- Done" exit 0 diff --git a/README.md b/README.md index 8582bf6..1dd44ae 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ Details see [the lead project](https://github.com/yc9559/sdm855-tune/commits/mas - fast: providing stable performance capacity considering the TDP limitation of device chassis ```plain +sdm865 +- powersave: 1.8+1.6+2.4g, boost 1.8+2.0+2.6g, min 0.3+0.7+1.1 +- balance: 1.8+2.0+2.6g, boost 1.8+2.4+2.7g, min 0.7+0.7+1.1 +- performance: 1.8+2.4+2.8g, boost 1.8+2.4+2.8g, min 0.7+0.7+1.1 +- fast: 1.8+2.0+2.7g, boost 1.8+2.4+2.8g, min 0.7+1.2+1.2 + sdm855/sdm855+ - powersave: 1.7+1.6+2.4g, boost 1.7+2.0+2.6g, min 0.3+0.7+0.8 - balance: 1.7+2.0+2.6g, boost 1.7+2.4+2.7g, min 0.5+0.7+0.8 @@ -26,7 +32,13 @@ sdm845 - performance: 1.7+2.8g, boost 1.7+2.8g, min 0.5+0.8 - fast: 1.7+2.4g, boost 1.7+2.8g, min 0.5+1.6 -sdm730 +sdm765/sdm765g +- powersave: 1.8+1.7+2.0g, boost 1.8+2.0+2.2g, min 0.3+0.6+0.8 +- balance: 1.8+2.0+2.2g, boost 1.8+2.2+2.3/2.4g, min 0.5+0.6+0.6 +- performance: 1.8+2.2+2.3g, boost 1.8+2.2+2.3/2.4g, min 0.5+0.6+0.8 +- fast: 1.8+2.0+2.2g, boost 1.8+2.2+2.3/2.4g, min 0.5+1.1+1.4 + +sdm730/sdm730g - powersave: 1.7+1.5g, boost 1.7+1.9g, min 0.3+0.3 - balance: 1.7+1.9g, boost 1.7+2.1g, min 0.5+0.6 - performance: 1.8+2.2g, boost 1.8+2.2g, min 0.5+0.6 @@ -38,19 +50,18 @@ sdm675 - performance: 1.8+2.0g, boost 1.8+2.0g, min 0.5+0.6 - fast: 1.8+1.7g, boost 1.8+2.0g, min 0.5+1.2 -sdm710 +sdm710/sdm712 - powersave: 1.7+1.8g, boost 1.7+2.0g, min 0.3+0.3 -- balance: 1.7+2.0g, boost 1.7+2.2g, min 0.5+0.6 -- performance: 1.7+2.2g, boost 1.7+2.2g, min 0.5+0.6 -- fast: 1.7+2.0g, boost 1.7+2.2g, min 0.5+1.5 +- balance: 1.7+2.0g, boost 1.7+2.2/2.3g, min 0.5+0.6 +- performance: 1.7+2.2g, boost 1.7+2.2/2.3g, min 0.5+0.6 +- fast: 1.7+2.0g, boost 1.7+2.2/2.3g, min 0.5+1.5 ``` ## Requirements -1. sdm855 or sdm845 or sdm730 or sdm675 or sdm710 -2. Android >= 8.0 -3. Rooted -4. Magisk >= 17.0 +1. Android >= 8.0 +2. Rooted +3. Magisk >= 19.0 ## Installation diff --git a/customize.sh b/customize.sh new file mode 100644 index 0000000..f7badc3 --- /dev/null +++ b/customize.sh @@ -0,0 +1,109 @@ +#!/sbin/sh + +# If you need even more customization and prefer to +# do everything on your own, declare SKIPUNZIP=1 +SKIPUNZIP=0 + +# List all directories you want to directly replace in the system +# Construct your list in the following format +# This is an example +# REPLACE_EXAMPLE=" +# /system/app/Youtube +# /system/priv-app/SystemUI +# /system/framework +# " +REPLACE="" + +# ! DO NOT use any Magisk internal paths as those are NOT public API. +# ! DO NOT use other functions in util_functions.sh as they are NOT public API. +# ! Non public APIs are not guranteed to maintain compatibility between releases. + +# Available variables: +# MAGISK_VER (string): the version string of current installed Magisk +# MAGISK_VER_CODE (int): the version code of current installed Magisk +# BOOTMODE (bool): true if the module is currently installing in Magisk Manager +# MODPATH (path): the path where your module files should be installed +# TMPDIR (path): a place where you can temporarily store files +# ZIPFILE (path): your module's installation zip +# ARCH (string): the architecture of the device. Value is either arm, arm64, x86, or x64 +# IS64BIT (bool): true if $ARCH is either arm64 or x64 +# API (int): the API level (Android version) of the device + +# Availible functions: +# ui_print +# print to console +# Avoid using 'echo' as it will not display in custom recovery's console +# abort +# print error message to console and terminate installation +# Avoid using 'exit' as it will skip the termination cleanup steps +# set_perm [context] +# if [context] is not set, the default is "u:object_r:system_file:s0" +# this function is a shorthand for the following commands: +# chown owner.group platform_name +# chmod permission platform_name +# chcon context platform_name +# set_perm_recursive [context] +# if [context] is not set, the default is "u:object_r:system_file:s0" +# for all files in , it will call: +# set_perm file owner group filepermission context +# for all directories in (including itself), it will call: +# set_perm dir owner group dirpermission context + +# $1:platform_name +_extract_platform_file() { + ui_print "- Extracting platform module files" + mv $MODPATH/profiles/$1/system $MODPATH/ + mv $MODPATH/profiles/$1/powercfg_modes.sh $MODPATH/script/ + rm -rf $MODPATH/profiles +} + + +ui_print "" +ui_print "* Perfd-opt https://github.com/yc9559/perfd-opt/" +ui_print "* Author: Matt Yang" +ui_print "* Version: v4 (20200306)" +ui_print "" + +platform_name="$(getprop ro.board.platform)" +case "$(getprop ro.board.platform)" in +"kona") + ui_print "- The platform of this device is sdm865($platform_name)" + _extract_platform_file "sdm865" + ;; +"msmnile") + ui_print "- The platform of this device is sdm855/855+($platform_name)" + _extract_platform_file "sdm855" + ;; +"sdm845") + ui_print "- The platform of this device is sdm845($platform_name)" + _extract_platform_file "sdm845" + ;; +"lito") + ui_print "- The platform of this device is sdm765/sdm765g($platform_name)" + _extract_platform_file "sdm765" + ;; +"sm6150") + [ -f /sys/devices/soc0/soc_id ] && SOC_ID="$(cat /sys/devices/soc0/soc_id)" + [ -f /sys/devices/system/soc/soc0/id ] && SOC_ID="$(cat /sys/devices/system/soc/soc0/id)" + case "$SOC_ID" in + 365 | 366) PLATFORM_NAME="sdm730" ;; + 355 | 369) PLATFORM_NAME="sdm675" ;; + esac + ui_print "- The platform of this device is $PLATFORM_NAME($platform_name)" + _extract_platform_file "sdm675_730" + ;; +"sdm710") + ui_print "- The platform of this device is sdm710/sdm712($platform_name)" + _extract_platform_file "sdm710" + ;; +*) + abort "- [$platform_name] not supported, terminated." + ;; +esac + +# Only some special files require specific permissions +# The default permissions should be good enough for most cases +# set_perm_recursive $MODPATH/system/lib 0 0 0755 0644 +# set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0 +# set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0 +# set_perm $MODPATH/system/lib/libart.so 0 0 0644 diff --git a/install.sh b/install.sh deleted file mode 100644 index e609edb..0000000 --- a/install.sh +++ /dev/null @@ -1,191 +0,0 @@ -########################################################################################## -# -# Magisk Module Installer Script -# -########################################################################################## -########################################################################################## -# -# Instructions: -# -# 1. Place your files into system folder (delete the placeholder file) -# 2. Fill in your module's info into module.prop -# 3. Configure and implement callbacks in this file -# 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh -# 5. Add your additional or modified system properties into common/system.prop -# -########################################################################################## - -########################################################################################## -# Config Flags -########################################################################################## - -# Set to true if you do *NOT* want Magisk to mount -# any files for you. Most modules would NOT want -# to set this flag to true -SKIPMOUNT=false - -# Set to true if you need to load system.prop -PROPFILE=true - -# Set to true if you need post-fs-data script -POSTFSDATA=true - -# Set to true if you need late_start service script -LATESTARTSERVICE=true - -########################################################################################## -# Replace list -########################################################################################## - -# List all directories you want to directly replace in the system -# Check the documentations for more info why you would need this - -# Construct your list in the following format -# This is an example -# REPLACE_EXAMPLE=" -# /system/app/Youtube -# /system/priv-app/SystemUI -# /system/priv-app/Settings -# /system/framework -# " - -# Construct your own list here -REPLACE="" - -########################################################################################## -# -# Function Callbacks -# -# The following functions will be called by the installation framework. -# You do not have the ability to modify update-binary, the only way you can customize -# installation is through implementing these functions. -# -# When running your callbacks, the installation framework will make sure the Magisk -# internal busybox path is *PREPENDED* to PATH, so all common commands shall exist. -# Also, it will make sure /data, /system, and /vendor is properly mounted. -# -########################################################################################## -########################################################################################## -# -# The installation framework will export some variables and functions. -# You should use these variables and functions for installation. -# -# ! DO NOT use any Magisk internal paths as those are NOT public API. -# ! DO NOT use other functions in util_functions.sh as they are NOT public API. -# ! Non public APIs are not guranteed to maintain compatibility between releases. -# -# Available variables: -# -# MAGISK_VER (string): the version string of current installed Magisk -# MAGISK_VER_CODE (int): the version code of current installed Magisk -# BOOTMODE (bool): true if the module is currently installing in Magisk Manager -# MODPATH (path): the path where your module files should be installed -# TMPDIR (path): a place where you can temporarily store files -# ZIPFILE (path): your module's installation zip -# ARCH (string): the architecture of the device. Value is either arm, arm64, x86, or x64 -# IS64BIT (bool): true if $ARCH is either arm64 or x64 -# API (int): the API level (Android version) of the device -# -# Availible functions: -# -# ui_print -# print to console -# Avoid using 'echo' as it will not display in custom recovery's console -# -# abort -# print error message to console and terminate installation -# Avoid using 'exit' as it will skip the termination cleanup steps -# -# set_perm [context] -# if [context] is empty, it will default to "u:object_r:system_file:s0" -# this function is a shorthand for the following commands -# chown owner.group target -# chmod permission target -# chcon context target -# -# set_perm_recursive [context] -# if [context] is empty, it will default to "u:object_r:system_file:s0" -# for all files in , it will call: -# set_perm file owner group filepermission context -# for all directories in (including itself), it will call: -# set_perm dir owner group dirpermission context -# -##########################################################################################x -##########################################################################################j -# If you need boot scripts, DO NOT use general boot scripts (post-fs-data.d/service.d) -# ONLY use module scripts as it respects the module status (remove/disable) and is -# guaranteed to maintain the same behavior in future Magisk releases.xin -# Enable boot scripts by setting the flags in the config section above.jie -########################################################################################## - -# Set what you want to display when installing your module - -print_modname() { - ui_print "" - ui_print "Perfd-opt https://github.com/yc9559/perfd-opt/" - ui_print "Author: Matt Yang" - ui_print "Version: v3 (20200222)" - ui_print "" -} - -# Copy/extract your module files into $MODPATH in on_install. - -on_install() { - target=`getprop ro.board.platform` - ui_print "- The platform of this device is $target" - - case "$target" in - "msmnile") - extract_common_file - extract_platform_file "sdm855" - ;; - "sdm845") - extract_common_file - extract_platform_file "sdm845" - ;; - "sm6150") - extract_common_file - extract_platform_file "sdm675_730" - ;; - "sdm710") - extract_common_file - extract_platform_file "sdm710" - ;; - *) - abort "- $target not supported, terminated." - ;; - esac -} - -# Only some special files require specific permissions -# This function will be called after on_install is done -# The default permissions should be good enough for most cases - -set_permissions() { - # The following is the default rule, DO NOT remove - set_perm_recursive $MODPATH 0 0 0755 0644 - - # Here are some examples: - # set_perm_recursive $MODPATH/system/lib 0 0 0755 0644 - # set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0 - # set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0 - # set_perm $MODPATH/system/lib/libart.so 0 0 0644 -} - -# You can add more functions to assist your custom script code - -extract_common_file() { - ui_print "- Extracting common module files" - unzip -o "$ZIPFILE" 'system/*' -d $MODPATH >&2 - unzip -o "$ZIPFILE" 'script/*' -d $MODPATH >&2 - unzip -o "$ZIPFILE" 'bin/*' -d $MODPATH >&2 -} - -# $1:platform_name -extract_platform_file() { - ui_print "- Extracting platform module files" - unzip -o "$ZIPFILE" 'profiles/*' -d $MODPATH >&2 - mv $MODPATH/profiles/$1/system $MODPATH/ - mv $MODPATH/profiles/$1/powercfg_modes.sh $MODPATH/script/ - rm -rf $MODPATH/profiles -} diff --git a/module.prop b/module.prop index 56c85cc..a5f67fb 100644 --- a/module.prop +++ b/module.prop @@ -1,7 +1,6 @@ id=perfd-opt name=Perfd-opt -version=v3 (20200222) -versionCode=1 +version=v4 (20200306) +versionCode=4 author=Matt Yang description=Provide better energy efficiency on EAS platforms by tuning CAF boostframework configuration. Repo: https://github.com/yc9559/perfd-opt/ -minMagisk=17000 diff --git a/common/post-fs-data.sh b/post-fs-data.sh similarity index 100% rename from common/post-fs-data.sh rename to post-fs-data.sh diff --git a/profiles/sdm675_730/powercfg_modes.sh b/profiles/sdm675_730/powercfg_modes.sh index d92d036..e1d7f30 100644 --- a/profiles/sdm675_730/powercfg_modes.sh +++ b/profiles/sdm675_730/powercfg_modes.sh @@ -3,27 +3,27 @@ # Perfd-opt https://github.com/yc9559/perfd-opt/ # Author: Matt Yang # Platform: sm6150 -# Version: v3 (20200222) +# Version: v4 (20200306) BASEDIR="$(dirname "$0")" . $BASEDIR/pathinfo.sh . $BASEDIR/libpowercfg.sh -# "365,366"="sdmmagpie"="sdm730" +# "365,366"="sdmmagpie"="sdm730/sdm730g" # "355,369"="msmsteppe"="sdm675" [ -f /sys/devices/soc0/soc_id ] && SOC_ID="$(cat /sys/devices/soc0/soc_id)" [ -f /sys/devices/system/soc/soc0/id ] && SOC_ID="$(cat /sys/devices/system/soc/soc0/id)" case "$SOC_ID" in - 365|366) PLATFORM_NAME="sdm730" ;; + 365|366) PLATFORM_NAME="sdm730/sdm730g" ;; 355|369) PLATFORM_NAME="sdm675" ;; esac BWMON_CPU_LLC="soc:qcom,cpu-cpu-llcc-bw" BWMON_LLC_DDR="soc:qcom,cpu-llcc-ddr-bw" BIG_L3_LAT="soc:qcom,cpu6-cpu-l3-lat" BIG_DDR_LAT="soc:qcom,cpu6-llcc-ddr-lat" -STUNE_BG_CPUS="0-5" -STUNE_FG_CPUS="0-7" +STUNE_BG_CPUS="0-3" +STUNE_FG_CPUS="0-6" apply_common() { @@ -55,7 +55,6 @@ apply_powersave() lock_val "0:1000000 6:1000000" $CPU_BOOST/input_boost_freq lock_val "800" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "0" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "13000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -72,11 +71,10 @@ apply_balance() esac set_sched_migrate "95" "95" "140" "100" set_corectl_param "min_cpus" "0:4 6:2" - set_governor_param "schedutil/pl" "0:0 6:0" + set_governor_param "schedutil/pl" "0:0 6:1" lock_val "0:1000000 6:1000000" $CPU_BOOST/input_boost_freq lock_val "800" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "0" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "13000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -97,7 +95,6 @@ apply_performance() lock_val "0:1000000 6:1200000" $CPU_BOOST/input_boost_freq lock_val "2000" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "10" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "15000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -118,7 +115,6 @@ apply_fast() lock_val "0:1000000 6:1200000" $CPU_BOOST/input_boost_freq lock_val "2000" $CPU_BOOST/input_boost_ms lock_val "1" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "30" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "15000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -129,6 +125,7 @@ apply_fast() apply_once() { mutate "$STUNE_FG_CPUS" /dev/cpuset/foreground/cpus + lock_val "$STUNE_BG_CPUS" /dev/cpuset/background/cpus lock_val "$STUNE_BG_CPUS" /dev/cpuset/restricted/cpus lock_val "$STUNE_BG_CPUS" /dev/cpuset/display/cpus set_corectl_param "enable" "0:1 6:1" diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml index 859a65b..121fec0 100644 --- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml +++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml @@ -16,18 +16,18 @@ - + - + - + - + + Resources="0x40800000, 1600, 0x40800100, 1500" /> diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml index 2a350d2..aa42fda 100644 --- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml +++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml @@ -16,18 +16,18 @@ - + - + - + - + + Resources="0x40800000, 1600, 0x40800100, 1500" /> diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml index 2a350d2..aa42fda 100644 --- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml +++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml @@ -16,18 +16,18 @@ - + - + - + - + + Resources="0x40800000, 1600, 0x40800100, 1500" /> diff --git a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml index c886389..db9b78c 100644 --- a/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml +++ b/profiles/sdm675_730/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml @@ -16,18 +16,18 @@ - + - + - + - + + Resources="0x40800000, 1600, 0x40800100, 1500" /> diff --git a/profiles/sdm710/powercfg_modes.sh b/profiles/sdm710/powercfg_modes.sh index 06ab186..c3dd486 100644 --- a/profiles/sdm710/powercfg_modes.sh +++ b/profiles/sdm710/powercfg_modes.sh @@ -2,20 +2,20 @@ # Platform Power Modes # Perfd-opt https://github.com/yc9559/perfd-opt/ # Author: Matt Yang -# Platform: sdm710 -# Version: v3 (20200222) +# Platform: sdm710/sdm712 +# Version: v4 (20200306) BASEDIR="$(dirname "$0")" . $BASEDIR/pathinfo.sh . $BASEDIR/libpowercfg.sh -PLATFORM_NAME="sdm710" +PLATFORM_NAME="sdm710/sdm712" BWMON_CPU_LLC="soc:qcom,cpubw" BWMON_LLC_DDR="soc:qcom,cpubw" BIG_L3_LAT="soc:qcom,l3-cpu6" BIG_DDR_LAT="soc:qcom,memlat-cpu6" -STUNE_BG_CPUS="0-5" -STUNE_FG_CPUS="0-7" +STUNE_BG_CPUS="0-3" +STUNE_FG_CPUS="0-6" apply_common() { @@ -44,7 +44,6 @@ apply_powersave() lock_val "0:998400 6:1132800" $CPU_BOOST/input_boost_freq lock_val "800" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "0" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "6000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -58,11 +57,10 @@ apply_balance() set_cpufreq_max "0:1708800 6:2016000" set_sched_migrate "95" "95" "140" "100" set_corectl_param "min_cpus" "0:4 6:2" - set_governor_param "schedutil/pl" "0:0 6:0" + set_governor_param "schedutil/pl" "0:0 6:1" lock_val "0:998400 6:1132800" $CPU_BOOST/input_boost_freq lock_val "800" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "0" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "6000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -80,7 +78,6 @@ apply_performance() lock_val "0:998400 6:1536000" $CPU_BOOST/input_boost_freq lock_val "2000" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "10" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "7000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -98,7 +95,6 @@ apply_fast() lock_val "0:998400 6:1536000" $CPU_BOOST/input_boost_freq lock_val "2000" $CPU_BOOST/input_boost_ms lock_val "1" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "30" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "7000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -109,6 +105,7 @@ apply_fast() apply_once() { mutate "$STUNE_FG_CPUS" /dev/cpuset/foreground/cpus + lock_val "$STUNE_BG_CPUS" /dev/cpuset/background/cpus lock_val "$STUNE_BG_CPUS" /dev/cpuset/restricted/cpus lock_val "$STUNE_BG_CPUS" /dev/cpuset/display/cpus set_corectl_param "enable" "0:1 6:1" diff --git a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml index 7b4ea18..f7b18ab 100644 --- a/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml +++ b/profiles/sdm710/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml @@ -16,16 +16,16 @@ - + - + + Resources="0x40804000, 2300, 0x40800000, 1600, 0x40800100, 1500, 0x40C18000, 30, 0x41000000, 2, 0x41000100, 6, 0x42C10000, 1, 0x41444100, 1, 0x41800000, 55" /> + Resources="0x40800000, 1600, 0x40800100, 1500" /> - + - + + Resources="0x40804000, 0xFFF, 0x40800000, 0xFFF, 0x40800100, 0xFFF, 0x40C18000, 30, 0x41000000, 2, 0x41000100, 6, 0x42C10000, 1, 0x41444100, 1, 0x41800000, 55" /> + Resources="0x40800000, 1600, 0x40800100, 1500" /> - + - + + Resources="0x40804000, 0xFFF, 0x40800000, 0xFFF, 0x40800100, 0xFFF, 0x40C18000, 30, 0x41000000, 2, 0x41000100, 6, 0x42C10000, 1, 0x41444100, 1, 0x41800000, 55" /> + Resources="0x40800000, 1600, 0x40800100, 1500" /> - + - + + Resources="0x40804000, 2000, 0x40800000, 1600, 0x40800100, 1500, 0x40C18000, 30, 0x41000000, 2, 0x41000100, 6, 0x42C10000, 1, 0x41444100, 1, 0x41800000, 55" /> + Resources="0x40800000, 1600, 0x40800100, 1500" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfboostsconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfboostsconfig.xml new file mode 100644 index 0000000..3a489f3 --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfboostsconfig.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml new file mode 100644 index 0000000..412e47d --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml new file mode 100644 index 0000000..ab7e8b8 --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml new file mode 100644 index 0000000..ae72e81 --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml new file mode 100644 index 0000000..ab7e8b8 --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml new file mode 100644 index 0000000..ae72e81 --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml new file mode 100644 index 0000000..f24534a --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml new file mode 100644 index 0000000..c645e0e --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml new file mode 100644 index 0000000..2aa091a --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/targetconfig.xml b/profiles/sdm765/system/vendor/etc/perf/targetconfig.xml new file mode 100644 index 0000000..430ddeb --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm765/system/vendor/etc/perf/targetresourceconfigs.xml b/profiles/sdm765/system/vendor/etc/perf/targetresourceconfigs.xml new file mode 100644 index 0000000..0cf0aa6 --- /dev/null +++ b/profiles/sdm765/system/vendor/etc/perf/targetresourceconfigs.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm845/powercfg_modes.sh b/profiles/sdm845/powercfg_modes.sh index 8d3323c..2c5b8e7 100644 --- a/profiles/sdm845/powercfg_modes.sh +++ b/profiles/sdm845/powercfg_modes.sh @@ -3,7 +3,7 @@ # Perfd-opt https://github.com/yc9559/perfd-opt/ # Author: Matt Yang # Platform: sdm845 -# Version: v3 (20200222) +# Version: v4 (20200306) BASEDIR="$(dirname "$0")" . $BASEDIR/pathinfo.sh @@ -44,7 +44,6 @@ apply_powersave() lock_val "0:1132800 4:1286400" $CPU_BOOST/input_boost_freq lock_val "800" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "0" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "9500" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -58,11 +57,10 @@ apply_balance() set_cpufreq_max "0:1766400 4:2476800" set_sched_migrate "95" "95" "140" "100" set_corectl_param "min_cpus" "0:4 4:2" - set_governor_param "schedutil/pl" "0:0 4:0" + set_governor_param "schedutil/pl" "0:0 4:1" lock_val "0:1132800 4:1286400" $CPU_BOOST/input_boost_freq lock_val "800" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "0" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "9500" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -80,7 +78,6 @@ apply_performance() lock_val "0:1132800 4:1612800" $CPU_BOOST/input_boost_freq lock_val "2000" $CPU_BOOST/input_boost_ms lock_val "2" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "10" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "11000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -98,7 +95,6 @@ apply_fast() lock_val "0:1132800 4:1612800" $CPU_BOOST/input_boost_freq lock_val "2000" $CPU_BOOST/input_boost_ms lock_val "1" $CPU_BOOST/sched_boost_on_input - mutate "1" $ST_TOP/schedtune.sched_boost_enabled mutate "30" $ST_TOP/schedtune.boost mutate "1" $ST_TOP/schedtune.prefer_idle mutate "11000" $DEVFREQ/$BWMON_CPU_LLC/max_freq @@ -109,6 +105,7 @@ apply_fast() apply_once() { mutate "$STUNE_FG_CPUS" /dev/cpuset/foreground/cpus + lock_val "$STUNE_BG_CPUS" /dev/cpuset/background/cpus lock_val "$STUNE_BG_CPUS" /dev/cpuset/restricted/cpus lock_val "$STUNE_BG_CPUS" /dev/cpuset/display/cpus set_corectl_param "enable" "0:1 4:1" diff --git a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml index a30c4a1..0d710cb 100644 --- a/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml +++ b/profiles/sdm845/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml @@ -16,12 +16,12 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfboostsconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfboostsconfig.xml new file mode 100644 index 0000000..1564ee0 --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfboostsconfig.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml new file mode 100644 index 0000000..f03c991 --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml new file mode 100644 index 0000000..50d2dae --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml new file mode 100644 index 0000000..58b4c9d --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml new file mode 100644 index 0000000..8671f48 --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml new file mode 100644 index 0000000..58b4c9d --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml new file mode 100644 index 0000000..9f51c6f --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml new file mode 100644 index 0000000..63f7dcb --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml new file mode 100644 index 0000000..b2df502 --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/targetconfig.xml b/profiles/sdm865/system/vendor/etc/perf/targetconfig.xml new file mode 100644 index 0000000..412e8bf --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/targetconfig.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/profiles/sdm865/system/vendor/etc/perf/targetresourceconfigs.xml b/profiles/sdm865/system/vendor/etc/perf/targetresourceconfigs.xml new file mode 100644 index 0000000..91be193 --- /dev/null +++ b/profiles/sdm865/system/vendor/etc/perf/targetresourceconfigs.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/script/libcommon.sh b/script/libcommon.sh index 3420605..5fa239a 100644 --- a/script/libcommon.sh +++ b/script/libcommon.sh @@ -2,7 +2,7 @@ # Basic Tool Library # https://github.com/yc9559/ # Author: Matt Yang -# Version: 20200217 +# Version: 20200227 BASEDIR="$(dirname "$0")" . $BASEDIR/pathinfo.sh @@ -75,8 +75,7 @@ wait_until_login() sleep 2 done # we doesn't have the permission to rw "/sdcard" before the user unlocks the screen - while [ ! -f "$PANEL_FILE" ]; do - touch "$PANEL_FILE" + while [ ! -d "/sdcard/Android" ]; do sleep 2 done } @@ -116,3 +115,35 @@ change_task_affinity() done done } + +# $1:task_name $2:nice(relative to 120) +change_task_nice() +{ + # avoid matching grep itself + # ps -Ao pid,args | grep kswapd + # 150 [kswapd0] + # 16490 grep kswapd + local ps_ret + ps_ret="$(ps -Ao pid,args)" + for temp_pid in $(echo "$ps_ret" | grep "$1" | awk '{print $1}'); do + for temp_tid in $(ls "/proc/$temp_pid/task/"); do + renice "$2" -p "$temp_tid" + done + done +} + +############################### +# Platform info functions +############################### + +# $1:"4.14" return:string_in_version +match_linux_version() +{ + echo "$(cat /proc/version | grep "$1")" +} + +# return:platform_name +get_platform_name() +{ + echo "$(getprop ro.board.platform)" +} diff --git a/script/libpowercfg.sh b/script/libpowercfg.sh index 712637f..b7fdc82 100644 --- a/script/libpowercfg.sh +++ b/script/libpowercfg.sh @@ -2,7 +2,7 @@ # Powercfg Library # https://github.com/yc9559/ # Author: Matt Yang -# Version: 20200216 +# Version: 20200225 BASEDIR="$(dirname "$0")" . $BASEDIR/pathinfo.sh @@ -20,7 +20,6 @@ PERFCFG_REL="./system/vendor/etc/perf" SCHED="/proc/sys/kernel" CPU="/sys/devices/system/cpu" -CPU_BOOST="/sys/module/cpu_boost/parameters" KSGL="/sys/class/kgsl/kgsl-3d0" DEVFREQ="/sys/class/devfreq" LPM="/sys/module/lpm_levels/parameters" @@ -30,6 +29,12 @@ ST_FORE="/dev/stune/foreground" ST_BACK="/dev/stune/background" SDA_Q="/sys/block/sda/queue" +if [ "$(match_linux_version 4.19)" != "" ]; then + CPU_BOOST="/sys/devices/system/cpu/cpu_boost/parameters" +else + CPU_BOOST="/sys/module/cpu_boost/parameters" +fi + ############################### # Powermodes helper functions ############################### @@ -110,8 +115,10 @@ set_sched_migrate() # QTI perf framework functions ############################### +perfhal_mode="balance" + # stop before updating cfg -stop_qti_perfd() +perfhal_stop() { stop perf-hal-1-0 stop perf-hal-2-0 @@ -119,15 +126,26 @@ stop_qti_perfd() } # start after updating cfg -start_qti_perfd() +perfhal_start() { start perf-hal-1-0 start perf-hal-2-0 } # $1:mode(such as balance) -update_qti_perfd() +perfhal_update() { + perfhal_mode="$1" rm /data/vendor/perfd/default_values - cp -af "$MODULE_PATH/$PERFCFG_REL/perfd_profiles/$1"/* "$MODULE_PATH/$PERFCFG_REL/" + cp -af "$MODULE_PATH/$PERFCFG_REL/perfd_profiles/$perfhal_mode"/* "$MODULE_PATH/$PERFCFG_REL/" +} + +# return:status +perfhal_status() +{ + if [ "$(ps -A | grep "qti.hardware.perf")" != "" ]; then + echo "Running. Current mode is $perfhal_mode." + else + echo "QTI boost framework not equipped with this system." + fi } diff --git a/script/powercfg.sh b/script/powercfg_main.sh similarity index 83% rename from script/powercfg.sh rename to script/powercfg_main.sh index ba82367..662b27d 100644 --- a/script/powercfg.sh +++ b/script/powercfg_main.sh @@ -3,7 +3,7 @@ # Original repo: https://github.com/yc9559/sdm855-tune/ # Author: Matt Yang # Platform: sdm855 -# Version: v3 (20200222) +# Version: v4 (20200306) BASEDIR="$(dirname "$0")" . $BASEDIR/libcommon.sh @@ -13,11 +13,11 @@ BASEDIR="$(dirname "$0")" # $1: power_mode apply_power_mode() { - stop_qti_perfd + perfhal_stop apply_common eval apply_$1 - update_qti_perfd "$1" - start_qti_perfd + perfhal_update "$1" + perfhal_start echo "Applying $1 done." } @@ -38,13 +38,14 @@ save_panel() write_panel "https://github.com/yc9559/perfd-opt/" write_panel "Author: Matt Yang" write_panel "Platform: $PLATFORM_NAME" - write_panel "Version: v3 (20200222)" + write_panel "Version: v4 (20200306)" write_panel "Last performed: $(date '+%Y-%m-%d %H:%M:%S')" write_panel "" - write_panel "[current status]" - write_panel "Power mode: $action" + write_panel "[Perfhal status]" + write_panel "$(perfhal_status)" write_panel "" - write_panel "[settings]" + write_panel "[Settings]" + write_panel "# The default mode applied at boot" write_panel "# Available mode: balance powersave performance fast" write_panel "default_mode=$default_mode" } diff --git a/script/powercfg_once.sh b/script/powercfg_once.sh index 8861bbd..0551417 100644 --- a/script/powercfg_once.sh +++ b/script/powercfg_once.sh @@ -3,7 +3,7 @@ # Original repo: https://github.com/yc9559/sdm855-tune/ # Author: Matt Yang # Platform: sdm855 -# Version: v3 (20200222) +# Version: v4 (20200306) # Runonce after boot, to speed up the transition of power modes in powercfg @@ -28,6 +28,7 @@ lock_val "0" $ST_FORE/schedtune.sched_boost_enabled lock_val "0" $ST_FORE/schedtune.sched_boost_no_override lock_val "0" $ST_FORE/schedtune.boost lock_val "1" $ST_FORE/schedtune.prefer_idle +lock_val "1" $ST_TOP/schedtune.sched_boost_enabled lock_val "0" $ST_TOP/schedtune.sched_boost_no_override # CFQ io scheduler takes cgroup into consideration @@ -55,7 +56,7 @@ lock_val "0" $KSGL/force_clk_on lock_val "0" $KSGL/force_rail_on # treat crtc_commit as background, avoid display preemption on big -change_task_cgroup "crtc_commit" "background" "cpuset" +change_task_cgroup "crtc_commit" "system-background" "cpuset" # fix laggy bilibili feed scrolling change_task_cgroup "servicemanager" "top-app" "cpuset" @@ -73,6 +74,9 @@ change_task_cgroup "surfaceflinger" "foreground" "stune" # reduce big cluster wakeup, eg. android.hardware.sensors@1.0-service change_task_affinity ".hardware." "0f" +# ...but exclude the fingerprint&camera service for speed +change_task_affinity ".hardware.biometrics.fingerprint" "ff" +change_task_affinity ".hardware.camera.provider" "ff" # platform specific apply_once diff --git a/script/settings_override.sh b/script/settings_override.sh index 6c50a84..f43bf5f 100644 --- a/script/settings_override.sh +++ b/script/settings_override.sh @@ -3,7 +3,7 @@ # Original repo: https://github.com/yc9559/sdm855-tune/ # Author: Matt Yang # Platform: sdm855 -# Version: v3 (20200222) +# Version: v4 (20200306) # smoother oneplus launcher gesture animation, not relying on window_animation_scale # /vendor/bin/sh: settings: inaccessible or not found diff --git a/sepolicy.rule b/sepolicy.rule new file mode 100644 index 0000000..0b9723f --- /dev/null +++ b/sepolicy.rule @@ -0,0 +1,2 @@ +# Put sepolicy statements here +# Example: allow { audioserver mediaserver } audioserver_tmpfs file { read write open } diff --git a/common/service.sh b/service.sh similarity index 89% rename from common/service.sh rename to service.sh index 9bf2236..a8f1e09 100644 --- a/common/service.sh +++ b/service.sh @@ -17,9 +17,9 @@ chmod 755 /data/powercfg.sh chmod 755 /data/powercfg-base.sh # powercfg path provided by magisk module -echo "sh $SCRIPT_DIR/powercfg.sh \"\$1\"" >> /data/powercfg.sh +echo "sh $SCRIPT_DIR/powercfg_main.sh \"\$1\"" >> /data/powercfg.sh # not relying on executable permissions -sh $SCRIPT_DIR/powercfg.sh +sh $SCRIPT_DIR/powercfg_main.sh sh $SCRIPT_DIR/powercfg_once.sh sh $SCRIPT_DIR/settings_override.sh diff --git a/common/system.prop b/system.prop similarity index 100% rename from common/system.prop rename to system.prop diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..d86c28a --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,19 @@ +#!/system/bin/sh +# Additional cleanup + +wait_until_login() +{ + # whether in lock screen, tested on Android 7.1 & 10.0 + # in case of other magisk module remounting /data as RW + while [ "$(dumpsys window policy | grep mInputRestricted=true)" != "" ]; do + sleep 2 + done + # we doesn't have the permission to rw "/sdcard" before the user unlocks the screen + while [ ! -d "/sdcard/Android" ]; do + sleep 2 + done +} + +wait_until_login +rm -rf "/sdcard/Android/panel_powercfg.txt" +rm -rf "/sdcard/powercfg_panel.txt"