From aff5005ca9b7efebac5d9814a911e6fccc95b068 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Wed, 18 Jan 2023 17:54:33 -0500 Subject: [PATCH] Allow max == min, fix SMT bug, compile missing .mo files --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- backend/src/api/handler.rs | 1 + backend/src/settings/steam_deck/cpu.rs | 5 +- backend/src/settings/steam_deck/oc_limits.rs | 10 ++-- package.json | 2 +- pt_oc.json | 47 +++++++++++++++++++ src/components/cpus.tsx | 8 ++-- src/components/gpu.tsx | 4 +- translations/es-ES.mo | Bin 0 -> 2450 bytes translations/es-ES.po | 8 ++-- translations/{zh_CN.mo => zh-CN.mo} | Bin translations/{zh_CN.po => zh-CN.po} | 0 translations/zh-HK.mo | Bin 0 -> 2306 bytes translations/{zh_HK.po => zh-HK.po} | 0 15 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 pt_oc.json create mode 100644 translations/es-ES.mo rename translations/{zh_CN.mo => zh-CN.mo} (100%) rename translations/{zh_CN.po => zh-CN.po} (100%) create mode 100644 translations/zh-HK.mo rename translations/{zh_HK.po => zh-HK.po} (100%) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 53a7aa6..4576e9a 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -826,7 +826,7 @@ dependencies = [ [[package]] name = "powertools-rs" -version = "1.1.0" +version = "1.1.0-beta4" dependencies = [ "async-trait", "limits_core", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 8bbfa40..d154972 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools-rs" -version = "1.1.0" +version = "1.1.0-beta4" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" diff --git a/backend/src/api/handler.rs b/backend/src/api/handler.rs index 2b9cd60..48a4962 100644 --- a/backend/src/api/handler.rs +++ b/backend/src/api/handler.rs @@ -145,6 +145,7 @@ impl CpuMessage { matches!(self, Self::SetCpuOnline(_, _) | Self::SetCpusOnline(_) + | Self::SetSmt(_, _) | Self::SetClockLimits(_, _) | Self::SetCpuGovernor(_, _) | Self::SetCpusGovernor(_) diff --git a/backend/src/settings/steam_deck/cpu.rs b/backend/src/settings/steam_deck/cpu.rs index 2c3544a..539a5f4 100644 --- a/backend/src/settings/steam_deck/cpu.rs +++ b/backend/src/settings/steam_deck/cpu.rs @@ -256,7 +256,8 @@ impl Cpu { }, )?; // min clock - let payload_min = format!("p {} 0 {}\n", self.index / 2, clock_limits.min); + let valid_min = if clock_limits.min < self.limits.clock_min.min {self.limits.clock_min.min} else {clock_limits.min}; + let payload_min = format!("p {} 0 {}\n", self.index / 2, valid_min); usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, &payload_min).map_err( |e| SettingError { msg: format!( @@ -339,7 +340,7 @@ impl Cpu { fn limits(&self) -> crate::api::CpuLimits { crate::api::CpuLimits { clock_min_limits: Some(RangeLimit { - min: self.limits.clock_min.min, + min: self.limits.clock_max.min, // allows min to be set by max (it's weird, blame the kernel) max: self.limits.clock_min.max }), clock_max_limits: Some(RangeLimit { diff --git a/backend/src/settings/steam_deck/oc_limits.rs b/backend/src/settings/steam_deck/oc_limits.rs index fe45826..da5cefa 100644 --- a/backend/src/settings/steam_deck/oc_limits.rs +++ b/backend/src/settings/steam_deck/oc_limits.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::settings::MinMax; -const OC_LIMITS_FILEPATH: &str = "./pt_oc.json"; +const OC_LIMITS_FILEPATH: &str = "pt_oc.json"; #[derive(Serialize, Deserialize, Debug)] pub(super) struct OverclockLimits { @@ -23,7 +23,7 @@ impl Default for OverclockLimits { impl OverclockLimits { /// (Self, is_default) pub fn load_or_default() -> (Self, bool) { - let path = std::path::Path::new(OC_LIMITS_FILEPATH); + let path = oc_limits_filepath(); if path.exists() { log::info!("Steam Deck limits file {} found", path.display()); let mut file = match std::fs::File::open(&path) { @@ -86,7 +86,7 @@ impl Default for CpuLimits { fn default() -> Self { Self { clock_min: MinMax { min: 1400, max: 3500 }, - clock_max: MinMax { min: 500, max: 3500 } + clock_max: MinMax { min: 400, max: 3500 } } } } @@ -109,3 +109,7 @@ impl Default for GpuLimits { } } } + +fn oc_limits_filepath() -> std::path::PathBuf { + crate::utility::settings_dir().join(OC_LIMITS_FILEPATH) +} diff --git a/package.json b/package.json index acca2f6..4988edf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "1.1.0", + "version": "1.1.0-beta4", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/pt_oc.json b/pt_oc.json new file mode 100644 index 0000000..410b8fd --- /dev/null +++ b/pt_oc.json @@ -0,0 +1,47 @@ +{ + "battery": { + "charge_rate": {"min": 250, "max": 2500} + }, + "cpus": { + "cpus": [ + { + "clock_min": {"min": 1400, "max": 3500}, + "clock_max": {"min": 500, "max": 3500} + }, + { + "clock_min": {"min": 1400, "max": 3500}, + "clock_max": {"min": 500, "max": 3500} + }, + { + "clock_min": {"min": 1400, "max": 3500}, + "clock_max": {"min": 500, "max": 3500} + }, + { + "clock_min": {"min": 1400, "max": 3500}, + "clock_max": {"min": 500, "max": 3500} + }, + { + "clock_min": {"min": 1400, "max": 3500}, + "clock_max": {"min": 500, "max": 3500} + }, + { + "clock_min": {"min": 1400, "max": 3500}, + "clock_max": {"min": 500, "max": 3500} + }, + { + "clock_min": {"min": 1400, "max": 3500}, + "clock_max": {"min": 500, "max": 3500} + }, + { + "clock_min": {"min": 1400, "max": 3500}, + "clock_max": {"min": 500, "max": 3500} + } + ] + }, + "gpu": { + "fast_ppt": {"min": 1000000, "max": 30000000}, + "slow_ppt": {"min": 1000000, "max": 29000000}, + "clock_min": {"min": 200, "max": 1600}, + "clock_max": {"min": 200, "max": 1600} + } +} diff --git a/src/components/cpus.tsx b/src/components/cpus.tsx index 586200c..fcc73dc 100644 --- a/src/components/cpus.tsx +++ b/src/components/cpus.tsx @@ -173,7 +173,7 @@ export class Cpus extends Component<{}, CpuState> { backend.log(backend.LogLevel.Debug, "Min freq slider is now " + freq.toString()); const freqNow = get_value(CLOCK_MIN_CPU); const maxNow = get_value(CLOCK_MAX_CPU); - if (freq != freqNow && ((maxNow != null && freq > maxNow) || maxNow == null)) { + if (freq != freqNow && ((maxNow != null && freq <= maxNow) || maxNow == null)) { set_value(CLOCK_MIN_CPU, freq); for (let i = 0; i < total_cpus; i++) { backend.resolve(backend.setCpuClockLimits(i, freq, get_value(CLOCK_MAX_CPU)), @@ -204,7 +204,7 @@ export class Cpus extends Component<{}, CpuState> { backend.log(backend.LogLevel.Debug, "Max freq slider is now " + freq.toString()); const freqNow = get_value(CLOCK_MAX_CPU); const minNow = get_value(CLOCK_MIN_CPU); - if (freq != freqNow && ((minNow != null && freq > minNow) || minNow == null)) { + if (freq != freqNow && ((minNow != null && freq >= minNow) || minNow == null)) { set_value(CLOCK_MAX_CPU, freq); for (let i = 0; i < total_cpus; i++) { backend.resolve(backend.setCpuClockLimits(i, get_value(CLOCK_MIN_CPU), freq), @@ -303,7 +303,7 @@ export class Cpus extends Component<{}, CpuState> { onChange={(freq: number) => { backend.log(backend.LogLevel.Debug, "Min freq slider for " + advancedCpu.toString() + " is now " + freq.toString()); const freqNow = get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex] as MinMax; - if (freq != freqNow.min && ((freqNow.max != null && freqNow.max > freq) || freqNow.max == null)) { + if (freq != freqNow.min && ((freqNow.max != null && freq <= freqNow.max) || freqNow.max == null)) { backend.resolve(backend.setCpuClockLimits(advancedCpuIndex, freq, freqNow.max!), (limits: number[]) => { const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[]; @@ -328,7 +328,7 @@ export class Cpus extends Component<{}, CpuState> { onChange={(freq: number) => { backend.log(backend.LogLevel.Debug, "Max freq slider for " + advancedCpu.toString() + " is now " + freq.toString()); const freqNow = get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex] as MinMax; - if (freq != freqNow.max && ((freqNow.min != null && freq > freqNow.min) || freqNow.min == null)) { + if (freq != freqNow.max && ((freqNow.min != null && freq >= freqNow.min) || freqNow.min == null)) { backend.resolve(backend.setCpuClockLimits(advancedCpuIndex, freqNow.min!, freq), (limits: number[]) => { const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[]; diff --git a/src/components/gpu.tsx b/src/components/gpu.tsx index e101aeb..7e432c7 100644 --- a/src/components/gpu.tsx +++ b/src/components/gpu.tsx @@ -145,7 +145,7 @@ export class Gpu extends Component<{}> { backend.log(backend.LogLevel.Debug, "GPU Clock Min is now " + val.toString()); const valNow = get_value(CLOCK_MIN_GPU); const maxNow = get_value(CLOCK_MAX_GPU); - if (val != valNow && ((maxNow != null && val < maxNow) || maxNow == null)) { + if (val != valNow && ((maxNow != null && val <= maxNow) || maxNow == null)) { backend.resolve(backend.setGpuClockLimits(val, get_value(CLOCK_MAX_GPU)), (limits: number[]) => { set_value(CLOCK_MIN_GPU, limits[0]); @@ -169,7 +169,7 @@ export class Gpu extends Component<{}> { backend.log(backend.LogLevel.Debug, "GPU Clock Max is now " + val.toString()); const valNow = get_value(CLOCK_MAX_GPU); const minNow = get_value(CLOCK_MIN_GPU); - if (val != valNow && ((minNow != null && val > minNow) || minNow == null)) { + if (val != valNow && ((minNow != null && val >= minNow) || minNow == null)) { backend.resolve(backend.setGpuClockLimits(get_value(CLOCK_MIN_GPU), val), (limits: number[]) => { set_value(CLOCK_MIN_GPU, limits[0]); diff --git a/translations/es-ES.mo b/translations/es-ES.mo new file mode 100644 index 0000000000000000000000000000000000000000..40ddd41615c4c8e89364cbc1524361c36b4d4bb2 GIT binary patch literal 2450 zcmZXUJB%Ae7{>?51DudRLV)lb2!uP7J>LZd9R>>LUWpXv%$*5Mgf!m$&Ns<=#+jM5 zbFP7oCV~QlA_XK0M3f>8NGT$@fsPJAK?Sr38Y(3I-+Jvhm(`7bH#?8-`QP6T?D$mR znZkGmoB+SLA3u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ScCH9rerKnhaR;o>Sl;?sBxfaI`LGq@2Igfl>bYgj|%QJ)P zoLtX4HXOyQQLV&Ko%mdsJcPUTIk*Oa+L1m-vs|Bp>k#O8Dc9%V8uXc`UgYYuq6&}I zJ^HMgEQQnerXxYo3(ZbQmBgg$W8Lx&2sYR2N~TBYG&;WMif2p<`9m|VC^&Fkat^x}V&hgVqu literal 0 HcmV?d00001 diff --git a/translations/es-ES.po b/translations/es-ES.po index 937fffe..aef82f0 100644 --- a/translations/es-ES.po +++ b/translations/es-ES.po @@ -9,10 +9,10 @@ msgstr "" "Project-Id-Version: v1.1\n" "Report-Msgid-Bugs-To: https://github.com/NGnius/PowerTools/issues\n" "POT-Creation-Date: 2023-01-09 19:52-0500\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" +"PO-Revision-Date: 2023-01-18 19:52-0500\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es-ES\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/translations/zh_CN.mo b/translations/zh-CN.mo similarity index 100% rename from translations/zh_CN.mo rename to translations/zh-CN.mo diff --git a/translations/zh_CN.po b/translations/zh-CN.po similarity index 100% rename from translations/zh_CN.po rename to translations/zh-CN.po diff --git a/translations/zh-HK.mo b/translations/zh-HK.mo new file mode 100644 index 0000000000000000000000000000000000000000..396104d172e7f08680d64ff16aaf276ff9f34557 GIT binary patch literal 2306 zcmZ9MTWl0n7{`wSUKT+_QB;)U4Ywx4QoID$@K7jMS=hiLFBmhsd%7K%owLlPg+8^3 zOAC~OLJ?}EAO#k&AQ;UGu(%Try zJ3=`RQv5FP6>vXDey)LZp6@}j`w67Dw?Ojmf#mmgxIY6$B|q~((q9y^2_*eDLU|=f z{x^o}8Ib(!3gvE)>emaBpOYY+^E~)8SOzJtAH)4$L5lkuNd5i`MEUCXlJsei|GAh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rename to translations/zh-HK.po