luci-app-cpufreq: unlocked for all target

This commit is contained in:
LEAN-ESX 2020-03-08 01:50:35 -08:00 committed by CN_SZTL
parent ff1a7b25e2
commit 018ea78507
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
3 changed files with 38 additions and 19 deletions

View File

@ -16,7 +16,7 @@ DEVICE_TYPE?=router
DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd urandom-seed urngd \ DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd urandom-seed urngd \
coreutils kmod-nf-nathelper kmod-nf-nathelper-extra kmod-ipt-raw wget libustream-openssl ca-certificates \ coreutils kmod-nf-nathelper kmod-nf-nathelper-extra kmod-ipt-raw wget libustream-openssl ca-certificates \
default-settings luci luci-base luci-compat luci-lib-fs luci-lib-ipkg luci-proto-relay \ default-settings luci luci-base luci-compat luci-lib-fs luci-lib-ipkg luci-proto-relay \
luci-app-flowoffload luci-app-cpufreq luci-app-flowoffload
# For nas targets # For nas targets
DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm
# For router targets # For router targets

View File

@ -6,11 +6,11 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI for CPU IPQ40xx Freq LUCI_TITLE:=LuCI for CPU Freq Setting
LUCI_DEPENDS:=@TARGET_ipq40xx LUCI_DEPENDS:=
PKG_NAME:=luci-app-cpufreq PKG_NAME:=luci-app-cpufreq
PKG_VERSION:=1 PKG_VERSION:=1
PKG_RELEASE:=2 PKG_RELEASE:=3
include $(TOPDIR)/feeds/luci/luci.mk include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -1,3 +1,26 @@
local fs = require "nixio.fs"
cpu_freqs = fs.readfile("/sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies") or "100000"
cpu_freqs = string.sub(cpu_freqs, 1, -3)
cpu_governors = fs.readfile("/sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors") or "performance"
cpu_governors = string.sub(cpu_governors, 1, -3)
function string.split(input, delimiter)
input = tostring(input)
delimiter = tostring(delimiter)
if (delimiter=='') then return false end
local pos,arr = 0, {}
for st,sp in function() return string.find(input, delimiter, pos, true) end do
table.insert(arr, string.sub(input, pos, st - 1))
pos = sp + 1
end
table.insert(arr, string.sub(input, pos))
return arr
end
freq_array = string.split(cpu_freqs, " ")
governor_array = string.split(cpu_governors, " ")
mp = Map("cpufreq", translate("CPU Freq Settings")) mp = Map("cpufreq", translate("CPU Freq Settings"))
mp.description = translate("Set CPU Scaling Governor to Max Performance or Balance Mode") mp.description = translate("Set CPU Scaling Governor to Max Performance or Balance Mode")
@ -6,22 +29,19 @@ s = mp:section(NamedSection, "cpufreq", "settings")
s.anonymouse = true s.anonymouse = true
governor = s:option(ListValue, "governor", translate("CPU Scaling Governor")) governor = s:option(ListValue, "governor", translate("CPU Scaling Governor"))
governor:value("ondemand", translate("Ondemand Balance Mode")) for _, e in ipairs(governor_array) do
governor:value("performance", translate("Performance Mode")) if e ~= "" then governor:value(e,string.upper(e)) end
end
minifreq = s:option(Value, "minifreq", translate("Min Idle CPU Freq")) minfreq = s:option(ListValue, "minifreq", translate("Min Idle CPU Freq"))
minifreq.datatype="range(48000,716000)" for _, e in ipairs(freq_array) do
minifreq.rmempty = false if e ~= "" then minfreq:value(e) end
minifreq.description = translate("CPU Freq from 48000 to 716000 (Khz)") end
minifreq.placeholder = 48000
minifreq.default = 48000
maxfreq = s:option(Value, "maxfreq", translate("Max Turbo Boost CPU Freq")) maxfreq = s:option(ListValue, "maxfreq", translate("Max Turbo Boost CPU Freq"))
maxfreq.datatype="range(48000,716000)" for _, e in ipairs(freq_array) do
maxfreq.rmempty = false if e ~= "" then maxfreq:value(e) end
maxfreq.description = translate("CPU Freq from 48000 to 716000 (Khz)") end
maxfreq.placeholder = 716000
maxfreq.default = 716000
upthreshold = s:option(Value, "upthreshold", translate("CPU Switching Threshold")) upthreshold = s:option(Value, "upthreshold", translate("CPU Switching Threshold"))
upthreshold.datatype="range(1,99)" upthreshold.datatype="range(1,99)"
@ -37,5 +57,4 @@ factor.description = translate("The sampling rate determines how frequently the
factor.placeholder = 10 factor.placeholder = 10
factor.default = 10 factor.default = 10
return mp return mp