From 0d68ae996c8bad3806cd36c64472bc0fc1d2ff23 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 1 Apr 2023 20:11:02 -0400 Subject: [PATCH] Reset PPT to max when limits disabled --- backend/src/settings/steam_deck/gpu.rs | 32 ++++++++++++++++++++++++++ backend/src/state/steam_deck/gpu.rs | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/backend/src/settings/steam_deck/gpu.rs b/backend/src/settings/steam_deck/gpu.rs index 596c6e0..cf168c8 100644 --- a/backend/src/settings/steam_deck/gpu.rs +++ b/backend/src/settings/steam_deck/gpu.rs @@ -199,6 +199,22 @@ impl Gpu { let mut errors = Vec::new(); // set fast PPT if let Some(fast_ppt) = &self.fast_ppt { + self.state.fast_ppt_set = true; + let fast_ppt_path = gpu_power_path(FAST_PPT); + usdpl_back::api::files::write_single(&fast_ppt_path, fast_ppt) + .map_err(|e| SettingError { + msg: format!( + "Failed to write `{}` to `{}`: {}", + fast_ppt, &fast_ppt_path, e + ), + setting: crate::settings::SettingVariant::Gpu, + }) + .unwrap_or_else(|e| { + errors.push(e); + }); + } else if self.state.fast_ppt_set { + self.state.fast_ppt_set = false; + let fast_ppt = self.limits.fast_ppt.max; let fast_ppt_path = gpu_power_path(FAST_PPT); usdpl_back::api::files::write_single(&fast_ppt_path, fast_ppt) .map_err(|e| SettingError { @@ -214,6 +230,22 @@ impl Gpu { } // set slow PPT if let Some(slow_ppt) = &self.slow_ppt { + self.state.slow_ppt_set = true; + let slow_ppt_path = gpu_power_path(SLOW_PPT); + usdpl_back::api::files::write_single(&slow_ppt_path, slow_ppt) + .map_err(|e| SettingError { + msg: format!( + "Failed to write `{}` to `{}`: {}", + slow_ppt, &slow_ppt_path, e + ), + setting: crate::settings::SettingVariant::Gpu, + }) + .unwrap_or_else(|e| { + errors.push(e); + }); + } else if self.state.slow_ppt_set { + self.state.slow_ppt_set = false; + let slow_ppt = self.limits.slow_ppt.max; 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/state/steam_deck/gpu.rs b/backend/src/state/steam_deck/gpu.rs index 3091f70..d7f31b1 100644 --- a/backend/src/state/steam_deck/gpu.rs +++ b/backend/src/state/steam_deck/gpu.rs @@ -1,6 +1,8 @@ #[derive(Debug, Clone)] pub struct Gpu { pub clock_limits_set: bool, + pub fast_ppt_set: bool, + pub slow_ppt_set: bool, pub is_resuming: bool, } @@ -8,6 +10,8 @@ impl std::default::Default for Gpu { fn default() -> Self { Self { clock_limits_set: true, + fast_ppt_set: false, + slow_ppt_set: false, is_resuming: false, } }