mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bb7b3a81fb | |||
| 19607d71c3 | |||
| 96f281d789 | |||
| 7613eded95 | |||
| 50eccd2b1d | |||
| ba54007102 | |||
| a028f5375f | |||
| 9ec02cd727 | |||
| 4b46ece09a | |||
| 086bbd0908 | |||
| c94eaa473e | |||
| b1b809834b | |||
| 84183288ec | |||
| 86cbef83b6 | |||
| 006fb632c4 | |||
| e3636ed8ce | |||
| cfd207f251 | |||
| d4c68546e7 | |||
| 6f4a7e16dc | |||
| f64253d633 | |||
| 124c17aadc | |||
| ab40f9fcbf | |||
| 5cdfa5a8d4 | |||
| ce870cd5ed | |||
| 4541d2e1ba | |||
| b525411fd3 | |||
| a867496f13 | |||
| f421b8ee3b | |||
| 82780feb4b | |||
| 1e5443e206 | |||
| 027a591d26 |
@@ -59,6 +59,7 @@ release:
|
||||
- tags
|
||||
<<: *rust_cache
|
||||
script:
|
||||
- cargo install cargo-vendor-filterer
|
||||
- make && make vendor
|
||||
artifacts:
|
||||
paths:
|
||||
|
||||
@@ -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
|
||||
@@ -6,6 +6,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [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]
|
||||
### Changed
|
||||
- Fan-curves: nuke a few async deadlocks
|
||||
|
||||
Generated
+197
-199
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -4,10 +4,10 @@ default-members = ["asusctl", "asusd", "asusd-user", "cpuctl", "rog-control-cent
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "5.0.2"
|
||||
version = "5.0.8"
|
||||
rust-version = "1.75"
|
||||
|
||||
[workspace.dependencies]
|
||||
async-trait = "^0.1"
|
||||
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync"]}
|
||||
concat-idents = "^1.1"
|
||||
dirs = "^4.0"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[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
|
||||
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
|
||||
|
||||
**The minimum supported kernel version is 5.17**
|
||||
|
||||
**For TUF laptops, the minimum supported kernel version is 6.1**
|
||||
**The minimum supported kernel version is 6.6**
|
||||
|
||||
## 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.
|
||||
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
|
||||
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.
|
||||
|
||||
Point 3 means that the list of supported distros is very narrow - fedora is explicitly
|
||||
supported. All other distros are *not* supported (while asusd might still run fine on them).
|
||||
For best support use fedora 36+ Workstation.
|
||||
1. Provide safe dbus interface
|
||||
2. Respect the users resources: be small, light, and fast
|
||||
|
||||
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
|
||||
|
||||
@@ -41,6 +41,10 @@ to this:
|
||||
```
|
||||
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
|
||||
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
|
||||
|
||||
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):**
|
||||
|
||||
|
||||
@@ -22,5 +22,6 @@ gif.workspace = true
|
||||
tinybmp.workspace = true
|
||||
glam.workspace = true
|
||||
rog_dbus = { path = "../rog-dbus" }
|
||||
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync", "rt", "time"]}
|
||||
|
||||
cargo-husky.workspace = true
|
||||
@@ -1,5 +1,5 @@
|
||||
use gumdrop::Options;
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
|
||||
use crate::anime_cli::AnimeCommand;
|
||||
use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin};
|
||||
@@ -60,7 +60,7 @@ pub struct ProfileCommand {
|
||||
pub profile_get: bool,
|
||||
|
||||
#[options(meta = "", help = "set the active profile")]
|
||||
pub profile_set: Option<PlatformPolicy>,
|
||||
pub profile_set: Option<ThrottlePolicy>,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use gumdrop::Options;
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::FanCurvePU;
|
||||
|
||||
@@ -18,7 +18,7 @@ pub struct FanCurveCommand {
|
||||
meta = "",
|
||||
help = "profile to modify fan-curve for. Shows data if no options provided"
|
||||
)]
|
||||
pub mod_profile: Option<PlatformPolicy>,
|
||||
pub mod_profile: Option<ThrottlePolicy>,
|
||||
|
||||
#[options(
|
||||
meta = "",
|
||||
|
||||
+24
-11
@@ -18,7 +18,7 @@ use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraPowerDev};
|
||||
use rog_aura::{self, AuraEffect};
|
||||
use rog_dbus::RogDbusClientBlocking;
|
||||
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 crate::aura_cli::{AuraPowerStates, LedBrightness};
|
||||
@@ -132,9 +132,9 @@ fn do_parsed(
|
||||
println!("{}", CliStart::usage());
|
||||
println!();
|
||||
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();
|
||||
for command in commands.iter().filter(|command| {
|
||||
let dev_type = dbus.proxies().aura().device_type().unwrap();
|
||||
if !dev_type.is_old_style()
|
||||
&& !dev_type.is_tuf_style()
|
||||
&& command.trim().starts_with("led-pow-1")
|
||||
@@ -180,10 +180,23 @@ fn do_parsed(
|
||||
dbus.proxies().aura().set_brightness(brightness.prev())?;
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// if parsed.show_supported {
|
||||
// println!("Supported laptop functions:\n\n{}", supported);
|
||||
// }
|
||||
if parsed.show_supported {
|
||||
println!("Supported Core Functions:\n{:#?}", supported_interfaces);
|
||||
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 {
|
||||
dbus.proxies()
|
||||
@@ -420,8 +433,8 @@ fn handle_led_mode(
|
||||
|
||||
if let Some(cmdlist) = LedModeCommand::command_list() {
|
||||
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| {
|
||||
let modes = dbus.proxies().aura().supported_modes().unwrap();
|
||||
for mode in &modes {
|
||||
if command
|
||||
.trim()
|
||||
@@ -450,7 +463,7 @@ fn handle_led_mode(
|
||||
}
|
||||
if mode.next_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;
|
||||
if pos >= modes.len() {
|
||||
pos = 0;
|
||||
@@ -458,7 +471,7 @@ fn handle_led_mode(
|
||||
dbus.proxies().aura().set_led_mode(modes[pos])?;
|
||||
} else if mode.prev_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();
|
||||
if pos == 0 {
|
||||
pos = modes.len() - 1;
|
||||
@@ -662,7 +675,7 @@ fn handle_throttle_profile(
|
||||
supported: &[Properties],
|
||||
cmd: &ProfileCommand,
|
||||
) -> 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.");
|
||||
return Err(ProfileError::NotSupported.into());
|
||||
}
|
||||
@@ -691,7 +704,7 @@ fn handle_throttle_profile(
|
||||
}
|
||||
|
||||
if cmd.list {
|
||||
let res = PlatformPolicy::list();
|
||||
let res = ThrottlePolicy::list();
|
||||
for p in &res {
|
||||
println!("{:?}", p);
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,8 +22,8 @@ rog_profiles = { path = "../rog-profiles" }
|
||||
dmi_id = { path = "../dmi-id" }
|
||||
futures-lite = "*"
|
||||
udev.workspace = true
|
||||
inotify.workspace = true
|
||||
|
||||
async-trait.workspace = true
|
||||
tokio.workspace = true
|
||||
|
||||
# cli and logging
|
||||
|
||||
+161
-37
@@ -1,31 +1,78 @@
|
||||
use config_traits::{StdConfig, StdConfigLoad2};
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
use config_traits::{StdConfig, StdConfigLoad3};
|
||||
use rog_platform::cpu::CPUEPP;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
const CONFIG_FILE: &str = "asusd.ron";
|
||||
|
||||
#[derive(Deserialize, Serialize, Default, Debug)]
|
||||
#[derive(Deserialize, Serialize, Debug, PartialEq, PartialOrd)]
|
||||
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 panel_od: bool,
|
||||
pub mini_led_mode: bool,
|
||||
pub disable_nvidia_powerd_on_battery: bool,
|
||||
/// An optional command/script to run when power is changed to AC
|
||||
pub ac_command: String,
|
||||
/// An optional command/script to run when power is changed to battery
|
||||
pub bat_command: String,
|
||||
/// Restored on boot as well as when power is plugged
|
||||
#[serde(skip)]
|
||||
pub platform_policy_to_restore: PlatformPolicy,
|
||||
pub platform_policy_on_battery: PlatformPolicy,
|
||||
pub platform_policy_on_ac: PlatformPolicy,
|
||||
//
|
||||
/// Set true if energy_performance_preference should be set if the
|
||||
/// throttle/platform profile is changed
|
||||
pub throttle_policy_linked_epp: bool,
|
||||
/// Which throttle/profile to use on battery power
|
||||
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>,
|
||||
/// Defaults to `None` if not supported
|
||||
pub ppt_pl2_sppt: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
pub ppt_fppt: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
pub ppt_apu_sppt: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
pub ppt_platform_sppt: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
pub nv_dynamic_boost: Option<u8>,
|
||||
/// Defaults to `None` if not supported
|
||||
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 {
|
||||
@@ -33,8 +80,8 @@ impl StdConfig for Config {
|
||||
Config {
|
||||
charge_control_end_threshold: 100,
|
||||
disable_nvidia_powerd_on_battery: true,
|
||||
platform_policy_on_battery: PlatformPolicy::Quiet,
|
||||
platform_policy_on_ac: PlatformPolicy::Performance,
|
||||
throttle_policy_on_battery: ThrottlePolicy::Quiet,
|
||||
throttle_policy_on_ac: ThrottlePolicy::Performance,
|
||||
ac_command: String::new(),
|
||||
bat_command: String::new(),
|
||||
..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 {
|
||||
/// Save charge limit for restoring on boot
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::StdConfig;
|
||||
use log::warn;
|
||||
use logind_zbus::manager::ManagerProxy;
|
||||
@@ -35,7 +34,6 @@ async fn get_logind_manager<'a>() -> ManagerProxy<'a> {
|
||||
pub struct CtrlAnimeZbus(pub Arc<Mutex<CtrlAnime>>);
|
||||
|
||||
/// The struct with the main dbus methods requires this trait
|
||||
#[async_trait]
|
||||
impl crate::ZbusRun for CtrlAnimeZbus {
|
||||
async fn add_to_server(self, server: &mut Connection) {
|
||||
Self::add_to_server_helper(self, ANIME_ZBUS_PATH, server).await;
|
||||
@@ -259,7 +257,6 @@ impl CtrlAnimeZbus {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
fn zbus_path() -> &'static str {
|
||||
ANIME_ZBUS_PATH
|
||||
@@ -277,16 +274,8 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
async move {
|
||||
let lock = inner.lock().await;
|
||||
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.node
|
||||
.write_bytes(&pkt_set_enable_display(
|
||||
!(sleeping && lock.config.off_when_suspended),
|
||||
@@ -296,7 +285,21 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
})
|
||||
.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)
|
||||
.await;
|
||||
}
|
||||
@@ -379,7 +382,6 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl crate::Reloadable for CtrlAnimeZbus {
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
if let Some(lock) = self.0.try_lock() {
|
||||
|
||||
@@ -25,13 +25,13 @@ pub struct CtrlKbdLed {
|
||||
pub led_prod: AuraDevice,
|
||||
pub led_node: LEDNode,
|
||||
pub sysfs_node: KeyboardLed,
|
||||
pub supported_modes: LaptopLedData,
|
||||
pub supported_data: LaptopLedData,
|
||||
pub per_key_mode_active: bool,
|
||||
pub config: AuraConfig,
|
||||
}
|
||||
|
||||
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 usb_node = None;
|
||||
for prod in ASUS_KEYBOARD_DEVICES {
|
||||
@@ -97,7 +97,7 @@ impl CtrlKbdLed {
|
||||
let mut new_set = Vec::new();
|
||||
// only reuse a zone mode if the mode is supported
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ impl CtrlKbdLed {
|
||||
led_prod,
|
||||
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
|
||||
supported_modes,
|
||||
supported_data: supported_basic_modes,
|
||||
per_key_mode_active: false,
|
||||
config: config_loaded,
|
||||
};
|
||||
@@ -245,7 +245,7 @@ impl CtrlKbdLed {
|
||||
/// exists.
|
||||
fn create_multizone_default(&mut self) -> Result<(), RogError> {
|
||||
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 {
|
||||
mode: self.config.current_mode,
|
||||
zone: *tmp,
|
||||
@@ -285,7 +285,7 @@ mod tests {
|
||||
fn create_multizone_if_no_config() {
|
||||
// Checking to ensure set_mode errors when unsupported modes are tried
|
||||
let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
|
||||
let supported_modes = LaptopLedData {
|
||||
let supported_basic_modes = LaptopLedData {
|
||||
board_name: String::new(),
|
||||
layout_name: "ga401".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
@@ -297,7 +297,7 @@ mod tests {
|
||||
led_prod: AuraDevice::X19b6,
|
||||
led_node: LEDNode::None,
|
||||
sysfs_node: KeyboardLed::default(),
|
||||
supported_modes,
|
||||
supported_data: supported_basic_modes,
|
||||
per_key_mode_active: false,
|
||||
config,
|
||||
};
|
||||
@@ -306,8 +306,8 @@ mod tests {
|
||||
assert!(controller.create_multizone_default().is_err());
|
||||
assert!(controller.config.multizone.is_none());
|
||||
|
||||
controller.supported_modes.basic_zones.push(AuraZone::Key1);
|
||||
controller.supported_modes.basic_zones.push(AuraZone::Key2);
|
||||
controller.supported_data.basic_zones.push(AuraZone::Key1);
|
||||
controller.supported_data.basic_zones.push(AuraZone::Key2);
|
||||
assert!(controller.create_multizone_default().is_ok());
|
||||
assert!(controller.config.multizone.is_some());
|
||||
|
||||
@@ -323,7 +323,7 @@ mod tests {
|
||||
fn next_mode_create_multizone_if_no_config() {
|
||||
// Checking to ensure set_mode errors when unsupported modes are tried
|
||||
let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default());
|
||||
let supported_modes = LaptopLedData {
|
||||
let supported_basic_modes = LaptopLedData {
|
||||
board_name: String::new(),
|
||||
layout_name: "ga401".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
@@ -335,7 +335,7 @@ mod tests {
|
||||
led_prod: AuraDevice::X19b6,
|
||||
led_node: LEDNode::None,
|
||||
sysfs_node: KeyboardLed::default(),
|
||||
supported_modes,
|
||||
supported_data: supported_basic_modes,
|
||||
per_key_mode_active: false,
|
||||
config,
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::StdConfig;
|
||||
use log::{debug, error, info, warn};
|
||||
use rog_aura::advanced::UsbPackets;
|
||||
use rog_aura::aura_detection::PowerZones;
|
||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
||||
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
|
||||
@@ -32,7 +32,6 @@ impl CtrlAuraZbus {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl crate::ZbusRun for CtrlAuraZbus {
|
||||
async fn add_to_server(self, server: &mut Connection) {
|
||||
Self::add_to_server_helper(self, AURA_ZBUS_PATH, server).await;
|
||||
@@ -78,11 +77,23 @@ impl CtrlAuraZbus {
|
||||
|
||||
/// The total available modes
|
||||
#[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;
|
||||
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
|
||||
#[dbus_interface(property)]
|
||||
async fn led_mode(&self) -> Result<AuraModeNum, ZbErr> {
|
||||
@@ -126,9 +137,9 @@ impl CtrlAuraZbus {
|
||||
#[dbus_interface(property)]
|
||||
async fn set_led_mode_data(&mut self, effect: AuraEffect) -> Result<(), ZbErr> {
|
||||
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
|
||||
&& !ctrl.supported_modes.basic_zones.contains(&effect.zone)
|
||||
&& !ctrl.supported_data.basic_zones.contains(&effect.zone)
|
||||
{
|
||||
return Err(ZbErr::NotSupported(format!(
|
||||
"The Aura effect is not supported: {effect:?}"
|
||||
@@ -192,7 +203,6 @@ impl CtrlAuraZbus {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl CtrlTask for CtrlAuraZbus {
|
||||
fn zbus_path() -> &'static str {
|
||||
AURA_ZBUS_PATH
|
||||
@@ -265,7 +275,6 @@ impl CtrlTask for CtrlAuraZbus {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl crate::Reloadable for CtrlAuraZbus {
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
|
||||
+29
-37
@@ -1,11 +1,10 @@
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use futures_lite::StreamExt;
|
||||
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::fan_curve_set::CurveData;
|
||||
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
|
||||
@@ -70,19 +69,19 @@ impl CtrlFanCurveZbus {
|
||||
info!("{MOD_NAME}: Fetching default fan curves");
|
||||
|
||||
for this in [
|
||||
PlatformPolicy::Balanced,
|
||||
PlatformPolicy::Performance,
|
||||
PlatformPolicy::Quiet,
|
||||
ThrottlePolicy::Balanced,
|
||||
ThrottlePolicy::Performance,
|
||||
ThrottlePolicy::Quiet,
|
||||
] {
|
||||
// For each profile we need to switch to it before we
|
||||
// can read the existing values from hardware. The ACPI method used
|
||||
// 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())?;
|
||||
|
||||
let active = platform
|
||||
.get_throttle_thermal_policy()
|
||||
.map_or(PlatformPolicy::Balanced, |t| t.into());
|
||||
.map_or(ThrottlePolicy::Balanced, |t| t.into());
|
||||
|
||||
info!("{MOD_NAME}: {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
|
||||
async fn set_fan_curves_enabled(
|
||||
&mut self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
enabled: bool,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.fan_curves
|
||||
@@ -150,7 +149,7 @@ impl CtrlFanCurveZbus {
|
||||
/// activate a fan curve if in the same profile mode
|
||||
async fn set_profile_fan_curve_enabled(
|
||||
&mut self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
fan: FanCurvePU,
|
||||
enabled: bool,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
@@ -167,10 +166,10 @@ impl CtrlFanCurveZbus {
|
||||
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(
|
||||
&mut self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
) -> zbus::fdo::Result<Vec<CurveData>> {
|
||||
let curve = self
|
||||
.fan_curves
|
||||
@@ -185,7 +184,7 @@ impl CtrlFanCurveZbus {
|
||||
/// Will also activate the fan curve if the user is in the same mode.
|
||||
async fn set_fan_curve(
|
||||
&mut self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
curve: CurveData,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.fan_curves
|
||||
@@ -222,19 +221,14 @@ impl CtrlFanCurveZbus {
|
||||
///
|
||||
/// Each platform_profile has a different default and the defualt can be
|
||||
/// read only for the currently active profile.
|
||||
async fn reset_profile_curves(&self, profile: PlatformPolicy) -> zbus::fdo::Result<()> {
|
||||
let active = self
|
||||
.platform
|
||||
.get_throttle_thermal_policy()
|
||||
.unwrap_or(PlatformPolicy::Balanced.into());
|
||||
async fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> {
|
||||
let active = self.platform.get_throttle_thermal_policy()?;
|
||||
|
||||
self.platform.set_throttle_thermal_policy(profile.into())?;
|
||||
{
|
||||
self.fan_curves
|
||||
.lock()
|
||||
.await
|
||||
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
|
||||
}
|
||||
self.fan_curves
|
||||
.lock()
|
||||
.await
|
||||
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
|
||||
self.platform.set_throttle_thermal_policy(active)?;
|
||||
|
||||
self.update_config_from_profiles().await;
|
||||
@@ -243,14 +237,12 @@ impl CtrlFanCurveZbus {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl crate::ZbusRun for CtrlFanCurveZbus {
|
||||
async fn add_to_server(self, server: &mut Connection) {
|
||||
Self::add_to_server_helper(self, FAN_CURVE_ZBUS_PATH, server).await;
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl CtrlTask for CtrlFanCurveZbus {
|
||||
fn zbus_path() -> &'static str {
|
||||
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 {
|
||||
/// Fetch the active profile and use that to set all related components up
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
// let active = self.platform.get_throttle_thermal_policy()?.into();
|
||||
// if let Ok(mut device) = find_fan_curve_node() {
|
||||
// // 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
|
||||
// // after
|
||||
// self.fan_curves
|
||||
// .lock()
|
||||
// .await
|
||||
// .write_profile_curve_to_platform(active, &mut device)?;
|
||||
// }
|
||||
let active = self.platform.get_throttle_thermal_policy()?.into();
|
||||
if let Ok(mut device) = find_fan_curve_node() {
|
||||
// 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
|
||||
// after
|
||||
loop {
|
||||
if let Ok(mut curves) = self.fan_curves.try_lock() {
|
||||
curves.write_profile_curve_to_platform(active, &mut device)?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
+307
-48
@@ -1,11 +1,11 @@
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use config_traits::StdConfig;
|
||||
use log::{debug, error, info, warn};
|
||||
use rog_platform::cpu::{CPUControl, CPUGovernor};
|
||||
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties, RogPlatform};
|
||||
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
|
||||
use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
|
||||
use rog_platform::power::AsusPower;
|
||||
use zbus::export::futures_util::lock::Mutex;
|
||||
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_fancurves::{CtrlFanCurveZbus, FAN_CURVE_ZBUS_NAME, FAN_CURVE_ZBUS_PATH};
|
||||
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 {
|
||||
($self:ident, $property:tt, $prop_name:literal) => {
|
||||
@@ -33,7 +34,7 @@ macro_rules! platform_get_value {
|
||||
})
|
||||
})
|
||||
} else {
|
||||
error!("RogPlatform: {} not supported", $prop_name);
|
||||
info!("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 {
|
||||
if $self.platform.has() {
|
||||
let lock = $self.config.lock().await;
|
||||
Ok(lock.ppt_pl1_spl.unwrap_or($default))
|
||||
Ok(lock.$property.unwrap_or($default))
|
||||
} else {
|
||||
error!("RogPlatform: {} not supported", $prop_name);
|
||||
info!("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();
|
||||
Ok(())
|
||||
} else {
|
||||
error!("RogPlatform: {} not supported", $prop_name);
|
||||
info!("RogPlatform: {} not supported", $prop_name);
|
||||
Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)))
|
||||
}
|
||||
})
|
||||
@@ -115,7 +116,11 @@ pub struct 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 power = AsusPower::new()?;
|
||||
|
||||
@@ -124,14 +129,70 @@ impl CtrlPlatform {
|
||||
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,
|
||||
platform,
|
||||
config,
|
||||
cpu_control: CPUControl::new()
|
||||
.map_err(|e| error!("Couldn't get CPU control sysfs: {e}"))
|
||||
.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> {
|
||||
@@ -180,14 +241,18 @@ impl CtrlPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_and_set_epp(&self, profile: PlatformPolicy) {
|
||||
info!("PlatformPolicy setting EPP");
|
||||
fn check_and_set_epp(&self, enegy_pref: CPUEPP, change_epp: bool) {
|
||||
if !change_epp {
|
||||
info!("ThrottlePolicy unlinked from EPP");
|
||||
return;
|
||||
}
|
||||
info!("ThrottlePolicy setting EPP");
|
||||
if let Some(cpu) = self.cpu_control.as_ref() {
|
||||
if let Ok(epp) = cpu.get_available_epp() {
|
||||
debug!("Available EPP: {epp:?}");
|
||||
if epp.contains(&profile.into()) {
|
||||
debug!("Setting {profile:?}");
|
||||
cpu.set_epp(profile.into()).ok();
|
||||
if epp.contains(&enegy_pref) {
|
||||
debug!("Setting {enegy_pref:?}");
|
||||
cpu.set_epp(enegy_pref).ok();
|
||||
} else if let Ok(gov) = cpu.get_governor() {
|
||||
if gov != CPUGovernor::Powersave {
|
||||
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) {
|
||||
let profile = if power_plugged {
|
||||
self.config.lock().await.platform_policy_on_ac
|
||||
async fn get_config_epp_for_throttle(&self, throttle: ThrottlePolicy) -> CPUEPP {
|
||||
match throttle {
|
||||
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 {
|
||||
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
|
||||
.set_throttle_thermal_policy(profile.into())
|
||||
.set_throttle_thermal_policy(throttle.into())
|
||||
.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!(mini_led_mode, Properties::MiniLedMode);
|
||||
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_pl2_sppt, Properties::PptPl2Sppt);
|
||||
@@ -287,6 +362,13 @@ impl CtrlPlatform {
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
@@ -334,20 +416,21 @@ impl CtrlPlatform {
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||
) -> Result<(), FdoErr> {
|
||||
let policy: PlatformPolicy =
|
||||
let policy: ThrottlePolicy =
|
||||
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
|
||||
.map(|n| n.into())?;
|
||||
let policy = PlatformPolicy::next(&policy);
|
||||
let policy = ThrottlePolicy::next(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
|
||||
.set_throttle_thermal_policy(policy.into())
|
||||
.map_err(|err| {
|
||||
warn!("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?)
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
@@ -357,17 +440,18 @@ impl CtrlPlatform {
|
||||
}
|
||||
|
||||
#[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")
|
||||
.map(|n| n.into())
|
||||
}
|
||||
|
||||
#[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
|
||||
if self.platform.has_throttle_thermal_policy() {
|
||||
self.check_and_set_epp(policy);
|
||||
self.config.lock().await.platform_policy_to_restore = 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
|
||||
.set_throttle_thermal_policy(policy.into())
|
||||
.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)]
|
||||
fn post_animation_sound(&self) -> Result<bool, FdoErr> {
|
||||
platform_get_value!(self, post_animation_sound, "post_animation_sound")
|
||||
@@ -434,7 +603,10 @@ impl CtrlPlatform {
|
||||
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)]
|
||||
async fn ppt_pl1_spl(&self) -> Result<u8, FdoErr> {
|
||||
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)
|
||||
}
|
||||
|
||||
/// 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)]
|
||||
async fn ppt_pl2_sppt(&self) -> Result<u8, FdoErr> {
|
||||
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)
|
||||
}
|
||||
|
||||
/// Set the Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
|
||||
/// * min=5, max=250
|
||||
#[dbus_interface(property)]
|
||||
async fn ppt_fppt(&self) -> Result<u8, FdoErr> {
|
||||
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)
|
||||
}
|
||||
|
||||
/// Set the APU SPPT limit. Shown on full AMD systems only:
|
||||
/// * min=5, max=130
|
||||
#[dbus_interface(property)]
|
||||
async fn ppt_apu_sppt(&self) -> Result<u8, FdoErr> {
|
||||
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)
|
||||
}
|
||||
|
||||
/// Set the platform SPPT limit. Shown on full AMD systems only:
|
||||
/// * min=5, max=130
|
||||
#[dbus_interface(property)]
|
||||
async fn ppt_platform_sppt(&self) -> Result<u8, FdoErr> {
|
||||
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)
|
||||
}
|
||||
|
||||
/// Set the dynamic boost limit of the Nvidia dGPU:
|
||||
/// * min=5, max=25
|
||||
#[dbus_interface(property)]
|
||||
async fn nv_dynamic_boost(&self) -> Result<u8, FdoErr> {
|
||||
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)
|
||||
}
|
||||
|
||||
/// Set the target temperature limit of the Nvidia dGPU:
|
||||
/// * min=75, max=87
|
||||
#[dbus_interface(property)]
|
||||
async fn nv_temp_target(&self) -> Result<u8, FdoErr> {
|
||||
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 {
|
||||
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 {
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
if self.platform.has_panel_od() {
|
||||
@@ -533,8 +779,11 @@ impl crate::Reloadable for CtrlPlatform {
|
||||
}
|
||||
|
||||
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() {
|
||||
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;
|
||||
}
|
||||
@@ -574,10 +823,9 @@ impl CtrlPlatform {
|
||||
task_watch_item_notify!(nv_temp_target platform);
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl CtrlTask for CtrlPlatform {
|
||||
fn zbus_path() -> &'static str {
|
||||
ZBUS_PATH
|
||||
PLATFORM_ZBUS_PATH
|
||||
}
|
||||
|
||||
async fn create_tasks(&self, signal_ctxt: SignalContext<'static>) -> Result<(), RogError> {
|
||||
@@ -613,11 +861,18 @@ impl CtrlTask for CtrlPlatform {
|
||||
.ok();
|
||||
}
|
||||
if let Ok(power_plugged) = platform1.power.get_online() {
|
||||
if !sleeping && platform1.platform.has_throttle_thermal_policy() {
|
||||
platform1.update_policy_ac_or_bat(power_plugged > 0).await;
|
||||
}
|
||||
if !sleeping {
|
||||
platform1.run_ac_or_bat_cmd(power_plugged > 0).await;
|
||||
if platform1.config.lock().await.last_power_plugged != power_plugged {
|
||||
if !sleeping && platform1.platform.has_throttle_thermal_policy() {
|
||||
let change_epp =
|
||||
platform1.config.lock().await.throttle_policy_linked_epp;
|
||||
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
|
||||
async move {
|
||||
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;
|
||||
}
|
||||
@@ -692,13 +950,14 @@ impl CtrlTask for CtrlPlatform {
|
||||
if let Ok(profile) = ctrl
|
||||
.platform
|
||||
.get_throttle_thermal_policy()
|
||||
.map(PlatformPolicy::from)
|
||||
.map(ThrottlePolicy::from)
|
||||
.map_err(|e| {
|
||||
error!("Platform: get_throttle_thermal_policy error: {e}");
|
||||
})
|
||||
{
|
||||
ctrl.check_and_set_epp(profile);
|
||||
ctrl.config.lock().await.platform_policy_to_restore = profile;
|
||||
let change_epp = ctrl.config.lock().await.throttle_policy_linked_epp;
|
||||
let epp = ctrl.get_config_epp_for_throttle(profile).await;
|
||||
ctrl.check_and_set_epp(epp, change_epp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -15,7 +15,7 @@ use asusd::ctrl_aura::trait_impls::CtrlAuraZbus;
|
||||
use asusd::ctrl_fancurves::CtrlFanCurveZbus;
|
||||
use asusd::ctrl_platform::CtrlPlatform;
|
||||
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 rog_aura::aura_detection::LaptopLedData;
|
||||
use tokio::time::sleep;
|
||||
@@ -64,11 +64,16 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
let mut connection = Connection::system().await?;
|
||||
|
||||
let config = Config::new().load();
|
||||
let cfg_path = config.file_path();
|
||||
let config = Arc::new(Mutex::new(config));
|
||||
|
||||
// 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) => {
|
||||
let sig_ctx = CtrlPlatform::signal_context(&connection)?;
|
||||
start_tasks(ctrl, &mut connection, sig_ctx).await?;
|
||||
|
||||
+86
-71
@@ -15,7 +15,6 @@ pub mod error;
|
||||
use std::future::Future;
|
||||
use std::time::Duration;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use dmi_id::DMIID;
|
||||
use futures_lite::stream::StreamExt;
|
||||
use log::{debug, info, warn};
|
||||
@@ -130,34 +129,44 @@ pub fn print_board_info() {
|
||||
info!("Board name: {}", dmi.board_name);
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
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 ZbusRun {
|
||||
async fn add_to_server(self, server: &mut Connection);
|
||||
pub trait ReloadAndNotify {
|
||||
type Data: Send;
|
||||
|
||||
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,
|
||||
path: &str,
|
||||
server: &mut Connection,
|
||||
) {
|
||||
server
|
||||
.object_server()
|
||||
.at(&ObjectPath::from_str_unchecked(path), iface)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("{}: add_to_server {}", path, err);
|
||||
err
|
||||
})
|
||||
.ok();
|
||||
) -> impl std::future::Future<Output = ()> + Send {
|
||||
async move {
|
||||
server
|
||||
.object_server()
|
||||
.at(&ObjectPath::from_str_unchecked(path), iface)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("{}: add_to_server {}", path, err);
|
||||
err
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Set up a task to run on the async executor
|
||||
#[async_trait]
|
||||
pub trait CtrlTask {
|
||||
fn zbus_path() -> &'static str;
|
||||
|
||||
@@ -168,7 +177,10 @@ pub trait CtrlTask {
|
||||
/// 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
|
||||
/// 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
|
||||
// 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
|
||||
/// minimal possible such as save a variable.
|
||||
async fn create_sys_event_tasks<
|
||||
fn create_sys_event_tasks<
|
||||
Fut1,
|
||||
Fut2,
|
||||
Fut3,
|
||||
@@ -201,7 +213,8 @@ pub trait CtrlTask {
|
||||
mut on_prepare_for_shutdown: F2,
|
||||
mut on_lid_change: F3,
|
||||
mut on_external_power_change: F4,
|
||||
) where
|
||||
) -> impl std::future::Future<Output = ()> + Send
|
||||
where
|
||||
F1: FnMut(bool) -> Fut1,
|
||||
F2: FnMut(bool) -> Fut2,
|
||||
F3: FnMut(bool) -> Fut3,
|
||||
@@ -211,70 +224,72 @@ pub trait CtrlTask {
|
||||
Fut3: Future<Output = ()> + Send,
|
||||
Fut4: Future<Output = ()> + Send,
|
||||
{
|
||||
let connection = Connection::system()
|
||||
.await
|
||||
.expect("Controller could not create dbus connection");
|
||||
async {
|
||||
let connection = Connection::system()
|
||||
.await
|
||||
.expect("Controller could not create dbus connection");
|
||||
|
||||
let manager = ManagerProxy::builder(&connection)
|
||||
.cache_properties(CacheProperties::No)
|
||||
.build()
|
||||
.await
|
||||
.expect("Controller could not create ManagerProxy");
|
||||
let manager = ManagerProxy::builder(&connection)
|
||||
.cache_properties(CacheProperties::No)
|
||||
.build()
|
||||
.await
|
||||
.expect("Controller could not create ManagerProxy");
|
||||
|
||||
let manager1 = manager.clone();
|
||||
tokio::spawn(async move {
|
||||
if let Ok(mut notif) = manager1.receive_prepare_for_shutdown().await {
|
||||
while let Some(event) = notif.next().await {
|
||||
// blocks thread :|
|
||||
if let Ok(args) = event.args() {
|
||||
debug!("Doing on_prepare_for_shutdown({})", args.start);
|
||||
on_prepare_for_shutdown(args.start).await;
|
||||
let manager1 = manager.clone();
|
||||
tokio::spawn(async move {
|
||||
if let Ok(mut notif) = manager1.receive_prepare_for_shutdown().await {
|
||||
while let Some(event) = notif.next().await {
|
||||
// blocks thread :|
|
||||
if let Ok(args) = event.args() {
|
||||
debug!("Doing on_prepare_for_shutdown({})", args.start);
|
||||
on_prepare_for_shutdown(args.start).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let manager2 = manager.clone();
|
||||
tokio::spawn(async move {
|
||||
if let Ok(mut notif) = manager2.receive_prepare_for_sleep().await {
|
||||
while let Some(event) = notif.next().await {
|
||||
// blocks thread :|
|
||||
if let Ok(args) = event.args() {
|
||||
debug!("Doing on_prepare_for_sleep({})", args.start);
|
||||
on_prepare_for_sleep(args.start).await;
|
||||
let manager2 = manager.clone();
|
||||
tokio::spawn(async move {
|
||||
if let Ok(mut notif) = manager2.receive_prepare_for_sleep().await {
|
||||
while let Some(event) = notif.next().await {
|
||||
// blocks thread :|
|
||||
if let Ok(args) = event.args() {
|
||||
debug!("Doing on_prepare_for_sleep({})", args.start);
|
||||
on_prepare_for_sleep(args.start).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let manager3 = manager.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut last_power = manager3.on_external_power().await.unwrap_or_default();
|
||||
let manager3 = manager.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut last_power = manager3.on_external_power().await.unwrap_or_default();
|
||||
|
||||
loop {
|
||||
if let Ok(next) = manager3.on_external_power().await {
|
||||
if next != last_power {
|
||||
last_power = next;
|
||||
on_external_power_change(next).await;
|
||||
loop {
|
||||
if let Ok(next) = manager3.on_external_power().await {
|
||||
if next != last_power {
|
||||
last_power = next;
|
||||
on_external_power_change(next).await;
|
||||
}
|
||||
}
|
||||
sleep(Duration::from_secs(2)).await;
|
||||
}
|
||||
sleep(Duration::from_secs(2)).await;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
tokio::spawn(async move {
|
||||
let mut last_lid = manager.lid_closed().await.unwrap_or_default();
|
||||
// need to loop on these as they don't emit signals
|
||||
loop {
|
||||
if let Ok(next) = manager.lid_closed().await {
|
||||
if next != last_lid {
|
||||
last_lid = next;
|
||||
on_lid_change(next).await;
|
||||
tokio::spawn(async move {
|
||||
let mut last_lid = manager.lid_closed().await.unwrap_or_default();
|
||||
// need to loop on these as they don't emit signals
|
||||
loop {
|
||||
if let Ok(next) = manager.lid_closed().await {
|
||||
if next != last_lid {
|
||||
last_lid = next;
|
||||
on_lid_change(next).await;
|
||||
}
|
||||
}
|
||||
sleep(Duration::from_secs(2)).await;
|
||||
}
|
||||
sleep(Duration::from_secs(2)).await;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Get the data set for every mode available
|
||||
-->
|
||||
<method name="AllModeData">
|
||||
<arg type="a{u(us(yyy)(yyy)ss)}" direction="out"/>
|
||||
<arg type="a{u(uu(yyy)(yyy)ss)}" direction="out"/>
|
||||
</method>
|
||||
<!--
|
||||
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
|
||||
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.
|
||||
`enabled` sets if the sent array should be disabled or enabled
|
||||
|
||||
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
|
||||
-->
|
||||
<property name="SupportedBrightness" type="au" access="read"/>
|
||||
<!--
|
||||
The total available modes
|
||||
-->
|
||||
<property name="SupportedModes" type="au" access="read"/>
|
||||
<property name="SupportedPowerZones" type="au" access="read"/>
|
||||
</interface>
|
||||
</node>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
</method>
|
||||
<!--
|
||||
Get the fan-curve data for the currently active PlatformPolicy
|
||||
Get the fan-curve data for the currently active ThrottlePolicy
|
||||
-->
|
||||
<method name="FanCurveData">
|
||||
<arg name="profile" type="s" direction="in"/>
|
||||
|
||||
+17
-2
@@ -2,6 +2,20 @@
|
||||
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 {
|
||||
Discrete = "Discrete",
|
||||
Optimus = "Optimus",
|
||||
@@ -13,7 +27,8 @@ export enum GpuMode {
|
||||
NotSupported = "NotSupported",
|
||||
}
|
||||
|
||||
export enum PlatformPolicy {
|
||||
/** `throttle_thermal_policy` in asus_wmi */
|
||||
export enum ThrottlePolicy {
|
||||
Balanced = "Balanced",
|
||||
Performance = "Performance",
|
||||
Quiet = "Quiet",
|
||||
@@ -28,7 +43,7 @@ export enum Properties {
|
||||
PanelOd = "PanelOd",
|
||||
MiniLedMode = "MiniLedMode",
|
||||
EgpuEnable = "EgpuEnable",
|
||||
PlatformPolicy = "PlatformPolicy",
|
||||
ThrottlePolicy = "ThrottlePolicy",
|
||||
PptPl1Spl = "PptPl1Spl",
|
||||
PptPl2Sppt = "PptPl2Sppt",
|
||||
PptFppt = "PptFppt",
|
||||
|
||||
@@ -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
|
||||
fn write(&self) {
|
||||
let mut file = match File::create(self.file_path()) {
|
||||
|
||||
@@ -71,6 +71,14 @@
|
||||
advanced_type: None,
|
||||
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",
|
||||
layout_name: "g512",
|
||||
@@ -231,6 +239,14 @@
|
||||
advanced_type: PerKey,
|
||||
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",
|
||||
layout_name: "g634j-per-key",
|
||||
@@ -399,6 +415,22 @@
|
||||
advanced_type: PerKey,
|
||||
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",
|
||||
layout_name: "ga401q",
|
||||
@@ -695,4 +727,4 @@
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
),
|
||||
])
|
||||
])
|
||||
|
||||
@@ -28,7 +28,7 @@ pub struct LedSupportFile(Vec<LaptopLedData>);
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "s")
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Copy, Clone)]
|
||||
pub enum PowerZones {
|
||||
|
||||
@@ -303,7 +303,7 @@ impl From<AuraEffect> for AuraModeNum {
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "s")
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub enum AuraZone {
|
||||
|
||||
+1
-2
@@ -10,10 +10,9 @@ pub mod effects;
|
||||
pub mod advanced;
|
||||
/// Convert the `RgbAddress` to `&str` labels
|
||||
pub mod advanced_to_str;
|
||||
pub mod error;
|
||||
pub use advanced_to_str::*;
|
||||
/// Helper for detecting what is available
|
||||
pub mod aura_detection;
|
||||
pub mod error;
|
||||
/// Helpers for consructing keyboard layouts for UI use and effects
|
||||
pub mod layouts;
|
||||
pub mod usb;
|
||||
|
||||
+2
-2
@@ -137,7 +137,7 @@ pub struct AuraPowerDev {
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "y")
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
@@ -172,7 +172,7 @@ impl AuraDevTuf {
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "y")
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
|
||||
@@ -10,10 +10,12 @@ edition = "2021"
|
||||
#mocking = []
|
||||
|
||||
[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"}
|
||||
eframe = { git = "https://github.com/emilk/egui", rev = "b8e798777de519de3a1878798097ab2ab0bd4def"}
|
||||
# egui = { path = "../../egui/crates/egui" }
|
||||
# eframe = { path = "../../egui/crates/eframe" }
|
||||
|
||||
libappindicator = "0.8" # Tray icon
|
||||
gtk = "0.16"
|
||||
|
||||
@@ -107,7 +107,7 @@ impl eframe::App for RogApp {
|
||||
/// Called each time the UI needs repainting, which may be many times per
|
||||
/// second. Put your widgets into a `SidePanel`, `TopPanel`,
|
||||
/// `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();
|
||||
|
||||
if let Ok(mut states) = states.try_lock() {
|
||||
@@ -131,7 +131,7 @@ impl eframe::App for RogApp {
|
||||
return;
|
||||
}
|
||||
|
||||
self.top_bar(&mut states, ctx, frame);
|
||||
self.top_bar(ctx, frame);
|
||||
self.side_panel(ctx);
|
||||
}
|
||||
let page = self.page;
|
||||
|
||||
@@ -6,9 +6,9 @@ use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use eframe::IconData;
|
||||
use eframe::HardwareAcceleration;
|
||||
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::layouts::KeyLayout;
|
||||
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,
|
||||
SHOW_GUI,
|
||||
};
|
||||
#[cfg(not(feature = "mocking"))]
|
||||
use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
#[cfg(not(feature = "mocking"))]
|
||||
@@ -29,7 +31,8 @@ const DATA_DIR: &str = "/usr/share/rog-gui/";
|
||||
#[cfg(feature = "mocking")]
|
||||
const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR");
|
||||
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<()> {
|
||||
let args: Vec<String> = args().skip(1).collect();
|
||||
@@ -60,12 +63,10 @@ fn main() -> Result<()> {
|
||||
|
||||
let native_options = eframe::NativeOptions {
|
||||
vsync: true,
|
||||
decorated: true,
|
||||
transparent: false,
|
||||
min_window_size: Some(egui::vec2(960.0, 670.0)),
|
||||
max_window_size: Some(egui::vec2(960.0, 670.0)),
|
||||
hardware_acceleration: HardwareAcceleration::Preferred,
|
||||
min_window_size: Some(egui::vec2(980.0, 670.0)),
|
||||
max_window_size: Some(egui::vec2(980.0, 670.0)),
|
||||
run_and_return: true,
|
||||
icon_data: Some(load_icon()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -187,10 +188,27 @@ fn main() -> Result<()> {
|
||||
&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 {
|
||||
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;
|
||||
loop {
|
||||
if !running_in_bg.load(Ordering::Relaxed) {
|
||||
@@ -202,7 +220,9 @@ fn main() -> Result<()> {
|
||||
"ROG Control Center",
|
||||
native_options.clone(),
|
||||
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 !lock.run_in_bg || cli_parsed.board_name.is_some() || cli_parsed.layout_viewing {
|
||||
if !lock.run_in_bg {
|
||||
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.
|
||||
fn load_icon() -> IconData {
|
||||
let path = PathBuf::from(APP_ICON_PATH);
|
||||
let mut rgba = Vec::new();
|
||||
let mut height = 512;
|
||||
let mut width = 512;
|
||||
if path.exists() {
|
||||
if let Ok(data) = std::fs::read(path)
|
||||
.map_err(|e| error!("Error reading app icon: {e:?}"))
|
||||
.map_err(|e| error!("Error opening app icon: {e:?}"))
|
||||
{
|
||||
let data = std::io::Cursor::new(data);
|
||||
let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
|
||||
let png_pong::Step { raster, delay: _ } = decoder.last().unwrap().unwrap();
|
||||
// fn load_icon() -> IconData {
|
||||
// let path = PathBuf::from(APP_ICON_PATH);
|
||||
// let mut rgba = Vec::new();
|
||||
// let mut height = 512;
|
||||
// let mut width = 512;
|
||||
// if path.exists() {
|
||||
// if let Ok(data) = std::fs::read(path)
|
||||
// .map_err(|e| error!("Error reading app icon: {e:?}"))
|
||||
// .map_err(|e| error!("Error opening app icon: {e:?}"))
|
||||
// {
|
||||
// let data = std::io::Cursor::new(data);
|
||||
// let decoder = png_pong::Decoder::new(data).unwrap().into_steps();
|
||||
// let png_pong::Step { raster, delay: _ } =
|
||||
// decoder.last().unwrap().unwrap();
|
||||
|
||||
if let png_pong::PngRaster::Rgba8(ras) = raster {
|
||||
rgba = ras.as_u8_slice().to_vec();
|
||||
width = ras.width();
|
||||
height = ras.height();
|
||||
info!("Loaded app icon. Not actually supported in Wayland yet");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error!("Missing {APP_ICON_PATH}");
|
||||
}
|
||||
// if let png_pong::PngRaster::Rgba8(ras) = raster {
|
||||
// rgba = ras.as_u8_slice().to_vec();
|
||||
// width = ras.width();
|
||||
// height = ras.height();
|
||||
// info!("Loaded app icon. Not actually supported in Wayland
|
||||
// yet"); }
|
||||
// }
|
||||
// } else {
|
||||
// error!("Missing {APP_ICON_PATH}");
|
||||
// }
|
||||
|
||||
IconData {
|
||||
height,
|
||||
width,
|
||||
rgba,
|
||||
}
|
||||
}
|
||||
// IconData {
|
||||
// height,
|
||||
// width,
|
||||
// rgba,
|
||||
// }
|
||||
// }
|
||||
|
||||
fn do_cli_help(parsed: &CliStart) -> bool {
|
||||
if parsed.help {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::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| {
|
||||
ui.label("In progress");
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::widgets::app_settings;
|
||||
use crate::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;
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::widgets::{aura_modes_group, keyboard};
|
||||
use crate::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 {
|
||||
oscillator1,
|
||||
oscillator2,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use egui::{RichText, Ui};
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
|
||||
use crate::system_state::{FanCurvesState, SystemState};
|
||||
use crate::widgets::fan_graphs;
|
||||
use crate::{RogApp, RogDbusClientBlocking};
|
||||
|
||||
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 {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Custom fan curves");
|
||||
@@ -29,7 +29,7 @@ impl RogApp {
|
||||
}
|
||||
|
||||
fn fan_curve(
|
||||
current: &mut PlatformPolicy,
|
||||
current: &mut ThrottlePolicy,
|
||||
curves: &mut FanCurvesState,
|
||||
dbus: &RogDbusClientBlocking<'_>,
|
||||
do_error: &mut Option<String>,
|
||||
@@ -43,31 +43,6 @@ impl RogApp {
|
||||
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(¤t) {
|
||||
// for curve in curves.iter_mut() {
|
||||
// fan_curve_enable(current, curve.fan, curve.enabled);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Enabled fan-curves: ");
|
||||
let mut checked = false;
|
||||
|
||||
@@ -3,9 +3,3 @@ mod app_settings;
|
||||
mod aura_page;
|
||||
mod fan_curve_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::*;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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;
|
||||
|
||||
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| {
|
||||
ui.heading("Laptop settings");
|
||||
|
||||
@@ -22,7 +22,7 @@ impl RogApp {
|
||||
ui.vertical(|ui| {
|
||||
ui.separator();
|
||||
if self.supported_interfaces.contains(&"Aura".to_string()) {
|
||||
// aura_power_group(states, ui);
|
||||
aura_power_group(states, ui);
|
||||
}
|
||||
});
|
||||
ui.end_row();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use egui::{Button, RichText};
|
||||
use egui::RichText;
|
||||
|
||||
pub struct AppErrorShow {
|
||||
error: String,
|
||||
@@ -11,7 +11,7 @@ impl 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| {
|
||||
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));
|
||||
});
|
||||
|
||||
egui::TopBottomPanel::bottom("error_bar_2")
|
||||
.default_height(26.0)
|
||||
.show(ctx, |ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||
if ui
|
||||
.add(Button::new(RichText::new("Okay").size(20.0)))
|
||||
.clicked()
|
||||
{
|
||||
frame.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
// egui::TopBottomPanel::bottom("error_bar_2")
|
||||
// .default_height(26.0)
|
||||
// .show(ctx, |ui| {
|
||||
// ui.
|
||||
// with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||
// if ui
|
||||
// .add(Button::new(RichText::new("Okay").size(20.0)))
|
||||
// .clicked()
|
||||
// {
|
||||
// // frame.close();
|
||||
// // ui.close_menu();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ use std::time::SystemTime;
|
||||
use egui::Vec2;
|
||||
use log::error;
|
||||
use rog_anime::{Animations, DeviceState};
|
||||
use rog_aura::aura_detection::PowerZones;
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_aura::usb::AuraPowerDev;
|
||||
use rog_aura::{AuraEffect, AuraModeNum, LedBrightness};
|
||||
use rog_platform::platform::{GpuMode, PlatformPolicy};
|
||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
||||
use rog_platform::platform::{GpuMode, ThrottlePolicy};
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::FanCurvePU;
|
||||
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
||||
@@ -33,7 +34,7 @@ pub struct PlatformState {
|
||||
pub mini_led_mode: Option<bool>,
|
||||
pub dgpu_disable: Option<bool>,
|
||||
pub egpu_enable: Option<bool>,
|
||||
pub throttle: Option<PlatformPolicy>,
|
||||
pub throttle: Option<ThrottlePolicy>,
|
||||
pub charge_limit: Option<u8>,
|
||||
}
|
||||
|
||||
@@ -64,9 +65,9 @@ impl PlatformState {
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct FanCurvesState {
|
||||
pub show_curve: PlatformPolicy,
|
||||
pub show_curve: ThrottlePolicy,
|
||||
pub show_graph: FanCurvePU,
|
||||
pub curves: BTreeMap<PlatformPolicy, Vec<CurveData>>,
|
||||
pub curves: BTreeMap<ThrottlePolicy, Vec<CurveData>>,
|
||||
pub available_fans: HashSet<FanCurvePU>,
|
||||
pub drag_delta: Vec2,
|
||||
}
|
||||
@@ -74,25 +75,26 @@ pub struct FanCurvesState {
|
||||
impl FanCurvesState {
|
||||
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
|
||||
let profiles = vec![
|
||||
PlatformPolicy::Balanced,
|
||||
PlatformPolicy::Quiet,
|
||||
PlatformPolicy::Performance,
|
||||
ThrottlePolicy::Balanced,
|
||||
ThrottlePolicy::Quiet,
|
||||
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 {
|
||||
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);
|
||||
} else {
|
||||
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()?;
|
||||
|
||||
Ok(Self {
|
||||
@@ -110,6 +112,9 @@ pub struct AuraState {
|
||||
pub current_mode: AuraModeNum,
|
||||
pub modes: BTreeMap<AuraModeNum, AuraEffect>,
|
||||
pub enabled: AuraPowerDev,
|
||||
pub dev_type: AuraDevice,
|
||||
pub supported_basic_zones: Vec<AuraZone>,
|
||||
pub supported_power_zones: Vec<PowerZones>,
|
||||
/// Brightness from 0-3
|
||||
pub bright: LedBrightness,
|
||||
pub wave_red: [u8; 22],
|
||||
@@ -132,6 +137,17 @@ impl AuraState {
|
||||
BTreeMap::new()
|
||||
},
|
||||
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(),
|
||||
wave_red: [0u8; 22],
|
||||
wave_green: [0u8; 22],
|
||||
|
||||
@@ -14,7 +14,7 @@ use notify_rust::{Hint, Notification, NotificationHandle, Urgency};
|
||||
use rog_dbus::zbus_anime::AnimeProxy;
|
||||
use rog_dbus::zbus_aura::AuraProxy;
|
||||
use rog_dbus::zbus_platform::PlatformProxy;
|
||||
use rog_platform::platform::{GpuMode, PlatformPolicy};
|
||||
use rog_platform::platform::{GpuMode, ThrottlePolicy};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use supergfxctl::actions::UserActionRequired as GfxUserAction;
|
||||
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()?)
|
||||
}
|
||||
|
||||
fn do_thermal_notif(message: &str, profile: &PlatformPolicy) -> Result<NotificationHandle> {
|
||||
fn do_thermal_notif(message: &str, profile: &ThrottlePolicy) -> Result<NotificationHandle> {
|
||||
let icon = match profile {
|
||||
PlatformPolicy::Balanced => "asus_notif_yellow",
|
||||
PlatformPolicy::Performance => "asus_notif_red",
|
||||
PlatformPolicy::Quiet => "asus_notif_green",
|
||||
ThrottlePolicy::Balanced => "asus_notif_yellow",
|
||||
ThrottlePolicy::Performance => "asus_notif_red",
|
||||
ThrottlePolicy::Quiet => "asus_notif_green",
|
||||
};
|
||||
let profile: &str = (*profile).into();
|
||||
let mut notif = base_notification(message, &profile.to_uppercase());
|
||||
|
||||
@@ -224,12 +224,11 @@ pub fn aura_modes_group(states: &mut SystemState, freq: &mut Arc<AtomicU8>, ui:
|
||||
|
||||
if changed {
|
||||
states.aura.current_mode = selected;
|
||||
|
||||
states
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.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| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
|
||||
@@ -4,24 +4,23 @@ use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
|
||||
|
||||
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");
|
||||
|
||||
if supported.keyboard_led.dev_id.is_old_style() || supported.keyboard_led.dev_id.is_tuf_style()
|
||||
{
|
||||
aura_power1(supported, states, ui);
|
||||
} else if supported.keyboard_led.dev_id.is_new_style() {
|
||||
aura_power2(supported, states, ui);
|
||||
if states.aura.dev_type.is_old_style() || states.aura.dev_type.is_tuf_style() {
|
||||
aura_power1(states, ui);
|
||||
} else if states.aura.dev_type.is_new_style() {
|
||||
aura_power2(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 mut boot = enabled_states.old_rog.contains(&AuraDevRog1::Boot);
|
||||
let mut sleep = enabled_states.old_rog.contains(&AuraDevRog1::Sleep);
|
||||
let mut keyboard = enabled_states.old_rog.contains(&AuraDevRog1::Keyboard);
|
||||
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);
|
||||
sleep = enabled_states.tuf.contains(&AuraDevTuf::Sleep);
|
||||
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() {
|
||||
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()
|
||||
{
|
||||
changed = true;
|
||||
@@ -93,7 +92,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
||||
});
|
||||
|
||||
if changed {
|
||||
if supported.keyboard_led.dev_id == AuraDevice::Tuf {
|
||||
if states.aura.dev_type == AuraDevice::Tuf {
|
||||
let mut enabled = Vec::new();
|
||||
let mut disabled = Vec::new();
|
||||
|
||||
@@ -132,7 +131,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.aura()
|
||||
.set_led_power(options, enable)
|
||||
.set_led_power((options, enable))
|
||||
.map_err(|err| {
|
||||
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(sleep, AuraDevRog1::Sleep);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -182,7 +181,7 @@ fn aura_power1(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
||||
.asus_dbus
|
||||
.proxies()
|
||||
.aura()
|
||||
.set_led_power(options, enable)
|
||||
.set_led_power((options, enable))
|
||||
.map_err(|err| {
|
||||
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 {
|
||||
keyboard,
|
||||
logo,
|
||||
@@ -208,7 +207,7 @@ fn aura_power2(supported: &SupportedFunctions, states: &mut SystemState, ui: &mu
|
||||
let mut changed = false;
|
||||
let mut item = |power: &mut KbAuraPowerState, ui: &mut 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.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
|
||||
.proxies()
|
||||
.aura()
|
||||
.set_led_power(options, enable)
|
||||
.set_led_power((options, enable))
|
||||
.map_err(|err| {
|
||||
states.error = Some(err.to_string());
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use egui::plot::Points;
|
||||
use egui::plot::{Line, Plot, Points};
|
||||
use egui::Ui;
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::FanCurvePU;
|
||||
|
||||
@@ -13,9 +13,13 @@ pub fn fan_graphs(
|
||||
do_error: &mut Option<String>,
|
||||
ui: &mut Ui,
|
||||
) {
|
||||
if curves.available_fans.is_empty() {
|
||||
return; // TODO:
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
let mut item = |profile: PlatformPolicy, ui: &mut Ui| {
|
||||
let mut item = |profile: ThrottlePolicy, ui: &mut Ui| {
|
||||
ui.group(|ui| {
|
||||
if ui
|
||||
.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();
|
||||
|
||||
use egui::plot::{Line, Plot};
|
||||
|
||||
let mut data = &mut CurveData::default();
|
||||
for c in curve {
|
||||
if c.fan == curves.show_graph {
|
||||
@@ -116,8 +118,8 @@ pub fn fan_graphs(
|
||||
.allow_scroll(false)
|
||||
.allow_drag(false)
|
||||
.allow_boxed_zoom(false)
|
||||
.x_axis_formatter(|d, _r| format!("{}", d))
|
||||
.y_axis_formatter(|d, _r| format!("{:.*}%", 1, d))
|
||||
// .x_axis_formatter(|d, _r| format!("{}", d))
|
||||
// .y_axis_formatter(|d, _r| format!("{:.*}%", 1, d))
|
||||
.label_formatter(|name, value| {
|
||||
if !name.is_empty() {
|
||||
format!("{}: {:.*}%", name, 1, value.y)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
mod anime_power;
|
||||
mod app_settings;
|
||||
mod aura_modes;
|
||||
// mod aura_power;
|
||||
mod aura_power;
|
||||
mod fan_graph;
|
||||
mod keyboard_layout;
|
||||
mod rog_bios;
|
||||
@@ -11,9 +11,7 @@ mod top_bar;
|
||||
pub use anime_power::*;
|
||||
pub use app_settings::*;
|
||||
pub use aura_modes::*;
|
||||
// pub use aura_power::*;
|
||||
pub use aura_power::*;
|
||||
pub use fan_graph::*;
|
||||
pub use keyboard_layout::*;
|
||||
pub use rog_bios::*;
|
||||
pub use side_panel::*;
|
||||
pub use top_bar::*;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use egui::Ui;
|
||||
use rog_platform::platform::{GpuMode, PlatformPolicy};
|
||||
use rog_platform::platform::{GpuMode, ThrottlePolicy};
|
||||
|
||||
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 {
|
||||
ui.heading("Platform profile");
|
||||
|
||||
let mut item = |p: PlatformPolicy, ui: &mut Ui| {
|
||||
let mut item = |p: ThrottlePolicy, ui: &mut Ui| {
|
||||
if ui
|
||||
.selectable_value(&mut throttle, p, format!("{p:?}"))
|
||||
.clicked()
|
||||
@@ -25,7 +25,7 @@ pub fn platform_profile(states: &mut SystemState, ui: &mut Ui) {
|
||||
};
|
||||
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
for a in PlatformPolicy::list() {
|
||||
for a in ThrottlePolicy::list() {
|
||||
item(a, ui);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{Page, 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")
|
||||
.resizable(false)
|
||||
.default_width(60.0) // TODO: set size to match icon buttons when done
|
||||
|
||||
@@ -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};
|
||||
|
||||
impl RogApp {
|
||||
pub fn top_bar(
|
||||
&mut self,
|
||||
states: &mut SystemState,
|
||||
ctx: &egui::Context,
|
||||
frame: &mut eframe::Frame,
|
||||
) {
|
||||
pub fn top_bar(&mut self, ctx: &eframe::egui::Context, frame: &mut eframe::Frame) {
|
||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||
// The top panel is often a good place for a menu bar:
|
||||
egui::menu::bar(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
self.dark_light_mode_buttons(ui);
|
||||
egui::warn_if_debug_build(ui);
|
||||
if ui.button("Quit app").clicked() {
|
||||
states.run_in_bg = false;
|
||||
frame.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Drag area
|
||||
@@ -43,15 +33,14 @@ impl RogApp {
|
||||
FontId::proportional(height - 2.0),
|
||||
text_color,
|
||||
);
|
||||
// // Add the close button:
|
||||
// let close_response = ui.put(
|
||||
// egui::Rect::from_min_size(titlebar_rect.right_top(),
|
||||
// egui::Vec2::splat(height)),
|
||||
// egui::Button::new(egui::RichText::new("❌").size(height -
|
||||
// 4.0)).frame(false), );
|
||||
// if close_response.clicked() {
|
||||
// frame.close();
|
||||
// }
|
||||
// Add the close button:
|
||||
let close_response = ui.put(
|
||||
Rect::from_min_size(titlebar_rect.right_top(), Vec2::splat(height)),
|
||||
Button::new(RichText::new("❌").size(height - 4.0)).frame(false),
|
||||
);
|
||||
if close_response.clicked() {
|
||||
frame.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use rog_aura::advanced::UsbPackets;
|
||||
use rog_aura::aura_detection::PowerZones;
|
||||
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::{dbus_proxy, Result};
|
||||
|
||||
@@ -74,9 +75,17 @@ trait Aura {
|
||||
#[dbus_proxy(property)]
|
||||
fn supported_brightness(&self) -> zbus::Result<Vec<LedBrightness>>;
|
||||
|
||||
/// SupportedModes property
|
||||
/// SupportedBasicModes 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>);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//!
|
||||
//! …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::FanCurvePU;
|
||||
use zbus::dbus_proxy;
|
||||
@@ -32,30 +32,30 @@ use zbus::dbus_proxy;
|
||||
)]
|
||||
trait FanCurves {
|
||||
/// 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
|
||||
/// platform.
|
||||
///
|
||||
/// Each platform_profile has a different default and the defualt can be
|
||||
/// 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
|
||||
fn set_active_curve_to_defaults(&self) -> zbus::Result<()>;
|
||||
|
||||
/// 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.
|
||||
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.
|
||||
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
|
||||
/// activate a fan curve.
|
||||
async fn set_profile_fan_curve_enabled(
|
||||
&self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
fan: FanCurvePU,
|
||||
enabled: bool,
|
||||
) -> zbus::Result<()>;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//!
|
||||
//! …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;
|
||||
|
||||
#[dbus_proxy(
|
||||
@@ -118,9 +118,9 @@ trait Platform {
|
||||
#[dbus_proxy(property)]
|
||||
fn set_ppt_platform_sppt(&self, value: u8) -> zbus::Result<()>;
|
||||
|
||||
/// PlatformPolicy property
|
||||
/// ThrottlePolicy property
|
||||
#[dbus_proxy(property)]
|
||||
fn throttle_thermal_policy(&self) -> zbus::Result<PlatformPolicy>;
|
||||
fn throttle_thermal_policy(&self) -> zbus::Result<ThrottlePolicy>;
|
||||
#[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
@@ -6,7 +6,7 @@ use typeshare::typeshare;
|
||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||
|
||||
use crate::error::{PlatformError, Result};
|
||||
use crate::platform::PlatformPolicy;
|
||||
use crate::platform::ThrottlePolicy;
|
||||
use crate::{read_attr_string, to_device};
|
||||
|
||||
const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors";
|
||||
@@ -180,12 +180,23 @@ impl From<CPUGovernor> for String {
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[repr(u8)]
|
||||
#[repr(u32)]
|
||||
#[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 {
|
||||
#[default]
|
||||
Default = 0,
|
||||
Performance = 1,
|
||||
BalancePerformance = 2,
|
||||
@@ -193,12 +204,12 @@ pub enum CPUEPP {
|
||||
Power = 4,
|
||||
}
|
||||
|
||||
impl From<PlatformPolicy> for CPUEPP {
|
||||
fn from(value: PlatformPolicy) -> Self {
|
||||
impl From<ThrottlePolicy> for CPUEPP {
|
||||
fn from(value: ThrottlePolicy) -> Self {
|
||||
match value {
|
||||
PlatformPolicy::Balanced => CPUEPP::BalancePerformance,
|
||||
PlatformPolicy::Performance => CPUEPP::Performance,
|
||||
PlatformPolicy::Quiet => CPUEPP::Power,
|
||||
ThrottlePolicy::Balanced => CPUEPP::BalancePerformance,
|
||||
ThrottlePolicy::Performance => CPUEPP::Performance,
|
||||
ThrottlePolicy::Quiet => CPUEPP::Power,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ impl Display for GpuMode {
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[repr(u8)]
|
||||
#[repr(u32)]
|
||||
#[derive(
|
||||
Deserialize,
|
||||
Serialize,
|
||||
@@ -266,17 +266,17 @@ impl Display for GpuMode {
|
||||
Clone,
|
||||
Copy,
|
||||
)]
|
||||
#[zvariant(signature = "s")]
|
||||
#[zvariant(signature = "u")]
|
||||
/// `throttle_thermal_policy` in asus_wmi
|
||||
pub enum PlatformPolicy {
|
||||
pub enum ThrottlePolicy {
|
||||
#[default]
|
||||
Balanced = 0,
|
||||
Performance = 1,
|
||||
Quiet = 2,
|
||||
}
|
||||
|
||||
impl PlatformPolicy {
|
||||
pub const fn next(&self) -> Self {
|
||||
impl ThrottlePolicy {
|
||||
pub const fn next(self) -> Self {
|
||||
match self {
|
||||
Self::Balanced => Self::Performance,
|
||||
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 {
|
||||
match num {
|
||||
0 => Self::Balanced,
|
||||
@@ -303,55 +303,45 @@ impl From<u8> for PlatformPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PlatformPolicy> for u8 {
|
||||
fn from(p: PlatformPolicy) -> Self {
|
||||
impl From<ThrottlePolicy> for u8 {
|
||||
fn from(p: ThrottlePolicy) -> Self {
|
||||
match p {
|
||||
PlatformPolicy::Balanced => 0,
|
||||
PlatformPolicy::Performance => 1,
|
||||
PlatformPolicy::Quiet => 2,
|
||||
ThrottlePolicy::Balanced => 0,
|
||||
ThrottlePolicy::Performance => 1,
|
||||
ThrottlePolicy::Quiet => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PlatformPolicy> for &str {
|
||||
fn from(profile: PlatformPolicy) -> &'static str {
|
||||
impl From<ThrottlePolicy> for &str {
|
||||
fn from(profile: ThrottlePolicy) -> &'static str {
|
||||
match profile {
|
||||
PlatformPolicy::Balanced => "balanced",
|
||||
PlatformPolicy::Performance => "performance",
|
||||
PlatformPolicy::Quiet => "quiet",
|
||||
ThrottlePolicy::Balanced => "balanced",
|
||||
ThrottlePolicy::Performance => "performance",
|
||||
ThrottlePolicy::Quiet => "quiet",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for PlatformPolicy {
|
||||
impl std::str::FromStr for ThrottlePolicy {
|
||||
type Err = PlatformError;
|
||||
|
||||
fn from_str(profile: &str) -> Result<Self> {
|
||||
match profile.to_ascii_lowercase().trim() {
|
||||
"balanced" => Ok(PlatformPolicy::Balanced),
|
||||
"performance" => Ok(PlatformPolicy::Performance),
|
||||
"quiet" => Ok(PlatformPolicy::Quiet),
|
||||
"balanced" => Ok(ThrottlePolicy::Balanced),
|
||||
"performance" => Ok(ThrottlePolicy::Performance),
|
||||
"quiet" => Ok(ThrottlePolicy::Quiet),
|
||||
_ => Err(PlatformError::NotSupported),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for PlatformPolicy {
|
||||
impl Display for ThrottlePolicy {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
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
|
||||
#[typeshare]
|
||||
#[repr(u8)]
|
||||
@@ -365,7 +355,7 @@ pub enum Properties {
|
||||
PanelOd,
|
||||
MiniLedMode,
|
||||
EgpuEnable,
|
||||
PlatformPolicy,
|
||||
ThrottlePolicy,
|
||||
PptPl1Spl,
|
||||
PptPl2Sppt,
|
||||
PptFppt,
|
||||
|
||||
+39
-34
@@ -4,12 +4,13 @@ pub mod fan_curve_set;
|
||||
use error::ProfileError;
|
||||
use fan_curve_set::CurveData;
|
||||
use log::debug;
|
||||
use rog_platform::platform::PlatformPolicy;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
pub use udev::Device;
|
||||
#[cfg(feature = "dbus")]
|
||||
use zbus::zvariant::Type;
|
||||
use zbus::zvariant::{OwnedValue, Value};
|
||||
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
@@ -31,12 +32,16 @@ pub fn find_fan_curve_node() -> Result<Device, ProfileError> {
|
||||
}
|
||||
|
||||
#[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)]
|
||||
pub enum FanCurvePU {
|
||||
CPU,
|
||||
GPU,
|
||||
MID,
|
||||
CPU = 0,
|
||||
GPU = 1,
|
||||
MID = 2,
|
||||
}
|
||||
|
||||
impl FanCurvePU {
|
||||
@@ -118,7 +123,7 @@ impl FanCurveProfiles {
|
||||
///
|
||||
pub fn read_from_dev_profile(
|
||||
&mut self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
device: &Device,
|
||||
) -> Result<(), ProfileError> {
|
||||
let fans = Self::supported_fans()?;
|
||||
@@ -136,9 +141,9 @@ impl FanCurveProfiles {
|
||||
}
|
||||
|
||||
match profile {
|
||||
PlatformPolicy::Balanced => self.balanced = curves,
|
||||
PlatformPolicy::Performance => self.performance = curves,
|
||||
PlatformPolicy::Quiet => self.quiet = curves,
|
||||
ThrottlePolicy::Balanced => self.balanced = curves,
|
||||
ThrottlePolicy::Performance => self.performance = curves,
|
||||
ThrottlePolicy::Quiet => self.quiet = curves,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -150,7 +155,7 @@ impl FanCurveProfiles {
|
||||
/// read only for the currently active profile.
|
||||
pub fn set_active_curve_to_defaults(
|
||||
&mut self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
device: &mut Device,
|
||||
) -> Result<(), ProfileError> {
|
||||
let fans = Self::supported_fans()?;
|
||||
@@ -170,13 +175,13 @@ impl FanCurveProfiles {
|
||||
// TODO: Make this return an error if curve is zeroed
|
||||
pub fn write_profile_curve_to_platform(
|
||||
&mut self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
device: &mut Device,
|
||||
) -> Result<(), ProfileError> {
|
||||
let fans = match profile {
|
||||
PlatformPolicy::Balanced => &mut self.balanced,
|
||||
PlatformPolicy::Performance => &mut self.performance,
|
||||
PlatformPolicy::Quiet => &mut self.quiet,
|
||||
ThrottlePolicy::Balanced => &mut self.balanced,
|
||||
ThrottlePolicy::Performance => &mut self.performance,
|
||||
ThrottlePolicy::Quiet => &mut self.quiet,
|
||||
};
|
||||
for fan in fans {
|
||||
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
|
||||
@@ -185,19 +190,19 @@ impl FanCurveProfiles {
|
||||
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 {
|
||||
PlatformPolicy::Balanced => {
|
||||
ThrottlePolicy::Balanced => {
|
||||
for curve in self.balanced.iter_mut() {
|
||||
curve.enabled = enabled;
|
||||
}
|
||||
}
|
||||
PlatformPolicy::Performance => {
|
||||
ThrottlePolicy::Performance => {
|
||||
for curve in self.performance.iter_mut() {
|
||||
curve.enabled = enabled;
|
||||
}
|
||||
}
|
||||
PlatformPolicy::Quiet => {
|
||||
ThrottlePolicy::Quiet => {
|
||||
for curve in self.quiet.iter_mut() {
|
||||
curve.enabled = enabled;
|
||||
}
|
||||
@@ -207,12 +212,12 @@ impl FanCurveProfiles {
|
||||
|
||||
pub fn set_profile_fan_curve_enabled(
|
||||
&mut self,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
fan: FanCurvePU,
|
||||
enabled: bool,
|
||||
) {
|
||||
match profile {
|
||||
PlatformPolicy::Balanced => {
|
||||
ThrottlePolicy::Balanced => {
|
||||
for curve in self.balanced.iter_mut() {
|
||||
if curve.fan == fan {
|
||||
curve.enabled = enabled;
|
||||
@@ -220,7 +225,7 @@ impl FanCurveProfiles {
|
||||
}
|
||||
}
|
||||
}
|
||||
PlatformPolicy::Performance => {
|
||||
ThrottlePolicy::Performance => {
|
||||
for curve in self.performance.iter_mut() {
|
||||
if curve.fan == fan {
|
||||
curve.enabled = enabled;
|
||||
@@ -228,7 +233,7 @@ impl FanCurveProfiles {
|
||||
}
|
||||
}
|
||||
}
|
||||
PlatformPolicy::Quiet => {
|
||||
ThrottlePolicy::Quiet => {
|
||||
for curve in self.quiet.iter_mut() {
|
||||
if curve.fan == fan {
|
||||
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 {
|
||||
PlatformPolicy::Balanced => &self.balanced,
|
||||
PlatformPolicy::Performance => &self.performance,
|
||||
PlatformPolicy::Quiet => &self.quiet,
|
||||
ThrottlePolicy::Balanced => &self.balanced,
|
||||
ThrottlePolicy::Performance => &self.performance,
|
||||
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 {
|
||||
PlatformPolicy::Balanced => {
|
||||
ThrottlePolicy::Balanced => {
|
||||
for this_curve in self.balanced.iter() {
|
||||
if this_curve.fan == pu {
|
||||
return Some(this_curve);
|
||||
}
|
||||
}
|
||||
}
|
||||
PlatformPolicy::Performance => {
|
||||
ThrottlePolicy::Performance => {
|
||||
for this_curve in self.performance.iter() {
|
||||
if this_curve.fan == pu {
|
||||
return Some(this_curve);
|
||||
}
|
||||
}
|
||||
}
|
||||
PlatformPolicy::Quiet => {
|
||||
ThrottlePolicy::Quiet => {
|
||||
for this_curve in self.quiet.iter() {
|
||||
if this_curve.fan == pu {
|
||||
return Some(this_curve);
|
||||
@@ -277,10 +282,10 @@ impl FanCurveProfiles {
|
||||
pub fn save_fan_curve(
|
||||
&mut self,
|
||||
curve: CurveData,
|
||||
profile: PlatformPolicy,
|
||||
profile: ThrottlePolicy,
|
||||
) -> Result<(), ProfileError> {
|
||||
match profile {
|
||||
PlatformPolicy::Balanced => {
|
||||
ThrottlePolicy::Balanced => {
|
||||
for this_curve in self.balanced.iter_mut() {
|
||||
if this_curve.fan == curve.fan {
|
||||
*this_curve = curve;
|
||||
@@ -288,7 +293,7 @@ impl FanCurveProfiles {
|
||||
}
|
||||
}
|
||||
}
|
||||
PlatformPolicy::Performance => {
|
||||
ThrottlePolicy::Performance => {
|
||||
for this_curve in self.performance.iter_mut() {
|
||||
if this_curve.fan == curve.fan {
|
||||
*this_curve = curve;
|
||||
@@ -296,7 +301,7 @@ impl FanCurveProfiles {
|
||||
}
|
||||
}
|
||||
}
|
||||
PlatformPolicy::Quiet => {
|
||||
ThrottlePolicy::Quiet => {
|
||||
for this_curve in self.quiet.iter_mut() {
|
||||
if this_curve.fan == curve.fan {
|
||||
*this_curve = curve;
|
||||
|
||||
Reference in New Issue
Block a user