Remove dangerous use of ppt* in platform, add use of ppt_pl3_fppt in asus_armoury handler

This commit is contained in:
Luke D. Jones
2025-01-13 23:10:37 +13:00
parent be51a1ab77
commit a790d9a499
6 changed files with 53 additions and 279 deletions

View File

@@ -59,28 +59,6 @@ macro_rules! platform_set_value {
}
}
macro_rules! platform_ppt_set_value {
($self:ident, $property:tt, $prop_name:literal, $new_value:expr) => {
concat_idents::concat_idents!(has = has_, $property {
if $self.platform.has() {
concat_idents::concat_idents!(set = set_, $property {
$self.platform.set($new_value).map_err(|err| {
error!("RogPlatform: {} {err}", $prop_name);
FdoErr::NotSupported(format!("RogPlatform: {} {err}", $prop_name))
})?;
});
let mut lock = $self.config.lock().await;
lock.$property = Some($new_value);
lock.write();
Ok(())
} else {
debug!("RogPlatform: ppt: setting {} not supported", $prop_name);
Err(FdoErr::NotSupported(format!("RogPlatform: {} not supported", $prop_name)))
}
})
}
}
#[derive(Clone)]
pub struct CtrlPlatform {
power: AsusPower,
@@ -345,14 +323,6 @@ impl CtrlPlatform {
platform_name!(egpu_enable, Properties::EgpuEnable);
platform_name!(throttle_thermal_policy, Properties::ThrottlePolicy);
platform_name!(ppt_pl1_spl, Properties::PptPl1Spl);
platform_name!(ppt_pl2_sppt, Properties::PptPl2Sppt);
platform_name!(ppt_fppt, Properties::PptFppt);
platform_name!(ppt_apu_sppt, Properties::PptApuSppt);
platform_name!(ppt_platform_sppt, Properties::PptPlatformSppt);
platform_name!(nv_dynamic_boost, Properties::NvDynamicBoost);
platform_name!(nv_temp_target, Properties::NvTempTarget);
supported
}
@@ -631,107 +601,6 @@ impl CtrlPlatform {
fn egpu_enable(&self) -> Result<bool, FdoErr> {
platform_get_value!(self, egpu_enable, "egpu_enable")
}
/// ***********************************************************************
/// Set the Package Power Target total of CPU: PL1 on Intel, SPL on AMD.
/// Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
#[zbus(property)]
async fn ppt_pl1_spl(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_pl1_spl, "ppt_pl1_spl")
}
#[zbus(property)]
async fn set_ppt_pl1_spl(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_pl1_spl, "ppt_pl1_spl", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the Slow Package Power Tracking Limit of CPU: PL2 on Intel, SPPT,
/// on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
#[zbus(property)]
async fn ppt_pl2_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_pl2_sppt, "ppt_pl2_sppt")
}
#[zbus(property)]
async fn set_ppt_pl2_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_pl2_sppt, "ppt_pl2_sppt", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
/// * min=5, max=250
#[zbus(property)]
async fn ppt_fppt(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_fppt, "ppt_fppt")
}
#[zbus(property)]
async fn set_ppt_fppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_fppt, "ppt_fppt", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the APU SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
#[zbus(property)]
async fn ppt_apu_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_apu_sppt, "ppt_apu_sppt")
}
#[zbus(property)]
async fn set_ppt_apu_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_apu_sppt, "ppt_apu_sppt", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the platform SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
#[zbus(property)]
async fn ppt_platform_sppt(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, ppt_platform_sppt, "ppt_platform_sppt")
}
#[zbus(property)]
async fn set_ppt_platform_sppt(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, ppt_platform_sppt, "ppt_platform_sppt", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the dynamic boost limit of the Nvidia dGPU:
/// * min=5, max=25
#[zbus(property)]
async fn nv_dynamic_boost(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, nv_dynamic_boost, "nv_dynamic_boost")
}
#[zbus(property)]
async fn set_nv_dynamic_boost(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, nv_dynamic_boost, "nv_dynamic_boost", value)?;
self.config.lock().await.write();
Ok(())
}
/// Set the target temperature limit of the Nvidia dGPU:
/// * min=75, max=87
#[zbus(property)]
async fn nv_temp_target(&self) -> Result<u8, FdoErr> {
platform_get_value!(self, nv_temp_target, "nv_temp_target")
}
#[zbus(property)]
async fn set_nv_temp_target(&mut self, value: u8) -> Result<(), FdoErr> {
platform_ppt_set_value!(self, nv_temp_target, "nv_temp_target", value)?;
self.config.lock().await.write();
Ok(())
}
}
impl crate::ZbusRun for CtrlPlatform {
@@ -790,27 +659,6 @@ impl ReloadAndNotify for CtrlPlatform {
reload_and_notify!(boot_sound, "boot_sound");
// reload_and_notify!(throttle_thermal_policy, "throttle_thermal_policy");
macro_rules! ppt_reload_and_notify {
($property:tt, $prop_name:literal) => {
concat_idents::concat_idents!(has = has_, $property {
if self.platform.has() && config.$property != data.$property {
concat_idents::concat_idents!(set = set_, $property {
self.platform
.set(data.$property.unwrap_or_default())?;});
concat_idents::concat_idents!(changed = $property, _changed {
self.changed(signal_context).await?;});
}
})
}
}
ppt_reload_and_notify!(ppt_pl1_spl, "ppt_pl1_spl");
ppt_reload_and_notify!(ppt_pl2_sppt, "ppt_pl2_sppt");
ppt_reload_and_notify!(ppt_fppt, "ppt_fppt");
ppt_reload_and_notify!(ppt_apu_sppt, "ppt_apu_sppt");
ppt_reload_and_notify!(ppt_platform_sppt, "ppt_platform_sppt");
ppt_reload_and_notify!(nv_dynamic_boost, "nv_dynamic_boost");
ppt_reload_and_notify!(nv_temp_target, "nv_temp_target");
*config = data;
config.base_charge_control_end_threshold =
base_charge_control_end_threshold.unwrap_or_default();
@@ -848,25 +696,6 @@ impl crate::Reloadable for CtrlPlatform {
reload!(panel_od, "panel_od");
reload!(boot_sound, "boot_sound");
macro_rules! ppt_reload {
($property:tt, $prop_name:literal) => {
concat_idents::concat_idents!(has = has_, $property {
if self.platform.has() {
concat_idents::concat_idents!(set = set_, $property {
self.platform
.set(self.config.lock().await.$property.unwrap_or_default())?;});
}
})
}
}
ppt_reload!(ppt_pl1_spl, "ppt_pl1_spl");
ppt_reload!(ppt_pl2_sppt, "ppt_pl2_sppt");
ppt_reload!(ppt_fppt, "ppt_fppt");
ppt_reload!(ppt_apu_sppt, "ppt_apu_sppt");
ppt_reload!(ppt_platform_sppt, "ppt_platform_sppt");
ppt_reload!(nv_dynamic_boost, "nv_dynamic_boost");
ppt_reload!(nv_temp_target, "nv_temp_target");
if let Ok(power_plugged) = self.power.get_online() {
self.config.lock().await.last_power_plugged = power_plugged;
if self.platform.has_throttle_thermal_policy() {
@@ -896,20 +725,6 @@ impl CtrlPlatform {
// NOTE: see note further below
task_watch_item_notify!(gpu_mux_mode platform);
task_watch_item_notify!(ppt_pl1_spl platform);
task_watch_item_notify!(ppt_pl2_sppt platform);
task_watch_item_notify!(ppt_fppt platform);
task_watch_item_notify!(ppt_apu_sppt platform);
task_watch_item_notify!(ppt_platform_sppt platform);
task_watch_item_notify!(nv_dynamic_boost platform);
task_watch_item_notify!(nv_temp_target platform);
}
impl CtrlTask for CtrlPlatform {
@@ -1043,14 +858,6 @@ impl CtrlTask for CtrlPlatform {
self.watch_gpu_mux_mode(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?;
self.watch_ppt_fppt(signal_ctxt.clone()).await?;
self.watch_ppt_apu_sppt(signal_ctxt.clone()).await?;
self.watch_ppt_platform_sppt(signal_ctxt.clone()).await?;
self.watch_nv_dynamic_boost(signal_ctxt.clone()).await?;
self.watch_nv_temp_target(signal_ctxt.clone()).await?;
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?;
let ctrl = self.clone();

View File

@@ -272,6 +272,16 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
setup_callback!(ppt_pl2_sppt, handle, attr, i32);
setup_minmax_external!(ppt_pl2_sppt, handle, attr);
}
FirmwareAttribute::PptPl3Fppt => {
init_minmax_property!(ppt_pl3_fppt, handle, attr);
setup_callback!(ppt_pl3_fppt, handle, attr, i32);
setup_minmax_external!(ppt_pl3_fppt, handle, attr);
}
FirmwareAttribute::PptFppt => {
init_minmax_property!(ppt_fppt, handle, attr);
setup_callback!(ppt_fppt, handle, attr, i32);
setup_minmax_external!(ppt_fppt, handle, attr);
}
FirmwareAttribute::PptApuSppt => {
init_minmax_property!(ppt_apu_sppt, handle, attr);
setup_callback!(ppt_apu_sppt, handle, attr, i32);
@@ -282,11 +292,6 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
setup_callback!(ppt_platform_sppt, handle, attr, i32);
setup_minmax_external!(ppt_platform_sppt, handle, attr);
}
FirmwareAttribute::PptFppt => {
init_minmax_property!(ppt_fppt, handle, attr);
setup_callback!(ppt_fppt, handle, attr, i32);
setup_minmax_external!(ppt_fppt, handle, attr);
}
FirmwareAttribute::NvDynamicBoost => {
init_minmax_property!(nv_dynamic_boost, handle, attr);
setup_callback!(nv_dynamic_boost, handle, attr, i32);

View File

@@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-01-13 01:32+0000\n"
"POT-Creation-Date: 2025-01-13 09:38+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -65,6 +65,13 @@ export global SystemPageData {
};
callback cb_ppt_pl2_sppt(int);
in-out property <AttrMinMax> ppt_pl3_fppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_pl3_fppt(int);
in-out property <AttrMinMax> ppt_fppt: {
min: 0,
max: 100,
@@ -234,6 +241,16 @@ export component PageSystem inherits Rectangle {
}
}
if SystemPageData.ppt_pl3_fppt.val != -1: SystemSlider {
text: @tr("ppt_pl3_fppt" => "PL3, Fast Power Limit");
minimum: SystemPageData.ppt_pl3_fppt.min;
maximum: SystemPageData.ppt_pl3_fppt.max;
value: SystemPageData.ppt_pl3_fppt.val;
released => {
SystemPageData.ppt_fppt.val = self.value;
SystemPageData.cb_ppt_fppt(Math.round(self.value))
}
}
if SystemPageData.ppt_fppt.val != -1: SystemSlider {
text: @tr("ppt_fppt" => "FPPT, Fast Power Limit");
minimum: SystemPageData.ppt_fppt.min;

View File

@@ -238,25 +238,26 @@ pub enum FirmwareAttribute {
CoresEfficiency = 2,
PptPl1Spl = 3,
PptPl2Sppt = 4,
PptApuSppt = 5,
PptPlatformSppt = 6,
PptFppt = 7,
NvDynamicBoost = 8,
NvTempTarget = 9,
DgpuBaseTgp = 10,
DgpuTgp = 11,
ChargeMode = 12,
BootSound = 13,
McuPowersave = 14,
PanelOverdrive = 15,
PanelHdMode = 16,
EgpuConnected = 17,
EgpuEnable = 18,
DgpuDisable = 19,
GpuMuxMode = 20,
MiniLedMode = 21,
PendingReboot = 22,
None = 23
PptPl3Fppt = 5,
PptFppt = 6,
PptApuSppt = 7,
PptPlatformSppt = 8,
NvDynamicBoost = 9,
NvTempTarget = 10,
DgpuBaseTgp = 11,
DgpuTgp = 12,
ChargeMode = 13,
BootSound = 14,
McuPowersave = 15,
PanelOverdrive = 16,
PanelHdMode = 17,
EgpuConnected = 18,
EgpuEnable = 19,
DgpuDisable = 20,
GpuMuxMode = 21,
MiniLedMode = 22,
PendingReboot = 23,
None = 24
}
impl From<&str> for FirmwareAttribute {
@@ -267,9 +268,10 @@ impl From<&str> for FirmwareAttribute {
"cores_efficiency" => Self::CoresEfficiency,
"ppt_pl1_spl" => Self::PptPl1Spl,
"ppt_pl2_sppt" => Self::PptPl2Sppt,
"ppt_pl3_fppt" => Self::PptPl3Fppt,
"ppt_fppt" => Self::PptFppt,
"ppt_apu_sppt" => Self::PptApuSppt,
"ppt_platform_sppt" => Self::PptPlatformSppt,
"ppt_fppt" => Self::PptFppt,
"nv_dynamic_boost" => Self::NvDynamicBoost,
"nv_temp_target" => Self::NvTempTarget,
"dgpu_base_tgp" => Self::DgpuBaseTgp,
@@ -298,9 +300,10 @@ impl From<FirmwareAttribute> for &str {
FirmwareAttribute::CoresEfficiency => "cores_efficiency",
FirmwareAttribute::PptPl1Spl => "ppt_pl1_spl",
FirmwareAttribute::PptPl2Sppt => "ppt_pl2_sppt",
FirmwareAttribute::PptPl3Fppt => "ppt_pl3_fppt",
FirmwareAttribute::PptFppt => "ppt_fppt",
FirmwareAttribute::PptApuSppt => "ppt_apu_sppt",
FirmwareAttribute::PptPlatformSppt => "ppt_platform_sppt",
FirmwareAttribute::PptFppt => "ppt_fppt",
FirmwareAttribute::NvDynamicBoost => "nv_dynamic_boost",
FirmwareAttribute::NvTempTarget => "nv_temp_target",
FirmwareAttribute::DgpuBaseTgp => "dgpu_base_tgp",

View File

@@ -47,57 +47,6 @@ impl RogPlatform {
pp_path
);
attr_u8!(
/// Package Power Target total of CPU: PL1 on Intel, SPL on AMD.
/// Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
"ppt_pl1_spl",
path
);
attr_u8!(
/// Slow Package Power Tracking Limit of CPU: PL2 on Intel, SPPT,
/// on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems:
/// * min=5, max=250
"ppt_pl2_sppt",
path
);
attr_u8!(
/// Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
/// * min=5, max=250
"ppt_fppt",
path
);
attr_u8!(
/// APU SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
"ppt_apu_sppt",
path
);
attr_u8!(
/// Platform SPPT limit. Shown on full AMD systems only:
/// * min=5, max=130
"ppt_platform_sppt",
path
);
attr_u8!(
/// Dynamic boost limit of the Nvidia dGPU:
/// * min=5, max=25
"nv_dynamic_boost",
path
);
attr_u8!(
/// Target temperature limit of the Nvidia dGPU:
/// * min=75, max=87
"nv_temp_target",
path
);
attr_bool!(
/// Control the POST animation "FWOOoosh" sound
"boot_sound",
@@ -364,12 +313,5 @@ pub enum Properties {
PanelOd,
MiniLedMode,
EgpuEnable,
ThrottlePolicy,
PptPl1Spl,
PptPl2Sppt,
PptFppt,
PptApuSppt,
PptPlatformSppt,
NvDynamicBoost,
NvTempTarget
ThrottlePolicy
}