From 3e3e9a68f4cb1782b9bbba960f96edf60009078a Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 10 Feb 2024 12:52:21 -0500 Subject: [PATCH] Add Steam Deck max clock detection since OC can now be reported correctly version 2.0.0-alpha3 --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- backend/limits_core/src/json_v2/base.rs | 10 +- backend/limits_core/src/json_v2/cpu_limit.rs | 38 +- backend/limits_core/src/json_v2/gpu_limit.rs | 1 + backend/limits_srv/pt_limits_v2.json | 524 +++++++++++++++---- backend/src/settings/steam_deck/cpu.rs | 41 +- backend/src/settings/steam_deck/gpu.rs | 41 +- package.json | 2 +- 9 files changed, 536 insertions(+), 125 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 61c7515..a2f06f9 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1170,7 +1170,7 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "powertools" -version = "2.0.0-alpha2" +version = "2.0.0-alpha3" dependencies = [ "async-trait", "chrono", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 0c13046..ef0df3b 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools" -version = "2.0.0-alpha2" +version = "2.0.0-alpha3" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" diff --git a/backend/limits_core/src/json_v2/base.rs b/backend/limits_core/src/json_v2/base.rs index e066c71..72aa0f3 100644 --- a/backend/limits_core/src/json_v2/base.rs +++ b/backend/limits_core/src/json_v2/base.rs @@ -77,16 +77,16 @@ impl Default for Base { }, limits: super::Limits { cpu: super::Limit { - provider: super::CpuLimitType::SteamDeck, - limits: super::GenericCpusLimit::default_for(super::CpuLimitType::SteamDeck), + provider: super::CpuLimitType::SteamDeckOLED, + limits: super::GenericCpusLimit::default_for(super::CpuLimitType::SteamDeckOLED), }, gpu: super::Limit { - provider: super::GpuLimitType::SteamDeck, + provider: super::GpuLimitType::SteamDeckOLED, limits: super::GenericGpuLimit::default_for(super::GpuLimitType::SteamDeckOLED), }, battery: super::Limit { - provider: super::BatteryLimitType::SteamDeck, - limits: super::GenericBatteryLimit::default_for(super::BatteryLimitType::SteamDeck), + provider: super::BatteryLimitType::SteamDeckOLED, + limits: super::GenericBatteryLimit::default_for(super::BatteryLimitType::SteamDeckOLED), }, } }, diff --git a/backend/limits_core/src/json_v2/cpu_limit.rs b/backend/limits_core/src/json_v2/cpu_limit.rs index 24b7fde..4433a66 100644 --- a/backend/limits_core/src/json_v2/cpu_limit.rs +++ b/backend/limits_core/src/json_v2/cpu_limit.rs @@ -93,13 +93,14 @@ pub struct GenericCpuLimit { pub tdp_divisor: Option, pub tdp_step: Option, pub skip_resume_reclock: bool, - pub experiments: bool, + pub extras: super::LimitExtras, } impl GenericCpuLimit { pub fn default_for(t: &CpuLimitType, _index: usize) -> Self { match t { - CpuLimitType::SteamDeck | CpuLimitType::SteamDeckOLED => Self::default_steam_deck(), + CpuLimitType::SteamDeck => Self::default_steam_deck(), + CpuLimitType::SteamDeckOLED => Self::default_steam_deck_oled(), CpuLimitType::DevMode => Self { clock_min: Some(RangeLimit { min: Some(100), max: Some(5000) }), clock_max: Some(RangeLimit { min: Some(100), max: Some(4800) }), @@ -109,7 +110,7 @@ impl GenericCpuLimit { tdp_divisor: Some(1_000_000), tdp_step: Some(1), skip_resume_reclock: false, - experiments: true, + extras: Default::default(), }, _ => Self { clock_min: None, @@ -120,7 +121,7 @@ impl GenericCpuLimit { tdp_divisor: None, tdp_step: None, skip_resume_reclock: false, - experiments: false, + extras: Default::default(), }, } } @@ -141,7 +142,32 @@ impl GenericCpuLimit { tdp_divisor: None, tdp_step: None, skip_resume_reclock: false, - experiments: false, + extras: Default::default(), + } + } + + fn default_steam_deck_oled() -> Self { + Self { + clock_min: Some(RangeLimit { + min: Some(1400), + max: Some(3500), + }), + clock_max: Some(RangeLimit { + min: Some(400), + max: Some(3500), + }), + clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, + skip_resume_reclock: false, + extras: super::LimitExtras { + experiments: false, + quirks: vec![ + "clock-autodetect".to_owned(), + ].into_iter().collect() + }, } } @@ -165,6 +191,6 @@ impl GenericCpuLimit { } self.clock_step = limit_override.clock_step; self.skip_resume_reclock = limit_override.skip_resume_reclock; - self.experiments = limit_override.experiments; + self.extras = limit_override.extras; } } diff --git a/backend/limits_core/src/json_v2/gpu_limit.rs b/backend/limits_core/src/json_v2/gpu_limit.rs index f5a326a..d29ae6e 100644 --- a/backend/limits_core/src/json_v2/gpu_limit.rs +++ b/backend/limits_core/src/json_v2/gpu_limit.rs @@ -93,6 +93,7 @@ impl GenericGpuLimit { fn default_steam_deck_oled() -> Self { let mut sd = Self::default_steam_deck(); sd.memory_clock_step = Some(200); + sd.extras.quirks.insert("clock-autodetect".to_owned()); sd } diff --git a/backend/limits_srv/pt_limits_v2.json b/backend/limits_srv/pt_limits_v2.json index a0fc84e..9250956 100644 --- a/backend/limits_srv/pt_limits_v2.json +++ b/backend/limits_srv/pt_limits_v2.json @@ -35,7 +35,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -58,7 +61,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -81,7 +87,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -104,7 +113,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -127,7 +139,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -150,7 +165,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -173,7 +191,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -196,7 +217,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -219,7 +243,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -242,7 +269,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -265,7 +295,10 @@ "tdp_divisor": 1000000, "tdp_step": 1, "skip_resume_reclock": false, - "experiments": true + "extras": { + "experiments": false, + "quirks": [] + } } ], "global_governors": true, @@ -381,7 +414,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -398,7 +434,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -415,7 +454,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -432,7 +474,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -449,7 +494,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -466,7 +514,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -483,7 +534,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -500,7 +554,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } } ], "global_governors": true, @@ -547,8 +604,8 @@ "extras": { "experiments": false, "quirks": [ - "pp_dpm_fclk-reversed", - "pp_dpm_fclk-not-updated-on-LCD" + "pp_dpm_fclk-not-updated-on-LCD", + "pp_dpm_fclk-reversed" ] } } @@ -589,7 +646,7 @@ }, "limits": { "cpu": { - "provider": "GabeBoy", + "provider": "GabeBoySP", "limits": { "cpus": [ { @@ -607,7 +664,12 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [ + "clock-autodetect" + ] + } }, { "clock_min": { @@ -624,7 +686,12 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [ + "clock-autodetect" + ] + } }, { "clock_min": { @@ -641,7 +708,12 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [ + "clock-autodetect" + ] + } }, { "clock_min": { @@ -658,7 +730,12 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [ + "clock-autodetect" + ] + } }, { "clock_min": { @@ -675,7 +752,12 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [ + "clock-autodetect" + ] + } }, { "clock_min": { @@ -692,7 +774,12 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [ + "clock-autodetect" + ] + } }, { "clock_min": { @@ -709,7 +796,12 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [ + "clock-autodetect" + ] + } }, { "clock_min": { @@ -726,7 +818,12 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [ + "clock-autodetect" + ] + } } ], "global_governors": true, @@ -737,7 +834,7 @@ } }, "gpu": { - "provider": "GabeBoy", + "provider": "GabeBoySP", "limits": { "fast_ppt": { "min": 1000000, @@ -773,14 +870,15 @@ "extras": { "experiments": false, "quirks": [ + "pp_dpm_fclk-not-updated-on-LCD", "pp_dpm_fclk-reversed", - "pp_dpm_fclk-not-updated-on-LCD" + "clock-autodetect" ] } } }, "battery": { - "provider": "GabeBoy", + "provider": "GabeBoySP", "limits": { "charge_rate": { "min": 250, @@ -833,7 +931,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -850,7 +951,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -867,7 +971,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -884,7 +991,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } } ], "global_governors": true, @@ -975,7 +1085,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -992,7 +1105,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1009,7 +1125,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1026,7 +1145,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1043,7 +1165,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1060,7 +1185,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1077,7 +1205,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1094,7 +1225,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1111,7 +1245,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1128,7 +1265,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1145,7 +1285,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1162,7 +1305,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } } ], "global_governors": true, @@ -1253,7 +1399,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1270,7 +1419,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1287,7 +1439,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1304,7 +1459,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1321,7 +1479,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1338,7 +1499,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1355,7 +1519,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1372,7 +1539,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1389,7 +1559,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1406,7 +1579,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1423,7 +1599,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1440,7 +1619,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1457,7 +1639,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1474,7 +1659,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1491,7 +1679,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1508,7 +1699,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } } ], "global_governors": true, @@ -1599,7 +1793,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1616,7 +1813,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1633,7 +1833,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1650,7 +1853,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1667,7 +1873,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1684,7 +1893,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1701,7 +1913,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1718,7 +1933,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1735,7 +1953,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1752,7 +1973,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1769,7 +1993,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1786,7 +2013,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1803,7 +2033,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1820,7 +2053,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1837,7 +2073,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1854,7 +2093,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } } ], "global_governors": true, @@ -1945,7 +2187,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1962,7 +2207,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1979,7 +2227,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -1996,7 +2247,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2013,7 +2267,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2030,7 +2287,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2047,7 +2307,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2064,7 +2327,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2081,7 +2347,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2098,7 +2367,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2115,7 +2387,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2132,7 +2407,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2149,7 +2427,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2166,7 +2447,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2183,7 +2467,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": { @@ -2200,7 +2487,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } } ], "global_governors": true, @@ -2279,7 +2569,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": null, @@ -2290,7 +2583,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": null, @@ -2301,7 +2597,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": null, @@ -2312,7 +2611,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": null, @@ -2323,7 +2625,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": null, @@ -2334,7 +2639,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": null, @@ -2345,7 +2653,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } }, { "clock_min": null, @@ -2356,7 +2667,10 @@ "tdp_divisor": null, "tdp_step": null, "skip_resume_reclock": false, - "experiments": false + "extras": { + "experiments": false, + "quirks": [] + } } ], "global_governors": true, diff --git a/backend/src/settings/steam_deck/cpu.rs b/backend/src/settings/steam_deck/cpu.rs index de849fb..0ba44c5 100644 --- a/backend/src/settings/steam_deck/cpu.rs +++ b/backend/src/settings/steam_deck/cpu.rs @@ -102,6 +102,9 @@ impl Cpus { pub fn variant(mut self, model: super::Model) -> Self { self.variant = model; + for cpu in self.cpus.iter_mut() { + cpu.variant(model) + } self } } @@ -125,7 +128,12 @@ impl ProviderBuilder, GenericCpusLimit> for Cpus { } } let new_cpu = if let Some(cpu_limit) = limits.cpus.get(i) { - Cpu::from_json_and_limits(cpu, version, i, cpu_limit.to_owned()) + let mut cpu_limit_clone = cpu_limit.to_owned(); + for item in &limits.extras.quirks { + cpu_limit_clone.extras.quirks.insert(item.to_owned()); + } + cpu_limit_clone.extras.experiments |= limits.extras.experiments; + Cpu::from_json_and_limits(cpu, version, i, cpu_limit_clone) } else { Cpu::from_json(cpu, version, i) }; @@ -262,6 +270,7 @@ pub struct Cpu { index: usize, state: crate::state::steam_deck::Cpu, sysfs: BasicEntityPath, + variant: super::Model, } //const CPU_CLOCK_LIMITS_PATH: &str = "/sys/class/drm/card0/device/pp_od_clk_voltage"; @@ -289,6 +298,7 @@ impl Cpu { index: i, state: crate::state::steam_deck::Cpu::default(), sysfs: Self::find_card_sysfs(other.root), + variant: super::Model::LCD, }, _ => Self { online: other.online, @@ -298,6 +308,7 @@ impl Cpu { index: i, state: crate::state::steam_deck::Cpu::default(), sysfs: Self::find_card_sysfs(other.root), + variant: super::Model::LCD, }, } } @@ -341,6 +352,19 @@ impl Cpu { } } + fn read_max_cpu_clock(&self) -> u64 { + if !(self.limits.extras.experiments || self.limits.extras.quirks.contains("clock-autodetect")) { + return MAX_CLOCK; + } + if let super::Model::OLED = self.variant { + if let Ok(freq_khz) = usdpl_back::api::files::read_single::<_, u64, _>(cpu_max_clock_path(self.index)) { + log::debug!("Detected CPU max clock of {}KHz", freq_khz); + return freq_khz / 1000 + } + } + MAX_CLOCK + } + fn set_clock_limit( &self, index: usize, @@ -591,6 +615,7 @@ impl Cpu { index: cpu_index, state: crate::state::steam_deck::Cpu::default(), sysfs: Self::find_card_sysfs(None::<&'static str>), + variant: super::Model::LCD, } } @@ -602,14 +627,15 @@ impl Cpu { } fn limits(&self) -> crate::api::CpuLimits { + let max_cpu_clock = self.read_max_cpu_clock(); crate::api::CpuLimits { clock_min_limits: Some(RangeLimit { min: range_min_or_fallback(&self.limits.clock_max, MIN_MAX_CLOCK), // allows min to be set by max (it's weird, blame the kernel) - max: range_max_or_fallback(&self.limits.clock_min, MAX_CLOCK), + max: range_max_or_fallback(&self.limits.clock_min, max_cpu_clock), }), clock_max_limits: Some(RangeLimit { min: range_min_or_fallback(&self.limits.clock_max, MIN_MAX_CLOCK), - max: range_max_or_fallback(&self.limits.clock_max, MAX_CLOCK), + max: range_max_or_fallback(&self.limits.clock_max, max_cpu_clock), }), clock_step: self.limits.clock_step.unwrap_or(CLOCK_STEP), governors: self.governors(), @@ -628,6 +654,10 @@ impl Cpu { }; gov_str.split(' ').map(|s| s.to_owned()).collect() } + + pub fn variant(&mut self, model: super::Model) { + self.variant = model; + } } impl Into for Cpu { @@ -714,3 +744,8 @@ fn cpu_available_governors_path(index: usize) -> String { index ) } + +#[inline] +fn cpu_max_clock_path(index: usize) -> String { + format!("/sys/devices/system/cpu/cpufreq/policy{}/cpuinfo_max_freq", index) +} diff --git a/backend/src/settings/steam_deck/gpu.rs b/backend/src/settings/steam_deck/gpu.rs index 562923b..f638f10 100644 --- a/backend/src/settings/steam_deck/gpu.rs +++ b/backend/src/settings/steam_deck/gpu.rs @@ -37,6 +37,7 @@ pub struct Gpu { const GPU_CLOCK_LIMITS_ATTRIBUTE: &str = "device/pp_od_clk_voltage"; const GPU_MEMORY_DOWNCLOCK_ATTRIBUTE: &str = "device/pp_dpm_fclk"; +const GPU_CLOCK_READOUT_ATTRIBUTE: &str = "device/pp_dpm_sclk"; const CARD_EXTENSIONS: &[&'static str] = &[ GPU_CLOCK_LIMITS_ATTRIBUTE, @@ -141,6 +142,29 @@ impl Gpu { }) } + fn read_max_gpu_clock(&self) -> u64 { + if !(self.limits.extras.experiments || self.limits.extras.quirks.contains("clock-autodetect")) { + return MAX_CLOCK; + } + if let super::Model::OLED = self.variant { + if let Ok(f) = self + .sysfs_card + .read_value(GPU_CLOCK_READOUT_ATTRIBUTE.to_owned()) + { + let options = parse_pp_dpm_sclk(&String::from_utf8_lossy(&f)); + return options.get(options.len() - 1) + .map(|x| { + let x = x.1 as u64; + log::debug!("Detected GPU max clock of {}MHz", x); + x + + }) + .unwrap_or(MAX_CLOCK); + } + } + MAX_CLOCK + } + fn is_memory_clock_maxed(&self) -> bool { if let Some(clock) = &self.memory_clock { if let Some(limit) = &self.limits.memory_clock { @@ -611,6 +635,7 @@ impl crate::settings::OnUnload for Gpu { impl TGpu for Gpu { fn limits(&self) -> crate::api::GpuLimits { + let max_gpu_clock = self.read_max_gpu_clock(); crate::api::GpuLimits { fast_ppt_limits: Some(RangeLimit { min: super::util::range_min_or_fallback(&self.limits.fast_ppt, MIN_FAST_PPT) @@ -630,11 +655,11 @@ impl TGpu for Gpu { tdp_step: 42, clock_min_limits: Some(RangeLimit { min: super::util::range_min_or_fallback(&self.limits.clock_min, MIN_CLOCK), - max: super::util::range_max_or_fallback(&self.limits.clock_min, MAX_CLOCK), + max: super::util::range_max_or_fallback(&self.limits.clock_min, max_gpu_clock), }), clock_max_limits: Some(RangeLimit { min: super::util::range_min_or_fallback(&self.limits.clock_max, MIN_CLOCK), - max: super::util::range_max_or_fallback(&self.limits.clock_max, MAX_CLOCK), + max: super::util::range_max_or_fallback(&self.limits.clock_max, max_gpu_clock), }), clock_step: self.limits.clock_step.unwrap_or(100), memory_control: Some(RangeLimit { @@ -693,7 +718,7 @@ impl TGpu for Gpu { } } -fn parse_pp_dpm_fclk(s: &str) -> Vec<(usize, usize)> { +fn parse_sysfs_clk_selector_str(s: &str) -> Vec<(usize, usize)> { // (value, MHz) let mut result = Vec::new(); for line in s.split('\n') { @@ -715,3 +740,13 @@ fn parse_pp_dpm_fclk(s: &str) -> Vec<(usize, usize)> { } result } + +#[inline] +fn parse_pp_dpm_fclk(s: &str) -> Vec<(usize, usize)> { + parse_sysfs_clk_selector_str(s) +} + +#[inline] +fn parse_pp_dpm_sclk(s: &str) -> Vec<(usize, usize)> { + parse_sysfs_clk_selector_str(s) +} diff --git a/package.json b/package.json index 04f659b..46ce370 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "2.0.0-alpha2", + "version": "2.0.0-alpha3", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c",