├── .gitignore
├── LICENSE
├── README.md
├── magisk
├── META-INF
│ └── com
│ │ └── google
│ │ └── android
│ │ ├── update-binary
│ │ └── updater-script
├── common
│ ├── post-fs-data.sh
│ ├── service.sh
│ └── system.prop
├── config.sh
├── module.prop
└── system
│ └── vendor
│ ├── bin
│ └── powercfg.sh
│ └── etc
│ └── perf
│ ├── commonresourceconfigs.xml
│ ├── perfboostsconfig.xml
│ ├── perfd_profiles
│ ├── balance
│ │ ├── perfboostsconfig.xml
│ │ └── targetconfig.xml
│ ├── fast
│ │ ├── perfboostsconfig.xml
│ │ └── targetconfig.xml
│ ├── performance
│ │ ├── perfboostsconfig.xml
│ │ └── targetconfig.xml
│ └── powersave
│ │ ├── perfboostsconfig.xml
│ │ └── targetconfig.xml
│ ├── targetconfig.xml
│ └── targetresourceconfigs.xml
├── perfboostsconfig_desc.csv
├── tools
├── get_power_consumption.sh
└── ramp-up-test.cpp
└── vtools-powercfg.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | /.vscode
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # sdm855-tune
2 |
3 | 在过去的[Project WIPE](https://github.com/yc9559/cpufreq-interactive-opt)中,借助仿真和启发式优化算法自动调参`interactive`参数,实现了对所有主流机型的适配。在近期的[wipe v2](https://github.com/yc9559/wipe-v2)中,改进了仿真支持了内核的更多特性以及重点满足渲染性能需求,自动调参`interactive`+`HMP`+`input boost`参数,显著改进了流畅度。但是在EAS合入主线之后,自动调参依赖的仿真难度变大,很难仿真调度器所有主体的逻辑,此外,EAS在设计之初就为了避免调参,因此例如`schedutil`的调参没有明显效果。
4 |
5 | 在[wipe v2](https://github.com/yc9559/wipe-v2)中,重点满足与手机交互时的性能需求,而降低非交互式的卡顿权重,使得在流畅性和省电的权衡上更近一步。而`QTI Boost Framework`,这个此前在应用调参前要求先禁用的模块,因为它根据当前事件动态覆盖参数,导致冲突。基于这一点,此项目借助`QTI Boost Framework`,扩展了它能更改参数的范围,在APP启动和滑动屏幕时,动态应用较为激进的参数,在可接受的功耗代价下改善响应,在没有交互时,使用保守的参数,尽可能利用小核集群,并在重负载时运行在能效比更优的频点。
6 |
7 | 具体的调整和解释见[历史commit信息](https://github.com/yc9559/sdm855-tune/commits/master)
8 |
9 | ## 模式区别
10 |
11 | - 卡顿:基础1.6+2.0,UI交互1.8+0.8,突发2.0+2.6,最低0.3+0.7+0.8,低基础频率低动态频率,但是基本不影响APP启动时间
12 | - 均衡:基础1.8+2.4,UI交互2.0+2.4,突发2.4+2.7,最低0.5+0.7+0.8,低基础频率高动态频率
13 | - 费电:基础2.4+2.7,UI交互2.4+2.8,突发2.4+2.8,最低0.5+0.7+0.8,基本不做频率限制,2.8g相比2.7g,性能+3.5%功耗+13.6%
14 | - 低延:基础2.0+2.6,UI交互2.4+2.8,突发2.4+2.8,最低1.0+1.4+1.4,压缩频率变化范围,散热允许TDP下的稳定持续性能
15 |
16 | ## 如何使用
17 |
18 | ### 环境要求
19 |
20 | 1. 高通骁龙855(SM8150)平台
21 | 2. 已ROOT
22 | 3. Magisk >= 17.0
23 | 4. 自动化切换辅助APP(可选)
24 | - 微工具箱
25 | - Tasker
26 | - Edge
27 | - ...
28 |
29 | ### 静态配置步骤(不需要根据前台APP自动切换)
30 |
31 | 1. 在[Release页面](https://github.com/yc9559/sdm855-tune/releases)下载magisk模块
32 | 2. 在Magisk Manager内刷入
33 | 3. 重启
34 | 4. 修改`/sdcard/powercfg_panel.txt`的内容来选择开机后默认设置的模式,可选的字段有`balance`,`powersave`,`performance`,`fast`
35 | 5. 重启
36 |
37 | ### 动态配置步骤(微工具箱)
38 |
39 | 1. 在[Release页面](https://github.com/yc9559/sdm855-tune/releases)下载magisk模块
40 | 2. 在Magisk Manager内刷入
41 | 3. 重启
42 | 4. 在[Release页面](https://github.com/yc9559/sdm855-tune/releases)下载`vtools-powercfg.sh`
43 | 5. 在微工具箱内,导入本地配置,选择`vtools-powercfg.sh`
44 | 6. 在微工具箱内,选择APP的默认配置
45 |
46 | ### 动态配置步骤(Tasker等)
47 |
48 | 1. 在[Release页面](https://github.com/yc9559/sdm855-tune/releases)下载magisk模块
49 | 2. 在Magisk Manager内刷入
50 | 3. 重启
51 | 4. 在Tasker等APP内,添加动作,执行命令`/vendor/bin/sh /vendor/bin/powercfg.sh balance`,其中balance替换为你需要的模式
52 | 5. 在Tasker等APP内,把动作绑定到如顶部下拉菜单开关或者滑动手势等事件
53 |
54 | ### 检查是否生效
55 |
56 | 打开`/sdcard/powercfg_panel.txt`,内容为如下形式:
57 | ```
58 | sdm855-tune https://github.com/yc9559/sdm855-tune/
59 | Author: Matt Yang
60 | Platform: sdm855
61 | Version: 20190712
62 |
63 | [status]
64 | Power mode: balance
65 | Last performed: 2019-06-28 15:13:12
66 |
67 | [settings]
68 | # Available mode: balance powersave performance fast
69 | default_mode=balance
70 |
71 | ```
72 |
73 | `[status]`是最近一次执行的时间和结果,如果跟最近一次开机时间或者最近一次切换时间接近,则表示已生效
74 | 修改`default_mode`来选择下次执行的默认设置,注意执行`/vendor/bin/sh /vendor/bin/powercfg.sh fast`也会把`default_mode`设置为`fast`
75 |
--------------------------------------------------------------------------------
/magisk/META-INF/com/google/android/update-binary:
--------------------------------------------------------------------------------
1 | #!/sbin/sh
2 | ##########################################################################################
3 | #
4 | # Magisk Module Template Install Script
5 | # by😏
6 | #
7 | ##########################################################################################
8 |
9 | TMPDIR=/dev/tmp
10 | INSTALLER=$TMPDIR/install
11 | # Always mount under tmp
12 | MOUNTPATH=$TMPDIR/magisk_img
13 |
14 | # Default permissions
15 | umask 022
16 |
17 | # Initial cleanup
18 | rm -rf $TMPDIR 2>/dev/null
19 | mkdir -p $INSTALLER
20 |
21 | # echo before loading util_functions
22 | ui_print() { echo "$1"; }
23 |
24 | require_new_magisk() {
25 | ui_print "*******************************"
26 | ui_print " Please install Magisk v17.0+! "
27 | ui_print "*******************************"
28 | exit 1
29 | }
30 |
31 | ##########################################################################################
32 | # Environment
33 | ##########################################################################################
34 |
35 | OUTFD=$2
36 | ZIP=$3
37 |
38 | mount /data 2>/dev/null
39 |
40 | # Load utility functions
41 | if [ -f /data/adb/magisk/util_functions.sh ]; then
42 | . /data/adb/magisk/util_functions.sh
43 | elif [ -f /data/magisk/util_functions.sh ]; then
44 | NVBASE=/data
45 | . /data/magisk/util_functions.sh
46 | else
47 | require_new_magisk
48 | fi
49 |
50 | # Use alternative image if in BOOTMODE
51 | $BOOTMODE && IMG=$NVBASE/magisk_merge.img
52 |
53 | # Preperation for flashable zips
54 | setup_flashable
55 |
56 | # Mount partitions
57 | mount_partitions
58 |
59 | # Detect version and architecture
60 | api_level_arch_detect
61 |
62 | # You can get the Android API version from $API, the CPU architecture from $ARCH
63 | # Useful if you are creating Android version / platform dependent mods
64 |
65 | # Setup busybox and binaries
66 | $BOOTMODE && boot_actions || recovery_actions
67 |
68 | ##########################################################################################
69 | # Preparation
70 | ##########################################################################################
71 |
72 | # Extract common files
73 | unzip -o "$ZIP" module.prop config.sh 'common/*' -d $INSTALLER >&2
74 |
75 | [ ! -f $INSTALLER/config.sh ] && abort "! Unable to extract zip file!"
76 | # Load configurations
77 | . $INSTALLER/config.sh
78 |
79 | # Check the installed magisk version
80 | MIN_VER=`grep_prop minMagisk $INSTALLER/module.prop`
81 | [ ! -z $MAGISK_VER_CODE -a $MAGISK_VER_CODE -ge $MIN_VER ] || require_new_magisk
82 | MODID=`grep_prop id $INSTALLER/module.prop`
83 | MODPATH=$MOUNTPATH/$MODID
84 |
85 | # Print mod name
86 | print_modname
87 |
88 | # Please leave this message in your flashable zip for credits :)
89 | ui_print "******************************"
90 | ui_print "Powered by Magisk (😏)"
91 | ui_print "******************************"
92 |
93 | ##########################################################################################
94 | # Install
95 | ##########################################################################################
96 |
97 | # Get the variable reqSizeM. Use your own method to determine reqSizeM if needed
98 | request_zip_size_check "$ZIP"
99 |
100 | # This function will mount $IMG to $MOUNTPATH, and resize the image based on $reqSizeM
101 | mount_magisk_img
102 |
103 | # Create mod paths
104 | rm -rf $MODPATH 2>/dev/null
105 | mkdir -p $MODPATH
106 |
107 | # Extract files to system. Use your own method if needed
108 | ui_print "- Extracting module files"
109 | unzip -o "$ZIP" 'system/*' -d $MODPATH >&2
110 |
111 | # Remove placeholder
112 | rm -f $MODPATH/system/placeholder 2>/dev/null
113 |
114 | # Handle replace folders
115 | for TARGET in $REPLACE; do
116 | mktouch $MODPATH$TARGET/.replace
117 | done
118 |
119 | # Auto Mount
120 | $AUTOMOUNT && touch $MODPATH/auto_mount
121 |
122 | # prop files
123 | $PROPFILE && cp -af $INSTALLER/common/system.prop $MODPATH/system.prop
124 |
125 | # Module info
126 | cp -af $INSTALLER/module.prop $MODPATH/module.prop
127 | if $BOOTMODE; then
128 | # Update info for Magisk Manager
129 | mktouch /sbin/.core/img/$MODID/update
130 | cp -af $INSTALLER/module.prop /sbin/.core/img/$MODID/module.prop
131 | fi
132 |
133 | # post-fs-data mode scripts
134 | $POSTFSDATA && cp -af $INSTALLER/common/post-fs-data.sh $MODPATH/post-fs-data.sh
135 |
136 | # service mode scripts
137 | $LATESTARTSERVICE && cp -af $INSTALLER/common/service.sh $MODPATH/service.sh
138 |
139 | ui_print "- Setting permissions"
140 | set_permissions
141 |
142 | ##########################################################################################
143 | # Finalizing
144 | ##########################################################################################
145 |
146 | # Unmount magisk image and shrink if possible
147 | unmount_magisk_img
148 |
149 | $BOOTMODE || recovery_cleanup
150 | rm -rf $TMPDIR
151 |
152 | ui_print "- Done"
153 | exit 0
154 |
--------------------------------------------------------------------------------
/magisk/META-INF/com/google/android/updater-script:
--------------------------------------------------------------------------------
1 | #MAGISK
2 |
--------------------------------------------------------------------------------
/magisk/common/post-fs-data.sh:
--------------------------------------------------------------------------------
1 | MODDIR=${0%/*}
2 |
--------------------------------------------------------------------------------
/magisk/common/service.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 | # Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
3 | # This will make your scripts compatible even if Magisk change its mount point in the future
4 | MODDIR=${0%/*}
5 |
6 | /vendor/bin/sh $MODDIR/system/vendor/bin/powercfg.sh
7 |
--------------------------------------------------------------------------------
/magisk/common/system.prop:
--------------------------------------------------------------------------------
1 | # This file will be read by resetprop
2 | # Example: Change dpi
3 | # ro.sf.lcd_density=320
4 | # persist.sys.force_sw_gles=0
5 | # debug.sf.hw=0
6 | # debug.egl.hw=0
7 | # debug.composition.type=dyn
8 | # persist.sys.composition.type=dyn
9 | # persist.hwc.dyncomp.enable=true
--------------------------------------------------------------------------------
/magisk/config.sh:
--------------------------------------------------------------------------------
1 | ##########################################################################################
2 | #
3 | # Magisk Module Installer Script
4 | #
5 | ##########################################################################################
6 | ##########################################################################################
7 | #
8 | # Instructions:
9 | #
10 | # 1. Place your files into system folder (delete the placeholder file)
11 | # 2. Fill in your module's info into module.prop
12 | # 3. Configure and implement callbacks in this file
13 | # 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh
14 | # 5. Add your additional or modified system properties into common/system.prop
15 | #
16 | ##########################################################################################
17 |
18 | ##########################################################################################
19 | # Config Flags
20 | ##########################################################################################
21 |
22 | # Set to true if you do *NOT* want Magisk to mount
23 | # any files for you. Most modules would NOT want
24 | # to set this flag to true
25 | SKIPMOUNT=false
26 |
27 | # Set to true if you need to load system.prop
28 | PROPFILE=true
29 |
30 | # Set to true if you need post-fs-data script
31 | POSTFSDATA=true
32 |
33 | # Set to true if you need late_start service script
34 | LATESTARTSERVICE=true
35 |
36 | ##########################################################################################
37 | # Replace list
38 | ##########################################################################################
39 |
40 | # List all directories you want to directly replace in the system
41 | # Check the documentations for more info why you would need this
42 |
43 | # Construct your list in the following format
44 | # This is an example
45 | # REPLACE_EXAMPLE="
46 | # /system/app/Youtube
47 | # /system/priv-app/SystemUI
48 | # /system/priv-app/Settings
49 | # /system/framework
50 | # "
51 |
52 | # Construct your own list here
53 | REPLACE=""
54 |
55 | ##########################################################################################
56 | #
57 | # Function Callbacks
58 | #
59 | # The following functions will be called by the installation framework.
60 | # You do not have the ability to modify update-binary, the only way you can customize
61 | # installation is through implementing these functions.
62 | #
63 | # When running your callbacks, the installation framework will make sure the Magisk
64 | # internal busybox path is *PREPENDED* to PATH, so all common commands shall exist.
65 | # Also, it will make sure /data, /system, and /vendor is properly mounted.
66 | #
67 | ##########################################################################################
68 | ##########################################################################################
69 | #
70 | # The installation framework will export some variables and functions.
71 | # You should use these variables and functions for installation.
72 | #
73 | # ! DO NOT use any Magisk internal paths as those are NOT public API.
74 | # ! DO NOT use other functions in util_functions.sh as they are NOT public API.
75 | # ! Non public APIs are not guranteed to maintain compatibility between releases.
76 | #
77 | # Available variables:
78 | #
79 | # MAGISK_VER (string): the version string of current installed Magisk
80 | # MAGISK_VER_CODE (int): the version code of current installed Magisk
81 | # BOOTMODE (bool): true if the module is currently installing in Magisk Manager
82 | # MODPATH (path): the path where your module files should be installed
83 | # TMPDIR (path): a place where you can temporarily store files
84 | # ZIPFILE (path): your module's installation zip
85 | # ARCH (string): the architecture of the device. Value is either arm, arm64, x86, or x64
86 | # IS64BIT (bool): true if $ARCH is either arm64 or x64
87 | # API (int): the API level (Android version) of the device
88 | #
89 | # Availible functions:
90 | #
91 | # ui_print
92 | # print to console
93 | # Avoid using 'echo' as it will not display in custom recovery's console
94 | #
95 | # abort
96 | # print error message to console and terminate installation
97 | # Avoid using 'exit' as it will skip the termination cleanup steps
98 | #
99 | # set_perm [context]
100 | # if [context] is empty, it will default to "u:object_r:system_file:s0"
101 | # this function is a shorthand for the following commands
102 | # chown owner.group target
103 | # chmod permission target
104 | # chcon context target
105 | #
106 | # set_perm_recursive [context]
107 | # if [context] is empty, it will default to "u:object_r:system_file:s0"
108 | # for all files in , it will call:
109 | # set_perm file owner group filepermission context
110 | # for all directories in (including itself), it will call:
111 | # set_perm dir owner group dirpermission context
112 | #
113 | ##########################################################################################x
114 | ##########################################################################################j
115 | # If you need boot scripts, DO NOT use general boot scripts (post-fs-data.d/service.d)
116 | # ONLY use module scripts as it respects the module status (remove/disable) and is
117 | # guaranteed to maintain the same behavior in future Magisk releases.xin
118 | # Enable boot scripts by setting the flags in the config section above.jie
119 | ##########################################################################################
120 |
121 | # Set what you want to display when installing your module
122 |
123 | print_modname() {
124 | ui_print "sdm855-tune https://github.com/yc9559/sdm855-tune/"
125 | ui_print "Author: Matt Yang"
126 | ui_print "Platform: sdm855"
127 | ui_print "Version: 20190712"
128 | }
129 |
130 | # Copy/extract your module files into $MODPATH in on_install.
131 |
132 | on_install() {
133 | # The following is the default implementation: extract $ZIPFILE/system to $MODPATH
134 | # Extend/change the logic to whatever you want
135 | ui_print "- Extracting module files"
136 | unzip -o "$ZIPFILE" 'system/*' -d $MODPATH >&2
137 | }
138 |
139 | # Only some special files require specific permissions
140 | # This function will be called after on_install is done
141 | # The default permissions should be good enough for most cases
142 |
143 | set_permissions() {
144 | # The following is the default rule, DO NOT remove
145 | set_perm_recursive $MODPATH 0 0 0755 0644
146 |
147 | # Here are some examples:
148 | # set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
149 | # set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0
150 | # set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0
151 | # set_perm $MODPATH/system/lib/libart.so 0 0 0644
152 | set_perm $MODDIR/system/vendor/bin/powercfg.sh 0 2000 0755 u:object_r:vendor_file:s0
153 | }
154 |
155 | # You can add more functions to assist your custom script code
156 |
--------------------------------------------------------------------------------
/magisk/module.prop:
--------------------------------------------------------------------------------
1 | id=sdm855-tune
2 | name=sdm855-tune
3 | version=20190712
4 | versionCode=1
5 | author=Matt Yang
6 | description=GitHub: https://github.com/yc9559/sdm855-tune/
7 | minMagisk=17000
8 |
--------------------------------------------------------------------------------
/magisk/system/vendor/bin/powercfg.sh:
--------------------------------------------------------------------------------
1 | #! /vendor/bin/sh
2 | # sdm855-tune https://github.com/yc9559/sdm855-tune/
3 | # Author: Matt Yang
4 | # Platform: sdm855
5 | # Version: 20190712
6 |
7 | module_dir="/data/adb/modules/sdm855-tune"
8 | panel_path="/sdcard/powercfg_panel.txt"
9 |
10 | # target power mode
11 | action=$1
12 |
13 | # $1:value $2:file path
14 | lock_value()
15 | {
16 | if [ -f ${2} ]; then
17 | chmod 0666 ${2}
18 | echo ${1} > ${2}
19 | chmod 0444 ${2}
20 | fi
21 | }
22 |
23 | # $1:task_name $2:cgroup_name $3:"cpuset"/"stune"
24 | change_task_cgroup()
25 | {
26 | temp_pids=`ps -Ao pid,cmd | grep "${1}" | awk '{print $1}'`
27 | for temp_pid in ${temp_pids}
28 | do
29 | for temp_tid in `ls /proc/${temp_pid}/task/`
30 | do
31 | echo ${temp_tid} > /dev/${3}/${2}/tasks
32 | done
33 | done
34 | }
35 |
36 | # stop before updating cfg
37 | stop_qti_perfd()
38 | {
39 | stop perf-hal-1-0
40 | }
41 |
42 | # start after updating cfg
43 | start_qti_perfd()
44 | {
45 | start perf-hal-1-0
46 | }
47 |
48 | # $1:mode(such as balance)
49 | update_qti_perfd()
50 | {
51 | rm /data/vendor/perfd/default_values
52 | cp ${module_dir}/system/vendor/etc/perf/perfd_profiles/${1}/* ${module_dir}/system/vendor/etc/perf/
53 | }
54 |
55 | # $1:key $return:value(string)
56 | read_cfg_value()
57 | {
58 | value=""
59 | if [ -f ${panel_path} ]; then
60 | value=`grep "^${1}=" "${panel_path}" | tr -d ' ' | cut -d= -f2`
61 | fi
62 | echo ${value}
63 | }
64 |
65 | apply_common()
66 | {
67 | # 580M for empty apps
68 | lock_value "18432,23040,27648,51256,122880,150296" /sys/module/lowmemorykiller/parameters/minfree
69 |
70 | # task_util(p) = p->ravg.demand_scaled <= sysctl_sched_min_task_util_for_boost
71 | echo "16" > /proc/sys/kernel/sched_min_task_util_for_boost
72 | echo "96" > /proc/sys/kernel/sched_min_task_util_for_colocation
73 | # normal colocation util report
74 | echo "1000000" > /proc/sys/kernel/sched_little_cluster_coloc_fmin_khz
75 | # prevent big tasks which we aren't interacting with running on big cluster
76 | echo "0" > /proc/sys/kernel/sched_walt_rotate_big_tasks
77 |
78 | # move all top-app to foreground to reduce nr_top_app
79 | for ttask in `cat /dev/cpuset/top-app/tasks`
80 | do
81 | echo ${ttask} > /dev/cpuset/foreground/tasks
82 | echo ${ttask} > /dev/stune/foreground/tasks
83 | done
84 |
85 | # prevent foreground using big cluster, may be override
86 | echo "0-3" > /dev/cpuset/foreground/cpus
87 |
88 | # treat crtc_commit as display
89 | change_task_cgroup "crtc_commit" "display" "cpuset"
90 |
91 | # avoid display preemption on big
92 | lock_value "0-3" /dev/cpuset/display/cpus
93 |
94 | # fix laggy bilibili feed scrolling
95 | change_task_cgroup "servicemanager" "top-app" "cpuset"
96 | change_task_cgroup "servicemanager" "top-app" "stune"
97 | change_task_cgroup "android.phone" "top-app" "cpuset"
98 | change_task_cgroup "android.phone" "top-app" "stune"
99 |
100 | # fix laggy home gesture
101 | change_task_cgroup "system_server" "top-app" "cpuset"
102 | change_task_cgroup "system_server" "top-app" "stune"
103 |
104 | # reduce render thread waiting time
105 | change_task_cgroup "surfaceflinger" "top-app" "cpuset"
106 | change_task_cgroup "surfaceflinger" "top-app" "stune"
107 |
108 | # unify schedtune misc
109 | lock_value "0" /dev/stune/background/schedtune.sched_boost_enabled
110 | lock_value "1" /dev/stune/background/schedtune.sched_boost_no_override
111 | lock_value "0" /dev/stune/background/schedtune.boost
112 | lock_value "0" /dev/stune/background/schedtune.prefer_idle
113 | lock_value "0" /dev/stune/foreground/schedtune.sched_boost_enabled
114 | lock_value "1" /dev/stune/foreground/schedtune.sched_boost_no_override
115 | lock_value "0" /dev/stune/foreground/schedtune.boost
116 | lock_value "1" /dev/stune/foreground/schedtune.prefer_idle
117 | lock_value "0" /dev/stune/top-app/schedtune.sched_boost_no_override
118 |
119 | # CFQ io scheduler takes cgroup into consideration
120 | lock_value "cfq" /sys/block/sda/queue/scheduler
121 | # Flash doesn't have back seek problem, so penalty is as low as possible
122 | lock_value "1" /sys/block/sda/queue/iosched/back_seek_penalty
123 | # slice_idle = 0 means CFQ IOP mode, https://lore.kernel.org/patchwork/patch/944972/
124 | lock_value "0" /sys/block/sda/queue/iosched/slice_idle
125 | # UFS 2.0+ hardware queue depth is 32
126 | lock_value "16" /sys/block/sda/queue/iosched/quantum
127 | # lower read_ahead_kb to reduce random access overhead
128 | lock_value "128" /sys/block/sda/queue/read_ahead_kb
129 |
130 | # turn off hotplug to reduce latency
131 | lock_value "0" /sys/devices/system/cpu/cpu0/core_ctl/enable
132 | # tend to online more cores to balance parallel tasks
133 | echo "15" > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres
134 | echo "5" > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres
135 | echo "100" > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms
136 | echo "5" > /sys/devices/system/cpu/cpu4/core_ctl/task_thres
137 | # task usually doesn't run on cpu7
138 | echo "15" > /sys/devices/system/cpu/cpu7/core_ctl/busy_up_thres
139 | echo "10" > /sys/devices/system/cpu/cpu7/core_ctl/busy_down_thres
140 | echo "100" > /sys/devices/system/cpu/cpu7/core_ctl/offline_delay_ms
141 |
142 | # zram doesn't need much read ahead(random read)
143 | echo "4" > /sys/block/zram0/queue/read_ahead_kb
144 |
145 | # unify scaling_min_freq, may be override
146 | echo "576000" > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
147 | echo "710400" > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
148 | echo "825600" > /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freq
149 |
150 | # unify scaling_max_freq, may be override
151 | echo "1785600" > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
152 | echo "2419100" > /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freq
153 | echo "2841600" > /sys/devices/system/cpu/cpufreq/policy7/scaling_max_freq
154 |
155 | # unify group_migrate
156 | lock_value "120" /proc/sys/kernel/sched_group_upmigrate
157 | lock_value "100" /proc/sys/kernel/sched_group_downmigrate
158 |
159 | # adreno default settings
160 | lock_value "0" /sys/class/kgsl/kgsl-3d0/force_no_nap
161 | lock_value "1" /sys/class/kgsl/kgsl-3d0/bus_split
162 | lock_value "0" /sys/class/kgsl/kgsl-3d0/force_bus_on
163 | lock_value "0" /sys/class/kgsl/kgsl-3d0/force_clk_on
164 | lock_value "0" /sys/class/kgsl/kgsl-3d0/force_rail_on
165 | }
166 |
167 | apply_powersave()
168 | {
169 | # may be override
170 | echo "300000" > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
171 | echo "710400" > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
172 | echo "825600" > /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freq
173 |
174 | # 1708 * 0.95 / 1785 = 90.9
175 | # higher sched_downmigrate to use little cluster more
176 | echo "90 60" > /proc/sys/kernel/sched_downmigrate
177 | echo "90 85" > /proc/sys/kernel/sched_upmigrate
178 | echo "90 60" > /proc/sys/kernel/sched_downmigrate
179 |
180 | # do not use lock_value(), libqti-perfd-client.so will fail to override it
181 | echo "0" > /dev/stune/top-app/schedtune.sched_boost_enabled
182 | echo "0" > /dev/stune/top-app/schedtune.boost
183 | echo "0" > /dev/stune/top-app/schedtune.prefer_idle
184 |
185 | lock_value "0:1036800 4:0 7:0" /sys/module/cpu_boost/parameters/input_boost_freq
186 | lock_value "500" /sys/module/cpu_boost/parameters/input_boost_ms
187 | lock_value "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
188 |
189 | # limit the usage of big cluster
190 | lock_value "1" /sys/devices/system/cpu/cpu4/core_ctl/enable
191 | echo "0" > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
192 | # task usually doesn't run on cpu7
193 | lock_value "1" /sys/devices/system/cpu/cpu7/core_ctl/enable
194 | echo "0" > /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
195 | }
196 |
197 | apply_balance()
198 | {
199 | # 1708 * 0.95 / 1785 = 90.9
200 | # higher sched_downmigrate to use little cluster more
201 | echo "90 60" > /proc/sys/kernel/sched_downmigrate
202 | echo "90 85" > /proc/sys/kernel/sched_upmigrate
203 | echo "90 60" > /proc/sys/kernel/sched_downmigrate
204 |
205 | # do not use lock_value(), libqti-perfd-client.so will fail to override it
206 | echo "0" > /dev/stune/top-app/schedtune.sched_boost_enabled
207 | echo "0" > /dev/stune/top-app/schedtune.boost
208 | echo "0" > /dev/stune/top-app/schedtune.prefer_idle
209 |
210 | lock_value "0:1036800 4:1056000 7:0" /sys/module/cpu_boost/parameters/input_boost_freq
211 | lock_value "500" /sys/module/cpu_boost/parameters/input_boost_ms
212 | lock_value "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
213 |
214 | # limit the usage of big cluster
215 | lock_value "1" /sys/devices/system/cpu/cpu4/core_ctl/enable
216 | echo "2" > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
217 | # task usually doesn't run on cpu7
218 | lock_value "1" /sys/devices/system/cpu/cpu7/core_ctl/enable
219 | echo "0" > /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
220 | }
221 |
222 | apply_performance()
223 | {
224 | # 1708 * 0.95 / 1785 = 90.9
225 | # higher sched_downmigrate to use little cluster more
226 | echo "90 60" > /proc/sys/kernel/sched_downmigrate
227 | echo "90 85" > /proc/sys/kernel/sched_upmigrate
228 | echo "90 60" > /proc/sys/kernel/sched_downmigrate
229 |
230 | # do not use lock_value(), libqti-perfd-client.so will fail to override it
231 | echo "1" > /dev/stune/top-app/schedtune.sched_boost_enabled
232 | echo "10" > /dev/stune/top-app/schedtune.boost
233 | echo "1" > /dev/stune/top-app/schedtune.prefer_idle
234 |
235 | lock_value "0:1209600 4:1612800 7:0" /sys/module/cpu_boost/parameters/input_boost_freq
236 | lock_value "2000" /sys/module/cpu_boost/parameters/input_boost_ms
237 | lock_value "2" /sys/module/cpu_boost/parameters/sched_boost_on_input
238 |
239 | # turn off core_ctl to reduce latency
240 | lock_value "0" /sys/devices/system/cpu/cpu4/core_ctl/enable
241 | echo "3" > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
242 | # task usually doesn't run on cpu7
243 | lock_value "1" /sys/devices/system/cpu/cpu7/core_ctl/enable
244 | echo "0" > /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
245 | }
246 |
247 | apply_fast()
248 | {
249 | # may be override
250 | echo "1036800" > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
251 | echo "1401600" > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
252 | echo "1401600" > /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freq
253 |
254 | # easier to boost
255 | echo "16" > /proc/sys/kernel/sched_min_task_util_for_boost
256 | echo "16" > /proc/sys/kernel/sched_min_task_util_for_colocation
257 | echo "40 40" > /proc/sys/kernel/sched_downmigrate
258 | echo "40 60" > /proc/sys/kernel/sched_upmigrate
259 | echo "40 40" > /proc/sys/kernel/sched_downmigrate
260 |
261 | # do not use lock_value(), libqti-perfd-client.so will fail to override it
262 | echo "1" > /dev/stune/top-app/schedtune.sched_boost_enabled
263 | echo "20" > /dev/stune/top-app/schedtune.boost
264 | echo "1" > /dev/stune/top-app/schedtune.prefer_idle
265 |
266 | lock_value "0:0 4:1804800 7:1612800" /sys/module/cpu_boost/parameters/input_boost_freq
267 | lock_value "2000" /sys/module/cpu_boost/parameters/input_boost_ms
268 | lock_value "1" /sys/module/cpu_boost/parameters/sched_boost_on_input
269 |
270 | # turn off core_ctl to reduce latency
271 | lock_value "0" /sys/devices/system/cpu/cpu4/core_ctl/enable
272 | echo "3" > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus
273 | # turn off core_ctl to reduce latency
274 | lock_value "0" /sys/devices/system/cpu/cpu7/core_ctl/enable
275 | echo "1" > /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
276 | }
277 |
278 | # $1: power_mode
279 | apply_power_mode()
280 | {
281 | case "${1}" in
282 | "powersave")
283 | stop_qti_perfd
284 | apply_common
285 | apply_powersave
286 | update_qti_perfd powersave
287 | start_qti_perfd
288 | echo "Applying powersave done."
289 | ;;
290 | "balance")
291 | stop_qti_perfd
292 | apply_common
293 | apply_balance
294 | update_qti_perfd balance
295 | start_qti_perfd
296 | echo "Applying balance done."
297 | ;;
298 | "performance")
299 | stop_qti_perfd
300 | apply_common
301 | apply_performance
302 | update_qti_perfd performance
303 | start_qti_perfd
304 | echo "Applying performance done."
305 | ;;
306 | "fast")
307 | stop_qti_perfd
308 | apply_common
309 | apply_fast
310 | update_qti_perfd fast
311 | start_qti_perfd
312 | echo "Applying fast done."
313 | ;;
314 | *)
315 | action="balance"
316 | stop_qti_perfd
317 | apply_common
318 | apply_balance
319 | update_qti_perfd balance
320 | start_qti_perfd
321 | echo "Applying balance done."
322 | ;;
323 | esac
324 | }
325 |
326 | # suppress stderr
327 | (
328 |
329 | echo ""
330 |
331 | # we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
332 | while [ ! -e ${panel_path} ]
333 | do
334 | touch ${panel_path}
335 | sleep 2
336 | done
337 |
338 | if [ ! -n "$action" ]; then
339 | # default option is balance
340 | action="balance"
341 | # load default mode from file
342 | default_action=`read_cfg_value default_mode`
343 | if [ "${default_action}" != "" ]; then
344 | action=${default_action}
345 | fi
346 | fi
347 |
348 | # perform hotfix
349 | apply_power_mode ${action}
350 |
351 | # save mode for automatic applying mode after reboot
352 | echo "" > ${panel_path}
353 | echo "sdm855-tune https://github.com/yc9559/sdm855-tune/" >> ${panel_path}
354 | echo "Author: Matt Yang" >> ${panel_path}
355 | echo "Platform: sdm855" >> ${panel_path}
356 | echo "Version: 20190712" >> ${panel_path}
357 | echo "" >> ${panel_path}
358 | echo "[status]" >> ${panel_path}
359 | echo "Power mode: ${action}" >> ${panel_path}
360 | echo "Last performed: `date '+%Y-%m-%d %H:%M:%S'`" >> ${panel_path}
361 | echo "" >> ${panel_path}
362 | echo "[settings]" >> ${panel_path}
363 | echo "# Available mode: balance powersave performance fast" >> ${panel_path}
364 | echo "default_mode=${action}" >> ${panel_path}
365 |
366 | echo "${panel_path} has been updated."
367 |
368 | echo ""
369 |
370 | # suppress stderr
371 | ) 2> /dev/null
372 |
373 | exit 0
374 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/commonresourceconfigs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
17 |
18 |
22 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfboostsconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfd_profiles/balance/perfboostsconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
147 |
148 |
149 |
150 |
151 |
152 |
155 |
156 |
157 |
158 |
159 |
160 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
251 |
252 |
253 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfd_profiles/balance/targetconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
27 |
28 |
38 |
39 |
42 |
43 |
44 |
45 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfd_profiles/fast/perfboostsconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
145 |
146 |
147 |
148 |
149 |
150 |
153 |
154 |
155 |
156 |
157 |
158 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
247 |
248 |
249 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfd_profiles/fast/targetconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
27 |
28 |
38 |
39 |
42 |
43 |
44 |
45 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfd_profiles/performance/perfboostsconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
145 |
146 |
147 |
148 |
149 |
150 |
153 |
154 |
155 |
156 |
157 |
158 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
247 |
248 |
249 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfd_profiles/performance/targetconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
27 |
28 |
38 |
39 |
42 |
43 |
44 |
45 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfd_profiles/powersave/perfboostsconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
146 |
147 |
148 |
149 |
150 |
151 |
154 |
155 |
156 |
157 |
158 |
159 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
249 |
250 |
251 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/perfd_profiles/powersave/targetconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
27 |
28 |
38 |
39 |
42 |
43 |
44 |
45 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/targetconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
27 |
28 |
38 |
39 |
42 |
43 |
44 |
45 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/magisk/system/vendor/etc/perf/targetresourceconfigs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
12 |
13 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/perfboostsconfig_desc.csv:
--------------------------------------------------------------------------------
1 | opcode,name,sysfs node
2 | 0x40400000,POWER COLLAPSE,/dev/cpu_dma_latency
3 | 0x40404000,,/sys/module/lpm_levels/system/perf/perf-l2-pc/idle_enabled,unsupported
4 | 0x40408000,LPM Bias,/sys/module/lpm_levels/parameters/bias_hyst
5 | 0x4040C000,,/sys/module/lpm_levels/parameters/ref_stddev
6 | 0x40410000,,/sys/module/lpm_levels/parameters/tmr_add
7 | 0x40800000,CPUBOOST_MIN_FREQ BIG Core,/sys/module/msm_performance/parameters/cpu_min_freq
8 | 0x40800100,CPUBOOST_MIN_FREQ LITTLE Core,/sys/module/msm_performance/parameters/cpu_min_freq
9 | 0x40800200,CPUBOOST_MIN_FREQ BIG Core,/sys/module/msm_performance/parameters/cpu_min_freq
10 | 0x40804000,CPUBOOST_MAX_FREQ BIG Core,/sys/module/msm_performance/parameters/cpu_max_freq
11 | 0x40804100,CPUBOOST_MAX_FREQ LITTLE Core,/sys/module/msm_performance/parameters/cpu_max_freq
12 | 0x40804200,CPUBOOST_MAX_FREQ PRIME Core,/sys/module/msm_performance/parameters/cpu_max_freq
13 | 0x40C00000,SCHEDBOOST,/proc/sys/kernel/sched_boost
14 | 0x40C1C000,SCHED UPMIGRATE,/proc/sys/kernel/sched_upmigrate
15 | 0x40C1C200,SCHED UPMIGRATE PRIME,/proc/sys/kernel/sched_upmigrate
16 | 0x40C20000,SCHED DOWNMIGRATE,/proc/sys/kernel/sched_downmigrate
17 | 0x40C20200,SCHED DOWNMIGRATE PRIME,/proc/sys/kernel/sched_downmigrate
18 | 0x40C54000,SCHED GROUP UPMIGRATE,/proc/sys/kernel/sched_group_upmigrate
19 | 0x40C58000,SCHED GROUP DOWNMIGRATE,/proc/sys/kernel/sched_group_downmigrate
20 | 0x41800000,CPUBW_MIN_FREQ,/sys/class/devfreq/soc:qcom,cpu-cpu-llcc-bw/min_freq
21 | 0x4280C000,GPU MIN_FREQUENCY,/sys/class/kgsl/kgsl-3d0/devfreq/min_freq
22 | 0x42C10000,STORAGE CLK SCALING,StorageNode_path_is_figured_out_based_on_the_target_device
23 | 0x43000000,LLCBW_MIN_FREQ,/sys/class/devfreq/soc:qcom,cpu-llcc-ddr-bw/min_freq
24 | 0x43400000,L3_MEMLAT_MIN_FREQ,/sys/class/devfreq/soc:qcom,cpu%d-cpu-l3-lat/min_freq
25 |
--------------------------------------------------------------------------------
/tools/get_power_consumption.sh:
--------------------------------------------------------------------------------
1 | #! /vendor/bin/sh
2 | # 由于Oneplus 7 Pro未接电源时电流刷新周期为30s,此测试需要连接电脑USB完成
3 | # 需要ROOT权限执行
4 |
5 | nr_seconds=$1
6 |
7 | for i in `seq ${nr_seconds}`
8 | do
9 | current=`cat /sys/class/power_supply/battery/current_now`
10 | voltage=`cat /sys/class/power_supply/battery/voltage_now`
11 | power=`expr ${voltage} / 1000000 \* ${current} / 1000`
12 | echo "${voltage},${current},${power}"
13 | sleep 1
14 | done
15 |
--------------------------------------------------------------------------------
/tools/ramp-up-test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | class Timer
9 | {
10 | public:
11 | Timer() { start_ = std::chrono::high_resolution_clock::now(); }
12 |
13 | // 距离上次重置已经xx毫秒
14 | unsigned int elapsed() const
15 | {
16 | return static_cast(
17 | std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - start_)
18 | .count());
19 | }
20 |
21 | private:
22 | std::chrono::high_resolution_clock::time_point start_;
23 | };
24 |
25 | #define BUF_SIZE 64
26 |
27 | int main()
28 | {
29 | char buf[3][BUF_SIZE];
30 | memset(buf, 0, sizeof(buf));
31 |
32 | std::ifstream c0("/sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq");
33 | std::ifstream c1("/sys/devices/system/cpu/cpufreq/policy4/scaling_cur_freq");
34 | std::ifstream c2("/sys/devices/system/cpu/cpufreq/policy7/scaling_cur_freq");
35 |
36 | sleep(2);
37 |
38 | Timer timer;
39 | unsigned int prev;
40 |
41 | while (timer.elapsed() < 1000)
42 | {
43 | auto now = timer.elapsed();
44 | if (now != prev)
45 | {
46 | c0.getline(buf[0], BUF_SIZE);
47 | c1.getline(buf[1], BUF_SIZE);
48 | c2.getline(buf[2], BUF_SIZE);
49 | std::cout << timer.elapsed() << ',' << buf[0] << ',' << buf[1] << ',' << buf[2] << std::endl;
50 | c0.seekg(c0.beg);
51 | c1.seekg(c1.beg);
52 | c2.seekg(c2.beg);
53 | }
54 | for (unsigned int t = 0; t < 10000; t++);
55 | prev = now;
56 | }
57 |
58 | return 0;
59 | }
60 |
--------------------------------------------------------------------------------
/vtools-powercfg.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 | # sdm855-tune https://github.com/yc9559/sdm855-tune/
3 | # Author: Matt Yang
4 | # Platform: sdm855
5 |
6 | # powercfg wrapper for com.omarea.vtools
7 | # MAKE SURE THAT THE MAGISK MODULE OF sdm855-tune HAS BEEN INSTALLED
8 |
9 | powercfg_path="/vendor/bin/powercfg.sh"
10 |
11 | # suppress stderr
12 | (
13 |
14 | /vendor/bin/sh ${powercfg_path} $1
15 |
16 | # suppress stderr
17 | ) 2>/dev/null
18 |
19 | exit 0
20 |
--------------------------------------------------------------------------------