Fix unecessary calls to on_set() from battery vibe checks and reset ppt to default instead of max
This commit is contained in:
parent
d654e3ee06
commit
2f8c0a0172
9 changed files with 18 additions and 12 deletions
2
backend/Cargo.lock
generated
2
backend/Cargo.lock
generated
|
@ -1053,7 +1053,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "powertools"
|
||||
version = "1.3.0-beta4"
|
||||
version = "1.4.0-alpha"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"libryzenadj",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "powertools"
|
||||
version = "1.3.0-beta4"
|
||||
version = "1.4.0-alpha"
|
||||
edition = "2021"
|
||||
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
||||
description = "Backend (superuser) functionality for PowerTools"
|
||||
|
|
|
@ -355,7 +355,7 @@ impl ApiMessageHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
false // on_power_event() should apply everything
|
||||
}
|
||||
ApiMessage::WaitForEmptyQueue(callback) => {
|
||||
self.on_empty.push(callback);
|
||||
|
|
|
@ -10,7 +10,7 @@ const ALLOWED_ERROR: f64 = 100.0; // period of 10ms with 100x means sleep has to
|
|||
pub fn spawn(sender: Sender<ApiMessage>) -> 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 {
|
||||
|
|
|
@ -96,23 +96,23 @@ impl OnSet for Settings {
|
|||
fn on_set(&mut self) -> Result<(), Vec<SettingError>> {
|
||||
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(())
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -123,7 +123,9 @@ impl Default for CpuLimits {
|
|||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub(super) struct GpuLimits {
|
||||
pub fast_ppt: MinMax<u64>,
|
||||
pub fast_ppt_default: u64,
|
||||
pub slow_ppt: MinMax<u64>,
|
||||
pub slow_ppt_default: u64,
|
||||
pub ppt_divisor: u64,
|
||||
pub ppt_step: u64,
|
||||
pub clock_min: MinMax<u64>,
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in a new issue