Compare commits

..

6 Commits

Author SHA1 Message Date
Luke D. Jones f421b8ee3b Fix to apply led effect in rogcc 2023-12-23 21:45:19 +13:00
Luke D. Jones 82780feb4b Update readme 2023-12-23 10:37:46 +13:00
Luke D. Jones 1e5443e206 Bugfix release 2023-12-22 11:39:17 +13:00
Luke D. Jones 027a591d26 Add cargo-vendor-filterer to pipeline 2023-12-17 21:44:33 +13:00
Luke D. Jones e90375828d Fix: nuke some async deadlocks in fan-curves 2023-12-17 21:41:07 +13:00
Luke D. Jones 75b4d67072 Fix: force Anime power/wakeup disabled to prevent idiotic random wakes 2023-12-15 19:15:14 +13:00
24 changed files with 265 additions and 128 deletions
+1
View File
@@ -59,6 +59,7 @@ release:
- tags
<<: *rust_cache
script:
- cargo install cargo-vendor-filterer
- make && make vendor
artifacts:
paths:
+17
View File
@@ -6,6 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Added G834JZ led config
- Fix in ROGCC to apply the actual effect changed
## [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
- Anime: force power/wakeup disabled to prevent idiotic random wakes
## [v5.0.1]
### Changed
- Fix setting next fan profile
Generated
+14 -13
View File
@@ -199,7 +199,7 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "asusctl"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"asusd",
"cargo-husky",
@@ -218,7 +218,7 @@ dependencies = [
[[package]]
name = "asusd"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"async-trait",
"cargo-husky",
@@ -237,12 +237,13 @@ dependencies = [
"serde_derive",
"systemd-zbus",
"tokio",
"udev",
"zbus",
]
[[package]]
name = "asusd-user"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"cargo-husky",
"config-traits",
@@ -845,7 +846,7 @@ dependencies = [
[[package]]
name = "config-traits"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"cargo-husky",
"log",
@@ -898,7 +899,7 @@ dependencies = [
[[package]]
name = "cpuctl"
version = "5.0.0"
version = "5.0.4"
[[package]]
name = "cpufeatures"
@@ -1025,7 +1026,7 @@ dependencies = [
[[package]]
name = "dmi_id"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"log",
"udev",
@@ -2845,7 +2846,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rog-control-center"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"asusd",
"cargo-husky",
@@ -2878,7 +2879,7 @@ dependencies = [
[[package]]
name = "rog_anime"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"cargo-husky",
"dmi_id",
@@ -2895,7 +2896,7 @@ dependencies = [
[[package]]
name = "rog_aura"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"cargo-husky",
"dmi_id",
@@ -2909,7 +2910,7 @@ dependencies = [
[[package]]
name = "rog_dbus"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"asusd",
"cargo-husky",
@@ -2922,7 +2923,7 @@ dependencies = [
[[package]]
name = "rog_platform"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"cargo-husky",
"concat-idents",
@@ -2939,7 +2940,7 @@ dependencies = [
[[package]]
name = "rog_profiles"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"cargo-husky",
"log",
@@ -2953,7 +2954,7 @@ dependencies = [
[[package]]
name = "rog_simulators"
version = "5.0.0"
version = "5.0.4"
dependencies = [
"glam",
"log",
+2 -2
View File
@@ -4,11 +4,11 @@ default-members = ["asusctl", "asusd", "asusd-user", "cpuctl", "rog-control-cent
resolver = "2"
[workspace.package]
version = "5.0.1"
version = "5.0.4"
[workspace.dependencies]
async-trait = "^0.1"
tokio = { version = "^1.23.0", features = ["macros", "sync", "rt-multi-thread"]}
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync"]}
concat-idents = "^1.1"
dirs = "^4.0"
smol = "^1.3"
+16 -12
View File
@@ -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.
+4 -4
View File
@@ -421,7 +421,7 @@ fn handle_led_mode(
if let Some(cmdlist) = LedModeCommand::command_list() {
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
for command in commands.iter().filter(|command| {
let modes = dbus.proxies().aura().supported_modes().unwrap();
let modes = dbus.proxies().aura().supported_basic_modes().unwrap();
for mode in &modes {
if command
.trim()
@@ -450,7 +450,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 +458,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 +662,7 @@ fn handle_throttle_profile(
supported: &[Properties],
cmd: &ProfileCommand,
) -> Result<(), Box<dyn std::error::Error>> {
if !supported.contains(&Properties::DgpuDisable) {
if !supported.contains(&Properties::PlatformPolicy) {
println!("Profiles not supported by either this kernel or by the laptop.");
return Err(ProfileError::NotSupported.into());
}
+1
View File
@@ -21,6 +21,7 @@ rog_platform = { path = "../rog-platform" }
rog_profiles = { path = "../rog-profiles" }
dmi_id = { path = "../dmi-id" }
futures-lite = "*"
udev.workspace = true
async-trait.workspace = true
tokio.workspace = true
+14
View File
@@ -73,6 +73,20 @@ impl CtrlAnime {
return Err(RogError::Anime(AnimeError::NoDevice));
};
// TODO: something better to set wakeups disabled
if matches!(node, Node::Usb(_)) {
if let Ok(mut enumerator) = udev::Enumerator::new() {
enumerator.match_subsystem("usb").ok();
enumerator.match_attribute("idProduct", "193b").ok();
if let Ok(mut enumer) = enumerator.scan_devices() {
if let Some(mut dev) = enumer.next() {
dev.set_attribute_value("power/wakeup", "disabled").ok();
}
}
}
}
let mut anime_type = get_anime_type()?;
if let AnimeType::Unknown = anime_type {
if let Some(model) = config.model_override {
+26 -1
View File
@@ -277,6 +277,15 @@ 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(
@@ -316,8 +325,16 @@ impl crate::CtrlTask for CtrlAnimeZbus {
async move {
let lock = inner.lock().await;
if lock.config.off_when_lid_closed {
if lock.config.builtin_anims_enabled {
lock.node
.write_bytes(&pkt_set_enable_powersave_anim(!lid_closed))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_suspended {}", err);
})
.ok();
}
lock.node
.write_bytes(&pkt_set_enable_display(lid_closed))
.write_bytes(&pkt_set_enable_display(!lid_closed))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_lid_closed {}", err);
})
@@ -331,6 +348,14 @@ impl crate::CtrlTask for CtrlAnimeZbus {
async move {
let lock = inner.lock().await;
if lock.config.off_when_unplugged {
if lock.config.builtin_anims_enabled {
lock.node
.write_bytes(&pkt_set_enable_powersave_anim(power_plugged))
.map_err(|err| {
warn!("create_sys_event_tasks::off_when_suspended {}", err);
})
.ok();
}
lock.node
.write_bytes(&pkt_set_enable_display(power_plugged))
.map_err(|err| {
+11 -11
View File
@@ -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,
};
+16 -3
View File
@@ -5,6 +5,7 @@ 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};
@@ -78,11 +79,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 +139,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:?}"
+48 -32
View File
@@ -109,19 +109,18 @@ impl CtrlFanCurveZbus {
}
pub async fn update_profiles_from_config(&self) {
let mut fan_curves = self.fan_curves.lock().await;
let config = self.config.lock().await;
fan_curves.balanced = config.balanced.clone();
fan_curves.performance = config.performance.clone();
fan_curves.quiet = config.quiet.clone();
self.fan_curves.lock().await.balanced = self.config.lock().await.balanced.clone();
self.fan_curves.lock().await.performance = self.config.lock().await.performance.clone();
self.fan_curves.lock().await.quiet = self.config.lock().await.quiet.clone();
}
/// Because this locks both config and fan_curves, it means nothing else can
/// hold a lock across this function call. Stupid choice to do this and
/// needs to be fixed.
pub async fn update_config_from_profiles(&self) {
let fan_curves = self.fan_curves.lock().await;
let mut config = self.config.lock().await;
config.balanced = fan_curves.balanced.clone();
config.performance = fan_curves.performance.clone();
config.quiet = fan_curves.quiet.clone();
self.config.lock().await.balanced = self.fan_curves.lock().await.balanced.clone();
self.config.lock().await.performance = self.fan_curves.lock().await.performance.clone();
self.config.lock().await.quiet = self.fan_curves.lock().await.quiet.clone();
}
}
@@ -134,10 +133,14 @@ impl CtrlFanCurveZbus {
profile: PlatformPolicy,
enabled: bool,
) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
fan_curves.set_profile_curves_enabled(profile, enabled);
fan_curves.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.fan_curves
.lock()
.await
.set_profile_curves_enabled(profile, enabled);
self.fan_curves
.lock()
.await
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.update_config_from_profiles().await;
self.config.lock().await.write();
Ok(())
@@ -151,10 +154,14 @@ impl CtrlFanCurveZbus {
fan: FanCurvePU,
enabled: bool,
) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
fan_curves.set_profile_fan_curve_enabled(profile, fan, enabled);
fan_curves.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.fan_curves
.lock()
.await
.set_profile_fan_curve_enabled(profile, fan, enabled);
self.fan_curves
.lock()
.await
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.update_config_from_profiles().await;
self.config.lock().await.write();
Ok(())
@@ -165,9 +172,13 @@ impl CtrlFanCurveZbus {
&mut self,
profile: PlatformPolicy,
) -> zbus::fdo::Result<Vec<CurveData>> {
let fan_curves = self.fan_curves.lock().await;
let curve = fan_curves.get_fan_curves_for(profile);
Ok(curve.to_vec())
let curve = self
.fan_curves
.lock()
.await
.get_fan_curves_for(profile)
.to_vec();
Ok(curve)
}
/// Set the fan curve for the specified profile.
@@ -177,13 +188,16 @@ impl CtrlFanCurveZbus {
profile: PlatformPolicy,
curve: CurveData,
) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
fan_curves.save_fan_curve(curve, profile)?;
fan_curves.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.fan_curves
.lock()
.await
.save_fan_curve(curve, profile)?;
self.fan_curves
.lock()
.await
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
self.update_config_from_profiles().await;
self.config.lock().await.write();
Ok(())
}
@@ -193,10 +207,11 @@ impl CtrlFanCurveZbus {
/// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile.
async fn set_active_curve_to_defaults(&mut self) -> zbus::fdo::Result<()> {
let mut fan_curves = self.fan_curves.lock().await;
let active = self.platform.get_throttle_thermal_policy()?;
fan_curves.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.update_config_from_profiles().await;
self.config.lock().await.write();
Ok(())
@@ -208,15 +223,16 @@ 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 mut fan_curves = self.fan_curves.lock().await;
let active = self
.platform
.get_throttle_thermal_policy()
.unwrap_or(PlatformPolicy::Balanced.into());
self.platform.set_throttle_thermal_policy(profile.into())?;
fan_curves.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;
+26 -20
View File
@@ -4,7 +4,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use config_traits::StdConfig;
use log::{debug, error, info, warn};
use rog_platform::cpu::CPUControl;
use rog_platform::cpu::{CPUControl, CPUGovernor};
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties, RogPlatform};
use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex;
@@ -33,7 +33,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 +45,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 +69,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)))
}
})
@@ -180,6 +180,23 @@ impl CtrlPlatform {
}
}
fn check_and_set_epp(&self, profile: PlatformPolicy) {
info!("PlatformPolicy 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();
} else if let Ok(gov) = cpu.get_governor() {
if gov != CPUGovernor::Powersave {
warn!("powersave governor is not is use, you should use it.");
}
}
}
}
}
async fn update_policy_ac_or_bat(&self, power_plugged: bool) {
let profile = if power_plugged {
self.config.lock().await.platform_policy_on_ac
@@ -189,9 +206,7 @@ impl CtrlPlatform {
self.platform
.set_throttle_thermal_policy(profile.into())
.ok();
if let Some(cpu) = self.cpu_control.as_ref() {
cpu.set_epp(profile.into()).ok();
}
self.check_and_set_epp(profile);
}
}
@@ -325,10 +340,7 @@ impl CtrlPlatform {
let policy = PlatformPolicy::next(&policy);
if self.platform.has_throttle_thermal_policy() {
if let Some(cpu) = self.cpu_control.as_ref() {
info!("PlatformPolicy setting EPP");
cpu.set_epp(policy.into())?
}
self.check_and_set_epp(policy);
self.platform
.set_throttle_thermal_policy(policy.into())
.map_err(|err| {
@@ -354,10 +366,7 @@ impl CtrlPlatform {
async fn set_throttle_thermal_policy(&mut self, policy: PlatformPolicy) -> Result<(), FdoErr> {
// TODO: watch for external changes
if self.platform.has_throttle_thermal_policy() {
if let Some(cpu) = self.cpu_control.as_ref() {
info!("PlatformPolicy setting EPP");
cpu.set_epp(policy.into())?
}
self.check_and_set_epp(policy);
self.config.lock().await.platform_policy_to_restore = policy;
self.platform
.set_throttle_thermal_policy(policy.into())
@@ -688,10 +697,7 @@ impl CtrlTask for CtrlPlatform {
error!("Platform: get_throttle_thermal_policy error: {e}");
})
{
if let Some(cpu) = ctrl.cpu_control.as_ref() {
info!("PlatformPolicy setting EPP");
cpu.set_epp(profile.into()).ok();
}
ctrl.check_and_set_epp(profile);
ctrl.config.lock().await.platform_policy_to_restore = profile;
}
}
+8
View File
@@ -399,6 +399,14 @@
advanced_type: PerKey,
power_zones: [Keyboard, Lightbar],
),
(
board_name: "G834JZ",
layout_name: "G834JZ",
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",
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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 {
+3 -1
View File
@@ -202,7 +202,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())
}),
)?;
+2 -2
View File
@@ -1,5 +1,5 @@
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 {
@@ -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();
+17 -2
View File
@@ -6,9 +6,10 @@ 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_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use rog_platform::platform::{GpuMode, PlatformPolicy};
use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU;
@@ -110,6 +111,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 +136,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],
+1 -2
View File
@@ -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());
})
+15 -16
View File
@@ -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());
})
+2 -2
View File
@@ -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,7 +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::*;
+12 -3
View File
@@ -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>);
+7
View File
@@ -4,6 +4,7 @@ use std::io::Write;
use std::path::PathBuf;
use log::{info, warn};
use udev::Device;
use crate::error::{PlatformError, Result};
@@ -88,4 +89,10 @@ impl HidRaw {
file.write_all(message)
.map_err(|e| PlatformError::IoPath(path.to_string_lossy().to_string(), e))
}
pub fn set_wakeup_disabled(&self) -> Result<()> {
let path = unsafe { &*(self.path.get()) };
let mut dev = Device::from_syspath(path)?;
Ok(dev.set_attribute_value("power/wakeup", "disabled")?)
}
}