mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-27 17:07:44 +00:00
cpu: enhance document set_turbo
function and Auto
mode behavior
This commit is contained in:
parent
a1c8190c28
commit
04b01aa070
1 changed files with 26 additions and 6 deletions
32
src/cpu.rs
32
src/cpu.rs
|
@ -212,24 +212,44 @@ fn get_available_governors() -> Result<Vec<String>> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: I think the Auto Turbo behaviour is still pretty confusing for the end-user
|
/// Controls CPU turbo boost behavior by writing to appropriate sysfs files.
|
||||||
// who might not have read the documentation in detail. We could just make the program
|
///
|
||||||
// more verbose here, but I think this is a fundamental design flaw that I will want
|
/// # Parameters
|
||||||
// to refactor in the future. For now though, I think this is a good-ish solution.
|
///
|
||||||
|
/// * `setting` - The desired turbo boost setting:
|
||||||
|
/// - `TurboSetting::Always`: Forces turbo boost to be always enabled
|
||||||
|
/// - `TurboSetting::Never`: Forces turbo boost to be always disabled
|
||||||
|
/// - `TurboSetting::Auto`: Has two distinct behaviors depending on the context:
|
||||||
|
/// 1. When called directly from user commands: Resets turbo to system default (enabled)
|
||||||
|
/// 2. When used with `enable_auto_turbo=true` in config: Managed dynamically by the engine
|
||||||
|
///
|
||||||
|
/// # Turbo Auto Mode Explained
|
||||||
|
///
|
||||||
|
/// When `TurboSetting::Auto` is used:
|
||||||
|
/// - This function writes the same values as `TurboSetting::Always` to reset the hardware
|
||||||
|
/// to its default state (turbo enabled)
|
||||||
|
/// - The actual dynamic management happens at a higher level in the engine module
|
||||||
|
/// when `enable_auto_turbo=true`
|
||||||
|
/// - With `enable_auto_turbo=false`, the system's native turbo management takes over
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// * `Result<()>` - Success or an error if the operation failed
|
||||||
pub fn set_turbo(setting: TurboSetting) -> Result<()> {
|
pub fn set_turbo(setting: TurboSetting) -> Result<()> {
|
||||||
let value_pstate = match setting {
|
let value_pstate = match setting {
|
||||||
TurboSetting::Always => "0", // no_turbo = 0 means turbo is enabled
|
TurboSetting::Always => "0", // no_turbo = 0 means turbo is enabled
|
||||||
TurboSetting::Never => "1", // no_turbo = 1 means turbo is disabled
|
TurboSetting::Never => "1", // no_turbo = 1 means turbo is disabled
|
||||||
// For Auto, we need to enable the hardware default (which is turbo enabled)
|
// For Auto, we need to enable the hardware default (which is turbo enabled)
|
||||||
// and we reset to the system default when explicitly set to Auto
|
// and we reset to the system default when explicitly set to Auto
|
||||||
TurboSetting::Auto => "0", // Set to enabled (default hardware state) when Auto is requested
|
TurboSetting::Auto => "0", // set to enabled (default hardware state) when Auto is requested
|
||||||
};
|
};
|
||||||
let value_boost = match setting {
|
let value_boost = match setting {
|
||||||
TurboSetting::Always => "1", // boost = 1 means turbo is enabled
|
TurboSetting::Always => "1", // boost = 1 means turbo is enabled
|
||||||
TurboSetting::Never => "0", // boost = 0 means turbo is disabled
|
TurboSetting::Never => "0", // boost = 0 means turbo is disabled
|
||||||
// For Auto, we need to enable the hardware default (which is turbo enabled)
|
// For Auto, we need to enable the hardware default (which is turbo enabled)
|
||||||
// and we reset to the system default when explicitly set to Auto
|
// and we reset to the system default when explicitly set to Auto
|
||||||
TurboSetting::Auto => "1", // Set to enabled (default hardware state) when Auto is requested
|
TurboSetting::Auto => "1", // set to enabled (default hardware state) when Auto is requested
|
||||||
};
|
};
|
||||||
|
|
||||||
// AMD specific paths
|
// AMD specific paths
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue