Compare commits

...

32 Commits

Author SHA1 Message Date
Luke Jones b2726f3a67 Fix: charge control 2025-02-10 22:18:34 +13:00
Luke Jones 663f87d5e2 Checkpoint 2025-02-10 13:56:26 +13:00
Luke Jones 377bb4d6ad Merge branch 'private/Rohitrajak1807/G513RW-ledfix' into 'main'
Add ROG G513RW led cfgs

See merge request asus-linux/asusctl!217
2025-02-10 00:55:33 +00:00
Rohit Rajak 98e60db2da Add ROG G513RW led cfgs 2025-02-10 00:55:33 +00:00
Luke Jones 11ac46df11 Edit README.md 2025-02-08 02:39:30 +00:00
Luke Jones 05bec93644 Edit README.md 2025-02-08 02:33:08 +00:00
Luke Jones c77e7cf1ce Fix: correction to wrong matching function used for aura data find
Closes #607
2025-02-07 09:45:05 +13:00
Luke Jones d30f7dc2ea Merge branch 'main' into 'main'
feat (rog-aura): ASUS TUF FA617NS AURA Support

See merge request asus-linux/asusctl!214
2025-02-05 02:58:05 +00:00
Luke Jones 759606fca3 Merge branch 'aura' into 'main'
Update 'led-mode' -> 'aura' in example command.

See merge request asus-linux/asusctl!215
2025-02-05 02:57:38 +00:00
Luke Jones 25ed8bdeed Fix spelling mistake 2025-02-05 14:35:17 +13:00
Luke Jones de61a15b7a Prep 6.1.0 2025-02-04 18:52:55 +13:00
Luke Jones 16700e55f4 ROGCC: refactor many more parts of the PPT settings 2025-02-04 18:50:48 +13:00
Luke Jones 5833a011ce Merge branch 'g513rc-zonefix' into 'main'
Add basic zones for G513RC

See merge request asus-linux/asusctl!216
2025-02-03 04:08:29 +00:00
loystonpais 62577ee0e4 Add basic zones for G513RC 2025-02-03 07:36:32 +05:30
Luke Jones dac35996b1 Enable use of GAMESCOPE_WAYLAND_DISPLAY 2025-02-02 20:02:51 +13:00
Luke Jones 5c2bcad7c6 Various UI fixes 2025-02-01 20:31:09 +13:00
armdebug 81f6c18a24 Update 'led-mode' -> 'aura' in example command.
led-mode is renamed to aura in 19ffcf3376
2025-01-28 02:18:56 +05:30
riarumoda bcc3d42789 feat (rog-aura): ASUS TUF FA617NS AURA Support 2025-01-23 15:14:52 +08:00
Luke Jones 36c34cb3dd Merge branch 'fix/anime-animation-crash' into 'main'
fix: Use spawn instead of spawn_local in anime animation callback

Closes #588

See merge request asus-linux/asusctl!213
2025-01-22 02:05:04 +00:00
I-Al-Istannen 9b82b875f1 fix: Use spawn instead of spawn_local in anime animation callback
Closes #588
2025-01-21 21:04:20 +01:00
Luke D. Jones bddccc696f Update deps 2025-01-21 19:49:20 +13:00
Luke D. Jones 51e9f10087 Prep 6.1.0-rc7 2025-01-21 16:44:58 +13:00
Luke D. Jones 911ff8690e feature: rework PPT tuning handling more
1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
2025-01-21 16:39:34 +13:00
Luke D. Jones 25823dc6b7 asusd: anime: don't cause async deadlocks damnit
Same old song, an async mutex lock being held for a wide scope.
In particular being held for a scope that includes a function call which
also tries to get the lock.

Fix it by copy/clone of the config interior values required.

