ROGCC: better handling of platform profile

This commit is contained in:
Luke Jones
2025-03-03 16:31:43 +13:00
parent f164583792
commit 192e5ccaa3
14 changed files with 190 additions and 46 deletions

View File

@@ -3,7 +3,7 @@ set -e
ROOT_DIR=$(git rev-parse --show-toplevel)
AURA_DATA="${ROOT_DIR}/rog-aura/data/aura_support.ron"
SPEC_FILE="${ROOT_DIR}/distro-packaging/fedora/asusctl.spec"
SPEC_FILE="${ROOT_DIR}/distro-packaging/asusctl.spec"
TRANSLATION="${ROOT_DIR}/rog-control-center/translations/en/rog-control-center.po"
VERSION=$(grep -Pm1 'version = "(\d+.\d+.\d+.*)"' "${ROOT_DIR}/Cargo.toml" | cut -d'"' -f2)

View File

@@ -2,6 +2,11 @@
## [Unreleased]
## [v6.1.9]
### Changed
- ROGCC: better handling of platform profiles
## [v6.1.8]
### Changed

28
Cargo.lock generated
View File

@@ -158,7 +158,7 @@ checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
[[package]]
name = "asusctl"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"dmi_id",
"env_logger",
@@ -177,7 +177,7 @@ dependencies = [
[[package]]
name = "asusd"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"cargo-husky",
"concat-idents",
@@ -204,7 +204,7 @@ dependencies = [
[[package]]
name = "asusd-user"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"config-traits",
"dirs",
@@ -918,7 +918,7 @@ dependencies = [
[[package]]
name = "config-traits"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"log",
"ron",
@@ -1310,7 +1310,7 @@ dependencies = [
[[package]]
name = "dmi_id"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"log",
"udev 0.8.0",
@@ -4542,7 +4542,7 @@ dependencies = [
[[package]]
name = "rog-control-center"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"asusd",
"concat-idents",
@@ -4573,7 +4573,7 @@ dependencies = [
[[package]]
name = "rog_anime"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"dmi_id",
"gif 0.12.0",
@@ -4587,7 +4587,7 @@ dependencies = [
[[package]]
name = "rog_aura"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"dmi_id",
"log",
@@ -4598,7 +4598,7 @@ dependencies = [
[[package]]
name = "rog_dbus"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"asusd",
"rog_anime",
@@ -4612,7 +4612,7 @@ dependencies = [
[[package]]
name = "rog_platform"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"concat-idents",
"inotify",
@@ -4625,7 +4625,7 @@ dependencies = [
[[package]]
name = "rog_profiles"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"log",
"rog_platform",
@@ -4636,7 +4636,7 @@ dependencies = [
[[package]]
name = "rog_scsi"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"ron",
"serde",
@@ -4646,7 +4646,7 @@ dependencies = [
[[package]]
name = "rog_simulators"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"log",
"rog_anime",
@@ -4656,7 +4656,7 @@ dependencies = [
[[package]]
name = "rog_slash"
version = "6.1.8"
version = "6.1.9"
dependencies = [
"dmi_id",
"serde",

View File

@@ -1,5 +1,5 @@
[workspace.package]
version = "6.1.8"
version = "6.1.9"
rust-version = "1.82"
license = "MPL-2.0"
readme = "README.md"

View File

@@ -43,6 +43,8 @@ pub struct Config {
/// The energy_performance_preference for this platform profile
pub profile_balanced_epp: CPUEPP,
/// The energy_performance_preference for this platform profile
pub profile_custom_epp: CPUEPP,
/// The energy_performance_preference for this platform profile
pub profile_performance_epp: CPUEPP,
pub ac_profile_tunings: Tunings,
pub dc_profile_tunings: Tunings,
@@ -79,6 +81,7 @@ impl Default for Config {
profile_quiet_epp: CPUEPP::Power,
profile_balanced_epp: CPUEPP::BalancePower,
profile_performance_epp: CPUEPP::Performance,
profile_custom_epp: CPUEPP::Performance,
ac_profile_tunings: HashMap::default(),
dc_profile_tunings: HashMap::default(),
armoury_settings: HashMap::default(),
@@ -167,6 +170,7 @@ impl From<Config601> for Config {
profile_quiet_epp: c.profile_quiet_epp,
profile_balanced_epp: c.profile_balanced_epp,
profile_performance_epp: c.profile_performance_epp,
profile_custom_epp: c.profile_performance_epp,
last_power_plugged: c.last_power_plugged,
ac_profile_tunings: HashMap::default(),
dc_profile_tunings: HashMap::default(),

View File

@@ -212,6 +212,7 @@ impl CtrlPlatform {
PlatformProfile::Performance => self.config.lock().await.profile_performance_epp,
PlatformProfile::Quiet => self.config.lock().await.profile_quiet_epp,
PlatformProfile::LowPower => self.config.lock().await.profile_quiet_epp,
PlatformProfile::Custom => self.config.lock().await.profile_custom_epp,
}
}
@@ -354,16 +355,7 @@ impl CtrlPlatform {
#[zbus(property)]
fn platform_profile(&self) -> Result<PlatformProfile, FdoErr> {
let choices = self.platform.get_platform_profile_choices()?;
let policy: PlatformProfile = self.platform.get_platform_profile()?.as_str().into();
let policy = if policy == PlatformProfile::LowPower
&& choices.contains(&PlatformProfile::LowPower)
{
PlatformProfile::Quiet
} else {
policy
};
Ok(policy)
}
@@ -382,13 +374,12 @@ impl CtrlPlatform {
self.config.lock().await.write();
let choices = self.platform.get_platform_profile_choices()?;
let policy = if policy == PlatformProfile::Quiet
&& choices.contains(&PlatformProfile::LowPower)
{
PlatformProfile::LowPower
} else {
policy
};
if !choices.contains(&PlatformProfile::LowPower) {
return Err(FdoErr::NotSupported(format!(
"RogPlatform: platform_profile: {} not supported",
policy
)));
}
self.platform
.set_platform_profile(policy.into())
@@ -651,6 +642,7 @@ impl ReloadAndNotify for CtrlPlatform {
PlatformProfile::Performance => data.profile_performance_epp,
PlatformProfile::Quiet => data.profile_quiet_epp,
PlatformProfile::LowPower => data.profile_quiet_epp,
PlatformProfile::Custom => data.profile_custom_epp,
};
warn!("setting epp to {epp:?}");
self.check_and_set_epp(epp, true);

View File

@@ -10,6 +10,7 @@ impl From<Profile> for PlatformProfile {
Profile::Performance => PlatformProfile::Performance,
Profile::Quiet => PlatformProfile::Quiet,
Profile::LowPower => PlatformProfile::LowPower,
Profile::Custom => PlatformProfile::Custom,
}
}
}
@@ -21,6 +22,7 @@ impl From<PlatformProfile> for Profile {
PlatformProfile::Performance => Profile::Performance,
PlatformProfile::Quiet => Profile::Quiet,
PlatformProfile::LowPower => Profile::LowPower,
PlatformProfile::Custom => Profile::Custom,
}
}
}

View File

@@ -138,7 +138,6 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
else {
return;
};
dbg!(&quiet);
update_fan_data(handle, balanced, perf, quiet);
let handle_next1 = handle_copy.clone();

View File

@@ -6,7 +6,7 @@ use rog_dbus::asus_armoury::AsusArmouryProxy;
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
use rog_platform::asus_armoury::FirmwareAttribute;
use rog_platform::platform::Properties;
use slint::ComponentHandle;
use slint::{ComponentHandle, Model, ModelRc, SharedString, VecModel};
use super::show_toast;
use crate::config::Config;
@@ -297,7 +297,59 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
charge_control_end_threshold
);
set_ui_props_async!(handle, platform, SystemPageData, platform_profile);
let platform_copy = platform.clone();
if let Ok(mut value) = platform.platform_profile_choices().await {
handle
.upgrade_in_event_loop(move |handle| {
value.sort();
let translate: Vec<SharedString> = handle
.global::<SystemPageData>()
.get_platform_profile_choices()
.iter()
.collect();
let mut indexes = Vec::new();
let strings: Vec<SharedString> = value
.iter()
.filter_map(|p| {
let index = i32::from(*p) as usize;
if index < translate.len() {
indexes.push(index as i32);
Some(translate[index].clone())
} else {
None
}
})
.collect();
let choices = ModelRc::new(VecModel::from(strings));
handle
.global::<SystemPageData>()
.set_platform_profile_choices(choices);
handle
.global::<SystemPageData>()
.set_platform_profile_indexes(ModelRc::from(indexes.as_slice()));
// Set current only after setting the choices up
let handle = handle.as_weak();
tokio::spawn(async move {
if let Ok(value) = platform_copy.platform_profile().await {
let profile_value = <i32>::from(value);
handle
.upgrade_in_event_loop(move |handle| {
if let Some(position) =
indexes.iter().position(|&index| index == profile_value)
{
handle
.global::<SystemPageData>()
.set_platform_profile(position as i32);
}
})
.ok();
}
});
})
.ok();
}
set_ui_props_async!(
handle,
platform,
@@ -333,6 +385,54 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
handle
.upgrade_in_event_loop(move |handle| {
debug!("Setting up system page standard callbacks");
let handle_copy = handle.as_weak();
let proxy_copy = platform_copy.clone();
handle
.global::<SystemPageData>()
.on_cb_platform_profile(move |value| {
let proxy_copy = proxy_copy.clone();
let handle_copy = handle_copy.clone();
tokio::spawn(async move {
show_toast(
format!("Throttle policy set to {}", value).into(),
"Setting Throttle policy failed".into(),
handle_copy,
proxy_copy.set_platform_profile(value.into()).await,
);
});
});
let handle_copy = handle.as_weak();
let proxy_copy = platform_copy.clone();
// spawn required since the while let never exits
tokio::spawn(async move {
let mut x = proxy_copy.receive_platform_profile_changed().await;
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
.upgrade_in_event_loop(move |handle| {
let indexes = handle
.global::<SystemPageData>()
.get_platform_profile_indexes();
handle
.global::<SystemPageData>()
.set_platform_profile(out as i32);
let profile_value = <i32>::from(out);
if let Some(position) =
indexes.iter().position(|index| index == profile_value)
{
handle
.global::<SystemPageData>()
.set_platform_profile(position as i32);
}
})
.ok();
}
}
});
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform_copy.enable_ppt_group(as bool),
@@ -346,12 +446,12 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
"Charge limit successfully set to {}",
"Setting Charge limit failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform_copy.platform_profile(.into()),
"Throttle policy set to {}",
"Setting Throttle policy failed"
);
// set_ui_callbacks!(handle,
// SystemPageData(as i32),
// platform_copy.platform_profile(.into()),
// "Throttle policy set to {}",
// "Setting Throttle policy failed"
// );
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform_copy.profile_balanced_epp(.into()),

View File

@@ -17,7 +17,10 @@ export global SystemPageData {
in-out property <float> charge_control_end_threshold: 30;
callback cb_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> platform_profile: 0;
in-out property <[string]> platform_profile_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
in-out property <[string]> platform_profile_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet"), @tr("LowPower")];
// The dropdown list index is used to index in to this and find the correct
// value for platform profile
in-out property <[int]> platform_profile_indexes: [0, 1, 2, 3];
callback cb_platform_profile(int);
in-out property <[string]> energy_performance_choices: [
@tr("Default"),
@@ -169,7 +172,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile];
model <=> SystemPageData.platform_profile_choices;
selected => {
SystemPageData.cb_platform_profile(SystemPageData.platform_profile)
SystemPageData.cb_platform_profile(SystemPageData.platform_profile_indexes[SystemPageData.platform_profile])
}
}

View File

@@ -5,13 +5,14 @@ export enum Profile {
Performance,
Quiet,
LowPower,
Custom
}
export enum FanType {
CPU,
Middle,
GPU,
}
}
export global FanPageData {
in-out property <[Profile]> available_profiles: [Profile.Balanced, Profile.Performance, Profile.Quiet];

View File

@@ -208,6 +208,7 @@ impl From<PlatformProfile> for CPUEPP {
PlatformProfile::Performance => CPUEPP::Performance,
PlatformProfile::Quiet => CPUEPP::Power,
PlatformProfile::LowPower => CPUEPP::Power,
PlatformProfile::Custom => CPUEPP::BalancePower,
}
}
}

View File

@@ -186,6 +186,7 @@ impl Display for GpuMode {
Debug,
PartialEq,
Eq,
Ord,
PartialOrd,
Hash,
Clone,
@@ -199,6 +200,7 @@ pub enum PlatformProfile {
Performance = 1,
Quiet = 2,
LowPower = 3,
Custom = 4,
}
impl PlatformProfile {
@@ -212,8 +214,7 @@ impl PlatformProfile {
Self::Quiet
}
}
Self::Quiet => Self::Balanced,
Self::LowPower => Self::Balanced,
Self::Quiet | Self::LowPower | Self::Custom => Self::Balanced,
}
}
}
@@ -225,6 +226,7 @@ impl From<i32> for PlatformProfile {
1 => Self::Performance,
2 => Self::Quiet,
3 => Self::LowPower,
4 => Self::Custom,
_ => {
warn!("Unknown number for PlatformProfile: {}", num);
Self::Balanced
@@ -246,6 +248,7 @@ impl From<&PlatformProfile> for &str {
PlatformProfile::Performance => "performance",
PlatformProfile::Quiet => "quiet",
PlatformProfile::LowPower => "low-power",
PlatformProfile::Custom => "custom",
}
}
}
@@ -277,6 +280,7 @@ impl std::str::FromStr for PlatformProfile {
"performance" => Ok(PlatformProfile::Performance),
"quiet" => Ok(PlatformProfile::Quiet),
"low-power" => Ok(PlatformProfile::LowPower),
"custom" => Ok(PlatformProfile::Custom),
_ => Err(PlatformError::NotSupported),
}
}
@@ -289,6 +293,7 @@ impl From<&str> for PlatformProfile {
"performance" => PlatformProfile::Performance,
"quiet" => PlatformProfile::Quiet,
"low-power" => PlatformProfile::LowPower,
"custom" => PlatformProfile::Custom,
_ => {
warn!("{profile} is unknown, using ThrottlePolicy::Balanced");
PlatformProfile::Balanced

View File

@@ -113,6 +113,7 @@ pub struct FanCurveProfiles {
pub balanced: Vec<CurveData>,
pub performance: Vec<CurveData>,
pub quiet: Vec<CurveData>,
pub custom: Vec<CurveData>,
}
impl FanCurveProfiles {
@@ -146,6 +147,7 @@ impl FanCurveProfiles {
PlatformProfile::Balanced => self.balanced = curves,
PlatformProfile::Performance => self.performance = curves,
PlatformProfile::Quiet | PlatformProfile::LowPower => self.quiet = curves,
PlatformProfile::Custom => self.custom = curves,
}
Ok(())
}
@@ -182,6 +184,7 @@ impl FanCurveProfiles {
PlatformProfile::Balanced => &mut self.balanced,
PlatformProfile::Performance => &mut self.performance,
PlatformProfile::Quiet | PlatformProfile::LowPower => &mut self.quiet,
PlatformProfile::Custom => &mut self.custom,
};
for fan in fans.iter().filter(|f| !f.enabled) {
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
@@ -213,6 +216,11 @@ impl FanCurveProfiles {
curve.enabled = enabled;
}
}
PlatformProfile::Custom => {
for curve in self.custom.iter_mut() {
curve.enabled = enabled;
}
}
}
}
@@ -247,6 +255,14 @@ impl FanCurveProfiles {
}
}
}
PlatformProfile::Custom => {
for curve in self.custom.iter_mut() {
if curve.fan == fan {
curve.enabled = enabled;
break;
}
}
}
}
}
@@ -255,6 +271,7 @@ impl FanCurveProfiles {
PlatformProfile::Balanced => &self.balanced,
PlatformProfile::Performance => &self.performance,
PlatformProfile::Quiet | PlatformProfile::LowPower => &self.quiet,
PlatformProfile::Custom => &self.custom,
}
}
@@ -281,6 +298,13 @@ impl FanCurveProfiles {
}
}
}
PlatformProfile::Custom => {
for this_curve in self.custom.iter() {
if this_curve.fan == pu {
return Some(this_curve);
}
}
}
}
None
}
@@ -315,6 +339,14 @@ impl FanCurveProfiles {
}
}
}
PlatformProfile::Custom => {
for this_curve in self.custom.iter_mut() {
if this_curve.fan == curve.fan {
*this_curve = curve;
break;
}
}
}
}
Ok(())
}