mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-09 02:43:53 +08:00
luci-app-cpufreq: add cpufreq luci for ipq40xx by @coolsnowwolf
This commit is contained in:
parent
d95f51fb14
commit
83c41b4b62
17
package/lean/luci-app-cpufreq/Makefile
Normal file
17
package/lean/luci-app-cpufreq/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI for CPU IPQ40xx Freq
|
||||
LUCI_DEPENDS:=@TARGET_ipq40xx
|
||||
PKG_NAME:=luci-app-cpufreq
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
11
package/lean/luci-app-cpufreq/luasrc/controller/cpufreq.lua
Normal file
11
package/lean/luci-app-cpufreq/luasrc/controller/cpufreq.lua
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
module("luci.controller.cpufreq", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/cpufreq") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "cpufreq"}, cbi("cpufreq"), _("CPU Freq"), 900).dependent=false
|
||||
end
|
||||
|
41
package/lean/luci-app-cpufreq/luasrc/model/cbi/cpufreq.lua
Normal file
41
package/lean/luci-app-cpufreq/luasrc/model/cbi/cpufreq.lua
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
mp = Map("cpufreq", translate("CPU Freq Settings"))
|
||||
mp.description = translate("Set CPU Scaling Governor to Max Performance or Balance Mode")
|
||||
|
||||
s = mp:section(NamedSection, "cpufreq", "settings")
|
||||
s.anonymouse = true
|
||||
|
||||
governor = s:option(ListValue, "governor", translate("CPU Scaling Governor"))
|
||||
governor:value("ondemand", translate("Ondemand Balance Mode"))
|
||||
governor:value("performance", translate("Performance Mode"))
|
||||
|
||||
minifreq = s:option(Value, "minifreq", translate("Min Idle CPU Freq"))
|
||||
minifreq.datatype="range(48000,716000)"
|
||||
minifreq.rmempty = false
|
||||
minifreq.description = translate("CPU Freq from 48000 to 716000 (Khz)")
|
||||
minifreq.placeholder = 48000
|
||||
minifreq.default = 48000
|
||||
|
||||
maxfreq = s:option(Value, "maxfreq", translate("Max Turbo Boost CPU Freq"))
|
||||
maxfreq.datatype="range(48000,716000)"
|
||||
maxfreq.rmempty = false
|
||||
maxfreq.description = translate("CPU Freq from 48000 to 716000 (Khz)")
|
||||
maxfreq.placeholder = 716000
|
||||
maxfreq.default = 716000
|
||||
|
||||
upthreshold = s:option(Value, "upthreshold", translate("CPU Switching Threshold"))
|
||||
upthreshold.datatype="range(1,99)"
|
||||
upthreshold.rmempty = false
|
||||
upthreshold.description = translate("Kernel make a decision on whether it should increase the frequency (%)")
|
||||
upthreshold.placeholder = 50
|
||||
upthreshold.default = 50
|
||||
|
||||
factor = s:option(Value, "factor", translate("CPU Switching Sampling rate"))
|
||||
factor.datatype="range(1,100000)"
|
||||
factor.rmempty = false
|
||||
factor.description = translate("The sampling rate determines how frequently the governor checks to tune the CPU (ms)")
|
||||
factor.placeholder = 10
|
||||
factor.default = 10
|
||||
|
||||
|
||||
return mp
|
39
package/lean/luci-app-cpufreq/po/zh_Hans/cpufreq.po
Normal file
39
package/lean/luci-app-cpufreq/po/zh_Hans/cpufreq.po
Normal file
@ -0,0 +1,39 @@
|
||||
msgid "CPU Freq"
|
||||
msgstr "CPU 性能优化调节"
|
||||
|
||||
msgid "CPU Freq Settings"
|
||||
msgstr "CPU 性能优化调节设置"
|
||||
|
||||
msgid "Set CPU Scaling Governor to Max Performance or Balance Mode"
|
||||
msgstr "设置路由器的 CPU 性能模式(高性能/均衡省电)"
|
||||
|
||||
msgid "CPU Scaling Governor"
|
||||
msgstr "CPU 工作模式"
|
||||
|
||||
msgid "Ondemand Balance Mode"
|
||||
msgstr "Ondemand 自动平衡模式"
|
||||
|
||||
msgid "Performance Mode"
|
||||
msgstr "Performance 高性能模式(降低游戏转发延迟)"
|
||||
|
||||
msgid "CPU Freq from 48000 to 716000 (Khz)"
|
||||
msgstr "CPU 频率范围为 48000 到 716000 (Khz)"
|
||||
|
||||
msgid "Min Idle CPU Freq"
|
||||
msgstr "待机 CPU 最小频率"
|
||||
|
||||
msgid "Max Turbo Boost CPU Freq"
|
||||
msgstr "最大 Turbo Boost CPU 频率"
|
||||
|
||||
msgid "CPU Switching Threshold"
|
||||
msgstr "CPU 切换频率触发阈值"
|
||||
|
||||
msgid "Kernel make a decision on whether it should increase the frequency (%)"
|
||||
msgstr "当 CPU 占用率超过 (%) 的情况下触发内核切换频率"
|
||||
|
||||
msgid "CPU Switching Sampling rate"
|
||||
msgstr "CPU 切换周期"
|
||||
|
||||
msgid "The sampling rate determines how frequently the governor checks to tune the CPU (ms)"
|
||||
msgstr "CPU 检查切换的周期 (ms) 。注意:过于频繁的切换频率会引起网络延迟抖动"
|
||||
|
8
package/lean/luci-app-cpufreq/root/etc/config/cpufreq
Normal file
8
package/lean/luci-app-cpufreq/root/etc/config/cpufreq
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
config settings 'cpufreq'
|
||||
option maxfreq '716000'
|
||||
option upthreshold '50'
|
||||
option factor '10'
|
||||
option minifreq '300000'
|
||||
option governor 'ondemand'
|
||||
|
29
package/lean/luci-app-cpufreq/root/etc/init.d/cpufreq
Executable file
29
package/lean/luci-app-cpufreq/root/etc/init.d/cpufreq
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=50
|
||||
|
||||
NAME=cpufreq
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get $NAME.@$1[0].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
config_load cpufreq
|
||||
local governor=$(uci_get_by_type settings governor ondemand)
|
||||
local minifreq=$(uci_get_by_type settings minifreq 48000)
|
||||
local maxfreq=$(uci_get_by_type settings maxfreq 716000)
|
||||
local upthreshold=$(uci_get_by_type settings upthreshold 50)
|
||||
local factor=$(uci_get_by_type settings factor 10)
|
||||
|
||||
echo $governor > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
|
||||
echo $minifreq > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
|
||||
echo $maxfreq > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
|
||||
if [ "$governor" == "ondemand" ]; then
|
||||
echo $upthreshold > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
||||
echo $factor > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
|
||||
fi
|
||||
}
|
||||
|
||||
|
11
package/lean/luci-app-cpufreq/root/etc/uci-defaults/cpufreq
Executable file
11
package/lean/luci-app-cpufreq/root/etc/uci-defaults/cpufreq
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@cpufreq[-1]
|
||||
add ucitrack cpufreq
|
||||
set ucitrack.@cpufreq[-1].init=cpufreq
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
35
target/linux/ipq40xx/base-files/etc/init.d/zlinksys_recovery
Executable file
35
target/linux/ipq40xx/base-files/etc/init.d/zlinksys_recovery
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# This script sets auto_recovery to "yes" and resets the boot counter to 0.
|
||||
# As a golden rule, this should be the latest script to run at boot. For a
|
||||
# developer snapshot, it is fine to set auto_recovery here. But for a stable
|
||||
# release, this script must in fact turn off auto_recovery.
|
||||
#
|
||||
# Why? Because the custom sysupgrade script for the device will turn on
|
||||
# auto_recovery to "yes". And it's the job of this script to set the
|
||||
# boot boot_count to 0 and then disable auto_recovery, as that condition
|
||||
# means that the stable release went well.
|
||||
#
|
||||
# I have to repeat: this script should be changed for stable releases.
|
||||
|
||||
START=99
|
||||
boot() {
|
||||
. /lib/functions.sh
|
||||
|
||||
case $(board_name) in
|
||||
linksys,ea6350v3)
|
||||
# make sure auto_recovery in uboot is always on
|
||||
IS_AUTO_RECOVERY="$(fw_printenv -n auto_recovery)"
|
||||
if [ "$IS_AUTO_RECOVERY" != "yes" ] ; then
|
||||
fw_setenv auto_recovery yes
|
||||
echo "Linksys EA6350v3: fw_setenv: auto_recovery has been set to yes"
|
||||
fi
|
||||
# reset the boot counter
|
||||
fw_setenv boot_count 0
|
||||
mtd resetbc s_env
|
||||
echo "Linksys EA6350v3: boot counter has been reset"
|
||||
echo "Linksys EA6350v3: boot_part=$(fw_printenv -n boot_part)"
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user