Fixes #588
2025-01-21 12:24:24 +13:00
Luke D. Jones cba8e1a473 Add extra debug logging to anime path 2025-01-20 13:43:38 +13:00
Luke D. Jones fb98827a1a Prep 6.1.0-rc6 2025-01-19 23:35:32 +13:00
Luke D. Jones b9296862df Move entirely to using only platform-profile
throttle_thermal_policy is not ideal anymore and may be
removed from kernel in the future.
2025-01-19 21:52:32 +13:00
Luke D. Jones 450205f9a9 Bug fix: correctly set charge limit from UI 2025-01-19 17:29:36 +13:00
Luke D. Jones 82431ee25b Prep 6.1.0-rc5 2025-01-19 16:11:48 +13:00
Luke D. Jones f11aea02a8 Add help and reset to UI for ppt values 2025-01-19 16:01:57 +13:00
Luke D. Jones 2d6d669c22 PPT restor defaults (WIP) 2025-01-19 12:02:22 +13:00
Luke D. Jones f9cebf9221 Per-AC/DC per-profile tunings enabled 2025-01-19 11:33:48 +13:00
46 changed files with 2987 additions and 1529 deletions
+42
View File
@@ -2,6 +2,48 @@
## [Unreleased] ## [Unreleased]
## [v6.1.2]
### Changed
- Try a slightly different tact to fix charge control slider
## [v6.1.1]
### Changed
- Fix aura data matching
- Fix charge control slider
## [v6.1.0]
### Changed
- Update deps
- Add support for G513RC RGB modes
- Many UI fixes
- Fixes to PPT settings in UI
## [v6.1.0-rc7]
- Refactor PPT handling more:
1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
- Bugfix: prevent an AniMe thread async deadlock
## [v6.1.0-rc6]
### Changed
- Two small fixes, one for `low-power` profile name, and one for base gpu tdp
- Move to using platform_profile api only (no throttle_thermal_policy)
## [v6.1.0-rc5]
### Changed
- Per-AC/DC, per-profile tunings enabled (Battery vs AC power + platform profile)
- Add ability to restore PPT defaults
- Add PPT help dialogue to UI
- Bug fix: correctly set charge limit from UI
## [v6.1.0-rc4] ## [v6.1.0-rc4]
### Changed ### Changed
Generated
+1119 -495
View File
File diff suppressed because it is too large Load Diff
+8 -7
View File
@@ -1,5 +1,5 @@
[workspace.package] [workspace.package]
version = "6.1.0-rc4" version = "6.1.2"
rust-version = "1.82" rust-version = "1.82"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
@@ -43,7 +43,8 @@ dirs = "^4.0"
smol = "^2.0" smol = "^2.0"
mio = "0.8.11" mio = "0.8.11"
zbus = "5.1" futures-util = "0.3.31"
zbus = "5.1.1"
logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["non_blocking"] } logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["non_blocking"] }
serde = { version = "^1.0", features = ["serde_derive"] } serde = { version = "^1.0", features = ["serde_derive"] }
@@ -65,26 +66,26 @@ gif = "^0.12.0"
versions = "6.2" versions = "6.2"
notify-rust = { version = "4.11.0", features = ["z", "async"] } notify-rust = { version = "4.11.4", features = ["z", "async"] }
sg = { git = "https://github.com/flukejones/sg-rs.git" } sg = { git = "https://github.com/flukejones/sg-rs.git" }
[profile.release] [profile.release]
# thin = 57s, asusd = 9.0M # thin = 57s, asusd = 9.0M
# fat = 72s, asusd = 6.4M # fat = 72s, asusd = 6.4M
lto = "fat" lto = "thin"
debug = false debug = false
opt-level = 3 opt-level = 3
panic = "abort" panic = "abort"
codegen-units = 1 # codegen-units = 1
[profile.dev] [profile.dev]
opt-level = 1 opt-level = 1
codegen-units = 16 # codegen-units = 1
[profile.dev.package."*"] [profile.dev.package."*"]
opt-level = 1 opt-level = 1
codegen-units = 16 # codegen-units = 1
[profile.bench] [profile.bench]
debug = false debug = false
+1 -1
View File
@@ -39,7 +39,7 @@ See the [rog-aura readme](./rog-aura/README.md) for more details.
## Discord ## Discord
[![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/z8y99XqPb7) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/B8GftRW2Hd)
## SUPPORTED LAPTOPS ## SUPPORTED LAPTOPS
+6 -3
View File
@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use crate::anime_cli::AnimeCommand; use crate::anime_cli::AnimeCommand;
use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin}; use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin};
@@ -71,7 +71,7 @@ pub struct ProfileCommand {
pub profile_get: bool, pub profile_get: bool,
#[options(meta = "", help = "set the active profile")] #[options(meta = "", help = "set the active profile")]
pub profile_set: Option<ThrottlePolicy> pub profile_set: Option<PlatformProfile>
} }
#[derive(Options)] #[derive(Options)]
@@ -96,6 +96,9 @@ pub struct GraphicsCommand {
pub struct ArmouryCommand { pub struct ArmouryCommand {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
#[options(free)] #[options(
free,
help = "append each value name followed by the value to set. `-1` sets to default"
)]
pub free: Vec<String> pub free: Vec<String>
} }
+2 -2
View File
@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
@@ -18,7 +18,7 @@ pub struct FanCurveCommand {
meta = "", meta = "",
help = "profile to modify fan-curve for. Shows data if no options provided" help = "profile to modify fan-curve for. Shows data if no options provided"
)] )]
pub mod_profile: Option<ThrottlePolicy>, pub mod_profile: Option<PlatformProfile>,
#[options( #[options(
meta = "", meta = "",
+25 -12
View File
@@ -9,7 +9,7 @@ use aura_cli::{LedPowerCommand1, LedPowerCommand2};
use dmi_id::DMIID; use dmi_id::DMIID;
use fan_curve_cli::FanCurveCommand; use fan_curve_cli::FanCurveCommand;
use gumdrop::{Opt, Options}; use gumdrop::{Opt, Options};
use log::error; use log::{error, info};
use rog_anime::usb::get_anime_type; use rog_anime::usb::get_anime_type;
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2}; use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower}; use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
@@ -22,7 +22,7 @@ use rog_dbus::zbus_aura::AuraProxyBlocking;
use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking;
use rog_dbus::zbus_platform::PlatformProxyBlocking; use rog_dbus::zbus_platform::PlatformProxyBlocking;
use rog_dbus::zbus_slash::SlashProxyBlocking; use rog_dbus::zbus_slash::SlashProxyBlocking;
use rog_platform::platform::{Properties, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, Properties};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use rog_scsi::AuraMode; use rog_scsi::AuraMode;
use rog_slash::SlashMode; use rog_slash::SlashMode;
@@ -74,7 +74,15 @@ fn main() {
println!("\nError: {e}\n"); println!("\nError: {e}\n");
print_info(); print_info();
}) { }) {
let asusd_version = platform_proxy.version().unwrap(); let asusd_version = platform_proxy
.version()
.map_err(|e| {
error!(
"Could not get asusd version: {e:?}\nIs asusd.service running? {}",
check_service("asusd")
);
})
.unwrap();
if asusd_version != self_version { if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}"); println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return; return;
@@ -273,8 +281,8 @@ fn do_parsed(
} }
println!("\nExtra help can be requested on any command or subcommand:"); println!("\nExtra help can be requested on any command or subcommand:");
println!(" asusctl led-mode --help"); println!(" asusctl aura --help");
println!(" asusctl led-mode static --help"); println!(" asusctl aura static --help");
} }
} }
} }
@@ -918,16 +926,16 @@ fn handle_throttle_profile(
} }
let proxy = PlatformProxyBlocking::new(conn)?; let proxy = PlatformProxyBlocking::new(conn)?;
let current = proxy.throttle_thermal_policy()?; let current = proxy.platform_profile()?;
if cmd.next { if cmd.next {
proxy.set_throttle_thermal_policy(current.next())?; proxy.set_platform_profile(current.next())?;
} else if let Some(profile) = cmd.profile_set { } else if let Some(profile) = cmd.profile_set {
proxy.set_throttle_thermal_policy(profile)?; proxy.set_platform_profile(profile)?;
} }
if cmd.list { if cmd.list {
let res = ThrottlePolicy::list(); let res = PlatformProfile::list();
for p in &res { for p in &res {
println!("{:?}", p); println!("{:?}", p);
} }
@@ -974,7 +982,7 @@ fn handle_fan_curve(
let plat_proxy = PlatformProxyBlocking::new(conn)?; let plat_proxy = PlatformProxyBlocking::new(conn)?;
if cmd.get_enabled { if cmd.get_enabled {
let profile = plat_proxy.throttle_thermal_policy()?; let profile = plat_proxy.platform_profile()?;
let curves = fan_proxy.fan_curve_data(profile)?; let curves = fan_proxy.fan_curve_data(profile)?;
for curve in curves.iter() { for curve in curves.iter() {
println!("{}", String::from(curve)); println!("{}", String::from(curve));
@@ -982,7 +990,7 @@ fn handle_fan_curve(
} }
if cmd.default { if cmd.default {
let active = plat_proxy.throttle_thermal_policy()?; let active = plat_proxy.platform_profile()?;
fan_proxy.set_curves_to_defaults(active)?; fan_proxy.set_curves_to_defaults(active)?;
} }
@@ -1122,7 +1130,12 @@ fn handle_armoury_command(cmd: &ArmouryCommand) -> Result<(), Box<dyn std::error
for attr in attr.iter() { for attr in attr.iter() {
let name = attr.name()?; let name = attr.name()?;
if <&str>::from(name) == cmd[0] { if <&str>::from(name) == cmd[0] {
attr.set_current_value(cmd[1].parse()?)?; let mut value: i32 = cmd[1].parse()?;
if value == -1 {
info!("Setting to default");
value = attr.default_value()?;
}
attr.set_current_value(value)?;
print_firmware_attr(attr)?; print_firmware_attr(attr)?;
} }
} }
+1 -1
View File
@@ -7,7 +7,7 @@ pub struct SlashCommand {
pub help: bool, pub help: bool,
#[options(help = "Enable the Slash Ledbar")] #[options(help = "Enable the Slash Ledbar")]
pub enable: bool, pub enable: bool,
#[options(help = "Ddisable the Slash Ledbar")] #[options(help = "Disable the Slash Ledbar")]
pub disable: bool, pub disable: bool,
#[options(short = "l", meta = "", help = "Set brightness value <0-255>")] #[options(short = "l", meta = "", help = "Set brightness value <0-255>")]
pub brightness: Option<u8>, pub brightness: Option<u8>,
+1
View File
@@ -34,6 +34,7 @@ tokio.workspace = true
log.workspace = true log.workspace = true
env_logger.workspace = true env_logger.workspace = true
futures-util.workspace = true
zbus.workspace = true zbus.workspace = true
logind-zbus.workspace = true logind-zbus.workspace = true
+209 -74
View File
@@ -1,12 +1,11 @@
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use ::zbus::export::futures_util::lock::Mutex;
use config_traits::StdConfig; use config_traits::StdConfig;
use futures_util::lock::Mutex;
use log::{debug, error, info}; use log::{debug, error, info};
use rog_platform::asus_armoury::{AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes}; use rog_platform::asus_armoury::{AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes};
use rog_platform::platform::{RogPlatform, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, RogPlatform};
use rog_platform::power::AsusPower;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zbus::object_server::SignalEmitter; use zbus::object_server::SignalEmitter;
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value}; use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
@@ -33,15 +32,22 @@ pub struct AsusArmouryAttribute {
attr: Attribute, attr: Attribute,
config: Arc<Mutex<Config>>, config: Arc<Mutex<Config>>,
/// platform control required here for access to PPD or Throttle profile /// platform control required here for access to PPD or Throttle profile
platform: RogPlatform platform: RogPlatform,
power: AsusPower
} }
impl AsusArmouryAttribute { impl AsusArmouryAttribute {
pub fn new(attr: Attribute, platform: RogPlatform, config: Arc<Mutex<Config>>) -> Self { pub fn new(
attr: Attribute,
platform: RogPlatform,
power: AsusPower,
config: Arc<Mutex<Config>>
) -> Self {
Self { Self {
attr, attr,
config, config,
platform platform,
power
} }
} }
@@ -60,32 +66,43 @@ impl AsusArmouryAttribute {
&mut self, &mut self,
signal_ctxt: SignalEmitter<'static> signal_ctxt: SignalEmitter<'static>
) -> Result<(), RogError> { ) -> Result<(), RogError> {
use zbus::export::futures_util::StreamExt; use futures_util::StreamExt;
let ctrl = self.clone();
let name = self.name(); let name = self.name();
match self.attr.get_watcher() { macro_rules! watch_value_notify {
Ok(watch) => { ($attr_str:expr, $fn_prop_changed:ident) => {
let name = <&str>::from(name); match self.attr.get_watcher($attr_str) {
tokio::spawn(async move { Ok(watch) => {
let mut buffer = [0; 32]; let name = <&str>::from(name);
watch let ctrl = self.clone();
.into_event_stream(&mut buffer) let sig = signal_ctxt.clone();
.unwrap() tokio::spawn(async move {
.for_each(|_| async { let mut buffer = [0; 32];
debug!("{} changed", name); watch
ctrl.current_value_changed(&signal_ctxt).await.ok(); .into_event_stream(&mut buffer)
}) .unwrap()
.await; .for_each(|_| async {
}); debug!("{} changed", name);
} ctrl.$fn_prop_changed(&sig).await.ok();
Err(e) => info!( })
"inotify watch failed: {}. You can ignore this if your device does not support \ .await;
the feature", });
e }
) Err(e) => info!(
"inotify watch failed: {}. You can ignore this if your device does not \
support the feature",
e
)
}
};
} }
// "current_value", "default_value", "min_value", "max_value"
watch_value_notify!("current_value", current_value_changed);
watch_value_notify!("default_value", default_value_changed);
watch_value_notify!("min_value", min_value_changed);
watch_value_notify!("max_value", max_value_changed);
Ok(()) Ok(())
} }
} }
@@ -93,17 +110,32 @@ impl AsusArmouryAttribute {
impl crate::Reloadable for AsusArmouryAttribute { impl crate::Reloadable for AsusArmouryAttribute {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
info!("Reloading {}", self.attr.name()); info!("Reloading {}", self.attr.name());
let profile: ThrottlePolicy = let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
ThrottlePolicy::from_str(self.platform.get_platform_profile()?.as_str())?; let power_plugged = self
if let Some(tunings) = self.config.lock().await.profile_tunings.get(&profile) { .power
if let Some(tune) = tunings.get(&self.name()) { .get_online()
self.attr .map_err(|e| {
.set_current_value(AttrValue::Integer(*tune)) error!("Could not get power status: {e:?}");
.map_err(|e| { e
error!("Could not set value: {e:?}"); })
e .unwrap_or_default();
})?; let config = if power_plugged == 1 {
info!("Set {} to {:?}", self.attr.name(), tune); &self.config.lock().await.ac_profile_tunings
} else {
&self.config.lock().await.dc_profile_tunings
};
if let Some(tuning) = config.get(&profile) {
if tuning.enabled {
if let Some(tune) = tuning.group.get(&self.name()) {
self.attr
.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Could not set {} value: {e:?}", self.attr.name());
self.attr.base_path_exists();
e
})?;
info!("Set {} to {:?}", self.attr.name(), tune);
}
} }
} }
@@ -159,6 +191,39 @@ impl AsusArmouryAttribute {
} }
} }
async fn restore_default(&self) -> fdo::Result<()> {
self.attr.restore_default()?;
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get_mut(&self.name()) {
if let AttrValue::Integer(i) = self.attr.default_value() {
*tune = *i;
}
}
if tuning.enabled {
self.attr
.set_current_value(self.attr.default_value())
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
}
config.write();
}
Ok(())
}
#[zbus(property)] #[zbus(property)]
async fn min_value(&self) -> i32 { async fn min_value(&self) -> i32 {
match self.attr.min_value() { match self.attr.min_value() {
@@ -193,6 +258,28 @@ impl AsusArmouryAttribute {
#[zbus(property)] #[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> { async fn current_value(&self) -> fdo::Result<i32> {
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get(&self.name()) {
return Ok(*tune);
} else if let AttrValue::Integer(i) = self.attr.default_value() {
return Ok(*i);
}
return Err(fdo::Error::Failed(
"Could not read current value".to_string()
));
}
if let Ok(AttrValue::Integer(i)) = self.attr.current_value() { if let Ok(AttrValue::Integer(i)) = self.attr.current_value() {
return Ok(i); return Ok(i);
} }
@@ -203,43 +290,42 @@ impl AsusArmouryAttribute {
#[zbus(property)] #[zbus(property)]
async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> { async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> {
self.attr
.set_current_value(AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
if self.name().is_ppt() { if self.name().is_ppt() {
let profile: ThrottlePolicy = let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
ThrottlePolicy::from_str(self.platform.get_platform_profile()?.as_str())?; let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
// var here to prevent async deadlock on else clause let mut config = self.config.lock().await;
let has_profile = self let tuning = config.select_tunings(power_plugged == 1, profile);
.config
.lock() if let Some(tune) = tuning.group.get_mut(&self.name()) {
.await *tune = value;
.profile_tunings
.contains_key(&profile);
if has_profile {
if let Some(tunings) = self.config.lock().await.profile_tunings.get_mut(&profile) {
if let Some(tune) = tunings.get_mut(&self.name()) {
*tune = value;
} else {
tunings.insert(self.name(), value);
debug!("Set tuning config for {} = {:?}", self.attr.name(), value);
}
}
} else { } else {
debug!("Adding tuning config for {}", profile); tuning.group.insert(self.name(), value);
self.config debug!("Store tuning config for {} = {:?}", self.attr.name(), value);
.lock() }
.await if tuning.enabled {
.profile_tunings self.attr
.insert(profile, HashMap::from([(self.name(), value)])); .set_current_value(&AttrValue::Integer(value))
debug!("Set tuning config for {} = {:?}", self.attr.name(), value); .map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
} }
} else { } else {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
let has_attr = self let has_attr = self
.config .config
.lock() .lock()
@@ -274,10 +360,17 @@ impl AsusArmouryAttribute {
pub async fn start_attributes_zbus( pub async fn start_attributes_zbus(
conn: &Connection, conn: &Connection,
platform: RogPlatform, platform: RogPlatform,
power: AsusPower,
attributes: FirmwareAttributes,
config: Arc<Mutex<Config>> config: Arc<Mutex<Config>>
) -> Result<(), RogError> { ) -> Result<(), RogError> {
for attr in FirmwareAttributes::new().attributes() { for attr in attributes.attributes() {
let mut attr = AsusArmouryAttribute::new(attr.clone(), platform.clone(), config.clone()); let mut attr = AsusArmouryAttribute::new(
attr.clone(),
platform.clone(),
power.clone(),
config.clone()
);
attr.reload().await?; attr.reload().await?;
let path = dbus_path_for_attr(attr.attr.name()); let path = dbus_path_for_attr(attr.attr.name());
@@ -288,3 +381,45 @@ pub async fn start_attributes_zbus(
} }
Ok(()) Ok(())
} }
pub async fn set_config_or_default(
attrs: &FirmwareAttributes,
config: &mut Config,
power_plugged: bool,
profile: PlatformProfile
) {
for attr in attrs.attributes().iter() {
let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() {
let tuning = config.select_tunings(power_plugged, profile);
if !tuning.enabled {
debug!("Tuning group is not enabled, skipping");
return;
}
if let Some(tune) = tuning.group.get(&name) {
attr.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
} else {
let default = attr.default_value();
attr.set_current_value(default)
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
if let AttrValue::Integer(i) = default {
tuning.group.insert(name, *i);
info!(
"Set default tuning config for {} = {:?}",
<&str>::from(name),
i
);
// config.write();
}
}
}
}
}
+13 -12
View File
@@ -8,7 +8,8 @@ use std::sync::Arc;
use std::thread::sleep; use std::thread::sleep;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{error, info, warn}; use futures_util::lock::Mutex;
use log::{debug, error, info, warn};
use rog_anime::usb::{ use rog_anime::usb::{
pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim, pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim,
pkts_for_init, Brightness pkts_for_init, Brightness
@@ -16,7 +17,6 @@ use rog_anime::usb::{
use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType}; use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw; use rog_platform::usb_raw::USBRaw;
use tokio::sync::{Mutex, MutexGuard};
use self::config::{AniMeConfig, AniMeConfigCached}; use self::config::{AniMeConfig, AniMeConfigCached};
use crate::error::RogError; use crate::error::RogError;
@@ -51,7 +51,7 @@ impl AniMe {
/// Will fail if something is already holding the config lock /// Will fail if something is already holding the config lock
async fn do_init_cache(&mut self) { async fn do_init_cache(&mut self) {
if let Ok(mut config) = self.config.try_lock() { if let Some(mut config) = self.config.try_lock() {
if let Err(e) = self.cache.init_from_config(&config, config.anime_type) { if let Err(e) = self.cache.init_from_config(&config, config.anime_type) {
error!( error!(
"Trying to cache the Anime Config failed, will reset to default config: {e:?}" "Trying to cache the Anime Config failed, will reset to default config: {e:?}"
@@ -59,6 +59,8 @@ impl AniMe {
config.rename_file_old(); config.rename_file_old();
*config = AniMeConfig::new(); *config = AniMeConfig::new();
config.write(); config.write();
} else {
debug!("Initialised AniMe cache");
} }
} else { } else {
error!("AniMe Matrix could not init cache") error!("AniMe Matrix could not init cache")
@@ -70,11 +72,9 @@ impl AniMe {
self.do_init_cache().await; self.do_init_cache().await;
let pkts = pkts_for_init(); let pkts = pkts_for_init();
self.write_bytes(&pkts[0]).await?; self.write_bytes(&pkts[0]).await?;
self.write_bytes(&pkts[1]).await self.write_bytes(&pkts[1]).await?;
} debug!("Succesfully initialised AniMe matrix display");
Ok(())
pub async fn lock_config(&self) -> MutexGuard<AniMeConfig> {
self.config.lock().await
} }
pub async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> { pub async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> {
@@ -176,7 +176,7 @@ impl AniMe {
return Ok(true); // Do safe exit return Ok(true); // Do safe exit
} }
let inner = inner.clone(); let inner = inner.clone();
tokio::task::spawn_local(async move { tokio::task::spawn(async move {
inner inner
.write_data_buffer(frame) .write_data_buffer(frame)
.await .await
@@ -227,10 +227,11 @@ impl AniMe {
}) })
.ok(); .ok();
} }
// A write can block for many milliseconds so lets not hold the config lock for
// the same period
let enabled = inner.config.lock().await.builtin_anims_enabled;
inner inner
.write_bytes(&pkt_set_enable_powersave_anim( .write_bytes(&pkt_set_enable_powersave_anim(enabled))
inner.config.lock().await.builtin_anims_enabled
))
.await .await
.map_err(|err| { .map_err(|err| {
warn!("rog_anime::run_animation:callback {}", err); warn!("rog_anime::run_animation:callback {}", err);
+59 -46
View File
@@ -1,7 +1,7 @@
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{error, warn}; use log::{debug, error, warn};
use logind_zbus::manager::ManagerProxy; use logind_zbus::manager::ManagerProxy;
use rog_anime::usb::{ use rog_anime::usb::{
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display, pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
@@ -51,8 +51,11 @@ impl AniMeZbus {
.object_server() .object_server()
.at(path.clone(), self) .at(path.clone(), self)
.await .await
.map_err(|e| error!("Couldn't add server at path: {path}, {e:?}")) .map_err(|e| {
.ok(); error!("Couldn't add server at path: {path}, {e:?}");
e
})?;
debug!("start_tasks was successful");
Ok(()) Ok(())
} }
} }
@@ -78,7 +81,7 @@ impl AniMeZbus {
/// Set base brightness level /// Set base brightness level
#[zbus(property)] #[zbus(property)]
async fn brightness(&self) -> Brightness { async fn brightness(&self) -> Brightness {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.display_brightness; return config.display_brightness;
} }
Brightness::Off Brightness::Off
@@ -110,7 +113,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn builtins_enabled(&self) -> bool { async fn builtins_enabled(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.builtin_anims_enabled; return config.builtin_anims_enabled;
} }
false false
@@ -155,7 +158,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn builtin_animations(&self) -> Animations { async fn builtin_animations(&self) -> Animations {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.builtin_anims; return config.builtin_anims;
} }
Animations::default() Animations::default()
@@ -188,7 +191,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn enable_display(&self) -> bool { async fn enable_display(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.display_enabled; return config.display_enabled;
} }
false false
@@ -211,7 +214,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_unplugged(&self) -> bool { async fn off_when_unplugged(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.off_when_unplugged; return config.off_when_unplugged;
} }
false false
@@ -238,7 +241,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_suspended(&self) -> bool { async fn off_when_suspended(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.off_when_suspended; return config.off_when_suspended;
} }
false false
@@ -254,7 +257,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_lid_closed(&self) -> bool { async fn off_when_lid_closed(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
return config.off_when_lid_closed; return config.off_when_lid_closed;
} }
false false
@@ -440,50 +443,60 @@ impl crate::CtrlTask for AniMeZbus {
impl crate::Reloadable for AniMeZbus { impl crate::Reloadable for AniMeZbus {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
if let Ok(config) = self.0.config.try_lock() { let AniMeConfig {
let anim = &config.builtin_anims; builtin_anims_enabled,
// Set builtins builtin_anims,
if config.builtin_anims_enabled { display_enabled,
self.0 display_brightness,
.write_bytes(&pkt_set_builtin_animations( off_when_lid_closed,
anim.boot, anim.awake, anim.sleep, anim.shutdown off_when_unplugged,
)) ..
.await?; } = *self.0.config.lock().await;
}
// Builtins enabled or na? // Set builtins
if builtin_anims_enabled {
self.0 self.0
.set_builtins_enabled(config.builtin_anims_enabled, config.display_brightness) .write_bytes(&pkt_set_builtin_animations(
builtin_anims.boot,
builtin_anims.awake,
builtin_anims.sleep,
builtin_anims.shutdown
))
.await?; .await?;
}
// Builtins enabled or na?
self.0
.set_builtins_enabled(builtin_anims_enabled, display_brightness)
.await?;
let manager = get_logind_manager().await; let manager = get_logind_manager().await;
let lid_closed = manager.lid_closed().await.unwrap_or_default(); let lid_closed = manager.lid_closed().await.unwrap_or_default();
let power_plugged = manager.on_external_power().await.unwrap_or_default(); let power_plugged = manager.on_external_power().await.unwrap_or_default();
let turn_off = (lid_closed && config.off_when_lid_closed) let turn_off =
|| (!power_plugged && config.off_when_unplugged); (lid_closed && off_when_lid_closed) || (!power_plugged && off_when_unplugged);
self.0
.write_bytes(&pkt_set_enable_display(!turn_off))
.await
.map_err(|err| {
warn!("create_sys_event_tasks::reload {}", err);
})
.ok();
if turn_off || !display_enabled {
self.0.write_bytes(&pkt_set_enable_display(false)).await?;
// early return so we don't run animation thread
return Ok(());
}
if !builtin_anims_enabled && !self.0.cache.boot.is_empty() {
self.0 self.0
.write_bytes(&pkt_set_enable_display(!turn_off)) .write_bytes(&pkt_set_enable_powersave_anim(false))
.await .await
.map_err(|err| {
warn!("create_sys_event_tasks::reload {}", err);
})
.ok(); .ok();
if turn_off || !config.display_enabled { let action = self.0.cache.boot.clone();
self.0.write_bytes(&pkt_set_enable_display(false)).await?; self.0.run_thread(action, true).await;
// early return so we don't run animation thread
return Ok(());
}
if !config.builtin_anims_enabled && !self.0.cache.boot.is_empty() {
self.0
.write_bytes(&pkt_set_enable_powersave_anim(false))
.await
.ok();
let action = self.0.cache.boot.clone();
self.0.run_thread(action, true).await;
}
} }
Ok(()) Ok(())
} }
+1 -1
View File
@@ -2,13 +2,13 @@ use std::sync::Arc;
use config::AuraConfig; use config::AuraConfig;
use config_traits::StdConfig; use config_traits::StdConfig;
use futures_util::lock::{Mutex, MutexGuard};
use log::info; use log::info;
use rog_aura::keyboard::{AuraLaptopUsbPackets, LedUsbPackets}; use rog_aura::keyboard::{AuraLaptopUsbPackets, LedUsbPackets};
use rog_aura::usb::{AURA_LAPTOP_LED_APPLY, AURA_LAPTOP_LED_SET}; use rog_aura::usb::{AURA_LAPTOP_LED_APPLY, AURA_LAPTOP_LED_SET};
use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, PowerZones, AURA_LAPTOP_LED_MSG_LEN}; use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, PowerZones, AURA_LAPTOP_LED_MSG_LEN};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::keyboard_led::KeyboardBacklight; use rog_platform::keyboard_led::KeyboardBacklight;
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
+2 -2
View File
@@ -112,7 +112,7 @@ impl AuraZbus {
// entirely possible to deadlock here, so use try instead of lock() // entirely possible to deadlock here, so use try instead of lock()
// let ctrl = self.0.lock().await; // let ctrl = self.0.lock().await;
// Ok(config.current_mode) // Ok(config.current_mode)
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
Ok(config.current_mode) Ok(config.current_mode)
} else { } else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string())) Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
@@ -140,7 +140,7 @@ impl AuraZbus {
#[zbus(property)] #[zbus(property)]
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> { async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
// entirely possible to deadlock here, so use try instead of lock() // entirely possible to deadlock here, so use try instead of lock()
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
let mode = config.current_mode; let mode = config.current_mode;
match config.builtins.get(&mode) { match config.builtins.get(&mode) {
Some(effect) => Ok(effect.clone()), Some(effect) => Ok(effect.clone()),
+19 -10
View File
@@ -8,11 +8,11 @@ use std::sync::Arc;
use dmi_id::DMIID; use dmi_id::DMIID;
use futures_lite::future::block_on; use futures_lite::future::block_on;
use futures_util::lock::Mutex;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use mio::{Events, Interest, Poll, Token}; use mio::{Events, Interest, Poll, Token};
use rog_platform::error::PlatformError; use rog_platform::error::PlatformError;
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use tokio::sync::Mutex;
use udev::{Device, MonitorBuilder}; use udev::{Device, MonitorBuilder};
use zbus::zvariant::{ObjectPath, OwnedObjectPath}; use zbus::zvariant::{ObjectPath, OwnedObjectPath};
use zbus::Connection; use zbus::Connection;
@@ -319,11 +319,17 @@ impl DeviceManager {
if let DeviceHandle::AniMe(anime) = dev_type.clone() { if let DeviceHandle::AniMe(anime) = dev_type.clone() {
let path = dbus_path_for_anime(); let path = dbus_path_for_anime();
let ctrl = AniMeZbus::new(anime); let ctrl = AniMeZbus::new(anime);
ctrl.start_tasks(connection, path.clone()).await.unwrap(); if ctrl
devices.push(AsusDevice { .start_tasks(connection, path.clone())
device: dev_type, .await
dbus_path: path .map_err(|e| error!("Failed to start tasks: {e:?}, not adding this device"))
}); .is_ok()
{
devices.push(AsusDevice {
device: dev_type,
dbus_path: path
});
}
} }
} else { } else {
info!("Tested device was not AniMe Matrix"); info!("Tested device was not AniMe Matrix");
@@ -364,7 +370,9 @@ impl DeviceManager {
pub async fn new(connection: Connection) -> Result<Self, RogError> { pub async fn new(connection: Connection) -> Result<Self, RogError> {
let conn_copy = connection.clone(); let conn_copy = connection.clone();
let devices = Arc::new(Mutex::new(Self::find_all_devices(&conn_copy).await)); let devices = Self::find_all_devices(&conn_copy).await;
info!("Found {} valid devices on startup", devices.len());
let devices = Arc::new(Mutex::new(devices));
let manager = Self { let manager = Self {
_dbus_connection: connection _dbus_connection: connection
}; };
@@ -372,8 +380,6 @@ impl DeviceManager {
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually // TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
// checked for and added // checked for and added
// detect all plugged in aura devices (eventually)
// only USB devices are detected for here
std::thread::spawn(move || { std::thread::spawn(move || {
let mut monitor = MonitorBuilder::new()?.listen()?; let mut monitor = MonitorBuilder::new()?.listen()?;
let mut poll = Poll::new()?; let mut poll = Poll::new()?;
@@ -420,7 +426,10 @@ impl DeviceManager {
{ {
index index
} else { } else {
warn!("No device for dbus path: {path:?}"); if dev_prop_matches(&event.device(), "ID_VENDOR_ID", "0b05")
{
warn!("No device for dbus path: {path:?}");
}
return Ok(()); return Ok(());
}; };
info!("removing: {path:?}"); info!("removing: {path:?}");
+1 -1
View File
@@ -1,8 +1,8 @@
use std::sync::Arc; use std::sync::Arc;
use config::ScsiConfig; use config::ScsiConfig;
use futures_util::lock::{Mutex, MutexGuard};
use rog_scsi::{AuraEffect, Device, Task}; use rog_scsi::{AuraEffect, Device, Task};
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
+1 -1
View File
@@ -83,7 +83,7 @@ impl ScsiZbus {
#[zbus(property)] #[zbus(property)]
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> { async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
// entirely possible to deadlock here, so use try instead of lock() // entirely possible to deadlock here, so use try instead of lock()
if let Ok(config) = self.0.config.try_lock() { if let Some(config) = self.0.config.try_lock() {
let mode = config.current_mode; let mode = config.current_mode;
match config.modes.get(&mode) { match config.modes.get(&mode) {
Some(effect) => Ok(effect.clone()), Some(effect) => Ok(effect.clone()),
+1 -1
View File
@@ -1,11 +1,11 @@
use std::sync::Arc; use std::sync::Arc;
use config::SlashConfig; use config::SlashConfig;
use futures_util::lock::{Mutex, MutexGuard};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw; use rog_platform::usb_raw::USBRaw;
use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init}; use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init};
use rog_slash::SlashType; use rog_slash::SlashType;
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
+1 -1
View File
@@ -1,6 +1,7 @@
use std::sync::Arc; use std::sync::Arc;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_util::lock::Mutex;
use log::{debug, error, info}; use log::{debug, error, info};
use rog_anime::error::AnimeError; use rog_anime::error::AnimeError;
use rog_anime::usb::get_anime_type; use rog_anime::usb::get_anime_type;
@@ -12,7 +13,6 @@ use rog_platform::usb_raw::USBRaw;
use rog_scsi::{open_device, ScsiType}; use rog_scsi::{open_device, ScsiType};
use rog_slash::error::SlashError; use rog_slash::error::SlashError;
use rog_slash::SlashType; use rog_slash::SlashType;
use tokio::sync::Mutex;
use crate::aura_anime::config::AniMeConfig; use crate::aura_anime::config::AniMeConfig;
use crate::aura_anime::AniMe; use crate::aura_anime::AniMe;
+66 -45
View File
@@ -3,11 +3,18 @@ use std::collections::HashMap;
use config_traits::{StdConfig, StdConfigLoad1}; use config_traits::{StdConfig, StdConfigLoad1};
use rog_platform::asus_armoury::FirmwareAttribute; use rog_platform::asus_armoury::FirmwareAttribute;
use rog_platform::cpu::CPUEPP; use rog_platform::cpu::CPUEPP;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
const CONFIG_FILE: &str = "asusd.ron"; const CONFIG_FILE: &str = "asusd.ron";
#[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
pub struct Tuning {
pub enabled: bool,
pub group: HashMap<FirmwareAttribute, i32>
}
type Tunings = HashMap<PlatformProfile, Tuning>;
#[derive(Deserialize, Serialize, PartialEq)] #[derive(Deserialize, Serialize, PartialEq)]
pub struct Config { pub struct Config {
// The current charge limit applied // The current charge limit applied
@@ -21,29 +28,41 @@ pub struct Config {
/// An optional command/script to run when power is changed to battery /// An optional command/script to run when power is changed to battery
pub bat_command: String, pub bat_command: String,
/// Set true if energy_performance_preference should be set if the /// Set true if energy_performance_preference should be set if the
/// throttle/platform profile is changed /// platform profile is changed
pub throttle_policy_linked_epp: bool, pub platform_profile_linked_epp: bool,
/// Which throttle/profile to use on battery power /// Which platform profile to use on battery power
pub throttle_policy_on_battery: ThrottlePolicy, pub platform_profile_on_battery: PlatformProfile,
/// Should the throttle policy be set on bat/ac change? /// Should the throttle policy be set on bat/ac change?
pub change_throttle_policy_on_battery: bool, pub change_platform_profile_on_battery: bool,
/// Which throttle/profile to use on AC power /// Which platform profile to use on AC power
pub throttle_policy_on_ac: ThrottlePolicy, pub platform_profile_on_ac: PlatformProfile,
/// Should the throttle policy be set on bat/ac change? /// Should the platform profile be set on bat/ac change?
pub change_throttle_policy_on_ac: bool, pub change_platform_profile_on_ac: bool,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_quiet_epp: CPUEPP, pub profile_quiet_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_balanced_epp: CPUEPP, pub profile_balanced_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_performance_epp: CPUEPP, pub profile_performance_epp: CPUEPP,
pub profile_tunings: HashMap<ThrottlePolicy, HashMap<FirmwareAttribute, i32>>, pub ac_profile_tunings: Tunings,
pub dc_profile_tunings: Tunings,
pub armoury_settings: HashMap<FirmwareAttribute, i32>, pub armoury_settings: HashMap<FirmwareAttribute, i32>,
/// Temporary state for AC/Batt /// Temporary state for AC/Batt
#[serde(skip)] #[serde(skip)]
pub last_power_plugged: u8 pub last_power_plugged: u8
} }
impl Config {
pub fn select_tunings(&mut self, power_plugged: bool, profile: PlatformProfile) -> &mut Tuning {
let config = if power_plugged {
&mut self.ac_profile_tunings
} else {
&mut self.dc_profile_tunings
};
config.entry(profile).or_insert_with(Tuning::default)
}
}
impl Default for Config { impl Default for Config {
fn default() -> Self { fn default() -> Self {
Self { Self {
@@ -52,15 +71,16 @@ impl Default for Config {
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
ac_command: Default::default(), ac_command: Default::default(),
bat_command: Default::default(), bat_command: Default::default(),
throttle_policy_linked_epp: true, platform_profile_linked_epp: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet, platform_profile_on_battery: PlatformProfile::Quiet,
change_throttle_policy_on_battery: true, change_platform_profile_on_battery: true,
throttle_policy_on_ac: ThrottlePolicy::Performance, platform_profile_on_ac: PlatformProfile::Performance,
change_throttle_policy_on_ac: true, change_platform_profile_on_ac: true,
throttle_quiet_epp: CPUEPP::Power, profile_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower, profile_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance, profile_performance_epp: CPUEPP::Performance,
profile_tunings: HashMap::default(), ac_profile_tunings: HashMap::default(),
dc_profile_tunings: HashMap::default(),
armoury_settings: HashMap::default(), armoury_settings: HashMap::default(),
last_power_plugged: Default::default() last_power_plugged: Default::default()
} }
@@ -72,8 +92,8 @@ impl StdConfig for Config {
Config { Config {
charge_control_end_threshold: 100, charge_control_end_threshold: 100,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet, platform_profile_on_battery: PlatformProfile::Quiet,
throttle_policy_on_ac: ThrottlePolicy::Performance, platform_profile_on_ac: PlatformProfile::Performance,
ac_command: String::new(), ac_command: String::new(),
bat_command: String::new(), bat_command: String::new(),
..Default::default() ..Default::default()
@@ -102,14 +122,14 @@ pub struct Config601 {
pub disable_nvidia_powerd_on_battery: bool, pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String, pub ac_command: String,
pub bat_command: String, pub bat_command: String,
pub throttle_policy_linked_epp: bool, pub platform_profile_linked_epp: bool,
pub throttle_policy_on_battery: ThrottlePolicy, pub platform_profile_on_battery: PlatformProfile,
pub change_throttle_policy_on_battery: bool, pub change_platform_profile_on_battery: bool,
pub throttle_policy_on_ac: ThrottlePolicy, pub platform_profile_on_ac: PlatformProfile,
pub change_throttle_policy_on_ac: bool, pub change_platform_profile_on_ac: bool,
pub throttle_quiet_epp: CPUEPP, pub profile_quiet_epp: CPUEPP,
pub throttle_balanced_epp: CPUEPP, pub profile_balanced_epp: CPUEPP,
pub throttle_performance_epp: CPUEPP, pub profile_performance_epp: CPUEPP,
#[serde(skip_serializing_if = "Option::is_none", default)] #[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl1_spl: Option<u8>, pub ppt_pl1_spl: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)] #[serde(skip_serializing_if = "Option::is_none", default)]
@@ -139,16 +159,17 @@ impl From<Config601> for Config {
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery, disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command, ac_command: c.ac_command,
bat_command: c.bat_command, bat_command: c.bat_command,
throttle_policy_linked_epp: c.throttle_policy_linked_epp, platform_profile_linked_epp: c.platform_profile_linked_epp,
throttle_policy_on_battery: c.throttle_policy_on_battery, platform_profile_on_battery: c.platform_profile_on_battery,
change_throttle_policy_on_battery: c.change_throttle_policy_on_battery, change_platform_profile_on_battery: c.change_platform_profile_on_battery,
throttle_policy_on_ac: c.throttle_policy_on_ac, platform_profile_on_ac: c.platform_profile_on_ac,
change_throttle_policy_on_ac: c.change_throttle_policy_on_ac, change_platform_profile_on_ac: c.change_platform_profile_on_ac,
throttle_quiet_epp: c.throttle_quiet_epp, profile_quiet_epp: c.profile_quiet_epp,
throttle_balanced_epp: c.throttle_balanced_epp, profile_balanced_epp: c.profile_balanced_epp,
throttle_performance_epp: c.throttle_performance_epp, profile_performance_epp: c.profile_performance_epp,
last_power_plugged: c.last_power_plugged, last_power_plugged: c.last_power_plugged,
profile_tunings: HashMap::default(), ac_profile_tunings: HashMap::default(),
dc_profile_tunings: HashMap::default(),
armoury_settings: HashMap::default() armoury_settings: HashMap::default()
} }
} }
+37 -32
View File
@@ -3,13 +3,13 @@ use std::sync::Arc;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_lite::StreamExt; use futures_lite::StreamExt;
use futures_util::lock::Mutex;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::platform::{RogPlatform, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, RogPlatform};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles}; use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use zbus::object_server::SignalEmitter; use zbus::object_server::SignalEmitter;
use zbus::{interface, Connection}; use zbus::{interface, Connection};
@@ -23,7 +23,7 @@ pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";
pub struct FanCurveConfig { pub struct FanCurveConfig {
pub profiles: FanCurveProfiles, pub profiles: FanCurveProfiles,
#[serde(skip)] #[serde(skip)]
pub current: u8 pub current: PlatformProfile
} }
impl StdConfig for FanCurveConfig { impl StdConfig for FanCurveConfig {
@@ -54,7 +54,7 @@ pub struct CtrlFanCurveZbus {
impl CtrlFanCurveZbus { impl CtrlFanCurveZbus {
pub fn new() -> Result<Self, RogError> { pub fn new() -> Result<Self, RogError> {
let platform = RogPlatform::new()?; let platform = RogPlatform::new()?;
if platform.has_throttle_thermal_policy() { if platform.has_platform_profile() {
info!("Device has profile control available"); info!("Device has profile control available");
find_fan_curve_node()?; find_fan_curve_node()?;
info!("Device has fan curves available"); info!("Device has fan curves available");
@@ -65,16 +65,16 @@ impl CtrlFanCurveZbus {
if config.profiles.balanced.is_empty() || !config.file_path().exists() { if config.profiles.balanced.is_empty() || !config.file_path().exists() {
info!("Fetching default fan curves"); info!("Fetching default fan curves");
let current = platform.get_throttle_thermal_policy()?; let current = platform.get_platform_profile()?;
for this in [ for this in [
ThrottlePolicy::Balanced, PlatformProfile::Balanced,
ThrottlePolicy::Performance, PlatformProfile::Performance,
ThrottlePolicy::Quiet PlatformProfile::Quiet
] { ] {
// For each profile we need to switch to it before we // For each profile we need to switch to it before we
// can read the existing values from hardware. The ACPI method used // can read the existing values from hardware. The ACPI method used
// for this is what limits us. // for this is what limits us.
platform.set_throttle_thermal_policy(this.into())?; platform.set_platform_profile(this.into())?;
let mut dev = find_fan_curve_node()?; let mut dev = find_fan_curve_node()?;
fan_curves.set_active_curve_to_defaults(this, &mut dev)?; fan_curves.set_active_curve_to_defaults(this, &mut dev)?;
@@ -83,7 +83,7 @@ impl CtrlFanCurveZbus {
info!("{}", String::from(curve)); info!("{}", String::from(curve));
} }
} }
platform.set_throttle_thermal_policy(current)?; platform.set_platform_profile(current.as_str())?;
config.profiles = fan_curves; config.profiles = fan_curves;
config.write(); config.write();
} else { } else {
@@ -107,7 +107,7 @@ impl CtrlFanCurveZbus {
/// fan curve if in the same profile mode /// fan curve if in the same profile mode
async fn set_fan_curves_enabled( async fn set_fan_curves_enabled(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
enabled: bool enabled: bool
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
@@ -128,7 +128,7 @@ impl CtrlFanCurveZbus {
/// activate a fan curve if in the same profile mode /// activate a fan curve if in the same profile mode
async fn set_profile_fan_curve_enabled( async fn set_profile_fan_curve_enabled(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool enabled: bool
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
@@ -149,7 +149,7 @@ impl CtrlFanCurveZbus {
/// Get the fan-curve data for the currently active ThrottlePolicy /// Get the fan-curve data for the currently active ThrottlePolicy
async fn fan_curve_data( async fn fan_curve_data(
&mut self, &mut self,
profile: ThrottlePolicy profile: PlatformProfile
) -> zbus::fdo::Result<Vec<CurveData>> { ) -> zbus::fdo::Result<Vec<CurveData>> {
let curve = self let curve = self
.config .config
@@ -165,7 +165,7 @@ impl CtrlFanCurveZbus {
/// Will also activate the fan curve if the user is in the same mode. /// Will also activate the fan curve if the user is in the same mode.
async fn set_fan_curve( async fn set_fan_curve(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
curve: CurveData curve: CurveData
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
@@ -173,7 +173,7 @@ impl CtrlFanCurveZbus {
.await .await
.profiles .profiles
.save_fan_curve(curve, profile)?; .save_fan_curve(curve, profile)?;
let active: ThrottlePolicy = self.platform.get_throttle_thermal_policy()?.into(); let active: PlatformProfile = self.platform.get_platform_profile()?.into();
if active == profile { if active == profile {
self.config self.config
.lock() .lock()
@@ -190,15 +190,15 @@ impl CtrlFanCurveZbus {
/// ///
/// Each platform_profile has a different default and the default can be /// Each platform_profile has a different default and the default can be
/// read only for the currently active profile. /// read only for the currently active profile.
async fn set_curves_to_defaults(&mut self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> { async fn set_curves_to_defaults(&mut self, profile: PlatformProfile) -> zbus::fdo::Result<()> {
let active = self.platform.get_throttle_thermal_policy()?; let active = self.platform.get_platform_profile()?;
self.platform.set_throttle_thermal_policy(profile.into())?; self.platform.set_platform_profile(profile.into())?;
self.config self.config
.lock() .lock()
.await .await
.profiles .profiles
.set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?; .set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?;
self.platform.set_throttle_thermal_policy(active)?; self.platform.set_platform_profile(active.as_str())?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
@@ -208,16 +208,16 @@ impl CtrlFanCurveZbus {
/// ///
/// Each platform_profile has a different default and the defualt can be /// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile. /// read only for the currently active profile.
async fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> { async fn reset_profile_curves(&self, profile: PlatformProfile) -> zbus::fdo::Result<()> {
let active = self.platform.get_throttle_thermal_policy()?; let active = self.platform.get_platform_profile()?;
self.platform.set_throttle_thermal_policy(profile.into())?; self.platform.set_platform_profile(profile.into())?;
self.config self.config
.lock() .lock()
.await .await
.profiles .profiles
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?; .set_active_curve_to_defaults((&active).into(), &mut find_fan_curve_node()?)?;
self.platform.set_throttle_thermal_policy(active)?; self.platform.set_platform_profile(active.as_str())?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
@@ -236,26 +236,31 @@ impl CtrlTask for CtrlFanCurveZbus {
} }
async fn create_tasks(&self, _signal_ctxt: SignalEmitter<'static>) -> Result<(), RogError> { async fn create_tasks(&self, _signal_ctxt: SignalEmitter<'static>) -> Result<(), RogError> {
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?; let watch_platform_profile = self.platform.monitor_platform_profile()?;
let platform = self.platform.clone(); let platform = self.platform.clone();
let config = self.config.clone(); let config = self.config.clone();
let fan_curves = self.config.clone(); let fan_curves = self.config.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut buffer = [0; 32]; let mut buffer = [0; 32];
if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) { if let Ok(mut stream) = watch_platform_profile.into_event_stream(&mut buffer) {
while (stream.next().await).is_some() { while (stream.next().await).is_some() {
debug!("watch_throttle_thermal_policy changed"); debug!("watch_platform_profile changed");
if let Ok(profile) = platform.get_throttle_thermal_policy().map_err(|e| { if let Ok(profile) =
error!("get_throttle_thermal_policy error: {e}"); platform
}) { .get_platform_profile()
.map(|p| p.into())
.map_err(|e| {
error!("get_platform_profile error: {e}");
})
{
if profile != config.lock().await.current { if profile != config.lock().await.current {
fan_curves fan_curves
.lock() .lock()
.await .await
.profiles .profiles
.write_profile_curve_to_platform( .write_profile_curve_to_platform(
profile.into(), profile,
&mut find_fan_curve_node().unwrap() &mut find_fan_curve_node().unwrap()
) )
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e)) .map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
@@ -274,7 +279,7 @@ impl CtrlTask for CtrlFanCurveZbus {
impl crate::Reloadable for CtrlFanCurveZbus { impl crate::Reloadable for CtrlFanCurveZbus {
/// Fetch the active profile and use that to set all related components up /// Fetch the active profile and use that to set all related components up
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
let active = self.platform.get_throttle_thermal_policy()?.into(); let active = self.platform.get_platform_profile()?.into();
let mut config = self.config.lock().await; let mut config = self.config.lock().await;
if let Ok(mut device) = find_fan_curve_node() { if let Ok(mut device) = find_fan_curve_node() {
config config
+240 -135
View File
@@ -1,19 +1,19 @@
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use config_traits::StdConfig; use config_traits::StdConfig;
use futures_util::lock::Mutex;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::asus_armoury::{AttrValue, FirmwareAttribute, FirmwareAttributes}; use rog_platform::asus_armoury::{AttrValue, FirmwareAttribute, FirmwareAttributes};
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP}; use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
use rog_platform::platform::{Properties, RogPlatform, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, Properties, RogPlatform};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex;
use zbus::fdo::Error as FdoErr; use zbus::fdo::Error as FdoErr;
use zbus::object_server::SignalEmitter; use zbus::object_server::SignalEmitter;
use zbus::{interface, Connection}; use zbus::{interface, Connection};
use crate::asus_armoury::set_config_or_default;
use crate::config::Config; use crate::config::Config;
use crate::error::RogError; use crate::error::RogError;
use crate::{task_watch_item, CtrlTask, ReloadAndNotify}; use crate::{task_watch_item, CtrlTask, ReloadAndNotify};
@@ -43,24 +43,27 @@ macro_rules! platform_get_value {
pub struct CtrlPlatform { pub struct CtrlPlatform {
power: AsusPower, power: AsusPower,
platform: RogPlatform, platform: RogPlatform,
attributes: FirmwareAttributes,
cpu_control: Option<CPUControl>, cpu_control: Option<CPUControl>,
config: Arc<Mutex<Config>> config: Arc<Mutex<Config>>
} }
impl CtrlPlatform { impl CtrlPlatform {
pub fn new( pub fn new(
platform: RogPlatform,
power: AsusPower,
attributes: FirmwareAttributes,
config: Arc<Mutex<Config>>, config: Arc<Mutex<Config>>,
config_path: &Path, config_path: &Path,
signal_context: SignalEmitter<'static> signal_context: SignalEmitter<'static>
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
let platform = RogPlatform::new()?;
let power = AsusPower::new()?;
let config1 = config.clone(); let config1 = config.clone();
let config_path = config_path.to_owned(); let config_path = config_path.to_owned();
let ret_self = CtrlPlatform { let ret_self = CtrlPlatform {
power, power,
platform, platform,
attributes,
config, config,
cpu_control: CPUControl::new() cpu_control: CPUControl::new()
.map_err(|e| error!("Couldn't get CPU control sysfs: {e}")) .map_err(|e| error!("Couldn't get CPU control sysfs: {e}"))
@@ -69,7 +72,7 @@ impl CtrlPlatform {
let mut inotify_self = ret_self.clone(); let mut inotify_self = ret_self.clone();
tokio::spawn(async move { tokio::spawn(async move {
use zbus::export::futures_util::StreamExt; use futures_util::StreamExt;
info!("Starting inotify watch for asusd config file"); info!("Starting inotify watch for asusd config file");
let mut buffer = [0; 32]; let mut buffer = [0; 32];
@@ -203,40 +206,38 @@ impl CtrlPlatform {
} }
} }
async fn get_config_epp_for_throttle(&self, throttle: ThrottlePolicy) -> CPUEPP { async fn get_config_epp_for_throttle(&self, throttle: PlatformProfile) -> CPUEPP {
match throttle { match throttle {
ThrottlePolicy::Balanced => self.config.lock().await.throttle_balanced_epp, PlatformProfile::Balanced => self.config.lock().await.profile_balanced_epp,
ThrottlePolicy::Performance => self.config.lock().await.throttle_performance_epp, PlatformProfile::Performance => self.config.lock().await.profile_performance_epp,
ThrottlePolicy::Quiet => self.config.lock().await.throttle_quiet_epp PlatformProfile::Quiet => self.config.lock().await.profile_quiet_epp
} }
} }
async fn update_policy_ac_or_bat(&self, power_plugged: bool, change_epp: bool) { async fn update_policy_ac_or_bat(&self, power_plugged: bool, change_epp: bool) {
if power_plugged && !self.config.lock().await.change_throttle_policy_on_ac { if power_plugged && !self.config.lock().await.change_platform_profile_on_ac {
debug!( debug!(
"Power status changed but set_throttle_policy_on_ac set false. Not setting the \ "Power status changed but set_platform_profile_on_ac set false. Not setting the \
thing" thing"
); );
return; return;
} }
if !power_plugged && !self.config.lock().await.change_throttle_policy_on_battery { if !power_plugged && !self.config.lock().await.change_platform_profile_on_battery {
debug!( debug!(
"Power status changed but set_throttle_policy_on_battery set false. Not setting \ "Power status changed but set_platform_profile_on_battery set false. Not setting \
the thing" the thing"
); );
return; return;
} }
let throttle = if power_plugged { let throttle = if power_plugged {
self.config.lock().await.throttle_policy_on_ac self.config.lock().await.platform_profile_on_ac
} else { } else {
self.config.lock().await.throttle_policy_on_battery self.config.lock().await.platform_profile_on_battery
}; };
debug!("Setting {throttle:?} before EPP"); debug!("Setting {throttle:?} before EPP");
let epp = self.get_config_epp_for_throttle(throttle).await; let epp = self.get_config_epp_for_throttle(throttle).await;
self.platform self.platform.set_platform_profile(throttle.into()).ok();
.set_throttle_thermal_policy(throttle.into())
.ok();
self.check_and_set_epp(epp, change_epp); self.check_and_set_epp(epp, change_epp);
} }
} }
@@ -278,7 +279,7 @@ impl CtrlPlatform {
Properties::ChargeControlEndThreshold Properties::ChargeControlEndThreshold
); );
platform_name!(throttle_thermal_policy, Properties::ThrottlePolicy); platform_name!(platform_profile, Properties::ThrottlePolicy);
supported supported
} }
@@ -316,121 +317,133 @@ impl CtrlPlatform {
/// Toggle to next platform_profile. Names provided by `Profiles`. /// Toggle to next platform_profile. Names provided by `Profiles`.
/// If fan-curves are supported will also activate a fan curve for profile. /// If fan-curves are supported will also activate a fan curve for profile.
async fn next_throttle_thermal_policy( async fn next_platform_profile(
&mut self, &mut self,
#[zbus(signal_context)] ctxt: SignalEmitter<'_> #[zbus(signal_context)] ctxt: SignalEmitter<'_>
) -> Result<(), FdoErr> { ) -> Result<(), FdoErr> {
let policy: ThrottlePolicy = let policy: PlatformProfile =
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into())?;
.map(|n| n.into())?; let policy = PlatformProfile::next(policy);
let policy = ThrottlePolicy::next(policy);
if self.platform.has_throttle_thermal_policy() { if self.platform.has_platform_profile() {
let change_epp = self.config.lock().await.throttle_policy_linked_epp; let change_epp = self.config.lock().await.platform_profile_linked_epp;
let epp = self.get_config_epp_for_throttle(policy).await; let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp); self.check_and_set_epp(epp, change_epp);
self.platform self.platform
.set_throttle_thermal_policy(policy.into()) .set_platform_profile(policy.into())
.map_err(|err| { .map_err(|err| {
warn!("throttle_thermal_policy {}", err); warn!("platform_profile {}", err);
FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}")) FdoErr::Failed(format!("RogPlatform: platform_profile: {err}"))
})?; })?;
Ok(self.throttle_thermal_policy_changed(&ctxt).await?) self.enable_ppt_group_changed(&ctxt).await?;
Ok(self.platform_profile_changed(&ctxt).await?)
} else { } else {
Err(FdoErr::NotSupported( Err(FdoErr::NotSupported(
"RogPlatform: throttle_thermal_policy not supported".to_owned() "RogPlatform: platform_profile not supported".to_owned()
)) ))
} }
} }
#[zbus(property)] #[zbus(property)]
fn throttle_thermal_policy(&self) -> Result<ThrottlePolicy, FdoErr> { fn platform_profile(&self) -> Result<PlatformProfile, FdoErr> {
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into())
.map(|n| n.into())
} }
#[zbus(property)] #[zbus(property)]
async fn set_throttle_thermal_policy(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> { async fn set_platform_profile(
&mut self,
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
policy: PlatformProfile
) -> Result<(), FdoErr> {
// TODO: watch for external changes // TODO: watch for external changes
if self.platform.has_throttle_thermal_policy() { if self.platform.has_platform_profile() {
let change_epp = self.config.lock().await.throttle_policy_linked_epp; let change_epp = self.config.lock().await.platform_profile_linked_epp;
let epp = self.get_config_epp_for_throttle(policy).await; let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp); self.check_and_set_epp(epp, change_epp);
self.config.lock().await.write(); self.config.lock().await.write();
// TODO: Need to get supported profiles here and ensure we translate to one
self.platform self.platform
.set_throttle_thermal_policy(policy.into()) .set_platform_profile(policy.into())
.map_err(|err| { .map_err(|err| {
warn!("throttle_thermal_policy {}", err); warn!("platform_profile {}", err);
FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}")) FdoErr::Failed(format!("RogPlatform: platform_profile: {err}"))
}) })?;
self.enable_ppt_group_changed(&ctxt).await?;
Ok(())
} else { } else {
Err(FdoErr::NotSupported( Err(FdoErr::NotSupported(
"RogPlatform: throttle_thermal_policy not supported".to_owned() "RogPlatform: platform_profile not supported".to_owned()
)) ))
} }
} }
#[zbus(property)] #[zbus(property)]
async fn throttle_policy_linked_epp(&self) -> Result<bool, FdoErr> { async fn platform_profile_linked_epp(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.throttle_policy_linked_epp) Ok(self.config.lock().await.platform_profile_linked_epp)
} }
#[zbus(property)] #[zbus(property)]
async fn set_throttle_policy_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> { async fn set_platform_profile_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> {
self.config.lock().await.throttle_policy_linked_epp = linked; self.config.lock().await.platform_profile_linked_epp = linked;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
#[zbus(property)] #[zbus(property)]
async fn throttle_policy_on_battery(&self) -> Result<ThrottlePolicy, FdoErr> { async fn platform_profile_on_battery(&self) -> Result<PlatformProfile, FdoErr> {
Ok(self.config.lock().await.throttle_policy_on_battery) Ok(self.config.lock().await.platform_profile_on_battery)
} }
#[zbus(property)] #[zbus(property)]
async fn set_throttle_policy_on_battery( async fn set_platform_profile_on_battery(
&mut self, &mut self,
policy: ThrottlePolicy #[zbus(signal_context)] ctxt: SignalEmitter<'_>,
policy: PlatformProfile
) -> Result<(), FdoErr> { ) -> Result<(), FdoErr> {
self.config.lock().await.throttle_policy_on_battery = policy; self.config.lock().await.platform_profile_on_battery = policy;
self.set_throttle_thermal_policy(policy).await?; self.set_platform_profile(ctxt, policy).await?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
#[zbus(property)] #[zbus(property)]
async fn change_throttle_policy_on_battery(&self) -> Result<bool, FdoErr> { async fn change_platform_profile_on_battery(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.change_throttle_policy_on_battery) Ok(self.config.lock().await.change_platform_profile_on_battery)
} }
#[zbus(property)] #[zbus(property)]
async fn set_change_throttle_policy_on_battery(&mut self, change: bool) -> Result<(), FdoErr> { async fn set_change_platform_profile_on_battery(&mut self, change: bool) -> Result<(), FdoErr> {
self.config.lock().await.change_throttle_policy_on_battery = change; self.config.lock().await.change_platform_profile_on_battery = change;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
#[zbus(property)] #[zbus(property)]
async fn throttle_policy_on_ac(&self) -> Result<ThrottlePolicy, FdoErr> { async fn platform_profile_on_ac(&self) -> Result<PlatformProfile, FdoErr> {
Ok(self.config.lock().await.throttle_policy_on_ac) Ok(self.config.lock().await.platform_profile_on_ac)
} }
#[zbus(property)] #[zbus(property)]
async fn set_throttle_policy_on_ac(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> { async fn set_platform_profile_on_ac(
self.config.lock().await.throttle_policy_on_ac = policy; &mut self,
self.set_throttle_thermal_policy(policy).await?; #[zbus(signal_context)] ctxt: SignalEmitter<'_>,
policy: PlatformProfile
) -> Result<(), FdoErr> {
self.config.lock().await.platform_profile_on_ac = policy;
self.set_platform_profile(ctxt, policy).await?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
#[zbus(property)] #[zbus(property)]
async fn change_throttle_policy_on_ac(&self) -> Result<bool, FdoErr> { async fn change_platform_profile_on_ac(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.change_throttle_policy_on_ac) Ok(self.config.lock().await.change_platform_profile_on_ac)
} }
#[zbus(property)] #[zbus(property)]
async fn set_change_throttle_policy_on_ac(&mut self, change: bool) -> Result<(), FdoErr> { async fn set_change_platform_profile_on_ac(&mut self, change: bool) -> Result<(), FdoErr> {
self.config.lock().await.change_throttle_policy_on_ac = change; self.config.lock().await.change_platform_profile_on_ac = change;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
@@ -438,14 +451,14 @@ impl CtrlPlatform {
/// The energy_performance_preference for the quiet throttle/platform /// The energy_performance_preference for the quiet throttle/platform
/// profile /// profile
#[zbus(property)] #[zbus(property)]
async fn throttle_quiet_epp(&self) -> Result<CPUEPP, FdoErr> { async fn profile_quiet_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_quiet_epp) Ok(self.config.lock().await.profile_quiet_epp)
} }
#[zbus(property)] #[zbus(property)]
async fn set_throttle_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { async fn set_profile_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp; let change_pp = self.config.lock().await.platform_profile_linked_epp;
self.config.lock().await.throttle_quiet_epp = epp; self.config.lock().await.profile_quiet_epp = epp;
self.check_and_set_epp(epp, change_pp); self.check_and_set_epp(epp, change_pp);
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
@@ -454,14 +467,14 @@ impl CtrlPlatform {
/// The energy_performance_preference for the balanced throttle/platform /// The energy_performance_preference for the balanced throttle/platform
/// profile /// profile
#[zbus(property)] #[zbus(property)]
async fn throttle_balanced_epp(&self) -> Result<CPUEPP, FdoErr> { async fn profile_balanced_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_balanced_epp) Ok(self.config.lock().await.profile_balanced_epp)
} }
#[zbus(property)] #[zbus(property)]
async fn set_throttle_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { async fn set_profile_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp; let change_pp = self.config.lock().await.platform_profile_linked_epp;
self.config.lock().await.throttle_balanced_epp = epp; self.config.lock().await.profile_balanced_epp = epp;
self.check_and_set_epp(epp, change_pp); self.check_and_set_epp(epp, change_pp);
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
@@ -470,18 +483,101 @@ impl CtrlPlatform {
/// The energy_performance_preference for the performance throttle/platform /// The energy_performance_preference for the performance throttle/platform
/// profile /// profile
#[zbus(property)] #[zbus(property)]
async fn throttle_performance_epp(&self) -> Result<CPUEPP, FdoErr> { async fn profile_performance_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_performance_epp) Ok(self.config.lock().await.profile_performance_epp)
} }
#[zbus(property)] #[zbus(property)]
async fn set_throttle_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { async fn set_profile_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp; let change_pp = self.config.lock().await.platform_profile_linked_epp;
self.config.lock().await.throttle_performance_epp = epp; self.config.lock().await.profile_performance_epp = epp;
self.check_and_set_epp(epp, change_pp); self.check_and_set_epp(epp, change_pp);
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
async fn enable_ppt_group(&self) -> Result<bool, FdoErr> {
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
Ok(self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.enabled)
}
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
async fn set_enable_ppt_group(&mut self, enable: bool) -> Result<(), FdoErr> {
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
if enable {
// Clone to reduce blocking
let tuning = self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.clone();
for attr in self.attributes.attributes() {
let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() {
// reset stored value
if let Some(tune) = self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.group
.get_mut(&name)
{
let value = tuning
.group
.get(&name)
.map(|v| AttrValue::Integer(*v))
.unwrap_or_else(|| attr.default_value().clone());
// restore default
attr.set_current_value(&value)?;
if let AttrValue::Integer(i) = value {
*tune = i
}
}
}
}
} else {
// finally, reapply the profile to ensure acpi does the thingy
self.platform.set_platform_profile(profile.into())?;
}
self.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.enabled = enable;
self.config.lock().await.write();
Ok(())
}
} }
impl crate::ZbusRun for CtrlPlatform { impl crate::ZbusRun for CtrlPlatform {
@@ -518,21 +614,20 @@ impl ReloadAndNotify for CtrlPlatform {
.or(Some(limit)); .or(Some(limit));
} }
if self.platform.has_throttle_thermal_policy() if self.platform.has_platform_profile()
&& config.throttle_policy_linked_epp != data.throttle_policy_linked_epp && config.platform_profile_linked_epp != data.platform_profile_linked_epp
{ {
let profile: ThrottlePolicy = let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
ThrottlePolicy::from_str(self.platform.get_platform_profile()?.as_str())?;
let epp = match profile { let epp = match profile {
ThrottlePolicy::Balanced => data.throttle_balanced_epp, PlatformProfile::Balanced => data.profile_balanced_epp,
ThrottlePolicy::Performance => data.throttle_performance_epp, PlatformProfile::Performance => data.profile_performance_epp,
ThrottlePolicy::Quiet => data.throttle_quiet_epp PlatformProfile::Quiet => data.profile_quiet_epp
}; };
warn!("setting epp to {epp:?}"); warn!("setting epp to {epp:?}");
self.check_and_set_epp(epp, true); self.check_and_set_epp(epp, true);
} }
// reload_and_notify!(throttle_thermal_policy, "throttle_thermal_policy"); // reload_and_notify!(platform_profile, "platform_profile");
*config = data; *config = data;
config.base_charge_control_end_threshold = config.base_charge_control_end_threshold =
@@ -556,8 +651,8 @@ impl crate::Reloadable for CtrlPlatform {
if let Ok(power_plugged) = self.power.get_online() { if let Ok(power_plugged) = self.power.get_online() {
self.config.lock().await.last_power_plugged = power_plugged; self.config.lock().await.last_power_plugged = power_plugged;
if self.platform.has_throttle_thermal_policy() { if self.platform.has_platform_profile() {
let change_epp = self.config.lock().await.throttle_policy_linked_epp; let change_epp = self.config.lock().await.platform_profile_linked_epp;
self.update_policy_ac_or_bat(power_plugged > 0, change_epp) self.update_policy_ac_or_bat(power_plugged > 0, change_epp)
.await; .await;
} }
@@ -581,6 +676,7 @@ impl CtrlTask for CtrlPlatform {
let platform1 = self.clone(); let platform1 = self.clone();
let platform2 = self.clone(); let platform2 = self.clone();
let platform3 = self.clone(); let platform3 = self.clone();
let signal_ctxt_copy = signal_ctxt.clone();
self.create_sys_event_tasks( self.create_sys_event_tasks(
move |sleeping| { move |sleeping| {
let platform1 = platform1.clone(); let platform1 = platform1.clone();
@@ -604,9 +700,9 @@ impl CtrlTask for CtrlPlatform {
} }
if let Ok(power_plugged) = platform1.power.get_online() { if let Ok(power_plugged) = platform1.power.get_online() {
if platform1.config.lock().await.last_power_plugged != power_plugged { if platform1.config.lock().await.last_power_plugged != power_plugged {
if !sleeping && platform1.platform.has_throttle_thermal_policy() { if !sleeping && platform1.platform.has_platform_profile() {
let change_epp = let change_epp =
platform1.config.lock().await.throttle_policy_linked_epp; platform1.config.lock().await.platform_profile_linked_epp;
platform1 platform1
.update_policy_ac_or_bat(power_plugged > 0, change_epp) .update_policy_ac_or_bat(power_plugged > 0, change_epp)
.await; .await;
@@ -648,10 +744,11 @@ impl CtrlTask for CtrlPlatform {
}, },
move |power_plugged| { move |power_plugged| {
let platform3 = platform3.clone(); let platform3 = platform3.clone();
let signal_ctxt_copy = signal_ctxt.clone();
// power change // power change
async move { async move {
if platform3.platform.has_throttle_thermal_policy() { if platform3.platform.has_platform_profile() {
let change_epp = platform3.config.lock().await.throttle_policy_linked_epp; let change_epp = platform3.config.lock().await.platform_profile_linked_epp;
platform3 platform3
.update_policy_ac_or_bat(power_plugged, change_epp) .update_policy_ac_or_bat(power_plugged, change_epp)
.await; .await;
@@ -661,6 +758,29 @@ impl CtrlTask for CtrlPlatform {
if platform3.power.has_charge_control_end_threshold() && !power_plugged { if platform3.power.has_charge_control_end_threshold() && !power_plugged {
platform3.restore_charge_limit().await; platform3.restore_charge_limit().await;
} }
if let Ok(profile) = platform3
.platform
.get_platform_profile()
.map(|p| p.into())
.map_err(|e| {
error!("Platform: get_platform_profile error: {e}");
})
{
// TODO: manage this better, shouldn't need to create every time
let attrs = FirmwareAttributes::new();
set_config_or_default(
&attrs,
&mut *platform3.config.lock().await,
power_plugged,
profile
)
.await;
platform3
.enable_ppt_group_changed(&signal_ctxt_copy)
.await
.ok();
}
} }
} }
) )
@@ -668,10 +788,10 @@ impl CtrlTask for CtrlPlatform {
// This spawns a new task for every item. // This spawns a new task for every item.
// TODO: find a better way to manage this // TODO: find a better way to manage this
self.watch_charge_control_end_threshold(signal_ctxt.clone()) self.watch_charge_control_end_threshold(signal_ctxt_copy.clone())
.await?; .await?;
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?; let watch_platform_profile = self.platform.monitor_platform_profile()?;
let ctrl = self.clone(); let ctrl = self.clone();
// Need a copy here, not ideal. But first use in asus_armoury.rs is // Need a copy here, not ideal. But first use in asus_armoury.rs is
@@ -680,53 +800,38 @@ impl CtrlTask for CtrlPlatform {
tokio::spawn(async move { tokio::spawn(async move {
use futures_lite::StreamExt; use futures_lite::StreamExt;
let mut buffer = [0; 32]; let mut buffer = [0; 32];
if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) { if let Ok(mut stream) = watch_platform_profile.into_event_stream(&mut buffer) {
while (stream.next().await).is_some() { while (stream.next().await).is_some() {
// this blocks // this blocks
debug!("Platform: watch_throttle_thermal_policy changed"); debug!("Platform: watch_platform_profile changed");
if let Ok(profile) = ctrl if let Ok(profile) = ctrl
.platform .platform
.get_throttle_thermal_policy() .get_platform_profile()
.map(ThrottlePolicy::from) .map(|p| p.into())
.map_err(|e| { .map_err(|e| {
error!("Platform: get_throttle_thermal_policy error: {e}"); error!("Platform: get_platform_profile error: {e}");
}) })
{ {
let change_epp = ctrl.config.lock().await.throttle_policy_linked_epp; let change_epp = ctrl.config.lock().await.platform_profile_linked_epp;
let epp = ctrl.get_config_epp_for_throttle(profile).await; let epp = ctrl.get_config_epp_for_throttle(profile).await;
ctrl.check_and_set_epp(epp, change_epp); ctrl.check_and_set_epp(epp, change_epp);
ctrl.throttle_thermal_policy_changed(&signal_ctxt) ctrl.platform_profile_changed(&signal_ctxt_copy).await.ok();
.await ctrl.enable_ppt_group_changed(&signal_ctxt_copy).await.ok();
.ok(); let power_plugged = ctrl
for attr in attrs.attributes().iter() { .power
let name: FirmwareAttribute = attr.name().into(); .get_online()
if name.is_ppt() { .map_err(|e| {
let mut do_default = false; error!("Could not get power status: {e:?}");
if let Some(tunings) = e
ctrl.config.lock().await.profile_tunings.get(&profile) })
{ .unwrap_or_default();
if let Some(tune) = tunings.get(&name) { set_config_or_default(
attr.set_current_value(AttrValue::Integer(*tune)) &attrs,
.map_err(|e| { &mut *ctrl.config.lock().await,
error!("Failed to set {}: {e}", <&str>::from(name)); power_plugged == 1,
}) profile
.ok(); )
} else { .await;
do_default = true;
}
} else {
do_default = true;
}
if do_default {
let default = attr.default_value().clone();
attr.set_current_value(default)
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
}
}
}
} }
} }
} }
+17 -2
View File
@@ -2,7 +2,6 @@ use std::env;
use std::error::Error; use std::error::Error;
use std::sync::Arc; use std::sync::Arc;
use ::zbus::export::futures_util::lock::Mutex;
use ::zbus::Connection; use ::zbus::Connection;
use asusd::asus_armoury::start_attributes_zbus; use asusd::asus_armoury::start_attributes_zbus;
use asusd::aura_manager::DeviceManager; use asusd::aura_manager::DeviceManager;
@@ -11,8 +10,11 @@ use asusd::ctrl_fancurves::CtrlFanCurveZbus;
use asusd::ctrl_platform::CtrlPlatform; use asusd::ctrl_platform::CtrlPlatform;
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME}; use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad1}; use config_traits::{StdConfig, StdConfigLoad1};
use futures_util::lock::Mutex;
use log::{error, info}; use log::{error, info};
use rog_platform::asus_armoury::FirmwareAttributes;
use rog_platform::platform::RogPlatform; use rog_platform::platform::RogPlatform;
use rog_platform::power::AsusPower;
use zbus::fdo::ObjectManager; use zbus::fdo::ObjectManager;
#[tokio::main] #[tokio::main]
@@ -67,7 +69,16 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// supported.add_to_server(&mut connection).await; // supported.add_to_server(&mut connection).await;
let platform = RogPlatform::new()?; // TODO: maybe needs async mutex? let platform = RogPlatform::new()?; // TODO: maybe needs async mutex?
start_attributes_zbus(&server, platform, config.clone()).await?; let power = AsusPower::new()?; // TODO: maybe needs async mutex?
let attributes = FirmwareAttributes::new();
start_attributes_zbus(
&server,
platform.clone(),
power.clone(),
attributes.clone(),
config.clone()
)
.await?;
match CtrlFanCurveZbus::new() { match CtrlFanCurveZbus::new() {
Ok(ctrl) => { Ok(ctrl) => {
@@ -80,6 +91,9 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
} }
match CtrlPlatform::new( match CtrlPlatform::new(
platform,
power,
attributes,
config.clone(), config.clone(),
&cfg_path, &cfg_path,
CtrlPlatform::signal_context(&server)? CtrlPlatform::signal_context(&server)?
@@ -98,6 +112,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// Request dbus name after finishing initalizing all functions // Request dbus name after finishing initalizing all functions
server.request_name(DBUS_NAME).await?; server.request_name(DBUS_NAME).await?;
info!("Startup success, begining dbus server loop");
loop { loop {
// This is just a blocker to idle and ensure the reator reacts // This is just a blocker to idle and ensure the reator reacts
server.executor().tick().await; server.executor().tick().await;
+1 -1
View File
@@ -67,7 +67,7 @@ macro_rules! task_watch_item {
&self, &self,
signal_ctxt: SignalEmitter<'static>, signal_ctxt: SignalEmitter<'static>,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
use zbus::export::futures_util::StreamExt; use futures_util::StreamExt;
let ctrl = self.clone(); let ctrl = self.clone();
concat_idents::concat_idents!(watch_fn = monitor_, $name { concat_idents::concat_idents!(watch_fn = monitor_, $name {
+2 -1
View File
@@ -6,7 +6,7 @@ After=nvidia-powerd.service systemd-udevd.service
[Service] [Service]
Environment=IS_SERVICE=1 Environment=IS_SERVICE=1
Environment=RUST_LOG="info" Environment=RUST_LOG="debug"
# required to prevent init issues with hid_asus and MCU # required to prevent init issues with hid_asus and MCU
ExecStartPre=/bin/sleep 1 ExecStartPre=/bin/sleep 1
ExecStart=/usr/bin/asusd ExecStart=/usr/bin/asusd
@@ -16,3 +16,4 @@ Type=dbus
BusName=xyz.ljones.Asusd BusName=xyz.ljones.Asusd
SELinuxContext=system_u:system_r:unconfined_t:s0 SELinuxContext=system_u:system_r:unconfined_t:s0
#SELinuxContext=system_u:object_r:modules_object_t:s0 #SELinuxContext=system_u:object_r:modules_object_t:s0
TimeoutSec=10
+29 -11
View File
@@ -35,6 +35,15 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "FA617NS",
product_id: "",
layout_name: "fa617ns",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
device_name: "FX505", device_name: "FX505",
product_id: "", product_id: "",
@@ -80,6 +89,15 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "FX617X",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
device_name: "FX705D", device_name: "FX705D",
product_id: "", product_id: "",
@@ -134,12 +152,21 @@
advanced_type: PerKey, advanced_type: PerKey,
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
(
device_name: "G513RW",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
( (
device_name: "G513RC", device_name: "G513RC",
product_id: "", product_id: "",
layout_name: "g513i", layout_name: "g513i",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse], basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [], basic_zones: [Key1, Key2, Key3, Key4],
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]), advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
@@ -548,15 +575,6 @@
advanced_type: Zoned([SingleZone]), advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "GA605W",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [],
advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard],
),
( (
device_name: "GL503", device_name: "GL503",
product_id: "", product_id: "",
@@ -854,4 +872,4 @@
advanced_type: None, advanced_type: None,
power_zones: [Ally], power_zones: [Ally],
), ),
]) ])
+1
View File
@@ -41,6 +41,7 @@ zbus.workspace = true
dirs.workspace = true dirs.workspace = true
notify-rust.workspace = true notify-rust.workspace = true
concat-idents.workspace = true concat-idents.workspace = true
futures-util.workspace = true
versions.workspace = true versions.workspace = true
+1 -3
View File
@@ -5,7 +5,6 @@ use slint_build::CompilerConfiguration;
fn main() { fn main() {
// write_locales(); // write_locales();
let root = env!("CARGO_MANIFEST_DIR"); let root = env!("CARGO_MANIFEST_DIR");
let mut main = PathBuf::from_str(root).unwrap(); let mut main = PathBuf::from_str(root).unwrap();
main.push("ui/main_window.slint"); main.push("ui/main_window.slint");
@@ -14,13 +13,12 @@ fn main() {
include.push("ui"); include.push("ui");
slint_build::print_rustc_flags().unwrap(); slint_build::print_rustc_flags().unwrap();
// slint_build::compile("ui/main_window.slint").unwrap();
slint_build::compile_with_config( slint_build::compile_with_config(
main, main,
CompilerConfiguration::new() CompilerConfiguration::new()
// .embed_resources(EmbedResourcesKind::EmbedFiles) // .embed_resources(EmbedResourcesKind::EmbedFiles)
.with_include_paths(vec![include]) .with_include_paths(vec![include])
.with_style("fluent-dark".into()) .with_style("fluent".into())
) )
.unwrap(); .unwrap();
} }
@@ -1,7 +1,6 @@
[Desktop Entry] [Desktop Entry]
Version=1.0 Version=1.0
Type=Application Type=Application
Name=ROG Control Center Name=ROG Control Center
Comment=Make your ASUS ROG Laptop go Brrrrr! Comment=Make your ASUS ROG Laptop go Brrrrr!
Categories=Settings Categories=Settings
+48 -16
View File
@@ -1,4 +1,4 @@
use std::env::args; use std::env::{self, args};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::exit; use std::process::exit;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
@@ -32,6 +32,12 @@ async fn main() -> Result<()> {
.format_timestamp(None) .format_timestamp(None)
.init(); .init();
// If we're running under gamescope we have to set WAYLAND_DISPLAY for winit to
// use
if let Ok(gamescope) = env::var("GAMESCOPE_WAYLAND_DISPLAY") {
env::set_var("WAYLAND_DISPLAY", gamescope);
}
// Try to open a proxy and check for app state first // Try to open a proxy and check for app state first
{ {
let user_con = zbus::blocking::Connection::session()?; let user_con = zbus::blocking::Connection::session()?;
@@ -49,7 +55,12 @@ async fn main() -> Result<()> {
let self_version = env!("CARGO_PKG_VERSION"); let self_version = env!("CARGO_PKG_VERSION");
let zbus_con = zbus::blocking::Connection::system()?; let zbus_con = zbus::blocking::Connection::system()?;
let platform_proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&zbus_con)?; let platform_proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&zbus_con)?;
let asusd_version = platform_proxy.version().unwrap(); let asusd_version = platform_proxy
.version()
.map_err(|e| {
println!("Could not get asusd version: {e:?}\nIs asusd.service running?");
})
.unwrap();
if asusd_version != self_version { if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}"); println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return Ok(()); return Ok(());
@@ -79,7 +90,7 @@ async fn main() -> Result<()> {
let board_name = dmi.board_name; let board_name = dmi.board_name;
let prod_family = dmi.product_family; let prod_family = dmi.product_family;
info!("Running on {board_name}, product: {prod_family}"); info!("Running on {board_name}, product: {prod_family}");
let is_rog_ally = prod_family == "RC71L"; let is_rog_ally = prod_family == "RC71L" || prod_family == "RC72L";
let args: Vec<String> = args().skip(1).collect(); let args: Vec<String> = args().skip(1).collect();
@@ -115,7 +126,9 @@ async fn main() -> Result<()> {
config.enable_tray_icon = false; config.enable_tray_icon = false;
config.run_in_background = false; config.run_in_background = false;
config.startup_in_background = false; config.startup_in_background = false;
config.start_fullscreen = true;
} }
config.write();
let enable_tray_icon = config.enable_tray_icon; let enable_tray_icon = config.enable_tray_icon;
let startup_in_background = config.startup_in_background; let startup_in_background = config.startup_in_background;
@@ -131,8 +144,8 @@ async fn main() -> Result<()> {
// i_slint_backend_selector::with_platform(|_| Ok(())).unwrap(); // i_slint_backend_selector::with_platform(|_| Ok(())).unwrap();
if !startup_in_background { if !startup_in_background {
if let Ok(mut lock) = app_state.lock() { if let Ok(mut app_state) = app_state.lock() {
*lock = AppState::MainWindowShouldOpen; *app_state = AppState::MainWindowShouldOpen;
} }
} }
@@ -149,15 +162,15 @@ async fn main() -> Result<()> {
let mut state = AppState::StartingUp; let mut state = AppState::StartingUp;
loop { loop {
// save as a var, don't hold the lock the entire time or deadlocks happen // save as a var, don't hold the lock the entire time or deadlocks happen
if let Ok(lock) = app_state.lock() { if let Ok(app_state) = app_state.lock() {
state = *lock; state = *app_state;
} }
// This sleep is required to give the event loop time to react // This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300)); sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen { if state == AppState::MainWindowShouldOpen {
if let Ok(mut lock) = app_state.lock() { if let Ok(mut app_state) = app_state.lock() {
*lock = AppState::MainWindowOpen; *app_state = AppState::MainWindowOpen;
} }
let config_copy = config.clone(); let config_copy = config.clone();
@@ -169,20 +182,39 @@ async fn main() -> Result<()> {
if let Some(ui) = ui.as_mut() { if let Some(ui) = ui.as_mut() {
ui.window().show().unwrap(); ui.window().show().unwrap();
ui.window().on_close_requested(move || { ui.window().on_close_requested(move || {
if let Ok(mut lock) = app_state_copy.lock() { if let Ok(mut app_state) = app_state_copy.lock() {
*lock = AppState::MainWindowClosed; *app_state = AppState::MainWindowClosed;
} }
slint::CloseRequestResponse::HideWindow slint::CloseRequestResponse::HideWindow
}); });
} else { } else {
let config_copy_2 = config_copy.clone();
let newui = setup_window(config_copy); let newui = setup_window(config_copy);
newui.window().show().unwrap();
newui.window().on_close_requested(move || { newui.window().on_close_requested(move || {
if let Ok(mut lock) = app_state_copy.lock() { if let Ok(mut app_state) = app_state_copy.lock() {
*lock = AppState::MainWindowClosed; *app_state = AppState::MainWindowClosed;
} }
slint::CloseRequestResponse::HideWindow slint::CloseRequestResponse::HideWindow
}); });
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::RenderingSetup = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen =
config.lock().is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
}
})
.ok();
ui.replace(newui); ui.replace(newui);
} }
}); });
@@ -192,8 +224,8 @@ async fn main() -> Result<()> {
slint::quit_event_loop().unwrap(); slint::quit_event_loop().unwrap();
exit(0); exit(0);
} else if state != AppState::MainWindowOpen { } else if state != AppState::MainWindowOpen {
if let Ok(lock) = config.lock() { if let Ok(config) = config.lock() {
if !lock.run_in_background { if !config.run_in_background {
slint::quit_event_loop().unwrap(); slint::quit_event_loop().unwrap();
exit(0); exit(0);
} }
+9 -1
View File
@@ -208,7 +208,15 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
} }
} }
} }
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}") Err(e) => match e {
zbus::Error::MethodError(_, _, message) => {
warn!(
"Couldn't get mode from supergfxd: {message:?}, the supergfxd service \
may not be running or installed"
)
}
_ => warn!("Couldn't get mode from supergfxd: {e:?}")
}
} }
info!("Started ROGTray"); info!("Started ROGTray");
+10 -10
View File
@@ -1,24 +1,24 @@
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use crate::{FanType, Profile}; use crate::{FanType, Profile};
impl From<Profile> for ThrottlePolicy { impl From<Profile> for PlatformProfile {
fn from(value: Profile) -> Self { fn from(value: Profile) -> Self {
match value { match value {
Profile::Balanced => ThrottlePolicy::Balanced, Profile::Balanced => PlatformProfile::Balanced,
Profile::Performance => ThrottlePolicy::Performance, Profile::Performance => PlatformProfile::Performance,
Profile::Quiet => ThrottlePolicy::Quiet Profile::Quiet => PlatformProfile::Quiet
} }
} }
} }
impl From<ThrottlePolicy> for Profile { impl From<PlatformProfile> for Profile {
fn from(value: ThrottlePolicy) -> Self { fn from(value: PlatformProfile) -> Self {
match value { match value {
ThrottlePolicy::Balanced => Profile::Balanced, PlatformProfile::Balanced => Profile::Balanced,
ThrottlePolicy::Performance => Profile::Performance, PlatformProfile::Performance => Profile::Performance,
ThrottlePolicy::Quiet => Profile::Quiet PlatformProfile::Quiet => Profile::Quiet
} }
} }
} }
+7 -10
View File
@@ -6,8 +6,9 @@ pub mod setup_system;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use config_traits::StdConfig; use config_traits::StdConfig;
use log::warn;
use rog_dbus::list_iface_blocking; use rog_dbus::list_iface_blocking;
use slint::{ComponentHandle, PhysicalSize, SharedString, Weak}; use slint::{ComponentHandle, SharedString, Weak};
use crate::config::Config; use crate::config::Config;
use crate::ui::setup_anime::setup_anime_page; use crate::ui::setup_anime::setup_anime_page;
@@ -82,16 +83,11 @@ pub fn show_toast(
} }
pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow { pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
slint::set_xdg_app_id("rog-control-center")
.map_err(|e| warn!("Couldn't set application ID: {e:?}"))
.ok();
let ui = MainWindow::new().unwrap(); let ui = MainWindow::new().unwrap();
if let Ok(lock) = config.try_lock() { ui.window().show().unwrap();
let fullscreen = lock.start_fullscreen;
let width = lock.fullscreen_width;
let height = lock.fullscreen_height;
if fullscreen {
ui.window().set_fullscreen(fullscreen);
ui.window().set_size(PhysicalSize { width, height });
}
};
let available = list_iface_blocking().unwrap_or_default(); let available = list_iface_blocking().unwrap_or_default();
ui.set_sidebar_items_avilable( ui.set_sidebar_items_avilable(
@@ -125,6 +121,7 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
if available.contains(&"xyz.ljones.FanCurves".to_string()) { if available.contains(&"xyz.ljones.FanCurves".to_string()) {
setup_fan_curve_page(&ui, config); setup_fan_curve_page(&ui, config);
} }
ui ui
} }
+7 -7
View File
@@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex};
use log::{error, info}; use log::{error, info};
use rog_dbus::zbus_fan_curves::FanCurvesProxy; use rog_dbus::zbus_fan_curves::FanCurvesProxy;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use slint::{ComponentHandle, Model, Weak}; use slint::{ComponentHandle, Model, Weak};
@@ -109,21 +109,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let handle_copy = handle.clone(); let handle_copy = handle.clone();
// Do initial setup // Do initial setup
let Ok(balanced) = fans let Ok(balanced) = fans
.fan_curve_data(ThrottlePolicy::Balanced) .fan_curve_data(PlatformProfile::Balanced)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(perf) = fans let Ok(perf) = fans
.fan_curve_data(ThrottlePolicy::Performance) .fan_curve_data(PlatformProfile::Performance)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(quiet) = fans let Ok(quiet) = fans
.fan_curve_data(ThrottlePolicy::Quiet) .fan_curve_data(PlatformProfile::Quiet)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
@@ -144,21 +144,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
return; return;
} }
let Ok(balanced) = fans let Ok(balanced) = fans
.fan_curve_data(ThrottlePolicy::Balanced) .fan_curve_data(PlatformProfile::Balanced)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(perf) = fans let Ok(perf) = fans
.fan_curve_data(ThrottlePolicy::Performance) .fan_curve_data(PlatformProfile::Performance)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(quiet) = fans let Ok(quiet) = fans
.fan_curve_data(ThrottlePolicy::Quiet) .fan_curve_data(PlatformProfile::Quiet)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
+136 -46
View File
@@ -16,12 +16,12 @@ use crate::{set_ui_callbacks, set_ui_props_async, AttrMinMax, MainWindow, System
const MINMAX: AttrMinMax = AttrMinMax { const MINMAX: AttrMinMax = AttrMinMax {
min: 0, min: 0,
max: 0, max: 0,
val: -1.0 current: -1.0
}; };
pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) { pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
let platform = PlatformProxyBlocking::new(&conn).unwrap(); let platform = PlatformProxyBlocking::builder(&conn).build().unwrap();
// let armoury_attrs = // let armoury_attrs =
// find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap(); // find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap();
@@ -29,7 +29,8 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
ui.global::<SystemPageData>() ui.global::<SystemPageData>()
.set_charge_control_end_threshold(-1.0); .set_charge_control_end_threshold(-1.0);
ui.global::<SystemPageData>() ui.global::<SystemPageData>()
.set_throttle_thermal_policy(-1); .set_charge_control_enabled(false);
ui.global::<SystemPageData>().set_platform_profile(-1);
ui.global::<SystemPageData>().set_panel_overdrive(-1); ui.global::<SystemPageData>().set_panel_overdrive(-1);
ui.global::<SystemPageData>().set_boot_sound(-1); ui.global::<SystemPageData>().set_boot_sound(-1);
ui.global::<SystemPageData>().set_mini_led_mode(-1); ui.global::<SystemPageData>().set_mini_led_mode(-1);
@@ -41,12 +42,17 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX); ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX);
ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX); ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX);
ui.global::<SystemPageData>().set_nv_temp_target(MINMAX); ui.global::<SystemPageData>().set_nv_temp_target(MINMAX);
ui.global::<SystemPageData>().set_ppt_enabled(false);
ui.global::<SystemPageData>()
.set_ppt_enabled_available(false);
let sys_props = platform.supported_properties().unwrap(); let sys_props = platform.supported_properties().unwrap();
log::debug!("Available system properties: {sys_props:?}"); log::debug!("Available system properties: {:?}", &sys_props);
if sys_props.contains(&Properties::ChargeControlEndThreshold) { if sys_props.contains(&Properties::ChargeControlEndThreshold) {
ui.global::<SystemPageData>() ui.global::<SystemPageData>()
.set_charge_control_end_threshold(60.0); .set_charge_control_end_threshold(60.0);
ui.global::<SystemPageData>()
.set_charge_control_enabled(true);
} }
} }
@@ -94,13 +100,13 @@ macro_rules! init_minmax_property {
tokio::spawn(async move { tokio::spawn(async move {
let min = proxy_copy.min_value().await.unwrap(); let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap(); let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32; let current = proxy_copy.current_value().await.unwrap() as f32;
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
handle handle
.global::<SystemPageData>() .global::<SystemPageData>()
.setter(AttrMinMax { min, max, val }); .setter(AttrMinMax { min, max, current });
}); });
}) })
.ok(); .ok();
@@ -132,6 +138,23 @@ macro_rules! setup_callback {
}; };
} }
// For handling callbacks from UI value changes
macro_rules! setup_callback_restore_default {
($property:ident, $handle:expr, $attr:expr) => {
let proxy_copy = $attr.clone();
concat_idents!(on_callback = on_cb_default_, $property {
$handle
.global::<SystemPageData>()
.on_callback(move || {
let proxy_copy = proxy_copy.clone();
tokio::spawn(async move {
proxy_copy.restore_default().await.ok();
});
});
});
};
}
macro_rules! setup_external { macro_rules! setup_external {
($property:ident, $type:tt, $handle:expr, $attr:expr, $value:expr) => {{ ($property:ident, $type:tt, $handle:expr, $attr:expr, $value:expr) => {{
// EXTERNAL CHANGES // EXTERNAL CHANGES
@@ -140,7 +163,7 @@ macro_rules! setup_external {
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
tokio::spawn(async move { tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await; let mut x = proxy_copy.receive_current_value_changed().await;
use zbus::export::futures_util::StreamExt; use futures_util::StreamExt;
while let Some(e) = x.next().await { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
handle_copy handle_copy
@@ -158,49 +181,59 @@ macro_rules! setup_external {
} }
// For handling external value changes // For handling external value changes
macro_rules! setup_minmax_external { macro_rules! setup_value_watch {
($property:ident, $handle:expr, $attr:expr, $platform:expr) => { ($property:ident, $handle:expr, $proxy:expr, $value_type:ident $($conv: tt)*) => {
let handle_copy = $handle.as_weak(); let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone(); let proxy_copy = $proxy.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await; let mut x = concat_idents!(recv = receive_, $value_type, _value_changed {
use zbus::export::futures_util::StreamExt; proxy_copy.recv().await
});
use futures_util::StreamExt;
while let Some(e) = x.next().await { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
concat_idents!(getter = get_, $property { concat_idents!(getter = get_, $property {
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
let mut tmp: AttrMinMax = let mut tmp: AttrMinMax =
handle.global::<SystemPageData>().getter(); handle.global::<SystemPageData>().getter();
tmp.val = out as f32; tmp.$value_type = out $($conv)*;
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
handle.global::<SystemPageData>().setter(tmp); handle.global::<SystemPageData>().setter(tmp);
}); });
}) })
.ok(); .ok();
}); });
} }
} }
}); });
};
}
macro_rules! setup_minmax_external {
($property:ident, $handle:expr, $attr:expr, $platform:expr) => {
setup_value_watch!($property, $handle, $attr, current as f32);
setup_value_watch!($property, $handle, $attr, min);
setup_value_watch!($property, $handle, $attr, max);
let handle_copy = $handle.as_weak(); let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone(); let proxy_copy = $attr.clone();
let platform_proxy_copy = $platform.clone(); let platform_proxy_copy = $platform.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut x = platform_proxy_copy.receive_throttle_thermal_policy_changed().await; let mut x = platform_proxy_copy.receive_platform_profile_changed().await;
use zbus::export::futures_util::StreamExt; use futures_util::StreamExt;
while let Some(e) = x.next().await { while let Some(e) = x.next().await {
if let Ok(_) = e.get().await { if let Ok(_) = e.get().await {
debug!("receive_throttle_thermal_policy_changed, getting new {}", stringify!(attr)); debug!("receive_platform_profile_changed, getting new {}", stringify!(attr));
let min = proxy_copy.min_value().await.unwrap(); let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap(); let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32; let current = proxy_copy.current_value().await.unwrap() as f32;
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
handle handle
.global::<SystemPageData>() .global::<SystemPageData>()
.setter(AttrMinMax { min, max, val }); .setter(AttrMinMax { min, max, current });
}); });
}) })
.ok(); .ok();
@@ -233,7 +266,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
tokio::spawn(async move { tokio::spawn(async move {
// Create the connections/proxies here to prevent future delays in process // Create the connections/proxies here to prevent future delays in process
let conn = zbus::Connection::system().await.unwrap(); let conn = zbus::Connection::system().await.unwrap();
let platform = PlatformProxy::new(&conn).await.unwrap(); let platform = PlatformProxy::builder(&conn).build().await.unwrap();
set_ui_props_async!( set_ui_props_async!(
handle, handle,
@@ -242,29 +275,48 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
charge_control_end_threshold charge_control_end_threshold
); );
set_ui_props_async!(handle, platform, SystemPageData, throttle_thermal_policy); set_ui_props_async!(handle, platform, SystemPageData, platform_profile);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_linked_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_balanced_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_performance_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_quiet_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_battery);
set_ui_props_async!( set_ui_props_async!(
handle, handle,
platform, platform,
SystemPageData, SystemPageData,
change_throttle_policy_on_battery platform_profile_linked_epp
); );
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_ac); set_ui_props_async!(handle, platform, SystemPageData, profile_balanced_epp);
set_ui_props_async!(handle, platform, SystemPageData, profile_performance_epp);
set_ui_props_async!(handle, platform, SystemPageData, profile_quiet_epp);
set_ui_props_async!( set_ui_props_async!(
handle, handle,
platform, platform,
SystemPageData, SystemPageData,
change_throttle_policy_on_ac platform_profile_on_battery
); );
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_platform_profile_on_battery
);
set_ui_props_async!(handle, platform, SystemPageData, platform_profile_on_ac);
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_platform_profile_on_ac
);
set_ui_props_async!(handle, platform, SystemPageData, enable_ppt_group);
let platform_copy = platform.clone(); let platform_copy = platform.clone();
handle handle
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform_copy.enable_ppt_group(as bool),
"Applied PPT group settings {}",
"Setting PPT group settings failed"
);
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as f32), SystemPageData(as f32),
platform_copy.charge_control_end_threshold(as u8), platform_copy.charge_control_end_threshold(as u8),
@@ -273,56 +325,56 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform_copy.throttle_thermal_policy(.into()), platform_copy.platform_profile(.into()),
"Throttle policy set to {}", "Throttle policy set to {}",
"Setting Throttle policy failed" "Setting Throttle policy failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform_copy.throttle_balanced_epp(.into()), platform_copy.profile_balanced_epp(.into()),
"Throttle policy EPP set to {}", "Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed" "Setting Throttle policy EPP failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform_copy.throttle_performance_epp(.into()), platform_copy.profile_performance_epp(.into()),
"Throttle policy EPP set to {}", "Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed" "Setting Throttle policy EPP failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform_copy.throttle_quiet_epp(.into()), platform_copy.profile_quiet_epp(.into()),
"Throttle policy EPP set to {}", "Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed" "Setting Throttle policy EPP failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
SystemPageData(), SystemPageData(),
platform_copy.throttle_policy_linked_epp(), platform_copy.platform_profile_linked_epp(),
"Throttle policy linked to EPP: {}", "Throttle policy linked to EPP: {}",
"Setting Throttle policy linked to EPP failed" "Setting Throttle policy linked to EPP failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform_copy.throttle_policy_on_ac(.into()), platform_copy.platform_profile_on_ac(.into()),
"Throttle policy on AC set to {}", "Throttle policy on AC set to {}",
"Setting Throttle policy on AC failed" "Setting Throttle policy on AC failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as bool), SystemPageData(as bool),
platform_copy.change_throttle_policy_on_ac(.into()), platform_copy.change_platform_profile_on_ac(.into()),
"Throttle policy on AC enabled: {}", "Throttle policy on AC enabled: {}",
"Setting Throttle policy on AC failed" "Setting Throttle policy on AC failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as i32), SystemPageData(as i32),
platform_copy.throttle_policy_on_battery(.into()), platform_copy.platform_profile_on_battery(.into()),
"Throttle policy on abttery set to {}", "Throttle policy on abttery set to {}",
"Setting Throttle policy on battery failed" "Setting Throttle policy on battery failed"
); );
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as bool), SystemPageData(as bool),
platform_copy.change_throttle_policy_on_battery(.into()), platform_copy.change_platform_profile_on_battery(.into()),
"Throttle policy on battery enabled: {}", "Throttle policy on battery enabled: {}",
"Setting Throttle policy on AC failed" "Setting Throttle policy on AC failed"
); );
@@ -355,44 +407,82 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
FirmwareAttribute::ApuMem => {} FirmwareAttribute::ApuMem => {}
FirmwareAttribute::CoresPerformance => {} FirmwareAttribute::CoresPerformance => {}
FirmwareAttribute::CoresEfficiency => {} FirmwareAttribute::CoresEfficiency => {}
FirmwareAttribute::PptEnabled => {
init_property!(ppt_enabled, handle, value, bool);
setup_callback!(ppt_enabled, handle, attr, bool);
let handle_copy = handle.as_weak();
let proxy_copy = attr.clone();
tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await;
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
.upgrade_in_event_loop(move |handle| {
handle
.global::<SystemPageData>()
.set_enable_ppt_group(out == 1);
handle
.global::<SystemPageData>()
.set_ppt_enabled(out == 1);
})
.ok();
}
}
});
handle
.global::<SystemPageData>()
.set_ppt_enabled_available(true);
handle
.global::<SystemPageData>()
.set_enable_ppt_group(value == 1);
}
FirmwareAttribute::PptPl1Spl => { FirmwareAttribute::PptPl1Spl => {
init_minmax_property!(ppt_pl1_spl, handle, attr); init_minmax_property!(ppt_pl1_spl, handle, attr);
setup_callback!(ppt_pl1_spl, handle, attr, i32); setup_callback!(ppt_pl1_spl, handle, attr, i32);
setup_callback_restore_default!(ppt_pl1_spl, handle, attr);
setup_minmax_external!(ppt_pl1_spl, handle, attr, platform); setup_minmax_external!(ppt_pl1_spl, handle, attr, platform);
} }
FirmwareAttribute::PptPl2Sppt => { FirmwareAttribute::PptPl2Sppt => {
init_minmax_property!(ppt_pl2_sppt, handle, attr); init_minmax_property!(ppt_pl2_sppt, handle, attr);
setup_callback!(ppt_pl2_sppt, handle, attr, i32); setup_callback!(ppt_pl2_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_pl2_sppt, handle, attr);
setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform); setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform);
} }
FirmwareAttribute::PptPl3Fppt => { FirmwareAttribute::PptPl3Fppt => {
init_minmax_property!(ppt_pl3_fppt, handle, attr); init_minmax_property!(ppt_pl3_fppt, handle, attr);
setup_callback!(ppt_pl3_fppt, handle, attr, i32); setup_callback!(ppt_pl3_fppt, handle, attr, i32);
setup_callback_restore_default!(ppt_pl3_fppt, handle, attr);
setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform); setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform);
} }
FirmwareAttribute::PptFppt => { FirmwareAttribute::PptFppt => {
init_minmax_property!(ppt_fppt, handle, attr); init_minmax_property!(ppt_fppt, handle, attr);
setup_callback!(ppt_fppt, handle, attr, i32); setup_callback!(ppt_fppt, handle, attr, i32);
setup_callback_restore_default!(ppt_fppt, handle, attr);
setup_minmax_external!(ppt_fppt, handle, attr, platform); setup_minmax_external!(ppt_fppt, handle, attr, platform);
} }
FirmwareAttribute::PptApuSppt => { FirmwareAttribute::PptApuSppt => {
init_minmax_property!(ppt_apu_sppt, handle, attr); init_minmax_property!(ppt_apu_sppt, handle, attr);
setup_callback!(ppt_apu_sppt, handle, attr, i32); setup_callback!(ppt_apu_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_apu_sppt, handle, attr);
setup_minmax_external!(ppt_apu_sppt, handle, attr, platform); setup_minmax_external!(ppt_apu_sppt, handle, attr, platform);
} }
FirmwareAttribute::PptPlatformSppt => { FirmwareAttribute::PptPlatformSppt => {
init_minmax_property!(ppt_platform_sppt, handle, attr); init_minmax_property!(ppt_platform_sppt, handle, attr);
setup_callback!(ppt_platform_sppt, handle, attr, i32); setup_callback!(ppt_platform_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_platform_sppt, handle, attr);
setup_minmax_external!(ppt_platform_sppt, handle, attr, platform); setup_minmax_external!(ppt_platform_sppt, handle, attr, platform);
} }
FirmwareAttribute::NvDynamicBoost => { FirmwareAttribute::NvDynamicBoost => {
init_minmax_property!(nv_dynamic_boost, handle, attr); init_minmax_property!(nv_dynamic_boost, handle, attr);
setup_callback!(nv_dynamic_boost, handle, attr, i32); setup_callback!(nv_dynamic_boost, handle, attr, i32);
setup_callback_restore_default!(nv_dynamic_boost, handle, attr);
setup_minmax_external!(nv_dynamic_boost, handle, attr, platform); setup_minmax_external!(nv_dynamic_boost, handle, attr, platform);
} }
FirmwareAttribute::NvTempTarget => { FirmwareAttribute::NvTempTarget => {
init_minmax_property!(nv_temp_target, handle, attr); init_minmax_property!(nv_temp_target, handle, attr);
setup_callback!(nv_temp_target, handle, attr, i32); setup_callback!(nv_temp_target, handle, attr, i32);
setup_callback_restore_default!(nv_temp_target, handle, attr);
setup_minmax_external!(nv_temp_target, handle, attr, platform); setup_minmax_external!(nv_temp_target, handle, attr, platform);
} }
FirmwareAttribute::DgpuBaseTgp => {} FirmwareAttribute::DgpuBaseTgp => {}
@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-01-18 10:11+0000\n" "POT-Creation-Date: 2025-02-10 09:04+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12,81 +12,287 @@ msgstr ""
"Language: \n" "Language: \n"
"Plural-Forms: nplurals=1; plural=0;\n" "Plural-Forms: nplurals=1; plural=0;\n"
#: rog-control-center/ui/pages/app_settings.slint:26 #: rog-control-center/ui/pages/system.slint:20
msgctxt "PageAppSettings" msgctxt "SystemPageData"
msgid "Run in background after closing"
msgstr ""
#: rog-control-center/ui/pages/app_settings.slint:34
msgctxt "PageAppSettings"
msgid "Start app in background (UI closed)"
msgstr ""
#: rog-control-center/ui/pages/app_settings.slint:42
msgctxt "PageAppSettings"
msgid "Enable system tray icon"
msgstr ""
#: rog-control-center/ui/pages/app_settings.slint:50
msgctxt "PageAppSettings"
msgid "Enable dGPU notifications"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:26
msgctxt "FanTab"
msgid "This fan is not avilable on this machine"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:34
msgctxt "FanTab"
msgid "Enabled"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:43
msgctxt "FanTab"
msgid "Apply"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:51
msgctxt "FanTab"
msgid "Cancel"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:59
msgctxt "FanTab"
msgid "Factory Default (all fans)"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:72
msgctxt "PageFans"
msgid "Balanced" msgid "Balanced"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/fans.slint:75 rog-control-center/ui/pages/fans.slint:134 rog-control-center/ui/pages/fans.slint:193 #: rog-control-center/ui/pages/system.slint:20 rog-control-center/ui/pages/system.slint:24
msgctxt "PageFans" msgctxt "SystemPageData"
msgid "CPU"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:93 rog-control-center/ui/pages/fans.slint:152 rog-control-center/ui/pages/fans.slint:211
msgctxt "PageFans"
msgid "Mid"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:111 rog-control-center/ui/pages/fans.slint:170 rog-control-center/ui/pages/fans.slint:229
msgctxt "PageFans"
msgid "GPU"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:131
msgctxt "PageFans"
msgid "Performance" msgid "Performance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/fans.slint:190 #: rog-control-center/ui/pages/system.slint:20
msgctxt "PageFans" msgctxt "SystemPageData"
msgid "Quiet" msgid "Quiet"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:23
msgctxt "SystemPageData"
msgid "Default"
msgstr ""
#: rog-control-center/ui/pages/system.slint:25
msgctxt "SystemPageData"
msgid "BalancePerformance"
msgstr ""
#: rog-control-center/ui/pages/system.slint:26
msgctxt "SystemPageData"
msgid "BalancePower"
msgstr ""
#: rog-control-center/ui/pages/system.slint:27
msgctxt "SystemPageData"
msgid "Power"
msgstr ""
#: rog-control-center/ui/pages/system.slint:147
msgctxt "PageSystem"
msgid "Power settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:152
msgctxt "PageSystem"
msgid "Charge limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:167
msgctxt "PageSystem"
msgid "Platform Profile"
msgstr ""
#: rog-control-center/ui/pages/system.slint:177
msgctxt "PageSystem"
msgid "Advanced"
msgstr ""
#: rog-control-center/ui/pages/system.slint:195
msgctxt "PageSystem"
msgid "Armoury settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:205
msgctxt "no_asus_armoury_driver_1"
msgid "The asus-armoury driver is not loaded"
msgstr ""
#: rog-control-center/ui/pages/system.slint:211
msgctxt "no_asus_armoury_driver_2"
msgid "For advanced features you will require a kernel with this driver added."
msgstr ""
#: rog-control-center/ui/pages/system.slint:222
msgctxt "PageSystem"
msgid "Panel Overdrive"
msgstr ""
#: rog-control-center/ui/pages/system.slint:230
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:238
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:254
msgctxt "ppt_warning"
msgid "The following settings are not applied until the toggle is enabled."
msgstr ""
#: rog-control-center/ui/pages/system.slint:259 rog-control-center/ui/pages/system.slint:266
msgctxt "ppt_group_enabled"
msgid "Enable Tuning"
msgstr ""
#: rog-control-center/ui/pages/system.slint:277 rog-control-center/ui/pages/system.slint:278
msgctxt "ppt_pl1_spl"
msgid "CPU Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:279
msgctxt "ppt_pl1_spl_help"
msgid ""
"Long-term CPU power limit that affects sustained workload performance. "
"Higher values may increase heat and power consumption."
msgstr ""
#: rog-control-center/ui/pages/system.slint:295 rog-control-center/ui/pages/system.slint:296
msgctxt "ppt_pl2_sppt"
msgid "CPU Turbo Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:297
msgctxt "ppt_pl2_sppt_help"
msgid ""
"Short-term CPU power limit for boost periods. Controls maximum power during "
"brief high-performance bursts."
msgstr ""
#: rog-control-center/ui/pages/system.slint:313 rog-control-center/ui/pages/system.slint:314
msgctxt "ppt_pl3_fppt"
msgid "CPU Fast Burst Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:315
msgctxt "ppt_pl3_fppt_help"
msgid ""
"Ultra-short duration power limit for instantaneous CPU bursts. Affects "
"responsiveness during sudden workload spikes."
msgstr ""
#: rog-control-center/ui/pages/system.slint:330 rog-control-center/ui/pages/system.slint:331
msgctxt "ppt_fppt"
msgid "Fast Package Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:332
msgctxt "ppt_fppt_help"
msgid ""
"Ultra-short duration power limit for system package. Controls maximum power "
"during millisecond-scale load spikes."
msgstr ""
#: rog-control-center/ui/pages/system.slint:348 rog-control-center/ui/pages/system.slint:349
msgctxt "ppt_apu_sppt"
msgid "APU Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:350
msgctxt "ppt_apu_sppt_help"
msgid ""
"Long-term power limit for integrated graphics and CPU combined. Affects "
"sustained performance of APU-based workloads."
msgstr ""
#: rog-control-center/ui/pages/system.slint:366 rog-control-center/ui/pages/system.slint:367
msgctxt "ppt_platform_sppt"
msgid "Platform Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:368
msgctxt "ppt_platform_sppt_help"
msgid ""
"Overall system power limit for sustained operations. Controls total platform "
"power consumption over extended periods."
msgstr ""
#: rog-control-center/ui/pages/system.slint:384 rog-control-center/ui/pages/system.slint:385
msgctxt "nv_dynamic_boost"
msgid "GPU Power Boost"
msgstr ""
#: rog-control-center/ui/pages/system.slint:386
msgctxt "nv_dynamic_boost_help"
msgid ""
"Additional power allocation for GPU dynamic boost. Higher values increase "
"GPU performance but generate more heat."
msgstr ""
#: rog-control-center/ui/pages/system.slint:402 rog-control-center/ui/pages/system.slint:403
msgctxt "nv_temp_target"
msgid "GPU Temperature Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:404
msgctxt "nv_temp_target_help"
msgid ""
"Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain "
"temperature below this limit."
msgstr ""
#: rog-control-center/ui/pages/system.slint:456
msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:460
msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:468
msgctxt "PageSystem"
msgid "EPP for Balanced Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:478
msgctxt "PageSystem"
msgid "EPP for Performance Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:488
msgctxt "PageSystem"
msgid "EPP for Quiet Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:506
msgctxt "PageSystem"
msgid "Throttle Policy for power state"
msgstr ""
#: rog-control-center/ui/pages/system.slint:512
msgctxt "PageSystem"
msgid "Throttle Policy on Battery"
msgstr ""
#: rog-control-center/ui/pages/system.slint:522 rog-control-center/ui/pages/system.slint:543
msgctxt "PageSystem"
msgid "Enabled"
msgstr ""
#: rog-control-center/ui/pages/system.slint:533
msgctxt "PageSystem"
msgid "Throttle Policy on AC"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:28
msgctxt "PageAura"
msgid "Brightness"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:39
msgctxt "PageAura"
msgid "Aura mode"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:59
msgctxt "PageAura"
msgid "Colour 1"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:85
msgctxt "PageAura"
msgid "Colour 2"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:119
msgctxt "PageAura"
msgid "Zone"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:142
msgctxt "PageAura"
msgid "Direction"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:164
msgctxt "PageAura"
msgid "Speed"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:185
msgctxt "PageAura"
msgid "Power Settings"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:270
msgctxt "PageAura"
msgid "Power Zones"
msgstr ""
#: rog-control-center/ui/pages/anime.slint:6 #: rog-control-center/ui/pages/anime.slint:6
msgctxt "Anime Brightness" msgctxt "Anime Brightness"
msgid "Off" msgid "Off"
@@ -212,224 +418,79 @@ msgctxt "PageAnime"
msgid "Off when on battery" msgid "Off when on battery"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/aura.slint:28 #: rog-control-center/ui/pages/fans.slint:26
msgctxt "PageAura" msgctxt "FanTab"
msgid "Brightness" msgid "This fan is not avilable on this machine"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/aura.slint:39 #: rog-control-center/ui/pages/fans.slint:34
msgctxt "PageAura" msgctxt "FanTab"
msgid "Aura mode"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:59
msgctxt "PageAura"
msgid "Colour 1"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:85
msgctxt "PageAura"
msgid "Colour 2"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:119
msgctxt "PageAura"
msgid "Zone"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:142
msgctxt "PageAura"
msgid "Direction"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:164
msgctxt "PageAura"
msgid "Speed"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:185
msgctxt "PageAura"
msgid "Power Settings"
msgstr ""
#: rog-control-center/ui/pages/aura.slint:270
msgctxt "PageAura"
msgid "Power Zones"
msgstr ""
#: rog-control-center/ui/pages/system.slint:19
msgctxt "SystemPageData"
msgid "Balanced"
msgstr ""
#: rog-control-center/ui/pages/system.slint:19 rog-control-center/ui/pages/system.slint:23
msgctxt "SystemPageData"
msgid "Performance"
msgstr ""
#: rog-control-center/ui/pages/system.slint:19
msgctxt "SystemPageData"
msgid "Quiet"
msgstr ""
#: rog-control-center/ui/pages/system.slint:22
msgctxt "SystemPageData"
msgid "Default"
msgstr ""
#: rog-control-center/ui/pages/system.slint:24
msgctxt "SystemPageData"
msgid "BalancePerformance"
msgstr ""
#: rog-control-center/ui/pages/system.slint:25
msgctxt "SystemPageData"
msgid "BalancePower"
msgstr ""
#: rog-control-center/ui/pages/system.slint:26
msgctxt "SystemPageData"
msgid "Power"
msgstr ""
#: rog-control-center/ui/pages/system.slint:130
msgctxt "PageSystem"
msgid "Power settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:135
msgctxt "PageSystem"
msgid "Charge limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:147
msgctxt "PageSystem"
msgid "Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:157
msgctxt "PageSystem"
msgid "Advanced"
msgstr ""
#: rog-control-center/ui/pages/system.slint:175
msgctxt "PageSystem"
msgid "Armoury settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:183
msgctxt "PageSystem"
msgid "Panel Overdrive"
msgstr ""
#: rog-control-center/ui/pages/system.slint:191
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:199
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:210
msgctxt "PageSystem"
msgid "The asus-armoury driver is not loaded"
msgstr ""
#: rog-control-center/ui/pages/system.slint:215
msgctxt "PageSystem"
msgid "For advanced features you will require a kernel with this driver added."
msgstr ""
#: rog-control-center/ui/pages/system.slint:226
msgctxt "ppt_warning"
msgid "The following settings may not be safe, please take care."
msgstr ""
#: rog-control-center/ui/pages/system.slint:231
msgctxt "ppt_pl1_spl"
msgid "PL1, sustained power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:242
msgctxt "ppt_pl2_sppt"
msgid "PL2, turbo power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:253
msgctxt "ppt_pl3_fppt"
msgid "PL3, Fast Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:263
msgctxt "ppt_fppt"
msgid "FPPT, Fast Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:274
msgctxt "ppt_apu_sppt"
msgid "SPPT, APU slow power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:285
msgctxt "ppt_platform_sppt"
msgid "Slow package power tracking limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:296
msgctxt "nv_dynamic_boost"
msgid "dGPU boost overclock"
msgstr ""
#: rog-control-center/ui/pages/system.slint:307
msgctxt "nv_temp_target"
msgid "dGPU temperature max"
msgstr ""
#: rog-control-center/ui/pages/system.slint:354
msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:358
msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:366
msgctxt "PageSystem"
msgid "EPP for Balanced Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:376
msgctxt "PageSystem"
msgid "EPP for Performance Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:386
msgctxt "PageSystem"
msgid "EPP for Quiet Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:404
msgctxt "PageSystem"
msgid "Throttle Policy for power state"
msgstr ""
#: rog-control-center/ui/pages/system.slint:410
msgctxt "PageSystem"
msgid "Throttle Policy on Battery"
msgstr ""
#: rog-control-center/ui/pages/system.slint:420 rog-control-center/ui/pages/system.slint:441
msgctxt "PageSystem"
msgid "Enabled" msgid "Enabled"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:431 #: rog-control-center/ui/pages/fans.slint:43
msgctxt "PageSystem" msgctxt "FanTab"
msgid "Throttle Policy on AC" msgid "Apply"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:51
msgctxt "FanTab"
msgid "Cancel"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:59
msgctxt "FanTab"
msgid "Factory Default (all fans)"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:72
msgctxt "PageFans"
msgid "Balanced"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:75 rog-control-center/ui/pages/fans.slint:134 rog-control-center/ui/pages/fans.slint:193
msgctxt "PageFans"
msgid "CPU"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:93 rog-control-center/ui/pages/fans.slint:152 rog-control-center/ui/pages/fans.slint:211
msgctxt "PageFans"
msgid "Mid"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:111 rog-control-center/ui/pages/fans.slint:170 rog-control-center/ui/pages/fans.slint:229
msgctxt "PageFans"
msgid "GPU"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:131
msgctxt "PageFans"
msgid "Performance"
msgstr ""
#: rog-control-center/ui/pages/fans.slint:190
msgctxt "PageFans"
msgid "Quiet"
msgstr ""
#: rog-control-center/ui/pages/app_settings.slint:26
msgctxt "PageAppSettings"
msgid "Run in background after closing"
msgstr ""
#: rog-control-center/ui/pages/app_settings.slint:34
msgctxt "PageAppSettings"
msgid "Start app in background (UI closed)"
msgstr ""
#: rog-control-center/ui/pages/app_settings.slint:42
msgctxt "PageAppSettings"
msgid "Enable system tray icon"
msgstr ""
#: rog-control-center/ui/pages/app_settings.slint:50
msgctxt "PageAppSettings"
msgid "Enable dGPU notifications"
msgstr "" msgstr ""
#: rog-control-center/ui/types/aura_types.slint:52 #: rog-control-center/ui/types/aura_types.slint:52
@@ -667,42 +728,47 @@ msgctxt "AuraPowerGroupOld"
msgid "Sleep" msgid "Sleep"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:51 #: rog-control-center/ui/widgets/common.slint:136
msgctxt "confirm_reset"
msgid "Are you sure you want to reset this?"
msgstr ""
#: rog-control-center/ui/main_window.slint:55
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "ROG" msgid "ROG"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:53 #: rog-control-center/ui/main_window.slint:57
msgctxt "Menu1" msgctxt "Menu1"
msgid "System Control" msgid "System Control"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:54 #: rog-control-center/ui/main_window.slint:58
msgctxt "Menu2" msgctxt "Menu2"
msgid "Keyboard Aura" msgid "Keyboard Aura"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:55 #: rog-control-center/ui/main_window.slint:59
msgctxt "Menu3" msgctxt "Menu3"
msgid "AniMe Matrix" msgid "AniMe Matrix"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:56 #: rog-control-center/ui/main_window.slint:60
msgctxt "Menu4" msgctxt "Menu4"
msgid "Fan Curves" msgid "Fan Curves"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:57 #: rog-control-center/ui/main_window.slint:61
msgctxt "Menu5" msgctxt "Menu5"
msgid "App Settings" msgid "App Settings"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:58 #: rog-control-center/ui/main_window.slint:62
msgctxt "Menu6" msgctxt "Menu6"
msgid "About" msgid "About"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:70 #: rog-control-center/ui/main_window.slint:74
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "Quit App" msgid "Quit App"
msgstr "" msgstr ""
+17 -13
View File
@@ -19,10 +19,14 @@ export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData
export component MainWindow inherits Window { export component MainWindow inherits Window {
title: "ROG Control"; title: "ROG Control";
default-font-family: "DejaVu Sans"; always-on-top: true;
default-font-family: "Noto Sans";
default-font-size: 14px;
default-font-weight: 400;
icon: @image-url("../data/rog-control-center.png");
in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true]; in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true];
private property <bool> show-notif; private property <bool> show_notif;
private property <bool> fade-cover; private property <bool> fade_cover;
private property <bool> toast: false; private property <bool> toast: false;
private property <string> toast_text: "I show when something is waiting"; private property <string> toast_text: "I show when something is waiting";
callback show_toast(string); callback show_toast(string);
@@ -31,10 +35,10 @@ export component MainWindow inherits Window {
toast_text = text; toast_text = text;
} }
callback exit-app(); callback exit-app();
callback show-notification(bool); callback show_notification(bool);
show-notification(yes) => { show_notification(yes) => {
show-notif = yes; show_notif = yes;
fade-cover = yes; fade_cover = yes;
} }
callback external_colour_change(); callback external_colour_change();
external_colour_change() => { external_colour_change() => {
@@ -109,7 +113,7 @@ export component MainWindow inherits Window {
} }
} }
if fade-cover: Rectangle { if fade_cover: Rectangle {
x: 0px; x: 0px;
y: 0px; y: 0px;
width: root.width; width: root.width;
@@ -121,10 +125,10 @@ export component MainWindow inherits Window {
width: 100%; width: 100%;
clicked => { clicked => {
// toolbar-dropdown.close(); // toolbar-dropdown.close();
if (show-notif) { if (show_notif) {
show-notif = false; show_notif = false;
} }
fade-cover = false; fade_cover = false;
} }
} }
} }
@@ -156,7 +160,7 @@ export component MainWindow inherits Window {
} }
// // TODO: or use Dialogue // // TODO: or use Dialogue
if show-notif: Rectangle { if show_notif: Rectangle {
x: root.width / 8; x: root.width / 8;
y: root.height / 8; y: root.height / 8;
height: (root.height / 8) * 6; height: (root.height / 8) * 6;
@@ -165,7 +169,7 @@ export component MainWindow inherits Window {
height: 100%; height: 100%;
width: 100%; width: 100%;
clicked => { clicked => {
show-notif = false; show_notif = false;
exit-app(); exit-app();
} }
} }
+214 -112
View File
@@ -1,23 +1,24 @@
import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint"; import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox} from "std-widgets.slint"; import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox, StandardButton} from "std-widgets.slint";
export struct AttrMinMax { export struct AttrMinMax {
min: int, min: int,
max: int, max: int,
val: float, current: float,
} }
export struct AttrPossible { export struct AttrPossible {
range: [int], range: [int],
val: int, current: int,
} }
export global SystemPageData { export global SystemPageData {
in-out property <bool> charge_control_enabled: true;
in-out property <float> charge_control_end_threshold: 30; in-out property <float> charge_control_end_threshold: 30;
callback cb_charge_control_end_threshold(/* charge limit */ int); callback cb_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> throttle_thermal_policy: 0; in-out property <int> platform_profile: 0;
in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")]; in-out property <[string]> platform_profile_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
callback cb_throttle_thermal_policy(int); callback cb_platform_profile(int);
in-out property <[string]> energy_performance_choices: [ in-out property <[string]> energy_performance_choices: [
@tr("Default"), @tr("Default"),
@tr("Performance"), @tr("Performance"),
@@ -25,23 +26,23 @@ export global SystemPageData {
@tr("BalancePower"), @tr("BalancePower"),
@tr("Power") @tr("Power")
]; ];
in-out property <int> throttle_balanced_epp: 0; in-out property <int> profile_balanced_epp: 0;
callback cb_throttle_balanced_epp(int); callback cb_profile_balanced_epp(int);
in-out property <int> throttle_performance_epp: 0; in-out property <int> profile_performance_epp: 0;
callback cb_throttle_performance_epp(int); callback cb_profile_performance_epp(int);
in-out property <int> throttle_quiet_epp: 0; in-out property <int> profile_quiet_epp: 0;
callback cb_throttle_quiet_epp(int); callback cb_profile_quiet_epp(int);
// if the EPP should change with throttle // if the EPP should change with throttle
in-out property <bool> throttle_policy_linked_epp: true; in-out property <bool> platform_profile_linked_epp: true;
callback cb_throttle_policy_linked_epp(bool); callback cb_platform_profile_linked_epp(bool);
in-out property <int> throttle_policy_on_ac: 0; in-out property <int> platform_profile_on_ac: 0;
callback cb_throttle_policy_on_ac(int); callback cb_platform_profile_on_ac(int);
in-out property <bool> change_throttle_policy_on_ac: true; in-out property <bool> change_platform_profile_on_ac: true;
callback cb_change_throttle_policy_on_ac(bool); callback cb_change_platform_profile_on_ac(bool);
in-out property <int> throttle_policy_on_battery: 0; in-out property <int> platform_profile_on_battery: 0;
callback cb_throttle_policy_on_battery(int); callback cb_platform_profile_on_battery(int);
in-out property <bool> change_throttle_policy_on_battery: true; in-out property <bool> change_platform_profile_on_battery: true;
callback cb_change_throttle_policy_on_battery(bool); callback cb_change_platform_profile_on_battery(bool);
// //
in-out property <int> panel_overdrive; in-out property <int> panel_overdrive;
callback cb_panel_overdrive(int); callback cb_panel_overdrive(int);
@@ -54,58 +55,73 @@ export global SystemPageData {
in-out property <AttrMinMax> ppt_pl1_spl: { in-out property <AttrMinMax> ppt_pl1_spl: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_pl1_spl(int); callback cb_ppt_pl1_spl(int);
callback cb_default_ppt_pl1_spl();
in-out property <AttrMinMax> ppt_pl2_sppt: { in-out property <AttrMinMax> ppt_pl2_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_pl2_sppt(int); callback cb_ppt_pl2_sppt(int);
callback cb_default_ppt_pl2_sppt();
in-out property <AttrMinMax> ppt_pl3_fppt: { in-out property <AttrMinMax> ppt_pl3_fppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_pl3_fppt(int); callback cb_ppt_pl3_fppt(int);
callback cb_default_ppt_pl3_fppt();
in-out property <AttrMinMax> ppt_fppt: { in-out property <AttrMinMax> ppt_fppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_fppt(int); callback cb_ppt_fppt(int);
callback cb_default_ppt_fppt();
in-out property <AttrMinMax> ppt_apu_sppt: { in-out property <AttrMinMax> ppt_apu_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_apu_sppt(int); callback cb_ppt_apu_sppt(int);
callback cb_default_ppt_apu_sppt();
in-out property <AttrMinMax> ppt_platform_sppt: { in-out property <AttrMinMax> ppt_platform_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_platform_sppt(int); callback cb_ppt_platform_sppt(int);
callback cb_default_ppt_platform_sppt();
in-out property <AttrMinMax> nv_dynamic_boost: { in-out property <AttrMinMax> nv_dynamic_boost: {
min: 0, min: 0,
max: 30, max: 30,
val: 5, current: 5,
}; };
callback cb_nv_dynamic_boost(int); callback cb_nv_dynamic_boost(int);
callback cb_default_nv_dynamic_boost();
in-out property <AttrMinMax> nv_temp_target: { in-out property <AttrMinMax> nv_temp_target: {
min: 0, min: 0,
max: 80, max: 80,
val: 75, current: 75,
}; };
callback cb_nv_temp_target(int); callback cb_nv_temp_target(int);
callback cb_default_nv_temp_target();
in-out property <bool> enable_ppt_group: false;
callback cb_enable_ppt_group(bool);
in-out property <bool> ppt_enabled_available;
in-out property <bool> ppt_enabled;
callback cb_ppt_enabled(bool);
} }
export component PageSystem inherits Rectangle { export component PageSystem inherits Rectangle {
@@ -117,6 +133,7 @@ export component PageSystem inherits Rectangle {
VerticalLayout { VerticalLayout {
padding: 10px; padding: 10px;
spacing: 10px; spacing: 10px;
alignment: LayoutAlignment.start;
Rectangle { Rectangle {
background: Palette.alternate-background; background: Palette.alternate-background;
border-color: Palette.accent-background; border-color: Palette.accent-background;
@@ -135,21 +152,24 @@ export component PageSystem inherits Rectangle {
text: @tr("Charge limit"); text: @tr("Charge limit");
minimum: 20; minimum: 20;
maximum: 100; maximum: 100;
value <=> SystemPageData.charge_control_end_threshold; has_reset: false;
enabled <=> SystemPageData.charge_control_enabled;
value: SystemPageData.charge_control_end_threshold;
released => { released => {
SystemPageData.charge_control_end_threshold = self.value;
SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold)) SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
} }
} }
if SystemPageData.throttle_thermal_policy != -1: HorizontalLayout { if SystemPageData.platform_profile != -1: HorizontalLayout {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy"); text: @tr("Platform Profile");
current_index <=> SystemPageData.throttle_thermal_policy; current_index <=> SystemPageData.platform_profile;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.cb_throttle_thermal_policy(SystemPageData.throttle_thermal_policy) SystemPageData.cb_platform_profile(SystemPageData.platform_profile)
} }
} }
@@ -176,6 +196,25 @@ export component PageSystem inherits Rectangle {
} }
} }
if !SystemPageData.asus_armoury_loaded: Rectangle {
border-width: 3px;
border-color: red;
max-height: 30px;
VerticalBox {
Text {
text: @tr("no_asus_armoury_driver_1" => "The asus-armoury driver is not loaded");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
}
}
HorizontalBox { HorizontalBox {
padding: 0px; padding: 0px;
spacing: 10px; spacing: 10px;
@@ -204,112 +243,175 @@ export component PageSystem inherits Rectangle {
} }
} }
if !SystemPageData.asus_armoury_loaded: Rectangle { if SystemPageData.ppt_pl1_spl.current != -1 || SystemPageData.ppt_pl2_sppt.current != -1 || SystemPageData.nv_dynamic_boost.current != -1: HorizontalLayout {
VerticalBox { padding-right: 10px;
Text { padding-left: 10px;
text: @tr("The asus-armoury driver is not loaded"); alignment: LayoutAlignment.space-between;
font-size: 16px; Rectangle {
horizontal-alignment: TextHorizontalAlignment.center; height: 32px;
Text {
font-size: 16px;
text: @tr("ppt_warning" => "The following settings are not applied until the toggle is enabled.");
}
} }
Text {
text: @tr("For advanced features you will require a kernel with this driver added."); if !SystemPageData.ppt_enabled_available: Switch {
font-size: 16px; text: @tr("ppt_group_enabled" => "Enable Tuning");
horizontal-alignment: TextHorizontalAlignment.center; checked <=> SystemPageData.enable_ppt_group;
toggled => {
SystemPageData.cb_enable_ppt_group(SystemPageData.enable_ppt_group)
}
} }
} if SystemPageData.ppt_enabled_available: Switch {
text: @tr("ppt_group_enabled" => "Enable Tuning");
checked <=> SystemPageData.ppt_enabled;
toggled => {
SystemPageData.enable_ppt_group = self.checked;
SystemPageData.cb_ppt_enabled(SystemPageData.ppt_enabled)
}
}
} }
if SystemPageData.ppt_pl1_spl.val != -1: Rectangle { if SystemPageData.ppt_pl1_spl.current != -1: SystemSlider {
height: 32px; text: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
Text { title: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
font-size: 16px; help_text: @tr("ppt_pl1_spl_help" => "Long-term CPU power limit that affects sustained workload performance. Higher values may increase heat and power consumption.");
text: @tr("ppt_warning" => "The following settings may not be safe, please take care.");
}
}
if SystemPageData.ppt_pl1_spl.val != -1: SystemSlider {
text: @tr("ppt_pl1_spl" => "PL1, sustained power limit");
minimum: SystemPageData.ppt_pl1_spl.min; minimum: SystemPageData.ppt_pl1_spl.min;
maximum: SystemPageData.ppt_pl1_spl.max; maximum: SystemPageData.ppt_pl1_spl.max;
value: SystemPageData.ppt_pl1_spl.val; value: SystemPageData.ppt_pl1_spl.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl1_spl();
}
released => { released => {
SystemPageData.ppt_pl1_spl.val = self.value; SystemPageData.ppt_pl1_spl.current = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value)) SystemPageData.cb_ppt_pl1_spl(Math.round(self.value));
} }
} }
if SystemPageData.ppt_pl2_sppt.val != -1: SystemSlider { if SystemPageData.ppt_pl2_sppt.current != -1: SystemSlider {
text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit"); text: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
title: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
help_text: @tr("ppt_pl2_sppt_help" => "Short-term CPU power limit for boost periods. Controls maximum power during brief high-performance bursts.");
minimum: SystemPageData.ppt_pl2_sppt.min; minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: SystemPageData.ppt_pl2_sppt.max; maximum: SystemPageData.ppt_pl2_sppt.max;
value: SystemPageData.ppt_pl2_sppt.val; value: SystemPageData.ppt_pl2_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl2_sppt();
}
released => { released => {
SystemPageData.ppt_pl2_sppt.val = self.value; SystemPageData.ppt_pl2_sppt.current = self.value;
SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value)) SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_pl3_fppt.val != -1: SystemSlider { if SystemPageData.ppt_pl3_fppt.current != -1: SystemSlider {
text: @tr("ppt_pl3_fppt" => "PL3, Fast Power Limit"); text: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
title: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
help_text: @tr("ppt_pl3_fppt_help" => "Ultra-short duration power limit for instantaneous CPU bursts. Affects responsiveness during sudden workload spikes.");
minimum: SystemPageData.ppt_pl3_fppt.min; minimum: SystemPageData.ppt_pl3_fppt.min;
maximum: SystemPageData.ppt_pl3_fppt.max; maximum: SystemPageData.ppt_pl3_fppt.max;
value: SystemPageData.ppt_pl3_fppt.val; value: SystemPageData.ppt_pl3_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl3_fppt();
}
released => { released => {
SystemPageData.ppt_pl3_fppt.val = self.value; SystemPageData.ppt_pl3_fppt.current = self.value;
SystemPageData.cb_ppt_pl3_fppt(Math.round(self.value)) SystemPageData.cb_ppt_pl3_fppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_fppt.val != -1: SystemSlider { if SystemPageData.ppt_fppt.current != -1: SystemSlider {
text: @tr("ppt_fppt" => "FPPT, Fast Power Limit"); text: @tr("ppt_fppt" => "Fast Package Power Limit");
title: @tr("ppt_fppt" => "Fast Package Power Limit");
help_text: @tr("ppt_fppt_help" => "Ultra-short duration power limit for system package. Controls maximum power during millisecond-scale load spikes.");
minimum: SystemPageData.ppt_fppt.min; minimum: SystemPageData.ppt_fppt.min;
maximum: SystemPageData.ppt_fppt.max; maximum: SystemPageData.ppt_fppt.max;
value: SystemPageData.ppt_fppt.val; value: SystemPageData.ppt_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_fppt();
}
released => { released => {
SystemPageData.ppt_fppt.val = self.value; SystemPageData.ppt_fppt.current = self.value;
SystemPageData.cb_ppt_fppt(Math.round(self.value)) SystemPageData.cb_ppt_fppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_apu_sppt.val != -1: SystemSlider { if SystemPageData.ppt_apu_sppt.current != -1: SystemSlider {
text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit"); text: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
title: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
help_text: @tr("ppt_apu_sppt_help" => "Long-term power limit for integrated graphics and CPU combined. Affects sustained performance of APU-based workloads.");
minimum: SystemPageData.ppt_apu_sppt.min; minimum: SystemPageData.ppt_apu_sppt.min;
maximum: SystemPageData.ppt_apu_sppt.max; maximum: SystemPageData.ppt_apu_sppt.max;
value: SystemPageData.ppt_apu_sppt.val; value: SystemPageData.ppt_apu_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_apu_sppt();
}
released => { released => {
SystemPageData.ppt_apu_sppt.val = self.value; SystemPageData.ppt_apu_sppt.current = self.value;
SystemPageData.cb_ppt_apu_sppt(Math.round(self.value)) SystemPageData.cb_ppt_apu_sppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_platform_sppt.val != -1: SystemSlider { if SystemPageData.ppt_platform_sppt.current != -1: SystemSlider {
text: @tr("ppt_platform_sppt" => "Slow package power tracking limit"); text: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
title: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
help_text: @tr("ppt_platform_sppt_help" => "Overall system power limit for sustained operations. Controls total platform power consumption over extended periods.");
minimum: SystemPageData.ppt_platform_sppt.min; minimum: SystemPageData.ppt_platform_sppt.min;
maximum: SystemPageData.ppt_platform_sppt.max; maximum: SystemPageData.ppt_platform_sppt.max;
value: SystemPageData.ppt_platform_sppt.val; value: SystemPageData.ppt_platform_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_platform_sppt();
}
released => { released => {
SystemPageData.ppt_platform_sppt.val = self.value; SystemPageData.ppt_platform_sppt.current = self.value;
SystemPageData.cb_ppt_platform_sppt(Math.round(self.value)) SystemPageData.cb_ppt_platform_sppt(Math.round(self.value))
} }
} }
if SystemPageData.nv_dynamic_boost.val != -1: SystemSlider { if SystemPageData.nv_dynamic_boost.current != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "dGPU boost overclock"); text: @tr("nv_dynamic_boost" => "GPU Power Boost");
title: @tr("nv_dynamic_boost" => "GPU Power Boost");
help_text: @tr("nv_dynamic_boost_help" => "Additional power allocation for GPU dynamic boost. Higher values increase GPU performance but generate more heat.");
minimum: SystemPageData.nv_dynamic_boost.min; minimum: SystemPageData.nv_dynamic_boost.min;
maximum: SystemPageData.nv_dynamic_boost.max; maximum: SystemPageData.nv_dynamic_boost.max;
value: SystemPageData.nv_dynamic_boost.val; value: SystemPageData.nv_dynamic_boost.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_nv_dynamic_boost();
}
released => { released => {
SystemPageData.nv_dynamic_boost.val = self.value; SystemPageData.nv_dynamic_boost.current = self.value;
SystemPageData.cb_nv_dynamic_boost(Math.round(self.value)) SystemPageData.cb_nv_dynamic_boost(Math.round(self.value))
} }
} }
if SystemPageData.nv_temp_target.val != -1: SystemSlider { if SystemPageData.nv_temp_target.current != -1: SystemSlider {
text: @tr("nv_temp_target" => "dGPU temperature max"); text: @tr("nv_temp_target" => "GPU Temperature Limit");
title: @tr("nv_temp_target" => "GPU Temperature Limit");
help_text: @tr("nv_temp_target_help" => "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain temperature below this limit.");
minimum: SystemPageData.nv_temp_target.min; minimum: SystemPageData.nv_temp_target.min;
maximum: SystemPageData.nv_temp_target.max; maximum: SystemPageData.nv_temp_target.max;
value: SystemPageData.nv_temp_target.val; value: SystemPageData.nv_temp_target.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_nv_temp_target();
}
released => { released => {
SystemPageData.nv_temp_target.val = self.value; SystemPageData.nv_temp_target.current = self.value;
SystemPageData.cb_nv_temp_target(Math.round(self.value)) SystemPageData.cb_nv_temp_target(Math.round(self.value))
} }
} }
@@ -356,39 +458,39 @@ export component PageSystem inherits Rectangle {
SystemToggle { SystemToggle {
text: @tr("Change EPP based on Throttle Policy"); text: @tr("Change EPP based on Throttle Policy");
checked <=> SystemPageData.throttle_policy_linked_epp; checked <=> SystemPageData.platform_profile_linked_epp;
toggled => { toggled => {
SystemPageData.cb_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp) SystemPageData.cb_platform_profile_linked_epp(SystemPageData.platform_profile_linked_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Balanced Policy"); text: @tr("EPP for Balanced Policy");
current_index <=> SystemPageData.throttle_balanced_epp; current_index <=> SystemPageData.profile_balanced_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_balanced_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.cb_throttle_balanced_epp(SystemPageData.throttle_balanced_epp) SystemPageData.cb_profile_balanced_epp(SystemPageData.profile_balanced_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Performance Policy"); text: @tr("EPP for Performance Policy");
current_index <=> SystemPageData.throttle_performance_epp; current_index <=> SystemPageData.profile_performance_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_performance_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.cb_throttle_performance_epp(SystemPageData.throttle_performance_epp) SystemPageData.cb_profile_performance_epp(SystemPageData.profile_performance_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Quiet Policy"); text: @tr("EPP for Quiet Policy");
current_index <=> SystemPageData.throttle_quiet_epp; current_index <=> SystemPageData.profile_quiet_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_quiet_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.cb_throttle_quiet_epp(SystemPageData.throttle_quiet_epp) SystemPageData.cb_profile_quiet_epp(SystemPageData.profile_quiet_epp)
} }
} }
} }
@@ -408,19 +510,19 @@ export component PageSystem inherits Rectangle {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy on Battery"); text: @tr("Throttle Policy on Battery");
current_index <=> SystemPageData.throttle_policy_on_battery; current_index <=> SystemPageData.platform_profile_on_battery;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_battery];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.cb_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery) SystemPageData.cb_platform_profile_on_battery(SystemPageData.platform_profile_on_battery)
} }
} }
SystemToggle { SystemToggle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_battery; checked <=> SystemPageData.change_platform_profile_on_battery;
toggled => { toggled => {
SystemPageData.cb_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery); SystemPageData.cb_change_platform_profile_on_battery(SystemPageData.change_platform_profile_on_battery);
} }
} }
} }
@@ -429,19 +531,19 @@ export component PageSystem inherits Rectangle {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy on AC"); text: @tr("Throttle Policy on AC");
current_index <=> SystemPageData.throttle_policy_on_ac; current_index <=> SystemPageData.platform_profile_on_ac;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_ac];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.cb_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac) SystemPageData.cb_platform_profile_on_ac(SystemPageData.platform_profile_on_ac)
} }
} }
SystemToggle { SystemToggle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_ac; checked <=> SystemPageData.change_platform_profile_on_ac;
toggled => { toggled => {
SystemPageData.cb_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac); SystemPageData.cb_change_platform_profile_on_ac(SystemPageData.change_platform_profile_on_ac);
} }
} }
} }
+122 -22
View File
@@ -10,40 +10,48 @@ export component RogItem inherits Rectangle {
} }
export component SystemSlider inherits RogItem { export component SystemSlider inherits RogItem {
in property <string> title;
in property <string> text; in property <string> text;
in-out property <bool> enabled: true;
in-out property <float> value; in-out property <float> value;
in-out property <float> minimum; in-out property <float> minimum;
in-out property <float> maximum; in-out property <float> maximum;
callback released(int); callback released(int);
in-out property <string> help_text;
in-out property <bool> has_reset: false;
callback cb_do_reset();
HorizontalLayout { HorizontalLayout {
HorizontalLayout { HorizontalLayout {
width: 50%; width: 40%;
alignment: LayoutAlignment.stretch; alignment: LayoutAlignment.stretch;
padding-left: 10px; padding-left: 10px;
TouchArea { TouchArea {
clicked => { enabled <=> root.enabled;
slider.value += 1; clicked => {
if slider.value > slider.maximum { slider.value += 1;
slider.value = slider.minimum; if slider.value > slider.maximum {
slider.value = slider.minimum;
}
} }
} HorizontalLayout {
HorizontalLayout { spacing: 6px;
spacing: 6px; Text {
Text { font-size: 16px;
font-size: 16px; vertical-alignment: TextVerticalAlignment.center;
vertical-alignment: TextVerticalAlignment.center; color: Palette.control-foreground;
color: Palette.control-foreground; text <=> root.text;
text <=> root.text; }
Text {
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.right;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text: "\{Math.round(root.value)}";
}
} }
Text {
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.right;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text: "\{Math.round(root.value)}";
}
}
} }
} }
@@ -51,6 +59,7 @@ export component SystemSlider inherits RogItem {
// alignment: LayoutAlignment.end; // alignment: LayoutAlignment.end;
padding-right: 20px; padding-right: 20px;
slider := Slider { slider := Slider {
enabled <=> root.enabled;
maximum: root.maximum; maximum: root.maximum;
minimum: root.minimum; minimum: root.minimum;
value <=> root.value; value <=> root.value;
@@ -59,6 +68,97 @@ export component SystemSlider inherits RogItem {
} }
} }
} }
help_popup := PopupWindow {
x: help.x - self.width + help.width - 10px;
y: help.y - self.height + help.height - 10px;
Rectangle {
drop-shadow-blur: 10px;
drop-shadow-color: black;
border-radius: 10px;
border-color: Palette.accent-background;
background: Palette.background;
Dialog {
title <=> root.title;
VerticalBox {
Text {
max-width: 420px;
font-size: 18px;
wrap: TextWrap.word-wrap;
horizontal-alignment: TextHorizontalAlignment.center;
text <=> root.title;
}
Rectangle {
height: 1px;
border-color: black;
border-width: 1px;
}
Text {
max-width: 420px;
font-size: 16px;
wrap: TextWrap.word-wrap;
text <=> root.help_text;
}
}
StandardButton {
kind: ok;
}
}
}
}
help := HorizontalBox {
if (help_text != ""): StandardButton {
kind: StandardButtonKind.help;
clicked => {
help_popup.show();
}
}
}
reset_popup := PopupWindow {
x: reset.x - self.width + reset.width;
y: reset.y - self.height + reset.height;
Rectangle {
drop-shadow-blur: 10px;
drop-shadow-color: black;
border-radius: 10px;
border-color: Palette.accent-background;
background: Palette.background;
Dialog {
Text {
max-width: 420px;
font-size: 16px;
wrap: TextWrap.word-wrap;
text: @tr("confirm_reset" => "Are you sure you want to reset this?");
}
StandardButton {
kind: ok;
clicked => {
root.cb_do_reset();
}
}
StandardButton {
kind: cancel;
}
}
}
}
reset := HorizontalBox {
if (has_reset): StandardButton {
kind: StandardButtonKind.reset;
enabled <=> root.enabled;
clicked => {
reset_popup.show();
}
}
}
} }
} }
@@ -114,7 +214,7 @@ export component SystemToggleInt inherits RogItem {
alignment: LayoutAlignment.end; alignment: LayoutAlignment.end;
padding-right: 20px; padding-right: 20px;
Switch { Switch {
checked: root.checked_int != 0; checked: root.checked_int != 0;
toggled => { toggled => {
root.checked_int = self.checked ? 1 : 0; root.checked_int = self.checked ? 1 : 0;
root.toggled(root.checked_int); root.toggled(root.checked_int);
+2
View File
@@ -48,4 +48,6 @@ pub trait AsusArmoury {
/// take. Returns `-1` if not used or set. /// take. Returns `-1` if not used or set.
#[zbus(property)] #[zbus(property)]
fn scalar_increment(&self) -> zbus::Result<i32>; fn scalar_increment(&self) -> zbus::Result<i32>;
async fn restore_default(&self) -> zbus::Result<()>;
} }
+7 -7
View File
@@ -20,7 +20,7 @@
//! //!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use zbus::proxy; use zbus::proxy;
@@ -32,30 +32,30 @@ use zbus::proxy;
)] )]
pub trait FanCurves { pub trait FanCurves {
/// Get the fan-curve data for the currently active PlatformProfile /// Get the fan-curve data for the currently active PlatformProfile
fn fan_curve_data(&self, profile: ThrottlePolicy) -> zbus::Result<Vec<CurveData>>; fn fan_curve_data(&self, profile: PlatformProfile) -> zbus::Result<Vec<CurveData>>;
/// Reset the stored (self) and device curve to the defaults of the /// Reset the stored (self) and device curve to the defaults of the
/// platform. /// platform.
/// ///
/// Each platform_profile has a different default and the defualt can be /// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile. /// read only for the currently active profile.
fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::Result<()>; fn reset_profile_curves(&self, profile: PlatformProfile) -> zbus::Result<()>;
/// SetActiveCurveToDefaults method /// SetActiveCurveToDefaults method
fn set_curves_to_defaults(&self, profile: ThrottlePolicy) -> zbus::Result<()>; fn set_curves_to_defaults(&self, profile: PlatformProfile) -> zbus::Result<()>;
/// Set the fan curve for the specified profile, or the profile the user is /// Set the fan curve for the specified profile, or the profile the user is
/// currently in if profile == None. Will also activate the fan curve. /// currently in if profile == None. Will also activate the fan curve.
fn set_fan_curve(&self, profile: ThrottlePolicy, curve: CurveData) -> zbus::Result<()>; fn set_fan_curve(&self, profile: PlatformProfile, curve: CurveData) -> zbus::Result<()>;
/// Set a profile fan curve enabled status. Will also activate a fan curve. /// Set a profile fan curve enabled status. Will also activate a fan curve.
fn set_fan_curves_enabled(&self, profile: ThrottlePolicy, enabled: bool) -> zbus::Result<()>; fn set_fan_curves_enabled(&self, profile: PlatformProfile, enabled: bool) -> zbus::Result<()>;
/// Set a single fan curve for a profile to enabled status. Will also /// Set a single fan curve for a profile to enabled status. Will also
/// activate a fan curve. /// activate a fan curve.
async fn set_profile_fan_curve_enabled( async fn set_profile_fan_curve_enabled(
&self, &self,
profile: ThrottlePolicy, profile: PlatformProfile,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool enabled: bool
) -> zbus::Result<()>; ) -> zbus::Result<()>;
+31 -20
View File
@@ -21,7 +21,7 @@
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use rog_platform::cpu::CPUEPP; use rog_platform::cpu::CPUEPP;
use rog_platform::platform::{Properties, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, Properties};
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(
@@ -34,7 +34,7 @@ pub trait Platform {
fn version(&self) -> zbus::Result<String>; fn version(&self) -> zbus::Result<String>;
/// NextThrottleThermalPolicy method /// NextThrottleThermalPolicy method
fn next_throttle_thermal_policy(&self) -> zbus::Result<()>; fn next_platform_profile(&self) -> zbus::Result<()>;
/// SupportedProperties method /// SupportedProperties method
fn supported_properties(&self) -> zbus::Result<Vec<Properties>>; fn supported_properties(&self) -> zbus::Result<Vec<Properties>>;
@@ -50,55 +50,66 @@ pub trait Platform {
/// ThrottleBalancedEpp property /// ThrottleBalancedEpp property
#[zbus(property)] #[zbus(property)]
fn throttle_balanced_epp(&self) -> zbus::Result<CPUEPP>; fn profile_balanced_epp(&self) -> zbus::Result<CPUEPP>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_balanced_epp(&self, epp: CPUEPP) -> zbus::Result<()>; fn set_profile_balanced_epp(&self, epp: CPUEPP) -> zbus::Result<()>;
/// ThrottlePerformanceEpp property /// ThrottlePerformanceEpp property
#[zbus(property)] #[zbus(property)]
fn throttle_performance_epp(&self) -> zbus::Result<CPUEPP>; fn profile_performance_epp(&self) -> zbus::Result<CPUEPP>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_performance_epp(&self, epp: CPUEPP) -> zbus::Result<()>; fn set_profile_performance_epp(&self, epp: CPUEPP) -> zbus::Result<()>;
/// ThrottlePolicyLinkedEpp property /// ThrottlePolicyLinkedEpp property
#[zbus(property)] #[zbus(property)]
fn throttle_policy_linked_epp(&self) -> zbus::Result<bool>; fn platform_profile_linked_epp(&self) -> zbus::Result<bool>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_policy_linked_epp(&self, value: bool) -> zbus::Result<()>; fn set_platform_profile_linked_epp(&self, value: bool) -> zbus::Result<()>;
/// ThrottlePolicyOnAc property /// ThrottlePolicyOnAc property
#[zbus(property)] #[zbus(property)]
fn throttle_policy_on_ac(&self) -> zbus::Result<ThrottlePolicy>; fn platform_profile_on_ac(&self) -> zbus::Result<PlatformProfile>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_policy_on_ac(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; fn set_platform_profile_on_ac(&self, platform_profile: PlatformProfile) -> zbus::Result<()>;
/// ChangeThrottlePolicyOnAc property /// ChangeThrottlePolicyOnAc property
#[zbus(property)] #[zbus(property)]
fn change_throttle_policy_on_ac(&self) -> zbus::Result<bool>; fn change_platform_profile_on_ac(&self) -> zbus::Result<bool>;
#[zbus(property)] #[zbus(property)]
fn set_change_throttle_policy_on_ac(&self, change: bool) -> zbus::Result<()>; fn set_change_platform_profile_on_ac(&self, change: bool) -> zbus::Result<()>;
/// ThrottlePolicyOnBattery property /// ThrottlePolicyOnBattery property
#[zbus(property)] #[zbus(property)]
fn throttle_policy_on_battery(&self) -> zbus::Result<ThrottlePolicy>; fn platform_profile_on_battery(&self) -> zbus::Result<PlatformProfile>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_policy_on_battery(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; fn set_platform_profile_on_battery(
&self,
platform_profile: PlatformProfile
) -> zbus::Result<()>;
/// ChangeThrottlePolicyOnAc property /// ChangeThrottlePolicyOnAc property
#[zbus(property)] #[zbus(property)]
fn change_throttle_policy_on_battery(&self) -> zbus::Result<bool>; fn change_platform_profile_on_battery(&self) -> zbus::Result<bool>;
#[zbus(property)] #[zbus(property)]
fn set_change_throttle_policy_on_battery(&self, change: bool) -> zbus::Result<()>; fn set_change_platform_profile_on_battery(&self, change: bool) -> zbus::Result<()>;
/// ThrottleQuietEpp property /// ThrottleQuietEpp property
#[zbus(property)] #[zbus(property)]
fn throttle_quiet_epp(&self) -> zbus::Result<CPUEPP>; fn profile_quiet_epp(&self) -> zbus::Result<CPUEPP>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_quiet_epp(&self, epp: CPUEPP) -> zbus::Result<()>; fn set_profile_quiet_epp(&self, epp: CPUEPP) -> zbus::Result<()>;
/// ThrottlePolicy property /// ThrottlePolicy property
#[zbus(property)] #[zbus(property)]
fn throttle_thermal_policy(&self) -> zbus::Result<ThrottlePolicy>; fn platform_profile(&self) -> zbus::Result<PlatformProfile>;
#[zbus(property)] #[zbus(property)]
fn set_throttle_thermal_policy(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; fn set_platform_profile(&self, platform_profile: PlatformProfile) -> zbus::Result<()>;
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
fn enable_ppt_group(&self) -> zbus::Result<bool>;
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
fn set_enable_ppt_group(&self, enable: bool) -> zbus::Result<()>;
} }
+36 -10
View File
@@ -2,6 +2,7 @@ use std::fs::{read_dir, File, OpenOptions};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use log::{debug, error};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -75,12 +76,21 @@ impl Attribute {
} }
} }
pub fn base_path_exists(&self) -> bool {
let exists = self.base_path.exists();
debug!(
"Attribute path {:?} exits? {exists}",
self.base_path.as_os_str()
);
exists
}
/// Write the `current_value` directly to the attribute path /// Write the `current_value` directly to the attribute path
pub fn set_current_value(&self, new_value: AttrValue) -> Result<(), PlatformError> { pub fn set_current_value(&self, new_value: &AttrValue) -> Result<(), PlatformError> {
let path = self.base_path.join("current_value"); let path = self.base_path.join("current_value");
let value_str = match new_value { let value_str = match new_value {
AttrValue::Integer(val) => val.to_string(), AttrValue::Integer(val) => &val.to_string(),
AttrValue::String(val) => val, AttrValue::String(val) => val,
_ => return Err(PlatformError::InvalidValue) _ => return Err(PlatformError::InvalidValue)
}; };
@@ -94,6 +104,10 @@ impl Attribute {
&self.default_value &self.default_value
} }
pub fn restore_default(&self) -> Result<(), PlatformError> {
self.set_current_value(&self.default_value)
}
pub fn possible_values(&self) -> &AttrValue { pub fn possible_values(&self) -> &AttrValue {
&self.possible_values &self.possible_values
} }
@@ -158,8 +172,8 @@ impl Attribute {
) )
} }
pub fn get_watcher(&self) -> Result<inotify::Inotify, PlatformError> { pub fn get_watcher(&self, attr: &str) -> Result<inotify::Inotify, PlatformError> {
let path = self.base_path.join("current_value"); let path = self.base_path.join(attr);
if let Some(path) = path.to_str() { if let Some(path) = path.to_str() {
let inotify = inotify::Inotify::init()?; let inotify = inotify::Inotify::init()?;
inotify inotify
@@ -178,6 +192,7 @@ impl Attribute {
} }
} }
#[derive(Clone)]
pub struct FirmwareAttributes { pub struct FirmwareAttributes {
attrs: Vec<Attribute> attrs: Vec<Attribute>
} }
@@ -289,7 +304,8 @@ pub enum FirmwareAttribute {
GpuMuxMode = 21, GpuMuxMode = 21,
MiniLedMode = 22, MiniLedMode = 22,
PendingReboot = 23, PendingReboot = 23,
None = 24 PptEnabled = 24,
None = 25
} }
impl FirmwareAttribute { impl FirmwareAttribute {
@@ -302,9 +318,14 @@ impl FirmwareAttribute {
| FirmwareAttribute::PptFppt | FirmwareAttribute::PptFppt
| FirmwareAttribute::PptApuSppt | FirmwareAttribute::PptApuSppt
| FirmwareAttribute::PptPlatformSppt | FirmwareAttribute::PptPlatformSppt
| FirmwareAttribute::NvDynamicBoost )
}
pub fn is_dgpu(&self) -> bool {
matches!(
self,
FirmwareAttribute::NvDynamicBoost
| FirmwareAttribute::NvTempTarget | FirmwareAttribute::NvTempTarget
| FirmwareAttribute::DgpuBaseTgp
| FirmwareAttribute::DgpuTgp | FirmwareAttribute::DgpuTgp
) )
} }
@@ -316,6 +337,7 @@ impl From<&str> for FirmwareAttribute {
"apu_mem" => Self::ApuMem, "apu_mem" => Self::ApuMem,
"cores_performance" => Self::CoresPerformance, "cores_performance" => Self::CoresPerformance,
"cores_efficiency" => Self::CoresEfficiency, "cores_efficiency" => Self::CoresEfficiency,
"ppt_enabled" => Self::PptEnabled,
"ppt_pl1_spl" => Self::PptPl1Spl, "ppt_pl1_spl" => Self::PptPl1Spl,
"ppt_pl2_sppt" => Self::PptPl2Sppt, "ppt_pl2_sppt" => Self::PptPl2Sppt,
"ppt_pl3_fppt" => Self::PptPl3Fppt, "ppt_pl3_fppt" => Self::PptPl3Fppt,
@@ -324,7 +346,7 @@ impl From<&str> for FirmwareAttribute {
"ppt_platform_sppt" => Self::PptPlatformSppt, "ppt_platform_sppt" => Self::PptPlatformSppt,
"nv_dynamic_boost" => Self::NvDynamicBoost, "nv_dynamic_boost" => Self::NvDynamicBoost,
"nv_temp_target" => Self::NvTempTarget, "nv_temp_target" => Self::NvTempTarget,
"dgpu_base_tgp" => Self::DgpuBaseTgp, "nv_base_tgp" => Self::DgpuBaseTgp,
"dgpu_tgp" => Self::DgpuTgp, "dgpu_tgp" => Self::DgpuTgp,
"charge_mode" => Self::ChargeMode, "charge_mode" => Self::ChargeMode,
"boot_sound" => Self::BootSound, "boot_sound" => Self::BootSound,
@@ -337,7 +359,10 @@ impl From<&str> for FirmwareAttribute {
"gpu_mux_mode" => Self::GpuMuxMode, "gpu_mux_mode" => Self::GpuMuxMode,
"mini_led_mode" => Self::MiniLedMode, "mini_led_mode" => Self::MiniLedMode,
"pending_reboot" => Self::PendingReboot, "pending_reboot" => Self::PendingReboot,
_ => panic!("Invalid firmware attribute: {}", s) _ => {
error!("Invalid firmware attribute: {}", s);
Self::None
}
} }
} }
} }
@@ -348,6 +373,7 @@ impl From<FirmwareAttribute> for &str {
FirmwareAttribute::ApuMem => "apu_mem", FirmwareAttribute::ApuMem => "apu_mem",
FirmwareAttribute::CoresPerformance => "cores_performance", FirmwareAttribute::CoresPerformance => "cores_performance",
FirmwareAttribute::CoresEfficiency => "cores_efficiency", FirmwareAttribute::CoresEfficiency => "cores_efficiency",
FirmwareAttribute::PptEnabled => "ppt_enabled",
FirmwareAttribute::PptPl1Spl => "ppt_pl1_spl", FirmwareAttribute::PptPl1Spl => "ppt_pl1_spl",
FirmwareAttribute::PptPl2Sppt => "ppt_pl2_sppt", FirmwareAttribute::PptPl2Sppt => "ppt_pl2_sppt",
FirmwareAttribute::PptPl3Fppt => "ppt_pl3_fppt", FirmwareAttribute::PptPl3Fppt => "ppt_pl3_fppt",
@@ -452,6 +478,6 @@ mod tests {
if let AttrValue::Integer(val) = &mut val { if let AttrValue::Integer(val) = &mut val {
*val = 0; *val = 0;
} }
attr.set_current_value(val).unwrap(); attr.set_current_value(&val).unwrap();
} }
} }
+6 -6
View File
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::{PlatformError, Result}; use crate::error::{PlatformError, Result};
use crate::platform::ThrottlePolicy; use crate::platform::PlatformProfile;
use crate::{read_attr_string, to_device}; use crate::{read_attr_string, to_device};
const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors"; const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors";
@@ -201,12 +201,12 @@ pub enum CPUEPP {
Power = 4 Power = 4
} }
impl From<ThrottlePolicy> for CPUEPP { impl From<PlatformProfile> for CPUEPP {
fn from(value: ThrottlePolicy) -> Self { fn from(value: PlatformProfile) -> Self {
match value { match value {
ThrottlePolicy::Balanced => CPUEPP::BalancePerformance, PlatformProfile::Balanced => CPUEPP::BalancePerformance,
ThrottlePolicy::Performance => CPUEPP::Performance, PlatformProfile::Performance => CPUEPP::Performance,
ThrottlePolicy::Quiet => CPUEPP::Power PlatformProfile::Quiet => CPUEPP::Power
} }
} }
} }
+45 -30
View File
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::{PlatformError, Result}; use crate::error::{PlatformError, Result};
use crate::{attr_string, attr_u8, to_device}; use crate::{attr_string, to_device};
/// The "platform" device provides access to things like: /// The "platform" device provides access to things like:
/// - `dgpu_disable` /// - `dgpu_disable`
@@ -24,13 +24,6 @@ pub struct RogPlatform {
} }
impl RogPlatform { impl RogPlatform {
attr_u8!(
/// This is technically the same as `platform_profile` since both are
/// tied in-kernel
"throttle_thermal_policy",
path
);
attr_string!( attr_string!(
/// The acpi platform_profile support /// The acpi platform_profile support
"platform_profile", "platform_profile",
@@ -193,15 +186,15 @@ impl Display for GpuMode {
Copy, Copy,
)] )]
#[zvariant(signature = "u")] #[zvariant(signature = "u")]
/// `throttle_thermal_policy` in asus_wmi /// `platform_profile` in asus_wmi
pub enum ThrottlePolicy { pub enum PlatformProfile {
#[default] #[default]
Balanced = 0, Balanced = 0,
Performance = 1, Performance = 1,
Quiet = 2 Quiet = 2
} }
impl ThrottlePolicy { impl PlatformProfile {
pub const fn next(self) -> Self { pub const fn next(self) -> Self {
match self { match self {
Self::Balanced => Self::Performance, Self::Balanced => Self::Performance,
@@ -219,7 +212,7 @@ impl ThrottlePolicy {
} }
} }
impl From<u8> for ThrottlePolicy { impl From<u8> for PlatformProfile {
fn from(num: u8) -> Self { fn from(num: u8) -> Self {
match num { match num {
0 => Self::Balanced, 0 => Self::Balanced,
@@ -233,52 +226,74 @@ impl From<u8> for ThrottlePolicy {
} }
} }
impl From<i32> for ThrottlePolicy { impl From<i32> for PlatformProfile {
fn from(num: i32) -> Self { fn from(num: i32) -> Self {
(num as u8).into() (num as u8).into()
} }
} }
impl From<ThrottlePolicy> for u8 { impl From<PlatformProfile> for u8 {
fn from(p: ThrottlePolicy) -> Self { fn from(p: PlatformProfile) -> Self {
match p { match p {
ThrottlePolicy::Balanced => 0, PlatformProfile::Balanced => 0,
ThrottlePolicy::Performance => 1, PlatformProfile::Performance => 1,
ThrottlePolicy::Quiet => 2 PlatformProfile::Quiet => 2
} }
} }
} }
impl From<ThrottlePolicy> for i32 { impl From<PlatformProfile> for i32 {
fn from(p: ThrottlePolicy) -> Self { fn from(p: PlatformProfile) -> Self {
<u8>::from(p) as i32 <u8>::from(p) as i32
} }
} }
impl From<ThrottlePolicy> for &str { impl From<PlatformProfile> for &str {
fn from(profile: ThrottlePolicy) -> &'static str { fn from(profile: PlatformProfile) -> &'static str {
match profile { match profile {
ThrottlePolicy::Balanced => "balanced", PlatformProfile::Balanced => "balanced",
ThrottlePolicy::Performance => "performance", PlatformProfile::Performance => "performance",
ThrottlePolicy::Quiet => "quiet" PlatformProfile::Quiet => "quiet"
} }
} }
} }
impl std::str::FromStr for ThrottlePolicy { impl From<String> for PlatformProfile {
fn from(profile: String) -> Self {
Self::from(&profile)
}
}
impl From<&String> for PlatformProfile {
fn from(profile: &String) -> Self {
match profile.to_ascii_lowercase().trim() {
"balanced" => PlatformProfile::Balanced,
"performance" => PlatformProfile::Performance,
"quiet" => PlatformProfile::Quiet,
"low-power" => PlatformProfile::Quiet,
_ => {
warn!("{profile} is unknown, using ThrottlePolicy::Balanced");
PlatformProfile::Balanced
}
}
}
}
impl std::str::FromStr for PlatformProfile {
type Err = PlatformError; type Err = PlatformError;
fn from_str(profile: &str) -> Result<Self> { fn from_str(profile: &str) -> Result<Self> {
match profile.to_ascii_lowercase().trim() { match profile.to_ascii_lowercase().trim() {
"balanced" => Ok(ThrottlePolicy::Balanced), "balanced" => Ok(PlatformProfile::Balanced),
"performance" => Ok(ThrottlePolicy::Performance), "performance" => Ok(PlatformProfile::Performance),
"quiet" => Ok(ThrottlePolicy::Quiet), "quiet" => Ok(PlatformProfile::Quiet),
"low-power" => Ok(PlatformProfile::Quiet),
_ => Err(PlatformError::NotSupported) _ => Err(PlatformError::NotSupported)
} }
} }
} }
impl Display for ThrottlePolicy { impl Display for PlatformProfile {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self) write!(f, "{:?}", self)
} }
+30 -30
View File
@@ -4,7 +4,7 @@ pub mod fan_curve_set;
use error::ProfileError; use error::ProfileError;
use fan_curve_set::CurveData; use fan_curve_set::CurveData;
use log::debug; use log::debug;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub use udev::Device; pub use udev::Device;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
@@ -125,7 +125,7 @@ impl FanCurveProfiles {
pub fn read_from_dev_profile( pub fn read_from_dev_profile(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
device: &Device device: &Device
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = Self::supported_fans()?; let fans = Self::supported_fans()?;
@@ -143,9 +143,9 @@ impl FanCurveProfiles {
} }
match profile { match profile {
ThrottlePolicy::Balanced => self.balanced = curves, PlatformProfile::Balanced => self.balanced = curves,
ThrottlePolicy::Performance => self.performance = curves, PlatformProfile::Performance => self.performance = curves,
ThrottlePolicy::Quiet => self.quiet = curves PlatformProfile::Quiet => self.quiet = curves
} }
Ok(()) Ok(())
} }
@@ -157,7 +157,7 @@ impl FanCurveProfiles {
/// read only for the currently active profile. /// read only for the currently active profile.
pub fn set_active_curve_to_defaults( pub fn set_active_curve_to_defaults(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
device: &mut Device device: &mut Device
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = Self::supported_fans()?; let fans = Self::supported_fans()?;
@@ -175,13 +175,13 @@ impl FanCurveProfiles {
/// in the enabled list it will become active. /// in the enabled list it will become active.
pub fn write_profile_curve_to_platform( pub fn write_profile_curve_to_platform(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
device: &mut Device device: &mut Device
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = match profile { let fans = match profile {
ThrottlePolicy::Balanced => &mut self.balanced, PlatformProfile::Balanced => &mut self.balanced,
ThrottlePolicy::Performance => &mut self.performance, PlatformProfile::Performance => &mut self.performance,
ThrottlePolicy::Quiet => &mut self.quiet PlatformProfile::Quiet => &mut self.quiet
}; };
for fan in fans.iter().filter(|f| !f.enabled) { for fan in fans.iter().filter(|f| !f.enabled) {
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}"); debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
@@ -196,19 +196,19 @@ impl FanCurveProfiles {
Ok(()) Ok(())
} }
pub fn set_profile_curves_enabled(&mut self, profile: ThrottlePolicy, enabled: bool) { pub fn set_profile_curves_enabled(&mut self, profile: PlatformProfile, enabled: bool) {
match profile { match profile {
ThrottlePolicy::Balanced => { PlatformProfile::Balanced => {
for curve in self.balanced.iter_mut() { for curve in self.balanced.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
} }
ThrottlePolicy::Performance => { PlatformProfile::Performance => {
for curve in self.performance.iter_mut() { for curve in self.performance.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
} }
ThrottlePolicy::Quiet => { PlatformProfile::Quiet => {
for curve in self.quiet.iter_mut() { for curve in self.quiet.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
@@ -218,12 +218,12 @@ impl FanCurveProfiles {
pub fn set_profile_fan_curve_enabled( pub fn set_profile_fan_curve_enabled(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool enabled: bool
) { ) {
match profile { match profile {
ThrottlePolicy::Balanced => { PlatformProfile::Balanced => {
for curve in self.balanced.iter_mut() { for curve in self.balanced.iter_mut() {
if curve.fan == fan { if curve.fan == fan {
curve.enabled = enabled; curve.enabled = enabled;
@@ -231,7 +231,7 @@ impl FanCurveProfiles {
} }
} }
} }
ThrottlePolicy::Performance => { PlatformProfile::Performance => {
for curve in self.performance.iter_mut() { for curve in self.performance.iter_mut() {
if curve.fan == fan { if curve.fan == fan {
curve.enabled = enabled; curve.enabled = enabled;
@@ -239,7 +239,7 @@ impl FanCurveProfiles {
} }
} }
} }
ThrottlePolicy::Quiet => { PlatformProfile::Quiet => {
for curve in self.quiet.iter_mut() { for curve in self.quiet.iter_mut() {
if curve.fan == fan { if curve.fan == fan {
curve.enabled = enabled; curve.enabled = enabled;
@@ -250,31 +250,31 @@ impl FanCurveProfiles {
} }
} }
pub fn get_fan_curves_for(&self, name: ThrottlePolicy) -> &[CurveData] { pub fn get_fan_curves_for(&self, name: PlatformProfile) -> &[CurveData] {
match name { match name {
ThrottlePolicy::Balanced => &self.balanced, PlatformProfile::Balanced => &self.balanced,
ThrottlePolicy::Performance => &self.performance, PlatformProfile::Performance => &self.performance,
ThrottlePolicy::Quiet => &self.quiet PlatformProfile::Quiet => &self.quiet
} }
} }
pub fn get_fan_curve_for(&self, name: &ThrottlePolicy, pu: FanCurvePU) -> Option<&CurveData> { pub fn get_fan_curve_for(&self, name: &PlatformProfile, pu: FanCurvePU) -> Option<&CurveData> {
match name { match name {
ThrottlePolicy::Balanced => { PlatformProfile::Balanced => {
for this_curve in self.balanced.iter() { for this_curve in self.balanced.iter() {
if this_curve.fan == pu { if this_curve.fan == pu {
return Some(this_curve); return Some(this_curve);
} }
} }
} }
ThrottlePolicy::Performance => { PlatformProfile::Performance => {
for this_curve in self.performance.iter() { for this_curve in self.performance.iter() {
if this_curve.fan == pu { if this_curve.fan == pu {
return Some(this_curve); return Some(this_curve);
} }
} }
} }
ThrottlePolicy::Quiet => { PlatformProfile::Quiet => {
for this_curve in self.quiet.iter() { for this_curve in self.quiet.iter() {
if this_curve.fan == pu { if this_curve.fan == pu {
return Some(this_curve); return Some(this_curve);
@@ -288,10 +288,10 @@ impl FanCurveProfiles {
pub fn save_fan_curve( pub fn save_fan_curve(
&mut self, &mut self,
curve: CurveData, curve: CurveData,
profile: ThrottlePolicy profile: PlatformProfile
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
match profile { match profile {
ThrottlePolicy::Balanced => { PlatformProfile::Balanced => {
for this_curve in self.balanced.iter_mut() { for this_curve in self.balanced.iter_mut() {
if this_curve.fan == curve.fan { if this_curve.fan == curve.fan {
*this_curve = curve; *this_curve = curve;
@@ -299,7 +299,7 @@ impl FanCurveProfiles {
} }
} }
} }
ThrottlePolicy::Performance => { PlatformProfile::Performance => {
for this_curve in self.performance.iter_mut() { for this_curve in self.performance.iter_mut() {
if this_curve.fan == curve.fan { if this_curve.fan == curve.fan {
*this_curve = curve; *this_curve = curve;
@@ -307,7 +307,7 @@ impl FanCurveProfiles {
} }
} }
} }
ThrottlePolicy::Quiet => { PlatformProfile::Quiet => {
for this_curve in self.quiet.iter_mut() { for this_curve in self.quiet.iter_mut() {
if this_curve.fan == curve.fan { if this_curve.fan == curve.fan {
*this_curve = curve; *this_curve = curve;