Update support for boot_sound kernel patch

This commit is contained in:
Luke D. Jones
2024-03-10 20:53:03 +13:00
parent 0fac33a8ff
commit e371229b6c
11 changed files with 64 additions and 42 deletions

View File

@@ -813,10 +813,10 @@ fn handle_platform_properties(
} }
if let Some(opt) = cmd.post_sound_set { 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 { 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); println!("Bios POST sound on: {}", res);
} }

View File

@@ -10,6 +10,7 @@ pub struct Config {
/// Save charge limit for restoring on boot/resume /// Save charge limit for restoring on boot/resume
pub charge_control_end_threshold: u8, pub charge_control_end_threshold: u8,
pub panel_od: bool, pub panel_od: bool,
pub boot_sound: bool,
pub mini_led_mode: bool, pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool, pub disable_nvidia_powerd_on_battery: bool,
/// An optional command/script to run when power is changed to AC /// An optional command/script to run when power is changed to AC
@@ -53,6 +54,7 @@ impl Default for Config {
Self { Self {
charge_control_end_threshold: 100, charge_control_end_threshold: 100,
panel_od: false, panel_od: false,
boot_sound: false,
mini_led_mode: false, mini_led_mode: false,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
ac_command: Default::default(), ac_command: Default::default(),
@@ -126,6 +128,7 @@ impl From<Config507> for Config {
Self { Self {
charge_control_end_threshold: c.charge_control_end_threshold, charge_control_end_threshold: c.charge_control_end_threshold,
panel_od: c.panel_od, panel_od: c.panel_od,
boot_sound: false,
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery, disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command, ac_command: c.ac_command,
bat_command: c.bat_command, bat_command: c.bat_command,
@@ -177,6 +180,7 @@ impl From<Config506> for Config {
Self { Self {
charge_control_end_threshold: c.charge_control_end_threshold, charge_control_end_threshold: c.charge_control_end_threshold,
panel_od: c.panel_od, panel_od: c.panel_od,
boot_sound: false,
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery, disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command, ac_command: c.ac_command,
bat_command: c.bat_command, bat_command: c.bat_command,

View File

@@ -319,7 +319,7 @@ impl CtrlPlatform {
platform_name!(dgpu_disable, Properties::DgpuDisable); platform_name!(dgpu_disable, Properties::DgpuDisable);
platform_name!(gpu_mux_mode, Properties::GpuMuxMode); 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!(panel_od, Properties::PanelOd);
platform_name!(mini_led_mode, Properties::MiniLedMode); platform_name!(mini_led_mode, Properties::MiniLedMode);
platform_name!(egpu_enable, Properties::EgpuEnable); platform_name!(egpu_enable, Properties::EgpuEnable);
@@ -558,29 +558,6 @@ impl CtrlPlatform {
Ok(()) Ok(())
} }
/// ***********************************************************************
#[zbus(property)]
fn post_animation_sound(&self) -> Result<bool, FdoErr> {
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 /// Get the `panel_od` value from platform. Updates the stored value in
/// internal config also. /// internal config also.
#[zbus(property)] #[zbus(property)]
@@ -595,6 +572,20 @@ impl CtrlPlatform {
Ok(()) Ok(())
} }
/// Get the `boot_sound` value from platform. Updates the stored value in
/// internal config also.
#[zbus(property)]
fn boot_sound(&self) -> Result<bool, FdoErr> {
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 /// Get the `panel_od` value from platform. Updates the stored value in
/// internal config also. /// internal config also.
#[zbus(property)] #[zbus(property)]
@@ -751,6 +742,11 @@ impl ReloadAndNotify for CtrlPlatform {
self.panel_od_changed(signal_context).await?; 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 { 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.platform.set_mini_led_mode(data.mini_led_mode)?;
self.mini_led_mode_changed(signal_context).await?; 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!(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); 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 // 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. // booted-with value as it does not actually change until reboot.
self.watch_gpu_mux_mode(signal_ctxt.clone()).await?; 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_pl1_spl(signal_ctxt.clone()).await?;
self.watch_ppt_pl2_sppt(signal_ctxt.clone()).await?; self.watch_ppt_pl2_sppt(signal_ctxt.clone()).await?;

View File

@@ -40,7 +40,7 @@ pub struct PlatformState {
impl PlatformState { impl PlatformState {
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> { pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
Ok(Self { Ok(Self {
post_sound: dbus.proxies().platform().post_animation_sound().ok(), post_sound: dbus.proxies().platform().boot_sound().ok(),
gpu_mux_mode: dbus gpu_mux_mode: dbus
.proxies() .proxies()
.platform() .platform()

View File

@@ -415,6 +415,7 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost), nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost),
nv_temp_target: sys_props.contains(&Properties::NvTempTarget), nv_temp_target: sys_props.contains(&Properties::NvTempTarget),
panel_od: sys_props.contains(&Properties::PanelOd), panel_od: sys_props.contains(&Properties::PanelOd),
boot_sound: sys_props.contains(&Properties::PostAnimationSound),
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt), ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt),
ppt_fppt: sys_props.contains(&Properties::PptFppt), ppt_fppt: sys_props.contains(&Properties::PptFppt),
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl), ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl),
@@ -452,6 +453,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_ac); 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, 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, mini_led_mode);
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl1_spl); set_ui_props_async!(handle, platform, SystemPageData, ppt_pl1_spl);
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl2_sppt); set_ui_props_async!(handle, platform, SystemPageData, ppt_pl2_sppt);
@@ -473,6 +475,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost), nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost),
nv_temp_target: sys_props.contains(&Properties::NvTempTarget), nv_temp_target: sys_props.contains(&Properties::NvTempTarget),
panel_od: sys_props.contains(&Properties::PanelOd), panel_od: sys_props.contains(&Properties::PanelOd),
boot_sound: sys_props.contains(&Properties::PostAnimationSound),
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt), ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt),
ppt_fppt: sys_props.contains(&Properties::PptFppt), ppt_fppt: sys_props.contains(&Properties::PptFppt),
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl), ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl),
@@ -498,6 +501,13 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
"Panel OverDrive successfully set to {}", "Panel OverDrive successfully set to {}",
"Setting Panel OverDrive failed" "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!( set_ui_callbacks!(
handle, handle,
SystemPageData(), SystemPageData(),

View File

@@ -34,7 +34,7 @@ static mut POWER_BAT_CMD: Option<Command> = None;
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)] #[serde(default)]
pub struct EnabledNotifications { pub struct EnabledNotifications {
pub receive_post_animation_sound_changed: bool, pub receive_boot_sound_changed: bool,
pub receive_panel_od_changed: bool, pub receive_panel_od_changed: bool,
pub receive_mini_led_mode_changed: bool, pub receive_mini_led_mode_changed: bool,
pub receive_dgpu_disable_changed: bool, pub receive_dgpu_disable_changed: bool,
@@ -54,7 +54,7 @@ pub struct EnabledNotifications {
impl Default for EnabledNotifications { impl Default for EnabledNotifications {
fn default() -> Self { fn default() -> Self {
Self { Self {
receive_post_animation_sound_changed: false, receive_boot_sound_changed: false,
receive_panel_od_changed: true, receive_panel_od_changed: true,
receive_mini_led_mode_changed: true, receive_mini_led_mode_changed: true,
receive_dgpu_disable_changed: true, receive_dgpu_disable_changed: true,
@@ -199,7 +199,7 @@ pub fn start_notifications(
// BIOS notif // BIOS notif
recv_changed!( recv_changed!(
PlatformProxy, PlatformProxy,
receive_post_animation_sound_changed, receive_boot_sound_changed,
last_notification, last_notification,
enabled_notifications, enabled_notifications,
page_states, page_states,

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -201,8 +201,8 @@ export component PageAura inherits Rectangle {
padding: 30px; padding: 30px;
padding-top: 10px; padding-top: 10px;
spacing: 10px; spacing: 10px;
for power in AuraPageData.supported_power_zones: gr:= HorizontalLayout { for power in AuraPageData.supported_power_zones: gr := HorizontalLayout {
if power == PowerZones.Keyboard: zone1:= AuraPowerGroup { if power == PowerZones.Keyboard: zone1 := AuraPowerGroup {
title: @tr("Keyboard"); title: @tr("Keyboard");
boot_checked: AuraPageData.led_power.rog.keyboard.boot; boot_checked: AuraPageData.led_power.rog.keyboard.boot;
boot_toggled => { boot_toggled => {
@@ -225,7 +225,7 @@ export component PageAura inherits Rectangle {
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.set_led_power(AuraPageData.led_power);
} }
} }
if power == PowerZones.Logo: zone2:= AuraPowerGroup { if power == PowerZones.Logo: zone2 := AuraPowerGroup {
title: @tr("Lid Logo"); title: @tr("Lid Logo");
boot_checked: AuraPageData.led_power.rog.logo.boot; boot_checked: AuraPageData.led_power.rog.logo.boot;
boot_toggled => { boot_toggled => {
@@ -248,7 +248,7 @@ export component PageAura inherits Rectangle {
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.set_led_power(AuraPageData.led_power);
} }
} }
if power == PowerZones.Lightbar: zone3:= AuraPowerGroup { if power == PowerZones.Lightbar: zone3 := AuraPowerGroup {
title: @tr("Lightbar"); title: @tr("Lightbar");
boot_checked: AuraPageData.led_power.rog.lightbar.boot; boot_checked: AuraPageData.led_power.rog.lightbar.boot;
boot_toggled => { boot_toggled => {
@@ -271,7 +271,7 @@ export component PageAura inherits Rectangle {
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.set_led_power(AuraPageData.led_power);
} }
} }
if power == PowerZones.Lid: zone4:= AuraPowerGroup { if power == PowerZones.Lid: zone4 := AuraPowerGroup {
title: @tr("Lid Zone"); title: @tr("Lid Zone");
boot_checked: AuraPageData.led_power.rog.lid.boot; boot_checked: AuraPageData.led_power.rog.lid.boot;
boot_toggled => { boot_toggled => {
@@ -294,7 +294,7 @@ export component PageAura inherits Rectangle {
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.set_led_power(AuraPageData.led_power);
} }
} }
if power == PowerZones.RearGlow: zone5:= AuraPowerGroup { if power == PowerZones.RearGlow: zone5 := AuraPowerGroup {
title: @tr("Rear Glow"); title: @tr("Rear Glow");
boot_checked: AuraPageData.led_power.rog.rear-glow.boot; boot_checked: AuraPageData.led_power.rog.rear-glow.boot;
boot_toggled => { boot_toggled => {

View File

@@ -5,6 +5,7 @@ import { HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboB
export struct AvailableSystemProperties { export struct AvailableSystemProperties {
charge_control_end_threshold: bool, charge_control_end_threshold: bool,
panel_od: bool, panel_od: bool,
boot_sound: bool,
mini_led_mode: bool, mini_led_mode: bool,
disable_nvidia_powerd_on_battery: bool, disable_nvidia_powerd_on_battery: bool,
ac_command: bool, ac_command: bool,
@@ -47,6 +48,8 @@ export global SystemPageData {
callback set_throttle_policy_on_battery(int); callback set_throttle_policy_on_battery(int);
in-out property <bool> panel_od; in-out property <bool> panel_od;
callback set_panel_od(bool); callback set_panel_od(bool);
in-out property <bool> boot_sound;
callback set_boot_sound(bool);
in-out property <bool> mini_led_mode; in-out property <bool> mini_led_mode;
callback set_mini_led_mode(bool); callback set_mini_led_mode(bool);
in-out property <float> ppt_pl1_spl: 5; in-out property <float> ppt_pl1_spl: 5;
@@ -66,6 +69,7 @@ export global SystemPageData {
in-out property <AvailableSystemProperties> available: { in-out property <AvailableSystemProperties> available: {
charge_control_end_threshold: true, charge_control_end_threshold: true,
panel_od: true, panel_od: true,
boot_sound: true,
mini_led_mode: true, mini_led_mode: true,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
ac_command: true, ac_command: true,
@@ -153,6 +157,14 @@ export component PageSystem inherits Rectangle {
SystemPageData.set_mini_led_mode(SystemPageData.mini_led_mode) 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 { Rectangle {

View File

@@ -85,9 +85,9 @@ trait Platform {
/// PostAnimationSound property /// PostAnimationSound property
#[zbus(property)] #[zbus(property)]
fn post_animation_sound(&self) -> zbus::Result<bool>; fn boot_sound(&self) -> zbus::Result<bool>;
#[zbus(property)] #[zbus(property)]
fn set_post_animation_sound(&self, value: bool) -> zbus::Result<()>; fn set_boot_sound(&self, value: bool) -> zbus::Result<()>;
/// PptApuSppt property /// PptApuSppt property
#[zbus(property)] #[zbus(property)]

View File

@@ -101,7 +101,7 @@ impl RogPlatform {
attr_bool!( attr_bool!(
/// Control the POST animation "FWOOoosh" sound /// Control the POST animation "FWOOoosh" sound
"post_animation_sound", "boot_sound",
path path
); );