From 2f8c0a017207018d62d04e266638635ddb3a5266 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 1 Apr 2023 20:43:26 -0400 Subject: [PATCH] Fix unecessary calls to on_set() from battery vibe checks and reset ppt to default instead of max --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- backend/src/api/handler.rs | 2 +- backend/src/resume_worker.rs | 2 +- backend/src/settings/general.rs | 10 +++++----- backend/src/settings/steam_deck/gpu.rs | 4 ++-- backend/src/settings/steam_deck/oc_limits.rs | 4 ++++ package.json | 2 +- pt_oc.json | 2 ++ 9 files changed, 18 insertions(+), 12 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 4aa53b0..f8baccd 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1053,7 +1053,7 @@ dependencies = [ [[package]] name = "powertools" -version = "1.3.0-beta4" +version = "1.4.0-alpha" dependencies = [ "async-trait", "libryzenadj", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 0ceb00f..c441c74 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools" -version = "1.3.0-beta4" +version = "1.4.0-alpha" 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 d44afb9..57f57f5 100644 --- a/backend/src/api/handler.rs +++ b/backend/src/api/handler.rs @@ -355,7 +355,7 @@ impl ApiMessageHandler { } } } - true + false // on_power_event() should apply everything } ApiMessage::WaitForEmptyQueue(callback) => { self.on_empty.push(callback); diff --git a/backend/src/resume_worker.rs b/backend/src/resume_worker.rs index ca5c639..dfa4d8f 100644 --- a/backend/src/resume_worker.rs +++ b/backend/src/resume_worker.rs @@ -10,7 +10,7 @@ const ALLOWED_ERROR: f64 = 100.0; // period of 10ms with 100x means sleep has to pub fn spawn(sender: Sender) -> JoinHandle<()> { thread::spawn(move || { log::info!("resume_worker starting..."); - let duration = Duration::from_millis(10); // very low so it detects before Steam client does + let duration = Duration::from_millis(50); // very low so it detects before Steam client does // this allows PowerTools to set some values at wakeup and Steam to override them before user notices let mut start = Instant::now(); loop { diff --git a/backend/src/settings/general.rs b/backend/src/settings/general.rs index 348b10f..5e39694 100644 --- a/backend/src/settings/general.rs +++ b/backend/src/settings/general.rs @@ -96,23 +96,23 @@ impl OnSet for Settings { fn on_set(&mut self) -> Result<(), Vec> { let mut errors = Vec::new(); - log::debug!("Applying settings for on_resume"); + log::debug!("Applying settings for on_set"); self.general .on_set() .unwrap_or_else(|mut e| errors.append(&mut e)); - log::debug!("Resumed general"); + log::debug!("Set general"); self.battery .on_set() .unwrap_or_else(|mut e| errors.append(&mut e)); - log::debug!("Resumed battery"); + log::debug!("Set battery"); self.cpus .on_set() .unwrap_or_else(|mut e| errors.append(&mut e)); - log::debug!("Resumed CPUs"); + log::debug!("Set CPUs"); self.gpu .on_set() .unwrap_or_else(|mut e| errors.append(&mut e)); - log::debug!("Resumed GPU"); + log::debug!("Set GPU"); if errors.is_empty() { Ok(()) diff --git a/backend/src/settings/steam_deck/gpu.rs b/backend/src/settings/steam_deck/gpu.rs index cf168c8..83bf2bd 100644 --- a/backend/src/settings/steam_deck/gpu.rs +++ b/backend/src/settings/steam_deck/gpu.rs @@ -214,7 +214,7 @@ impl Gpu { }); } else if self.state.fast_ppt_set { self.state.fast_ppt_set = false; - let fast_ppt = self.limits.fast_ppt.max; + let fast_ppt = self.limits.fast_ppt_default; let fast_ppt_path = gpu_power_path(FAST_PPT); usdpl_back::api::files::write_single(&fast_ppt_path, fast_ppt) .map_err(|e| SettingError { @@ -245,7 +245,7 @@ impl Gpu { }); } else if self.state.slow_ppt_set { self.state.slow_ppt_set = false; - let slow_ppt = self.limits.slow_ppt.max; + let slow_ppt = self.limits.slow_ppt_default; let slow_ppt_path = gpu_power_path(SLOW_PPT); usdpl_back::api::files::write_single(&slow_ppt_path, slow_ppt) .map_err(|e| SettingError { diff --git a/backend/src/settings/steam_deck/oc_limits.rs b/backend/src/settings/steam_deck/oc_limits.rs index 29aae00..d0cbeac 100644 --- a/backend/src/settings/steam_deck/oc_limits.rs +++ b/backend/src/settings/steam_deck/oc_limits.rs @@ -123,7 +123,9 @@ impl Default for CpuLimits { #[derive(Serialize, Deserialize, Clone, Debug)] pub(super) struct GpuLimits { pub fast_ppt: MinMax, + pub fast_ppt_default: u64, pub slow_ppt: MinMax, + pub slow_ppt_default: u64, pub ppt_divisor: u64, pub ppt_step: u64, pub clock_min: MinMax, @@ -139,10 +141,12 @@ impl Default for GpuLimits { min: 1000000, max: 30_000_000, }, + fast_ppt_default: 15_000_000, slow_ppt: MinMax { min: 1000000, max: 29_000_000, }, + slow_ppt_default: 15_000_000, ppt_divisor: 1_000_000, ppt_step: 1, clock_min: MinMax { diff --git a/package.json b/package.json index 81359e9..993f9aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "1.3.0-beta4", + "version": "1.4.0-alpha", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/pt_oc.json b/pt_oc.json index 3ee8234..79d3c37 100644 --- a/pt_oc.json +++ b/pt_oc.json @@ -111,10 +111,12 @@ "min": 1000000, "max": 30000000 }, + "fast_ppt_default": 15000000, "slow_ppt": { "min": 1000000, "max": 29000000 }, + "slow_ppt_default": 15000000, "ppt_divisor": 1000000, "ppt_step": 1, "clock_min": {