Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
9ad63a508b | |||
f5303d077a | |||
cc26a2a91f | |||
b28ac638c3 | |||
cb2fd1dcc7 | |||
ec02a65571 | |||
f6bc49bb3b |
35 changed files with 1314 additions and 57 deletions
28
README.md
28
README.md
|
@ -1,12 +1,12 @@
|
||||||
# PowerTools
|
# PowerTools
|
||||||
<!-- TODO Update badges for new git repo location -->
|
<!-- TODO Update badges for new git repo location -->
|
||||||
[![Decky store](https://img.shields.io/badge/dynamic/json?color=blue&label=release&query=%24%5B%3F%28%40.name%3D%3D%27PowerTools%27%29%5D.versions%5B0%5D.name&url=https%3A%2F%2Fplugins.deckbrew.xyz%2Fplugins&style=flat-square)](https://plugins.deckbrew.xyz/)
|
[![Decky store](https://img.shields.io/badge/dynamic/json?color=blue&label=release&query=%24%5B%3F%28%40.name%3D%3D%27PowerTools%27%29%5D.versions%5B0%5D.name&url=https%3A%2F%2Fplugins.deckbrew.xyz%2Fplugins&style=flat-square)](https://plugins.deckbrew.xyz/)
|
||||||
[![Custom store](https://img.shields.io/badge/dynamic/json?color=blue&label=preview&query=%24%5B%3F%28%40.name%3D%3D%27PowerTools%27%29%5D.versions%5B0%5D.name&url=https%3A%2F%2Fnot-decky-alpha.ngni.us%2Fplugins&style=flat-square)](https://github.com/NGnius/PowerTools/wiki)
|
[![Custom store](https://img.shields.io/badge/dynamic/json?color=blue&label=preview&query=%24%5B%3F%28%40.name%3D%3D%27PowerTools%27%29%5D.versions%5B0%5D.name&url=https%3A%2F%2Fnot-decky-alpha.ngni.us%2Fplugins&style=flat-square)](https://git.ngni.us/NG-SD-Plugins/PowerTools/wiki)
|
||||||
[![GitHub package.json version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.ngni.us%2FNG-SD-Plugins%2FPowerTools%2Fraw%2Fbranch%2Fmain%2Fpackage.json&query=%24.version&style=flat-square&label=local&cacheSeconds=600)](https://git.ngni.us/NG-SD-Plugins/PowerTools/src/branch/main/package.json)
|
[![GitHub package.json version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.ngni.us%2FNG-SD-Plugins%2FPowerTools%2Fraw%2Fbranch%2Fmain%2Fpackage.json&query=%24.version&style=flat-square&label=local&cacheSeconds=600)](https://git.ngni.us/NG-SD-Plugins/PowerTools/src/branch/main/package.json)
|
||||||
|
|
||||||
[![Liberapay](https://img.shields.io/liberapay/patrons/NGnius?style=flat-square)](https://liberapay.com/NGnius)
|
[![Liberapay](https://img.shields.io/liberapay/patrons/NGnius?style=flat-square)](https://liberapay.com/NGnius)
|
||||||
[![GitHub](https://img.shields.io/badge/GPL--3.0-orange?style=flat-square&label=license&cacheSeconds=600)](https://github.com/NGnius/PowerTools/blob/main/LICENSE)
|
[![GitHub](https://img.shields.io/badge/GPL--3.0-orange?style=flat-square&label=license&cacheSeconds=600)](https://git.ngni.us/NG-SD-Plugins/PowerTools/blob/main/LICENSE)
|
||||||
[![GitHub package.json dependency version (local)](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.ngni.us%2FNG-SD-Plugins%2FPowerTools%2Fraw%2Fbranch%2Fmain%2Fpackage.json&query=%24..%5B'decky-frontend-lib'%5D&style=flat-square&label=decky-frontend-lib&cacheSeconds=600)](https://github.com/NGnius/PowerTools/blob/main/pnpm-lock.yaml)
|
[![GitHub package.json dependency version (local)](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgit.ngni.us%2FNG-SD-Plugins%2FPowerTools%2Fraw%2Fbranch%2Fmain%2Fpackage.json&query=%24..%5B'decky-frontend-lib'%5D&style=flat-square&label=decky-frontend-lib&cacheSeconds=600)](https://git.ngni.us/NG-SD-Plugins/PowerTools/blob/main/pnpm-lock.yaml)
|
||||||
|
|
||||||
![plugin_demo](./assets/ui.png)
|
![plugin_demo](./assets/ui.png)
|
||||||
|
|
||||||
|
@ -20,24 +20,38 @@ You will need that installed for this plugin to work.
|
||||||
- Enable & disable CPU threads & SMT
|
- Enable & disable CPU threads & SMT
|
||||||
- Set CPU frequencies
|
- Set CPU frequencies
|
||||||
- Set GPU frequencies and power (fastPPT & slowPPT)
|
- Set GPU frequencies and power (fastPPT & slowPPT)
|
||||||
- Cap battery charge rate (when awake)
|
- Cap battery charge level
|
||||||
- Display supplementary battery info
|
- Display supplementary battery info
|
||||||
- Keep settings between restarts (stored in `~/.config/powertools/<gameId>.json`)
|
- Keep settings between restarts (stored in `~/homebrew/settings/PowerTools/<appId>.ron`)
|
||||||
|
|
||||||
This plugin is tested on Steam Deck, but is designed to work on other Linux devices as well. Unfortunately I am currently unable to test on other devices.
|
This plugin is tested on Steam Deck LCD/OLED, but is designed to work on other Linux devices as well. Unfortunately I am currently unable to test on most other devices.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Please use Decky's [built-in store](https://plugins.deckbrew.xyz/) to install official releases.
|
Please use Decky's [built-in store](https://plugins.deckbrew.xyz/) to install official releases.
|
||||||
If you want to test unstable versions, use [my custom store](https://not-decky-alpha.ngni.us/plugins). If you would like to use an in-development version, feel free to build PowerTools yourself.
|
If you want to test unstable versions, use [my custom store](https://not-decky-alpha.ngni.us/plugins). If you would like to use an in-development version, feel free to build PowerTools yourself.
|
||||||
|
|
||||||
## Build
|
## Build/Deploy
|
||||||
|
|
||||||
0. Requirements: a functioning Rust toolchain for x86_64-unknown-linux-gnu (or -musl), pnpm, and some tech literacy
|
0. Requirements: a functioning Rust toolchain for x86_64-unknown-linux-gnu (or -musl), pnpm, and some tech literacy
|
||||||
1. In a terminal, navigate to the backend directory of this project and run `./build.sh`
|
1. In a terminal, navigate to the backend directory of this project and run `./build.sh`
|
||||||
2. In the root of this project, run `pnpm run build`
|
2. In the root of this project, run `pnpm run build`
|
||||||
3. Transfer the project (especially dist/ and bin/) to a folder in your Steam Deck's `~/homebrew/plugins` directory
|
3. Transfer the project (especially dist/ and bin/) to a folder in your Steam Deck's `~/homebrew/plugins` directory
|
||||||
|
4. Restart Decky with `sudo systemctl restart plugin_loader.service`
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This is licensed under GNU GPLv3.
|
This is licensed under GNU GPLv3.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
All contributions are welcome!
|
||||||
|
Anything from a comment on an issue to a new feature pull request will be appreciated by PowerTools's crack team of one (NGnius).
|
||||||
|
|
||||||
|
### Translations
|
||||||
|
|
||||||
|
Adding new languages and keeping existing language files up to date makes PowerTools more accessible to the majority of the world which doesn't speak English. Take a look at [this comment](https://git.ngni.us/NG-SD-Plugins/PowerTools/issues/9#issuecomment-345) (and the rest of that issue) to get started.
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
To prevent spam, this server does not allow regular users to create/fork repositories. Please open an issue [here](https://git.ngni.us/sys/website) to request permission. There's no pressure to actually do anything with that permission, though it may be revoked when the server is running low on space.
|
||||||
|
|
63
backend/Cargo.lock
generated
63
backend/Cargo.lock
generated
|
@ -201,7 +201,7 @@ version = "0.66.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags 2.4.1",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
@ -218,6 +218,18 @@ dependencies = [
|
||||||
"which",
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bit_field"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.4.1"
|
version = "2.4.1"
|
||||||
|
@ -915,7 +927,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limits_core"
|
name = "limits_core"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -1162,6 +1174,13 @@ dependencies = [
|
||||||
"universal-hash",
|
"universal-hash",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "powerbox"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"sysfuss 0.4.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "powerfmt"
|
name = "powerfmt"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -1180,13 +1199,14 @@ dependencies = [
|
||||||
"libryzenadj",
|
"libryzenadj",
|
||||||
"limits_core",
|
"limits_core",
|
||||||
"log",
|
"log",
|
||||||
|
"procbox",
|
||||||
"regex",
|
"regex",
|
||||||
"ron",
|
"ron",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"simplelog",
|
"simplelog",
|
||||||
"smokepatio",
|
"smokepatio",
|
||||||
"sysfuss",
|
"sysfuss 0.3.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"ureq",
|
"ureq",
|
||||||
"usdpl-back",
|
"usdpl-back",
|
||||||
|
@ -1227,6 +1247,15 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "procbox"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"powerbox",
|
||||||
|
"sysfuss 0.4.0",
|
||||||
|
"x86",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.33"
|
version = "1.0.33"
|
||||||
|
@ -1266,6 +1295,15 @@ dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "raw-cpuid"
|
||||||
|
version = "10.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.10.2"
|
version = "1.10.2"
|
||||||
|
@ -1316,7 +1354,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.21.5",
|
"base64 0.21.5",
|
||||||
"bitflags",
|
"bitflags 2.4.1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
@ -1339,7 +1377,7 @@ version = "0.38.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
|
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags 2.4.1",
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys",
|
"linux-raw-sys",
|
||||||
|
@ -1542,6 +1580,10 @@ version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f33bae529511a671b5f2ed4cc46ae0b2ccdf8c03ccf7eebe95a5a886ff7914dc"
|
checksum = "f33bae529511a671b5f2ed4cc46ae0b2ccdf8c03ccf7eebe95a5a886ff7914dc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sysfuss"
|
||||||
|
version = "0.4.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termcolor"
|
name = "termcolor"
|
||||||
version = "1.1.3"
|
version = "1.1.3"
|
||||||
|
@ -2166,6 +2208,17 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "x86"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385"
|
||||||
|
dependencies = [
|
||||||
|
"bit_field",
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"raw-cpuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zeroize"
|
name = "zeroize"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
|
|
|
@ -17,6 +17,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
ron = "0.8"
|
ron = "0.8"
|
||||||
sysfuss = { version = "0.3", features = ["derive"] }#,path = "../../sysfs-nav"}
|
sysfuss = { version = "0.3", features = ["derive"] }#,path = "../../sysfs-nav"}
|
||||||
|
procbox = { version = "0.1", path = "../../powerbox/crates/procbox" }
|
||||||
|
|
||||||
# async
|
# async
|
||||||
tokio = { version = "*", features = ["time"] }
|
tokio = { version = "*", features = ["time"] }
|
||||||
|
|
2
backend/limits_core/Cargo.lock
generated
2
backend/limits_core/Cargo.lock
generated
|
@ -4,7 +4,7 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limits_core"
|
name = "limits_core"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "limits_core"
|
name = "limits_core"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -9,6 +9,8 @@ pub enum CpuLimitType {
|
||||||
SteamDeck,
|
SteamDeck,
|
||||||
#[serde(rename = "GabeBoySP", alias = "SteamDeckOLED")]
|
#[serde(rename = "GabeBoySP", alias = "SteamDeckOLED")]
|
||||||
SteamDeckOLED,
|
SteamDeckOLED,
|
||||||
|
ROGAlly,
|
||||||
|
MSIClaw,
|
||||||
Generic,
|
Generic,
|
||||||
GenericAMD,
|
GenericAMD,
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|
|
@ -8,6 +8,8 @@ pub enum GpuLimitType {
|
||||||
SteamDeck,
|
SteamDeck,
|
||||||
#[serde(rename = "GabeBoySP", alias = "SteamDeckOLED")]
|
#[serde(rename = "GabeBoySP", alias = "SteamDeckOLED")]
|
||||||
SteamDeckOLED,
|
SteamDeckOLED,
|
||||||
|
ROGAlly,
|
||||||
|
MSIClaw,
|
||||||
Generic,
|
Generic,
|
||||||
GenericAMD,
|
GenericAMD,
|
||||||
Unknown,
|
Unknown,
|
||||||
|
@ -83,8 +85,7 @@ impl GenericGpuLimit {
|
||||||
experiments: false,
|
experiments: false,
|
||||||
quirks: vec![
|
quirks: vec![
|
||||||
"pp_dpm_fclk-reversed".to_owned(),
|
"pp_dpm_fclk-reversed".to_owned(),
|
||||||
"pp_dpm_fclk-not-updated-on-LCD".to_owned(),
|
"pp_dpm_fclk-static".to_owned(),
|
||||||
//"pp_dpm_fclk-static".to_owned(),
|
|
||||||
].into_iter().collect(),
|
].into_iter().collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +95,8 @@ impl GenericGpuLimit {
|
||||||
let mut sd = Self::default_steam_deck();
|
let mut sd = Self::default_steam_deck();
|
||||||
sd.memory_clock_step = Some(200);
|
sd.memory_clock_step = Some(200);
|
||||||
sd.extras.quirks.insert("clock-autodetect".to_owned());
|
sd.extras.quirks.insert("clock-autodetect".to_owned());
|
||||||
|
sd.extras.quirks.remove("pp_dpm_fclk-static");
|
||||||
|
//sd.extras.quirks.remove("pp_dpm_fclk-reversed");
|
||||||
sd
|
sd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
236
backend/limits_srv/Cargo.lock
generated
236
backend/limits_srv/Cargo.lock
generated
|
@ -32,6 +32,55 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstream"
|
||||||
|
version = "0.6.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"anstyle-parse",
|
||||||
|
"anstyle-query",
|
||||||
|
"anstyle-wincon",
|
||||||
|
"colorchoice",
|
||||||
|
"is_terminal_polyfill",
|
||||||
|
"utf8parse",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle"
|
||||||
|
version = "1.0.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-parse"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
|
||||||
|
dependencies = [
|
||||||
|
"utf8parse",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-query"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-wincon"
|
||||||
|
version = "3.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -71,6 +120,15 @@ version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
version = "0.10.4"
|
version = "0.10.4"
|
||||||
|
@ -125,6 +183,51 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "4.4.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c"
|
||||||
|
dependencies = [
|
||||||
|
"clap_builder",
|
||||||
|
"clap_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_builder"
|
||||||
|
version = "4.4.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7"
|
||||||
|
dependencies = [
|
||||||
|
"anstream",
|
||||||
|
"anstyle",
|
||||||
|
"clap_lex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_derive"
|
||||||
|
version = "4.4.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colorchoice"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation-sys"
|
name = "core-foundation-sys"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
|
@ -285,7 +388,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584"
|
checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.13.1",
|
"base64 0.13.1",
|
||||||
"bitflags",
|
"bitflags 1.3.2",
|
||||||
"bytes",
|
"bytes",
|
||||||
"headers-core",
|
"headers-core",
|
||||||
"http",
|
"http",
|
||||||
|
@ -303,6 +406,12 @@ dependencies = [
|
||||||
"http",
|
"http",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
@ -410,6 +519,12 @@ dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is_terminal_polyfill"
|
||||||
|
version = "1.70.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.8"
|
version = "1.0.8"
|
||||||
|
@ -433,17 +548,19 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limits_core"
|
name = "limits_core"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limits_srv"
|
name = "limits_srv"
|
||||||
version = "3.0.0"
|
version = "3.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"clap",
|
||||||
"limits_core",
|
"limits_core",
|
||||||
|
"ron",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
@ -495,7 +612,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -642,6 +759,18 @@ dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ron"
|
||||||
|
version = "0.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.21.2",
|
||||||
|
"bitflags 2.6.0",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.23"
|
version = "0.1.23"
|
||||||
|
@ -820,7 +949,7 @@ dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -976,6 +1105,12 @@ version = "0.7.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utf8parse"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
@ -1116,7 +1251,7 @@ version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
|
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.48.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1125,7 +1260,16 @@ version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.48.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1134,13 +1278,29 @@ version = "0.48.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
|
checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm 0.48.0",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc 0.48.0",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu 0.48.0",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc 0.48.0",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu 0.48.0",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm 0.48.0",
|
||||||
"windows_x86_64_msvc",
|
"windows_x86_64_msvc 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm 0.52.6",
|
||||||
|
"windows_aarch64_msvc 0.52.6",
|
||||||
|
"windows_i686_gnu 0.52.6",
|
||||||
|
"windows_i686_gnullvm",
|
||||||
|
"windows_i686_msvc 0.52.6",
|
||||||
|
"windows_x86_64_gnu 0.52.6",
|
||||||
|
"windows_x86_64_gnullvm 0.52.6",
|
||||||
|
"windows_x86_64_msvc 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1149,38 +1309,86 @@ version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "limits_srv"
|
name = "limits_srv"
|
||||||
version = "3.0.0"
|
version = "3.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -10,5 +10,7 @@ limits_core = { version = "3.0.0", path = "../limits_core" }
|
||||||
chrono = { version = "0.4" }
|
chrono = { version = "0.4" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
ron = "0.8"
|
||||||
warp = { version = "0.3" }
|
warp = { version = "0.3" }
|
||||||
tokio = { version = "1.22", features = ["macros", "rt", "rt-multi-thread"] }
|
tokio = { version = "1.22", features = ["macros", "rt", "rt-multi-thread"] }
|
||||||
|
clap = { version = "4", features = ["derive", "std", "color"], default-features = false }
|
||||||
|
|
|
@ -603,7 +603,7 @@
|
||||||
"experiments": false,
|
"experiments": false,
|
||||||
"quirks": [
|
"quirks": [
|
||||||
"pp_dpm_fclk-reversed",
|
"pp_dpm_fclk-reversed",
|
||||||
"pp_dpm_fclk-not-updated-on-LCD"
|
"pp_dpm_fclk-static"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -867,9 +867,8 @@
|
||||||
"extras": {
|
"extras": {
|
||||||
"experiments": false,
|
"experiments": false,
|
||||||
"quirks": [
|
"quirks": [
|
||||||
"pp_dpm_fclk-reversed",
|
"clock-autodetect",
|
||||||
"pp_dpm_fclk-not-updated-on-LCD",
|
"pp_dpm_fclk-reversed"
|
||||||
"clock-autodetect"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
19
backend/limits_srv/src/cli.rs
Normal file
19
backend/limits_srv/src/cli.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
#[derive(Parser, Debug, Clone)]
|
||||||
|
#[command(author, version, about, long_about = None)]
|
||||||
|
pub struct Cli {
|
||||||
|
/// Path to folder containing pt_limits.json and pt_limits_v2.json
|
||||||
|
#[arg(short, long, default_value = "./")]
|
||||||
|
pub limits: std::path::PathBuf,
|
||||||
|
|
||||||
|
/// Server port
|
||||||
|
#[arg(short, long, default_value_t = 8080)]
|
||||||
|
pub port: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cli {
|
||||||
|
pub fn get() -> Self {
|
||||||
|
Self::parse()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
mod cli;
|
||||||
|
|
||||||
use std::sync::atomic::{Ordering, AtomicU64, AtomicI64};
|
use std::sync::atomic::{Ordering, AtomicU64, AtomicI64};
|
||||||
use std::sync::{RwLock, Arc};
|
use std::sync::{RwLock, Arc};
|
||||||
|
|
||||||
|
@ -73,26 +75,35 @@ pub async fn recovery(reject: warp::Rejection) -> Result<impl warp::Reply, warp:
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
START_TIME.store(chrono::Utc::now().timestamp(), Ordering::Relaxed);
|
START_TIME.store(chrono::Utc::now().timestamp(), Ordering::Relaxed);
|
||||||
let file = std::fs::File::open("./pt_limits.json").expect("Failed to read limits file");
|
let args = cli::Cli::get();
|
||||||
|
let file = std::fs::File::open(args.limits.join("pt_limits.json")).expect("Failed to read limits file");
|
||||||
let limits: limits_core::json::Base = serde_json::from_reader(file).expect("Failed to parse limits file");
|
let limits: limits_core::json::Base = serde_json::from_reader(file).expect("Failed to parse limits file");
|
||||||
assert!(limits.refresh.is_some(), "`refresh` cannot be null, since it will brick future refreshes");
|
assert!(limits.refresh.is_some(), "`refresh` cannot be null, since it will brick future refreshes");
|
||||||
|
|
||||||
let file = std::fs::File::open("./pt_limits_v2.json").expect("Failed to read limits file");
|
let file = std::fs::File::open(args.limits.join("pt_limits_v2.json")).expect("Failed to read limits_v2 file");
|
||||||
let limits_v2: limits_core::json_v2::Base = serde_json::from_reader(file).expect("Failed to parse limits file");
|
let limits_v2: limits_core::json_v2::Base = serde_json::from_reader(file).expect("Failed to parse limits file");
|
||||||
assert!(limits_v2.refresh.is_some(), "`refresh` cannot be null, since it will brick future refreshes");
|
assert!(limits_v2.refresh.is_some(), "`refresh` cannot be null, since it will brick future refreshes");
|
||||||
|
|
||||||
warp::serve(routes(Arc::new(RwLock::new(limits)), Arc::new(RwLock::new(limits_v2))))
|
warp::serve(routes(Arc::new(RwLock::new(limits)), Arc::new(RwLock::new(limits_v2))))
|
||||||
.run(([0, 0, 0, 0], 8080))
|
.run(([0, 0, 0, 0], args.port))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
fn ron_pretty_config() -> ron::ser::PrettyConfig {
|
||||||
|
ron::ser::PrettyConfig::default()
|
||||||
|
.struct_names(true)
|
||||||
|
.compact_arrays(true)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn generate_default_pt_limits() {
|
fn generate_default_pt_limits() {
|
||||||
let limits = limits_core::json::Base::default();
|
let limits = limits_core::json::Base::default();
|
||||||
let output_file = std::fs::File::create("./pt_limits.json").unwrap();
|
let output_file = std::fs::File::create("./pt_limits.json").unwrap();
|
||||||
serde_json::to_writer_pretty(output_file, &limits).unwrap();
|
serde_json::to_writer_pretty(output_file, &limits).unwrap();
|
||||||
|
let output_file = std::fs::File::create("./pt_limits.ron").unwrap();
|
||||||
|
ron::ser::to_writer_pretty(output_file, &limits, ron_pretty_config()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -100,5 +111,7 @@ mod test {
|
||||||
let limits = limits_core::json_v2::Base::default();
|
let limits = limits_core::json_v2::Base::default();
|
||||||
let output_file = std::fs::File::create("./pt_limits_v2.json").unwrap();
|
let output_file = std::fs::File::create("./pt_limits_v2.json").unwrap();
|
||||||
serde_json::to_writer_pretty(output_file, &limits).unwrap();
|
serde_json::to_writer_pretty(output_file, &limits).unwrap();
|
||||||
|
let output_file = std::fs::File::create("./pt_limits_v2.ron").unwrap();
|
||||||
|
ron::ser::to_writer_pretty(output_file, &limits, ron_pretty_config()).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,10 @@ pub enum DriverJson {
|
||||||
Generic,
|
Generic,
|
||||||
#[serde(rename = "generic-amd")]
|
#[serde(rename = "generic-amd")]
|
||||||
GenericAMD,
|
GenericAMD,
|
||||||
|
#[serde(rename = "rog-ally")]
|
||||||
|
ROGAlly,
|
||||||
|
#[serde(rename = "msi-claw")]
|
||||||
|
MSIClaw,
|
||||||
#[serde(rename = "unknown")]
|
#[serde(rename = "unknown")]
|
||||||
Unknown,
|
Unknown,
|
||||||
#[default]
|
#[default]
|
||||||
|
|
|
@ -138,6 +138,20 @@ pub fn auto_detect0(
|
||||||
)
|
)
|
||||||
.variant(super::super::steam_deck::Model::OLED),
|
.variant(super::super::steam_deck::Model::OLED),
|
||||||
),
|
),
|
||||||
|
CpuLimitType::ROGAlly => Box::new(
|
||||||
|
crate::settings::rog_ally::Cpus::from_json_and_limits(
|
||||||
|
settings.cpus.clone(),
|
||||||
|
settings.version,
|
||||||
|
relevant_limits.cpu.limits,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
CpuLimitType::MSIClaw => Box::new(
|
||||||
|
crate::settings::msi_claw::Cpus::from_json_and_limits(
|
||||||
|
settings.cpus.clone(),
|
||||||
|
settings.version,
|
||||||
|
relevant_limits.cpu.limits,
|
||||||
|
)
|
||||||
|
),
|
||||||
CpuLimitType::Generic => Box::new(crate::settings::generic::Cpus::<
|
CpuLimitType::Generic => Box::new(crate::settings::generic::Cpus::<
|
||||||
crate::settings::generic::Cpu,
|
crate::settings::generic::Cpu,
|
||||||
>::from_json_and_limits(
|
>::from_json_and_limits(
|
||||||
|
@ -185,6 +199,20 @@ pub fn auto_detect0(
|
||||||
)
|
)
|
||||||
.variant(super::super::steam_deck::Model::OLED),
|
.variant(super::super::steam_deck::Model::OLED),
|
||||||
),
|
),
|
||||||
|
GpuLimitType::ROGAlly => Box::new(
|
||||||
|
crate::settings::rog_ally::Gpu::from_json_and_limits(
|
||||||
|
settings.gpu.clone(),
|
||||||
|
settings.version,
|
||||||
|
relevant_limits.gpu.limits,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
GpuLimitType::MSIClaw => Box::new(
|
||||||
|
crate::settings::msi_claw::Gpu::from_json_and_limits(
|
||||||
|
settings.gpu.clone(),
|
||||||
|
settings.version,
|
||||||
|
relevant_limits.gpu.limits,
|
||||||
|
)
|
||||||
|
),
|
||||||
GpuLimitType::Generic => {
|
GpuLimitType::Generic => {
|
||||||
Box::new(crate::settings::generic::Gpu::from_json_and_limits(
|
Box::new(crate::settings::generic::Gpu::from_json_and_limits(
|
||||||
settings.gpu.clone(),
|
settings.gpu.clone(),
|
||||||
|
@ -270,6 +298,12 @@ pub fn auto_detect0(
|
||||||
crate::settings::steam_deck::Cpus::from_limits(relevant_limits.cpu.limits)
|
crate::settings::steam_deck::Cpus::from_limits(relevant_limits.cpu.limits)
|
||||||
.variant(super::super::steam_deck::Model::OLED),
|
.variant(super::super::steam_deck::Model::OLED),
|
||||||
),
|
),
|
||||||
|
CpuLimitType::ROGAlly => Box::new(
|
||||||
|
crate::settings::rog_ally::Cpus::from_limits(relevant_limits.cpu.limits)
|
||||||
|
),
|
||||||
|
CpuLimitType::MSIClaw => Box::new(
|
||||||
|
crate::settings::msi_claw::Cpus::from_limits(relevant_limits.cpu.limits)
|
||||||
|
),
|
||||||
CpuLimitType::Generic => Box::new(crate::settings::generic::Cpus::<
|
CpuLimitType::Generic => Box::new(crate::settings::generic::Cpus::<
|
||||||
crate::settings::generic::Cpu,
|
crate::settings::generic::Cpu,
|
||||||
>::from_limits(
|
>::from_limits(
|
||||||
|
@ -294,6 +328,12 @@ pub fn auto_detect0(
|
||||||
crate::settings::steam_deck::Gpu::from_limits(relevant_limits.gpu.limits)
|
crate::settings::steam_deck::Gpu::from_limits(relevant_limits.gpu.limits)
|
||||||
.variant(super::super::steam_deck::Model::OLED),
|
.variant(super::super::steam_deck::Model::OLED),
|
||||||
),
|
),
|
||||||
|
GpuLimitType::ROGAlly => Box::new(
|
||||||
|
crate::settings::rog_ally::Gpu::from_limits(relevant_limits.gpu.limits)
|
||||||
|
),
|
||||||
|
GpuLimitType::MSIClaw => Box::new(
|
||||||
|
crate::settings::msi_claw::Gpu::from_limits(relevant_limits.gpu.limits)
|
||||||
|
),
|
||||||
GpuLimitType::Generic => Box::new(crate::settings::generic::Gpu::from_limits(
|
GpuLimitType::Generic => Box::new(crate::settings::generic::Gpu::from_limits(
|
||||||
relevant_limits.gpu.limits,
|
relevant_limits.gpu.limits,
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -272,11 +272,11 @@ impl TCpu for Cpu {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"dev_mode_Cpu::get_clock_limits(self) -> {:?}",
|
"dev_mode_Cpu::get_clock_limits(self) -> {:?}",
|
||||||
self.clock_limits.as_ref()
|
self.clock_limits.as_ref()
|
||||||
);
|
);
|
||||||
self.clock_limits.as_ref()
|
self.clock_limits.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,12 +188,12 @@ impl TGpu for Gpu {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"dev_mode_Gpu::get_clock_limits(self) -> {:?}",
|
"dev_mode_Gpu::get_clock_limits(self) -> {:?}",
|
||||||
self.clock_limits.as_ref()
|
self.clock_limits.as_ref()
|
||||||
);
|
);
|
||||||
self.clock_limits.as_ref()
|
self.clock_limits.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn memory_clock(&mut self, speed: Option<u64>) {
|
fn memory_clock(&mut self, speed: Option<u64>) {
|
||||||
|
|
|
@ -37,7 +37,9 @@ pub fn maybe_do_button() {
|
||||||
match super::auto_detect_provider() {
|
match super::auto_detect_provider() {
|
||||||
DriverJson::SteamDeck | DriverJson::SteamDeckOLED => {
|
DriverJson::SteamDeck | DriverJson::SteamDeckOLED => {
|
||||||
crate::settings::steam_deck::flash_led();
|
crate::settings::steam_deck::flash_led();
|
||||||
}
|
},
|
||||||
|
DriverJson::ROGAlly => log::info!("Roggle boggle smoggle flollop"),
|
||||||
|
DriverJson::MSIClaw => log::warn!("My condolences"),
|
||||||
DriverJson::Generic | DriverJson::GenericAMD => {
|
DriverJson::Generic | DriverJson::GenericAMD => {
|
||||||
log::warn!("You need to come up with something fun on generic")
|
log::warn!("You need to come up with something fun on generic")
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,8 +441,8 @@ impl TCpu for Cpu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
self.clock_limits.as_ref()
|
self.clock_limits.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -303,8 +303,8 @@ impl TGpu for Gpu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
self.clock_limits.as_ref()
|
self.clock_limits.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn memory_clock(&mut self, _speed: Option<u64>) {}
|
fn memory_clock(&mut self, _speed: Option<u64>) {}
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl TCpu for Cpu {
|
||||||
// TODO: support this
|
// TODO: support this
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
self.generic.get_clock_limits()
|
self.generic.get_clock_limits()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,7 +368,7 @@ impl TGpu for Gpu {
|
||||||
self.generic.clock_limits(limits)
|
self.generic.clock_limits(limits)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
self.generic.get_clock_limits()
|
self.generic.get_clock_limits()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ pub mod generic;
|
||||||
pub mod generic_amd;
|
pub mod generic_amd;
|
||||||
pub mod steam_deck;
|
pub mod steam_deck;
|
||||||
pub mod unknown;
|
pub mod unknown;
|
||||||
|
pub mod rog_ally;
|
||||||
|
pub mod msi_claw;
|
||||||
|
|
||||||
pub use detect::{
|
pub use detect::{
|
||||||
auto_detect0, auto_detect_provider, get_dev_messages,
|
auto_detect0, auto_detect_provider, get_dev_messages,
|
||||||
|
|
155
backend/src/settings/msi_claw/cpu.rs
Normal file
155
backend/src/settings/msi_claw/cpu.rs
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
use crate::persist::CpuJson;
|
||||||
|
use crate::settings::generic::{Cpu as GenericCpu, Cpus as GenericCpus, FromGenericCpuInfo};
|
||||||
|
use crate::settings::MinMax;
|
||||||
|
use crate::settings::{OnResume, OnSet, SettingError};
|
||||||
|
use crate::settings::{ProviderBuilder, TCpu, TCpus};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Cpus {
|
||||||
|
generic: GenericCpus<Cpu>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProviderBuilder<Vec<CpuJson>, limits_core::json_v2::GenericCpusLimit> for Cpus {
|
||||||
|
fn from_limits(limits: limits_core::json_v2::GenericCpusLimit) -> Self {
|
||||||
|
Self {
|
||||||
|
generic: GenericCpus::from_limits(limits),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_json_and_limits(
|
||||||
|
other: Vec<CpuJson>,
|
||||||
|
version: u64,
|
||||||
|
limits: limits_core::json_v2::GenericCpusLimit,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
generic: GenericCpus::from_json_and_limits(other, version, limits),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnResume for Cpus {
|
||||||
|
fn on_resume(&self) -> Result<(), Vec<SettingError>> {
|
||||||
|
self.generic.on_resume()
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnSet for Cpus {
|
||||||
|
fn on_set(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
self.generic.on_set()
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnPowerEvent for Cpus {}
|
||||||
|
|
||||||
|
impl crate::settings::OnLoad for Cpus {
|
||||||
|
fn on_load(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnUnload for Cpus {
|
||||||
|
fn on_unload(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TCpus for Cpus {
|
||||||
|
fn limits(&self) -> crate::api::CpusLimits {
|
||||||
|
self.generic.limits()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn json(&self) -> Vec<crate::persist::CpuJson> {
|
||||||
|
self.generic.json() // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cpus(&mut self) -> Vec<&mut dyn TCpu> {
|
||||||
|
self.generic.cpus() // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
fn len(&self) -> usize {
|
||||||
|
self.generic.len() // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
fn smt(&mut self) -> &'_ mut bool {
|
||||||
|
self.generic.smt()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn provider(&self) -> crate::persist::DriverJson {
|
||||||
|
crate::persist::DriverJson::GenericAMD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Cpu {
|
||||||
|
generic: GenericCpu,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromGenericCpuInfo for Cpu {
|
||||||
|
fn from_limits(cpu_index: usize, limits: limits_core::json_v2::GenericCpuLimit) -> Self {
|
||||||
|
let gen = GenericCpu::from_limits(cpu_index, limits.clone());
|
||||||
|
Self { generic: gen }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_json_and_limits(
|
||||||
|
other: CpuJson,
|
||||||
|
version: u64,
|
||||||
|
cpu_index: usize,
|
||||||
|
limits: limits_core::json_v2::GenericCpuLimit,
|
||||||
|
) -> Self {
|
||||||
|
let gen = GenericCpu::from_json_and_limits(other, version, cpu_index, limits);
|
||||||
|
Self { generic: gen }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsRef<GenericCpu> for Cpu {
|
||||||
|
fn as_ref(&self) -> &GenericCpu {
|
||||||
|
&self.generic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsMut<GenericCpu> for Cpu {
|
||||||
|
fn as_mut(&mut self) -> &mut GenericCpu {
|
||||||
|
&mut self.generic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnResume for Cpu {
|
||||||
|
fn on_resume(&self) -> Result<(), Vec<SettingError>> {
|
||||||
|
self.generic.on_resume()
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnSet for Cpu {
|
||||||
|
fn on_set(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
self.generic.on_set()
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnPowerEvent for Cpu {}
|
||||||
|
|
||||||
|
impl TCpu for Cpu {
|
||||||
|
fn online(&mut self) -> &mut bool {
|
||||||
|
self.generic.online()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn governor(&mut self, governor: String) {
|
||||||
|
self.generic.governor(governor)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_governor(&self) -> &'_ str {
|
||||||
|
self.generic.get_governor()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clock_limits(&mut self, _limits: Option<MinMax<u64>>) {
|
||||||
|
//self.generic.clock_limits(limits)
|
||||||
|
// TODO: support this
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
|
self.generic.get_clock_limits()
|
||||||
|
}
|
||||||
|
}
|
287
backend/src/settings/msi_claw/gpu.rs
Normal file
287
backend/src/settings/msi_claw/gpu.rs
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
use limits_core::json_v2::GenericGpuLimit;
|
||||||
|
//use sysfuss::{capability::attributes, BasicEntityPath, SysEntity};
|
||||||
|
//use procbox::gpu::IntelGpu; // TODO
|
||||||
|
|
||||||
|
use crate::api::RangeLimit;
|
||||||
|
use crate::persist::{GpuJson, MinMaxJson};
|
||||||
|
use crate::settings::{min_max_from_json, MinMax};
|
||||||
|
use crate::settings::{OnResume, OnSet, SettingError};
|
||||||
|
use crate::settings::{ProviderBuilder, TGpu};
|
||||||
|
|
||||||
|
//#[derive(Clone)]
|
||||||
|
pub struct Gpu {
|
||||||
|
//gpu_impl: IntelGpu,
|
||||||
|
settings: GpuJson,
|
||||||
|
limits: GenericGpuLimit,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Gpu {
|
||||||
|
/*fn find_badgpu(root: Option<impl AsRef<std::path::Path>>) -> IntelGpu {
|
||||||
|
let root = crate::settings::util::root_or_default_sysfs(root);
|
||||||
|
let ent_path = match root.class(
|
||||||
|
"drm",
|
||||||
|
attributes(
|
||||||
|
crate::settings::util::CARD_NEEDS
|
||||||
|
.into_iter()
|
||||||
|
.map(|s| s.to_string()),
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
Ok(iter) => {
|
||||||
|
let card = iter
|
||||||
|
.filter(|ent| if let Ok(name) = ent.name() { name.starts_with("card")} else { false })
|
||||||
|
//.filter(|ent| super::util::card_also_has(ent, CARD_EXTENSIONS))
|
||||||
|
.next()
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
log::error!("Failed to find ROG Ally gpu drm in sysfs (no results), using naive fallback");
|
||||||
|
BasicEntityPath::new(root.as_ref().join("sys/class/drm/card1"))
|
||||||
|
});
|
||||||
|
log::info!(
|
||||||
|
"Found ROG Ally gpu drm in sysfs: {}",
|
||||||
|
card.as_ref().display()
|
||||||
|
);
|
||||||
|
card
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!(
|
||||||
|
"Failed to find ROG Ally gpu drm in sysfs ({}), using naive fallback",
|
||||||
|
e
|
||||||
|
);
|
||||||
|
BasicEntityPath::new(root.as_ref().join("sys/class/drm/card1"))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
IntelGpu::new(ent_path)
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Debug for Gpu {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("msi_claw::Gpu")
|
||||||
|
.field("limits", &self.limits)
|
||||||
|
//.field("settings", &self.settings)
|
||||||
|
//.field("gpu_impl", &self.gpu_impl)
|
||||||
|
.finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProviderBuilder<GpuJson, GenericGpuLimit> for Gpu {
|
||||||
|
fn from_json_and_limits(persistent: GpuJson, _version: u64, limits: GenericGpuLimit) -> Self {
|
||||||
|
Self {
|
||||||
|
//gpu_impl: Self::find_badgpu(persistent.root.clone()),
|
||||||
|
settings: persistent,
|
||||||
|
limits,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_limits(limits: GenericGpuLimit) -> Self {
|
||||||
|
Self {
|
||||||
|
//gpu_impl: Self::find_badgpu(None::<&'static str>),
|
||||||
|
settings: GpuJson::default(),
|
||||||
|
limits,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<GpuJson> for Gpu {
|
||||||
|
#[inline]
|
||||||
|
fn into(self) -> GpuJson {
|
||||||
|
self.settings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnSet for Gpu {
|
||||||
|
fn on_set(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
// TODO
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnResume for Gpu {
|
||||||
|
fn on_resume(&self) -> Result<(), Vec<SettingError>> {
|
||||||
|
// TODO
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnPowerEvent for Gpu {}
|
||||||
|
|
||||||
|
impl crate::settings::OnLoad for Gpu {
|
||||||
|
fn on_load(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnUnload for Gpu {
|
||||||
|
fn on_unload(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TGpu for Gpu {
|
||||||
|
fn limits(&self) -> crate::api::GpuLimits {
|
||||||
|
crate::api::GpuLimits {
|
||||||
|
fast_ppt_limits: self
|
||||||
|
.limits
|
||||||
|
.fast_ppt
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(15)))
|
||||||
|
.map(|mut x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x.min /= ppt_divisor;
|
||||||
|
x.max /= ppt_divisor;
|
||||||
|
x
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
fast_ppt_default: {
|
||||||
|
let def = self
|
||||||
|
.limits
|
||||||
|
.fast_ppt_default
|
||||||
|
.or_else(|| self.limits.fast_ppt.and_then(|x| x.max))
|
||||||
|
.unwrap_or(15);
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
def / ppt_divisor
|
||||||
|
} else {
|
||||||
|
def
|
||||||
|
}
|
||||||
|
},
|
||||||
|
slow_ppt_limits: self
|
||||||
|
.limits
|
||||||
|
.slow_ppt
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(15)))
|
||||||
|
.map(|mut x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x.min /= ppt_divisor;
|
||||||
|
x.max /= ppt_divisor;
|
||||||
|
x
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
slow_ppt_default: {
|
||||||
|
let def = self
|
||||||
|
.limits
|
||||||
|
.slow_ppt_default
|
||||||
|
.or_else(|| self.limits.slow_ppt.and_then(|x| x.max))
|
||||||
|
.unwrap_or(15);
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
def / ppt_divisor
|
||||||
|
} else {
|
||||||
|
def
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ppt_step: self.limits.ppt_step.unwrap_or(1),
|
||||||
|
tdp_limits: self
|
||||||
|
.limits
|
||||||
|
.tdp
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(15_000_000))),
|
||||||
|
tdp_boost_limits: self
|
||||||
|
.limits
|
||||||
|
.tdp_boost
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(15_000_000))),
|
||||||
|
tdp_step: self.limits.tdp_step.unwrap_or(42),
|
||||||
|
clock_min_limits: self
|
||||||
|
.limits
|
||||||
|
.clock_min
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(3_000))),
|
||||||
|
clock_max_limits: self
|
||||||
|
.limits
|
||||||
|
.clock_max
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(3_000))),
|
||||||
|
clock_step: self.limits.clock_step.unwrap_or(100),
|
||||||
|
memory_control: None,
|
||||||
|
memory_step: 100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn json(&self) -> crate::persist::GpuJson {
|
||||||
|
self.settings.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ppt(&mut self, fast: Option<u64>, slow: Option<u64>) {
|
||||||
|
if let Some(fast_lims) = &self.limits.fast_ppt {
|
||||||
|
self.settings.fast_ppt = fast
|
||||||
|
.map(|x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x * ppt_divisor
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(|x| {
|
||||||
|
x.clamp(
|
||||||
|
fast_lims.min.unwrap_or(0),
|
||||||
|
fast_lims.max.unwrap_or(u64::MAX),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if let Some(slow_lims) = &self.limits.slow_ppt {
|
||||||
|
self.settings.slow_ppt = slow
|
||||||
|
.map(|x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x * ppt_divisor
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(|x| {
|
||||||
|
x.clamp(
|
||||||
|
slow_lims.min.unwrap_or(0),
|
||||||
|
slow_lims.max.unwrap_or(u64::MAX),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_ppt(&self) -> (Option<u64>, Option<u64>) {
|
||||||
|
(
|
||||||
|
self.settings.fast_ppt.map(|x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x / ppt_divisor
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
self.settings.slow_ppt.map(|x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x / ppt_divisor
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clock_limits(&mut self, limits: Option<MinMax<u64>>) {
|
||||||
|
if let Some(clock_min) = &self.limits.clock_min {
|
||||||
|
if let Some(clock_max) = &self.limits.clock_max {
|
||||||
|
self.settings.clock_limits = limits.map(|x| {
|
||||||
|
MinMaxJson {
|
||||||
|
min: x.min.clamp(clock_min.min, clock_min.max),
|
||||||
|
max: x.max.clamp(clock_max.max, clock_max.max)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
|
self.settings.clock_limits.clone().map(|mmj| min_max_from_json(mmj, 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn memory_clock(&mut self, _speed: Option<u64>) {}
|
||||||
|
|
||||||
|
fn get_memory_clock(&self) -> Option<u64> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn provider(&self) -> crate::persist::DriverJson {
|
||||||
|
crate::persist::DriverJson::Generic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
6
backend/src/settings/msi_claw/mod.rs
Normal file
6
backend/src/settings/msi_claw/mod.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
mod cpu;
|
||||||
|
mod gpu;
|
||||||
|
mod util;
|
||||||
|
|
||||||
|
pub use cpu::Cpus;
|
||||||
|
pub use gpu::Gpu;
|
0
backend/src/settings/msi_claw/util.rs
Normal file
0
backend/src/settings/msi_claw/util.rs
Normal file
155
backend/src/settings/rog_ally/cpu.rs
Normal file
155
backend/src/settings/rog_ally/cpu.rs
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
use crate::persist::CpuJson;
|
||||||
|
use crate::settings::generic::{Cpu as GenericCpu, Cpus as GenericCpus, FromGenericCpuInfo};
|
||||||
|
use crate::settings::MinMax;
|
||||||
|
use crate::settings::{OnResume, OnSet, SettingError};
|
||||||
|
use crate::settings::{ProviderBuilder, TCpu, TCpus};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Cpus {
|
||||||
|
generic: GenericCpus<Cpu>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProviderBuilder<Vec<CpuJson>, limits_core::json_v2::GenericCpusLimit> for Cpus {
|
||||||
|
fn from_limits(limits: limits_core::json_v2::GenericCpusLimit) -> Self {
|
||||||
|
Self {
|
||||||
|
generic: GenericCpus::from_limits(limits),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_json_and_limits(
|
||||||
|
other: Vec<CpuJson>,
|
||||||
|
version: u64,
|
||||||
|
limits: limits_core::json_v2::GenericCpusLimit,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
generic: GenericCpus::from_json_and_limits(other, version, limits),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnResume for Cpus {
|
||||||
|
fn on_resume(&self) -> Result<(), Vec<SettingError>> {
|
||||||
|
self.generic.on_resume()
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnSet for Cpus {
|
||||||
|
fn on_set(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
self.generic.on_set()
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnPowerEvent for Cpus {}
|
||||||
|
|
||||||
|
impl crate::settings::OnLoad for Cpus {
|
||||||
|
fn on_load(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnUnload for Cpus {
|
||||||
|
fn on_unload(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TCpus for Cpus {
|
||||||
|
fn limits(&self) -> crate::api::CpusLimits {
|
||||||
|
self.generic.limits()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn json(&self) -> Vec<crate::persist::CpuJson> {
|
||||||
|
self.generic.json() // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cpus(&mut self) -> Vec<&mut dyn TCpu> {
|
||||||
|
self.generic.cpus() // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
fn len(&self) -> usize {
|
||||||
|
self.generic.len() // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
fn smt(&mut self) -> &'_ mut bool {
|
||||||
|
self.generic.smt()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn provider(&self) -> crate::persist::DriverJson {
|
||||||
|
crate::persist::DriverJson::GenericAMD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Cpu {
|
||||||
|
generic: GenericCpu,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromGenericCpuInfo for Cpu {
|
||||||
|
fn from_limits(cpu_index: usize, limits: limits_core::json_v2::GenericCpuLimit) -> Self {
|
||||||
|
let gen = GenericCpu::from_limits(cpu_index, limits.clone());
|
||||||
|
Self { generic: gen }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_json_and_limits(
|
||||||
|
other: CpuJson,
|
||||||
|
version: u64,
|
||||||
|
cpu_index: usize,
|
||||||
|
limits: limits_core::json_v2::GenericCpuLimit,
|
||||||
|
) -> Self {
|
||||||
|
let gen = GenericCpu::from_json_and_limits(other, version, cpu_index, limits);
|
||||||
|
Self { generic: gen }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsRef<GenericCpu> for Cpu {
|
||||||
|
fn as_ref(&self) -> &GenericCpu {
|
||||||
|
&self.generic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsMut<GenericCpu> for Cpu {
|
||||||
|
fn as_mut(&mut self) -> &mut GenericCpu {
|
||||||
|
&mut self.generic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnResume for Cpu {
|
||||||
|
fn on_resume(&self) -> Result<(), Vec<SettingError>> {
|
||||||
|
self.generic.on_resume()
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnSet for Cpu {
|
||||||
|
fn on_set(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
self.generic.on_set()
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnPowerEvent for Cpu {}
|
||||||
|
|
||||||
|
impl TCpu for Cpu {
|
||||||
|
fn online(&mut self) -> &mut bool {
|
||||||
|
self.generic.online()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn governor(&mut self, governor: String) {
|
||||||
|
self.generic.governor(governor)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_governor(&self) -> &'_ str {
|
||||||
|
self.generic.get_governor()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clock_limits(&mut self, _limits: Option<MinMax<u64>>) {
|
||||||
|
//self.generic.clock_limits(limits)
|
||||||
|
// TODO: support this
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
|
self.generic.get_clock_limits()
|
||||||
|
}
|
||||||
|
}
|
286
backend/src/settings/rog_ally/gpu.rs
Normal file
286
backend/src/settings/rog_ally/gpu.rs
Normal file
|
@ -0,0 +1,286 @@
|
||||||
|
use limits_core::json_v2::GenericGpuLimit;
|
||||||
|
use sysfuss::{capability::attributes, BasicEntityPath, SysEntity};
|
||||||
|
use procbox::combo::AmdGpu;
|
||||||
|
|
||||||
|
use crate::api::RangeLimit;
|
||||||
|
use crate::persist::{GpuJson, MinMaxJson};
|
||||||
|
use crate::settings::{min_max_from_json, MinMax};
|
||||||
|
use crate::settings::{OnResume, OnSet, SettingError};
|
||||||
|
use crate::settings::{ProviderBuilder, TGpu};
|
||||||
|
|
||||||
|
//#[derive(Clone)]
|
||||||
|
pub struct Gpu {
|
||||||
|
gpu_impl: AmdGpu,
|
||||||
|
settings: GpuJson,
|
||||||
|
limits: GenericGpuLimit,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Gpu {
|
||||||
|
fn find_amdgpu(root: Option<impl AsRef<std::path::Path>>) -> AmdGpu {
|
||||||
|
let root = crate::settings::util::root_or_default_sysfs(root);
|
||||||
|
let ent_path = match root.class(
|
||||||
|
"drm",
|
||||||
|
attributes(
|
||||||
|
crate::settings::util::CARD_NEEDS
|
||||||
|
.into_iter()
|
||||||
|
.map(|s| s.to_string()),
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
Ok(iter) => {
|
||||||
|
let card = iter
|
||||||
|
.filter(|ent| if let Ok(name) = ent.name() { name.starts_with("card")} else { false })
|
||||||
|
//.filter(|ent| super::util::card_also_has(ent, CARD_EXTENSIONS))
|
||||||
|
.next()
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
log::error!("Failed to find ROG Ally gpu drm in sysfs (no results), using naive fallback");
|
||||||
|
BasicEntityPath::new(root.as_ref().join("sys/class/drm/card1"))
|
||||||
|
});
|
||||||
|
log::info!(
|
||||||
|
"Found ROG Ally gpu drm in sysfs: {}",
|
||||||
|
card.as_ref().display()
|
||||||
|
);
|
||||||
|
card
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!(
|
||||||
|
"Failed to find ROG Ally gpu drm in sysfs ({}), using naive fallback",
|
||||||
|
e
|
||||||
|
);
|
||||||
|
BasicEntityPath::new(root.as_ref().join("sys/class/drm/card1"))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
AmdGpu::new(ent_path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Debug for Gpu {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("rog_ally::Gpu")
|
||||||
|
.field("limits", &self.limits)
|
||||||
|
//.field("gpu_impl", &self.gpu_impl)
|
||||||
|
.finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProviderBuilder<GpuJson, GenericGpuLimit> for Gpu {
|
||||||
|
fn from_json_and_limits(persistent: GpuJson, _version: u64, limits: GenericGpuLimit) -> Self {
|
||||||
|
Self {
|
||||||
|
gpu_impl: Self::find_amdgpu(persistent.root.clone()),
|
||||||
|
settings: persistent,
|
||||||
|
limits,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_limits(limits: GenericGpuLimit) -> Self {
|
||||||
|
Self {
|
||||||
|
gpu_impl: Self::find_amdgpu(None::<&'static str>),
|
||||||
|
settings: GpuJson::default(),
|
||||||
|
limits,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<GpuJson> for Gpu {
|
||||||
|
#[inline]
|
||||||
|
fn into(self) -> GpuJson {
|
||||||
|
self.settings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnSet for Gpu {
|
||||||
|
fn on_set(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
// TODO
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OnResume for Gpu {
|
||||||
|
fn on_resume(&self) -> Result<(), Vec<SettingError>> {
|
||||||
|
// TODO
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnPowerEvent for Gpu {}
|
||||||
|
|
||||||
|
impl crate::settings::OnLoad for Gpu {
|
||||||
|
fn on_load(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::settings::OnUnload for Gpu {
|
||||||
|
fn on_unload(&mut self) -> Result<(), Vec<SettingError>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TGpu for Gpu {
|
||||||
|
fn limits(&self) -> crate::api::GpuLimits {
|
||||||
|
crate::api::GpuLimits {
|
||||||
|
fast_ppt_limits: self
|
||||||
|
.limits
|
||||||
|
.fast_ppt
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(15)))
|
||||||
|
.map(|mut x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x.min /= ppt_divisor;
|
||||||
|
x.max /= ppt_divisor;
|
||||||
|
x
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
fast_ppt_default: {
|
||||||
|
let def = self
|
||||||
|
.limits
|
||||||
|
.fast_ppt_default
|
||||||
|
.or_else(|| self.limits.fast_ppt.and_then(|x| x.max))
|
||||||
|
.unwrap_or(15);
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
def / ppt_divisor
|
||||||
|
} else {
|
||||||
|
def
|
||||||
|
}
|
||||||
|
},
|
||||||
|
slow_ppt_limits: self
|
||||||
|
.limits
|
||||||
|
.slow_ppt
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(15)))
|
||||||
|
.map(|mut x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x.min /= ppt_divisor;
|
||||||
|
x.max /= ppt_divisor;
|
||||||
|
x
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
slow_ppt_default: {
|
||||||
|
let def = self
|
||||||
|
.limits
|
||||||
|
.slow_ppt_default
|
||||||
|
.or_else(|| self.limits.slow_ppt.and_then(|x| x.max))
|
||||||
|
.unwrap_or(15);
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
def / ppt_divisor
|
||||||
|
} else {
|
||||||
|
def
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ppt_step: self.limits.ppt_step.unwrap_or(1),
|
||||||
|
tdp_limits: self
|
||||||
|
.limits
|
||||||
|
.tdp
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(15_000_000))),
|
||||||
|
tdp_boost_limits: self
|
||||||
|
.limits
|
||||||
|
.tdp_boost
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(15_000_000))),
|
||||||
|
tdp_step: self.limits.tdp_step.unwrap_or(42),
|
||||||
|
clock_min_limits: self
|
||||||
|
.limits
|
||||||
|
.clock_min
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(3_000))),
|
||||||
|
clock_max_limits: self
|
||||||
|
.limits
|
||||||
|
.clock_max
|
||||||
|
.clone()
|
||||||
|
.map(|x| RangeLimit::new(x.min.unwrap_or(0), x.max.unwrap_or(3_000))),
|
||||||
|
clock_step: self.limits.clock_step.unwrap_or(100),
|
||||||
|
memory_control: None,
|
||||||
|
memory_step: 100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn json(&self) -> crate::persist::GpuJson {
|
||||||
|
self.settings.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ppt(&mut self, fast: Option<u64>, slow: Option<u64>) {
|
||||||
|
if let Some(fast_lims) = &self.limits.fast_ppt {
|
||||||
|
self.settings.fast_ppt = fast
|
||||||
|
.map(|x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x * ppt_divisor
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(|x| {
|
||||||
|
x.clamp(
|
||||||
|
fast_lims.min.unwrap_or(0),
|
||||||
|
fast_lims.max.unwrap_or(u64::MAX),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if let Some(slow_lims) = &self.limits.slow_ppt {
|
||||||
|
self.settings.slow_ppt = slow
|
||||||
|
.map(|x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x * ppt_divisor
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(|x| {
|
||||||
|
x.clamp(
|
||||||
|
slow_lims.min.unwrap_or(0),
|
||||||
|
slow_lims.max.unwrap_or(u64::MAX),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_ppt(&self) -> (Option<u64>, Option<u64>) {
|
||||||
|
(
|
||||||
|
self.settings.fast_ppt.map(|x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x / ppt_divisor
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
self.settings.slow_ppt.map(|x| {
|
||||||
|
if let Some(ppt_divisor) = self.limits.ppt_divisor {
|
||||||
|
x / ppt_divisor
|
||||||
|
} else {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clock_limits(&mut self, limits: Option<MinMax<u64>>) {
|
||||||
|
if let Some(clock_min) = &self.limits.clock_min {
|
||||||
|
if let Some(clock_max) = &self.limits.clock_max {
|
||||||
|
self.settings.clock_limits = limits.map(|x| {
|
||||||
|
MinMaxJson {
|
||||||
|
min: x.min.clamp(clock_min.min, clock_min.max),
|
||||||
|
max: x.max.clamp(clock_max.max, clock_max.max)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
|
self.settings.clock_limits.clone().map(|mmj| min_max_from_json(mmj, 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn memory_clock(&mut self, _speed: Option<u64>) {}
|
||||||
|
|
||||||
|
fn get_memory_clock(&self) -> Option<u64> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn provider(&self) -> crate::persist::DriverJson {
|
||||||
|
crate::persist::DriverJson::Generic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
6
backend/src/settings/rog_ally/mod.rs
Normal file
6
backend/src/settings/rog_ally/mod.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
mod cpu;
|
||||||
|
mod gpu;
|
||||||
|
mod util;
|
||||||
|
|
||||||
|
pub use cpu::Cpus;
|
||||||
|
pub use gpu::Gpu;
|
0
backend/src/settings/rog_ally/util.rs
Normal file
0
backend/src/settings/rog_ally/util.rs
Normal file
|
@ -723,8 +723,8 @@ impl TCpu for Cpu {
|
||||||
self.clock_limits = limits;
|
self.clock_limits = limits;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
self.clock_limits.as_ref()
|
self.clock_limits.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -717,8 +717,8 @@ impl TGpu for Gpu {
|
||||||
self.clock_limits = limits;
|
self.clock_limits = limits;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
self.clock_limits.as_ref()
|
self.clock_limits.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn memory_clock(&mut self, speed: Option<u64>) {
|
fn memory_clock(&mut self, speed: Option<u64>) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub trait TGpu: OnSet + OnResume + OnPowerEvent + OnLoad + OnUnload + Debug + Se
|
||||||
|
|
||||||
fn clock_limits(&mut self, limits: Option<MinMax<u64>>);
|
fn clock_limits(&mut self, limits: Option<MinMax<u64>>);
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>>;
|
fn get_clock_limits(&self) -> Option<MinMax<u64>>;
|
||||||
|
|
||||||
fn memory_clock(&mut self, speed: Option<u64>);
|
fn memory_clock(&mut self, speed: Option<u64>);
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ pub trait TCpu: Debug + Send {
|
||||||
|
|
||||||
fn clock_limits(&mut self, limits: Option<MinMax<u64>>);
|
fn clock_limits(&mut self, limits: Option<MinMax<u64>>);
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>>;
|
fn get_clock_limits(&self) -> Option<MinMax<u64>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait TGeneral: OnSet + OnResume + OnPowerEvent + OnLoad + OnUnload + Debug + Send {
|
pub trait TGeneral: OnSet + OnResume + OnPowerEvent + OnLoad + OnUnload + Debug + Send {
|
||||||
|
|
|
@ -356,7 +356,7 @@ impl TCpu for Cpu {
|
||||||
|
|
||||||
fn clock_limits(&mut self, _limits: Option<MinMax<u64>>) {}
|
fn clock_limits(&mut self, _limits: Option<MinMax<u64>>) {}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl TGpu for Gpu {
|
||||||
|
|
||||||
fn clock_limits(&mut self, _limits: Option<MinMax<u64>>) {}
|
fn clock_limits(&mut self, _limits: Option<MinMax<u64>>) {}
|
||||||
|
|
||||||
fn get_clock_limits(&self) -> Option<&MinMax<u64>> {
|
fn get_clock_limits(&self) -> Option<MinMax<u64>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue