Compare commits

...

31 Commits

Author SHA1 Message Date
Luke D. Jones bb7b3a81fb Bump version 2024-02-24 21:50:52 +13:00
Luke D. Jones 19607d71c3 Prep 5.0.8 release 2024-02-24 17:09:24 +13:00
Luke D. Jones 96f281d789 Remove the use of bytes in zbus signatures 2024-02-23 21:50:53 +13:00
Luke D. Jones 7613eded95 Sane defaults for asusd config 2024-02-23 14:40:00 +13:00
Luke D. Jones 50eccd2b1d Formatting and fixes 2024-02-23 12:36:16 +13:00
Luke Jones ba54007102 Merge branch 'bugfix/persistent-theme' into 'main'
Reintroduce persistent dark/light mode

See merge request asus-linux/asusctl!180
2024-02-19 19:44:59 +00:00
Filip Binkiewicz a028f5375f Reintroduce persistent dark/light mode 2024-02-19 19:27:56 +00:00
Luke Jones 9ec02cd727 Merge branch 'dearner-main-patch-22870' into 'main'
Added G814JZ to aura_support.ron (uses G814JI keymap)

See merge request asus-linux/asusctl!179
2024-02-14 01:40:26 +00:00
Chris Dearner 4b46ece09a Added G814JZ to aura_support.ron (uses G814JI keymap) 2024-02-05 12:49:49 +00:00
Luke D. Jones 086bbd0908 Fix the broken pipe error 2024-02-02 23:26:41 +13:00
Luke D. Jones c94eaa473e Update TS bindings 2024-01-24 22:37:10 +13:00
Luke D. Jones b1b809834b Reload and apply settings if config file externally changed 2024-01-24 12:19:34 +13:00
Luke D. Jones 84183288ec Fix inotify watch failing thanks to vim idiocy 2024-01-23 22:44:20 +13:00
Luke D. Jones 86cbef83b6 Reload asusd.ron if changed 2024-01-22 21:54:19 +13:00
Luke D. Jones 006fb632c4 Doc and feature fixes 2024-01-22 19:33:40 +13:00
Luke D. Jones e3636ed8ce Update smithay-client-toolkit 2024-01-22 12:06:42 +13:00
Luke D. Jones cfd207f251 Remove async-trait crate and set min rustc 1.75 2024-01-15 18:22:41 +13:00
Luke D. Jones d4c68546e7 Added ability to change what EPP is linked with each throttle profile 2024-01-15 18:00:27 +13:00
Luke D. Jones 6f4a7e16dc Fixes to RCC 2024-01-05 14:21:31 +13:00
Luke D. Jones f64253d633 Various bugfixes 2024-01-05 13:53:57 +13:00
Luke D. Jones 124c17aadc Add default issue template 2024-01-04 14:30:11 +13:00
Luke D. Jones ab40f9fcbf Add FX705D led support 2024-01-04 09:23:37 +13:00
Luke D. Jones 5cdfa5a8d4 Fix to suspend process in anime thread to let custom anims run on wake 2023-12-27 11:24:39 +13:00
Luke D. Jones ce870cd5ed Revert egui update due to a lot of issues arising from window closing 2023-12-27 10:13:26 +13:00
Luke D. Jones 4541d2e1ba Update dbus introspection 2023-12-26 11:56:47 +13:00
Luke D. Jones b525411fd3 Minor fixes in asusctl 2023-12-25 21:24:05 +13:00
Luke D. Jones a867496f13 Re-enable ROGCC fan curves 2023-12-24 10:30:33 +13:00
Luke D. Jones f421b8ee3b Fix to apply led effect in rogcc 2023-12-23 21:45:19 +13:00
Luke D. Jones 82780feb4b Update readme 2023-12-23 10:37:46 +13:00
Luke D. Jones 1e5443e206 Bugfix release 2023-12-22 11:39:17 +13:00
Luke D. Jones 027a591d26 Add cargo-vendor-filterer to pipeline 2023-12-17 21:44:33 +13:00
53 changed files with 1296 additions and 733 deletions
+1
View File
@@ -59,6 +59,7 @@ release:
- tags - tags
<<: *rust_cache <<: *rust_cache
script: script:
- cargo install cargo-vendor-filterer
- make && make vendor - make && make vendor
artifacts: artifacts:
paths: paths:
+24
View File
@@ -0,0 +1,24 @@
## Issue description
(Summarize the bug encountered)
## Steps to reproduce
(How can the issue be reproduced)
## What is the current bug behavior?
(What actually happens)
## What is the expected correct behavior?
(What you should see instead)
## Relevant logs and/or screenshots
(run `journalctl -b -u supergfxd > ~/supergfxd.log` and attach `~/supergfxd.log`)
(Paste any relevant logs - use code blocks (```) to format console output, logs, and code, as
it's very hard to read otherwise.)
/label ~bug ~reproducable ~needs-investigation
+42
View File
@@ -6,6 +6,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [v5.0.8]
### Changed
- Reintroduce persisting dark/light mode in config file
- Added ability to change what EPP is linked with each throttle profile
- Don't change EPP or thermal profile if the battery/ac state hasn't actually changed on resume
- Re-implement the `asusctl -s` command (not fully)
- Add more docs to some parts of code, and dbus interfaces
- Reload asusd.ron if changed. Does not notify any dbus listeners (yet)
- Fix the broken pipe error
- Remove the use of bytes in zbus signatures (another cause of broken pipe)
### Added
- Support for G614J LED modes
## [v5.0.7]
### Changed
- Fix to suspend process in anime thread to let custom anims run on wake.
- Fix to reload the fan curves correctly on boot.
- Add new config option `platform_policy_linked_epp` to set if energy_performance_preference should be paired with platform_profile/throttle_thermal_policy
- Small fixes to rog-control-center
## [v5.0.6]
- Revert egui update due to a lot of issues arising from window closing.
## [v5.0.5]
- Resync. A release was made that was missing some commits.
## [v5.0.4]
### Changed
- Added G834JZ led config
- Fix in ROGCC to apply the actual effect changed
- Re-enable all fan curves (available) in ROGCC
- Update smithay-client-toolkit
## [v5.0.3]
### Changed
- Fix and error in platform ppt value gets
- Fix to asusctl CLI where an incorrect enum variant was used in throttle check
- Turn some error messages in to warning or info to prevent confusion
- Re-add the keyboard power settings in rogcc
- Add two new aura dbus properties for providing some basic info on aura modes/power
## [v5.0.2] ## [v5.0.2]
### Changed ### Changed
- Fan-curves: nuke a few async deadlocks - Fan-curves: nuke a few async deadlocks
Generated
+197 -199
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -4,10 +4,10 @@ default-members = ["asusctl", "asusd", "asusd-user", "cpuctl", "rog-control-cent
resolver = "2" resolver = "2"
[workspace.package] [workspace.package]
version = "5.0.2" version = "5.0.8"
rust-version = "1.75"
[workspace.dependencies] [workspace.dependencies]
async-trait = "^0.1"
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync"]} tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync"]}
concat-idents = "^1.1" concat-idents = "^1.1"
dirs = "^4.0" dirs = "^4.0"
+17 -13
View File
@@ -2,7 +2,7 @@
[Become a Patron!](https://www.patreon.com/bePatron?u=7602281) - [Asus Linux Website](https://asus-linux.org/) [Become a Patron!](https://www.patreon.com/bePatron?u=7602281) - [Asus Linux Website](https://asus-linux.org/)
**WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel, or v6.1 which has all my work merged upstream. **WARNING:** Many features are developed in tandem with kernel patches. If you see a feature is missing you either need a patched kernel or latest release.
`asusd` is a utility for Linux to control many aspects of various ASUS laptops `asusd` is a utility for Linux to control many aspects of various ASUS laptops
but can also be used with non-asus laptops with reduced features. but can also be used with non-asus laptops with reduced features.
@@ -11,23 +11,23 @@ Now includes a GUI, `rog-control-center`.
## Kernel support ## Kernel support
**The minimum supported kernel version is 5.17** **The minimum supported kernel version is 6.6**
**For TUF laptops, the minimum supported kernel version is 6.1**
## Goals ## Goals
1. To provide an interface for rootless control of some system functions most users wish to control such as fan speeds, keyboard LEDs, graphics modes. The main goal of this work is to provide a safe and easy to use abstraction over various laptop features via DBUS, and to provide some helpful defaults and other behaviour such as toggling throttle/profile on AC/battery change.
2. Enable third-party apps to use the above with dbus methods
3. To make the above as easy as possible for new users
4. Respect the users resources: be small, light, and fast
Point 3 means that the list of supported distros is very narrow - fedora is explicitly 1. Provide safe dbus interface
supported. All other distros are *not* supported (while asusd might still run fine on them). 2. Respect the users resources: be small, light, and fast
For best support use fedora 36+ Workstation.
Point 4? asusd currently uses a tiny fraction of cpu time, and less than 1Mb of ram, the way Point 4? asusd currently uses a tiny fraction of cpu time, and less than 1Mb of ram, the way
a system-level daemon should. a system-level daemon should. Languages such as JS and python should never be used for system level daemons (please stop).
## Keyboard LEDs
The level of support for laptops is dependent on folks submitting data to include in [`./rog-aura/data/layouts/aura_support.ron`](./rog-aura/data/layouts/aura_support.ron), typically installed in `/usr/share/asusd/aura_support.ron`. This is because the controller used for keyboards and LEDs is used across many years and many laptop models, all with different firmware configurations - the only way to track this is with the file mentioned above. Why not just enable all by default? Because it confuses people.
See the [rog-aura readme](./rog-aura/README.md) for more details.
## Discord ## Discord
@@ -41,6 +41,10 @@ to this:
``` ```
Bus 001 Device 002: ID 0b05:1866 ASUSTek Computer, Inc. N-KEY Device Bus 001 Device 002: ID 0b05:1866 ASUSTek Computer, Inc. N-KEY Device
``` ```
or
```
Bus 003 Device 002: ID 0b05:19b6 ASUSTek Computer, Inc. [unknown]
```
then it may work without tweaks. Technically all other functions except the LED then it may work without tweaks. Technically all other functions except the LED
and AniMe parts should work regardless of your latop make. and AniMe parts should work regardless of your latop make.
@@ -68,7 +72,7 @@ A gui is now in the repo - ROG Control Center. At this time it is still a WIP, b
# BUILDING # BUILDING
Requirements are rust >= 1.57 installed from rustup.io if the distro provided version is too old, and `make`. Requirements are rust >= 1.75 installed from rustup.io if the distro provided version is too old, and `make`.
**Ubuntu (unsuported):** **Ubuntu (unsuported):**
+1
View File
@@ -22,5 +22,6 @@ gif.workspace = true
tinybmp.workspace = true tinybmp.workspace = true
glam.workspace = true glam.workspace = true
rog_dbus = { path = "../rog-dbus" } rog_dbus = { path = "../rog-dbus" }
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync", "rt", "time"]}
cargo-husky.workspace = true cargo-husky.workspace = true
+2 -2
View File
@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
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};
@@ -60,7 +60,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<PlatformPolicy>, pub profile_set: Option<ThrottlePolicy>,
} }
#[derive(Options)] #[derive(Options)]
+2 -2
View File
@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
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<PlatformPolicy>, pub mod_profile: Option<ThrottlePolicy>,
#[options( #[options(
meta = "", meta = "",
+24 -11
View File
@@ -18,7 +18,7 @@ use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraPowerDev};
use rog_aura::{self, AuraEffect}; use rog_aura::{self, AuraEffect};
use rog_dbus::RogDbusClientBlocking; use rog_dbus::RogDbusClientBlocking;
use rog_platform::error::PlatformError; use rog_platform::error::PlatformError;
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties}; use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use crate::aura_cli::{AuraPowerStates, LedBrightness}; use crate::aura_cli::{AuraPowerStates, LedBrightness};
@@ -132,9 +132,9 @@ fn do_parsed(
println!("{}", CliStart::usage()); println!("{}", CliStart::usage());
println!(); println!();
if let Some(cmdlist) = CliStart::command_list() { if let Some(cmdlist) = CliStart::command_list() {
let dev_type = dbus.proxies().aura().device_type()?;
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect(); let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
for command in commands.iter().filter(|command| { for command in commands.iter().filter(|command| {
let dev_type = dbus.proxies().aura().device_type().unwrap();
if !dev_type.is_old_style() if !dev_type.is_old_style()
&& !dev_type.is_tuf_style() && !dev_type.is_tuf_style()
&& command.trim().starts_with("led-pow-1") && command.trim().starts_with("led-pow-1")
@@ -180,10 +180,23 @@ fn do_parsed(
dbus.proxies().aura().set_brightness(brightness.prev())?; dbus.proxies().aura().set_brightness(brightness.prev())?;
} }
// TODO: if parsed.show_supported {
// if parsed.show_supported { println!("Supported Core Functions:\n{:#?}", supported_interfaces);
// println!("Supported laptop functions:\n\n{}", supported); println!(
// } "Supported Platform Properties:\n{:#?}",
supported_properties
);
if supported_interfaces.contains(&"Aura".to_owned()) {
let bright = dbus.proxies().aura().supported_brightness()?;
let modes = dbus.proxies().aura().supported_basic_modes()?;
let zones = dbus.proxies().aura().supported_basic_zones()?;
let power = dbus.proxies().aura().supported_power_zones()?;
println!("Supported Keyboard Brightness:\n{:#?}", bright);
println!("Supported Aura Modes:\n{:#?}", modes);
println!("Supported Aura Zones:\n{:#?}", zones);
println!("Supported Aura Power Zones:\n{:#?}", power);
}
}
if let Some(chg_limit) = parsed.chg_limit { if let Some(chg_limit) = parsed.chg_limit {
dbus.proxies() dbus.proxies()
@@ -420,8 +433,8 @@ fn handle_led_mode(
if let Some(cmdlist) = LedModeCommand::command_list() { if let Some(cmdlist) = LedModeCommand::command_list() {
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect(); let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
let modes = dbus.proxies().aura().supported_basic_modes()?;
for command in commands.iter().filter(|command| { for command in commands.iter().filter(|command| {
let modes = dbus.proxies().aura().supported_modes().unwrap();
for mode in &modes { for mode in &modes {
if command if command
.trim() .trim()
@@ -450,7 +463,7 @@ fn handle_led_mode(
} }
if mode.next_mode { if mode.next_mode {
let mode = dbus.proxies().aura().led_mode()?; let mode = dbus.proxies().aura().led_mode()?;
let modes = dbus.proxies().aura().supported_modes()?; let modes = dbus.proxies().aura().supported_basic_modes()?;
let mut pos = modes.iter().position(|m| *m == mode).unwrap() + 1; let mut pos = modes.iter().position(|m| *m == mode).unwrap() + 1;
if pos >= modes.len() { if pos >= modes.len() {
pos = 0; pos = 0;
@@ -458,7 +471,7 @@ fn handle_led_mode(
dbus.proxies().aura().set_led_mode(modes[pos])?; dbus.proxies().aura().set_led_mode(modes[pos])?;
} else if mode.prev_mode { } else if mode.prev_mode {
let mode = dbus.proxies().aura().led_mode()?; let mode = dbus.proxies().aura().led_mode()?;
let modes = dbus.proxies().aura().supported_modes()?; let modes = dbus.proxies().aura().supported_basic_modes()?;
let mut pos = modes.iter().position(|m| *m == mode).unwrap(); let mut pos = modes.iter().position(|m| *m == mode).unwrap();
if pos == 0 { if pos == 0 {
pos = modes.len() - 1; pos = modes.len() - 1;
@@ -662,7 +675,7 @@ fn handle_throttle_profile(
supported: &[Properties], supported: &[Properties],
cmd: &ProfileCommand, cmd: &ProfileCommand,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
if !supported.contains(&Properties::DgpuDisable) { if !supported.contains(&Properties::ThrottlePolicy) {
println!("Profiles not supported by either this kernel or by the laptop."); println!("Profiles not supported by either this kernel or by the laptop.");
return Err(ProfileError::NotSupported.into()); return Err(ProfileError::NotSupported.into());
} }
@@ -691,7 +704,7 @@ fn handle_throttle_profile(
} }
if cmd.list { if cmd.list {
let res = PlatformPolicy::list(); let res = ThrottlePolicy::list();
for p in &res { for p in &res {
println!("{:?}", p); println!("{:?}", p);
} }
+1 -1
View File
@@ -22,8 +22,8 @@ rog_profiles = { path = "../rog-profiles" }
dmi_id = { path = "../dmi-id" } dmi_id = { path = "../dmi-id" }
futures-lite = "*" futures-lite = "*"
udev.workspace = true udev.workspace = true
inotify.workspace = true
async-trait.workspace = true
tokio.workspace = true tokio.workspace = true
# cli and logging # cli and logging
+161 -37
View File
@@ -1,31 +1,78 @@
use config_traits::{StdConfig, StdConfigLoad2}; use config_traits::{StdConfig, StdConfigLoad3};
use rog_platform::platform::PlatformPolicy; use rog_platform::cpu::CPUEPP;
use rog_platform::platform::ThrottlePolicy;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
const CONFIG_FILE: &str = "asusd.ron"; const CONFIG_FILE: &str = "asusd.ron";
#[derive(Deserialize, Serialize, Default, Debug)] #[derive(Deserialize, Serialize, Debug, PartialEq, PartialOrd)]
pub struct Config { pub struct Config {
/// Save charge limit for restoring on boot /// Save charge limit for restoring on boot/resume
pub charge_control_end_threshold: u8, pub charge_control_end_threshold: u8,
pub panel_od: bool, pub panel_od: bool,
pub mini_led_mode: bool, pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool, pub disable_nvidia_powerd_on_battery: bool,
/// An optional command/script to run when power is changed to AC
pub ac_command: String, pub ac_command: String,
/// An optional command/script to run when power is changed to battery
pub bat_command: String, pub bat_command: String,
/// Restored on boot as well as when power is plugged /// Set true if energy_performance_preference should be set if the
#[serde(skip)] /// throttle/platform profile is changed
pub platform_policy_to_restore: PlatformPolicy, pub throttle_policy_linked_epp: bool,
pub platform_policy_on_battery: PlatformPolicy, /// Which throttle/profile to use on battery power
pub platform_policy_on_ac: PlatformPolicy, pub throttle_policy_on_battery: ThrottlePolicy,
// /// Which throttle/profile to use on AC power
pub throttle_policy_on_ac: ThrottlePolicy,
/// The energy_performance_preference for this throttle/platform profile
pub throttle_quiet_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile
pub throttle_balanced_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile
pub throttle_performance_epp: CPUEPP,
/// Defaults to `None` if not supported
pub ppt_pl1_spl: Option<u8>, pub ppt_pl1_spl: Option<u8>,
/// Defaults to `None` if not supported
pub ppt_pl2_sppt: Option<u8>, pub ppt_pl2_sppt: Option<u8>,
/// Defaults to `None` if not supported
pub ppt_fppt: Option<u8>, pub ppt_fppt: Option<u8>,
/// Defaults to `None` if not supported
pub ppt_apu_sppt: Option<u8>, pub ppt_apu_sppt: Option<u8>,
/// Defaults to `None` if not supported
pub ppt_platform_sppt: Option<u8>, pub ppt_platform_sppt: Option<u8>,
/// Defaults to `None` if not supported
pub nv_dynamic_boost: Option<u8>, pub nv_dynamic_boost: Option<u8>,
/// Defaults to `None` if not supported
pub nv_temp_target: Option<u8>, pub nv_temp_target: Option<u8>,
/// Temporary state for AC/Batt
#[serde(skip)]
pub last_power_plugged: u8,
}
impl Default for Config {
fn default() -> Self {
Self {
charge_control_end_threshold: 100,
panel_od: false,
mini_led_mode: false,
disable_nvidia_powerd_on_battery: true,
ac_command: Default::default(),
bat_command: Default::default(),
throttle_policy_linked_epp: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet,
throttle_policy_on_ac: ThrottlePolicy::Performance,
throttle_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: Default::default(),
ppt_pl2_sppt: Default::default(),
ppt_fppt: Default::default(),
ppt_apu_sppt: Default::default(),
ppt_platform_sppt: Default::default(),
nv_dynamic_boost: Default::default(),
nv_temp_target: Default::default(),
last_power_plugged: Default::default(),
}
}
} }
impl StdConfig for Config { impl StdConfig for Config {
@@ -33,8 +80,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,
platform_policy_on_battery: PlatformPolicy::Quiet, throttle_policy_on_battery: ThrottlePolicy::Quiet,
platform_policy_on_ac: PlatformPolicy::Performance, throttle_policy_on_ac: ThrottlePolicy::Performance,
ac_command: String::new(), ac_command: String::new(),
bat_command: String::new(), bat_command: String::new(),
..Default::default() ..Default::default()
@@ -50,9 +97,109 @@ impl StdConfig for Config {
} }
} }
impl StdConfigLoad2<Config462, Config472> for Config {} impl StdConfigLoad3<Config472, Config506, Config507> for Config {}
#[derive(Deserialize, Serialize, Default, Debug)] #[derive(Deserialize, Serialize)]
pub struct Config507 {
/// Save charge limit for restoring on boot
pub charge_control_end_threshold: u8,
pub panel_od: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
pub platform_policy_linked_epp: bool,
pub platform_policy_on_battery: ThrottlePolicy,
pub platform_policy_on_ac: ThrottlePolicy,
//
pub ppt_pl1_spl: Option<u8>,
pub ppt_pl2_sppt: Option<u8>,
pub ppt_fppt: Option<u8>,
pub ppt_apu_sppt: Option<u8>,
pub ppt_platform_sppt: Option<u8>,
pub nv_dynamic_boost: Option<u8>,
pub nv_temp_target: Option<u8>,
}
impl From<Config507> for Config {
fn from(c: Config507) -> Self {
Self {
charge_control_end_threshold: c.charge_control_end_threshold,
panel_od: c.panel_od,
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command,
bat_command: c.bat_command,
mini_led_mode: c.mini_led_mode,
throttle_policy_linked_epp: true,
throttle_policy_on_battery: c.platform_policy_on_battery,
throttle_policy_on_ac: c.platform_policy_on_ac,
throttle_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: c.ppt_pl1_spl,
ppt_pl2_sppt: c.ppt_pl2_sppt,
ppt_fppt: c.ppt_fppt,
ppt_apu_sppt: c.ppt_apu_sppt,
ppt_platform_sppt: c.ppt_platform_sppt,
nv_dynamic_boost: c.nv_dynamic_boost,
nv_temp_target: c.nv_temp_target,
last_power_plugged: 0,
}
}
}
#[derive(Deserialize, Serialize)]
pub struct Config506 {
/// Save charge limit for restoring on boot
pub charge_control_end_threshold: u8,
pub panel_od: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
/// Restored on boot as well as when power is plugged
#[serde(skip)]
pub platform_policy_to_restore: ThrottlePolicy,
pub platform_policy_on_battery: ThrottlePolicy,
pub platform_policy_on_ac: ThrottlePolicy,
//
pub ppt_pl1_spl: Option<u8>,
pub ppt_pl2_sppt: Option<u8>,
pub ppt_fppt: Option<u8>,
pub ppt_apu_sppt: Option<u8>,
pub ppt_platform_sppt: Option<u8>,
pub nv_dynamic_boost: Option<u8>,
pub nv_temp_target: Option<u8>,
}
impl From<Config506> for Config {
fn from(c: Config506) -> Self {
Self {
charge_control_end_threshold: c.charge_control_end_threshold,
panel_od: c.panel_od,
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command,
bat_command: c.bat_command,
mini_led_mode: c.mini_led_mode,
throttle_policy_linked_epp: true,
throttle_policy_on_battery: c.platform_policy_on_battery,
throttle_policy_on_ac: c.platform_policy_on_ac,
throttle_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: c.ppt_pl1_spl,
ppt_pl2_sppt: c.ppt_pl2_sppt,
ppt_fppt: c.ppt_fppt,
ppt_apu_sppt: c.ppt_apu_sppt,
ppt_platform_sppt: c.ppt_platform_sppt,
nv_dynamic_boost: c.nv_dynamic_boost,
nv_temp_target: c.nv_temp_target,
last_power_plugged: 0,
}
}
}
#[derive(Deserialize, Serialize)]
pub struct Config472 { pub struct Config472 {
/// Save charge limit for restoring on boot /// Save charge limit for restoring on boot
pub bat_charge_limit: u8, pub bat_charge_limit: u8,
@@ -75,26 +222,3 @@ impl From<Config472> for Config {
} }
} }
} }
#[derive(Deserialize, Serialize)]
pub struct Config462 {
/// Save charge limit for restoring on boot
pub bat_charge_limit: u8,
pub panel_od: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
}
impl From<Config462> for Config {
fn from(c: Config462) -> Self {
Self {
charge_control_end_threshold: c.bat_charge_limit,
panel_od: c.panel_od,
disable_nvidia_powerd_on_battery: true,
ac_command: String::new(),
bat_command: String::new(),
..Default::default()
}
}
}
+16 -14
View File
@@ -1,7 +1,6 @@
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::sync::Arc; use std::sync::Arc;
use async_trait::async_trait;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::warn; use log::warn;
use logind_zbus::manager::ManagerProxy; use logind_zbus::manager::ManagerProxy;
@@ -35,7 +34,6 @@ async fn get_logind_manager<'a>() -> ManagerProxy<'a> {
pub struct CtrlAnimeZbus(pub Arc<Mutex<CtrlAnime>>); pub struct CtrlAnimeZbus(pub Arc<Mutex<CtrlAnime>>);
/// The struct with the main dbus methods requires this trait /// The struct with the main dbus methods requires this trait
#[async_trait]
impl crate::ZbusRun for CtrlAnimeZbus { impl crate::ZbusRun for CtrlAnimeZbus {
async fn add_to_server(self, server: &mut Connection) { async fn add_to_server(self, server: &mut Connection) {
Self::add_to_server_helper(self, ANIME_ZBUS_PATH, server).await; Self::add_to_server_helper(self, ANIME_ZBUS_PATH, server).await;
@@ -259,7 +257,6 @@ impl CtrlAnimeZbus {
} }
} }
#[async_trait]
impl crate::CtrlTask for CtrlAnimeZbus { impl crate::CtrlTask for CtrlAnimeZbus {
fn zbus_path() -> &'static str { fn zbus_path() -> &'static str {
ANIME_ZBUS_PATH ANIME_ZBUS_PATH
@@ -277,16 +274,8 @@ impl crate::CtrlTask for CtrlAnimeZbus {
async move { async move {
let lock = inner.lock().await; let lock = inner.lock().await;
if lock.config.display_enabled { if lock.config.display_enabled {
lock.node
.write_bytes(&pkt_set_enable_powersave_anim(
!(sleeping && lock.config.off_when_suspended),
))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_suspended {}", err);
})
.ok();
lock.thread_exit.store(true, Ordering::Release); // ensure clean slate lock.thread_exit.store(true, Ordering::Release); // ensure clean slate
lock.node lock.node
.write_bytes(&pkt_set_enable_display( .write_bytes(&pkt_set_enable_display(
!(sleeping && lock.config.off_when_suspended), !(sleeping && lock.config.off_when_suspended),
@@ -296,7 +285,21 @@ impl crate::CtrlTask for CtrlAnimeZbus {
}) })
.ok(); .ok();
if !sleeping && !lock.config.builtin_anims_enabled { if lock.config.builtin_anims_enabled {
lock.node
.write_bytes(&pkt_set_enable_powersave_anim(
!(sleeping && lock.config.off_when_suspended),
))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_suspended {}", err);
})
.ok();
} else if !sleeping && !lock.config.builtin_anims_enabled {
// Run custom wake animation
lock.node
.write_bytes(&pkt_set_enable_powersave_anim(false))
.ok(); // ensure builtins are disabled
CtrlAnime::run_thread(inner.clone(), lock.cache.wake.clone(), true) CtrlAnime::run_thread(inner.clone(), lock.cache.wake.clone(), true)
.await; .await;
} }
@@ -379,7 +382,6 @@ impl crate::CtrlTask for CtrlAnimeZbus {
} }
} }
#[async_trait]
impl crate::Reloadable for CtrlAnimeZbus { impl crate::Reloadable for CtrlAnimeZbus {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
if let Some(lock) = self.0.try_lock() { if let Some(lock) = self.0.try_lock() {
+11 -11
View File
@@ -25,13 +25,13 @@ pub struct CtrlKbdLed {
pub led_prod: AuraDevice, pub led_prod: AuraDevice,
pub led_node: LEDNode, pub led_node: LEDNode,
pub sysfs_node: KeyboardLed, pub sysfs_node: KeyboardLed,
pub supported_modes: LaptopLedData, pub supported_data: LaptopLedData,
pub per_key_mode_active: bool, pub per_key_mode_active: bool,
pub config: AuraConfig, pub config: AuraConfig,
} }
impl CtrlKbdLed { impl CtrlKbdLed {
pub fn new(supported_modes: LaptopLedData) -> Result<Self, RogError> { pub fn new(supported_basic_modes: LaptopLedData) -> Result<Self, RogError> {
let mut led_prod = AuraDevice::Unknown; let mut led_prod = AuraDevice::Unknown;
let mut usb_node = None; let mut usb_node = None;
for prod in ASUS_KEYBOARD_DEVICES { for prod in ASUS_KEYBOARD_DEVICES {
@@ -97,7 +97,7 @@ impl CtrlKbdLed {
let mut new_set = Vec::new(); let mut new_set = Vec::new();
// only reuse a zone mode if the mode is supported // only reuse a zone mode if the mode is supported
for mode in loaded { for mode in loaded {
if supported_modes.basic_modes.contains(&mode.mode) { if supported_basic_modes.basic_modes.contains(&mode.mode) {
new_set.push(mode.clone()); new_set.push(mode.clone());
} }
} }
@@ -111,7 +111,7 @@ impl CtrlKbdLed {
led_prod, led_prod,
led_node, // on TUF this is the same as rgb_led / kd_brightness led_node, // on TUF this is the same as rgb_led / kd_brightness
sysfs_node: rgb_led, // If was none then we already returned above sysfs_node: rgb_led, // If was none then we already returned above
supported_modes, supported_data: supported_basic_modes,
per_key_mode_active: false, per_key_mode_active: false,
config: config_loaded, config: config_loaded,
}; };
@@ -245,7 +245,7 @@ impl CtrlKbdLed {
/// exists. /// exists.
fn create_multizone_default(&mut self) -> Result<(), RogError> { fn create_multizone_default(&mut self) -> Result<(), RogError> {
let mut default = vec![]; let mut default = vec![];
for (i, tmp) in self.supported_modes.basic_zones.iter().enumerate() { for (i, tmp) in self.supported_data.basic_zones.iter().enumerate() {
default.push(AuraEffect { default.push(AuraEffect {
mode: self.config.current_mode, mode: self.config.current_mode,
zone: *tmp, zone: *tmp,
@@ -285,7 +285,7 @@ mod tests {
fn create_multizone_if_no_config() { fn create_multizone_if_no_config() {
// Checking to ensure set_mode errors when unsupported modes are tried // Checking to ensure set_mode errors when unsupported modes are tried
let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default()); let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
let supported_modes = LaptopLedData { let supported_basic_modes = LaptopLedData {
board_name: String::new(), board_name: String::new(),
layout_name: "ga401".to_owned(), layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static], basic_modes: vec![AuraModeNum::Static],
@@ -297,7 +297,7 @@ mod tests {
led_prod: AuraDevice::X19b6, led_prod: AuraDevice::X19b6,
led_node: LEDNode::None, led_node: LEDNode::None,
sysfs_node: KeyboardLed::default(), sysfs_node: KeyboardLed::default(),
supported_modes, supported_data: supported_basic_modes,
per_key_mode_active: false, per_key_mode_active: false,
config, config,
}; };
@@ -306,8 +306,8 @@ mod tests {
assert!(controller.create_multizone_default().is_err()); assert!(controller.create_multizone_default().is_err());
assert!(controller.config.multizone.is_none()); assert!(controller.config.multizone.is_none());
controller.supported_modes.basic_zones.push(AuraZone::Key1); controller.supported_data.basic_zones.push(AuraZone::Key1);
controller.supported_modes.basic_zones.push(AuraZone::Key2); controller.supported_data.basic_zones.push(AuraZone::Key2);
assert!(controller.create_multizone_default().is_ok()); assert!(controller.create_multizone_default().is_ok());
assert!(controller.config.multizone.is_some()); assert!(controller.config.multizone.is_some());
@@ -323,7 +323,7 @@ mod tests {
fn next_mode_create_multizone_if_no_config() { fn next_mode_create_multizone_if_no_config() {
// Checking to ensure set_mode errors when unsupported modes are tried // Checking to ensure set_mode errors when unsupported modes are tried
let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default()); let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
let supported_modes = LaptopLedData { let supported_basic_modes = LaptopLedData {
board_name: String::new(), board_name: String::new(),
layout_name: "ga401".to_owned(), layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static], basic_modes: vec![AuraModeNum::Static],
@@ -335,7 +335,7 @@ mod tests {
led_prod: AuraDevice::X19b6, led_prod: AuraDevice::X19b6,
led_node: LEDNode::None, led_node: LEDNode::None,
sysfs_node: KeyboardLed::default(), sysfs_node: KeyboardLed::default(),
supported_modes, supported_data: supported_basic_modes,
per_key_mode_active: false, per_key_mode_active: false,
config, config,
}; };
+16 -7
View File
@@ -1,10 +1,10 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::sync::Arc; use std::sync::Arc;
use async_trait::async_trait;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_aura::advanced::UsbPackets; use rog_aura::advanced::UsbPackets;
use rog_aura::aura_detection::PowerZones;
use rog_aura::usb::{AuraDevice, AuraPowerDev}; use rog_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use zbus::export::futures_util::lock::{Mutex, MutexGuard}; use zbus::export::futures_util::lock::{Mutex, MutexGuard};
@@ -32,7 +32,6 @@ impl CtrlAuraZbus {
} }
} }
#[async_trait]
impl crate::ZbusRun for CtrlAuraZbus { impl crate::ZbusRun for CtrlAuraZbus {
async fn add_to_server(self, server: &mut Connection) { async fn add_to_server(self, server: &mut Connection) {
Self::add_to_server_helper(self, AURA_ZBUS_PATH, server).await; Self::add_to_server_helper(self, AURA_ZBUS_PATH, server).await;
@@ -78,11 +77,23 @@ impl CtrlAuraZbus {
/// The total available modes /// The total available modes
#[dbus_interface(property)] #[dbus_interface(property)]
async fn supported_modes(&self) -> Result<Vec<AuraModeNum>, ZbErr> { async fn supported_basic_modes(&self) -> Result<Vec<AuraModeNum>, ZbErr> {
let ctrl = self.0.lock().await; let ctrl = self.0.lock().await;
Ok(ctrl.config.builtins.keys().cloned().collect()) Ok(ctrl.config.builtins.keys().cloned().collect())
} }
#[dbus_interface(property)]
async fn supported_basic_zones(&self) -> Result<Vec<AuraZone>, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.supported_data.basic_zones.clone())
}
#[dbus_interface(property)]
async fn supported_power_zones(&self) -> Result<Vec<PowerZones>, ZbErr> {
let ctrl = self.0.lock().await;
Ok(ctrl.supported_data.power_zones.clone())
}
/// The current mode data /// The current mode data
#[dbus_interface(property)] #[dbus_interface(property)]
async fn led_mode(&self) -> Result<AuraModeNum, ZbErr> { async fn led_mode(&self) -> Result<AuraModeNum, ZbErr> {
@@ -126,9 +137,9 @@ impl CtrlAuraZbus {
#[dbus_interface(property)] #[dbus_interface(property)]
async fn set_led_mode_data(&mut self, effect: AuraEffect) -> Result<(), ZbErr> { async fn set_led_mode_data(&mut self, effect: AuraEffect) -> Result<(), ZbErr> {
let mut ctrl = self.0.lock().await; let mut ctrl = self.0.lock().await;
if !ctrl.supported_modes.basic_modes.contains(&effect.mode) if !ctrl.supported_data.basic_modes.contains(&effect.mode)
|| effect.zone != AuraZone::None || effect.zone != AuraZone::None
&& !ctrl.supported_modes.basic_zones.contains(&effect.zone) && !ctrl.supported_data.basic_zones.contains(&effect.zone)
{ {
return Err(ZbErr::NotSupported(format!( return Err(ZbErr::NotSupported(format!(
"The Aura effect is not supported: {effect:?}" "The Aura effect is not supported: {effect:?}"
@@ -192,7 +203,6 @@ impl CtrlAuraZbus {
} }
} }
#[async_trait]
impl CtrlTask for CtrlAuraZbus { impl CtrlTask for CtrlAuraZbus {
fn zbus_path() -> &'static str { fn zbus_path() -> &'static str {
AURA_ZBUS_PATH AURA_ZBUS_PATH
@@ -265,7 +275,6 @@ impl CtrlTask for CtrlAuraZbus {
} }
} }
#[async_trait]
impl crate::Reloadable for CtrlAuraZbus { impl crate::Reloadable for CtrlAuraZbus {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
let mut ctrl = self.0.lock().await; let mut ctrl = self.0.lock().await;
+29 -37
View File
@@ -1,11 +1,10 @@
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use async_trait::async_trait;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_lite::StreamExt; use futures_lite::StreamExt;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::platform::{PlatformPolicy, RogPlatform}; use rog_platform::platform::{RogPlatform, ThrottlePolicy};
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};
@@ -70,19 +69,19 @@ impl CtrlFanCurveZbus {
info!("{MOD_NAME}: Fetching default fan curves"); info!("{MOD_NAME}: Fetching default fan curves");
for this in [ for this in [
PlatformPolicy::Balanced, ThrottlePolicy::Balanced,
PlatformPolicy::Performance, ThrottlePolicy::Performance,
PlatformPolicy::Quiet, ThrottlePolicy::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.
let next = PlatformPolicy::get_next_profile(this); let next = ThrottlePolicy::next(this);
platform.set_throttle_thermal_policy(next.into())?; platform.set_throttle_thermal_policy(next.into())?;
let active = platform let active = platform
.get_throttle_thermal_policy() .get_throttle_thermal_policy()
.map_or(PlatformPolicy::Balanced, |t| t.into()); .map_or(ThrottlePolicy::Balanced, |t| t.into());
info!("{MOD_NAME}: {active:?}:"); info!("{MOD_NAME}: {active:?}:");
for curve in fan_curves.get_fan_curves_for(active) { for curve in fan_curves.get_fan_curves_for(active) {
@@ -130,7 +129,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: PlatformPolicy, profile: ThrottlePolicy,
enabled: bool, enabled: bool,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.fan_curves self.fan_curves
@@ -150,7 +149,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: PlatformPolicy, profile: ThrottlePolicy,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
@@ -167,10 +166,10 @@ impl CtrlFanCurveZbus {
Ok(()) Ok(())
} }
/// Get the fan-curve data for the currently active PlatformPolicy /// 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: PlatformPolicy, profile: ThrottlePolicy,
) -> zbus::fdo::Result<Vec<CurveData>> { ) -> zbus::fdo::Result<Vec<CurveData>> {
let curve = self let curve = self
.fan_curves .fan_curves
@@ -185,7 +184,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: PlatformPolicy, profile: ThrottlePolicy,
curve: CurveData, curve: CurveData,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.fan_curves self.fan_curves
@@ -222,19 +221,14 @@ 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: PlatformPolicy) -> zbus::fdo::Result<()> { async fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> {
let active = self let active = self.platform.get_throttle_thermal_policy()?;
.platform
.get_throttle_thermal_policy()
.unwrap_or(PlatformPolicy::Balanced.into());
self.platform.set_throttle_thermal_policy(profile.into())?; self.platform.set_throttle_thermal_policy(profile.into())?;
{ self.fan_curves
self.fan_curves .lock()
.lock() .await
.await .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_throttle_thermal_policy(active)?;
self.update_config_from_profiles().await; self.update_config_from_profiles().await;
@@ -243,14 +237,12 @@ impl CtrlFanCurveZbus {
} }
} }
#[async_trait]
impl crate::ZbusRun for CtrlFanCurveZbus { impl crate::ZbusRun for CtrlFanCurveZbus {
async fn add_to_server(self, server: &mut Connection) { async fn add_to_server(self, server: &mut Connection) {
Self::add_to_server_helper(self, FAN_CURVE_ZBUS_PATH, server).await; Self::add_to_server_helper(self, FAN_CURVE_ZBUS_PATH, server).await;
} }
} }
#[async_trait]
impl CtrlTask for CtrlFanCurveZbus { impl CtrlTask for CtrlFanCurveZbus {
fn zbus_path() -> &'static str { fn zbus_path() -> &'static str {
FAN_CURVE_ZBUS_PATH FAN_CURVE_ZBUS_PATH
@@ -286,7 +278,6 @@ impl CtrlTask for CtrlFanCurveZbus {
} }
} }
} }
dbg!("STREAM ENDED");
} }
}); });
@@ -294,20 +285,21 @@ impl CtrlTask for CtrlFanCurveZbus {
} }
} }
#[async_trait]
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_throttle_thermal_policy()?.into();
// if let Ok(mut device) = find_fan_curve_node() { if let Ok(mut device) = find_fan_curve_node() {
// // There is a possibility that the curve was default zeroed, so this call // There is a possibility that the curve was default zeroed, so this call
// // initialises the data from system read and we need to save it // initialises the data from system read and we need to save it
// // after // after
// self.fan_curves loop {
// .lock() if let Ok(mut curves) = self.fan_curves.try_lock() {
// .await curves.write_profile_curve_to_platform(active, &mut device)?;
// .write_profile_curve_to_platform(active, &mut device)?; break;
// } }
}
}
Ok(()) Ok(())
} }
} }
+307 -48
View File
@@ -1,11 +1,11 @@
use std::path::Path;
use std::process::Command; use std::process::Command;
use std::sync::Arc; use std::sync::Arc;
use async_trait::async_trait;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::cpu::{CPUControl, CPUGovernor}; use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties, RogPlatform}; use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex; use zbus::export::futures_util::lock::Mutex;
use zbus::fdo::Error as FdoErr; use zbus::fdo::Error as FdoErr;
@@ -16,9 +16,10 @@ use crate::ctrl_anime::trait_impls::{CtrlAnimeZbus, ANIME_ZBUS_NAME, ANIME_ZBUS_
use crate::ctrl_aura::trait_impls::{CtrlAuraZbus, AURA_ZBUS_NAME, AURA_ZBUS_PATH}; use crate::ctrl_aura::trait_impls::{CtrlAuraZbus, AURA_ZBUS_NAME, AURA_ZBUS_PATH};
use crate::ctrl_fancurves::{CtrlFanCurveZbus, FAN_CURVE_ZBUS_NAME, FAN_CURVE_ZBUS_PATH}; use crate::ctrl_fancurves::{CtrlFanCurveZbus, FAN_CURVE_ZBUS_NAME, FAN_CURVE_ZBUS_PATH};
use crate::error::RogError; use crate::error::RogError;
use crate::{task_watch_item, task_watch_item_notify, CtrlTask}; use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify};
const ZBUS_PATH: &str = "/org/asuslinux/Platform"; const PLATFORM_ZBUS_NAME: &str = "Platform";
const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux/Platform";
macro_rules! platform_get_value { macro_rules! platform_get_value {
($self:ident, $property:tt, $prop_name:literal) => { ($self:ident, $property:tt, $prop_name:literal) => {
@@ -33,7 +34,7 @@ macro_rules! platform_get_value {
}) })
}) })
} else { } else {
error!("RogPlatform: {} not supported", $prop_name); info!("RogPlatform: {} not supported", $prop_name);
return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name))); return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)));
} }
}) })
@@ -45,9 +46,9 @@ macro_rules! platform_get_value_if_some {
concat_idents::concat_idents!(has = has_, $property { concat_idents::concat_idents!(has = has_, $property {
if $self.platform.has() { if $self.platform.has() {
let lock = $self.config.lock().await; let lock = $self.config.lock().await;
Ok(lock.ppt_pl1_spl.unwrap_or($default)) Ok(lock.$property.unwrap_or($default))
} else { } else {
error!("RogPlatform: {} not supported", $prop_name); info!("RogPlatform: {} not supported", $prop_name);
return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name))); return Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)));
} }
}) })
@@ -69,7 +70,7 @@ macro_rules! platform_set_bool {
lock.write(); lock.write();
Ok(()) Ok(())
} else { } else {
error!("RogPlatform: {} not supported", $prop_name); info!("RogPlatform: {} not supported", $prop_name);
Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name))) Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)))
} }
}) })
@@ -115,7 +116,11 @@ pub struct CtrlPlatform {
} }
impl CtrlPlatform { impl CtrlPlatform {
pub fn new(config: Arc<Mutex<Config>>) -> Result<Self, RogError> { pub fn new(
config: Arc<Mutex<Config>>,
config_path: &Path,
signal_context: SignalContext<'static>,
) -> Result<Self, RogError> {
let platform = RogPlatform::new()?; let platform = RogPlatform::new()?;
let power = AsusPower::new()?; let power = AsusPower::new()?;
@@ -124,14 +129,70 @@ impl CtrlPlatform {
info!("Standard graphics switching will still work."); info!("Standard graphics switching will still work.");
} }
Ok(CtrlPlatform { let config1 = config.clone();
let config_path = config_path.to_owned();
let ret_self = CtrlPlatform {
power, power,
platform, platform,
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}"))
.ok(), .ok(),
}) };
let mut inotify_self = ret_self.clone();
tokio::spawn(async move {
use zbus::export::futures_util::StreamExt;
info!("Starting inotify watch for asusd config file");
let mut buffer = [0; 32];
loop {
// vi and vim do stupid shit causing the file watch to be removed
let inotify = inotify::Inotify::init().unwrap();
inotify
.watches()
.add(
&config_path,
inotify::WatchMask::MODIFY
| inotify::WatchMask::CLOSE_WRITE
| inotify::WatchMask::ATTRIB
| inotify::WatchMask::CREATE,
)
.map_err(|e| {
if e.kind() == std::io::ErrorKind::NotFound {
error!("Not found: {:?}", config_path);
} else {
error!("Could not set asusd config inotify: {:?}", config_path);
}
e
})
.ok();
let mut events = inotify.into_event_stream(&mut buffer).unwrap();
while let Some(ev) = events.next().await {
if let Ok(ev) = ev {
if ev.mask == inotify::EventMask::IGNORED {
warn!(
"Something modified asusd.ron vi/vim style. Now need to reload \
inotify watch"
);
break;
}
}
let res = config1.lock().await.read_new();
if let Some(new_cfg) = res {
inotify_self
.reload_and_notify(&signal_context, new_cfg)
.await
.unwrap();
}
}
}
});
Ok(ret_self)
} }
fn set_gfx_mode(&self, mode: GpuMode) -> Result<(), RogError> { fn set_gfx_mode(&self, mode: GpuMode) -> Result<(), RogError> {
@@ -180,14 +241,18 @@ impl CtrlPlatform {
} }
} }
fn check_and_set_epp(&self, profile: PlatformPolicy) { fn check_and_set_epp(&self, enegy_pref: CPUEPP, change_epp: bool) {
info!("PlatformPolicy setting EPP"); if !change_epp {
info!("ThrottlePolicy unlinked from EPP");
return;
}
info!("ThrottlePolicy setting EPP");
if let Some(cpu) = self.cpu_control.as_ref() { if let Some(cpu) = self.cpu_control.as_ref() {
if let Ok(epp) = cpu.get_available_epp() { if let Ok(epp) = cpu.get_available_epp() {
debug!("Available EPP: {epp:?}"); debug!("Available EPP: {epp:?}");
if epp.contains(&profile.into()) { if epp.contains(&enegy_pref) {
debug!("Setting {profile:?}"); debug!("Setting {enegy_pref:?}");
cpu.set_epp(profile.into()).ok(); cpu.set_epp(enegy_pref).ok();
} else if let Ok(gov) = cpu.get_governor() { } else if let Ok(gov) = cpu.get_governor() {
if gov != CPUGovernor::Powersave { if gov != CPUGovernor::Powersave {
warn!("powersave governor is not is use, you should use it."); warn!("powersave governor is not is use, you should use it.");
@@ -197,16 +262,26 @@ impl CtrlPlatform {
} }
} }
async fn update_policy_ac_or_bat(&self, power_plugged: bool) { async fn get_config_epp_for_throttle(&self, throttle: ThrottlePolicy) -> CPUEPP {
let profile = if power_plugged { match throttle {
self.config.lock().await.platform_policy_on_ac ThrottlePolicy::Balanced => self.config.lock().await.throttle_balanced_epp,
ThrottlePolicy::Performance => self.config.lock().await.throttle_performance_epp,
ThrottlePolicy::Quiet => self.config.lock().await.throttle_quiet_epp,
}
}
async fn update_policy_ac_or_bat(&self, power_plugged: bool, change_epp: bool) {
let throttle = if power_plugged {
self.config.lock().await.throttle_policy_on_ac
} else { } else {
self.config.lock().await.platform_policy_on_battery self.config.lock().await.throttle_policy_on_battery
}; };
debug!("Setting {throttle:?} before EPP");
let epp = self.get_config_epp_for_throttle(throttle).await;
self.platform self.platform
.set_throttle_thermal_policy(profile.into()) .set_throttle_thermal_policy(throttle.into())
.ok(); .ok();
self.check_and_set_epp(profile); self.check_and_set_epp(epp, change_epp);
} }
} }
@@ -248,7 +323,7 @@ impl CtrlPlatform {
platform_name!(panel_od, Properties::PanelOd); platform_name!(panel_od, Properties::PanelOd);
platform_name!(mini_led_mode, Properties::MiniLedMode); platform_name!(mini_led_mode, Properties::MiniLedMode);
platform_name!(egpu_enable, Properties::EgpuEnable); platform_name!(egpu_enable, Properties::EgpuEnable);
platform_name!(throttle_thermal_policy, Properties::PlatformPolicy); platform_name!(throttle_thermal_policy, Properties::ThrottlePolicy);
platform_name!(ppt_pl1_spl, Properties::PptPl1Spl); platform_name!(ppt_pl1_spl, Properties::PptPl1Spl);
platform_name!(ppt_pl2_sppt, Properties::PptPl2Sppt); platform_name!(ppt_pl2_sppt, Properties::PptPl2Sppt);
@@ -287,6 +362,13 @@ impl CtrlPlatform {
{ {
interfaces.push(FAN_CURVE_ZBUS_NAME.to_owned()); interfaces.push(FAN_CURVE_ZBUS_NAME.to_owned());
} }
if server
.interface::<_, CtrlPlatform>(PLATFORM_ZBUS_PATH)
.await
.is_ok()
{
interfaces.push(PLATFORM_ZBUS_NAME.to_owned());
}
interfaces interfaces
} }
@@ -334,20 +416,21 @@ impl CtrlPlatform {
&mut self, &mut self,
#[zbus(signal_context)] ctxt: SignalContext<'_>, #[zbus(signal_context)] ctxt: SignalContext<'_>,
) -> Result<(), FdoErr> { ) -> Result<(), FdoErr> {
let policy: PlatformPolicy = let policy: ThrottlePolicy =
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
.map(|n| n.into())?; .map(|n| n.into())?;
let policy = PlatformPolicy::next(&policy); let policy = ThrottlePolicy::next(policy);
if self.platform.has_throttle_thermal_policy() { if self.platform.has_throttle_thermal_policy() {
self.check_and_set_epp(policy); let change_epp = self.config.lock().await.throttle_policy_linked_epp;
let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp);
self.platform self.platform
.set_throttle_thermal_policy(policy.into()) .set_throttle_thermal_policy(policy.into())
.map_err(|err| { .map_err(|err| {
warn!("RogPlatform: throttle_thermal_policy {}", err); warn!("RogPlatform: throttle_thermal_policy {}", err);
FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}")) FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}"))
})?; })?;
self.config.lock().await.platform_policy_to_restore = policy;
Ok(self.throttle_thermal_policy_changed(&ctxt).await?) Ok(self.throttle_thermal_policy_changed(&ctxt).await?)
} else { } else {
Err(FdoErr::NotSupported( Err(FdoErr::NotSupported(
@@ -357,17 +440,18 @@ impl CtrlPlatform {
} }
#[dbus_interface(property)] #[dbus_interface(property)]
fn throttle_thermal_policy(&self) -> Result<PlatformPolicy, FdoErr> { fn throttle_thermal_policy(&self) -> Result<ThrottlePolicy, FdoErr> {
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
.map(|n| n.into()) .map(|n| n.into())
} }
#[dbus_interface(property)] #[dbus_interface(property)]
async fn set_throttle_thermal_policy(&mut self, policy: PlatformPolicy) -> Result<(), FdoErr> { async fn set_throttle_thermal_policy(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
// TODO: watch for external changes // TODO: watch for external changes
if self.platform.has_throttle_thermal_policy() { if self.platform.has_throttle_thermal_policy() {
self.check_and_set_epp(policy); let change_epp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.platform_policy_to_restore = policy; let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp);
self.platform self.platform
.set_throttle_thermal_policy(policy.into()) .set_throttle_thermal_policy(policy.into())
.map_err(|err| { .map_err(|err| {
@@ -381,6 +465,91 @@ impl CtrlPlatform {
} }
} }
#[dbus_interface(property)]
async fn throttle_policy_linked_epp(&self) -> Result<bool, FdoErr> {
Ok(self.config.lock().await.throttle_policy_linked_epp)
}
#[dbus_interface(property)]
async fn set_throttle_policy_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> {
self.config.lock().await.throttle_policy_linked_epp = linked;
Ok(())
}
#[dbus_interface(property)]
async fn throttle_policy_on_battery(&self) -> Result<ThrottlePolicy, FdoErr> {
Ok(self.config.lock().await.throttle_policy_on_battery)
}
#[dbus_interface(property)]
async fn set_throttle_policy_on_battery(
&mut self,
policy: ThrottlePolicy,
) -> Result<(), FdoErr> {
self.config.lock().await.throttle_policy_on_battery = policy;
self.set_throttle_thermal_policy(policy).await?;
Ok(())
}
#[dbus_interface(property)]
async fn throttle_policy_on_ac(&self) -> Result<ThrottlePolicy, FdoErr> {
Ok(self.config.lock().await.throttle_policy_on_ac)
}
#[dbus_interface(property)]
async fn set_throttle_policy_on_ac(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
self.config.lock().await.throttle_policy_on_ac = policy;
self.set_throttle_thermal_policy(policy).await?;
Ok(())
}
/// The energy_performance_preference for the quiet throttle/platform
/// profile
#[dbus_interface(property)]
async fn throttle_quiet_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_quiet_epp)
}
#[dbus_interface(property)]
async fn set_throttle_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_quiet_epp = epp;
self.check_and_set_epp(epp, change_pp);
Ok(())
}
/// The energy_performance_preference for the balanced throttle/platform
/// profile
#[dbus_interface(property)]
async fn throttle_balanced_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_balanced_epp)
}
#[dbus_interface(property)]
async fn set_throttle_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_balanced_epp = epp;
self.check_and_set_epp(epp, change_pp);
Ok(())
}
/// The energy_performance_preference for the performance throttle/platform
/// profile
#[dbus_interface(property)]
async fn throttle_performance_epp(&self) -> Result<CPUEPP, FdoErr> {
Ok(self.config.lock().await.throttle_performance_epp)
}
#[dbus_interface(property)]
async fn set_throttle_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> {
let change_pp = self.config.lock().await.throttle_policy_linked_epp;
self.config.lock().await.throttle_performance_epp = epp;
self.check_and_set_epp(epp, change_pp);
Ok(())
}
/// ***********************************************************************
#[dbus_interface(property)] #[dbus_interface(property)]
fn post_animation_sound(&self) -> Result<bool, FdoErr> { fn post_animation_sound(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, post_animation_sound, "post_animation_sound") platform_get_value!(self, post_animation_sound, "post_animation_sound")
@@ -434,7 +603,10 @@ impl CtrlPlatform {
platform_get_value!(self, egpu_enable, "egpu_enable") platform_get_value!(self, egpu_enable, "egpu_enable")
} }
/// ************************************************************************ /// ***********************************************************************
/// Set the Package Power Target total of CPU: PL1 on Intel, SPL on AMD.
/// Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
#[dbus_interface(property)] #[dbus_interface(property)]
async fn ppt_pl1_spl(&self) -> Result<u8, FdoErr> { async fn ppt_pl1_spl(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_pl1_spl, "ppt_pl1_spl", 5) platform_get_value_if_some!(self, ppt_pl1_spl, "ppt_pl1_spl", 5)
@@ -445,6 +617,9 @@ impl CtrlPlatform {
platform_set_with_min_max!(self, ppt_pl1_spl, "ppt_pl1_spl", value, 5, 250) platform_set_with_min_max!(self, ppt_pl1_spl, "ppt_pl1_spl", value, 5, 250)
} }
/// Set the Slow Package Power Tracking Limit of CPU: PL2 on Intel, SPPT,
/// on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
#[dbus_interface(property)] #[dbus_interface(property)]
async fn ppt_pl2_sppt(&self) -> Result<u8, FdoErr> { async fn ppt_pl2_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_pl2_sppt, "ppt_pl2_sppt", 5) platform_get_value_if_some!(self, ppt_pl2_sppt, "ppt_pl2_sppt", 5)
@@ -455,6 +630,8 @@ impl CtrlPlatform {
platform_set_with_min_max!(self, ppt_pl2_sppt, "ppt_pl2_sppt", value, 5, 250) platform_set_with_min_max!(self, ppt_pl2_sppt, "ppt_pl2_sppt", value, 5, 250)
} }
/// Set the Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
/// * min=5, max=250
#[dbus_interface(property)] #[dbus_interface(property)]
async fn ppt_fppt(&self) -> Result<u8, FdoErr> { async fn ppt_fppt(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_fppt, "ppt_fppt", 5) platform_get_value_if_some!(self, ppt_fppt, "ppt_fppt", 5)
@@ -465,6 +642,8 @@ impl CtrlPlatform {
platform_set_with_min_max!(self, ppt_fppt, "ppt_fppt", value, 5, 250) platform_set_with_min_max!(self, ppt_fppt, "ppt_fppt", value, 5, 250)
} }
/// Set the APU SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
#[dbus_interface(property)] #[dbus_interface(property)]
async fn ppt_apu_sppt(&self) -> Result<u8, FdoErr> { async fn ppt_apu_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_apu_sppt, "ppt_apu_sppt", 5) platform_get_value_if_some!(self, ppt_apu_sppt, "ppt_apu_sppt", 5)
@@ -475,6 +654,8 @@ impl CtrlPlatform {
platform_set_with_min_max!(self, ppt_apu_sppt, "ppt_apu_sppt", value, 5, 130) platform_set_with_min_max!(self, ppt_apu_sppt, "ppt_apu_sppt", value, 5, 130)
} }
/// Set the platform SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
#[dbus_interface(property)] #[dbus_interface(property)]
async fn ppt_platform_sppt(&self) -> Result<u8, FdoErr> { async fn ppt_platform_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, ppt_platform_sppt, "ppt_platform_sppt", 5) platform_get_value_if_some!(self, ppt_platform_sppt, "ppt_platform_sppt", 5)
@@ -485,6 +666,8 @@ impl CtrlPlatform {
platform_set_with_min_max!(self, ppt_platform_sppt, "ppt_platform_sppt", value, 5, 130) platform_set_with_min_max!(self, ppt_platform_sppt, "ppt_platform_sppt", value, 5, 130)
} }
/// Set the dynamic boost limit of the Nvidia dGPU:
/// * min=5, max=25
#[dbus_interface(property)] #[dbus_interface(property)]
async fn nv_dynamic_boost(&self) -> Result<u8, FdoErr> { async fn nv_dynamic_boost(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, nv_dynamic_boost, "nv_dynamic_boost", 5) platform_get_value_if_some!(self, nv_dynamic_boost, "nv_dynamic_boost", 5)
@@ -495,6 +678,8 @@ impl CtrlPlatform {
platform_set_with_min_max!(self, nv_dynamic_boost, "nv_dynamic_boost", value, 5, 25) platform_set_with_min_max!(self, nv_dynamic_boost, "nv_dynamic_boost", value, 5, 25)
} }
/// Set the target temperature limit of the Nvidia dGPU:
/// * min=75, max=87
#[dbus_interface(property)] #[dbus_interface(property)]
async fn nv_temp_target(&self) -> Result<u8, FdoErr> { async fn nv_temp_target(&self) -> Result<u8, FdoErr> {
platform_get_value_if_some!(self, nv_temp_target, "nv_temp_target", 5) platform_get_value_if_some!(self, nv_temp_target, "nv_temp_target", 5)
@@ -506,14 +691,75 @@ impl CtrlPlatform {
} }
} }
#[async_trait]
impl crate::ZbusRun for CtrlPlatform { impl crate::ZbusRun for CtrlPlatform {
async fn add_to_server(self, server: &mut Connection) { async fn add_to_server(self, server: &mut Connection) {
Self::add_to_server_helper(self, ZBUS_PATH, server).await; Self::add_to_server_helper(self, PLATFORM_ZBUS_PATH, server).await;
}
}
impl ReloadAndNotify for CtrlPlatform {
type Data = Config;
async fn reload_and_notify(
&mut self,
signal_context: &SignalContext<'static>,
data: Self::Data,
) -> Result<(), RogError> {
let mut config = self.config.lock().await;
if *config != data {
info!("asusd.ron updated externally, reloading and updating internal copy");
if self.power.has_charge_control_end_threshold() {
self.power
.set_charge_control_end_threshold(data.charge_control_end_threshold)?;
self.charge_control_end_threshold_changed(signal_context)
.await?;
}
if self.platform.has_panel_od() && config.panel_od != data.panel_od {
self.platform.set_panel_od(data.panel_od)?;
self.panel_od_changed(signal_context).await?;
}
if self.platform.has_mini_led_mode() && config.mini_led_mode != data.mini_led_mode {
self.platform.set_mini_led_mode(data.mini_led_mode)?;
self.mini_led_mode_changed(signal_context).await?;
}
if self.platform.has_throttle_thermal_policy()
&& config.throttle_policy_linked_epp != data.throttle_policy_linked_epp
{
// TODO: extra stuff
}
macro_rules! ppt_reload_and_notify {
($property:tt, $prop_name:literal) => {
concat_idents::concat_idents!(has = has_, $property {
if self.platform.has() && config.$property != data.$property {
concat_idents::concat_idents!(set = set_, $property {
self.platform
.set_ppt_pl1_spl(data.$property.unwrap_or_default())?;});
concat_idents::concat_idents!(changed = $property, _changed {
self.ppt_pl1_spl_changed(signal_context).await?;});
}
})
}
}
ppt_reload_and_notify!(ppt_pl1_spl, "ppt_pl1_spl");
ppt_reload_and_notify!(ppt_pl2_sppt, "ppt_pl2_sppt");
ppt_reload_and_notify!(ppt_fppt, "ppt_fppt");
ppt_reload_and_notify!(ppt_apu_sppt, "ppt_apu_sppt");
ppt_reload_and_notify!(ppt_platform_sppt, "ppt_platform_sppt");
ppt_reload_and_notify!(nv_dynamic_boost, "nv_dynamic_boost");
ppt_reload_and_notify!(nv_temp_target, "nv_temp_target");
*config = data;
}
Ok(())
} }
} }
#[async_trait]
impl crate::Reloadable for CtrlPlatform { impl crate::Reloadable for CtrlPlatform {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
if self.platform.has_panel_od() { if self.platform.has_panel_od() {
@@ -533,8 +779,11 @@ 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;
if self.platform.has_throttle_thermal_policy() { if self.platform.has_throttle_thermal_policy() {
self.update_policy_ac_or_bat(power_plugged > 0).await; let change_epp = self.config.lock().await.throttle_policy_linked_epp;
self.update_policy_ac_or_bat(power_plugged > 0, change_epp)
.await;
} }
self.run_ac_or_bat_cmd(power_plugged > 0).await; self.run_ac_or_bat_cmd(power_plugged > 0).await;
} }
@@ -574,10 +823,9 @@ impl CtrlPlatform {
task_watch_item_notify!(nv_temp_target platform); task_watch_item_notify!(nv_temp_target platform);
} }
#[async_trait]
impl CtrlTask for CtrlPlatform { impl CtrlTask for CtrlPlatform {
fn zbus_path() -> &'static str { fn zbus_path() -> &'static str {
ZBUS_PATH PLATFORM_ZBUS_PATH
} }
async fn create_tasks(&self, signal_ctxt: SignalContext<'static>) -> Result<(), RogError> { async fn create_tasks(&self, signal_ctxt: SignalContext<'static>) -> Result<(), RogError> {
@@ -613,11 +861,18 @@ impl CtrlTask for CtrlPlatform {
.ok(); .ok();
} }
if let Ok(power_plugged) = platform1.power.get_online() { if let Ok(power_plugged) = platform1.power.get_online() {
if !sleeping && platform1.platform.has_throttle_thermal_policy() { if platform1.config.lock().await.last_power_plugged != power_plugged {
platform1.update_policy_ac_or_bat(power_plugged > 0).await; if !sleeping && platform1.platform.has_throttle_thermal_policy() {
} let change_epp =
if !sleeping { platform1.config.lock().await.throttle_policy_linked_epp;
platform1.run_ac_or_bat_cmd(power_plugged > 0).await; platform1
.update_policy_ac_or_bat(power_plugged > 0, change_epp)
.await;
}
if !sleeping {
platform1.run_ac_or_bat_cmd(power_plugged > 0).await;
}
platform1.config.lock().await.last_power_plugged = power_plugged;
} }
} }
} }
@@ -648,7 +903,10 @@ impl CtrlTask for CtrlPlatform {
// power change // power change
async move { async move {
if platform3.platform.has_throttle_thermal_policy() { if platform3.platform.has_throttle_thermal_policy() {
platform3.update_policy_ac_or_bat(power_plugged).await; let change_epp = platform3.config.lock().await.throttle_policy_linked_epp;
platform3
.update_policy_ac_or_bat(power_plugged, change_epp)
.await;
} }
platform3.run_ac_or_bat_cmd(power_plugged).await; platform3.run_ac_or_bat_cmd(power_plugged).await;
} }
@@ -692,13 +950,14 @@ impl CtrlTask for CtrlPlatform {
if let Ok(profile) = ctrl if let Ok(profile) = ctrl
.platform .platform
.get_throttle_thermal_policy() .get_throttle_thermal_policy()
.map(PlatformPolicy::from) .map(ThrottlePolicy::from)
.map_err(|e| { .map_err(|e| {
error!("Platform: get_throttle_thermal_policy error: {e}"); error!("Platform: get_throttle_thermal_policy error: {e}");
}) })
{ {
ctrl.check_and_set_epp(profile); let change_epp = ctrl.config.lock().await.throttle_policy_linked_epp;
ctrl.config.lock().await.platform_policy_to_restore = profile; let epp = ctrl.get_config_epp_for_throttle(profile).await;
ctrl.check_and_set_epp(epp, change_epp);
} }
} }
} }
+7 -2
View File
@@ -15,7 +15,7 @@ use asusd::ctrl_aura::trait_impls::CtrlAuraZbus;
use asusd::ctrl_fancurves::CtrlFanCurveZbus; use asusd::ctrl_fancurves::CtrlFanCurveZbus;
use asusd::ctrl_platform::CtrlPlatform; use asusd::ctrl_platform::CtrlPlatform;
use asusd::{print_board_info, CtrlTask, Reloadable, ZbusRun, DBUS_NAME}; use asusd::{print_board_info, CtrlTask, Reloadable, ZbusRun, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad2}; use config_traits::{StdConfig, StdConfigLoad2, StdConfigLoad3};
use log::{error, info, warn}; use log::{error, info, warn};
use rog_aura::aura_detection::LaptopLedData; use rog_aura::aura_detection::LaptopLedData;
use tokio::time::sleep; use tokio::time::sleep;
@@ -64,11 +64,16 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
let mut connection = Connection::system().await?; let mut connection = Connection::system().await?;
let config = Config::new().load(); let config = Config::new().load();
let cfg_path = config.file_path();
let config = Arc::new(Mutex::new(config)); let config = Arc::new(Mutex::new(config));
// supported.add_to_server(&mut connection).await; // supported.add_to_server(&mut connection).await;
match CtrlPlatform::new(config.clone()) { match CtrlPlatform::new(
config.clone(),
&cfg_path,
CtrlPlatform::signal_context(&connection)?,
) {
Ok(ctrl) => { Ok(ctrl) => {
let sig_ctx = CtrlPlatform::signal_context(&connection)?; let sig_ctx = CtrlPlatform::signal_context(&connection)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?; start_tasks(ctrl, &mut connection, sig_ctx).await?;
+86 -71
View File
@@ -15,7 +15,6 @@ pub mod error;
use std::future::Future; use std::future::Future;
use std::time::Duration; use std::time::Duration;
use async_trait::async_trait;
use dmi_id::DMIID; use dmi_id::DMIID;
use futures_lite::stream::StreamExt; use futures_lite::stream::StreamExt;
use log::{debug, info, warn}; use log::{debug, info, warn};
@@ -130,34 +129,44 @@ pub fn print_board_info() {
info!("Board name: {}", dmi.board_name); info!("Board name: {}", dmi.board_name);
} }
#[async_trait]
pub trait Reloadable { pub trait Reloadable {
async fn reload(&mut self) -> Result<(), RogError>; fn reload(&mut self) -> impl std::future::Future<Output = Result<(), RogError>> + Send;
} }
#[async_trait] pub trait ReloadAndNotify {
pub trait ZbusRun { type Data: Send;
async fn add_to_server(self, server: &mut Connection);
async fn add_to_server_helper( fn reload_and_notify(
&mut self,
signal_context: &SignalContext<'static>,
data: Self::Data,
) -> impl std::future::Future<Output = Result<(), RogError>> + Send;
}
pub trait ZbusRun {
fn add_to_server(self, server: &mut Connection)
-> impl std::future::Future<Output = ()> + Send;
fn add_to_server_helper(
iface: impl zbus::Interface, iface: impl zbus::Interface,
path: &str, path: &str,
server: &mut Connection, server: &mut Connection,
) { ) -> impl std::future::Future<Output = ()> + Send {
server async move {
.object_server() server
.at(&ObjectPath::from_str_unchecked(path), iface) .object_server()
.await .at(&ObjectPath::from_str_unchecked(path), iface)
.map_err(|err| { .await
warn!("{}: add_to_server {}", path, err); .map_err(|err| {
err warn!("{}: add_to_server {}", path, err);
}) err
.ok(); })
.ok();
}
} }
} }
/// Set up a task to run on the async executor /// Set up a task to run on the async executor
#[async_trait]
pub trait CtrlTask { pub trait CtrlTask {
fn zbus_path() -> &'static str; fn zbus_path() -> &'static str;
@@ -168,7 +177,10 @@ pub trait CtrlTask {
/// Implement to set up various tasks that may be required, using the /// Implement to set up various tasks that may be required, using the
/// `Executor`. No blocking loops are allowed, or they must be run on a /// `Executor`. No blocking loops are allowed, or they must be run on a
/// separate thread. /// separate thread.
async fn create_tasks(&self, signal: SignalContext<'static>) -> Result<(), RogError>; fn create_tasks(
&self,
signal: SignalContext<'static>,
) -> impl std::future::Future<Output = Result<(), RogError>> + Send;
// /// Create a timed repeating task // /// Create a timed repeating task
// async fn repeating_task(&self, millis: u64, mut task: impl FnMut() + Send + // async fn repeating_task(&self, millis: u64, mut task: impl FnMut() + Send +
@@ -186,7 +198,7 @@ pub trait CtrlTask {
/// ///
/// The closures can potentially block, so execution time should be the /// The closures can potentially block, so execution time should be the
/// minimal possible such as save a variable. /// minimal possible such as save a variable.
async fn create_sys_event_tasks< fn create_sys_event_tasks<
Fut1, Fut1,
Fut2, Fut2,
Fut3, Fut3,
@@ -201,7 +213,8 @@ pub trait CtrlTask {
mut on_prepare_for_shutdown: F2, mut on_prepare_for_shutdown: F2,
mut on_lid_change: F3, mut on_lid_change: F3,
mut on_external_power_change: F4, mut on_external_power_change: F4,
) where ) -> impl std::future::Future<Output = ()> + Send
where
F1: FnMut(bool) -> Fut1, F1: FnMut(bool) -> Fut1,
F2: FnMut(bool) -> Fut2, F2: FnMut(bool) -> Fut2,
F3: FnMut(bool) -> Fut3, F3: FnMut(bool) -> Fut3,
@@ -211,70 +224,72 @@ pub trait CtrlTask {
Fut3: Future<Output = ()> + Send, Fut3: Future<Output = ()> + Send,
Fut4: Future<Output = ()> + Send, Fut4: Future<Output = ()> + Send,
{ {
let connection = Connection::system() async {
.await let connection = Connection::system()
.expect("Controller could not create dbus connection"); .await
.expect("Controller could not create dbus connection");
let manager = ManagerProxy::builder(&connection) let manager = ManagerProxy::builder(&connection)
.cache_properties(CacheProperties::No) .cache_properties(CacheProperties::No)
.build() .build()
.await .await
.expect("Controller could not create ManagerProxy"); .expect("Controller could not create ManagerProxy");
let manager1 = manager.clone(); let manager1 = manager.clone();
tokio::spawn(async move { tokio::spawn(async move {
if let Ok(mut notif) = manager1.receive_prepare_for_shutdown().await { if let Ok(mut notif) = manager1.receive_prepare_for_shutdown().await {
while let Some(event) = notif.next().await { while let Some(event) = notif.next().await {
// blocks thread :| // blocks thread :|
if let Ok(args) = event.args() { if let Ok(args) = event.args() {
debug!("Doing on_prepare_for_shutdown({})", args.start); debug!("Doing on_prepare_for_shutdown({})", args.start);
on_prepare_for_shutdown(args.start).await; on_prepare_for_shutdown(args.start).await;
}
} }
} }
} });
});
let manager2 = manager.clone(); let manager2 = manager.clone();
tokio::spawn(async move { tokio::spawn(async move {
if let Ok(mut notif) = manager2.receive_prepare_for_sleep().await { if let Ok(mut notif) = manager2.receive_prepare_for_sleep().await {
while let Some(event) = notif.next().await { while let Some(event) = notif.next().await {
// blocks thread :| // blocks thread :|
if let Ok(args) = event.args() { if let Ok(args) = event.args() {
debug!("Doing on_prepare_for_sleep({})", args.start); debug!("Doing on_prepare_for_sleep({})", args.start);
on_prepare_for_sleep(args.start).await; on_prepare_for_sleep(args.start).await;
}
} }
} }
} });
});
let manager3 = manager.clone(); let manager3 = manager.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut last_power = manager3.on_external_power().await.unwrap_or_default(); let mut last_power = manager3.on_external_power().await.unwrap_or_default();
loop { loop {
if let Ok(next) = manager3.on_external_power().await { if let Ok(next) = manager3.on_external_power().await {
if next != last_power { if next != last_power {
last_power = next; last_power = next;
on_external_power_change(next).await; on_external_power_change(next).await;
}
} }
sleep(Duration::from_secs(2)).await;
} }
sleep(Duration::from_secs(2)).await; });
}
});
tokio::spawn(async move { tokio::spawn(async move {
let mut last_lid = manager.lid_closed().await.unwrap_or_default(); let mut last_lid = manager.lid_closed().await.unwrap_or_default();
// need to loop on these as they don't emit signals // need to loop on these as they don't emit signals
loop { loop {
if let Ok(next) = manager.lid_closed().await { if let Ok(next) = manager.lid_closed().await {
if next != last_lid { if next != last_lid {
last_lid = next; last_lid = next;
on_lid_change(next).await; on_lid_change(next).await;
}
} }
sleep(Duration::from_secs(2)).await;
} }
sleep(Duration::from_secs(2)).await; });
} }
});
} }
} }
+9 -7
View File
@@ -5,7 +5,7 @@
Get the data set for every mode available Get the data set for every mode available
--> -->
<method name="AllModeData"> <method name="AllModeData">
<arg type="a{u(us(yyy)(yyy)ss)}" direction="out"/> <arg type="a{u(uu(yyy)(yyy)ss)}" direction="out"/>
</method> </method>
<!-- <!--
On machine that have some form of either per-key keyboard or per-zone On machine that have some form of either per-key keyboard or per-zone
@@ -45,21 +45,23 @@
On success the aura config file is read to refresh cached values, then On success the aura config file is read to refresh cached values, then
the effect is stored and config written to disk. the effect is stored and config written to disk.
--> -->
<property name="LedModeData" type="(us(yyy)(yyy)ss)" access="readwrite"/> <property name="LedModeData" type="(uu(yyy)(yyy)ss)" access="readwrite"/>
<!-- <!--
Set a variety of states, input is array of enum. Set a variety of states, input is array of enum.
`enabled` sets if the sent array should be disabled or enabled `enabled` sets if the sent array should be disabled or enabled
For Modern ROG devices the "enabled" flag is ignored. For Modern ROG devices the "enabled" flag is ignored.
--> -->
<property name="LedPower" type="(asas((sbbbb)(sbbbb)(sbbbb)(sbbbb)(sbbbb)))" access="readwrite"/> <property name="LedPower" type="(ayay((ubbbb)(ubbbb)(ubbbb)(ubbbb)(ubbbb)))" access="readwrite"/>
<!--
The total available modes
-->
<property name="SupportedBasicModes" type="au" access="read"/>
<property name="SupportedBasicZones" type="au" access="read"/>
<!-- <!--
Total levels of brightness available Total levels of brightness available
--> -->
<property name="SupportedBrightness" type="au" access="read"/> <property name="SupportedBrightness" type="au" access="read"/>
<!-- <property name="SupportedPowerZones" type="au" access="read"/>
The total available modes
-->
<property name="SupportedModes" type="au" access="read"/>
</interface> </interface>
</node> </node>
@@ -19,7 +19,7 @@
<arg name="enabled" type="b" direction="in"/> <arg name="enabled" type="b" direction="in"/>
</method> </method>
<!-- <!--
Get the fan-curve data for the currently active PlatformPolicy Get the fan-curve data for the currently active ThrottlePolicy
--> -->
<method name="FanCurveData"> <method name="FanCurveData">
<arg name="profile" type="s" direction="in"/> <arg name="profile" type="s" direction="in"/>
+17 -2
View File
@@ -2,6 +2,20 @@
Generated by typeshare 1.7.0 Generated by typeshare 1.7.0
*/ */
export enum CPUGovernor {
Performance = "Performance",
Powersave = "Powersave",
BadValue = "BadValue",
}
export enum CPUEPP {
Default = "Default",
Performance = "Performance",
BalancePerformance = "BalancePerformance",
BalancePower = "BalancePower",
Power = "Power",
}
export enum GpuMode { export enum GpuMode {
Discrete = "Discrete", Discrete = "Discrete",
Optimus = "Optimus", Optimus = "Optimus",
@@ -13,7 +27,8 @@ export enum GpuMode {
NotSupported = "NotSupported", NotSupported = "NotSupported",
} }
export enum PlatformPolicy { /** `throttle_thermal_policy` in asus_wmi */
export enum ThrottlePolicy {
Balanced = "Balanced", Balanced = "Balanced",
Performance = "Performance", Performance = "Performance",
Quiet = "Quiet", Quiet = "Quiet",
@@ -28,7 +43,7 @@ export enum Properties {
PanelOd = "PanelOd", PanelOd = "PanelOd",
MiniLedMode = "MiniLedMode", MiniLedMode = "MiniLedMode",
EgpuEnable = "EgpuEnable", EgpuEnable = "EgpuEnable",
PlatformPolicy = "PlatformPolicy", ThrottlePolicy = "ThrottlePolicy",
PptPl1Spl = "PptPl1Spl", PptPl1Spl = "PptPl1Spl",
PptPl2Sppt = "PptPl2Sppt", PptPl2Sppt = "PptPl2Sppt",
PptFppt = "PptFppt", PptFppt = "PptFppt",
+14
View File
@@ -109,6 +109,20 @@ where
} }
} }
/// Open and parse the config file to self from ron format
fn read_new(&self) -> Option<Self> {
if let Ok(data) = fs::read_to_string(self.file_path()) {
if data.is_empty() {
warn!("File is empty {:?}", self.file_path());
} else if let Ok(data) = ron::from_str(&data) {
return Some(data);
} else {
warn!("Could not deserialise {:?}", self.file_path());
}
}
None
}
/// Write the config file data to pretty ron format /// Write the config file data to pretty ron format
fn write(&self) { fn write(&self) {
let mut file = match File::create(self.file_path()) { let mut file = match File::create(self.file_path()) {
+33 -1
View File
@@ -71,6 +71,14 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
board_name: "FX705D",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
board_name: "G512", board_name: "G512",
layout_name: "g512", layout_name: "g512",
@@ -231,6 +239,14 @@
advanced_type: PerKey, advanced_type: PerKey,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
board_name: "G614J",
layout_name: "g634j-per-key",
basic_modes: [Static, Breathe, Pulse, Strobe, Rainbow],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard, Lightbar],
),
( (
board_name: "G634J", board_name: "G634J",
layout_name: "g634j-per-key", layout_name: "g634j-per-key",
@@ -399,6 +415,22 @@
advanced_type: PerKey, advanced_type: PerKey,
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
(
board_name: "G814JZ",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
(
board_name: "G834JZ",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar, Logo, RearGlow],
),
( (
board_name: "GA401Q", board_name: "GA401Q",
layout_name: "ga401q", layout_name: "ga401q",
@@ -695,4 +727,4 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
]) ])
+1 -1
View File
@@ -28,7 +28,7 @@ pub struct LedSupportFile(Vec<LaptopLedData>);
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "u")
)] )]
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Copy, Clone)] #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Copy, Clone)]
pub enum PowerZones { pub enum PowerZones {
+1 -1
View File
@@ -303,7 +303,7 @@ impl From<AuraEffect> for AuraModeNum {
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "s") zvariant(signature = "u")
)] )]
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)] #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub enum AuraZone { pub enum AuraZone {
+1 -2
View File
@@ -10,10 +10,9 @@ pub mod effects;
pub mod advanced; pub mod advanced;
/// Convert the `RgbAddress` to `&str` labels /// Convert the `RgbAddress` to `&str` labels
pub mod advanced_to_str; pub mod advanced_to_str;
pub mod error;
pub use advanced_to_str::*;
/// Helper for detecting what is available /// Helper for detecting what is available
pub mod aura_detection; pub mod aura_detection;
pub mod error;
/// Helpers for consructing keyboard layouts for UI use and effects /// Helpers for consructing keyboard layouts for UI use and effects
pub mod layouts; pub mod layouts;
pub mod usb; pub mod usb;
+2 -2
View File
@@ -137,7 +137,7 @@ pub struct AuraPowerDev {
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "y") zvariant(signature = "u")
)] )]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)] #[repr(u32)]
@@ -172,7 +172,7 @@ impl AuraDevTuf {
#[cfg_attr( #[cfg_attr(
feature = "dbus", feature = "dbus",
derive(Type, Value, OwnedValue), derive(Type, Value, OwnedValue),
zvariant(signature = "y") zvariant(signature = "u")
)] )]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)] #[repr(u32)]
+4 -2
View File
@@ -10,10 +10,12 @@ edition = "2021"
#mocking = [] #mocking = []
[dependencies] [dependencies]
# egui = "0.24.1"
# eframe = "0.24.1"
# egui_plot = "0.24.1"
# Stuck on this revision due to crash issues on app close
egui = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"} egui = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"}
eframe = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"} eframe = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"}
# egui = { path = "../../egui/crates/egui" }
# eframe = { path = "../../egui/crates/eframe" }
libappindicator = "0.8" # Tray icon libappindicator = "0.8" # Tray icon
gtk = "0.16" gtk = "0.16"
+2 -2
View File
@@ -107,7 +107,7 @@ impl eframe::App for RogApp {
/// Called each time the UI needs repainting, which may be many times per /// Called each time the UI needs repainting, which may be many times per
/// second. Put your widgets into a `SidePanel`, `TopPanel`, /// second. Put your widgets into a `SidePanel`, `TopPanel`,
/// `CentralPanel`, `Window` or `Area`. /// `CentralPanel`, `Window` or `Area`.
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { fn update(&mut self, ctx: &eframe::egui::Context, frame: &mut eframe::Frame) {
let states = self.states.clone(); let states = self.states.clone();
if let Ok(mut states) = states.try_lock() { if let Ok(mut states) = states.try_lock() {
@@ -131,7 +131,7 @@ impl eframe::App for RogApp {
return; return;
} }
self.top_bar(&mut states, ctx, frame); self.top_bar(ctx, frame);
self.side_panel(ctx); self.side_panel(ctx);
} }
let page = self.page; let page = self.page;
+60 -39
View File
@@ -6,9 +6,9 @@ use std::sync::{Arc, Mutex};
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use eframe::IconData; use eframe::HardwareAcceleration;
use gumdrop::Options; use gumdrop::Options;
use log::{debug, error, info, warn, LevelFilter}; use log::{debug, error, warn, LevelFilter};
use rog_aura::aura_detection::{LaptopLedData, LedSupportFile}; use rog_aura::aura_detection::{LaptopLedData, LedSupportFile};
use rog_aura::layouts::KeyLayout; use rog_aura::layouts::KeyLayout;
use rog_control_center::cli_options::CliStart; use rog_control_center::cli_options::CliStart;
@@ -22,6 +22,8 @@ use rog_control_center::{
get_ipc_file, on_tmp_dir_exists, print_versions, RogApp, RogDbusClientBlocking, SHOWING_GUI, get_ipc_file, on_tmp_dir_exists, print_versions, RogApp, RogDbusClientBlocking, SHOWING_GUI,
SHOW_GUI, SHOW_GUI,
}; };
#[cfg(not(feature = "mocking"))]
use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking;
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
#[cfg(not(feature = "mocking"))] #[cfg(not(feature = "mocking"))]
@@ -29,7 +31,8 @@ const DATA_DIR: &str = "/usr/share/rog-gui/";
#[cfg(feature = "mocking")] #[cfg(feature = "mocking")]
const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR"); const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR");
const BOARD_NAME: &str = "/sys/class/dmi/id/board_name"; const BOARD_NAME: &str = "/sys/class/dmi/id/board_name";
const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png"; // const APP_ICON_PATH: &str =
// "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";
fn main() -> Result<()> { fn main() -> Result<()> {
let args: Vec<String> = args().skip(1).collect(); let args: Vec<String> = args().skip(1).collect();
@@ -60,12 +63,10 @@ fn main() -> Result<()> {
let native_options = eframe::NativeOptions { let native_options = eframe::NativeOptions {
vsync: true, vsync: true,
decorated: true, hardware_acceleration: HardwareAcceleration::Preferred,
transparent: false, min_window_size: Some(egui::vec2(980.0, 670.0)),
min_window_size: Some(egui::vec2(960.0, 670.0)), max_window_size: Some(egui::vec2(980.0, 670.0)),
max_window_size: Some(egui::vec2(960.0, 670.0)),
run_and_return: true, run_and_return: true,
icon_data: Some(load_icon()),
..Default::default() ..Default::default()
}; };
@@ -187,10 +188,27 @@ fn main() -> Result<()> {
&config, &config,
)?; )?;
if cli_parsed.board_name.is_some() || cli_parsed.layout_viewing {
if let Ok(mut lock) = states.lock() {
lock.run_in_bg = false;
running_in_bg.store(false, Ordering::Release);
}
}
if config.enable_tray_icon { if config.enable_tray_icon {
init_tray(supported_properties, states.clone()); init_tray(supported_properties, states.clone());
} }
if let Ok(mut states) = states.lock() {
// For some reason the gui is causing a broke pipe error on dbus send, so
// replace it.
let (asus_dbus, conn) =
rog_dbus::RogDbusClientBlocking::new().expect("Couldn't connect to asusd");
states.asus_dbus = asus_dbus;
let gfx_dbus = GfxProxyBlocking::new(&conn).expect("Couldn't connect to supergfxd");
states.gfx_dbus = gfx_dbus;
}
let mut bg_check_spawned = false; let mut bg_check_spawned = false;
loop { loop {
if !running_in_bg.load(Ordering::Relaxed) { if !running_in_bg.load(Ordering::Relaxed) {
@@ -202,7 +220,9 @@ fn main() -> Result<()> {
"ROG Control Center", "ROG Control Center",
native_options.clone(), native_options.clone(),
Box::new(move |cc| { Box::new(move |cc| {
Box::new(RogApp::new(Config::load().unwrap(), states, cc).unwrap()) let cfg = Config::load().unwrap();
let app = RogApp::new(cfg, states, cc);
Box::new(app.unwrap())
}), }),
)?; )?;
@@ -211,7 +231,7 @@ fn main() -> Result<()> {
} }
if let Ok(lock) = states.try_lock() { if let Ok(lock) = states.try_lock() {
if !lock.run_in_bg || cli_parsed.board_name.is_some() || cli_parsed.layout_viewing { if !lock.run_in_bg {
break; break;
} }
@@ -261,37 +281,38 @@ fn setup_page_state_and_notifs(
} }
/// Bah.. the icon dosn't work on wayland anyway, but we'll leave it in for now. /// Bah.. the icon dosn't work on wayland anyway, but we'll leave it in for now.
fn load_icon() -> IconData { // fn load_icon() -> IconData {
let path = PathBuf::from(APP_ICON_PATH); // let path = PathBuf::from(APP_ICON_PATH);
let mut rgba = Vec::new(); // let mut rgba = Vec::new();
let mut height = 512; // let mut height = 512;
let mut width = 512; // let mut width = 512;
if path.exists() { // if path.exists() {
if let Ok(data) = std::fs::read(path) // if let Ok(data) = std::fs::read(path)
.map_err(|e| error!("Error reading app icon: {e:?}")) // .map_err(|e| error!("Error reading app icon: {e:?}"))
.map_err(|e| error!("Error opening app icon: {e:?}")) // .map_err(|e| error!("Error opening app icon: {e:?}"))
{ // {
let data = std::io::Cursor::new(data); // let data = std::io::Cursor::new(data);
let decoder = png_pong::Decoder::new(data).unwrap().into_steps(); // let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
let png_pong::Step { raster, delay: _ } = decoder.last().unwrap().unwrap(); // let png_pong::Step { raster, delay: _ } =
// decoder.last().unwrap().unwrap();
if let png_pong::PngRaster::Rgba8(ras) = raster { // if let png_pong::PngRaster::Rgba8(ras) = raster {
rgba = ras.as_u8_slice().to_vec(); // rgba = ras.as_u8_slice().to_vec();
width = ras.width(); // width = ras.width();
height = ras.height(); // height = ras.height();
info!("Loaded app icon. Not actually supported in Wayland yet"); // info!("Loaded app icon. Not actually supported in Wayland
} // yet"); }
} // }
} else { // } else {
error!("Missing {APP_ICON_PATH}"); // error!("Missing {APP_ICON_PATH}");
} // }
IconData { // IconData {
height, // height,
width, // width,
rgba, // rgba,
} // }
} // }
fn do_cli_help(parsed: &CliStart) -> bool { fn do_cli_help(parsed: &CliStart) -> bool {
if parsed.help { if parsed.help {
+1 -1
View File
@@ -1,7 +1,7 @@
use crate::RogApp; use crate::RogApp;
impl RogApp { impl RogApp {
pub fn anime_page(&mut self, ctx: &egui::Context) { pub fn anime_page(&mut self, ctx: &eframe::egui::Context) {
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.label("In progress"); ui.label("In progress");
}); });
+1 -1
View File
@@ -3,7 +3,7 @@ use crate::widgets::app_settings;
use crate::RogApp; use crate::RogApp;
impl RogApp { impl RogApp {
pub fn app_settings_page(&mut self, states: &mut SystemState, ctx: &egui::Context) { pub fn app_settings_page(&mut self, states: &mut SystemState, ctx: &eframe::egui::Context) {
let Self { config, .. } = self; let Self { config, .. } = self;
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
+1 -1
View File
@@ -9,7 +9,7 @@ use crate::widgets::{aura_modes_group, keyboard};
use crate::RogApp; use crate::RogApp;
impl RogApp { impl RogApp {
pub fn aura_page(&mut self, states: &mut SystemState, ctx: &egui::Context) { pub fn aura_page(&mut self, states: &mut SystemState, ctx: &eframe::egui::Context) {
let Self { let Self {
oscillator1, oscillator1,
oscillator2, oscillator2,
+3 -28
View File
@@ -1,12 +1,12 @@
use egui::{RichText, Ui}; use egui::{RichText, Ui};
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use crate::system_state::{FanCurvesState, SystemState}; use crate::system_state::{FanCurvesState, SystemState};
use crate::widgets::fan_graphs; use crate::widgets::fan_graphs;
use crate::{RogApp, RogDbusClientBlocking}; use crate::{RogApp, RogDbusClientBlocking};
impl RogApp { impl RogApp {
pub fn fan_curve_page(&mut self, states: &mut SystemState, ctx: &egui::Context) { pub fn fan_curve_page(&mut self, states: &mut SystemState, ctx: &eframe::egui::Context) {
if let Some(mut throttle) = states.bios.throttle { if let Some(mut throttle) = states.bios.throttle {
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Custom fan curves"); ui.heading("Custom fan curves");
@@ -29,7 +29,7 @@ impl RogApp {
} }
fn fan_curve( fn fan_curve(
current: &mut PlatformPolicy, current: &mut ThrottlePolicy,
curves: &mut FanCurvesState, curves: &mut FanCurvesState,
dbus: &RogDbusClientBlocking<'_>, dbus: &RogDbusClientBlocking<'_>,
do_error: &mut Option<String>, do_error: &mut Option<String>,
@@ -43,31 +43,6 @@ impl RogApp {
ui.label(RichText::new(format!("{}", current)).strong()); ui.label(RichText::new(format!("{}", current)).strong());
}); });
// ui.horizontal(|ui| {
// ui.label("Enabled fan-curves: ");
// let mut fan_curve_enable = |profile: Profile, fan: FanCurvePU, mut
// checked: bool| { if ui
// .add(egui::Checkbox::new(&mut checked, format!("{:?}", fan)))
// .changed()
// {
// dbus.proxies()
// .profile()
// .set_fan_curves_enabled(profile, checked)
// .map_err(|err| {
// *do_error = Some(err.to_string());
// })
// .ok();
// changed = true;
// }
// };
// if let Some(curves) = curves.curves.get_mut(&current) {
// for curve in curves.iter_mut() {
// fan_curve_enable(current, curve.fan, curve.enabled);
// }
// }
// });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Enabled fan-curves: "); ui.label("Enabled fan-curves: ");
let mut checked = false; let mut checked = false;
-6
View File
@@ -3,9 +3,3 @@ mod app_settings;
mod aura_page; mod aura_page;
mod fan_curve_page; mod fan_curve_page;
mod system_page; mod system_page;
pub use anime_page::*;
pub use app_settings::*;
pub use aura_page::*;
pub use fan_curve_page::*;
pub use system_page::*;
+3 -3
View File
@@ -1,9 +1,9 @@
use crate::system_state::SystemState; use crate::system_state::SystemState;
use crate::widgets::{anime_power_group, platform_profile, rog_bios_group}; use crate::widgets::{anime_power_group, aura_power_group, platform_profile, rog_bios_group};
use crate::RogApp; use crate::RogApp;
impl RogApp { impl RogApp {
pub fn system_page(&mut self, states: &mut SystemState, ctx: &egui::Context) { pub fn system_page(&mut self, states: &mut SystemState, ctx: &eframe::egui::Context) {
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Laptop settings"); ui.heading("Laptop settings");
@@ -22,7 +22,7 @@ impl RogApp {
ui.vertical(|ui| { ui.vertical(|ui| {
ui.separator(); ui.separator();
if self.supported_interfaces.contains(&"Aura".to_string()) { if self.supported_interfaces.contains(&"Aura".to_string()) {
// aura_power_group(states, ui); aura_power_group(states, ui);
} }
}); });
ui.end_row(); ui.end_row();
+16 -14
View File
@@ -1,4 +1,4 @@
use egui::{Button, RichText}; use egui::RichText;
pub struct AppErrorShow { pub struct AppErrorShow {
error: String, error: String,
@@ -11,7 +11,7 @@ impl AppErrorShow {
} }
impl eframe::App for AppErrorShow { impl eframe::App for AppErrorShow {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("ROG ERROR"); ui.heading("ROG ERROR");
@@ -19,18 +19,20 @@ impl eframe::App for AppErrorShow {
ui.label(RichText::new(format!("The error was: {:?}", self.error)).size(22.0)); ui.label(RichText::new(format!("The error was: {:?}", self.error)).size(22.0));
}); });
egui::TopBottomPanel::bottom("error_bar_2") // egui::TopBottomPanel::bottom("error_bar_2")
.default_height(26.0) // .default_height(26.0)
.show(ctx, |ui| { // .show(ctx, |ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| { // ui.
if ui // with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
.add(Button::new(RichText::new("Okay").size(20.0))) // if ui
.clicked() // .add(Button::new(RichText::new("Okay").size(20.0)))
{ // .clicked()
frame.close(); // {
} // // frame.close();
}); // // ui.close_menu();
}); // }
// });
// });
}); });
} }
} }
+31 -15
View File
@@ -6,10 +6,11 @@ use std::time::SystemTime;
use egui::Vec2; use egui::Vec2;
use log::error; use log::error;
use rog_anime::{Animations, DeviceState}; use rog_anime::{Animations, DeviceState};
use rog_aura::aura_detection::PowerZones;
use rog_aura::layouts::KeyLayout; use rog_aura::layouts::KeyLayout;
use rog_aura::usb::AuraPowerDev; use rog_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, LedBrightness}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use rog_platform::platform::{GpuMode, PlatformPolicy}; use rog_platform::platform::{GpuMode, ThrottlePolicy};
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::pci_device::{GfxMode, GfxPower};
@@ -33,7 +34,7 @@ pub struct PlatformState {
pub mini_led_mode: Option<bool>, pub mini_led_mode: Option<bool>,
pub dgpu_disable: Option<bool>, pub dgpu_disable: Option<bool>,
pub egpu_enable: Option<bool>, pub egpu_enable: Option<bool>,
pub throttle: Option<PlatformPolicy>, pub throttle: Option<ThrottlePolicy>,
pub charge_limit: Option<u8>, pub charge_limit: Option<u8>,
} }
@@ -64,9 +65,9 @@ impl PlatformState {
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct FanCurvesState { pub struct FanCurvesState {
pub show_curve: PlatformPolicy, pub show_curve: ThrottlePolicy,
pub show_graph: FanCurvePU, pub show_graph: FanCurvePU,
pub curves: BTreeMap<PlatformPolicy, Vec<CurveData>>, pub curves: BTreeMap<ThrottlePolicy, Vec<CurveData>>,
pub available_fans: HashSet<FanCurvePU>, pub available_fans: HashSet<FanCurvePU>,
pub drag_delta: Vec2, pub drag_delta: Vec2,
} }
@@ -74,25 +75,26 @@ pub struct FanCurvesState {
impl FanCurvesState { impl FanCurvesState {
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> { pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
let profiles = vec![ let profiles = vec![
PlatformPolicy::Balanced, ThrottlePolicy::Balanced,
PlatformPolicy::Quiet, ThrottlePolicy::Quiet,
PlatformPolicy::Performance, ThrottlePolicy::Performance,
]; ];
let mut curves: BTreeMap<PlatformPolicy, Vec<CurveData>> = BTreeMap::new(); let mut available_fans = HashSet::new();
let mut curves: BTreeMap<ThrottlePolicy, Vec<CurveData>> = BTreeMap::new();
for p in &profiles { for p in &profiles {
if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) { if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) {
if available_fans.is_empty() {
for fan in &curve {
available_fans.insert(fan.fan);
}
}
curves.insert(*p, curve); curves.insert(*p, curve);
} else { } else {
curves.insert(*p, Default::default()); curves.insert(*p, Default::default());
} }
} }
let available_fans = HashSet::new();
// for fan in supported.platform_profile.fans.iter() {
// available_fans.insert(*fan);
// }
let show_curve = dbus.proxies().platform().throttle_thermal_policy()?; let show_curve = dbus.proxies().platform().throttle_thermal_policy()?;
Ok(Self { Ok(Self {
@@ -110,6 +112,9 @@ pub struct AuraState {
pub current_mode: AuraModeNum, pub current_mode: AuraModeNum,
pub modes: BTreeMap<AuraModeNum, AuraEffect>, pub modes: BTreeMap<AuraModeNum, AuraEffect>,
pub enabled: AuraPowerDev, pub enabled: AuraPowerDev,
pub dev_type: AuraDevice,
pub supported_basic_zones: Vec<AuraZone>,
pub supported_power_zones: Vec<PowerZones>,
/// Brightness from 0-3 /// Brightness from 0-3
pub bright: LedBrightness, pub bright: LedBrightness,
pub wave_red: [u8; 22], pub wave_red: [u8; 22],
@@ -132,6 +137,17 @@ impl AuraState {
BTreeMap::new() BTreeMap::new()
}, },
enabled: dbus.proxies().aura().led_power().unwrap_or_default(), enabled: dbus.proxies().aura().led_power().unwrap_or_default(),
supported_basic_zones: dbus
.proxies()
.aura()
.supported_basic_zones()
.unwrap_or_default(),
supported_power_zones: dbus
.proxies()
.aura()
.supported_power_zones()
.unwrap_or_default(),
dev_type: dbus.proxies().aura().device_type().unwrap_or_default(),
bright: dbus.proxies().aura().brightness().unwrap_or_default(), bright: dbus.proxies().aura().brightness().unwrap_or_default(),
wave_red: [0u8; 22], wave_red: [0u8; 22],
wave_green: [0u8; 22], wave_green: [0u8; 22],
+5 -5
View File
@@ -14,7 +14,7 @@ use notify_rust::{Hint, Notification, NotificationHandle, Urgency};
use rog_dbus::zbus_anime::AnimeProxy; use rog_dbus::zbus_anime::AnimeProxy;
use rog_dbus::zbus_aura::AuraProxy; use rog_dbus::zbus_aura::AuraProxy;
use rog_dbus::zbus_platform::PlatformProxy; use rog_dbus::zbus_platform::PlatformProxy;
use rog_platform::platform::{GpuMode, PlatformPolicy}; use rog_platform::platform::{GpuMode, ThrottlePolicy};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use supergfxctl::actions::UserActionRequired as GfxUserAction; use supergfxctl::actions::UserActionRequired as GfxUserAction;
use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::pci_device::{GfxMode, GfxPower};
@@ -546,11 +546,11 @@ fn _ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle
Ok(base_notification(message, &data).show()?) Ok(base_notification(message, &data).show()?)
} }
fn do_thermal_notif(message: &str, profile: &PlatformPolicy) -> Result<NotificationHandle> { fn do_thermal_notif(message: &str, profile: &ThrottlePolicy) -> Result<NotificationHandle> {
let icon = match profile { let icon = match profile {
PlatformPolicy::Balanced => "asus_notif_yellow", ThrottlePolicy::Balanced => "asus_notif_yellow",
PlatformPolicy::Performance => "asus_notif_red", ThrottlePolicy::Performance => "asus_notif_red",
PlatformPolicy::Quiet => "asus_notif_green", ThrottlePolicy::Quiet => "asus_notif_green",
}; };
let profile: &str = (*profile).into(); let profile: &str = (*profile).into();
let mut notif = base_notification(message, &profile.to_uppercase()); let mut notif = base_notification(message, &profile.to_uppercase());
+1 -2
View File
@@ -224,12 +224,11 @@ pub fn aura_modes_group(states: &mut SystemState, freq: &mut Arc<AtomicU8>, ui:
if changed { if changed {
states.aura.current_mode = selected; states.aura.current_mode = selected;
states states
.asus_dbus .asus_dbus
.proxies() .proxies()
.aura() .aura()
.set_led_mode(states.aura.modes.get(&selected).unwrap().mode) .set_led_mode_data(states.aura.modes.get(&selected).unwrap().clone())
.map_err(|err| { .map_err(|err| {
states.error = Some(err.to_string()); states.error = Some(err.to_string());
}) })
+15 -16
View File
@@ -4,24 +4,23 @@ use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
use crate::system_state::SystemState; use crate::system_state::SystemState;
pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) { pub fn aura_power_group(states: &mut SystemState, ui: &mut Ui) {
ui.heading("Keyboard LED power settings"); ui.heading("Keyboard LED power settings");
if supported.keyboard_led.dev_id.is_old_style() || supported.keyboard_led.dev_id.is_tuf_style() if states.aura.dev_type.is_old_style() || states.aura.dev_type.is_tuf_style() {
{ aura_power1(states, ui);
aura_power1(supported, states, ui); } else if states.aura.dev_type.is_new_style() {
} else if supported.keyboard_led.dev_id.is_new_style() { aura_power2(states, ui);
aura_power2(supported, states, ui);
} }
} }
fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) { fn aura_power1(states: &mut SystemState, ui: &mut Ui) {
let enabled_states = &mut states.aura.enabled; let enabled_states = &mut states.aura.enabled;
let mut boot = enabled_states.old_rog.contains(&AuraDevRog1::Boot); let mut boot = enabled_states.old_rog.contains(&AuraDevRog1::Boot);
let mut sleep = enabled_states.old_rog.contains(&AuraDevRog1::Sleep); let mut sleep = enabled_states.old_rog.contains(&AuraDevRog1::Sleep);
let mut keyboard = enabled_states.old_rog.contains(&AuraDevRog1::Keyboard); let mut keyboard = enabled_states.old_rog.contains(&AuraDevRog1::Keyboard);
let mut lightbar = enabled_states.old_rog.contains(&AuraDevRog1::Lightbar); let mut lightbar = enabled_states.old_rog.contains(&AuraDevRog1::Lightbar);
if supported.keyboard_led.dev_id == AuraDevice::Tuf { if states.aura.dev_type == AuraDevice::Tuf {
boot = enabled_states.tuf.contains(&AuraDevTuf::Boot); boot = enabled_states.tuf.contains(&AuraDevTuf::Boot);
sleep = enabled_states.tuf.contains(&AuraDevTuf::Sleep); sleep = enabled_states.tuf.contains(&AuraDevTuf::Sleep);
keyboard = enabled_states.tuf.contains(&AuraDevTuf::Awake); keyboard = enabled_states.tuf.contains(&AuraDevTuf::Awake);
@@ -58,7 +57,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
if ui.toggle_value(&mut keyboard, "Keyboard").changed() { if ui.toggle_value(&mut keyboard, "Keyboard").changed() {
changed = true; changed = true;
} }
if !supported.keyboard_led.basic_zones.is_empty() if !states.aura.supported_basic_zones.is_empty()
&& ui.toggle_value(&mut lightbar, "Lightbar").changed() && ui.toggle_value(&mut lightbar, "Lightbar").changed()
{ {
changed = true; changed = true;
@@ -93,7 +92,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
}); });
if changed { if changed {
if supported.keyboard_led.dev_id == AuraDevice::Tuf { if states.aura.dev_type == AuraDevice::Tuf {
let mut enabled = Vec::new(); let mut enabled = Vec::new();
let mut disabled = Vec::new(); let mut disabled = Vec::new();
@@ -132,7 +131,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
.asus_dbus .asus_dbus
.proxies() .proxies()
.aura() .aura()
.set_led_power(options, enable) .set_led_power((options, enable))
.map_err(|err| { .map_err(|err| {
states.error = Some(err.to_string()); states.error = Some(err.to_string());
}) })
@@ -168,7 +167,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
modify_x1866(boot, AuraDevRog1::Boot); modify_x1866(boot, AuraDevRog1::Boot);
modify_x1866(sleep, AuraDevRog1::Sleep); modify_x1866(sleep, AuraDevRog1::Sleep);
modify_x1866(keyboard, AuraDevRog1::Keyboard); modify_x1866(keyboard, AuraDevRog1::Keyboard);
if !supported.keyboard_led.basic_zones.is_empty() { if !states.aura.supported_basic_zones.is_empty() {
modify_x1866(lightbar, AuraDevRog1::Lightbar); modify_x1866(lightbar, AuraDevRog1::Lightbar);
} }
@@ -182,7 +181,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
.asus_dbus .asus_dbus
.proxies() .proxies()
.aura() .aura()
.set_led_power(options, enable) .set_led_power((options, enable))
.map_err(|err| { .map_err(|err| {
states.error = Some(err.to_string()); states.error = Some(err.to_string());
}) })
@@ -194,7 +193,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
} }
} }
fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) { fn aura_power2(states: &mut SystemState, ui: &mut Ui) {
let AuraPower { let AuraPower {
keyboard, keyboard,
logo, logo,
@@ -208,7 +207,7 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
let mut changed = false; let mut changed = false;
let mut item = |power: &mut KbAuraPowerState, ui: &mut Ui| { let mut item = |power: &mut KbAuraPowerState, ui: &mut Ui| {
ui.vertical(|ui| { ui.vertical(|ui| {
if supported.keyboard_led.power_zones.contains(&power.zone) { if states.aura.supported_power_zones.contains(&power.zone) {
ui.horizontal_wrapped(|ui| { ui.horizontal_wrapped(|ui| {
ui.label(RichText::new(format!("{:?}", power.zone)).size(14.0)); ui.label(RichText::new(format!("{:?}", power.zone)).size(14.0));
}); });
@@ -247,7 +246,7 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
.asus_dbus .asus_dbus
.proxies() .proxies()
.aura() .aura()
.set_led_power(options, enable) .set_led_power((options, enable))
.map_err(|err| { .map_err(|err| {
states.error = Some(err.to_string()); states.error = Some(err.to_string());
}) })
+9 -7
View File
@@ -1,6 +1,6 @@
use egui::plot::Points; use egui::plot::{Line, Plot, Points};
use egui::Ui; use egui::Ui;
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
@@ -13,9 +13,13 @@ pub fn fan_graphs(
do_error: &mut Option<String>, do_error: &mut Option<String>,
ui: &mut Ui, ui: &mut Ui,
) { ) {
if curves.available_fans.is_empty() {
return; // TODO:
}
ui.separator(); ui.separator();
let mut item = |profile: PlatformPolicy, ui: &mut Ui| { let mut item = |profile: ThrottlePolicy, ui: &mut Ui| {
ui.group(|ui| { ui.group(|ui| {
if ui if ui
.selectable_value(&mut curves.show_curve, profile, format!("{profile:?}")) .selectable_value(&mut curves.show_curve, profile, format!("{profile:?}"))
@@ -60,8 +64,6 @@ pub fn fan_graphs(
let curve = curves.curves.get_mut(&curves.show_curve).unwrap(); let curve = curves.curves.get_mut(&curves.show_curve).unwrap();
use egui::plot::{Line, Plot};
let mut data = &mut CurveData::default(); let mut data = &mut CurveData::default();
for c in curve { for c in curve {
if c.fan == curves.show_graph { if c.fan == curves.show_graph {
@@ -116,8 +118,8 @@ pub fn fan_graphs(
.allow_scroll(false) .allow_scroll(false)
.allow_drag(false) .allow_drag(false)
.allow_boxed_zoom(false) .allow_boxed_zoom(false)
.x_axis_formatter(|d, _r| format!("{}", d)) // .x_axis_formatter(|d, _r| format!("{}", d))
.y_axis_formatter(|d, _r| format!("{:.*}%", 1, d)) // .y_axis_formatter(|d, _r| format!("{:.*}%", 1, d))
.label_formatter(|name, value| { .label_formatter(|name, value| {
if !name.is_empty() { if !name.is_empty() {
format!("{}: {:.*}%", name, 1, value.y) format!("{}: {:.*}%", name, 1, value.y)
+2 -4
View File
@@ -1,7 +1,7 @@
mod anime_power; mod anime_power;
mod app_settings; mod app_settings;
mod aura_modes; mod aura_modes;
// mod aura_power; mod aura_power;
mod fan_graph; mod fan_graph;
mod keyboard_layout; mod keyboard_layout;
mod rog_bios; mod rog_bios;
@@ -11,9 +11,7 @@ mod top_bar;
pub use anime_power::*; pub use anime_power::*;
pub use app_settings::*; pub use app_settings::*;
pub use aura_modes::*; pub use aura_modes::*;
// pub use aura_power::*; pub use aura_power::*;
pub use fan_graph::*; pub use fan_graph::*;
pub use keyboard_layout::*; pub use keyboard_layout::*;
pub use rog_bios::*; pub use rog_bios::*;
pub use side_panel::*;
pub use top_bar::*;
+3 -3
View File
@@ -1,5 +1,5 @@
use egui::Ui; use egui::Ui;
use rog_platform::platform::{GpuMode, PlatformPolicy}; use rog_platform::platform::{GpuMode, ThrottlePolicy};
use crate::system_state::SystemState; use crate::system_state::SystemState;
@@ -7,7 +7,7 @@ pub fn platform_profile(states: &mut SystemState, ui: &mut Ui) {
if let Some(mut throttle) = states.bios.throttle { if let Some(mut throttle) = states.bios.throttle {
ui.heading("Platform profile"); ui.heading("Platform profile");
let mut item = |p: PlatformPolicy, ui: &mut Ui| { let mut item = |p: ThrottlePolicy, ui: &mut Ui| {
if ui if ui
.selectable_value(&mut throttle, p, format!("{p:?}")) .selectable_value(&mut throttle, p, format!("{p:?}"))
.clicked() .clicked()
@@ -25,7 +25,7 @@ pub fn platform_profile(states: &mut SystemState, ui: &mut Ui) {
}; };
ui.horizontal_wrapped(|ui| { ui.horizontal_wrapped(|ui| {
for a in PlatformPolicy::list() { for a in ThrottlePolicy::list() {
item(a, ui); item(a, ui);
} }
}); });
+1 -1
View File
@@ -1,7 +1,7 @@
use crate::{Page, RogApp}; use crate::{Page, RogApp};
impl RogApp { impl RogApp {
pub fn side_panel(&mut self, ctx: &egui::Context) { pub fn side_panel(&mut self, ctx: &eframe::egui::Context) {
egui::SidePanel::left("side_panel") egui::SidePanel::left("side_panel")
.resizable(false) .resizable(false)
.default_width(60.0) // TODO: set size to match icon buttons when done .default_width(60.0) // TODO: set size to match icon buttons when done
+10 -21
View File
@@ -1,25 +1,15 @@
use egui::{vec2, Align2, FontId, Id, Sense}; use egui::{vec2, Align2, Button, FontId, Id, Rect, RichText, Sense, Vec2};
use crate::system_state::SystemState;
use crate::{RogApp, VERSION}; use crate::{RogApp, VERSION};
impl RogApp { impl RogApp {
pub fn top_bar( pub fn top_bar(&mut self, ctx: &eframe::egui::Context, frame: &mut eframe::Frame) {
&mut self,
states: &mut SystemState,
ctx: &egui::Context,
frame: &mut eframe::Frame,
) {
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar: // The top panel is often a good place for a menu bar:
egui::menu::bar(ui, |ui| { egui::menu::bar(ui, |ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
self.dark_light_mode_buttons(ui); self.dark_light_mode_buttons(ui);
egui::warn_if_debug_build(ui); egui::warn_if_debug_build(ui);
if ui.button("Quit app").clicked() {
states.run_in_bg = false;
frame.close();
}
}); });
// Drag area // Drag area
@@ -43,15 +33,14 @@ impl RogApp {
FontId::proportional(height - 2.0), FontId::proportional(height - 2.0),
text_color, text_color,
); );
// // Add the close button: // Add the close button:
// let close_response = ui.put( let close_response = ui.put(
// egui::Rect::from_min_size(titlebar_rect.right_top(), Rect::from_min_size(titlebar_rect.right_top(), Vec2::splat(height)),
// egui::Vec2::splat(height)), Button::new(RichText::new("").size(height - 4.0)).frame(false),
// egui::Button::new(egui::RichText::new("❌").size(height - );
// 4.0)).frame(false), ); if close_response.clicked() {
// if close_response.clicked() { frame.close();
// frame.close(); }
// }
}); });
}); });
} }
+12 -3
View File
@@ -23,8 +23,9 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use rog_aura::advanced::UsbPackets; use rog_aura::advanced::UsbPackets;
use rog_aura::aura_detection::PowerZones;
use rog_aura::usb::{AuraDevice, AuraPowerDev}; use rog_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, LedBrightness}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use zbus::blocking::Connection; use zbus::blocking::Connection;
use zbus::{dbus_proxy, Result}; use zbus::{dbus_proxy, Result};
@@ -74,9 +75,17 @@ trait Aura {
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn supported_brightness(&self) -> zbus::Result<Vec<LedBrightness>>; fn supported_brightness(&self) -> zbus::Result<Vec<LedBrightness>>;
/// SupportedModes property /// SupportedBasicModes property
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn supported_modes(&self) -> zbus::Result<Vec<AuraModeNum>>; fn supported_basic_modes(&self) -> zbus::Result<Vec<AuraModeNum>>;
/// SupportedBasicZones property
#[dbus_proxy(property)]
fn supported_basic_zones(&self) -> zbus::Result<Vec<AuraZone>>;
/// SupportedPowerZones property
#[dbus_proxy(property)]
fn supported_power_zones(&self) -> zbus::Result<Vec<PowerZones>>;
} }
pub struct AuraProxyPerkey<'a>(AuraProxyBlocking<'a>); pub struct AuraProxyPerkey<'a>(AuraProxyBlocking<'a>);
+6 -6
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::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use zbus::dbus_proxy; use zbus::dbus_proxy;
@@ -32,30 +32,30 @@ use zbus::dbus_proxy;
)] )]
trait FanCurves { 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: PlatformPolicy) -> zbus::Result<Vec<CurveData>>; fn fan_curve_data(&self, profile: ThrottlePolicy) -> 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: PlatformPolicy) -> zbus::fdo::Result<()>; fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::Result<()>;
/// SetActiveCurveToDefaults method /// SetActiveCurveToDefaults method
fn set_active_curve_to_defaults(&self) -> zbus::Result<()>; fn set_active_curve_to_defaults(&self) -> 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: PlatformPolicy, curve: CurveData) -> zbus::Result<()>; fn set_fan_curve(&self, profile: ThrottlePolicy, 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: PlatformPolicy, enabled: bool) -> zbus::Result<()>; fn set_fan_curves_enabled(&self, profile: ThrottlePolicy, 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: PlatformPolicy, profile: ThrottlePolicy,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool,
) -> zbus::Result<()>; ) -> zbus::Result<()>;
+4 -4
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::{GpuMode, PlatformPolicy, Properties}; use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy};
use zbus::dbus_proxy; use zbus::dbus_proxy;
#[dbus_proxy( #[dbus_proxy(
@@ -118,9 +118,9 @@ trait Platform {
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn set_ppt_platform_sppt(&self, value: u8) -> zbus::Result<()>; fn set_ppt_platform_sppt(&self, value: u8) -> zbus::Result<()>;
/// PlatformPolicy property /// ThrottlePolicy property
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn throttle_thermal_policy(&self) -> zbus::Result<PlatformPolicy>; fn throttle_thermal_policy(&self) -> zbus::Result<ThrottlePolicy>;
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn set_throttle_thermal_policy(&self, value: PlatformPolicy) -> zbus::Result<()>; fn set_throttle_thermal_policy(&self, value: ThrottlePolicy) -> zbus::Result<()>;
} }
+20 -9
View File
@@ -6,7 +6,7 @@ use typeshare::typeshare;
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::PlatformPolicy; use crate::platform::ThrottlePolicy;
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";
@@ -180,12 +180,23 @@ impl From<CPUGovernor> for String {
} }
#[typeshare] #[typeshare]
#[repr(u8)] #[repr(u32)]
#[derive( #[derive(
Deserialize, Serialize, Type, Value, OwnedValue, Debug, PartialEq, PartialOrd, Clone, Copy, Deserialize,
Serialize,
Type,
Value,
OwnedValue,
Default,
Debug,
PartialEq,
PartialOrd,
Clone,
Copy,
)] )]
#[zvariant(signature = "s")] #[zvariant(signature = "u")]
pub enum CPUEPP { pub enum CPUEPP {
#[default]
Default = 0, Default = 0,
Performance = 1, Performance = 1,
BalancePerformance = 2, BalancePerformance = 2,
@@ -193,12 +204,12 @@ pub enum CPUEPP {
Power = 4, Power = 4,
} }
impl From<PlatformPolicy> for CPUEPP { impl From<ThrottlePolicy> for CPUEPP {
fn from(value: PlatformPolicy) -> Self { fn from(value: ThrottlePolicy) -> Self {
match value { match value {
PlatformPolicy::Balanced => CPUEPP::BalancePerformance, ThrottlePolicy::Balanced => CPUEPP::BalancePerformance,
PlatformPolicy::Performance => CPUEPP::Performance, ThrottlePolicy::Performance => CPUEPP::Performance,
PlatformPolicy::Quiet => CPUEPP::Power, ThrottlePolicy::Quiet => CPUEPP::Power,
} }
} }
} }
+22 -32
View File
@@ -249,7 +249,7 @@ impl Display for GpuMode {
} }
#[typeshare] #[typeshare]
#[repr(u8)] #[repr(u32)]
#[derive( #[derive(
Deserialize, Deserialize,
Serialize, Serialize,
@@ -266,17 +266,17 @@ impl Display for GpuMode {
Clone, Clone,
Copy, Copy,
)] )]
#[zvariant(signature = "s")] #[zvariant(signature = "u")]
/// `throttle_thermal_policy` in asus_wmi /// `throttle_thermal_policy` in asus_wmi
pub enum PlatformPolicy { pub enum ThrottlePolicy {
#[default] #[default]
Balanced = 0, Balanced = 0,
Performance = 1, Performance = 1,
Quiet = 2, Quiet = 2,
} }
impl PlatformPolicy { impl ThrottlePolicy {
pub const fn next(&self) -> Self { pub const fn next(self) -> Self {
match self { match self {
Self::Balanced => Self::Performance, Self::Balanced => Self::Performance,
Self::Performance => Self::Quiet, Self::Performance => Self::Quiet,
@@ -289,7 +289,7 @@ impl PlatformPolicy {
} }
} }
impl From<u8> for PlatformPolicy { impl From<u8> for ThrottlePolicy {
fn from(num: u8) -> Self { fn from(num: u8) -> Self {
match num { match num {
0 => Self::Balanced, 0 => Self::Balanced,
@@ -303,55 +303,45 @@ impl From<u8> for PlatformPolicy {
} }
} }
impl From<PlatformPolicy> for u8 { impl From<ThrottlePolicy> for u8 {
fn from(p: PlatformPolicy) -> Self { fn from(p: ThrottlePolicy) -> Self {
match p { match p {
PlatformPolicy::Balanced => 0, ThrottlePolicy::Balanced => 0,
PlatformPolicy::Performance => 1, ThrottlePolicy::Performance => 1,
PlatformPolicy::Quiet => 2, ThrottlePolicy::Quiet => 2,
} }
} }
} }
impl From<PlatformPolicy> for &str { impl From<ThrottlePolicy> for &str {
fn from(profile: PlatformPolicy) -> &'static str { fn from(profile: ThrottlePolicy) -> &'static str {
match profile { match profile {
PlatformPolicy::Balanced => "balanced", ThrottlePolicy::Balanced => "balanced",
PlatformPolicy::Performance => "performance", ThrottlePolicy::Performance => "performance",
PlatformPolicy::Quiet => "quiet", ThrottlePolicy::Quiet => "quiet",
} }
} }
} }
impl std::str::FromStr for PlatformPolicy { impl std::str::FromStr for ThrottlePolicy {
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(PlatformPolicy::Balanced), "balanced" => Ok(ThrottlePolicy::Balanced),
"performance" => Ok(PlatformPolicy::Performance), "performance" => Ok(ThrottlePolicy::Performance),
"quiet" => Ok(PlatformPolicy::Quiet), "quiet" => Ok(ThrottlePolicy::Quiet),
_ => Err(PlatformError::NotSupported), _ => Err(PlatformError::NotSupported),
} }
} }
} }
impl Display for PlatformPolicy { impl Display for ThrottlePolicy {
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)
} }
} }
impl PlatformPolicy {
pub fn get_next_profile(current: PlatformPolicy) -> PlatformPolicy {
match current {
PlatformPolicy::Balanced => PlatformPolicy::Performance,
PlatformPolicy::Performance => PlatformPolicy::Quiet,
PlatformPolicy::Quiet => PlatformPolicy::Balanced,
}
}
}
/// CamelCase names of the properties. Intended for use with DBUS /// CamelCase names of the properties. Intended for use with DBUS
#[typeshare] #[typeshare]
#[repr(u8)] #[repr(u8)]
@@ -365,7 +355,7 @@ pub enum Properties {
PanelOd, PanelOd,
MiniLedMode, MiniLedMode,
EgpuEnable, EgpuEnable,
PlatformPolicy, ThrottlePolicy,
PptPl1Spl, PptPl1Spl,
PptPl2Sppt, PptPl2Sppt,
PptFppt, PptFppt,
+39 -34
View File
@@ -4,12 +4,13 @@ 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::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare; use typeshare::typeshare;
pub use udev::Device; pub use udev::Device;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use zbus::zvariant::Type; use zbus::zvariant::Type;
use zbus::zvariant::{OwnedValue, Value};
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -31,12 +32,16 @@ pub fn find_fan_curve_node() -> Result<Device, ProfileError> {
} }
#[typeshare] #[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))] #[cfg_attr(
feature = "dbus",
derive(Type, Value, OwnedValue),
zvariant(signature = "s")
)]
#[derive(Deserialize, Serialize, Debug, Hash, PartialEq, Eq, Clone, Copy)] #[derive(Deserialize, Serialize, Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub enum FanCurvePU { pub enum FanCurvePU {
CPU, CPU = 0,
GPU, GPU = 1,
MID, MID = 2,
} }
impl FanCurvePU { impl FanCurvePU {
@@ -118,7 +123,7 @@ impl FanCurveProfiles {
/// ///
pub fn read_from_dev_profile( pub fn read_from_dev_profile(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
device: &Device, device: &Device,
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = Self::supported_fans()?; let fans = Self::supported_fans()?;
@@ -136,9 +141,9 @@ impl FanCurveProfiles {
} }
match profile { match profile {
PlatformPolicy::Balanced => self.balanced = curves, ThrottlePolicy::Balanced => self.balanced = curves,
PlatformPolicy::Performance => self.performance = curves, ThrottlePolicy::Performance => self.performance = curves,
PlatformPolicy::Quiet => self.quiet = curves, ThrottlePolicy::Quiet => self.quiet = curves,
} }
Ok(()) Ok(())
} }
@@ -150,7 +155,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: PlatformPolicy, profile: ThrottlePolicy,
device: &mut Device, device: &mut Device,
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = Self::supported_fans()?; let fans = Self::supported_fans()?;
@@ -170,13 +175,13 @@ impl FanCurveProfiles {
// TODO: Make this return an error if curve is zeroed // TODO: Make this return an error if curve is zeroed
pub fn write_profile_curve_to_platform( pub fn write_profile_curve_to_platform(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
device: &mut Device, device: &mut Device,
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = match profile { let fans = match profile {
PlatformPolicy::Balanced => &mut self.balanced, ThrottlePolicy::Balanced => &mut self.balanced,
PlatformPolicy::Performance => &mut self.performance, ThrottlePolicy::Performance => &mut self.performance,
PlatformPolicy::Quiet => &mut self.quiet, ThrottlePolicy::Quiet => &mut self.quiet,
}; };
for fan in fans { for fan in fans {
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}"); debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
@@ -185,19 +190,19 @@ impl FanCurveProfiles {
Ok(()) Ok(())
} }
pub fn set_profile_curves_enabled(&mut self, profile: PlatformPolicy, enabled: bool) { pub fn set_profile_curves_enabled(&mut self, profile: ThrottlePolicy, enabled: bool) {
match profile { match profile {
PlatformPolicy::Balanced => { ThrottlePolicy::Balanced => {
for curve in self.balanced.iter_mut() { for curve in self.balanced.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
} }
PlatformPolicy::Performance => { ThrottlePolicy::Performance => {
for curve in self.performance.iter_mut() { for curve in self.performance.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
} }
PlatformPolicy::Quiet => { ThrottlePolicy::Quiet => {
for curve in self.quiet.iter_mut() { for curve in self.quiet.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
@@ -207,12 +212,12 @@ impl FanCurveProfiles {
pub fn set_profile_fan_curve_enabled( pub fn set_profile_fan_curve_enabled(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool,
) { ) {
match profile { match profile {
PlatformPolicy::Balanced => { ThrottlePolicy::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;
@@ -220,7 +225,7 @@ impl FanCurveProfiles {
} }
} }
} }
PlatformPolicy::Performance => { ThrottlePolicy::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;
@@ -228,7 +233,7 @@ impl FanCurveProfiles {
} }
} }
} }
PlatformPolicy::Quiet => { ThrottlePolicy::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;
@@ -239,31 +244,31 @@ impl FanCurveProfiles {
} }
} }
pub fn get_fan_curves_for(&self, name: PlatformPolicy) -> &[CurveData] { pub fn get_fan_curves_for(&self, name: ThrottlePolicy) -> &[CurveData] {
match name { match name {
PlatformPolicy::Balanced => &self.balanced, ThrottlePolicy::Balanced => &self.balanced,
PlatformPolicy::Performance => &self.performance, ThrottlePolicy::Performance => &self.performance,
PlatformPolicy::Quiet => &self.quiet, ThrottlePolicy::Quiet => &self.quiet,
} }
} }
pub fn get_fan_curve_for(&self, name: &PlatformPolicy, pu: FanCurvePU) -> Option<&CurveData> { pub fn get_fan_curve_for(&self, name: &ThrottlePolicy, pu: FanCurvePU) -> Option<&CurveData> {
match name { match name {
PlatformPolicy::Balanced => { ThrottlePolicy::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);
} }
} }
} }
PlatformPolicy::Performance => { ThrottlePolicy::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);
} }
} }
} }
PlatformPolicy::Quiet => { ThrottlePolicy::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);
@@ -277,10 +282,10 @@ impl FanCurveProfiles {
pub fn save_fan_curve( pub fn save_fan_curve(
&mut self, &mut self,
curve: CurveData, curve: CurveData,
profile: PlatformPolicy, profile: ThrottlePolicy,
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
match profile { match profile {
PlatformPolicy::Balanced => { ThrottlePolicy::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;
@@ -288,7 +293,7 @@ impl FanCurveProfiles {
} }
} }
} }
PlatformPolicy::Performance => { ThrottlePolicy::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;
@@ -296,7 +301,7 @@ impl FanCurveProfiles {
} }
} }
} }
PlatformPolicy::Quiet => { ThrottlePolicy::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;