1
Fork 0
mirror of https://github.com/RGBCube/superfreq synced 2025-07-27 17:07:44 +00:00

engine: reduce sysfs writes

This commit is contained in:
NotAShelf 2025-05-18 05:28:52 +03:00
parent aaa46e9223
commit 9db1a028bf
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF

View file

@ -420,22 +420,41 @@ fn manage_auto_turbo(
hysteresis.update_state(enable_turbo); hysteresis.update_state(enable_turbo);
} }
// Apply the turbo setting // Only apply the setting if the state has changed
let turbo_setting = if enable_turbo { let changed = previous_turbo_enabled != enable_turbo;
TurboSetting::Always if changed {
} else { let turbo_setting = if enable_turbo {
TurboSetting::Never TurboSetting::Always
}; } else {
TurboSetting::Never
};
match cpu::set_turbo(turbo_setting) { info!(
Ok(()) => { "Auto Turbo: Applying turbo change from {} to {}",
debug!( if previous_turbo_enabled {
"Auto Turbo: Successfully set turbo to {}", "enabled"
if enable_turbo { "enabled" } else { "disabled" } } else {
); "disabled"
Ok(()) },
if enable_turbo { "enabled" } else { "disabled" }
);
match cpu::set_turbo(turbo_setting) {
Ok(()) => {
debug!(
"Auto Turbo: Successfully set turbo to {}",
if enable_turbo { "enabled" } else { "disabled" }
);
Ok(())
}
Err(e) => Err(EngineError::ControlError(e)),
} }
Err(e) => Err(EngineError::ControlError(e)), } else {
debug!(
"Auto Turbo: Maintaining turbo state ({}) - no change needed",
if enable_turbo { "enabled" } else { "disabled" }
);
Ok(())
} }
} }