From e371229b6c71eacd483f3ea14d41993fbfaed8ae Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 10 Mar 2024 20:53:03 +1300 Subject: [PATCH] Update support for boot_sound kernel patch --- asusctl/src/main.rs | 4 +- asusd/src/config.rs | 4 ++ asusd/src/ctrl_platform.rs | 48 +++++++++---------- rog-control-center/src/system_state.rs | 2 +- rog-control-center/src/ui_setup.rs | 10 ++++ rog-control-center/src/update_and_notify.rs | 6 +-- .../translations/en/rog-control-center.po | 2 +- rog-control-center/ui/pages/aura.slint | 12 ++--- rog-control-center/ui/pages/system.slint | 12 +++++ rog-dbus/src/zbus_platform.rs | 4 +- rog-platform/src/platform.rs | 2 +- 11 files changed, 64 insertions(+), 42 deletions(-) diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 5fc58cb6..7f406071 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -813,10 +813,10 @@ fn handle_platform_properties( } if let Some(opt) = cmd.post_sound_set { - dbus.proxies().platform().set_post_animation_sound(opt)?; + dbus.proxies().platform().set_boot_sound(opt)?; } if cmd.post_sound_get { - let res = dbus.proxies().platform().post_animation_sound()?; + let res = dbus.proxies().platform().boot_sound()?; println!("Bios POST sound on: {}", res); } diff --git a/asusd/src/config.rs b/asusd/src/config.rs index 6bab0a75..f3a2ea95 100644 --- a/asusd/src/config.rs +++ b/asusd/src/config.rs @@ -10,6 +10,7 @@ pub struct Config { /// Save charge limit for restoring on boot/resume pub charge_control_end_threshold: u8, pub panel_od: bool, + pub boot_sound: bool, pub mini_led_mode: bool, pub disable_nvidia_powerd_on_battery: bool, /// An optional command/script to run when power is changed to AC @@ -53,6 +54,7 @@ impl Default for Config { Self { charge_control_end_threshold: 100, panel_od: false, + boot_sound: false, mini_led_mode: false, disable_nvidia_powerd_on_battery: true, ac_command: Default::default(), @@ -126,6 +128,7 @@ impl From for Config { Self { charge_control_end_threshold: c.charge_control_end_threshold, panel_od: c.panel_od, + boot_sound: false, disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery, ac_command: c.ac_command, bat_command: c.bat_command, @@ -177,6 +180,7 @@ impl From for Config { Self { charge_control_end_threshold: c.charge_control_end_threshold, panel_od: c.panel_od, + boot_sound: false, disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery, ac_command: c.ac_command, bat_command: c.bat_command, diff --git a/asusd/src/ctrl_platform.rs b/asusd/src/ctrl_platform.rs index 4e98afb5..0d8cba8a 100644 --- a/asusd/src/ctrl_platform.rs +++ b/asusd/src/ctrl_platform.rs @@ -319,7 +319,7 @@ impl CtrlPlatform { platform_name!(dgpu_disable, Properties::DgpuDisable); platform_name!(gpu_mux_mode, Properties::GpuMuxMode); - platform_name!(post_animation_sound, Properties::PostAnimationSound); + platform_name!(boot_sound, Properties::PostAnimationSound); platform_name!(panel_od, Properties::PanelOd); platform_name!(mini_led_mode, Properties::MiniLedMode); platform_name!(egpu_enable, Properties::EgpuEnable); @@ -558,29 +558,6 @@ impl CtrlPlatform { Ok(()) } - /// *********************************************************************** - - #[zbus(property)] - fn post_animation_sound(&self) -> Result { - platform_get_value!(self, post_animation_sound, "post_animation_sound") - } - - #[zbus(property)] - async fn set_post_animation_sound(&mut self, on: bool) -> Result<(), FdoErr> { - if self.platform.has_post_animation_sound() { - self.platform.set_post_animation_sound(on).map_err(|err| { - warn!("RogPlatform: set_post_animation_sound {}", err); - FdoErr::Failed(format!("RogPlatform: set_post_animation_sound: {err}")) - })?; - self.config.lock().await.write(); - } else { - return Err(FdoErr::NotSupported( - "RogPlatform: set_post_animation_sound not supported".to_owned(), - )); - } - Ok(()) - } - /// Get the `panel_od` value from platform. Updates the stored value in /// internal config also. #[zbus(property)] @@ -595,6 +572,20 @@ impl CtrlPlatform { Ok(()) } + /// Get the `boot_sound` value from platform. Updates the stored value in + /// internal config also. + #[zbus(property)] + fn boot_sound(&self) -> Result { + platform_get_value!(self, boot_sound, "boot_sound") + } + + #[zbus(property)] + async fn set_boot_sound(&mut self, on: bool) -> Result<(), FdoErr> { + platform_set_bool!(self, boot_sound, "boot_sound", on)?; + self.config.lock().await.write(); + Ok(()) + } + /// Get the `panel_od` value from platform. Updates the stored value in /// internal config also. #[zbus(property)] @@ -751,6 +742,11 @@ impl ReloadAndNotify for CtrlPlatform { self.panel_od_changed(signal_context).await?; } + if self.platform.has_boot_sound() && config.panel_od != data.panel_od { + self.platform.set_boot_sound(data.panel_od)?; + self.boot_sound_changed(signal_context).await?; + } + if self.platform.has_mini_led_mode() && config.mini_led_mode != data.mini_led_mode { self.platform.set_mini_led_mode(data.mini_led_mode)?; self.mini_led_mode_changed(signal_context).await?; @@ -829,7 +825,7 @@ impl CtrlPlatform { task_watch_item!(charge_control_end_threshold power); - task_watch_item_notify!(post_animation_sound platform); + task_watch_item_notify!(boot_sound platform); task_watch_item_notify!(dgpu_disable platform); @@ -957,7 +953,7 @@ impl CtrlTask for CtrlPlatform { // NOTE: Can't have this as a watch because on a write to it, it reverts back to // booted-with value as it does not actually change until reboot. self.watch_gpu_mux_mode(signal_ctxt.clone()).await?; - self.watch_post_animation_sound(signal_ctxt.clone()).await?; + self.watch_boot_sound(signal_ctxt.clone()).await?; self.watch_ppt_pl1_spl(signal_ctxt.clone()).await?; self.watch_ppt_pl2_sppt(signal_ctxt.clone()).await?; diff --git a/rog-control-center/src/system_state.rs b/rog-control-center/src/system_state.rs index 079dbcc6..cab71e85 100644 --- a/rog-control-center/src/system_state.rs +++ b/rog-control-center/src/system_state.rs @@ -40,7 +40,7 @@ pub struct PlatformState { impl PlatformState { pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result { Ok(Self { - post_sound: dbus.proxies().platform().post_animation_sound().ok(), + post_sound: dbus.proxies().platform().boot_sound().ok(), gpu_mux_mode: dbus .proxies() .platform() diff --git a/rog-control-center/src/ui_setup.rs b/rog-control-center/src/ui_setup.rs index 6cadff69..89e7a274 100644 --- a/rog-control-center/src/ui_setup.rs +++ b/rog-control-center/src/ui_setup.rs @@ -415,6 +415,7 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc>) { nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost), nv_temp_target: sys_props.contains(&Properties::NvTempTarget), panel_od: sys_props.contains(&Properties::PanelOd), + boot_sound: sys_props.contains(&Properties::PostAnimationSound), ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt), ppt_fppt: sys_props.contains(&Properties::PptFppt), ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl), @@ -452,6 +453,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc>) set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_ac); set_ui_props_async!(handle, platform, SystemPageData, panel_od); + set_ui_props_async!(handle, platform, SystemPageData, boot_sound); set_ui_props_async!(handle, platform, SystemPageData, mini_led_mode); set_ui_props_async!(handle, platform, SystemPageData, ppt_pl1_spl); set_ui_props_async!(handle, platform, SystemPageData, ppt_pl2_sppt); @@ -473,6 +475,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc>) nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost), nv_temp_target: sys_props.contains(&Properties::NvTempTarget), panel_od: sys_props.contains(&Properties::PanelOd), + boot_sound: sys_props.contains(&Properties::PostAnimationSound), ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt), ppt_fppt: sys_props.contains(&Properties::PptFppt), ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl), @@ -498,6 +501,13 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc>) "Panel OverDrive successfully set to {}", "Setting Panel OverDrive failed" ); + set_ui_callbacks!( + handle, + SystemPageData(), + platform.boot_sound(), + "POST Animation sound successfully set to {}", + "Setting POST Animation sound failed" + ); set_ui_callbacks!( handle, SystemPageData(), diff --git a/rog-control-center/src/update_and_notify.rs b/rog-control-center/src/update_and_notify.rs index 7e8b5499..c39826b5 100644 --- a/rog-control-center/src/update_and_notify.rs +++ b/rog-control-center/src/update_and_notify.rs @@ -34,7 +34,7 @@ static mut POWER_BAT_CMD: Option = None; #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(default)] pub struct EnabledNotifications { - pub receive_post_animation_sound_changed: bool, + pub receive_boot_sound_changed: bool, pub receive_panel_od_changed: bool, pub receive_mini_led_mode_changed: bool, pub receive_dgpu_disable_changed: bool, @@ -54,7 +54,7 @@ pub struct EnabledNotifications { impl Default for EnabledNotifications { fn default() -> Self { Self { - receive_post_animation_sound_changed: false, + receive_boot_sound_changed: false, receive_panel_od_changed: true, receive_mini_led_mode_changed: true, receive_dgpu_disable_changed: true, @@ -199,7 +199,7 @@ pub fn start_notifications( // BIOS notif recv_changed!( PlatformProxy, - receive_post_animation_sound_changed, + receive_boot_sound_changed, last_notification, enabled_notifications, page_states, diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 1b53d7a8..75f58540 100644 --- a/rog-control-center/translations/en/rog-control-center.po +++ b/rog-control-center/translations/en/rog-control-center.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-03-09 10:30+0000\n" +"POT-Creation-Date: 2024-03-09 10:49+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/rog-control-center/ui/pages/aura.slint b/rog-control-center/ui/pages/aura.slint index 09227a09..0687dc27 100644 --- a/rog-control-center/ui/pages/aura.slint +++ b/rog-control-center/ui/pages/aura.slint @@ -201,8 +201,8 @@ export component PageAura inherits Rectangle { padding: 30px; padding-top: 10px; spacing: 10px; - for power in AuraPageData.supported_power_zones: gr:= HorizontalLayout { - if power == PowerZones.Keyboard: zone1:= AuraPowerGroup { + for power in AuraPageData.supported_power_zones: gr := HorizontalLayout { + if power == PowerZones.Keyboard: zone1 := AuraPowerGroup { title: @tr("Keyboard"); boot_checked: AuraPageData.led_power.rog.keyboard.boot; boot_toggled => { @@ -225,7 +225,7 @@ export component PageAura inherits Rectangle { AuraPageData.set_led_power(AuraPageData.led_power); } } - if power == PowerZones.Logo: zone2:= AuraPowerGroup { + if power == PowerZones.Logo: zone2 := AuraPowerGroup { title: @tr("Lid Logo"); boot_checked: AuraPageData.led_power.rog.logo.boot; boot_toggled => { @@ -248,7 +248,7 @@ export component PageAura inherits Rectangle { AuraPageData.set_led_power(AuraPageData.led_power); } } - if power == PowerZones.Lightbar: zone3:= AuraPowerGroup { + if power == PowerZones.Lightbar: zone3 := AuraPowerGroup { title: @tr("Lightbar"); boot_checked: AuraPageData.led_power.rog.lightbar.boot; boot_toggled => { @@ -271,7 +271,7 @@ export component PageAura inherits Rectangle { AuraPageData.set_led_power(AuraPageData.led_power); } } - if power == PowerZones.Lid: zone4:= AuraPowerGroup { + if power == PowerZones.Lid: zone4 := AuraPowerGroup { title: @tr("Lid Zone"); boot_checked: AuraPageData.led_power.rog.lid.boot; boot_toggled => { @@ -294,7 +294,7 @@ export component PageAura inherits Rectangle { AuraPageData.set_led_power(AuraPageData.led_power); } } - if power == PowerZones.RearGlow: zone5:= AuraPowerGroup { + if power == PowerZones.RearGlow: zone5 := AuraPowerGroup { title: @tr("Rear Glow"); boot_checked: AuraPageData.led_power.rog.rear-glow.boot; boot_toggled => { diff --git a/rog-control-center/ui/pages/system.slint b/rog-control-center/ui/pages/system.slint index c3a8fbf0..7025ec9a 100644 --- a/rog-control-center/ui/pages/system.slint +++ b/rog-control-center/ui/pages/system.slint @@ -5,6 +5,7 @@ import { HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboB export struct AvailableSystemProperties { charge_control_end_threshold: bool, panel_od: bool, + boot_sound: bool, mini_led_mode: bool, disable_nvidia_powerd_on_battery: bool, ac_command: bool, @@ -47,6 +48,8 @@ export global SystemPageData { callback set_throttle_policy_on_battery(int); in-out property panel_od; callback set_panel_od(bool); + in-out property boot_sound; + callback set_boot_sound(bool); in-out property mini_led_mode; callback set_mini_led_mode(bool); in-out property ppt_pl1_spl: 5; @@ -66,6 +69,7 @@ export global SystemPageData { in-out property available: { charge_control_end_threshold: true, panel_od: true, + boot_sound: true, mini_led_mode: true, disable_nvidia_powerd_on_battery: true, ac_command: true, @@ -153,6 +157,14 @@ export component PageSystem inherits Rectangle { SystemPageData.set_mini_led_mode(SystemPageData.mini_led_mode) } } + + if SystemPageData.available.boot-sound: SystemToggle { + text: @tr("POST boot sound"); + checked <=> SystemPageData.boot_sound; + toggled => { + SystemPageData.set_boot_sound(SystemPageData.boot_sound) + } + } } Rectangle { diff --git a/rog-dbus/src/zbus_platform.rs b/rog-dbus/src/zbus_platform.rs index c8f6f1b1..521700fc 100644 --- a/rog-dbus/src/zbus_platform.rs +++ b/rog-dbus/src/zbus_platform.rs @@ -85,9 +85,9 @@ trait Platform { /// PostAnimationSound property #[zbus(property)] - fn post_animation_sound(&self) -> zbus::Result; + fn boot_sound(&self) -> zbus::Result; #[zbus(property)] - fn set_post_animation_sound(&self, value: bool) -> zbus::Result<()>; + fn set_boot_sound(&self, value: bool) -> zbus::Result<()>; /// PptApuSppt property #[zbus(property)] diff --git a/rog-platform/src/platform.rs b/rog-platform/src/platform.rs index e8c374ca..6ae7ef1b 100644 --- a/rog-platform/src/platform.rs +++ b/rog-platform/src/platform.rs @@ -101,7 +101,7 @@ impl RogPlatform { attr_bool!( /// Control the POST animation "FWOOoosh" sound - "post_animation_sound", + "boot_sound", path );