mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Move entirely to using only platform-profile
throttle_thermal_policy is not ideal anymore and may be removed from kernel in the future.
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
use rog_platform::platform::PlatformProfile;
|
||||
use rog_profiles::FanCurvePU;
|
||||
|
||||
use crate::{FanType, Profile};
|
||||
|
||||
impl From<Profile> for ThrottlePolicy {
|
||||
impl From<Profile> for PlatformProfile {
|
||||
fn from(value: Profile) -> Self {
|
||||
match value {
|
||||
Profile::Balanced => ThrottlePolicy::Balanced,
|
||||
Profile::Performance => ThrottlePolicy::Performance,
|
||||
Profile::Quiet => ThrottlePolicy::Quiet
|
||||
Profile::Balanced => PlatformProfile::Balanced,
|
||||
Profile::Performance => PlatformProfile::Performance,
|
||||
Profile::Quiet => PlatformProfile::Quiet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ThrottlePolicy> for Profile {
|
||||
fn from(value: ThrottlePolicy) -> Self {
|
||||
impl From<PlatformProfile> for Profile {
|
||||
fn from(value: PlatformProfile) -> Self {
|
||||
match value {
|
||||
ThrottlePolicy::Balanced => Profile::Balanced,
|
||||
ThrottlePolicy::Performance => Profile::Performance,
|
||||
ThrottlePolicy::Quiet => Profile::Quiet
|
||||
PlatformProfile::Balanced => Profile::Balanced,
|
||||
PlatformProfile::Performance => Profile::Performance,
|
||||
PlatformProfile::Quiet => Profile::Quiet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use log::{error, info};
|
||||
use rog_dbus::zbus_fan_curves::FanCurvesProxy;
|
||||
use rog_platform::platform::ThrottlePolicy;
|
||||
use rog_platform::platform::PlatformProfile;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use slint::{ComponentHandle, Model, Weak};
|
||||
|
||||
@@ -109,21 +109,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
let handle_copy = handle.clone();
|
||||
// Do initial setup
|
||||
let Ok(balanced) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Balanced)
|
||||
.fan_curve_data(PlatformProfile::Balanced)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(perf) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Performance)
|
||||
.fan_curve_data(PlatformProfile::Performance)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(quiet) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Quiet)
|
||||
.fan_curve_data(PlatformProfile::Quiet)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
@@ -144,21 +144,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
return;
|
||||
}
|
||||
let Ok(balanced) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Balanced)
|
||||
.fan_curve_data(PlatformProfile::Balanced)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(perf) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Performance)
|
||||
.fan_curve_data(PlatformProfile::Performance)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(quiet) = fans
|
||||
.fan_curve_data(ThrottlePolicy::Quiet)
|
||||
.fan_curve_data(PlatformProfile::Quiet)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
else {
|
||||
|
||||
@@ -28,8 +28,7 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
// Null everything before the setup step
|
||||
ui.global::<SystemPageData>()
|
||||
.set_charge_control_end_threshold(-1.0);
|
||||
ui.global::<SystemPageData>()
|
||||
.set_throttle_thermal_policy(-1);
|
||||
ui.global::<SystemPageData>().set_platform_profile(-1);
|
||||
ui.global::<SystemPageData>().set_panel_overdrive(-1);
|
||||
ui.global::<SystemPageData>().set_boot_sound(-1);
|
||||
ui.global::<SystemPageData>().set_mini_led_mode(-1);
|
||||
@@ -204,11 +203,11 @@ macro_rules! setup_minmax_external {
|
||||
let proxy_copy = $attr.clone();
|
||||
let platform_proxy_copy = $platform.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut x = platform_proxy_copy.receive_throttle_thermal_policy_changed().await;
|
||||
let mut x = platform_proxy_copy.receive_platform_profile_changed().await;
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
while let Some(e) = x.next().await {
|
||||
if let Ok(_) = e.get().await {
|
||||
debug!("receive_throttle_thermal_policy_changed, getting new {}", stringify!(attr));
|
||||
debug!("receive_platform_profile_changed, getting new {}", stringify!(attr));
|
||||
let min = proxy_copy.min_value().await.unwrap();
|
||||
let max = proxy_copy.max_value().await.unwrap();
|
||||
let val = proxy_copy.current_value().await.unwrap() as f32;
|
||||
@@ -259,24 +258,34 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
|
||||
charge_control_end_threshold
|
||||
);
|
||||
|
||||
set_ui_props_async!(handle, platform, SystemPageData, throttle_thermal_policy);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_linked_epp);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, throttle_balanced_epp);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, throttle_performance_epp);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, throttle_quiet_epp);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_battery);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, platform_profile);
|
||||
set_ui_props_async!(
|
||||
handle,
|
||||
platform,
|
||||
SystemPageData,
|
||||
change_throttle_policy_on_battery
|
||||
platform_profile_linked_epp
|
||||
);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_ac);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, profile_balanced_epp);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, profile_performance_epp);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, profile_quiet_epp);
|
||||
set_ui_props_async!(
|
||||
handle,
|
||||
platform,
|
||||
SystemPageData,
|
||||
change_throttle_policy_on_ac
|
||||
platform_profile_on_battery
|
||||
);
|
||||
set_ui_props_async!(
|
||||
handle,
|
||||
platform,
|
||||
SystemPageData,
|
||||
change_platform_profile_on_battery
|
||||
);
|
||||
set_ui_props_async!(handle, platform, SystemPageData, platform_profile_on_ac);
|
||||
set_ui_props_async!(
|
||||
handle,
|
||||
platform,
|
||||
SystemPageData,
|
||||
change_platform_profile_on_ac
|
||||
);
|
||||
|
||||
let platform_copy = platform.clone();
|
||||
@@ -290,56 +299,56 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
|
||||
);
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as i32),
|
||||
platform_copy.throttle_thermal_policy(.into()),
|
||||
platform_copy.platform_profile(.into()),
|
||||
"Throttle policy set to {}",
|
||||
"Setting Throttle policy failed"
|
||||
);
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as i32),
|
||||
platform_copy.throttle_balanced_epp(.into()),
|
||||
platform_copy.profile_balanced_epp(.into()),
|
||||
"Throttle policy EPP set to {}",
|
||||
"Setting Throttle policy EPP failed"
|
||||
);
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as i32),
|
||||
platform_copy.throttle_performance_epp(.into()),
|
||||
platform_copy.profile_performance_epp(.into()),
|
||||
"Throttle policy EPP set to {}",
|
||||
"Setting Throttle policy EPP failed"
|
||||
);
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as i32),
|
||||
platform_copy.throttle_quiet_epp(.into()),
|
||||
platform_copy.profile_quiet_epp(.into()),
|
||||
"Throttle policy EPP set to {}",
|
||||
"Setting Throttle policy EPP failed"
|
||||
);
|
||||
set_ui_callbacks!(
|
||||
handle,
|
||||
SystemPageData(),
|
||||
platform_copy.throttle_policy_linked_epp(),
|
||||
platform_copy.platform_profile_linked_epp(),
|
||||
"Throttle policy linked to EPP: {}",
|
||||
"Setting Throttle policy linked to EPP failed"
|
||||
);
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as i32),
|
||||
platform_copy.throttle_policy_on_ac(.into()),
|
||||
platform_copy.platform_profile_on_ac(.into()),
|
||||
"Throttle policy on AC set to {}",
|
||||
"Setting Throttle policy on AC failed"
|
||||
);
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as bool),
|
||||
platform_copy.change_throttle_policy_on_ac(.into()),
|
||||
platform_copy.change_platform_profile_on_ac(.into()),
|
||||
"Throttle policy on AC enabled: {}",
|
||||
"Setting Throttle policy on AC failed"
|
||||
);
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as i32),
|
||||
platform_copy.throttle_policy_on_battery(.into()),
|
||||
platform_copy.platform_profile_on_battery(.into()),
|
||||
"Throttle policy on abttery set to {}",
|
||||
"Setting Throttle policy on battery failed"
|
||||
);
|
||||
set_ui_callbacks!(handle,
|
||||
SystemPageData(as bool),
|
||||
platform_copy.change_throttle_policy_on_battery(.into()),
|
||||
platform_copy.change_platform_profile_on_battery(.into()),
|
||||
"Throttle policy on battery enabled: {}",
|
||||
"Setting Throttle policy on AC failed"
|
||||
);
|
||||
|
||||
@@ -15,9 +15,9 @@ export struct AttrPossible {
|
||||
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> throttle_thermal_policy: 0;
|
||||
in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
|
||||
callback cb_throttle_thermal_policy(int);
|
||||
in-out property <int> platform_profile: 0;
|
||||
in-out property <[string]> platform_profile_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
|
||||
callback cb_platform_profile(int);
|
||||
in-out property <[string]> energy_performance_choices: [
|
||||
@tr("Default"),
|
||||
@tr("Performance"),
|
||||
@@ -25,23 +25,23 @@ export global SystemPageData {
|
||||
@tr("BalancePower"),
|
||||
@tr("Power")
|
||||
];
|
||||
in-out property <int> throttle_balanced_epp: 0;
|
||||
callback cb_throttle_balanced_epp(int);
|
||||
in-out property <int> throttle_performance_epp: 0;
|
||||
callback cb_throttle_performance_epp(int);
|
||||
in-out property <int> throttle_quiet_epp: 0;
|
||||
callback cb_throttle_quiet_epp(int);
|
||||
in-out property <int> profile_balanced_epp: 0;
|
||||
callback cb_profile_balanced_epp(int);
|
||||
in-out property <int> profile_performance_epp: 0;
|
||||
callback cb_profile_performance_epp(int);
|
||||
in-out property <int> profile_quiet_epp: 0;
|
||||
callback cb_profile_quiet_epp(int);
|
||||
// if the EPP should change with throttle
|
||||
in-out property <bool> throttle_policy_linked_epp: true;
|
||||
callback cb_throttle_policy_linked_epp(bool);
|
||||
in-out property <int> throttle_policy_on_ac: 0;
|
||||
callback cb_throttle_policy_on_ac(int);
|
||||
in-out property <bool> change_throttle_policy_on_ac: true;
|
||||
callback cb_change_throttle_policy_on_ac(bool);
|
||||
in-out property <int> throttle_policy_on_battery: 0;
|
||||
callback cb_throttle_policy_on_battery(int);
|
||||
in-out property <bool> change_throttle_policy_on_battery: true;
|
||||
callback cb_change_throttle_policy_on_battery(bool);
|
||||
in-out property <bool> platform_profile_linked_epp: true;
|
||||
callback cb_platform_profile_linked_epp(bool);
|
||||
in-out property <int> platform_profile_on_ac: 0;
|
||||
callback cb_platform_profile_on_ac(int);
|
||||
in-out property <bool> change_platform_profile_on_ac: true;
|
||||
callback cb_change_platform_profile_on_ac(bool);
|
||||
in-out property <int> platform_profile_on_battery: 0;
|
||||
callback cb_platform_profile_on_battery(int);
|
||||
in-out property <bool> change_platform_profile_on_battery: true;
|
||||
callback cb_change_platform_profile_on_battery(bool);
|
||||
//
|
||||
in-out property <int> panel_overdrive;
|
||||
callback cb_panel_overdrive(int);
|
||||
@@ -152,15 +152,15 @@ export component PageSystem inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
if SystemPageData.throttle_thermal_policy != -1: HorizontalLayout {
|
||||
if SystemPageData.platform_profile != -1: HorizontalLayout {
|
||||
spacing: 10px;
|
||||
SystemDropdown {
|
||||
text: @tr("Throttle Policy");
|
||||
current_index <=> SystemPageData.throttle_thermal_policy;
|
||||
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy];
|
||||
model <=> SystemPageData.throttle_policy_choices;
|
||||
text: @tr("Platform Profile");
|
||||
current_index <=> SystemPageData.platform_profile;
|
||||
current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile];
|
||||
model <=> SystemPageData.platform_profile_choices;
|
||||
selected => {
|
||||
SystemPageData.cb_throttle_thermal_policy(SystemPageData.throttle_thermal_policy)
|
||||
SystemPageData.cb_platform_profile(SystemPageData.platform_profile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,39 +419,39 @@ export component PageSystem inherits Rectangle {
|
||||
|
||||
SystemToggle {
|
||||
text: @tr("Change EPP based on Throttle Policy");
|
||||
checked <=> SystemPageData.throttle_policy_linked_epp;
|
||||
checked <=> SystemPageData.platform_profile_linked_epp;
|
||||
toggled => {
|
||||
SystemPageData.cb_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp)
|
||||
SystemPageData.cb_platform_profile_linked_epp(SystemPageData.platform_profile_linked_epp)
|
||||
}
|
||||
}
|
||||
|
||||
SystemDropdown {
|
||||
text: @tr("EPP for Balanced Policy");
|
||||
current_index <=> SystemPageData.throttle_balanced_epp;
|
||||
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp];
|
||||
current_index <=> SystemPageData.profile_balanced_epp;
|
||||
current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_balanced_epp];
|
||||
model <=> SystemPageData.energy_performance_choices;
|
||||
selected => {
|
||||
SystemPageData.cb_throttle_balanced_epp(SystemPageData.throttle_balanced_epp)
|
||||
SystemPageData.cb_profile_balanced_epp(SystemPageData.profile_balanced_epp)
|
||||
}
|
||||
}
|
||||
|
||||
SystemDropdown {
|
||||
text: @tr("EPP for Performance Policy");
|
||||
current_index <=> SystemPageData.throttle_performance_epp;
|
||||
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp];
|
||||
current_index <=> SystemPageData.profile_performance_epp;
|
||||
current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_performance_epp];
|
||||
model <=> SystemPageData.energy_performance_choices;
|
||||
selected => {
|
||||
SystemPageData.cb_throttle_performance_epp(SystemPageData.throttle_performance_epp)
|
||||
SystemPageData.cb_profile_performance_epp(SystemPageData.profile_performance_epp)
|
||||
}
|
||||
}
|
||||
|
||||
SystemDropdown {
|
||||
text: @tr("EPP for Quiet Policy");
|
||||
current_index <=> SystemPageData.throttle_quiet_epp;
|
||||
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp];
|
||||
current_index <=> SystemPageData.profile_quiet_epp;
|
||||
current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_quiet_epp];
|
||||
model <=> SystemPageData.energy_performance_choices;
|
||||
selected => {
|
||||
SystemPageData.cb_throttle_quiet_epp(SystemPageData.throttle_quiet_epp)
|
||||
SystemPageData.cb_profile_quiet_epp(SystemPageData.profile_quiet_epp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -471,19 +471,19 @@ export component PageSystem inherits Rectangle {
|
||||
spacing: 10px;
|
||||
SystemDropdown {
|
||||
text: @tr("Throttle Policy on Battery");
|
||||
current_index <=> SystemPageData.throttle_policy_on_battery;
|
||||
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery];
|
||||
model <=> SystemPageData.throttle_policy_choices;
|
||||
current_index <=> SystemPageData.platform_profile_on_battery;
|
||||
current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_battery];
|
||||
model <=> SystemPageData.platform_profile_choices;
|
||||
selected => {
|
||||
SystemPageData.cb_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery)
|
||||
SystemPageData.cb_platform_profile_on_battery(SystemPageData.platform_profile_on_battery)
|
||||
}
|
||||
}
|
||||
|
||||
SystemToggle {
|
||||
text: @tr("Enabled");
|
||||
checked <=> SystemPageData.change_throttle_policy_on_battery;
|
||||
checked <=> SystemPageData.change_platform_profile_on_battery;
|
||||
toggled => {
|
||||
SystemPageData.cb_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery);
|
||||
SystemPageData.cb_change_platform_profile_on_battery(SystemPageData.change_platform_profile_on_battery);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,19 +492,19 @@ export component PageSystem inherits Rectangle {
|
||||
spacing: 10px;
|
||||
SystemDropdown {
|
||||
text: @tr("Throttle Policy on AC");
|
||||
current_index <=> SystemPageData.throttle_policy_on_ac;
|
||||
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac];
|
||||
model <=> SystemPageData.throttle_policy_choices;
|
||||
current_index <=> SystemPageData.platform_profile_on_ac;
|
||||
current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_ac];
|
||||
model <=> SystemPageData.platform_profile_choices;
|
||||
selected => {
|
||||
SystemPageData.cb_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac)
|
||||
SystemPageData.cb_platform_profile_on_ac(SystemPageData.platform_profile_on_ac)
|
||||
}
|
||||
}
|
||||
|
||||
SystemToggle {
|
||||
text: @tr("Enabled");
|
||||
checked <=> SystemPageData.change_throttle_policy_on_ac;
|
||||
checked <=> SystemPageData.change_platform_profile_on_ac;
|
||||
toggled => {
|
||||
SystemPageData.cb_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac);
|
||||
SystemPageData.cb_change_platform_profile_on_ac(SystemPageData.change_platform_profile_on_ac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user