Add support for mini_led_mode get/set

- asusd get/set, zbus methods
- Rog control center notification, tray menu, UI entry
This commit is contained in:
Luke D. Jones
2023-06-26 10:44:58 +12:00
parent 03c9f06569
commit acf41c1783
11 changed files with 144 additions and 31 deletions

View File

@@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Builtin animations - Builtin animations
- In-progress simulators for GA402, GU604 animatrix, optional build and takes a single arg - In-progress simulators for GA402, GU604 animatrix, optional build and takes a single arg
- Add `model_override` option to anime config, this is handy for forcing a model for "Unknown" anime, and for simulators - Add `model_override` option to anime config, this is handy for forcing a model for "Unknown" anime, and for simulators
- Add `mini_led_mode` support to asusd and zbus crates (requires kernel patch https://lkml.org/lkml/2023/6/19/1264)
- Add `mini_led_mode` toggle to rog-control-center GUI, tray, notifications
### Changed ### Changed
- Move FX506HC to FX506H in arua DB to catch full series of this range - Move FX506HC to FX506H in arua DB to catch full series of this range
- Move FX506LH to FX506L in arua DB to catch full series of this range - Move FX506LH to FX506L in arua DB to catch full series of this range

View File

@@ -8,6 +8,7 @@ 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,
pub panel_od: bool, pub panel_od: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool, pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String, pub ac_command: String,
pub bat_command: String, pub bat_command: String,
@@ -18,6 +19,7 @@ impl StdConfig for Config {
Config { Config {
bat_charge_limit: 100, bat_charge_limit: 100,
panel_od: false, panel_od: false,
mini_led_mode: false,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
ac_command: String::new(), ac_command: String::new(),
bat_command: String::new(), bat_command: String::new(),
@@ -33,21 +35,24 @@ impl StdConfig for Config {
} }
} }
impl StdConfigLoad2<Config455, Config458> for Config {} impl StdConfigLoad2<Config458, Config462> for Config {}
#[derive(Deserialize, Serialize, Default)] #[derive(Deserialize, Serialize)]
#[serde(default)] pub struct Config462 {
pub struct Config455 {
/// Save charge limit for restoring on boot /// Save charge limit for restoring on boot
pub bat_charge_limit: u8, pub bat_charge_limit: u8,
pub panel_od: bool, pub panel_od: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
} }
impl From<Config455> for Config { impl From<Config462> for Config {
fn from(c: Config455) -> Self { fn from(c: Config462) -> Self {
Self { Self {
bat_charge_limit: c.bat_charge_limit, bat_charge_limit: c.bat_charge_limit,
panel_od: c.panel_od, panel_od: c.panel_od,
mini_led_mode: false,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
ac_command: String::new(), ac_command: String::new(),
bat_command: String::new(), bat_command: String::new(),
@@ -55,7 +60,7 @@ impl From<Config455> for Config {
} }
} }
#[derive(Deserialize, Serialize, Default)] #[derive(Deserialize, Serialize)]
pub struct Config458 { pub struct Config458 {
/// Save charge limit for restoring on boot /// Save charge limit for restoring on boot
pub bat_charge_limit: u8, pub bat_charge_limit: u8,
@@ -69,6 +74,7 @@ impl From<Config458> for Config {
Self { Self {
bat_charge_limit: c.bat_charge_limit, bat_charge_limit: c.bat_charge_limit,
panel_od: c.panel_od, panel_od: c.panel_od,
mini_led_mode: false,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
ac_command: c.ac_command, ac_command: c.ac_command,
bat_command: c.bat_command, bat_command: c.bat_command,

View File

@@ -31,12 +31,14 @@ impl GetSupported for CtrlPlatform {
fn get_supported() -> Self::A { fn get_supported() -> Self::A {
let mut panel_overdrive = false; let mut panel_overdrive = false;
let mut mini_led_mode = false;
let mut dgpu_disable = false; let mut dgpu_disable = false;
let mut egpu_enable = false; let mut egpu_enable = false;
let mut gpu_mux = false; let mut gpu_mux = false;
if let Ok(platform) = AsusPlatform::new() { if let Ok(platform) = AsusPlatform::new() {
panel_overdrive = platform.has_panel_od(); panel_overdrive = platform.has_panel_od();
mini_led_mode = platform.has_mini_led_mode();
dgpu_disable = platform.has_dgpu_disable(); dgpu_disable = platform.has_dgpu_disable();
egpu_enable = platform.has_egpu_enable(); egpu_enable = platform.has_egpu_enable();
gpu_mux = platform.has_gpu_mux_mode(); gpu_mux = platform.has_gpu_mux_mode();
@@ -46,6 +48,7 @@ impl GetSupported for CtrlPlatform {
post_sound: Path::new(ASUS_POST_LOGO_SOUND).exists(), post_sound: Path::new(ASUS_POST_LOGO_SOUND).exists(),
gpu_mux, gpu_mux,
panel_overdrive, panel_overdrive,
mini_led_mode,
dgpu_disable, dgpu_disable,
egpu_enable, egpu_enable,
} }
@@ -214,25 +217,51 @@ impl CtrlPlatform {
/// Get the `panel_od` value from platform. Updates the stored value in /// Get the `panel_od` value from platform. Updates the stored value in
/// internal config also. /// internal config also.
fn panel_od(&self) -> bool { fn panel_od(&self) -> bool {
let od = self self.platform
.platform
.get_panel_od() .get_panel_od()
.map_err(|err| { .map_err(|err| {
warn!("CtrlRogBios: get_panel_od {}", err); warn!("CtrlRogBios: get_panel_od {}", err);
err err
}) })
.unwrap_or(false); .unwrap_or(false)
if let Some(mut lock) = self.config.try_lock() {
lock.panel_od = od;
lock.write();
}
od
} }
#[dbus_interface(signal)] #[dbus_interface(signal)]
async fn notify_panel_od(signal_ctxt: &SignalContext<'_>, overdrive: bool) -> zbus::Result<()> { async fn notify_panel_od(signal_ctxt: &SignalContext<'_>, overdrive: bool) -> zbus::Result<()> {
} }
async fn set_mini_led_mode(
&mut self,
#[zbus(signal_context)] ctxt: SignalContext<'_>,
on: bool,
) {
match self.platform.set_mini_led_mode(on) {
Ok(_) => {
if let Some(mut lock) = self.config.try_lock() {
lock.mini_led_mode = on;
lock.write();
}
Self::notify_mini_led_mode(&ctxt, on).await.ok();
}
Err(err) => warn!("CtrlRogBios: set_mini_led_mode {}", err),
};
}
/// Get the `panel_od` value from platform. Updates the stored value in
/// internal config also.
fn mini_led_mode(&self) -> bool {
self.platform
.get_mini_led_mode()
.map_err(|err| {
warn!("CtrlRogBios: get_mini_led_mode {}", err);
err
})
.unwrap_or(false)
}
#[dbus_interface(signal)]
async fn notify_mini_led_mode(signal_ctxt: &SignalContext<'_>, on: bool) -> zbus::Result<()> {}
async fn set_dgpu_disable( async fn set_dgpu_disable(
&mut self, &mut self,
#[zbus(signal_context)] ctxt: SignalContext<'_>, #[zbus(signal_context)] ctxt: SignalContext<'_>,

View File

@@ -32,6 +32,7 @@ pub struct BiosState {
pub post_sound: bool, pub post_sound: bool,
pub dedicated_gfx: GpuMode, pub dedicated_gfx: GpuMode,
pub panel_overdrive: bool, pub panel_overdrive: bool,
pub mini_led_mode: bool,
pub dgpu_disable: bool, pub dgpu_disable: bool,
pub egpu_enable: bool, pub egpu_enable: bool,
} }
@@ -54,6 +55,11 @@ impl BiosState {
} else { } else {
false false
}, },
mini_led_mode: if supported.rog_bios_ctrl.mini_led_mode {
dbus.proxies().rog_bios().mini_led_mode()?
} else {
false
},
// TODO: needs supergfx // TODO: needs supergfx
dgpu_disable: supported.rog_bios_ctrl.dgpu_disable, dgpu_disable: supported.rog_bios_ctrl.dgpu_disable,
egpu_enable: supported.rog_bios_ctrl.egpu_enable, egpu_enable: supported.rog_bios_ctrl.egpu_enable,
@@ -410,9 +416,7 @@ impl Default for SystemState {
bios: BiosState { bios: BiosState {
post_sound: Default::default(), post_sound: Default::default(),
dedicated_gfx: GpuMode::NotSupported, dedicated_gfx: GpuMode::NotSupported,
panel_overdrive: Default::default(), ..Default::default()
dgpu_disable: Default::default(),
egpu_enable: Default::default(),
}, },
aura: AuraState { aura: AuraState {
current_mode: AuraModeNum::Static, current_mode: AuraModeNum::Static,
@@ -422,22 +426,14 @@ impl Default for SystemState {
x1866: vec![], x1866: vec![],
x19b6: vec![], x19b6: vec![],
}, },
bright: Default::default(), ..Default::default()
wave_red: Default::default(),
wave_green: Default::default(),
wave_blue: Default::default(),
}, },
anime: AnimeState::default(), anime: AnimeState::default(),
profiles: ProfilesState { profiles: ProfilesState {
list: Default::default(), ..Default::default()
current: Default::default(),
}, },
fan_curves: FanCurvesState { fan_curves: FanCurvesState {
show_curve: Default::default(), ..Default::default()
show_graph: Default::default(),
enabled: Default::default(),
curves: Default::default(),
drag_delta: Default::default(),
}, },
gfx_state: GfxState { gfx_state: GfxState {
has_supergfx: false, has_supergfx: false,

View File

@@ -247,6 +247,21 @@ impl ROGTray {
} }
} }
fn menu_add_mini_led_mode(&mut self, supported: &SupportedFunctions, on: bool) {
if supported.rog_bios_ctrl.mini_led_mode {
let bios = self.bios_proxy.clone();
self.add_check_menu_item("MiniLED mode", on, move |this| {
bios.set_mini_led_mode(this.is_active())
.map_err(|e| {
error!("ROGTray: set_mini_led_mode: {e}");
e
})
.ok();
});
debug!("ROGTray: appended miniLED mode menu");
}
}
fn menu_add_supergfx(&mut self, supported_gfx: &[GfxMode], current_mode: GfxMode) { fn menu_add_supergfx(&mut self, supported_gfx: &[GfxMode], current_mode: GfxMode) {
if !self.gfx_proxy_is_active { if !self.gfx_proxy_is_active {
trace!("menu_add_supergfx: gfx_proxy_is_active is false"); trace!("menu_add_supergfx: gfx_proxy_is_active is false");
@@ -386,11 +401,13 @@ impl ROGTray {
current_gfx_mode: GfxMode, current_gfx_mode: GfxMode,
charge_limit: u8, charge_limit: u8,
panel_od: bool, panel_od: bool,
mini_led: bool,
) { ) {
self.menu_clear(); self.menu_clear();
self.menu_add_base(); self.menu_add_base();
self.menu_add_charge_limit(supported, charge_limit); self.menu_add_charge_limit(supported, charge_limit);
self.menu_add_panel_od(supported, panel_od); self.menu_add_panel_od(supported, panel_od);
self.menu_add_mini_led_mode(supported, mini_led);
if self.gfx_proxy_is_active { if self.gfx_proxy_is_active {
// Add a supergfxctl specific menu // Add a supergfxctl specific menu
self.menu_add_supergfx(supported_gfx, current_gfx_mode); self.menu_add_supergfx(supported_gfx, current_gfx_mode);
@@ -453,7 +470,14 @@ pub fn init_tray(
Default::default() Default::default()
}; };
tray.rebuild_and_update(&supported, &supported_gfx, GfxMode::Hybrid, 100, false); tray.rebuild_and_update(
&supported,
&supported_gfx,
GfxMode::Hybrid,
100,
false,
false,
);
tray.set_icon(TRAY_APP_ICON); tray.set_icon(TRAY_APP_ICON);
info!("Started ROGTray"); info!("Started ROGTray");
@@ -475,6 +499,7 @@ pub fn init_tray(
current_gpu_mode, current_gpu_mode,
lock.power_state.charge_limit, lock.power_state.charge_limit,
lock.bios.panel_overdrive, lock.bios.panel_overdrive,
lock.bios.mini_led_mode,
); );
lock.tray_should_update = false; lock.tray_should_update = false;
debug!("ROGTray: rebuilt menus due to state change"); debug!("ROGTray: rebuilt menus due to state change");

View File

@@ -1,6 +1,8 @@
//! `update_and_notify` is responsible for both notifications *and* updating //! `update_and_notify` is responsible for both notifications *and* updating
//! stored statuses about the system state. This is done through either direct, //! stored statuses about the system state. This is done through either direct,
//! intoify, zbus notifications or similar methods. //! intoify, zbus notifications or similar methods.
//!
//! This module very much functions like a stand-alone app on its own thread.
use std::fmt::Display; use std::fmt::Display;
use std::process::Command; use std::process::Command;
@@ -37,6 +39,7 @@ static mut POWER_BAT_CMD: Option<Command> = None;
pub struct EnabledNotifications { pub struct EnabledNotifications {
pub receive_notify_post_boot_sound: bool, pub receive_notify_post_boot_sound: bool,
pub receive_notify_panel_od: bool, pub receive_notify_panel_od: bool,
pub receive_notify_mini_led_mode: bool,
pub receive_notify_dgpu_disable: bool, pub receive_notify_dgpu_disable: bool,
pub receive_notify_egpu_enable: bool, pub receive_notify_egpu_enable: bool,
pub receive_notify_gpu_mux_mode: bool, pub receive_notify_gpu_mux_mode: bool,
@@ -56,6 +59,7 @@ impl Default for EnabledNotifications {
Self { Self {
receive_notify_post_boot_sound: false, receive_notify_post_boot_sound: false,
receive_notify_panel_od: true, receive_notify_panel_od: true,
receive_notify_mini_led_mode: true,
receive_notify_dgpu_disable: true, receive_notify_dgpu_disable: true,
receive_notify_egpu_enable: true, receive_notify_egpu_enable: true,
receive_notify_gpu_mux_mode: true, receive_notify_gpu_mux_mode: true,
@@ -177,6 +181,18 @@ pub fn start_notifications(
do_notification do_notification
); );
recv_notif!(
RogBiosProxy,
receive_notify_mini_led_mode,
last_notification,
enabled_notifications,
page_states,
(bios.mini_led_mode),
(on),
"MiniLED mode enabled:",
do_notification
);
recv_notif!( recv_notif!(
RogBiosProxy, RogBiosProxy,
receive_notify_dgpu_disable, receive_notify_dgpu_disable,

View File

@@ -76,6 +76,12 @@ pub fn app_settings(config: &mut Config, states: &mut SystemState, ui: &mut Ui)
"Enable panel overdrive notification", "Enable panel overdrive notification",
) )
.clicked() .clicked()
|| ui
.checkbox(
&mut enabled_notifications.receive_notify_mini_led_mode,
"Enable MiniLED mode notification",
)
.clicked()
|| ui || ui
.checkbox( .checkbox(
&mut enabled_notifications.receive_notify_post_boot_sound, &mut enabled_notifications.receive_notify_post_boot_sound,

View File

@@ -74,7 +74,7 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
.ok(); .ok();
} }
if supported.rog_bios_ctrl.post_sound if supported.rog_bios_ctrl.panel_overdrive
&& ui && ui
.add(egui::Checkbox::new( .add(egui::Checkbox::new(
&mut states.bios.panel_overdrive, &mut states.bios.panel_overdrive,
@@ -93,6 +93,25 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
.ok(); .ok();
} }
if supported.rog_bios_ctrl.mini_led_mode
&& ui
.add(egui::Checkbox::new(
&mut states.bios.mini_led_mode,
"MiniLED backlight",
))
.changed()
{
states
.asus_dbus
.proxies()
.rog_bios()
.set_mini_led_mode(states.bios.mini_led_mode)
.map_err(|err| {
states.error = Some(err.to_string());
})
.ok();
}
if supported.rog_bios_ctrl.gpu_mux { if supported.rog_bios_ctrl.gpu_mux {
let mut changed = false; let mut changed = false;
let mut dedicated_gfx = states.bios.dedicated_gfx; let mut dedicated_gfx = states.bios.dedicated_gfx;

View File

@@ -40,6 +40,9 @@ trait RogBios {
/// PanelOd method /// PanelOd method
fn panel_od(&self) -> zbus::Result<bool>; fn panel_od(&self) -> zbus::Result<bool>;
/// MiniLedMode method
fn mini_led_mode(&self) -> zbus::Result<bool>;
/// PostBootSound method /// PostBootSound method
fn post_boot_sound(&self) -> zbus::Result<i16>; fn post_boot_sound(&self) -> zbus::Result<i16>;
@@ -55,6 +58,9 @@ trait RogBios {
/// SetPanelOd method /// SetPanelOd method
fn set_panel_od(&self, overdrive: bool) -> zbus::Result<()>; fn set_panel_od(&self, overdrive: bool) -> zbus::Result<()>;
/// SetminiLedMode
fn set_mini_led_mode(&self, on: bool) -> zbus::Result<()>;
/// SetPostBootSound method /// SetPostBootSound method
fn set_post_boot_sound(&self, on: bool) -> zbus::Result<()>; fn set_post_boot_sound(&self, on: bool) -> zbus::Result<()>;
@@ -74,6 +80,10 @@ trait RogBios {
#[dbus_proxy(signal)] #[dbus_proxy(signal)]
fn notify_panel_od(&self, overdrive: bool) -> zbus::Result<()>; fn notify_panel_od(&self, overdrive: bool) -> zbus::Result<()>;
/// NotifyMiniLedMode signal
#[dbus_proxy(signal)]
fn notify_mini_led_mode(&self, on: bool) -> zbus::Result<()>;
/// NotifyPostBootSound signal /// NotifyPostBootSound signal
#[inline] #[inline]
#[dbus_proxy(signal)] #[dbus_proxy(signal)]

View File

@@ -29,6 +29,8 @@ impl AsusPlatform {
attr_bool!("panel_od", path); attr_bool!("panel_od", path);
attr_bool!("mini_led_mode", path);
attr_bool!("gpu_mux_mode", path); attr_bool!("gpu_mux_mode", path);
// This is technically the same as `platform_profile` since both are tied // This is technically the same as `platform_profile` since both are tied

View File

@@ -62,6 +62,7 @@ pub struct RogBiosSupportedFunctions {
pub panel_overdrive: bool, pub panel_overdrive: bool,
pub dgpu_disable: bool, pub dgpu_disable: bool,
pub egpu_enable: bool, pub egpu_enable: bool,
pub mini_led_mode: bool,
} }
impl fmt::Display for SupportedFunctions { impl fmt::Display for SupportedFunctions {
@@ -112,6 +113,7 @@ impl fmt::Display for RogBiosSupportedFunctions {
writeln!(f, "ROG BIOS:")?; writeln!(f, "ROG BIOS:")?;
writeln!(f, "\tPOST sound switch: {}", self.post_sound)?; writeln!(f, "\tPOST sound switch: {}", self.post_sound)?;
writeln!(f, "\tPanel Overdrive: {}", self.panel_overdrive)?; writeln!(f, "\tPanel Overdrive: {}", self.panel_overdrive)?;
writeln!(f, "\tMiniLED backlight: {}", self.mini_led_mode)?;
writeln!(f, "\tdGPU disable switch: {}", self.dgpu_disable)?; writeln!(f, "\tdGPU disable switch: {}", self.dgpu_disable)?;
writeln!(f, "\teGPU enable switch: {}", self.egpu_enable)?; writeln!(f, "\teGPU enable switch: {}", self.egpu_enable)?;
writeln!(f, "\tGPU MUX control: {}", self.gpu_mux)?; writeln!(f, "\tGPU MUX control: {}", self.gpu_mux)?;