mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Merge branch 'fluke/multizone-fixes' into 'main'
Fluke/multizone fixes See merge request asus-linux/asusctl!119
This commit is contained in:
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased ]
|
## [Unreleased ]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add panel overdrive support (autodetects if supported)
|
||||||
|
- Add detection of dgpu_disable and egpu_enable for diagnostic
|
||||||
|
### Changed
|
||||||
|
- Fixed save and restore of multizone LED settings
|
||||||
|
|
||||||
## [4.2.0] - 2022-07-16
|
## [4.2.0] - 2022-07-16
|
||||||
### Added
|
### Added
|
||||||
- Support for GA402 Anime Matrix display (Author: I-Al-Istannen & Luke Jones)
|
- Support for GA402 Anime Matrix display (Author: I-Al-Istannen & Luke Jones)
|
||||||
|
|||||||
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -33,7 +33,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asusctl"
|
name = "asusctl"
|
||||||
version = "4.0.7"
|
version = "4.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"daemon",
|
"daemon",
|
||||||
"gif",
|
"gif",
|
||||||
@@ -278,7 +278,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "daemon"
|
name = "daemon"
|
||||||
version = "4.2.0"
|
version = "4.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
@@ -1034,7 +1034,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_aura"
|
name = "rog_aura"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
@@ -1067,7 +1067,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_supported"
|
name = "rog_supported"
|
||||||
version = "4.0.0"
|
version = "4.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rog_aura",
|
"rog_aura",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asusctl"
|
name = "asusctl"
|
||||||
version = "4.0.7"
|
version = "4.2.1"
|
||||||
authors = ["Luke D Jones <luke@ljones.dev>"]
|
authors = ["Luke D Jones <luke@ljones.dev>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
@@ -67,18 +67,29 @@ pub struct BiosCommand {
|
|||||||
pub help: bool,
|
pub help: bool,
|
||||||
#[options(
|
#[options(
|
||||||
meta = "",
|
meta = "",
|
||||||
|
short = "S",
|
||||||
no_long,
|
no_long,
|
||||||
help = "set bios POST sound: asusctl -p <true/false>"
|
help = "set bios POST sound: asusctl -p <true/false>"
|
||||||
)]
|
)]
|
||||||
pub post_sound_set: Option<bool>,
|
pub post_sound_set: Option<bool>,
|
||||||
#[options(no_long, help = "read bios POST sound")]
|
#[options(no_long, short = "s", help = "read bios POST sound")]
|
||||||
pub post_sound_get: bool,
|
pub post_sound_get: bool,
|
||||||
#[options(
|
#[options(
|
||||||
meta = "",
|
meta = "",
|
||||||
|
short = "D",
|
||||||
no_long,
|
no_long,
|
||||||
help = "activate dGPU dedicated/G-Sync: asusctl -d <true/false>, reboot required"
|
help = "activate dGPU dedicated/G-Sync: asusctl -d <true/false>, reboot required"
|
||||||
)]
|
)]
|
||||||
pub dedicated_gfx_set: Option<bool>,
|
pub dedicated_gfx_set: Option<bool>,
|
||||||
#[options(no_long, help = "get GPU mode")]
|
#[options(no_long, short = "d", help = "get GPU mode")]
|
||||||
pub dedicated_gfx_get: bool,
|
pub dedicated_gfx_get: bool,
|
||||||
|
#[options(
|
||||||
|
meta = "",
|
||||||
|
short = "O",
|
||||||
|
no_long,
|
||||||
|
help = "Set device panel overdrive <true/false>"
|
||||||
|
)]
|
||||||
|
pub panel_overdrive_set: Option<bool>,
|
||||||
|
#[options(no_long, short = "o", help = "get panel overdrive")]
|
||||||
|
pub panel_overdrive_get: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ fn do_parsed(
|
|||||||
if let Some(cmdlist) = CliStart::command_list() {
|
if let Some(cmdlist) = CliStart::command_list() {
|
||||||
println!("{}", cmdlist);
|
println!("{}", cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("\nExtra help can be requested on any command or subcommand:");
|
||||||
|
println!(" asusctl led-mode --help");
|
||||||
|
println!(" asusctl led-mode static --help");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -692,7 +696,9 @@ fn handle_bios_option(
|
|||||||
if (cmd.dedicated_gfx_set.is_none()
|
if (cmd.dedicated_gfx_set.is_none()
|
||||||
&& !cmd.dedicated_gfx_get
|
&& !cmd.dedicated_gfx_get
|
||||||
&& cmd.post_sound_set.is_none()
|
&& cmd.post_sound_set.is_none()
|
||||||
&& !cmd.post_sound_get)
|
&& !cmd.post_sound_get
|
||||||
|
&& cmd.panel_overdrive_set.is_none()
|
||||||
|
&& !cmd.panel_overdrive_get)
|
||||||
|| cmd.help
|
|| cmd.help
|
||||||
{
|
{
|
||||||
println!("Missing arg or command\n");
|
println!("Missing arg or command\n");
|
||||||
@@ -703,8 +709,9 @@ fn handle_bios_option(
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for line in usage.iter().filter(|line| {
|
for line in usage.iter().filter(|line| {
|
||||||
line.contains("sound") && supported.post_sound_toggle
|
line.contains("sound") && supported.post_sound
|
||||||
|| line.contains("GPU") && supported.dedicated_gfx_toggle
|
|| line.contains("GPU") && supported.dedicated_gfx
|
||||||
|
|| line.contains("panel") && supported.panel_overdrive
|
||||||
}) {
|
}) {
|
||||||
println!("{}", line);
|
println!("{}", line);
|
||||||
}
|
}
|
||||||
@@ -717,6 +724,7 @@ fn handle_bios_option(
|
|||||||
let res = dbus.proxies().rog_bios().post_boot_sound()? == 1;
|
let res = dbus.proxies().rog_bios().post_boot_sound()? == 1;
|
||||||
println!("Bios POST sound on: {}", res);
|
println!("Bios POST sound on: {}", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(opt) = cmd.dedicated_gfx_set {
|
if let Some(opt) = cmd.dedicated_gfx_set {
|
||||||
println!("Rebuilding initrd to include drivers");
|
println!("Rebuilding initrd to include drivers");
|
||||||
dbus.proxies().rog_bios().set_dedicated_graphic_mode(opt)?;
|
dbus.proxies().rog_bios().set_dedicated_graphic_mode(opt)?;
|
||||||
@@ -733,6 +741,14 @@ fn handle_bios_option(
|
|||||||
let res = dbus.proxies().rog_bios().dedicated_graphic_mode()? == 1;
|
let res = dbus.proxies().rog_bios().dedicated_graphic_mode()? == 1;
|
||||||
println!("Bios dedicated GPU on: {}", res);
|
println!("Bios dedicated GPU on: {}", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(opt) = cmd.panel_overdrive_set {
|
||||||
|
dbus.proxies().rog_bios().set_panel_overdrive(opt)?;
|
||||||
|
}
|
||||||
|
if cmd.panel_overdrive_get {
|
||||||
|
let res = dbus.proxies().rog_bios().panel_overdrive()? == 1;
|
||||||
|
println!("Panel overdrive on: {}", res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "daemon"
|
name = "daemon"
|
||||||
version = "4.2.0"
|
version = "4.2.1"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["Luke <luke@ljones.dev>"]
|
authors = ["Luke <luke@ljones.dev>"]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
pub static CONFIG_PATH: &str = "/etc/asusd/asusd.conf";
|
pub static CONFIG_PATH: &str = "/etc/asusd/asusd.conf";
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize, Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Save charge limit for restoring on boot
|
/// Save charge limit for restoring on boot
|
||||||
pub bat_charge_limit: u8,
|
pub bat_charge_limit: u8,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ pub struct AuraConfig {
|
|||||||
pub current_mode: AuraModeNum,
|
pub current_mode: AuraModeNum,
|
||||||
pub builtins: BTreeMap<AuraModeNum, AuraEffect>,
|
pub builtins: BTreeMap<AuraModeNum, AuraEffect>,
|
||||||
pub multizone: Option<BTreeMap<AuraModeNum, Vec<AuraEffect>>>,
|
pub multizone: Option<BTreeMap<AuraModeNum, Vec<AuraEffect>>>,
|
||||||
|
pub multizone_on: bool,
|
||||||
pub enabled: HashSet<AuraControl>,
|
pub enabled: HashSet<AuraControl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ impl Default for AuraConfig {
|
|||||||
current_mode: AuraModeNum::Static,
|
current_mode: AuraModeNum::Static,
|
||||||
builtins: BTreeMap::new(),
|
builtins: BTreeMap::new(),
|
||||||
multizone: None,
|
multizone: None,
|
||||||
|
multizone_on: false,
|
||||||
enabled: HashSet::from([
|
enabled: HashSet::from([
|
||||||
AuraControl::BootLogo,
|
AuraControl::BootLogo,
|
||||||
AuraControl::BootKeyb,
|
AuraControl::BootKeyb,
|
||||||
@@ -123,27 +125,35 @@ impl AuraConfig {
|
|||||||
.unwrap_or_else(|err| error!("Could not write config: {}", err));
|
.unwrap_or_else(|err| error!("Could not write config: {}", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Multipurpose, will accept AuraEffect with zones and put in the correct store
|
/// Set the mode data, current mode, and if multizone enabled.
|
||||||
|
///
|
||||||
|
/// Multipurpose, will accept AuraEffect with zones and put in the correct store.
|
||||||
pub fn set_builtin(&mut self, effect: AuraEffect) {
|
pub fn set_builtin(&mut self, effect: AuraEffect) {
|
||||||
|
self.current_mode = effect.mode;
|
||||||
match effect.zone() {
|
match effect.zone() {
|
||||||
AuraZone::None => {
|
AuraZone::None => {
|
||||||
self.builtins.insert(*effect.mode(), effect);
|
self.builtins.insert(*effect.mode(), effect);
|
||||||
|
self.multizone_on = false;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if let Some(multi) = self.multizone.as_mut() {
|
if let Some(multi) = self.multizone.as_mut() {
|
||||||
if let Some(fx) = multi.get_mut(effect.mode()) {
|
if let Some(fx) = multi.get_mut(effect.mode()) {
|
||||||
for fx in fx.iter_mut() {
|
for fx in fx.iter_mut() {
|
||||||
if fx.mode == effect.mode {
|
if fx.zone == effect.zone {
|
||||||
*fx = effect;
|
*fx = effect;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fx.push(effect);
|
||||||
} else {
|
} else {
|
||||||
let mut tmp = BTreeMap::new();
|
multi.insert(*effect.mode(), vec![effect]);
|
||||||
tmp.insert(*effect.mode(), vec![effect]);
|
|
||||||
self.multizone = Some(tmp);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let mut tmp = BTreeMap::new();
|
||||||
|
tmp.insert(*effect.mode(), vec![effect]);
|
||||||
|
self.multizone = Some(tmp);
|
||||||
}
|
}
|
||||||
|
self.multizone_on = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,3 +165,86 @@ impl AuraConfig {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::AuraConfig;
|
||||||
|
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn set_multizone_4key_config() {
|
||||||
|
let mut config = AuraConfig::default();
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.colour1 = Colour(0xff, 0x00, 0xff);
|
||||||
|
effect.zone = AuraZone::Key1;
|
||||||
|
config.set_builtin(effect);
|
||||||
|
|
||||||
|
assert!(config.multizone.is_some());
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.colour1 = Colour(0x00, 0xff, 0xff);
|
||||||
|
effect.zone = AuraZone::Key2;
|
||||||
|
config.set_builtin(effect);
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.colour1 = Colour(0xff, 0xff, 0x00);
|
||||||
|
effect.zone = AuraZone::Key3;
|
||||||
|
config.set_builtin(effect);
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.colour1 = Colour(0x00, 0xff, 0x00);
|
||||||
|
effect.zone = AuraZone::Key4;
|
||||||
|
let effect_clone = effect.clone();
|
||||||
|
config.set_builtin(effect);
|
||||||
|
// This should replace existing
|
||||||
|
config.set_builtin(effect_clone);
|
||||||
|
|
||||||
|
let res = config.multizone.unwrap();
|
||||||
|
let sta = res.get(&AuraModeNum::Static).unwrap();
|
||||||
|
assert_eq!(sta.len(), 4);
|
||||||
|
assert_eq!(sta[0].colour1, Colour(0xff, 0x00, 0xff));
|
||||||
|
assert_eq!(sta[1].colour1, Colour(0x00, 0xff, 0xff));
|
||||||
|
assert_eq!(sta[2].colour1, Colour(0xff, 0xff, 0x00));
|
||||||
|
assert_eq!(sta[3].colour1, Colour(0x00, 0xff, 0x00));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn set_multizone_multimode_config() {
|
||||||
|
let mut config = AuraConfig::default();
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.zone = AuraZone::Key1;
|
||||||
|
config.set_builtin(effect);
|
||||||
|
|
||||||
|
assert!(config.multizone.is_some());
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.zone = AuraZone::Key2;
|
||||||
|
effect.mode = AuraModeNum::Breathe;
|
||||||
|
config.set_builtin(effect);
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.zone = AuraZone::Key3;
|
||||||
|
effect.mode = AuraModeNum::Comet;
|
||||||
|
config.set_builtin(effect);
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.zone = AuraZone::Key4;
|
||||||
|
effect.mode = AuraModeNum::Pulse;
|
||||||
|
config.set_builtin(effect);
|
||||||
|
|
||||||
|
let res = config.multizone.unwrap();
|
||||||
|
let sta = res.get(&AuraModeNum::Static).unwrap();
|
||||||
|
assert_eq!(sta.len(), 1);
|
||||||
|
|
||||||
|
let sta = res.get(&AuraModeNum::Breathe).unwrap();
|
||||||
|
assert_eq!(sta.len(), 1);
|
||||||
|
|
||||||
|
let sta = res.get(&AuraModeNum::Comet).unwrap();
|
||||||
|
assert_eq!(sta.len(), 1);
|
||||||
|
|
||||||
|
let sta = res.get(&AuraModeNum::Pulse).unwrap();
|
||||||
|
assert_eq!(sta.len(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::{
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use logind_zbus::manager::ManagerProxy;
|
use logind_zbus::manager::ManagerProxy;
|
||||||
use rog_aura::usb::AuraControl;
|
use rog_aura::{usb::AuraControl, AuraZone};
|
||||||
use rog_aura::{
|
use rog_aura::{
|
||||||
usb::{LED_APPLY, LED_SET},
|
usb::{LED_APPLY, LED_SET},
|
||||||
AuraEffect, LedBrightness, LED_MSG_LEN,
|
AuraEffect, LedBrightness, LED_MSG_LEN,
|
||||||
@@ -106,11 +106,9 @@ impl CtrlTask for CtrlKbdLedTask {
|
|||||||
lock.set_brightness(lock.config.brightness)
|
lock.set_brightness(lock.config.brightness)
|
||||||
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
|
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
|
||||||
.ok();
|
.ok();
|
||||||
if let Some(mode) = lock.config.builtins.get(&lock.config.current_mode) {
|
lock.write_current_config_mode()
|
||||||
lock.write_mode(mode)
|
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
|
||||||
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
|
.ok();
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
} else if start {
|
} else if start {
|
||||||
info!("CtrlKbdLedTask saving last brightness");
|
info!("CtrlKbdLedTask saving last brightness");
|
||||||
Self::update_config(&mut lock)
|
Self::update_config(&mut lock)
|
||||||
@@ -154,15 +152,6 @@ impl CtrlTask for CtrlKbdLedTask {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
// let inner = self.inner.clone();
|
|
||||||
// self.repeating_task(500, executor, move || loop {
|
|
||||||
// if let Ok(ref mut lock) = inner.try_lock() {
|
|
||||||
// Self::update_config(lock).unwrap();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .await;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,12 +160,8 @@ pub struct CtrlKbdLedReloader(pub Arc<Mutex<CtrlKbdLed>>);
|
|||||||
|
|
||||||
impl crate::Reloadable for CtrlKbdLedReloader {
|
impl crate::Reloadable for CtrlKbdLedReloader {
|
||||||
fn reload(&mut self) -> Result<(), RogError> {
|
fn reload(&mut self) -> Result<(), RogError> {
|
||||||
if let Ok(mut ctrl) = self.0.try_lock() {
|
if let Ok(ctrl) = self.0.try_lock() {
|
||||||
let current = ctrl.config.current_mode;
|
ctrl.write_current_config_mode()?;
|
||||||
if let Some(mode) = ctrl.config.builtins.get(¤t).cloned() {
|
|
||||||
ctrl.do_command(mode).ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ctrl.set_power_states(&ctrl.config)
|
ctrl.set_power_states(&ctrl.config)
|
||||||
.map_err(|err| warn!("{err}"))
|
.map_err(|err| warn!("{err}"))
|
||||||
.ok();
|
.ok();
|
||||||
@@ -211,11 +196,8 @@ impl CtrlKbdLed {
|
|||||||
|
|
||||||
let bright_node = Self::get_kbd_bright_path();
|
let bright_node = Self::get_kbd_bright_path();
|
||||||
|
|
||||||
if led_node.is_none() && bright_node.is_none() {
|
if led_node.is_none() {
|
||||||
return Err(RogError::MissingFunction(
|
return Err(RogError::NoAuraKeyboard);
|
||||||
"All keyboard features missing, you may require a v5.11 series kernel or newer"
|
|
||||||
.into(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if bright_node.is_none() {
|
if bright_node.is_none() {
|
||||||
@@ -301,7 +283,6 @@ impl CtrlKbdLed {
|
|||||||
let set: Vec<AuraControl> = config.enabled.iter().map(|v| *v).collect();
|
let set: Vec<AuraControl> = config.enabled.iter().map(|v| *v).collect();
|
||||||
let bytes = AuraControl::to_bytes(&set);
|
let bytes = AuraControl::to_bytes(&set);
|
||||||
|
|
||||||
// Quite ugly, must be a more idiomatic way to do
|
|
||||||
let message = [
|
let message = [
|
||||||
0x5d, 0xbd, 0x01, bytes[0], bytes[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0x5d, 0xbd, 0x01, bytes[0], bytes[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
];
|
];
|
||||||
@@ -351,8 +332,24 @@ impl CtrlKbdLed {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn do_command(&mut self, mode: AuraEffect) -> Result<(), RogError> {
|
/// Set an Aura effect if the effect mode or zone is supported.
|
||||||
self.set_and_save(mode)
|
///
|
||||||
|
/// On success the aura config file is read to refresh cached values, then the effect is
|
||||||
|
/// stored and config written to disk.
|
||||||
|
pub(crate) fn set_effect(&mut self, effect: AuraEffect) -> Result<(), RogError> {
|
||||||
|
if !self.supported_modes.standard.contains(&effect.mode) {
|
||||||
|
return Err(RogError::AuraEffectNotSupported);
|
||||||
|
} else if effect.zone != AuraZone::None
|
||||||
|
&& !self.supported_modes.multizone.contains(&effect.zone)
|
||||||
|
{
|
||||||
|
return Err(RogError::AuraEffectNotSupported);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.write_mode(&effect)?;
|
||||||
|
self.config.read(); // refresh config if successful
|
||||||
|
self.config.set_builtin(effect);
|
||||||
|
self.config.write();
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Should only be used if the bytes you are writing are verified correct
|
/// Should only be used if the bytes you are writing are verified correct
|
||||||
@@ -366,10 +363,10 @@ impl CtrlKbdLed {
|
|||||||
.map_err(|err| RogError::Write("write_bytes".into(), err));
|
.map_err(|err| RogError::Write("write_bytes".into(), err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(RogError::NotSupported)
|
Err(RogError::NoAuraNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write an effect block
|
/// Write an effect block. This is for per-key
|
||||||
#[inline]
|
#[inline]
|
||||||
fn _write_effect(&mut self, effect: &[Vec<u8>]) -> Result<(), RogError> {
|
fn _write_effect(&mut self, effect: &[Vec<u8>]) -> Result<(), RogError> {
|
||||||
if self.flip_effect_write {
|
if self.flip_effect_write {
|
||||||
@@ -385,19 +382,6 @@ impl CtrlKbdLed {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used to set a builtin mode and save the settings for it
|
|
||||||
///
|
|
||||||
/// This needs to be universal so that settings applied by dbus stick
|
|
||||||
#[inline]
|
|
||||||
fn set_and_save(&mut self, mode: AuraEffect) -> Result<(), RogError> {
|
|
||||||
self.config.read();
|
|
||||||
self.write_mode(&mode)?;
|
|
||||||
self.config.current_mode = *mode.mode();
|
|
||||||
self.config.set_builtin(mode);
|
|
||||||
self.config.write();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn toggle_mode(&mut self, reverse: bool) -> Result<(), RogError> {
|
pub(super) fn toggle_mode(&mut self, reverse: bool) -> Result<(), RogError> {
|
||||||
let current = self.config.current_mode;
|
let current = self.config.current_mode;
|
||||||
@@ -424,9 +408,9 @@ impl CtrlKbdLed {
|
|||||||
let next = self.supported_modes.standard[idx];
|
let next = self.supported_modes.standard[idx];
|
||||||
|
|
||||||
self.config.read();
|
self.config.read();
|
||||||
if let Some(data) = self.config.builtins.get(&next) {
|
if self.config.builtins.contains_key(&next) {
|
||||||
self.write_mode(data)?;
|
|
||||||
self.config.current_mode = next;
|
self.config.current_mode = next;
|
||||||
|
self.write_current_config_mode()?;
|
||||||
}
|
}
|
||||||
self.config.write();
|
self.config.write();
|
||||||
}
|
}
|
||||||
@@ -436,9 +420,6 @@ impl CtrlKbdLed {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_mode(&self, mode: &AuraEffect) -> Result<(), RogError> {
|
fn write_mode(&self, mode: &AuraEffect) -> Result<(), RogError> {
|
||||||
if !self.supported_modes.standard.contains(mode.mode()) {
|
|
||||||
return Err(RogError::NotSupported);
|
|
||||||
}
|
|
||||||
let bytes: [u8; LED_MSG_LEN] = mode.into();
|
let bytes: [u8; LED_MSG_LEN] = mode.into();
|
||||||
self.write_bytes(&bytes)?;
|
self.write_bytes(&bytes)?;
|
||||||
self.write_bytes(&LED_SET)?;
|
self.write_bytes(&LED_SET)?;
|
||||||
@@ -446,4 +427,96 @@ impl CtrlKbdLed {
|
|||||||
self.write_bytes(&LED_APPLY)?;
|
self.write_bytes(&LED_APPLY)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn write_current_config_mode(&self) -> Result<(), RogError> {
|
||||||
|
if self.config.multizone_on {
|
||||||
|
let mode = self.config.current_mode;
|
||||||
|
if let Some(multizones) = self.config.multizone.as_ref() {
|
||||||
|
if let Some(set) = multizones.get(&mode) {
|
||||||
|
for mode in set {
|
||||||
|
self.write_mode(mode)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let mode = self.config.current_mode;
|
||||||
|
if let Some(effect) = self.config.builtins.get(&mode) {
|
||||||
|
self.write_mode(effect)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour};
|
||||||
|
|
||||||
|
use crate::{ctrl_aura::config::AuraConfig, laptops::LaptopLedData};
|
||||||
|
|
||||||
|
use super::CtrlKbdLed;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
// #[ignore = "Must be manually run due to detection stage"]
|
||||||
|
fn check_set_mode_errors() {
|
||||||
|
// Checking to ensure set_mode errors when unsupported modes are tried
|
||||||
|
let config = AuraConfig::default();
|
||||||
|
let supported_modes = LaptopLedData {
|
||||||
|
prod_family: "".into(),
|
||||||
|
board_names: vec![],
|
||||||
|
standard: vec![AuraModeNum::Static],
|
||||||
|
multizone: vec![],
|
||||||
|
per_key: false,
|
||||||
|
};
|
||||||
|
let mut controller = CtrlKbdLed {
|
||||||
|
led_node: None,
|
||||||
|
bright_node: String::new(),
|
||||||
|
supported_modes,
|
||||||
|
flip_effect_write: false,
|
||||||
|
config,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut effect = AuraEffect::default();
|
||||||
|
effect.colour1 = Colour(0xff, 0x00, 0xff);
|
||||||
|
effect.zone = AuraZone::None;
|
||||||
|
|
||||||
|
// This error comes from write_bytes because we don't have a keyboard node stored
|
||||||
|
assert_eq!(
|
||||||
|
controller
|
||||||
|
.set_effect(effect.clone())
|
||||||
|
.unwrap_err()
|
||||||
|
.to_string(),
|
||||||
|
"No Aura keyboard node found"
|
||||||
|
);
|
||||||
|
|
||||||
|
effect.mode = AuraModeNum::Laser;
|
||||||
|
assert_eq!(
|
||||||
|
controller
|
||||||
|
.set_effect(effect.clone())
|
||||||
|
.unwrap_err()
|
||||||
|
.to_string(),
|
||||||
|
"Aura effect not supported"
|
||||||
|
);
|
||||||
|
|
||||||
|
effect.mode = AuraModeNum::Static;
|
||||||
|
effect.zone = AuraZone::Key2;
|
||||||
|
assert_eq!(
|
||||||
|
controller
|
||||||
|
.set_effect(effect.clone())
|
||||||
|
.unwrap_err()
|
||||||
|
.to_string(),
|
||||||
|
"Aura effect not supported"
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.supported_modes.multizone.push(AuraZone::Key2);
|
||||||
|
assert_eq!(
|
||||||
|
controller
|
||||||
|
.set_effect(effect.clone())
|
||||||
|
.unwrap_err()
|
||||||
|
.to_string(),
|
||||||
|
"No Aura keyboard node found"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ impl CtrlKbdLedZbus {
|
|||||||
&mut self,
|
&mut self,
|
||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
enabled: Vec<AuraControl>,
|
enabled: Vec<AuraControl>,
|
||||||
) {
|
) -> zbus::fdo::Result<()> {
|
||||||
let mut states = None;
|
let mut states = None;
|
||||||
if let Ok(mut ctrl) = self.0.try_lock() {
|
if let Ok(mut ctrl) = self.0.try_lock() {
|
||||||
for s in enabled {
|
for s in enabled {
|
||||||
@@ -54,9 +54,10 @@ impl CtrlKbdLedZbus {
|
|||||||
}
|
}
|
||||||
ctrl.config.write();
|
ctrl.config.write();
|
||||||
|
|
||||||
ctrl.set_power_states(&ctrl.config)
|
ctrl.set_power_states(&ctrl.config).map_err(|e| {
|
||||||
.map_err(|err| warn!("{}", err))
|
warn!("{}", e);
|
||||||
.ok();
|
e
|
||||||
|
})?;
|
||||||
|
|
||||||
let set: Vec<AuraControl> = ctrl.config.enabled.iter().map(|v| *v).collect();
|
let set: Vec<AuraControl> = ctrl.config.enabled.iter().map(|v| *v).collect();
|
||||||
states = Some(set);
|
states = Some(set);
|
||||||
@@ -67,13 +68,14 @@ impl CtrlKbdLedZbus {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
.unwrap_or_else(|err| warn!("{}", err));
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn set_leds_disabled(
|
async fn set_leds_disabled(
|
||||||
&mut self,
|
&mut self,
|
||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
disabled: Vec<AuraControl>,
|
disabled: Vec<AuraControl>,
|
||||||
) {
|
) -> zbus::fdo::Result<()> {
|
||||||
let mut states = None;
|
let mut states = None;
|
||||||
if let Ok(mut ctrl) = self.0.try_lock() {
|
if let Ok(mut ctrl) = self.0.try_lock() {
|
||||||
for s in disabled {
|
for s in disabled {
|
||||||
@@ -81,9 +83,10 @@ impl CtrlKbdLedZbus {
|
|||||||
}
|
}
|
||||||
ctrl.config.write();
|
ctrl.config.write();
|
||||||
|
|
||||||
ctrl.set_power_states(&ctrl.config)
|
ctrl.set_power_states(&ctrl.config).map_err(|e| {
|
||||||
.map_err(|err| warn!("{}", err))
|
warn!("{}", e);
|
||||||
.ok();
|
e
|
||||||
|
})?;
|
||||||
|
|
||||||
let set: Vec<AuraControl> = ctrl.config.enabled.iter().map(|v| *v).collect();
|
let set: Vec<AuraControl> = ctrl.config.enabled.iter().map(|v| *v).collect();
|
||||||
states = Some(set);
|
states = Some(set);
|
||||||
@@ -94,24 +97,22 @@ impl CtrlKbdLedZbus {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
.unwrap_or_else(|err| warn!("{}", err));
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn set_led_mode(
|
async fn set_led_mode(
|
||||||
&mut self,
|
&mut self,
|
||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
effect: AuraEffect,
|
effect: AuraEffect,
|
||||||
) {
|
) -> zbus::fdo::Result<()> {
|
||||||
let mut led = None;
|
let mut led = None;
|
||||||
if let Ok(mut ctrl) = self.0.try_lock() {
|
if let Ok(mut ctrl) = self.0.try_lock() {
|
||||||
match ctrl.do_command(effect) {
|
ctrl.set_effect(effect).map_err(|e| {
|
||||||
Ok(_) => {
|
warn!("{}", e);
|
||||||
if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) {
|
e
|
||||||
led = Some(mode.clone());
|
})?;
|
||||||
}
|
if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) {
|
||||||
}
|
led = Some(mode.clone());
|
||||||
Err(err) => {
|
|
||||||
warn!("{}", err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(led) = led {
|
if let Some(led) = led {
|
||||||
@@ -119,13 +120,19 @@ impl CtrlKbdLedZbus {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
.unwrap_or_else(|err| warn!("{}", err));
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn next_led_mode(&self, #[zbus(signal_context)] ctxt: SignalContext<'_>) {
|
async fn next_led_mode(
|
||||||
|
&self,
|
||||||
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
|
) -> zbus::fdo::Result<()> {
|
||||||
let mut led = None;
|
let mut led = None;
|
||||||
if let Ok(mut ctrl) = self.0.lock() {
|
if let Ok(mut ctrl) = self.0.lock() {
|
||||||
ctrl.toggle_mode(false)
|
ctrl.toggle_mode(false).map_err(|e| {
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
warn!("{}", e);
|
||||||
|
e
|
||||||
|
})?;
|
||||||
|
|
||||||
if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) {
|
if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) {
|
||||||
led = Some(mode.clone());
|
led = Some(mode.clone());
|
||||||
@@ -136,13 +143,19 @@ impl CtrlKbdLedZbus {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
.unwrap_or_else(|err| warn!("{}", err));
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn prev_led_mode(&self, #[zbus(signal_context)] ctxt: SignalContext<'_>) {
|
async fn prev_led_mode(
|
||||||
|
&self,
|
||||||
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
|
) -> zbus::fdo::Result<()> {
|
||||||
let mut led = None;
|
let mut led = None;
|
||||||
if let Ok(mut ctrl) = self.0.lock() {
|
if let Ok(mut ctrl) = self.0.lock() {
|
||||||
ctrl.toggle_mode(true)
|
ctrl.toggle_mode(true).map_err(|e| {
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
warn!("{}", e);
|
||||||
|
e
|
||||||
|
})?;
|
||||||
|
|
||||||
if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) {
|
if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) {
|
||||||
led = Some(mode.clone());
|
led = Some(mode.clone());
|
||||||
@@ -153,20 +166,27 @@ impl CtrlKbdLedZbus {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
.unwrap_or_else(|err| warn!("{}", err));
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn next_led_brightness(&self) {
|
async fn next_led_brightness(&self) -> zbus::fdo::Result<()> {
|
||||||
if let Ok(mut ctrl) = self.0.try_lock() {
|
if let Ok(mut ctrl) = self.0.try_lock() {
|
||||||
ctrl.next_brightness()
|
ctrl.next_brightness().map_err(|e| {
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
warn!("{}", e);
|
||||||
|
e
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn prev_led_brightness(&self) {
|
async fn prev_led_brightness(&self) -> zbus::fdo::Result<()> {
|
||||||
if let Ok(mut ctrl) = self.0.try_lock() {
|
if let Ok(mut ctrl) = self.0.try_lock() {
|
||||||
ctrl.prev_brightness()
|
ctrl.prev_brightness().map_err(|e| {
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
warn!("{}", e);
|
||||||
|
e
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dbus_interface(property)]
|
#[dbus_interface(property)]
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ static ASUS_SWITCH_GRAPHIC_MODE: &str =
|
|||||||
"/sys/firmware/efi/efivars/AsusSwitchGraphicMode-607005d5-3f75-4b2e-98f0-85ba66797a3e";
|
"/sys/firmware/efi/efivars/AsusSwitchGraphicMode-607005d5-3f75-4b2e-98f0-85ba66797a3e";
|
||||||
static ASUS_POST_LOGO_SOUND: &str =
|
static ASUS_POST_LOGO_SOUND: &str =
|
||||||
"/sys/firmware/efi/efivars/AsusPostLogoSound-607005d5-3f75-4b2e-98f0-85ba66797a3e";
|
"/sys/firmware/efi/efivars/AsusPostLogoSound-607005d5-3f75-4b2e-98f0-85ba66797a3e";
|
||||||
|
static ASUS_PANEL_OD_PATH: &str = "/sys/devices/platform/asus-nb-wmi/panel_od";
|
||||||
|
static ASUS_DGPU_DISABLE_PATH: &str = "/sys/devices/platform/asus-nb-wmi/dgpu_disable";
|
||||||
|
static ASUS_EGPU_ENABLE_PATH: &str = "/sys/devices/platform/asus-nb-wmi/egpu_enable";
|
||||||
|
|
||||||
pub struct CtrlRogBios {
|
pub struct CtrlRogBios {
|
||||||
_config: Arc<Mutex<Config>>,
|
_config: Arc<Mutex<Config>>,
|
||||||
@@ -29,8 +32,11 @@ impl GetSupported for CtrlRogBios {
|
|||||||
|
|
||||||
fn get_supported() -> Self::A {
|
fn get_supported() -> Self::A {
|
||||||
RogBiosSupportedFunctions {
|
RogBiosSupportedFunctions {
|
||||||
post_sound_toggle: Path::new(ASUS_POST_LOGO_SOUND).exists(),
|
post_sound: Path::new(ASUS_POST_LOGO_SOUND).exists(),
|
||||||
dedicated_gfx_toggle: Path::new(ASUS_SWITCH_GRAPHIC_MODE).exists(),
|
dedicated_gfx: Path::new(ASUS_SWITCH_GRAPHIC_MODE).exists(),
|
||||||
|
panel_overdrive: Path::new(ASUS_PANEL_OD_PATH).exists(),
|
||||||
|
dgpu_disable: Path::new(ASUS_DGPU_DISABLE_PATH).exists(),
|
||||||
|
egpu_enable: Path::new(ASUS_EGPU_ENABLE_PATH).exists(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,6 +100,52 @@ impl CtrlRogBios {
|
|||||||
|
|
||||||
#[dbus_interface(signal)]
|
#[dbus_interface(signal)]
|
||||||
async fn notify_post_boot_sound(ctxt: &SignalContext<'_>, on: bool) -> zbus::Result<()> {}
|
async fn notify_post_boot_sound(ctxt: &SignalContext<'_>, on: bool) -> zbus::Result<()> {}
|
||||||
|
|
||||||
|
async fn set_panel_overdrive(
|
||||||
|
&mut self,
|
||||||
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
|
overdrive: bool,
|
||||||
|
) {
|
||||||
|
if self
|
||||||
|
.set_panel_od(overdrive)
|
||||||
|
.map_err(|err| {
|
||||||
|
warn!("CtrlRogBios: set_panel_overdrive {}", err);
|
||||||
|
err
|
||||||
|
})
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
|
Self::notify_panel_overdrive(&ctxt, overdrive).await.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn panel_overdrive(&self) -> i8 {
|
||||||
|
let path = ASUS_PANEL_OD_PATH;
|
||||||
|
if let Ok(mut file) = OpenOptions::new().read(true).open(path).map_err(|err| {
|
||||||
|
warn!("CtrlRogBios: panel_overdrive {}", err);
|
||||||
|
err
|
||||||
|
}) {
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
file.read_to_end(&mut buf)
|
||||||
|
.map_err(|err| {
|
||||||
|
warn!("CtrlRogBios: set_panel_overdrive {}", err);
|
||||||
|
err
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
|
||||||
|
if buf.len() >= 1 {
|
||||||
|
let tmp = String::from_utf8_lossy(&buf[0..1]);
|
||||||
|
return tmp.parse::<i8>().unwrap_or(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
|
||||||
|
#[dbus_interface(signal)]
|
||||||
|
async fn notify_panel_overdrive(
|
||||||
|
signal_ctxt: &SignalContext<'_>,
|
||||||
|
overdrive: bool,
|
||||||
|
) -> zbus::Result<()> {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@@ -305,4 +357,43 @@ impl CtrlRogBios {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_panel_od(&mut self, overdrive: bool) -> Result<(), RogError> {
|
||||||
|
let path = ASUS_PANEL_OD_PATH;
|
||||||
|
let mut file = OpenOptions::new().write(true).open(path).map_err(|err| {
|
||||||
|
warn!("CtrlRogBios: set_panel_overdrive {}", err);
|
||||||
|
err
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let s = if overdrive { '1' } else { '0' };
|
||||||
|
file.write(&[s as u8]).map_err(|err| {
|
||||||
|
warn!("CtrlRogBios: set_panel_overdrive {}", err);
|
||||||
|
err
|
||||||
|
})?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::CtrlRogBios;
|
||||||
|
use crate::config::Config;
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore = "Must be manually tested"]
|
||||||
|
fn set_multizone_4key_config() {
|
||||||
|
let config = Config::default();
|
||||||
|
|
||||||
|
let controller = CtrlRogBios {
|
||||||
|
_config: Arc::new(Mutex::new(config)),
|
||||||
|
};
|
||||||
|
|
||||||
|
let res = controller.panel_overdrive();
|
||||||
|
assert_eq!(res, 1);
|
||||||
|
|
||||||
|
// controller.set_panel_od(false).unwrap();
|
||||||
|
// let res = controller.panel_overdrive();
|
||||||
|
// assert_eq!(res, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ pub enum RogError {
|
|||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
Zbus(zbus::Error),
|
Zbus(zbus::Error),
|
||||||
ChargeLimit(u8),
|
ChargeLimit(u8),
|
||||||
|
AuraEffectNotSupported,
|
||||||
|
NoAuraKeyboard,
|
||||||
|
NoAuraNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for RogError {
|
impl fmt::Display for RogError {
|
||||||
@@ -48,6 +51,9 @@ impl fmt::Display for RogError {
|
|||||||
RogError::Io(detail) => write!(f, "std::io error: {}", detail),
|
RogError::Io(detail) => write!(f, "std::io error: {}", detail),
|
||||||
RogError::Zbus(detail) => write!(f, "Zbus error: {}", detail),
|
RogError::Zbus(detail) => write!(f, "Zbus error: {}", detail),
|
||||||
RogError::ChargeLimit(value) => write!(f, "Invalid charging limit, not in range 20-100%: {}", value),
|
RogError::ChargeLimit(value) => write!(f, "Invalid charging limit, not in range 20-100%: {}", value),
|
||||||
|
RogError::AuraEffectNotSupported => write!(f, "Aura effect not supported"),
|
||||||
|
RogError::NoAuraKeyboard => write!(f, "No supported Aura keyboard"),
|
||||||
|
RogError::NoAuraNode => write!(f, "No Aura keyboard node found"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -731,7 +731,7 @@ mod tests {
|
|||||||
vec![Pixel::default(); 1000],
|
vec![Pixel::default(); 1000],
|
||||||
100,
|
100,
|
||||||
AnimeType::GA402,
|
AnimeType::GA402,
|
||||||
);
|
).unwrap();
|
||||||
matrix._edge_outline();
|
matrix._edge_outline();
|
||||||
let data = AnimeDataBuffer::from(&matrix);
|
let data = AnimeDataBuffer::from(&matrix);
|
||||||
let pkt = AnimePacketType::from(data);
|
let pkt = AnimePacketType::from(data);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rog_aura"
|
name = "rog_aura"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["Luke <luke@ljones.dev>"]
|
authors = ["Luke <luke@ljones.dev>"]
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub const fn aura_brightness_bytes(brightness: u8) -> [u8; 17] {
|
|||||||
/// booting.
|
/// booting.
|
||||||
///
|
///
|
||||||
/// # Bits for 0x19b6 keyboard model
|
/// # Bits for 0x19b6 keyboard model
|
||||||
///
|
///
|
||||||
/// ```text
|
/// ```text
|
||||||
/// byte 4 in the USB packet is for keyboard + logo power states
|
/// byte 4 in the USB packet is for keyboard + logo power states
|
||||||
/// default is on, `ff`
|
/// default is on, `ff`
|
||||||
@@ -51,7 +51,7 @@ pub const fn aura_brightness_bytes(brightness: u8) -> [u8; 17] {
|
|||||||
/// | 0001 | 0000 | 10 | lightbar shtdn off | bit 5 |
|
/// | 0001 | 0000 | 10 | lightbar shtdn off | bit 5 |
|
||||||
///
|
///
|
||||||
/// # Bits for older 0x1866 keyboard model
|
/// # Bits for older 0x1866 keyboard model
|
||||||
///
|
///
|
||||||
/// Keybord and Light zone require Awake
|
/// Keybord and Light zone require Awake
|
||||||
/// | byte 1 | byte 2 | byte 3 | | |
|
/// | byte 1 | byte 2 | byte 3 | | |
|
||||||
/// | 1 | 2 | 3 | 4 | 5 | 6 | function | hex |
|
/// | 1 | 2 | 3 | 4 | 5 | 6 | function | hex |
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ trait RogBios {
|
|||||||
/// SetPostBootSound method
|
/// SetPostBootSound method
|
||||||
fn set_post_boot_sound(&self, on: bool) -> zbus::Result<()>;
|
fn set_post_boot_sound(&self, on: bool) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// PanelOverdrive method
|
||||||
|
fn panel_overdrive(&self) -> zbus::Result<i8>;
|
||||||
|
|
||||||
|
/// SetPanelOverdrive method
|
||||||
|
fn set_panel_overdrive(&self, overdrive: bool) -> zbus::Result<()>;
|
||||||
|
|
||||||
/// NotifyDedicatedGraphicMode signal
|
/// NotifyDedicatedGraphicMode signal
|
||||||
#[dbus_proxy(signal)]
|
#[dbus_proxy(signal)]
|
||||||
fn notify_dedicated_graphic_mode(&self, dedicated: bool) -> zbus::Result<()>;
|
fn notify_dedicated_graphic_mode(&self, dedicated: bool) -> zbus::Result<()>;
|
||||||
@@ -45,4 +51,8 @@ trait RogBios {
|
|||||||
/// NotifyPostBootSound signal
|
/// NotifyPostBootSound signal
|
||||||
#[dbus_proxy(signal)]
|
#[dbus_proxy(signal)]
|
||||||
fn notify_post_boot_sound(&self, sound: bool) -> zbus::Result<()>;
|
fn notify_post_boot_sound(&self, sound: bool) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// NotifyPanelOverdrive signal
|
||||||
|
#[dbus_proxy(signal)]
|
||||||
|
fn notify_panel_overdrive(&self, overdrive: bool) -> zbus::Result<()>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rog_supported"
|
name = "rog_supported"
|
||||||
version = "4.0.0"
|
version = "4.2.0"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["Luke <luke@ljones.dev>"]
|
authors = ["Luke <luke@ljones.dev>"]
|
||||||
|
|||||||
@@ -38,8 +38,11 @@ pub struct LedSupportedFunctions {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Type, Debug)]
|
#[derive(Serialize, Deserialize, Type, Debug)]
|
||||||
pub struct RogBiosSupportedFunctions {
|
pub struct RogBiosSupportedFunctions {
|
||||||
pub post_sound_toggle: bool,
|
pub post_sound: bool,
|
||||||
pub dedicated_gfx_toggle: bool,
|
pub dedicated_gfx: bool,
|
||||||
|
pub panel_overdrive: bool,
|
||||||
|
pub dgpu_disable: bool,
|
||||||
|
pub egpu_enable: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for SupportedFunctions {
|
impl fmt::Display for SupportedFunctions {
|
||||||
@@ -87,7 +90,11 @@ impl fmt::Display for LedSupportedFunctions {
|
|||||||
impl fmt::Display for RogBiosSupportedFunctions {
|
impl fmt::Display for RogBiosSupportedFunctions {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
writeln!(f, "ROG BIOS:")?;
|
writeln!(f, "ROG BIOS:")?;
|
||||||
writeln!(f, "\tPOST sound toggle: {}", self.post_sound_toggle)?;
|
writeln!(f, "\tPOST sound switch: {}", self.post_sound)?;
|
||||||
writeln!(f, "\tDedicated GFX toggle: {}", self.dedicated_gfx_toggle)
|
writeln!(f, "\tPanel Overdrive: {}", self.panel_overdrive)?;
|
||||||
|
writeln!(f, "\tdGPU disable switch: {}", self.dgpu_disable)?;
|
||||||
|
writeln!(f, "\teGPU enable switch: {}", self.egpu_enable)?;
|
||||||
|
writeln!(f, "\tDedicated GFX switch: {}", self.dedicated_gfx)?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user