feature: rework PPT tuning handling more

1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
This commit is contained in:
Luke D. Jones
2025-01-20 22:03:39 +13:00
parent 25823dc6b7
commit 911ff8690e
14 changed files with 351 additions and 122 deletions

View File

@@ -2,6 +2,12 @@
## [Unreleased] ## [Unreleased]
- Refactor PPT handling more:
1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
## [v6.1.0-rc6] ## [v6.1.0-rc6]
### Changed ### Changed

View File

@@ -113,15 +113,18 @@ impl crate::Reloadable for AsusArmouryAttribute {
} else { } else {
&self.config.lock().await.dc_profile_tunings &self.config.lock().await.dc_profile_tunings
}; };
if let Some(tunings) = config.get(&profile) { if let Some(tuning) = config.get(&profile) {
if let Some(tune) = tunings.get(&self.name()) { if tuning.enabled {
self.attr if let Some(tune) = tuning.group.get(&self.name()) {
.set_current_value(&AttrValue::Integer(*tune)) self.attr
.map_err(|e| { .set_current_value(&AttrValue::Integer(*tune))
error!("Could not set value: {e:?}"); .map_err(|e| {
e error!("Could not set {} value: {e:?}", self.attr.name());
})?; self.attr.base_path_exists();
info!("Set {} to {:?}", self.attr.name(), tune); e
})?;
info!("Set {} to {:?}", self.attr.name(), tune);
}
} }
} }
@@ -191,12 +194,20 @@ impl AsusArmouryAttribute {
.unwrap_or_default(); .unwrap_or_default();
let mut config = self.config.lock().await; let mut config = self.config.lock().await;
let tunings = config.select_tunings(power_plugged == 1, profile); let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tunings.get_mut(&self.name()) { if let Some(tune) = tuning.group.get_mut(&self.name()) {
if let AttrValue::Integer(i) = self.attr.default_value() { if let AttrValue::Integer(i) = self.attr.default_value() {
*tune = *i; *tune = *i;
} }
} }
if tuning.enabled {
self.attr
.set_current_value(self.attr.default_value())
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
}
config.write(); config.write();
} }
Ok(()) Ok(())
@@ -236,6 +247,28 @@ impl AsusArmouryAttribute {
#[zbus(property)] #[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> { async fn current_value(&self) -> fdo::Result<i32> {
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get(&self.name()) {
return Ok(*tune);
} else if let AttrValue::Integer(i) = self.attr.default_value() {
return Ok(*i);
}
return Err(fdo::Error::Failed(
"Could not read current value".to_string()
));
}
if let Ok(AttrValue::Integer(i)) = self.attr.current_value() { if let Ok(AttrValue::Integer(i)) = self.attr.current_value() {
return Ok(i); return Ok(i);
} }
@@ -246,16 +279,8 @@ impl AsusArmouryAttribute {
#[zbus(property)] #[zbus(property)]
async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> { async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
if self.name().is_ppt() { if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self let power_plugged = self
.power .power
.get_online() .get_online()
@@ -264,16 +289,32 @@ impl AsusArmouryAttribute {
e e
}) })
.unwrap_or_default(); .unwrap_or_default();
let mut config = self.config.lock().await;
let tunings = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tunings.get_mut(&self.name()) { let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get_mut(&self.name()) {
*tune = value; *tune = value;
} else { } else {
tunings.insert(self.name(), value); tuning.group.insert(self.name(), value);
debug!("Set tuning config for {} = {:?}", self.attr.name(), value); debug!("Store tuning config for {} = {:?}", self.attr.name(), value);
}
if tuning.enabled {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
} }
} else { } else {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
let has_attr = self let has_attr = self
.config .config
.lock() .lock()
@@ -309,9 +350,10 @@ pub async fn start_attributes_zbus(
conn: &Connection, conn: &Connection,
platform: RogPlatform, platform: RogPlatform,
power: AsusPower, power: AsusPower,
attributes: FirmwareAttributes,
config: Arc<Mutex<Config>> config: Arc<Mutex<Config>>
) -> Result<(), RogError> { ) -> Result<(), RogError> {
for attr in FirmwareAttributes::new().attributes() { for attr in attributes.attributes() {
let mut attr = AsusArmouryAttribute::new( let mut attr = AsusArmouryAttribute::new(
attr.clone(), attr.clone(),
platform.clone(), platform.clone(),
@@ -338,9 +380,13 @@ pub async fn set_config_or_default(
for attr in attrs.attributes().iter() { for attr in attrs.attributes().iter() {
let name: FirmwareAttribute = attr.name().into(); let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() { if name.is_ppt() {
let tunings = config.select_tunings(power_plugged, profile); let tuning = config.select_tunings(power_plugged, profile);
if !tuning.enabled {
debug!("Tuning group is not enabled, skipping");
return;
}
if let Some(tune) = tunings.get(&name) { if let Some(tune) = tuning.group.get(&name) {
attr.set_current_value(&AttrValue::Integer(*tune)) attr.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| { .map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name)); error!("Failed to set {}: {e}", <&str>::from(name));
@@ -354,7 +400,7 @@ pub async fn set_config_or_default(
}) })
.ok(); .ok();
if let AttrValue::Integer(i) = default { if let AttrValue::Integer(i) = default {
tunings.insert(name, *i); tuning.group.insert(name, *i);
info!( info!(
"Set default tuning config for {} = {:?}", "Set default tuning config for {} = {:?}",
<&str>::from(name), <&str>::from(name),

View File

@@ -7,7 +7,13 @@ use rog_platform::platform::PlatformProfile;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
const CONFIG_FILE: &str = "asusd.ron"; const CONFIG_FILE: &str = "asusd.ron";
type Tunings = HashMap<PlatformProfile, HashMap<FirmwareAttribute, i32>>;
#[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
pub struct Tuning {
pub enabled: bool,
pub group: HashMap<FirmwareAttribute, i32>
}
type Tunings = HashMap<PlatformProfile, Tuning>;
#[derive(Deserialize, Serialize, PartialEq)] #[derive(Deserialize, Serialize, PartialEq)]
pub struct Config { pub struct Config {
@@ -47,17 +53,13 @@ pub struct Config {
} }
impl Config { impl Config {
pub fn select_tunings( pub fn select_tunings(&mut self, power_plugged: bool, profile: PlatformProfile) -> &mut Tuning {
&mut self,
power_plugged: bool,
profile: PlatformProfile
) -> &mut HashMap<FirmwareAttribute, i32> {
let config = if power_plugged { let config = if power_plugged {
&mut self.ac_profile_tunings &mut self.ac_profile_tunings
} else { } else {
&mut self.dc_profile_tunings &mut self.dc_profile_tunings
}; };
config.entry(profile).or_insert_with(HashMap::new) config.entry(profile).or_insert_with(Tuning::default)
} }
} }

View File

@@ -4,7 +4,7 @@ use std::sync::Arc;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::asus_armoury::FirmwareAttributes; use rog_platform::asus_armoury::{AttrValue, FirmwareAttribute, FirmwareAttributes};
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP}; use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
use rog_platform::platform::{PlatformProfile, Properties, RogPlatform}; use rog_platform::platform::{PlatformProfile, Properties, RogPlatform};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
@@ -43,24 +43,27 @@ macro_rules! platform_get_value {
pub struct CtrlPlatform { pub struct CtrlPlatform {
power: AsusPower, power: AsusPower,
platform: RogPlatform, platform: RogPlatform,
attributes: FirmwareAttributes,
cpu_control: Option<CPUControl>, cpu_control: Option<CPUControl>,
config: Arc<Mutex<Config>> config: Arc<Mutex<Config>>
} }
impl CtrlPlatform { impl CtrlPlatform {
pub fn new( pub fn new(
platform: RogPlatform,
power: AsusPower,
attributes: FirmwareAttributes,
config: Arc<Mutex<Config>>, config: Arc<Mutex<Config>>,
config_path: &Path, config_path: &Path,
signal_context: SignalEmitter<'static> signal_context: SignalEmitter<'static>
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
let platform = RogPlatform::new()?;
let power = AsusPower::new()?;
let config1 = config.clone(); let config1 = config.clone();
let config_path = config_path.to_owned(); let config_path = config_path.to_owned();
let ret_self = CtrlPlatform { let ret_self = CtrlPlatform {
power, power,
platform, platform,
attributes,
config, config,
cpu_control: CPUControl::new() cpu_control: CPUControl::new()
.map_err(|e| error!("Couldn't get CPU control sysfs: {e}")) .map_err(|e| error!("Couldn't get CPU control sysfs: {e}"))
@@ -332,6 +335,7 @@ impl CtrlPlatform {
warn!("platform_profile {}", err); warn!("platform_profile {}", err);
FdoErr::Failed(format!("RogPlatform: platform_profile: {err}")) FdoErr::Failed(format!("RogPlatform: platform_profile: {err}"))
})?; })?;
self.enable_ppt_group_changed(&ctxt).await?;
Ok(self.platform_profile_changed(&ctxt).await?) Ok(self.platform_profile_changed(&ctxt).await?)
} else { } else {
Err(FdoErr::NotSupported( Err(FdoErr::NotSupported(
@@ -352,6 +356,21 @@ impl CtrlPlatform {
let change_epp = self.config.lock().await.platform_profile_linked_epp; let change_epp = self.config.lock().await.platform_profile_linked_epp;
let epp = self.get_config_epp_for_throttle(policy).await; let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp); self.check_and_set_epp(epp, change_epp);
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
self.config
.lock()
.await
.select_tunings(power_plugged == 1, policy)
.enabled = false;
self.config.lock().await.write(); self.config.lock().await.write();
self.platform self.platform
.set_platform_profile(policy.into()) .set_platform_profile(policy.into())
@@ -475,9 +494,96 @@ impl CtrlPlatform {
let change_pp = self.config.lock().await.platform_profile_linked_epp; let change_pp = self.config.lock().await.platform_profile_linked_epp;
self.config.lock().await.profile_performance_epp = epp; self.config.lock().await.profile_performance_epp = epp;
self.check_and_set_epp(epp, change_pp); self.check_and_set_epp(epp, change_pp);
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
async fn enable_ppt_group(&self) -> Result<bool, FdoErr> {
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
Ok(self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.enabled)
}
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
async fn set_enable_ppt_group(&mut self, enable: bool) -> Result<(), FdoErr> {
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
// Clone to reduce blocking
let tuning = self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.clone();
for attr in self.attributes.attributes() {
let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() {
// reset stored value
if let Some(tune) = self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.group
.get_mut(&name)
{
let value = if !enable {
attr.default_value().clone()
} else {
tuning
.group
.get(&name)
.map(|v| AttrValue::Integer(*v))
.unwrap_or_else(|| attr.default_value().clone())
};
// restore default
attr.set_current_value(&value)?;
if let AttrValue::Integer(i) = value {
*tune = i
}
}
}
}
if !enable {
// finally, reapply the profile to ensure acpi does the thingy
self.platform.set_platform_profile(profile.into())?;
}
self.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.enabled = enable;
self.config.lock().await.write();
Ok(())
}
} }
impl crate::ZbusRun for CtrlPlatform { impl crate::ZbusRun for CtrlPlatform {
@@ -665,6 +771,7 @@ impl CtrlTask for CtrlPlatform {
error!("Platform: get_platform_profile error: {e}"); error!("Platform: get_platform_profile error: {e}");
}) })
{ {
// TODO: manage this better, shouldn't need to create every time
let attrs = FirmwareAttributes::new(); let attrs = FirmwareAttributes::new();
set_config_or_default( set_config_or_default(
&attrs, &attrs,
@@ -709,6 +816,7 @@ impl CtrlTask for CtrlPlatform {
let epp = ctrl.get_config_epp_for_throttle(profile).await; let epp = ctrl.get_config_epp_for_throttle(profile).await;
ctrl.check_and_set_epp(epp, change_epp); ctrl.check_and_set_epp(epp, change_epp);
ctrl.platform_profile_changed(&signal_ctxt).await.ok(); ctrl.platform_profile_changed(&signal_ctxt).await.ok();
ctrl.enable_ppt_group_changed(&signal_ctxt).await.ok();
let power_plugged = ctrl let power_plugged = ctrl
.power .power
.get_online() .get_online()

View File

@@ -12,6 +12,7 @@ use asusd::ctrl_platform::CtrlPlatform;
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME}; use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad1}; use config_traits::{StdConfig, StdConfigLoad1};
use log::{error, info}; use log::{error, info};
use rog_platform::asus_armoury::FirmwareAttributes;
use rog_platform::platform::RogPlatform; use rog_platform::platform::RogPlatform;
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use zbus::fdo::ObjectManager; use zbus::fdo::ObjectManager;
@@ -69,7 +70,15 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// supported.add_to_server(&mut connection).await; // supported.add_to_server(&mut connection).await;
let platform = RogPlatform::new()?; // TODO: maybe needs async mutex? let platform = RogPlatform::new()?; // TODO: maybe needs async mutex?
let power = AsusPower::new()?; // TODO: maybe needs async mutex? let power = AsusPower::new()?; // TODO: maybe needs async mutex?
start_attributes_zbus(&server, platform, power, config.clone()).await?; let attributes = FirmwareAttributes::new();
start_attributes_zbus(
&server,
platform.clone(),
power.clone(),
attributes.clone(),
config.clone()
)
.await?;
match CtrlFanCurveZbus::new() { match CtrlFanCurveZbus::new() {
Ok(ctrl) => { Ok(ctrl) => {
@@ -82,6 +91,9 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
} }
match CtrlPlatform::new( match CtrlPlatform::new(
platform,
power,
attributes,
config.clone(), config.clone(),
&cfg_path, &cfg_path,
CtrlPlatform::signal_context(&server)? CtrlPlatform::signal_context(&server)?

View File

@@ -6,7 +6,7 @@ After=nvidia-powerd.service systemd-udevd.service
[Service] [Service]
Environment=IS_SERVICE=1 Environment=IS_SERVICE=1
Environment=RUST_LOG="info" Environment=RUST_LOG="debug"
# required to prevent init issues with hid_asus and MCU # required to prevent init issues with hid_asus and MCU
ExecStartPre=/bin/sleep 1 ExecStartPre=/bin/sleep 1
ExecStart=/usr/bin/asusd ExecStart=/usr/bin/asusd
@@ -16,3 +16,4 @@ Type=dbus
BusName=xyz.ljones.Asusd BusName=xyz.ljones.Asusd
SELinuxContext=system_u:system_r:unconfined_t:s0 SELinuxContext=system_u:system_r:unconfined_t:s0
#SELinuxContext=system_u:object_r:modules_object_t:s0 #SELinuxContext=system_u:object_r:modules_object_t:s0
TimeoutSec=10

View File

@@ -1,7 +1,6 @@
[Desktop Entry] [Desktop Entry]
Version=1.0 Version=1.0
Type=Application Type=Application
Name=ROG Control Center Name=ROG Control Center
Comment=Make your ASUS ROG Laptop go Brrrrr! Comment=Make your ASUS ROG Laptop go Brrrrr!
Categories=Settings Categories=Settings

View File

@@ -6,6 +6,7 @@ pub mod setup_system;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use config_traits::StdConfig; use config_traits::StdConfig;
use log::warn;
use rog_dbus::list_iface_blocking; use rog_dbus::list_iface_blocking;
use slint::{ComponentHandle, PhysicalSize, SharedString, Weak}; use slint::{ComponentHandle, PhysicalSize, SharedString, Weak};
@@ -82,6 +83,9 @@ pub fn show_toast(
} }
pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow { pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
slint::set_xdg_app_id("rog-control-center")
.map_err(warn!("Couldn't set application ID: {e:?}"))
.ok();
let ui = MainWindow::new().unwrap(); let ui = MainWindow::new().unwrap();
if let Ok(lock) = config.try_lock() { if let Ok(lock) = config.try_lock() {
let fullscreen = lock.start_fullscreen; let fullscreen = lock.start_fullscreen;

View File

@@ -288,9 +288,18 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
change_platform_profile_on_ac change_platform_profile_on_ac
); );
set_ui_props_async!(handle, platform, SystemPageData, enable_ppt_group);
let platform_copy = platform.clone(); let platform_copy = platform.clone();
handle handle
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform_copy.enable_ppt_group(as bool),
"Applied PPT group settings {}",
"Setting PPT group settings failed"
);
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
SystemPageData(as f32), SystemPageData(as f32),
platform_copy.charge_control_end_threshold(as u8), platform_copy.charge_control_end_threshold(as u8),

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: 2025-01-20 00:43+0000\n" "POT-Creation-Date: 2025-01-21 03:38+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"
@@ -47,198 +47,203 @@ msgctxt "SystemPageData"
msgid "Power" msgid "Power"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:139 #: rog-control-center/ui/pages/system.slint:142
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Power settings" msgid "Power settings"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:144 #: rog-control-center/ui/pages/system.slint:147
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Charge limit" msgid "Charge limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:158 #: rog-control-center/ui/pages/system.slint:161
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Platform Profile" msgid "Platform Profile"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:168 #: rog-control-center/ui/pages/system.slint:171
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Advanced" msgid "Advanced"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:186 #: rog-control-center/ui/pages/system.slint:189
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Armoury settings" msgid "Armoury settings"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:194 #: rog-control-center/ui/pages/system.slint:199
msgctxt "PageSystem"
msgid "Panel Overdrive"
msgstr ""
#: rog-control-center/ui/pages/system.slint:202
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:210
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:224
msgctxt "no_asus_armoury_driver_1" msgctxt "no_asus_armoury_driver_1"
msgid "The asus-armoury driver is not loaded" msgid "The asus-armoury driver is not loaded"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:230 #: rog-control-center/ui/pages/system.slint:205
msgctxt "no_asus_armoury_driver_2" msgctxt "no_asus_armoury_driver_2"
msgid "For advanced features you will require a kernel with this driver added." msgid "For advanced features you will require a kernel with this driver added."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:241 #: rog-control-center/ui/pages/system.slint:216
msgctxt "ppt_warning" msgctxt "PageSystem"
msgid "The following settings may not be safe, please review the help." msgid "Panel Overdrive"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:246 rog-control-center/ui/pages/system.slint:247 #: rog-control-center/ui/pages/system.slint:224
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:232
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:248
msgctxt "ppt_warning"
msgid "The following settings are not applied until the toggle is enabled."
msgstr ""
#: rog-control-center/ui/pages/system.slint:253
msgctxt "ppt_group_enabled"
msgid "Enable Tuning"
msgstr ""
#: rog-control-center/ui/pages/system.slint:262 rog-control-center/ui/pages/system.slint:263
msgctxt "ppt_pl1_spl" msgctxt "ppt_pl1_spl"
msgid "CPU Sustained Power Limit" msgid "CPU Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:248 #: rog-control-center/ui/pages/system.slint:264
msgctxt "ppt_pl1_spl_help" msgctxt "ppt_pl1_spl_help"
msgid "" msgid ""
"Long-term CPU power limit that affects sustained workload performance. " "Long-term CPU power limit that affects sustained workload performance. "
"Higher values may increase heat and power consumption." "Higher values may increase heat and power consumption."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:263 rog-control-center/ui/pages/system.slint:264 #: rog-control-center/ui/pages/system.slint:279 rog-control-center/ui/pages/system.slint:280
msgctxt "ppt_pl2_sppt" msgctxt "ppt_pl2_sppt"
msgid "CPU Turbo Power Limit" msgid "CPU Turbo Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:265 #: rog-control-center/ui/pages/system.slint:281
msgctxt "ppt_pl2_sppt_help" msgctxt "ppt_pl2_sppt_help"
msgid "" msgid ""
"Short-term CPU power limit for boost periods. Controls maximum power during " "Short-term CPU power limit for boost periods. Controls maximum power during "
"brief high-performance bursts." "brief high-performance bursts."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:280 rog-control-center/ui/pages/system.slint:281 #: rog-control-center/ui/pages/system.slint:296 rog-control-center/ui/pages/system.slint:297
msgctxt "ppt_pl3_fppt" msgctxt "ppt_pl3_fppt"
msgid "CPU Fast Burst Power Limit" msgid "CPU Fast Burst Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:282 #: rog-control-center/ui/pages/system.slint:298
msgctxt "ppt_pl3_fppt_help" msgctxt "ppt_pl3_fppt_help"
msgid "" msgid ""
"Ultra-short duration power limit for instantaneous CPU bursts. Affects " "Ultra-short duration power limit for instantaneous CPU bursts. Affects "
"responsiveness during sudden workload spikes." "responsiveness during sudden workload spikes."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:296 rog-control-center/ui/pages/system.slint:297 #: rog-control-center/ui/pages/system.slint:312 rog-control-center/ui/pages/system.slint:313
msgctxt "ppt_fppt" msgctxt "ppt_fppt"
msgid "Fast Package Power Limit" msgid "Fast Package Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:298 #: rog-control-center/ui/pages/system.slint:314
msgctxt "ppt_fppt_help" msgctxt "ppt_fppt_help"
msgid "" msgid ""
"Ultra-short duration power limit for system package. Controls maximum power " "Ultra-short duration power limit for system package. Controls maximum power "
"during millisecond-scale load spikes." "during millisecond-scale load spikes."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:313 rog-control-center/ui/pages/system.slint:314 #: rog-control-center/ui/pages/system.slint:329 rog-control-center/ui/pages/system.slint:330
msgctxt "ppt_apu_sppt" msgctxt "ppt_apu_sppt"
msgid "APU Sustained Power Limit" msgid "APU Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:315 #: rog-control-center/ui/pages/system.slint:331
msgctxt "ppt_apu_sppt_help" msgctxt "ppt_apu_sppt_help"
msgid "" msgid ""
"Long-term power limit for integrated graphics and CPU combined. Affects " "Long-term power limit for integrated graphics and CPU combined. Affects "
"sustained performance of APU-based workloads." "sustained performance of APU-based workloads."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:330 rog-control-center/ui/pages/system.slint:331 #: rog-control-center/ui/pages/system.slint:346 rog-control-center/ui/pages/system.slint:347
msgctxt "ppt_platform_sppt" msgctxt "ppt_platform_sppt"
msgid "Platform Sustained Power Limit" msgid "Platform Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:332 #: rog-control-center/ui/pages/system.slint:348
msgctxt "ppt_platform_sppt_help" msgctxt "ppt_platform_sppt_help"
msgid "" msgid ""
"Overall system power limit for sustained operations. Controls total platform " "Overall system power limit for sustained operations. Controls total platform "
"power consumption over extended periods." "power consumption over extended periods."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:347 rog-control-center/ui/pages/system.slint:348 #: rog-control-center/ui/pages/system.slint:363 rog-control-center/ui/pages/system.slint:364
msgctxt "nv_dynamic_boost" msgctxt "nv_dynamic_boost"
msgid "GPU Power Boost" msgid "GPU Power Boost"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:349 #: rog-control-center/ui/pages/system.slint:365
msgctxt "nv_dynamic_boost_help" msgctxt "nv_dynamic_boost_help"
msgid "" msgid ""
"Additional power allocation for GPU dynamic boost. Higher values increase " "Additional power allocation for GPU dynamic boost. Higher values increase "
"GPU performance but generate more heat." "GPU performance but generate more heat."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:364 rog-control-center/ui/pages/system.slint:365 #: rog-control-center/ui/pages/system.slint:380 rog-control-center/ui/pages/system.slint:381
msgctxt "nv_temp_target" msgctxt "nv_temp_target"
msgid "GPU Temperature Limit" msgid "GPU Temperature Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:366 #: rog-control-center/ui/pages/system.slint:382
msgctxt "nv_temp_target_help" msgctxt "nv_temp_target_help"
msgid "" msgid ""
"Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain " "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain "
"temperature below this limit." "temperature below this limit."
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:417 #: rog-control-center/ui/pages/system.slint:433
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy" msgid "Energy Performance Preference linked to Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:421 #: rog-control-center/ui/pages/system.slint:437
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy" msgid "Change EPP based on Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:429 #: rog-control-center/ui/pages/system.slint:445
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Balanced Policy" msgid "EPP for Balanced Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:439 #: rog-control-center/ui/pages/system.slint:455
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Performance Policy" msgid "EPP for Performance Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:449 #: rog-control-center/ui/pages/system.slint:465
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Quiet Policy" msgid "EPP for Quiet Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:467 #: rog-control-center/ui/pages/system.slint:483
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy for power state" msgid "Throttle Policy for power state"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:473 #: rog-control-center/ui/pages/system.slint:489
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on Battery" msgid "Throttle Policy on Battery"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:483 rog-control-center/ui/pages/system.slint:504 #: rog-control-center/ui/pages/system.slint:499 rog-control-center/ui/pages/system.slint:520
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Enabled" msgid "Enabled"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:494 #: rog-control-center/ui/pages/system.slint:510
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on AC" msgid "Throttle Policy on AC"
msgstr "" msgstr ""
@@ -728,42 +733,42 @@ msgctxt "confirm_reset"
msgid "Are you sure you want to reset this?" msgid "Are you sure you want to reset this?"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:51 #: rog-control-center/ui/main_window.slint:54
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "ROG" msgid "ROG"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:53 #: rog-control-center/ui/main_window.slint:56
msgctxt "Menu1" msgctxt "Menu1"
msgid "System Control" msgid "System Control"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:54 #: rog-control-center/ui/main_window.slint:57
msgctxt "Menu2" msgctxt "Menu2"
msgid "Keyboard Aura" msgid "Keyboard Aura"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:55 #: rog-control-center/ui/main_window.slint:58
msgctxt "Menu3" msgctxt "Menu3"
msgid "AniMe Matrix" msgid "AniMe Matrix"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:56 #: rog-control-center/ui/main_window.slint:59
msgctxt "Menu4" msgctxt "Menu4"
msgid "Fan Curves" msgid "Fan Curves"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:57 #: rog-control-center/ui/main_window.slint:60
msgctxt "Menu5" msgctxt "Menu5"
msgid "App Settings" msgid "App Settings"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:58 #: rog-control-center/ui/main_window.slint:61
msgctxt "Menu6" msgctxt "Menu6"
msgid "About" msgid "About"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:70 #: rog-control-center/ui/main_window.slint:73
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "Quit App" msgid "Quit App"
msgstr "" msgstr ""

View File

@@ -19,7 +19,10 @@ export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData
export component MainWindow inherits Window { export component MainWindow inherits Window {
title: "ROG Control"; title: "ROG Control";
default-font-family: "DejaVu Sans"; default-font-family: "Noto Sans";
default-font-size: 14px;
default-font-weight: 400;
icon: @image-url("../data/rog-control-center.png");
in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true]; in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true];
private property <bool> show_notif; private property <bool> show_notif;
private property <bool> fade_cover; private property <bool> fade_cover;

View File

@@ -1,5 +1,5 @@
import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint"; import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox} from "std-widgets.slint"; import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox, StandardButton} from "std-widgets.slint";
export struct AttrMinMax { export struct AttrMinMax {
min: int, min: int,
@@ -114,6 +114,9 @@ export global SystemPageData {
}; };
callback cb_nv_temp_target(int); callback cb_nv_temp_target(int);
callback cb_default_nv_temp_target(); callback cb_default_nv_temp_target();
in-out property <bool> enable_ppt_group;
callback cb_enable_ppt_group(bool);
} }
export component PageSystem inherits Rectangle { export component PageSystem inherits Rectangle {
@@ -187,6 +190,25 @@ export component PageSystem inherits Rectangle {
} }
} }
if !SystemPageData.asus_armoury_loaded: Rectangle {
border-width: 3px;
border-color: red;
max-height: 30px;
VerticalBox {
Text {
text: @tr("no_asus_armoury_driver_1" => "The asus-armoury driver is not loaded");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
}
}
HorizontalBox { HorizontalBox {
padding: 0px; padding: 0px;
spacing: 10px; spacing: 10px;
@@ -215,30 +237,24 @@ export component PageSystem inherits Rectangle {
} }
} }
if !SystemPageData.asus_armoury_loaded: Rectangle { if SystemPageData.ppt_pl1_spl.val != -1 || SystemPageData.ppt_pl2_sppt.val != -1 || SystemPageData.nv_dynamic_boost.val != -1: HorizontalLayout {
border-width: 3px; padding-right: 10px;
border-color: red; padding-left: 10px;
max-height: 30px; alignment: LayoutAlignment.space-between;
VerticalBox { Rectangle {
height: 32px;
Text { Text {
text: @tr("no_asus_armoury_driver_1" => "The asus-armoury driver is not loaded");
font-size: 16px; font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center; text: @tr("ppt_warning" => "The following settings are not applied until the toggle is enabled.");
}
Text {
text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
} }
} }
}
if SystemPageData.ppt_pl1_spl.val != -1: Rectangle { Switch {
height: 32px; text: @tr("ppt_group_enabled" => "Enable Tuning");
Text { checked <=> SystemPageData.enable_ppt_group;
font-size: 16px; toggled => {
text: @tr("ppt_warning" => "The following settings may not be safe, please review the help."); SystemPageData.cb_enable_ppt_group(SystemPageData.enable_ppt_group)
}
} }
} }
@@ -255,7 +271,7 @@ export component PageSystem inherits Rectangle {
} }
released => { released => {
SystemPageData.ppt_pl1_spl.val = self.value; SystemPageData.ppt_pl1_spl.val = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value)) SystemPageData.cb_ppt_pl1_spl(Math.round(self.value));
} }
} }

View File

@@ -104,4 +104,12 @@ pub trait Platform {
fn platform_profile(&self) -> zbus::Result<PlatformProfile>; fn platform_profile(&self) -> zbus::Result<PlatformProfile>;
#[zbus(property)] #[zbus(property)]
fn set_platform_profile(&self, platform_profile: PlatformProfile) -> zbus::Result<()>; fn set_platform_profile(&self, platform_profile: PlatformProfile) -> zbus::Result<()>;
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
fn enable_ppt_group(&self) -> zbus::Result<bool>;
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
fn set_enable_ppt_group(&self, enable: bool) -> zbus::Result<()>;
} }

View File

@@ -2,6 +2,7 @@ use std::fs::{read_dir, File, OpenOptions};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use log::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
@@ -75,6 +76,15 @@ impl Attribute {
} }
} }
pub fn base_path_exists(&self) -> bool {
let exists = self.base_path.exists();
debug!(
"Attribute path {:?} exits? {exists}",
self.base_path.as_os_str()
);
exists
}
/// Write the `current_value` directly to the attribute path /// Write the `current_value` directly to the attribute path
pub fn set_current_value(&self, new_value: &AttrValue) -> Result<(), PlatformError> { pub fn set_current_value(&self, new_value: &AttrValue) -> Result<(), PlatformError> {
let path = self.base_path.join("current_value"); let path = self.base_path.join("current_value");