From b9296862df6e3629dda97f8beaf08b0b37f581e3 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 19 Jan 2025 21:34:38 +1300 Subject: [PATCH] Move entirely to using only platform-profile throttle_thermal_policy is not ideal anymore and may be removed from kernel in the future. --- CHANGELOG.md | 6 + asusctl/src/cli_opts.rs | 4 +- asusctl/src/fan_curve_cli.rs | 4 +- asusctl/src/main.rs | 14 +- asusd/src/asus_armoury.rs | 14 +- asusd/src/config.rs | 88 +++++----- asusd/src/ctrl_fancurves.rs | 67 ++++---- asusd/src/ctrl_platform.rs | 198 +++++++++++----------- rog-control-center/src/types/fan_types.rs | 20 +-- rog-control-center/src/ui/setup_fans.rs | 14 +- rog-control-center/src/ui/setup_system.rs | 53 +++--- rog-control-center/ui/pages/system.slint | 96 +++++------ rog-dbus/src/zbus_fan_curves.rs | 14 +- rog-dbus/src/zbus_platform.rs | 43 ++--- rog-platform/src/asus_armoury.rs | 1 - rog-platform/src/cpu.rs | 12 +- rog-platform/src/platform.rs | 75 ++++---- rog-profiles/src/lib.rs | 60 +++---- 18 files changed, 404 insertions(+), 379 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29f54701..23202bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +## [v6.1.0-rc6] + +### Changed +- Two small fixes, one for `low-power` profile name, and one for base gpu tdp +- Move to using platform_profile api only (no throttle_thermal_policy) + ## [v6.1.0-rc5] ### Changed diff --git a/asusctl/src/cli_opts.rs b/asusctl/src/cli_opts.rs index b907b273..1e9919f6 100644 --- a/asusctl/src/cli_opts.rs +++ b/asusctl/src/cli_opts.rs @@ -1,5 +1,5 @@ use gumdrop::Options; -use rog_platform::platform::ThrottlePolicy; +use rog_platform::platform::PlatformProfile; use crate::anime_cli::AnimeCommand; use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin}; @@ -71,7 +71,7 @@ pub struct ProfileCommand { pub profile_get: bool, #[options(meta = "", help = "set the active profile")] - pub profile_set: Option + pub profile_set: Option } #[derive(Options)] diff --git a/asusctl/src/fan_curve_cli.rs b/asusctl/src/fan_curve_cli.rs index cbde802e..cfdc2718 100644 --- a/asusctl/src/fan_curve_cli.rs +++ b/asusctl/src/fan_curve_cli.rs @@ -1,5 +1,5 @@ use gumdrop::Options; -use rog_platform::platform::ThrottlePolicy; +use rog_platform::platform::PlatformProfile; use rog_profiles::fan_curve_set::CurveData; use rog_profiles::FanCurvePU; @@ -18,7 +18,7 @@ pub struct FanCurveCommand { meta = "", help = "profile to modify fan-curve for. Shows data if no options provided" )] - pub mod_profile: Option, + pub mod_profile: Option, #[options( meta = "", diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 78da90d2..2f5e18a0 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -22,7 +22,7 @@ use rog_dbus::zbus_aura::AuraProxyBlocking; use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; use rog_dbus::zbus_platform::PlatformProxyBlocking; use rog_dbus::zbus_slash::SlashProxyBlocking; -use rog_platform::platform::{Properties, ThrottlePolicy}; +use rog_platform::platform::{PlatformProfile, Properties}; use rog_profiles::error::ProfileError; use rog_scsi::AuraMode; use rog_slash::SlashMode; @@ -918,16 +918,16 @@ fn handle_throttle_profile( } let proxy = PlatformProxyBlocking::new(conn)?; - let current = proxy.throttle_thermal_policy()?; + let current = proxy.platform_profile()?; if cmd.next { - proxy.set_throttle_thermal_policy(current.next())?; + proxy.set_platform_profile(current.next())?; } else if let Some(profile) = cmd.profile_set { - proxy.set_throttle_thermal_policy(profile)?; + proxy.set_platform_profile(profile)?; } if cmd.list { - let res = ThrottlePolicy::list(); + let res = PlatformProfile::list(); for p in &res { println!("{:?}", p); } @@ -974,7 +974,7 @@ fn handle_fan_curve( let plat_proxy = PlatformProxyBlocking::new(conn)?; if cmd.get_enabled { - let profile = plat_proxy.throttle_thermal_policy()?; + let profile = plat_proxy.platform_profile()?; let curves = fan_proxy.fan_curve_data(profile)?; for curve in curves.iter() { println!("{}", String::from(curve)); @@ -982,7 +982,7 @@ fn handle_fan_curve( } if cmd.default { - let active = plat_proxy.throttle_thermal_policy()?; + let active = plat_proxy.platform_profile()?; fan_proxy.set_curves_to_defaults(active)?; } diff --git a/asusd/src/asus_armoury.rs b/asusd/src/asus_armoury.rs index 7ce63804..fcc68589 100644 --- a/asusd/src/asus_armoury.rs +++ b/asusd/src/asus_armoury.rs @@ -1,11 +1,10 @@ -use std::str::FromStr; use std::sync::Arc; use ::zbus::export::futures_util::lock::Mutex; use config_traits::StdConfig; use log::{debug, error, info}; use rog_platform::asus_armoury::{AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes}; -use rog_platform::platform::{RogPlatform, ThrottlePolicy}; +use rog_platform::platform::{PlatformProfile, RogPlatform}; use rog_platform::power::AsusPower; use serde::{Deserialize, Serialize}; use zbus::object_server::SignalEmitter; @@ -100,8 +99,7 @@ impl AsusArmouryAttribute { impl crate::Reloadable for AsusArmouryAttribute { async fn reload(&mut self) -> Result<(), RogError> { info!("Reloading {}", self.attr.name()); - let profile: ThrottlePolicy = - ThrottlePolicy::from_str(self.platform.get_platform_profile()?.as_str())?; + let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let power_plugged = self .power .get_online() @@ -182,8 +180,7 @@ impl AsusArmouryAttribute { async fn restore_default(&self) -> fdo::Result<()> { self.attr.restore_default()?; if self.name().is_ppt() { - let profile: ThrottlePolicy = - ThrottlePolicy::from_str(self.platform.get_platform_profile()?.as_str())?; + let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let power_plugged = self .power .get_online() @@ -257,8 +254,7 @@ impl AsusArmouryAttribute { })?; if self.name().is_ppt() { - let profile: ThrottlePolicy = - ThrottlePolicy::from_str(self.platform.get_platform_profile()?.as_str())?; + let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let power_plugged = self .power @@ -337,7 +333,7 @@ pub async fn set_config_or_default( attrs: &FirmwareAttributes, config: &mut Config, power_plugged: bool, - profile: ThrottlePolicy + profile: PlatformProfile ) { for attr in attrs.attributes().iter() { let name: FirmwareAttribute = attr.name().into(); diff --git a/asusd/src/config.rs b/asusd/src/config.rs index 0698284f..d0171a63 100644 --- a/asusd/src/config.rs +++ b/asusd/src/config.rs @@ -3,11 +3,11 @@ use std::collections::HashMap; use config_traits::{StdConfig, StdConfigLoad1}; use rog_platform::asus_armoury::FirmwareAttribute; use rog_platform::cpu::CPUEPP; -use rog_platform::platform::ThrottlePolicy; +use rog_platform::platform::PlatformProfile; use serde::{Deserialize, Serialize}; const CONFIG_FILE: &str = "asusd.ron"; -type Tunings = HashMap>; +type Tunings = HashMap>; #[derive(Deserialize, Serialize, PartialEq)] pub struct Config { @@ -22,22 +22,22 @@ pub struct Config { /// An optional command/script to run when power is changed to battery pub bat_command: String, /// Set true if energy_performance_preference should be set if the - /// throttle/platform profile is changed - pub throttle_policy_linked_epp: bool, - /// Which throttle/profile to use on battery power - pub throttle_policy_on_battery: ThrottlePolicy, + /// platform profile is changed + pub platform_profile_linked_epp: bool, + /// Which platform profile to use on battery power + pub platform_profile_on_battery: PlatformProfile, /// Should the throttle policy be set on bat/ac change? - pub change_throttle_policy_on_battery: bool, - /// Which throttle/profile to use on AC power - pub throttle_policy_on_ac: ThrottlePolicy, - /// Should the throttle policy be set on bat/ac change? - pub change_throttle_policy_on_ac: bool, - /// The energy_performance_preference for this throttle/platform profile - pub throttle_quiet_epp: CPUEPP, - /// The energy_performance_preference for this throttle/platform profile - pub throttle_balanced_epp: CPUEPP, - /// The energy_performance_preference for this throttle/platform profile - pub throttle_performance_epp: CPUEPP, + pub change_platform_profile_on_battery: bool, + /// Which platform profile to use on AC power + pub platform_profile_on_ac: PlatformProfile, + /// Should the platform profile be set on bat/ac change? + pub change_platform_profile_on_ac: bool, + /// The energy_performance_preference for this platform profile + pub profile_quiet_epp: CPUEPP, + /// The energy_performance_preference for this platform profile + pub profile_balanced_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, pub armoury_settings: HashMap, @@ -50,7 +50,7 @@ impl Config { pub fn select_tunings( &mut self, power_plugged: bool, - profile: ThrottlePolicy + profile: PlatformProfile ) -> &mut HashMap { let config = if power_plugged { &mut self.ac_profile_tunings @@ -69,14 +69,14 @@ impl Default for Config { disable_nvidia_powerd_on_battery: true, ac_command: Default::default(), bat_command: Default::default(), - throttle_policy_linked_epp: true, - throttle_policy_on_battery: ThrottlePolicy::Quiet, - change_throttle_policy_on_battery: true, - throttle_policy_on_ac: ThrottlePolicy::Performance, - change_throttle_policy_on_ac: true, - throttle_quiet_epp: CPUEPP::Power, - throttle_balanced_epp: CPUEPP::BalancePower, - throttle_performance_epp: CPUEPP::Performance, + platform_profile_linked_epp: true, + platform_profile_on_battery: PlatformProfile::Quiet, + change_platform_profile_on_battery: true, + platform_profile_on_ac: PlatformProfile::Performance, + change_platform_profile_on_ac: true, + profile_quiet_epp: CPUEPP::Power, + profile_balanced_epp: CPUEPP::BalancePower, + profile_performance_epp: CPUEPP::Performance, ac_profile_tunings: HashMap::default(), dc_profile_tunings: HashMap::default(), armoury_settings: HashMap::default(), @@ -90,8 +90,8 @@ impl StdConfig for Config { Config { charge_control_end_threshold: 100, disable_nvidia_powerd_on_battery: true, - throttle_policy_on_battery: ThrottlePolicy::Quiet, - throttle_policy_on_ac: ThrottlePolicy::Performance, + platform_profile_on_battery: PlatformProfile::Quiet, + platform_profile_on_ac: PlatformProfile::Performance, ac_command: String::new(), bat_command: String::new(), ..Default::default() @@ -120,14 +120,14 @@ pub struct Config601 { pub disable_nvidia_powerd_on_battery: bool, pub ac_command: String, pub bat_command: String, - pub throttle_policy_linked_epp: bool, - pub throttle_policy_on_battery: ThrottlePolicy, - pub change_throttle_policy_on_battery: bool, - pub throttle_policy_on_ac: ThrottlePolicy, - pub change_throttle_policy_on_ac: bool, - pub throttle_quiet_epp: CPUEPP, - pub throttle_balanced_epp: CPUEPP, - pub throttle_performance_epp: CPUEPP, + pub platform_profile_linked_epp: bool, + pub platform_profile_on_battery: PlatformProfile, + pub change_platform_profile_on_battery: bool, + pub platform_profile_on_ac: PlatformProfile, + pub change_platform_profile_on_ac: bool, + pub profile_quiet_epp: CPUEPP, + pub profile_balanced_epp: CPUEPP, + pub profile_performance_epp: CPUEPP, #[serde(skip_serializing_if = "Option::is_none", default)] pub ppt_pl1_spl: Option, #[serde(skip_serializing_if = "Option::is_none", default)] @@ -157,14 +157,14 @@ impl From for Config { disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery, ac_command: c.ac_command, bat_command: c.bat_command, - throttle_policy_linked_epp: c.throttle_policy_linked_epp, - throttle_policy_on_battery: c.throttle_policy_on_battery, - change_throttle_policy_on_battery: c.change_throttle_policy_on_battery, - throttle_policy_on_ac: c.throttle_policy_on_ac, - change_throttle_policy_on_ac: c.change_throttle_policy_on_ac, - throttle_quiet_epp: c.throttle_quiet_epp, - throttle_balanced_epp: c.throttle_balanced_epp, - throttle_performance_epp: c.throttle_performance_epp, + platform_profile_linked_epp: c.platform_profile_linked_epp, + platform_profile_on_battery: c.platform_profile_on_battery, + change_platform_profile_on_battery: c.change_platform_profile_on_battery, + platform_profile_on_ac: c.platform_profile_on_ac, + change_platform_profile_on_ac: c.change_platform_profile_on_ac, + profile_quiet_epp: c.profile_quiet_epp, + profile_balanced_epp: c.profile_balanced_epp, + profile_performance_epp: c.profile_performance_epp, last_power_plugged: c.last_power_plugged, ac_profile_tunings: HashMap::default(), dc_profile_tunings: HashMap::default(), diff --git a/asusd/src/ctrl_fancurves.rs b/asusd/src/ctrl_fancurves.rs index 30ad9226..cafdf97a 100644 --- a/asusd/src/ctrl_fancurves.rs +++ b/asusd/src/ctrl_fancurves.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use config_traits::{StdConfig, StdConfigLoad}; use futures_lite::StreamExt; use log::{debug, error, info, warn}; -use rog_platform::platform::{RogPlatform, ThrottlePolicy}; +use rog_platform::platform::{PlatformProfile, RogPlatform}; use rog_profiles::error::ProfileError; use rog_profiles::fan_curve_set::CurveData; use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles}; @@ -23,7 +23,7 @@ pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones"; pub struct FanCurveConfig { pub profiles: FanCurveProfiles, #[serde(skip)] - pub current: u8 + pub current: PlatformProfile } impl StdConfig for FanCurveConfig { @@ -54,7 +54,7 @@ pub struct CtrlFanCurveZbus { impl CtrlFanCurveZbus { pub fn new() -> Result { let platform = RogPlatform::new()?; - if platform.has_throttle_thermal_policy() { + if platform.has_platform_profile() { info!("Device has profile control available"); find_fan_curve_node()?; info!("Device has fan curves available"); @@ -65,16 +65,16 @@ impl CtrlFanCurveZbus { if config.profiles.balanced.is_empty() || !config.file_path().exists() { info!("Fetching default fan curves"); - let current = platform.get_throttle_thermal_policy()?; + let current = platform.get_platform_profile()?; for this in [ - ThrottlePolicy::Balanced, - ThrottlePolicy::Performance, - ThrottlePolicy::Quiet + PlatformProfile::Balanced, + PlatformProfile::Performance, + PlatformProfile::Quiet ] { // For each profile we need to switch to it before we // can read the existing values from hardware. The ACPI method used // for this is what limits us. - platform.set_throttle_thermal_policy(this.into())?; + platform.set_platform_profile(this.into())?; let mut dev = find_fan_curve_node()?; fan_curves.set_active_curve_to_defaults(this, &mut dev)?; @@ -83,7 +83,7 @@ impl CtrlFanCurveZbus { info!("{}", String::from(curve)); } } - platform.set_throttle_thermal_policy(current)?; + platform.set_platform_profile(current.as_str())?; config.profiles = fan_curves; config.write(); } else { @@ -107,7 +107,7 @@ impl CtrlFanCurveZbus { /// fan curve if in the same profile mode async fn set_fan_curves_enabled( &mut self, - profile: ThrottlePolicy, + profile: PlatformProfile, enabled: bool ) -> zbus::fdo::Result<()> { self.config @@ -128,7 +128,7 @@ impl CtrlFanCurveZbus { /// activate a fan curve if in the same profile mode async fn set_profile_fan_curve_enabled( &mut self, - profile: ThrottlePolicy, + profile: PlatformProfile, fan: FanCurvePU, enabled: bool ) -> zbus::fdo::Result<()> { @@ -149,7 +149,7 @@ impl CtrlFanCurveZbus { /// Get the fan-curve data for the currently active ThrottlePolicy async fn fan_curve_data( &mut self, - profile: ThrottlePolicy + profile: PlatformProfile ) -> zbus::fdo::Result> { let curve = self .config @@ -165,7 +165,7 @@ impl CtrlFanCurveZbus { /// Will also activate the fan curve if the user is in the same mode. async fn set_fan_curve( &mut self, - profile: ThrottlePolicy, + profile: PlatformProfile, curve: CurveData ) -> zbus::fdo::Result<()> { self.config @@ -173,7 +173,7 @@ impl CtrlFanCurveZbus { .await .profiles .save_fan_curve(curve, profile)?; - let active: ThrottlePolicy = self.platform.get_throttle_thermal_policy()?.into(); + let active: PlatformProfile = self.platform.get_platform_profile()?.into(); if active == profile { self.config .lock() @@ -190,15 +190,15 @@ impl CtrlFanCurveZbus { /// /// Each platform_profile has a different default and the default can be /// read only for the currently active profile. - async fn set_curves_to_defaults(&mut self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> { - let active = self.platform.get_throttle_thermal_policy()?; - self.platform.set_throttle_thermal_policy(profile.into())?; + async fn set_curves_to_defaults(&mut self, profile: PlatformProfile) -> zbus::fdo::Result<()> { + let active = self.platform.get_platform_profile()?; + self.platform.set_platform_profile(profile.into())?; self.config .lock() .await .profiles .set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?; - self.platform.set_throttle_thermal_policy(active)?; + self.platform.set_platform_profile(active.as_str())?; self.config.lock().await.write(); Ok(()) } @@ -208,16 +208,16 @@ impl CtrlFanCurveZbus { /// /// Each platform_profile has a different default and the defualt can be /// read only for the currently active profile. - async fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> { - let active = self.platform.get_throttle_thermal_policy()?; + async fn reset_profile_curves(&self, profile: PlatformProfile) -> zbus::fdo::Result<()> { + let active = self.platform.get_platform_profile()?; - self.platform.set_throttle_thermal_policy(profile.into())?; + self.platform.set_platform_profile(profile.into())?; self.config .lock() .await .profiles - .set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?; - self.platform.set_throttle_thermal_policy(active)?; + .set_active_curve_to_defaults((&active).into(), &mut find_fan_curve_node()?)?; + self.platform.set_platform_profile(active.as_str())?; self.config.lock().await.write(); Ok(()) @@ -236,26 +236,31 @@ impl CtrlTask for CtrlFanCurveZbus { } async fn create_tasks(&self, _signal_ctxt: SignalEmitter<'static>) -> Result<(), RogError> { - let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?; + let watch_platform_profile = self.platform.monitor_platform_profile()?; let platform = self.platform.clone(); let config = self.config.clone(); let fan_curves = self.config.clone(); tokio::spawn(async move { let mut buffer = [0; 32]; - if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) { + if let Ok(mut stream) = watch_platform_profile.into_event_stream(&mut buffer) { while (stream.next().await).is_some() { - debug!("watch_throttle_thermal_policy changed"); - if let Ok(profile) = platform.get_throttle_thermal_policy().map_err(|e| { - error!("get_throttle_thermal_policy error: {e}"); - }) { + debug!("watch_platform_profile changed"); + if let Ok(profile) = + platform + .get_platform_profile() + .map(|p| p.into()) + .map_err(|e| { + error!("get_platform_profile error: {e}"); + }) + { if profile != config.lock().await.current { fan_curves .lock() .await .profiles .write_profile_curve_to_platform( - profile.into(), + profile, &mut find_fan_curve_node().unwrap() ) .map_err(|e| warn!("write_profile_curve_to_platform, {}", e)) @@ -274,7 +279,7 @@ impl CtrlTask for CtrlFanCurveZbus { impl crate::Reloadable for CtrlFanCurveZbus { /// Fetch the active profile and use that to set all related components up async fn reload(&mut self) -> Result<(), RogError> { - let active = self.platform.get_throttle_thermal_policy()?.into(); + let active = self.platform.get_platform_profile()?.into(); let mut config = self.config.lock().await; if let Ok(mut device) = find_fan_curve_node() { config diff --git a/asusd/src/ctrl_platform.rs b/asusd/src/ctrl_platform.rs index 39866972..88ddf721 100644 --- a/asusd/src/ctrl_platform.rs +++ b/asusd/src/ctrl_platform.rs @@ -1,13 +1,12 @@ use std::path::Path; use std::process::Command; -use std::str::FromStr; use std::sync::Arc; use config_traits::StdConfig; use log::{debug, error, info, warn}; use rog_platform::asus_armoury::FirmwareAttributes; use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP}; -use rog_platform::platform::{Properties, RogPlatform, ThrottlePolicy}; +use rog_platform::platform::{PlatformProfile, Properties, RogPlatform}; use rog_platform::power::AsusPower; use zbus::export::futures_util::lock::Mutex; use zbus::fdo::Error as FdoErr; @@ -204,40 +203,38 @@ impl CtrlPlatform { } } - async fn get_config_epp_for_throttle(&self, throttle: ThrottlePolicy) -> CPUEPP { + async fn get_config_epp_for_throttle(&self, throttle: PlatformProfile) -> CPUEPP { match throttle { - ThrottlePolicy::Balanced => self.config.lock().await.throttle_balanced_epp, - ThrottlePolicy::Performance => self.config.lock().await.throttle_performance_epp, - ThrottlePolicy::Quiet => self.config.lock().await.throttle_quiet_epp + PlatformProfile::Balanced => self.config.lock().await.profile_balanced_epp, + PlatformProfile::Performance => self.config.lock().await.profile_performance_epp, + PlatformProfile::Quiet => self.config.lock().await.profile_quiet_epp } } async fn update_policy_ac_or_bat(&self, power_plugged: bool, change_epp: bool) { - if power_plugged && !self.config.lock().await.change_throttle_policy_on_ac { + if power_plugged && !self.config.lock().await.change_platform_profile_on_ac { debug!( - "Power status changed but set_throttle_policy_on_ac set false. Not setting the \ + "Power status changed but set_platform_profile_on_ac set false. Not setting the \ thing" ); return; } - if !power_plugged && !self.config.lock().await.change_throttle_policy_on_battery { + if !power_plugged && !self.config.lock().await.change_platform_profile_on_battery { debug!( - "Power status changed but set_throttle_policy_on_battery set false. Not setting \ + "Power status changed but set_platform_profile_on_battery set false. Not setting \ the thing" ); return; } let throttle = if power_plugged { - self.config.lock().await.throttle_policy_on_ac + self.config.lock().await.platform_profile_on_ac } else { - self.config.lock().await.throttle_policy_on_battery + self.config.lock().await.platform_profile_on_battery }; debug!("Setting {throttle:?} before EPP"); let epp = self.get_config_epp_for_throttle(throttle).await; - self.platform - .set_throttle_thermal_policy(throttle.into()) - .ok(); + self.platform.set_platform_profile(throttle.into()).ok(); self.check_and_set_epp(epp, change_epp); } } @@ -279,7 +276,7 @@ impl CtrlPlatform { Properties::ChargeControlEndThreshold ); - platform_name!(throttle_thermal_policy, Properties::ThrottlePolicy); + platform_name!(platform_profile, Properties::ThrottlePolicy); supported } @@ -317,121 +314,119 @@ impl CtrlPlatform { /// Toggle to next platform_profile. Names provided by `Profiles`. /// If fan-curves are supported will also activate a fan curve for profile. - async fn next_throttle_thermal_policy( + async fn next_platform_profile( &mut self, #[zbus(signal_context)] ctxt: SignalEmitter<'_> ) -> Result<(), FdoErr> { - let policy: ThrottlePolicy = - platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") - .map(|n| n.into())?; - let policy = ThrottlePolicy::next(policy); + let policy: PlatformProfile = + platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into())?; + let policy = PlatformProfile::next(policy); - if self.platform.has_throttle_thermal_policy() { - let change_epp = self.config.lock().await.throttle_policy_linked_epp; + if self.platform.has_platform_profile() { + let change_epp = self.config.lock().await.platform_profile_linked_epp; let epp = self.get_config_epp_for_throttle(policy).await; self.check_and_set_epp(epp, change_epp); self.platform - .set_throttle_thermal_policy(policy.into()) + .set_platform_profile(policy.into()) .map_err(|err| { - warn!("throttle_thermal_policy {}", err); - FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}")) + warn!("platform_profile {}", err); + FdoErr::Failed(format!("RogPlatform: platform_profile: {err}")) })?; - Ok(self.throttle_thermal_policy_changed(&ctxt).await?) + Ok(self.platform_profile_changed(&ctxt).await?) } else { Err(FdoErr::NotSupported( - "RogPlatform: throttle_thermal_policy not supported".to_owned() + "RogPlatform: platform_profile not supported".to_owned() )) } } #[zbus(property)] - fn throttle_thermal_policy(&self) -> Result { - platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") - .map(|n| n.into()) + fn platform_profile(&self) -> Result { + platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into()) } #[zbus(property)] - async fn set_throttle_thermal_policy(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> { + async fn set_platform_profile(&mut self, policy: PlatformProfile) -> Result<(), FdoErr> { // TODO: watch for external changes - if self.platform.has_throttle_thermal_policy() { - let change_epp = self.config.lock().await.throttle_policy_linked_epp; + if self.platform.has_platform_profile() { + let change_epp = self.config.lock().await.platform_profile_linked_epp; let epp = self.get_config_epp_for_throttle(policy).await; self.check_and_set_epp(epp, change_epp); self.config.lock().await.write(); self.platform - .set_throttle_thermal_policy(policy.into()) + .set_platform_profile(policy.into()) .map_err(|err| { - warn!("throttle_thermal_policy {}", err); - FdoErr::Failed(format!("RogPlatform: throttle_thermal_policy: {err}")) + warn!("platform_profile {}", err); + FdoErr::Failed(format!("RogPlatform: platform_profile: {err}")) }) } else { Err(FdoErr::NotSupported( - "RogPlatform: throttle_thermal_policy not supported".to_owned() + "RogPlatform: platform_profile not supported".to_owned() )) } } #[zbus(property)] - async fn throttle_policy_linked_epp(&self) -> Result { - Ok(self.config.lock().await.throttle_policy_linked_epp) + async fn platform_profile_linked_epp(&self) -> Result { + Ok(self.config.lock().await.platform_profile_linked_epp) } #[zbus(property)] - async fn set_throttle_policy_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> { - self.config.lock().await.throttle_policy_linked_epp = linked; + async fn set_platform_profile_linked_epp(&self, linked: bool) -> Result<(), zbus::Error> { + self.config.lock().await.platform_profile_linked_epp = linked; self.config.lock().await.write(); Ok(()) } #[zbus(property)] - async fn throttle_policy_on_battery(&self) -> Result { - Ok(self.config.lock().await.throttle_policy_on_battery) + async fn platform_profile_on_battery(&self) -> Result { + Ok(self.config.lock().await.platform_profile_on_battery) } #[zbus(property)] - async fn set_throttle_policy_on_battery( + async fn set_platform_profile_on_battery( &mut self, - policy: ThrottlePolicy + policy: PlatformProfile ) -> Result<(), FdoErr> { - self.config.lock().await.throttle_policy_on_battery = policy; - self.set_throttle_thermal_policy(policy).await?; + self.config.lock().await.platform_profile_on_battery = policy; + self.set_platform_profile(policy).await?; self.config.lock().await.write(); Ok(()) } #[zbus(property)] - async fn change_throttle_policy_on_battery(&self) -> Result { - Ok(self.config.lock().await.change_throttle_policy_on_battery) + async fn change_platform_profile_on_battery(&self) -> Result { + Ok(self.config.lock().await.change_platform_profile_on_battery) } #[zbus(property)] - async fn set_change_throttle_policy_on_battery(&mut self, change: bool) -> Result<(), FdoErr> { - self.config.lock().await.change_throttle_policy_on_battery = change; + async fn set_change_platform_profile_on_battery(&mut self, change: bool) -> Result<(), FdoErr> { + self.config.lock().await.change_platform_profile_on_battery = change; self.config.lock().await.write(); Ok(()) } #[zbus(property)] - async fn throttle_policy_on_ac(&self) -> Result { - Ok(self.config.lock().await.throttle_policy_on_ac) + async fn platform_profile_on_ac(&self) -> Result { + Ok(self.config.lock().await.platform_profile_on_ac) } #[zbus(property)] - async fn set_throttle_policy_on_ac(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> { - self.config.lock().await.throttle_policy_on_ac = policy; - self.set_throttle_thermal_policy(policy).await?; + async fn set_platform_profile_on_ac(&mut self, policy: PlatformProfile) -> Result<(), FdoErr> { + self.config.lock().await.platform_profile_on_ac = policy; + self.set_platform_profile(policy).await?; self.config.lock().await.write(); Ok(()) } #[zbus(property)] - async fn change_throttle_policy_on_ac(&self) -> Result { - Ok(self.config.lock().await.change_throttle_policy_on_ac) + async fn change_platform_profile_on_ac(&self) -> Result { + Ok(self.config.lock().await.change_platform_profile_on_ac) } #[zbus(property)] - async fn set_change_throttle_policy_on_ac(&mut self, change: bool) -> Result<(), FdoErr> { - self.config.lock().await.change_throttle_policy_on_ac = change; + async fn set_change_platform_profile_on_ac(&mut self, change: bool) -> Result<(), FdoErr> { + self.config.lock().await.change_platform_profile_on_ac = change; self.config.lock().await.write(); Ok(()) } @@ -439,14 +434,14 @@ impl CtrlPlatform { /// The energy_performance_preference for the quiet throttle/platform /// profile #[zbus(property)] - async fn throttle_quiet_epp(&self) -> Result { - Ok(self.config.lock().await.throttle_quiet_epp) + async fn profile_quiet_epp(&self) -> Result { + Ok(self.config.lock().await.profile_quiet_epp) } #[zbus(property)] - async fn set_throttle_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { - let change_pp = self.config.lock().await.throttle_policy_linked_epp; - self.config.lock().await.throttle_quiet_epp = epp; + async fn set_profile_quiet_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { + let change_pp = self.config.lock().await.platform_profile_linked_epp; + self.config.lock().await.profile_quiet_epp = epp; self.check_and_set_epp(epp, change_pp); self.config.lock().await.write(); Ok(()) @@ -455,14 +450,14 @@ impl CtrlPlatform { /// The energy_performance_preference for the balanced throttle/platform /// profile #[zbus(property)] - async fn throttle_balanced_epp(&self) -> Result { - Ok(self.config.lock().await.throttle_balanced_epp) + async fn profile_balanced_epp(&self) -> Result { + Ok(self.config.lock().await.profile_balanced_epp) } #[zbus(property)] - async fn set_throttle_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { - let change_pp = self.config.lock().await.throttle_policy_linked_epp; - self.config.lock().await.throttle_balanced_epp = epp; + async fn set_profile_balanced_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { + let change_pp = self.config.lock().await.platform_profile_linked_epp; + self.config.lock().await.profile_balanced_epp = epp; self.check_and_set_epp(epp, change_pp); self.config.lock().await.write(); Ok(()) @@ -471,14 +466,14 @@ impl CtrlPlatform { /// The energy_performance_preference for the performance throttle/platform /// profile #[zbus(property)] - async fn throttle_performance_epp(&self) -> Result { - Ok(self.config.lock().await.throttle_performance_epp) + async fn profile_performance_epp(&self) -> Result { + Ok(self.config.lock().await.profile_performance_epp) } #[zbus(property)] - async fn set_throttle_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { - let change_pp = self.config.lock().await.throttle_policy_linked_epp; - self.config.lock().await.throttle_performance_epp = epp; + async fn set_profile_performance_epp(&mut self, epp: CPUEPP) -> Result<(), FdoErr> { + let change_pp = self.config.lock().await.platform_profile_linked_epp; + self.config.lock().await.profile_performance_epp = epp; self.check_and_set_epp(epp, change_pp); self.config.lock().await.write(); Ok(()) @@ -519,21 +514,20 @@ impl ReloadAndNotify for CtrlPlatform { .or(Some(limit)); } - if self.platform.has_throttle_thermal_policy() - && config.throttle_policy_linked_epp != data.throttle_policy_linked_epp + if self.platform.has_platform_profile() + && config.platform_profile_linked_epp != data.platform_profile_linked_epp { - let profile: ThrottlePolicy = - ThrottlePolicy::from_str(self.platform.get_platform_profile()?.as_str())?; + let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let epp = match profile { - ThrottlePolicy::Balanced => data.throttle_balanced_epp, - ThrottlePolicy::Performance => data.throttle_performance_epp, - ThrottlePolicy::Quiet => data.throttle_quiet_epp + PlatformProfile::Balanced => data.profile_balanced_epp, + PlatformProfile::Performance => data.profile_performance_epp, + PlatformProfile::Quiet => data.profile_quiet_epp }; warn!("setting epp to {epp:?}"); self.check_and_set_epp(epp, true); } - // reload_and_notify!(throttle_thermal_policy, "throttle_thermal_policy"); + // reload_and_notify!(platform_profile, "platform_profile"); *config = data; config.base_charge_control_end_threshold = @@ -557,8 +551,8 @@ impl crate::Reloadable for CtrlPlatform { 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() { - let change_epp = self.config.lock().await.throttle_policy_linked_epp; + if self.platform.has_platform_profile() { + let change_epp = self.config.lock().await.platform_profile_linked_epp; self.update_policy_ac_or_bat(power_plugged > 0, change_epp) .await; } @@ -605,9 +599,9 @@ impl CtrlTask for CtrlPlatform { } if let Ok(power_plugged) = platform1.power.get_online() { if platform1.config.lock().await.last_power_plugged != power_plugged { - if !sleeping && platform1.platform.has_throttle_thermal_policy() { + if !sleeping && platform1.platform.has_platform_profile() { let change_epp = - platform1.config.lock().await.throttle_policy_linked_epp; + platform1.config.lock().await.platform_profile_linked_epp; platform1 .update_policy_ac_or_bat(power_plugged > 0, change_epp) .await; @@ -651,8 +645,8 @@ impl CtrlTask for CtrlPlatform { let platform3 = platform3.clone(); // power change async move { - if platform3.platform.has_throttle_thermal_policy() { - let change_epp = platform3.config.lock().await.throttle_policy_linked_epp; + if platform3.platform.has_platform_profile() { + let change_epp = platform3.config.lock().await.platform_profile_linked_epp; platform3 .update_policy_ac_or_bat(power_plugged, change_epp) .await; @@ -665,10 +659,10 @@ impl CtrlTask for CtrlPlatform { if let Ok(profile) = platform3 .platform - .get_throttle_thermal_policy() - .map(ThrottlePolicy::from) + .get_platform_profile() + .map(|p| p.into()) .map_err(|e| { - error!("Platform: get_throttle_thermal_policy error: {e}"); + error!("Platform: get_platform_profile error: {e}"); }) { let attrs = FirmwareAttributes::new(); @@ -690,7 +684,7 @@ impl CtrlTask for CtrlPlatform { self.watch_charge_control_end_threshold(signal_ctxt.clone()) .await?; - let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?; + let watch_platform_profile = self.platform.monitor_platform_profile()?; let ctrl = self.clone(); // Need a copy here, not ideal. But first use in asus_armoury.rs is @@ -699,24 +693,22 @@ impl CtrlTask for CtrlPlatform { tokio::spawn(async move { use futures_lite::StreamExt; let mut buffer = [0; 32]; - if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) { + if let Ok(mut stream) = watch_platform_profile.into_event_stream(&mut buffer) { while (stream.next().await).is_some() { // this blocks - debug!("Platform: watch_throttle_thermal_policy changed"); + debug!("Platform: watch_platform_profile changed"); if let Ok(profile) = ctrl .platform - .get_throttle_thermal_policy() - .map(ThrottlePolicy::from) + .get_platform_profile() + .map(|p| p.into()) .map_err(|e| { - error!("Platform: get_throttle_thermal_policy error: {e}"); + error!("Platform: get_platform_profile error: {e}"); }) { - let change_epp = ctrl.config.lock().await.throttle_policy_linked_epp; + let change_epp = ctrl.config.lock().await.platform_profile_linked_epp; let epp = ctrl.get_config_epp_for_throttle(profile).await; ctrl.check_and_set_epp(epp, change_epp); - ctrl.throttle_thermal_policy_changed(&signal_ctxt) - .await - .ok(); + ctrl.platform_profile_changed(&signal_ctxt).await.ok(); let power_plugged = ctrl .power .get_online() diff --git a/rog-control-center/src/types/fan_types.rs b/rog-control-center/src/types/fan_types.rs index 2e3224a9..1ce3e548 100644 --- a/rog-control-center/src/types/fan_types.rs +++ b/rog-control-center/src/types/fan_types.rs @@ -1,24 +1,24 @@ -use rog_platform::platform::ThrottlePolicy; +use rog_platform::platform::PlatformProfile; use rog_profiles::FanCurvePU; use crate::{FanType, Profile}; -impl From for ThrottlePolicy { +impl From 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 for Profile { - fn from(value: ThrottlePolicy) -> Self { +impl From 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 } } } diff --git a/rog-control-center/src/ui/setup_fans.rs b/rog-control-center/src/ui/setup_fans.rs index 7a470717..7ae1c635 100644 --- a/rog-control-center/src/ui/setup_fans.rs +++ b/rog-control-center/src/ui/setup_fans.rs @@ -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>) { 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>) { 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 { diff --git a/rog-control-center/src/ui/setup_system.rs b/rog-control-center/src/ui/setup_system.rs index 2de494ac..9b3d8ef1 100644 --- a/rog-control-center/src/ui/setup_system.rs +++ b/rog-control-center/src/ui/setup_system.rs @@ -28,8 +28,7 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc>) { // Null everything before the setup step ui.global::() .set_charge_control_end_threshold(-1.0); - ui.global::() - .set_throttle_thermal_policy(-1); + ui.global::().set_platform_profile(-1); ui.global::().set_panel_overdrive(-1); ui.global::().set_boot_sound(-1); ui.global::().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>) 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>) ); 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" ); diff --git a/rog-control-center/ui/pages/system.slint b/rog-control-center/ui/pages/system.slint index 7c4fed42..4bdcd8cd 100644 --- a/rog-control-center/ui/pages/system.slint +++ b/rog-control-center/ui/pages/system.slint @@ -15,9 +15,9 @@ export struct AttrPossible { export global SystemPageData { in-out property charge_control_end_threshold: 30; callback cb_charge_control_end_threshold(/* charge limit */ int); - in-out property 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 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 throttle_balanced_epp: 0; - callback cb_throttle_balanced_epp(int); - in-out property throttle_performance_epp: 0; - callback cb_throttle_performance_epp(int); - in-out property throttle_quiet_epp: 0; - callback cb_throttle_quiet_epp(int); + in-out property profile_balanced_epp: 0; + callback cb_profile_balanced_epp(int); + in-out property profile_performance_epp: 0; + callback cb_profile_performance_epp(int); + in-out property profile_quiet_epp: 0; + callback cb_profile_quiet_epp(int); // if the EPP should change with throttle - in-out property throttle_policy_linked_epp: true; - callback cb_throttle_policy_linked_epp(bool); - in-out property throttle_policy_on_ac: 0; - callback cb_throttle_policy_on_ac(int); - in-out property change_throttle_policy_on_ac: true; - callback cb_change_throttle_policy_on_ac(bool); - in-out property throttle_policy_on_battery: 0; - callback cb_throttle_policy_on_battery(int); - in-out property change_throttle_policy_on_battery: true; - callback cb_change_throttle_policy_on_battery(bool); + in-out property platform_profile_linked_epp: true; + callback cb_platform_profile_linked_epp(bool); + in-out property platform_profile_on_ac: 0; + callback cb_platform_profile_on_ac(int); + in-out property change_platform_profile_on_ac: true; + callback cb_change_platform_profile_on_ac(bool); + in-out property platform_profile_on_battery: 0; + callback cb_platform_profile_on_battery(int); + in-out property change_platform_profile_on_battery: true; + callback cb_change_platform_profile_on_battery(bool); // in-out property 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); } } } diff --git a/rog-dbus/src/zbus_fan_curves.rs b/rog-dbus/src/zbus_fan_curves.rs index ec517e32..777a33c2 100644 --- a/rog-dbus/src/zbus_fan_curves.rs +++ b/rog-dbus/src/zbus_fan_curves.rs @@ -20,7 +20,7 @@ //! //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. -use rog_platform::platform::ThrottlePolicy; +use rog_platform::platform::PlatformProfile; use rog_profiles::fan_curve_set::CurveData; use rog_profiles::FanCurvePU; use zbus::proxy; @@ -32,30 +32,30 @@ use zbus::proxy; )] pub trait FanCurves { /// Get the fan-curve data for the currently active PlatformProfile - fn fan_curve_data(&self, profile: ThrottlePolicy) -> zbus::Result>; + fn fan_curve_data(&self, profile: PlatformProfile) -> zbus::Result>; /// Reset the stored (self) and device curve to the defaults of the /// platform. /// /// Each platform_profile has a different default and the defualt can be /// read only for the currently active profile. - fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::Result<()>; + fn reset_profile_curves(&self, profile: PlatformProfile) -> zbus::Result<()>; /// SetActiveCurveToDefaults method - fn set_curves_to_defaults(&self, profile: ThrottlePolicy) -> zbus::Result<()>; + fn set_curves_to_defaults(&self, profile: PlatformProfile) -> zbus::Result<()>; /// Set the fan curve for the specified profile, or the profile the user is /// currently in if profile == None. Will also activate the fan curve. - fn set_fan_curve(&self, profile: ThrottlePolicy, curve: CurveData) -> zbus::Result<()>; + fn set_fan_curve(&self, profile: PlatformProfile, curve: CurveData) -> zbus::Result<()>; /// Set a profile fan curve enabled status. Will also activate a fan curve. - fn set_fan_curves_enabled(&self, profile: ThrottlePolicy, enabled: bool) -> zbus::Result<()>; + fn set_fan_curves_enabled(&self, profile: PlatformProfile, enabled: bool) -> zbus::Result<()>; /// Set a single fan curve for a profile to enabled status. Will also /// activate a fan curve. async fn set_profile_fan_curve_enabled( &self, - profile: ThrottlePolicy, + profile: PlatformProfile, fan: FanCurvePU, enabled: bool ) -> zbus::Result<()>; diff --git a/rog-dbus/src/zbus_platform.rs b/rog-dbus/src/zbus_platform.rs index 4b8a964d..c20a890c 100644 --- a/rog-dbus/src/zbus_platform.rs +++ b/rog-dbus/src/zbus_platform.rs @@ -21,7 +21,7 @@ //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. use rog_platform::cpu::CPUEPP; -use rog_platform::platform::{Properties, ThrottlePolicy}; +use rog_platform::platform::{PlatformProfile, Properties}; use zbus::proxy; #[proxy( @@ -34,7 +34,7 @@ pub trait Platform { fn version(&self) -> zbus::Result; /// NextThrottleThermalPolicy method - fn next_throttle_thermal_policy(&self) -> zbus::Result<()>; + fn next_platform_profile(&self) -> zbus::Result<()>; /// SupportedProperties method fn supported_properties(&self) -> zbus::Result>; @@ -50,55 +50,58 @@ pub trait Platform { /// ThrottleBalancedEpp property #[zbus(property)] - fn throttle_balanced_epp(&self) -> zbus::Result; + fn profile_balanced_epp(&self) -> zbus::Result; #[zbus(property)] - fn set_throttle_balanced_epp(&self, epp: CPUEPP) -> zbus::Result<()>; + fn set_profile_balanced_epp(&self, epp: CPUEPP) -> zbus::Result<()>; /// ThrottlePerformanceEpp property #[zbus(property)] - fn throttle_performance_epp(&self) -> zbus::Result; + fn profile_performance_epp(&self) -> zbus::Result; #[zbus(property)] - fn set_throttle_performance_epp(&self, epp: CPUEPP) -> zbus::Result<()>; + fn set_profile_performance_epp(&self, epp: CPUEPP) -> zbus::Result<()>; /// ThrottlePolicyLinkedEpp property #[zbus(property)] - fn throttle_policy_linked_epp(&self) -> zbus::Result; + fn platform_profile_linked_epp(&self) -> zbus::Result; #[zbus(property)] - fn set_throttle_policy_linked_epp(&self, value: bool) -> zbus::Result<()>; + fn set_platform_profile_linked_epp(&self, value: bool) -> zbus::Result<()>; /// ThrottlePolicyOnAc property #[zbus(property)] - fn throttle_policy_on_ac(&self) -> zbus::Result; + fn platform_profile_on_ac(&self) -> zbus::Result; #[zbus(property)] - fn set_throttle_policy_on_ac(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; + fn set_platform_profile_on_ac(&self, platform_profile: PlatformProfile) -> zbus::Result<()>; /// ChangeThrottlePolicyOnAc property #[zbus(property)] - fn change_throttle_policy_on_ac(&self) -> zbus::Result; + fn change_platform_profile_on_ac(&self) -> zbus::Result; #[zbus(property)] - fn set_change_throttle_policy_on_ac(&self, change: bool) -> zbus::Result<()>; + fn set_change_platform_profile_on_ac(&self, change: bool) -> zbus::Result<()>; /// ThrottlePolicyOnBattery property #[zbus(property)] - fn throttle_policy_on_battery(&self) -> zbus::Result; + fn platform_profile_on_battery(&self) -> zbus::Result; #[zbus(property)] - fn set_throttle_policy_on_battery(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; + fn set_platform_profile_on_battery( + &self, + platform_profile: PlatformProfile + ) -> zbus::Result<()>; /// ChangeThrottlePolicyOnAc property #[zbus(property)] - fn change_throttle_policy_on_battery(&self) -> zbus::Result; + fn change_platform_profile_on_battery(&self) -> zbus::Result; #[zbus(property)] - fn set_change_throttle_policy_on_battery(&self, change: bool) -> zbus::Result<()>; + fn set_change_platform_profile_on_battery(&self, change: bool) -> zbus::Result<()>; /// ThrottleQuietEpp property #[zbus(property)] - fn throttle_quiet_epp(&self) -> zbus::Result; + fn profile_quiet_epp(&self) -> zbus::Result; #[zbus(property)] - fn set_throttle_quiet_epp(&self, epp: CPUEPP) -> zbus::Result<()>; + fn set_profile_quiet_epp(&self, epp: CPUEPP) -> zbus::Result<()>; /// ThrottlePolicy property #[zbus(property)] - fn throttle_thermal_policy(&self) -> zbus::Result; + fn platform_profile(&self) -> zbus::Result; #[zbus(property)] - fn set_throttle_thermal_policy(&self, throttle_policy: ThrottlePolicy) -> zbus::Result<()>; + fn set_platform_profile(&self, platform_profile: PlatformProfile) -> zbus::Result<()>; } diff --git a/rog-platform/src/asus_armoury.rs b/rog-platform/src/asus_armoury.rs index e5ca6365..f6833806 100644 --- a/rog-platform/src/asus_armoury.rs +++ b/rog-platform/src/asus_armoury.rs @@ -309,7 +309,6 @@ impl FirmwareAttribute { | FirmwareAttribute::PptPlatformSppt | FirmwareAttribute::NvDynamicBoost | FirmwareAttribute::NvTempTarget - | FirmwareAttribute::DgpuBaseTgp | FirmwareAttribute::DgpuTgp ) } diff --git a/rog-platform/src/cpu.rs b/rog-platform/src/cpu.rs index 49b1adef..c28e7fbc 100644 --- a/rog-platform/src/cpu.rs +++ b/rog-platform/src/cpu.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use zbus::zvariant::{OwnedValue, Type, Value}; use crate::error::{PlatformError, Result}; -use crate::platform::ThrottlePolicy; +use crate::platform::PlatformProfile; use crate::{read_attr_string, to_device}; const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors"; @@ -201,12 +201,12 @@ pub enum CPUEPP { Power = 4 } -impl From for CPUEPP { - fn from(value: ThrottlePolicy) -> Self { +impl From for CPUEPP { + fn from(value: PlatformProfile) -> Self { match value { - ThrottlePolicy::Balanced => CPUEPP::BalancePerformance, - ThrottlePolicy::Performance => CPUEPP::Performance, - ThrottlePolicy::Quiet => CPUEPP::Power + PlatformProfile::Balanced => CPUEPP::BalancePerformance, + PlatformProfile::Performance => CPUEPP::Performance, + PlatformProfile::Quiet => CPUEPP::Power } } } diff --git a/rog-platform/src/platform.rs b/rog-platform/src/platform.rs index eab4874b..8eeaf830 100644 --- a/rog-platform/src/platform.rs +++ b/rog-platform/src/platform.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use zbus::zvariant::{OwnedValue, Type, Value}; use crate::error::{PlatformError, Result}; -use crate::{attr_string, attr_u8, to_device}; +use crate::{attr_string, to_device}; /// The "platform" device provides access to things like: /// - `dgpu_disable` @@ -24,13 +24,6 @@ pub struct RogPlatform { } impl RogPlatform { - attr_u8!( - /// This is technically the same as `platform_profile` since both are - /// tied in-kernel - "throttle_thermal_policy", - path - ); - attr_string!( /// The acpi platform_profile support "platform_profile", @@ -193,15 +186,15 @@ impl Display for GpuMode { Copy, )] #[zvariant(signature = "u")] -/// `throttle_thermal_policy` in asus_wmi -pub enum ThrottlePolicy { +/// `platform_profile` in asus_wmi +pub enum PlatformProfile { #[default] Balanced = 0, Performance = 1, Quiet = 2 } -impl ThrottlePolicy { +impl PlatformProfile { pub const fn next(self) -> Self { match self { Self::Balanced => Self::Performance, @@ -219,7 +212,7 @@ impl ThrottlePolicy { } } -impl From for ThrottlePolicy { +impl From for PlatformProfile { fn from(num: u8) -> Self { match num { 0 => Self::Balanced, @@ -233,52 +226,74 @@ impl From for ThrottlePolicy { } } -impl From for ThrottlePolicy { +impl From for PlatformProfile { fn from(num: i32) -> Self { (num as u8).into() } } -impl From for u8 { - fn from(p: ThrottlePolicy) -> Self { +impl From for u8 { + fn from(p: PlatformProfile) -> Self { match p { - ThrottlePolicy::Balanced => 0, - ThrottlePolicy::Performance => 1, - ThrottlePolicy::Quiet => 2 + PlatformProfile::Balanced => 0, + PlatformProfile::Performance => 1, + PlatformProfile::Quiet => 2 } } } -impl From for i32 { - fn from(p: ThrottlePolicy) -> Self { +impl From for i32 { + fn from(p: PlatformProfile) -> Self { ::from(p) as i32 } } -impl From for &str { - fn from(profile: ThrottlePolicy) -> &'static str { +impl From for &str { + fn from(profile: PlatformProfile) -> &'static str { match profile { - ThrottlePolicy::Balanced => "balanced", - ThrottlePolicy::Performance => "performance", - ThrottlePolicy::Quiet => "quiet" + PlatformProfile::Balanced => "balanced", + PlatformProfile::Performance => "performance", + PlatformProfile::Quiet => "quiet" } } } -impl std::str::FromStr for ThrottlePolicy { +impl From for PlatformProfile { + fn from(profile: String) -> Self { + Self::from(&profile) + } +} + +impl From<&String> for PlatformProfile { + fn from(profile: &String) -> Self { + match profile.to_ascii_lowercase().trim() { + "balanced" => PlatformProfile::Balanced, + "performance" => PlatformProfile::Performance, + "quiet" => PlatformProfile::Quiet, + "low-power" => PlatformProfile::Quiet, + _ => { + warn!("{profile} is unknown, using ThrottlePolicy::Balanced"); + PlatformProfile::Balanced + } + } + } +} + +impl std::str::FromStr for PlatformProfile { type Err = PlatformError; fn from_str(profile: &str) -> Result { match profile.to_ascii_lowercase().trim() { - "balanced" => Ok(ThrottlePolicy::Balanced), - "performance" => Ok(ThrottlePolicy::Performance), - "quiet" => Ok(ThrottlePolicy::Quiet), + "balanced" => Ok(PlatformProfile::Balanced), + "performance" => Ok(PlatformProfile::Performance), + "quiet" => Ok(PlatformProfile::Quiet), + "low-power" => Ok(PlatformProfile::Quiet), _ => Err(PlatformError::NotSupported) } } } -impl Display for ThrottlePolicy { +impl Display for PlatformProfile { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:?}", self) } diff --git a/rog-profiles/src/lib.rs b/rog-profiles/src/lib.rs index 77d3defd..d98936c3 100644 --- a/rog-profiles/src/lib.rs +++ b/rog-profiles/src/lib.rs @@ -4,7 +4,7 @@ pub mod fan_curve_set; use error::ProfileError; use fan_curve_set::CurveData; use log::debug; -use rog_platform::platform::ThrottlePolicy; +use rog_platform::platform::PlatformProfile; use serde::{Deserialize, Serialize}; pub use udev::Device; #[cfg(feature = "dbus")] @@ -125,7 +125,7 @@ impl FanCurveProfiles { pub fn read_from_dev_profile( &mut self, - profile: ThrottlePolicy, + profile: PlatformProfile, device: &Device ) -> Result<(), ProfileError> { let fans = Self::supported_fans()?; @@ -143,9 +143,9 @@ impl FanCurveProfiles { } match profile { - ThrottlePolicy::Balanced => self.balanced = curves, - ThrottlePolicy::Performance => self.performance = curves, - ThrottlePolicy::Quiet => self.quiet = curves + PlatformProfile::Balanced => self.balanced = curves, + PlatformProfile::Performance => self.performance = curves, + PlatformProfile::Quiet => self.quiet = curves } Ok(()) } @@ -157,7 +157,7 @@ impl FanCurveProfiles { /// read only for the currently active profile. pub fn set_active_curve_to_defaults( &mut self, - profile: ThrottlePolicy, + profile: PlatformProfile, device: &mut Device ) -> Result<(), ProfileError> { let fans = Self::supported_fans()?; @@ -175,13 +175,13 @@ impl FanCurveProfiles { /// in the enabled list it will become active. pub fn write_profile_curve_to_platform( &mut self, - profile: ThrottlePolicy, + profile: PlatformProfile, device: &mut Device ) -> Result<(), ProfileError> { let fans = match profile { - ThrottlePolicy::Balanced => &mut self.balanced, - ThrottlePolicy::Performance => &mut self.performance, - ThrottlePolicy::Quiet => &mut self.quiet + PlatformProfile::Balanced => &mut self.balanced, + PlatformProfile::Performance => &mut self.performance, + PlatformProfile::Quiet => &mut self.quiet }; for fan in fans.iter().filter(|f| !f.enabled) { debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}"); @@ -196,19 +196,19 @@ impl FanCurveProfiles { Ok(()) } - pub fn set_profile_curves_enabled(&mut self, profile: ThrottlePolicy, enabled: bool) { + pub fn set_profile_curves_enabled(&mut self, profile: PlatformProfile, enabled: bool) { match profile { - ThrottlePolicy::Balanced => { + PlatformProfile::Balanced => { for curve in self.balanced.iter_mut() { curve.enabled = enabled; } } - ThrottlePolicy::Performance => { + PlatformProfile::Performance => { for curve in self.performance.iter_mut() { curve.enabled = enabled; } } - ThrottlePolicy::Quiet => { + PlatformProfile::Quiet => { for curve in self.quiet.iter_mut() { curve.enabled = enabled; } @@ -218,12 +218,12 @@ impl FanCurveProfiles { pub fn set_profile_fan_curve_enabled( &mut self, - profile: ThrottlePolicy, + profile: PlatformProfile, fan: FanCurvePU, enabled: bool ) { match profile { - ThrottlePolicy::Balanced => { + PlatformProfile::Balanced => { for curve in self.balanced.iter_mut() { if curve.fan == fan { curve.enabled = enabled; @@ -231,7 +231,7 @@ impl FanCurveProfiles { } } } - ThrottlePolicy::Performance => { + PlatformProfile::Performance => { for curve in self.performance.iter_mut() { if curve.fan == fan { curve.enabled = enabled; @@ -239,7 +239,7 @@ impl FanCurveProfiles { } } } - ThrottlePolicy::Quiet => { + PlatformProfile::Quiet => { for curve in self.quiet.iter_mut() { if curve.fan == fan { curve.enabled = enabled; @@ -250,31 +250,31 @@ impl FanCurveProfiles { } } - pub fn get_fan_curves_for(&self, name: ThrottlePolicy) -> &[CurveData] { + pub fn get_fan_curves_for(&self, name: PlatformProfile) -> &[CurveData] { match name { - ThrottlePolicy::Balanced => &self.balanced, - ThrottlePolicy::Performance => &self.performance, - ThrottlePolicy::Quiet => &self.quiet + PlatformProfile::Balanced => &self.balanced, + PlatformProfile::Performance => &self.performance, + PlatformProfile::Quiet => &self.quiet } } - pub fn get_fan_curve_for(&self, name: &ThrottlePolicy, pu: FanCurvePU) -> Option<&CurveData> { + pub fn get_fan_curve_for(&self, name: &PlatformProfile, pu: FanCurvePU) -> Option<&CurveData> { match name { - ThrottlePolicy::Balanced => { + PlatformProfile::Balanced => { for this_curve in self.balanced.iter() { if this_curve.fan == pu { return Some(this_curve); } } } - ThrottlePolicy::Performance => { + PlatformProfile::Performance => { for this_curve in self.performance.iter() { if this_curve.fan == pu { return Some(this_curve); } } } - ThrottlePolicy::Quiet => { + PlatformProfile::Quiet => { for this_curve in self.quiet.iter() { if this_curve.fan == pu { return Some(this_curve); @@ -288,10 +288,10 @@ impl FanCurveProfiles { pub fn save_fan_curve( &mut self, curve: CurveData, - profile: ThrottlePolicy + profile: PlatformProfile ) -> Result<(), ProfileError> { match profile { - ThrottlePolicy::Balanced => { + PlatformProfile::Balanced => { for this_curve in self.balanced.iter_mut() { if this_curve.fan == curve.fan { *this_curve = curve; @@ -299,7 +299,7 @@ impl FanCurveProfiles { } } } - ThrottlePolicy::Performance => { + PlatformProfile::Performance => { for this_curve in self.performance.iter_mut() { if this_curve.fan == curve.fan { *this_curve = curve; @@ -307,7 +307,7 @@ impl FanCurveProfiles { } } } - ThrottlePolicy::Quiet => { + PlatformProfile::Quiet => { for this_curve in self.quiet.iter_mut() { if this_curve.fan == curve.fan { *this_curve = curve;