diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 9416cdc..9115d16 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -826,7 +826,7 @@ dependencies = [ [[package]] name = "powertools-rs" -version = "1.1.0-beta5" +version = "1.1.0-beta6" dependencies = [ "async-trait", "limits_core", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 4d4db5e..72d737b 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools-rs" -version = "1.1.0-beta5" +version = "1.1.0-beta6" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" diff --git a/backend/src/api/api_types.rs b/backend/src/api/api_types.rs index f70c69a..2107852 100644 --- a/backend/src/api/api_types.rs +++ b/backend/src/api/api_types.rs @@ -33,6 +33,7 @@ pub struct CpusLimits { pub cpus: Vec, pub count: usize, pub smt_capable: bool, + pub governors: Vec, } #[derive(Serialize, Deserialize)] diff --git a/backend/src/settings/generic/cpu.rs b/backend/src/settings/generic/cpu.rs index 0ae3c25..2ae1f5c 100644 --- a/backend/src/settings/generic/cpu.rs +++ b/backend/src/settings/generic/cpu.rs @@ -134,6 +134,7 @@ impl + AsRef + TCpu + OnResume + OnSet> TCpus for Cpus { cpus: self.cpus.iter().map(|x| x.as_ref().limits()).collect(), count: self.cpus.len(), smt_capable: self.smt_capable, + governors: Vec::with_capacity(0), } } diff --git a/backend/src/settings/steam_deck/cpu.rs b/backend/src/settings/steam_deck/cpu.rs index 038558b..2c7ce0c 100644 --- a/backend/src/settings/steam_deck/cpu.rs +++ b/backend/src/settings/steam_deck/cpu.rs @@ -155,6 +155,12 @@ impl TCpus for Cpus { cpus: self.cpus.iter().map(|x| x.limits()).collect(), count: self.cpus.len(), smt_capable: self.smt_capable, + governors: if self.limits.global_governors { + self.cpus.iter() + .next() + .map(|x| x.governors()) + .unwrap_or_else(|| Vec::with_capacity(0)) + } else { Vec::with_capacity(0) }, } } @@ -358,7 +364,7 @@ impl Cpu { min: self.limits.clock_max.min, max: self.limits.clock_max.max }), - clock_step: 100, + clock_step: self.limits.clock_step, governors: self.governors(), } } diff --git a/backend/src/settings/steam_deck/gpu.rs b/backend/src/settings/steam_deck/gpu.rs index 8f3f826..3253a8a 100644 --- a/backend/src/settings/steam_deck/gpu.rs +++ b/backend/src/settings/steam_deck/gpu.rs @@ -222,20 +222,18 @@ impl OnResume for Gpu { } } -const PPT_DIVISOR: u64 = 1_000_000; - impl TGpu for Gpu { fn limits(&self) -> crate::api::GpuLimits { crate::api::GpuLimits { fast_ppt_limits: Some(RangeLimit { - min: self.limits.fast_ppt.min / PPT_DIVISOR, - max: self.limits.fast_ppt.max / PPT_DIVISOR, + min: self.limits.fast_ppt.min / self.limits.ppt_divisor, + max: self.limits.fast_ppt.max / self.limits.ppt_divisor, }), slow_ppt_limits: Some(RangeLimit { - min: self.limits.slow_ppt.min / PPT_DIVISOR, - max: self.limits.slow_ppt.max / PPT_DIVISOR, + min: self.limits.slow_ppt.min / self.limits.ppt_divisor, + max: self.limits.slow_ppt.max / self.limits.ppt_divisor, }), - ppt_step: 1, + ppt_step: self.limits.ppt_step, tdp_limits: None, tdp_boost_limits: None, tdp_step: 42, @@ -247,7 +245,7 @@ impl TGpu for Gpu { min: self.limits.clock_max.min, max: self.limits.clock_max.max, }), - clock_step: 100, + clock_step: self.limits.clock_step, memory_control_capable: true, } } @@ -257,12 +255,12 @@ impl TGpu for Gpu { } fn ppt(&mut self, fast: Option, slow: Option) { - self.fast_ppt = fast.map(|x| x * PPT_DIVISOR); - self.slow_ppt = slow.map(|x| x * PPT_DIVISOR); + self.fast_ppt = fast.map(|x| x * self.limits.ppt_divisor); + self.slow_ppt = slow.map(|x| x * self.limits.ppt_divisor); } fn get_ppt(&self) -> (Option, Option) { - (self.fast_ppt.map(|x| x / PPT_DIVISOR), self.slow_ppt.map(|x| x / PPT_DIVISOR)) + (self.fast_ppt.map(|x| x / self.limits.ppt_divisor), self.slow_ppt.map(|x| x / self.limits.ppt_divisor)) } fn clock_limits(&mut self, limits: Option>) { diff --git a/backend/src/settings/steam_deck/oc_limits.rs b/backend/src/settings/steam_deck/oc_limits.rs index da5cefa..47e84be 100644 --- a/backend/src/settings/steam_deck/oc_limits.rs +++ b/backend/src/settings/steam_deck/oc_limits.rs @@ -66,12 +66,14 @@ impl Default for BatteryLimits { #[derive(Serialize, Deserialize, Clone, Debug)] pub(super) struct CpusLimits { pub cpus: Vec, + pub global_governors: bool, } impl Default for CpusLimits { fn default() -> Self { Self { - cpus: [(); 8].iter().map(|_| CpuLimits::default()).collect() + cpus: [(); 8].iter().map(|_| CpuLimits::default()).collect(), + global_governors: false, } } } @@ -80,13 +82,15 @@ impl Default for CpusLimits { pub(super) struct CpuLimits { pub clock_min: MinMax, pub clock_max: MinMax, + pub clock_step: u64, } impl Default for CpuLimits { fn default() -> Self { Self { clock_min: MinMax { min: 1400, max: 3500 }, - clock_max: MinMax { min: 400, max: 3500 } + clock_max: MinMax { min: 400, max: 3500 }, + clock_step: 100, } } } @@ -95,8 +99,11 @@ impl Default for CpuLimits { pub(super) struct GpuLimits { pub fast_ppt: MinMax, pub slow_ppt: MinMax, + pub ppt_divisor: u64, + pub ppt_step: u64, pub clock_min: MinMax, pub clock_max: MinMax, + pub clock_step: u64, } impl Default for GpuLimits { @@ -104,8 +111,11 @@ impl Default for GpuLimits { Self { fast_ppt: MinMax { min: 1000000, max: 30_000_000 }, slow_ppt: MinMax { min: 1000000, max: 29_000_000 }, + ppt_divisor: 1_000_000, + ppt_step: 1, clock_min: MinMax { min: 200, max: 1600 }, - clock_max: MinMax { min: 200, max: 1600 } + clock_max: MinMax { min: 200, max: 1600 }, + clock_step: 100, } } } diff --git a/backend/src/settings/unknown/cpu.rs b/backend/src/settings/unknown/cpu.rs index 909c746..16e5ba4 100644 --- a/backend/src/settings/unknown/cpu.rs +++ b/backend/src/settings/unknown/cpu.rs @@ -138,6 +138,7 @@ impl TCpus for Cpus { cpus: self.cpus.iter().map(|x| x.limits()).collect(), count: self.cpus.len(), smt_capable: self.smt_capable, + governors: Vec::with_capacity(0), } } diff --git a/package.json b/package.json index 1fad640..75e6fd7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "1.1.0-beta5", + "version": "1.1.0-beta6", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/src/backend.ts b/src/backend.ts index 5bbe0d1..55d05c8 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -72,6 +72,7 @@ export type CpusLimits = { cpus: CpuLimits[]; count: number; smt_capable: boolean; + governors: string[]; }; export type GeneralLimits = {}; diff --git a/src/components/cpus.tsx b/src/components/cpus.tsx index 9089dac..2b9a60d 100644 --- a/src/components/cpus.tsx +++ b/src/components/cpus.tsx @@ -54,6 +54,11 @@ export class Cpus extends Component<{}, CpuState> { label: {elem}, };}); + const governorGlobalOptions: SingleDropdownOption[] = (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.governors.map((elem) => {return { + data: elem, + label: {elem}, + };}); + return ( {/* CPU */}
@@ -215,6 +220,32 @@ export class Cpus extends Component<{}, CpuState> { }} />} } + {!advancedMode && governorGlobalOptions.length != 0 && + + { + backend.log(backend.LogLevel.Debug, "POWERTOOLS: array item " + val.toString()); + backend.log(backend.LogLevel.Debug, "POWERTOOLS: looking for data " + get_value(GOVERNOR_CPU)[0].toString()); + return val.data == get_value(GOVERNOR_CPU)[0]; + })} + strDefaultLabel={get_value(GOVERNOR_CPU)[0]} + onChange={(elem: SingleDropdownOption) => { + backend.log(backend.LogLevel.Debug, "Governor global dropdown selected " + elem.data.toString()); + const governors = get_value(GOVERNOR_CPU); + for (let i = 0; i < total_cpus; i++) { + governors[i] = elem.data as string; + backend.resolve(backend.setCpuGovernor(i, elem.data as string), (_: string) => {}); + } + set_value(GOVERNOR_CPU, governors); + reloadGUI("CPUGlobalGovernor"); + }} + /> + + } {/* CPU advanced mode */} {advancedMode &&