Added ability to change what EPP is linked with each throttle profile

This commit is contained in:
Luke D. Jones
2024-01-15 18:00:27 +13:00
parent 6f4a7e16dc
commit d4c68546e7
19 changed files with 230 additions and 177 deletions

View File

@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- Added ability to change what EPP is linked with each throttle profile
## [v5.0.7] ## [v5.0.7]
### Changed ### Changed
- Fix to suspend process in anime thread to let custom anims run on wake. - Fix to suspend process in anime thread to let custom anims run on wake.

1
Cargo.lock generated
View File

@@ -213,6 +213,7 @@ dependencies = [
"rog_platform", "rog_platform",
"rog_profiles", "rog_profiles",
"tinybmp", "tinybmp",
"tokio",
"toml 0.5.11", "toml 0.5.11",
] ]

View File

@@ -22,5 +22,6 @@ gif.workspace = true
tinybmp.workspace = true tinybmp.workspace = true
glam.workspace = true glam.workspace = true
rog_dbus = { path = "../rog-dbus" } rog_dbus = { path = "../rog-dbus" }
tokio = { version = "^1.23.0", default-features = false, features = ["macros", "sync", "rt", "time"]}
cargo-husky.workspace = true cargo-husky.workspace = true

View File

@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use crate::anime_cli::AnimeCommand; use crate::anime_cli::AnimeCommand;
use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin}; use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin};
@@ -60,7 +60,7 @@ pub struct ProfileCommand {
pub profile_get: bool, pub profile_get: bool,
#[options(meta = "", help = "set the active profile")] #[options(meta = "", help = "set the active profile")]
pub profile_set: Option<PlatformPolicy>, pub profile_set: Option<ThrottlePolicy>,
} }
#[derive(Options)] #[derive(Options)]

View File

@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
@@ -18,7 +18,7 @@ pub struct FanCurveCommand {
meta = "", meta = "",
help = "profile to modify fan-curve for. Shows data if no options provided" help = "profile to modify fan-curve for. Shows data if no options provided"
)] )]
pub mod_profile: Option<PlatformPolicy>, pub mod_profile: Option<ThrottlePolicy>,
#[options( #[options(
meta = "", meta = "",

View File

@@ -18,7 +18,7 @@ use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraPowerDev};
use rog_aura::{self, AuraEffect}; use rog_aura::{self, AuraEffect};
use rog_dbus::RogDbusClientBlocking; use rog_dbus::RogDbusClientBlocking;
use rog_platform::error::PlatformError; use rog_platform::error::PlatformError;
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties}; use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use crate::aura_cli::{AuraPowerStates, LedBrightness}; use crate::aura_cli::{AuraPowerStates, LedBrightness};
@@ -662,7 +662,7 @@ fn handle_throttle_profile(
supported: &[Properties], supported: &[Properties],
cmd: &ProfileCommand, cmd: &ProfileCommand,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
if !supported.contains(&Properties::PlatformPolicy) { if !supported.contains(&Properties::ThrottlePolicy) {
println!("Profiles not supported by either this kernel or by the laptop."); println!("Profiles not supported by either this kernel or by the laptop.");
return Err(ProfileError::NotSupported.into()); return Err(ProfileError::NotSupported.into());
} }
@@ -691,7 +691,7 @@ fn handle_throttle_profile(
} }
if cmd.list { if cmd.list {
let res = PlatformPolicy::list(); let res = ThrottlePolicy::list();
for p in &res { for p in &res {
println!("{:?}", p); println!("{:?}", p);
} }

View File

@@ -1,5 +1,6 @@
use config_traits::{StdConfig, StdConfigLoad3}; use config_traits::{StdConfig, StdConfigLoad3};
use rog_platform::platform::PlatformPolicy; use rog_platform::cpu::CPUEPP;
use rog_platform::platform::ThrottlePolicy;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
const CONFIG_FILE: &str = "asusd.ron"; const CONFIG_FILE: &str = "asusd.ron";
@@ -13,9 +14,14 @@ pub struct Config {
pub disable_nvidia_powerd_on_battery: bool, pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String, pub ac_command: String,
pub bat_command: String, pub bat_command: String,
pub platform_policy_linked_epp: bool, pub throttle_policy_linked_epp: bool,
pub platform_policy_on_battery: PlatformPolicy, pub throttle_policy_on_battery: ThrottlePolicy,
pub platform_policy_on_ac: PlatformPolicy, pub throttle_policy_on_ac: ThrottlePolicy,
//
pub throttle_quiet_epp: CPUEPP,
pub throttle_balanced_epp: CPUEPP,
pub throttle_performance_epp: CPUEPP,
// //
pub ppt_pl1_spl: Option<u8>, pub ppt_pl1_spl: Option<u8>,
pub ppt_pl2_sppt: Option<u8>, pub ppt_pl2_sppt: Option<u8>,
@@ -31,8 +37,8 @@ impl StdConfig for Config {
Config { Config {
charge_control_end_threshold: 100, charge_control_end_threshold: 100,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
platform_policy_on_battery: PlatformPolicy::Quiet, throttle_policy_on_battery: ThrottlePolicy::Quiet,
platform_policy_on_ac: PlatformPolicy::Performance, throttle_policy_on_ac: ThrottlePolicy::Performance,
ac_command: String::new(), ac_command: String::new(),
bat_command: String::new(), bat_command: String::new(),
..Default::default() ..Default::default()
@@ -48,7 +54,55 @@ impl StdConfig for Config {
} }
} }
impl StdConfigLoad3<Config462, Config472, Config506> for Config {} impl StdConfigLoad3<Config472, Config506, Config507> for Config {}
#[derive(Deserialize, Serialize)]
pub struct Config507 {
/// Save charge limit for restoring on boot
pub charge_control_end_threshold: u8,
pub panel_od: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
pub platform_policy_linked_epp: bool,
pub platform_policy_on_battery: ThrottlePolicy,
pub platform_policy_on_ac: ThrottlePolicy,
//
pub ppt_pl1_spl: Option<u8>,
pub ppt_pl2_sppt: Option<u8>,
pub ppt_fppt: Option<u8>,
pub ppt_apu_sppt: Option<u8>,
pub ppt_platform_sppt: Option<u8>,
pub nv_dynamic_boost: Option<u8>,
pub nv_temp_target: Option<u8>,
}
impl From<Config507> for Config {
fn from(c: Config507) -> Self {
Self {
charge_control_end_threshold: c.charge_control_end_threshold,
panel_od: c.panel_od,
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command,
bat_command: c.bat_command,
mini_led_mode: c.mini_led_mode,
throttle_policy_linked_epp: true,
throttle_policy_on_battery: c.platform_policy_on_battery,
throttle_policy_on_ac: c.platform_policy_on_ac,
throttle_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: c.ppt_pl1_spl,
ppt_pl2_sppt: c.ppt_pl2_sppt,
ppt_fppt: c.ppt_fppt,
ppt_apu_sppt: c.ppt_apu_sppt,
ppt_platform_sppt: c.ppt_platform_sppt,
nv_dynamic_boost: c.nv_dynamic_boost,
nv_temp_target: c.nv_temp_target,
}
}
}
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct Config506 { pub struct Config506 {
@@ -61,9 +115,9 @@ pub struct Config506 {
pub bat_command: String, pub bat_command: String,
/// Restored on boot as well as when power is plugged /// Restored on boot as well as when power is plugged
#[serde(skip)] #[serde(skip)]
pub platform_policy_to_restore: PlatformPolicy, pub platform_policy_to_restore: ThrottlePolicy,
pub platform_policy_on_battery: PlatformPolicy, pub platform_policy_on_battery: ThrottlePolicy,
pub platform_policy_on_ac: PlatformPolicy, pub platform_policy_on_ac: ThrottlePolicy,
// //
pub ppt_pl1_spl: Option<u8>, pub ppt_pl1_spl: Option<u8>,
pub ppt_pl2_sppt: Option<u8>, pub ppt_pl2_sppt: Option<u8>,
@@ -83,9 +137,12 @@ impl From<Config506> for Config {
ac_command: c.ac_command, ac_command: c.ac_command,
bat_command: c.bat_command, bat_command: c.bat_command,
mini_led_mode: c.mini_led_mode, mini_led_mode: c.mini_led_mode,
platform_policy_linked_epp: true, throttle_policy_linked_epp: true,
platform_policy_on_battery: c.platform_policy_on_battery, throttle_policy_on_battery: c.platform_policy_on_battery,
platform_policy_on_ac: c.platform_policy_on_ac, throttle_policy_on_ac: c.platform_policy_on_ac,
throttle_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: c.ppt_pl1_spl, ppt_pl1_spl: c.ppt_pl1_spl,
ppt_pl2_sppt: c.ppt_pl2_sppt, ppt_pl2_sppt: c.ppt_pl2_sppt,
ppt_fppt: c.ppt_fppt, ppt_fppt: c.ppt_fppt,
@@ -120,26 +177,3 @@ impl From<Config472> for Config {
} }
} }
} }
#[derive(Deserialize, Serialize)]
pub struct Config462 {
/// Save charge limit for restoring on boot
pub bat_charge_limit: u8,
pub panel_od: bool,
pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String,
pub bat_command: String,
}
impl From<Config462> for Config {
fn from(c: Config462) -> Self {
Self {
charge_control_end_threshold: c.bat_charge_limit,
panel_od: c.panel_od,
disable_nvidia_powerd_on_battery: true,
ac_command: String::new(),
bat_command: String::new(),
..Default::default()
}
}
}

View File

@@ -5,7 +5,7 @@ use async_trait::async_trait;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_lite::StreamExt; use futures_lite::StreamExt;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::platform::{PlatformPolicy, RogPlatform}; use rog_platform::platform::{RogPlatform, ThrottlePolicy};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles}; use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
@@ -70,19 +70,19 @@ impl CtrlFanCurveZbus {
info!("{MOD_NAME}: Fetching default fan curves"); info!("{MOD_NAME}: Fetching default fan curves");
for this in [ for this in [
PlatformPolicy::Balanced, ThrottlePolicy::Balanced,
PlatformPolicy::Performance, ThrottlePolicy::Performance,
PlatformPolicy::Quiet, ThrottlePolicy::Quiet,
] { ] {
// For each profile we need to switch to it before we // For each profile we need to switch to it before we
// can read the existing values from hardware. The ACPI method used // can read the existing values from hardware. The ACPI method used
// for this is what limits us. // for this is what limits us.
let next = PlatformPolicy::get_next_profile(this); let next = ThrottlePolicy::next(this);
platform.set_throttle_thermal_policy(next.into())?; platform.set_throttle_thermal_policy(next.into())?;
let active = platform let active = platform
.get_throttle_thermal_policy() .get_throttle_thermal_policy()
.map_or(PlatformPolicy::Balanced, |t| t.into()); .map_or(ThrottlePolicy::Balanced, |t| t.into());
info!("{MOD_NAME}: {active:?}:"); info!("{MOD_NAME}: {active:?}:");
for curve in fan_curves.get_fan_curves_for(active) { for curve in fan_curves.get_fan_curves_for(active) {
@@ -130,7 +130,7 @@ impl CtrlFanCurveZbus {
/// fan curve if in the same profile mode /// fan curve if in the same profile mode
async fn set_fan_curves_enabled( async fn set_fan_curves_enabled(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
enabled: bool, enabled: bool,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.fan_curves self.fan_curves
@@ -150,7 +150,7 @@ impl CtrlFanCurveZbus {
/// activate a fan curve if in the same profile mode /// activate a fan curve if in the same profile mode
async fn set_profile_fan_curve_enabled( async fn set_profile_fan_curve_enabled(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
@@ -170,7 +170,7 @@ impl CtrlFanCurveZbus {
/// Get the fan-curve data for the currently active PlatformPolicy /// Get the fan-curve data for the currently active PlatformPolicy
async fn fan_curve_data( async fn fan_curve_data(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
) -> zbus::fdo::Result<Vec<CurveData>> { ) -> zbus::fdo::Result<Vec<CurveData>> {
let curve = self let curve = self
.fan_curves .fan_curves
@@ -185,7 +185,7 @@ impl CtrlFanCurveZbus {
/// Will also activate the fan curve if the user is in the same mode. /// Will also activate the fan curve if the user is in the same mode.
async fn set_fan_curve( async fn set_fan_curve(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
curve: CurveData, curve: CurveData,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.fan_curves self.fan_curves
@@ -222,11 +222,11 @@ impl CtrlFanCurveZbus {
/// ///
/// Each platform_profile has a different default and the defualt can be /// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile. /// read only for the currently active profile.
async fn reset_profile_curves(&self, profile: PlatformPolicy) -> zbus::fdo::Result<()> { async fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> {
let active = self let active = self
.platform .platform
.get_throttle_thermal_policy() .get_throttle_thermal_policy()
.unwrap_or(PlatformPolicy::Balanced.into()); .unwrap_or(ThrottlePolicy::Balanced.into());
self.platform.set_throttle_thermal_policy(profile.into())?; self.platform.set_throttle_thermal_policy(profile.into())?;
self.fan_curves self.fan_curves

View File

@@ -4,8 +4,8 @@ use std::sync::Arc;
use async_trait::async_trait; use async_trait::async_trait;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::cpu::{CPUControl, CPUGovernor}; use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties, RogPlatform}; use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex; use zbus::export::futures_util::lock::Mutex;
use zbus::fdo::Error as FdoErr; use zbus::fdo::Error as FdoErr;
@@ -180,7 +180,7 @@ impl CtrlPlatform {
} }
} }
fn check_and_set_epp(&self, profile: PlatformPolicy, change_epp: bool) { fn check_and_set_epp(&self, enegy_pref: CPUEPP, change_epp: bool) {
if !change_epp { if !change_epp {
info!("PlatformPolicy unlinked from EPP"); info!("PlatformPolicy unlinked from EPP");
return; return;
@@ -189,9 +189,9 @@ impl CtrlPlatform {
if let Some(cpu) = self.cpu_control.as_ref() { if let Some(cpu) = self.cpu_control.as_ref() {
if let Ok(epp) = cpu.get_available_epp() { if let Ok(epp) = cpu.get_available_epp() {
debug!("Available EPP: {epp:?}"); debug!("Available EPP: {epp:?}");
if epp.contains(&profile.into()) { if epp.contains(&enegy_pref) {
debug!("Setting {profile:?}"); debug!("Setting {enegy_pref:?}");
cpu.set_epp(profile.into()).ok(); cpu.set_epp(enegy_pref).ok();
} else if let Ok(gov) = cpu.get_governor() { } else if let Ok(gov) = cpu.get_governor() {
if gov != CPUGovernor::Powersave { if gov != CPUGovernor::Powersave {
warn!("powersave governor is not is use, you should use it."); warn!("powersave governor is not is use, you should use it.");
@@ -201,16 +201,26 @@ impl CtrlPlatform {
} }
} }
async fn get_config_epp_for_throttle(&self, throttle: ThrottlePolicy) -> 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,
}
}
async fn update_policy_ac_or_bat(&self, power_plugged: bool, change_epp: bool) { async fn update_policy_ac_or_bat(&self, power_plugged: bool, change_epp: bool) {
let profile = if power_plugged { let throttle = if power_plugged {
self.config.lock().await.platform_policy_on_ac self.config.lock().await.throttle_policy_on_ac
} else { } else {
self.config.lock().await.platform_policy_on_battery self.config.lock().await.throttle_policy_on_battery
}; };
debug!("Setting {throttle:?} before EPP");
let epp = self.get_config_epp_for_throttle(throttle).await;
self.platform self.platform
.set_throttle_thermal_policy(profile.into()) .set_throttle_thermal_policy(throttle.into())
.ok(); .ok();
self.check_and_set_epp(profile, change_epp); self.check_and_set_epp(epp, change_epp);
} }
} }
@@ -252,7 +262,7 @@ impl CtrlPlatform {
platform_name!(panel_od, Properties::PanelOd); platform_name!(panel_od, Properties::PanelOd);
platform_name!(mini_led_mode, Properties::MiniLedMode); platform_name!(mini_led_mode, Properties::MiniLedMode);
platform_name!(egpu_enable, Properties::EgpuEnable); platform_name!(egpu_enable, Properties::EgpuEnable);
platform_name!(throttle_thermal_policy, Properties::PlatformPolicy); platform_name!(throttle_thermal_policy, Properties::ThrottlePolicy);
platform_name!(ppt_pl1_spl, Properties::PptPl1Spl); platform_name!(ppt_pl1_spl, Properties::PptPl1Spl);
platform_name!(ppt_pl2_sppt, Properties::PptPl2Sppt); platform_name!(ppt_pl2_sppt, Properties::PptPl2Sppt);
@@ -338,14 +348,15 @@ impl CtrlPlatform {
&mut self, &mut self,
#[zbus(signal_context)] ctxt: SignalContext<'_>, #[zbus(signal_context)] ctxt: SignalContext<'_>,
) -> Result<(), FdoErr> { ) -> Result<(), FdoErr> {
let policy: PlatformPolicy = let policy: ThrottlePolicy =
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
.map(|n| n.into())?; .map(|n| n.into())?;
let policy = PlatformPolicy::next(&policy); let policy = ThrottlePolicy::next(policy);
if self.platform.has_throttle_thermal_policy() { if self.platform.has_throttle_thermal_policy() {
let change_epp = self.config.lock().await.platform_policy_linked_epp; let change_epp = self.config.lock().await.throttle_policy_linked_epp;
self.check_and_set_epp(policy, change_epp); let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp);
self.platform self.platform
.set_throttle_thermal_policy(policy.into()) .set_throttle_thermal_policy(policy.into())
.map_err(|err| { .map_err(|err| {
@@ -361,17 +372,18 @@ impl CtrlPlatform {
} }
#[dbus_interface(property)] #[dbus_interface(property)]
fn throttle_thermal_policy(&self) -> Result<PlatformPolicy, FdoErr> { fn throttle_thermal_policy(&self) -> Result<ThrottlePolicy, FdoErr> {
platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy") platform_get_value!(self, throttle_thermal_policy, "throttle_thermal_policy")
.map(|n| n.into()) .map(|n| n.into())
} }
#[dbus_interface(property)] #[dbus_interface(property)]
async fn set_throttle_thermal_policy(&mut self, policy: PlatformPolicy) -> Result<(), FdoErr> { async fn set_throttle_thermal_policy(&mut self, policy: ThrottlePolicy) -> Result<(), FdoErr> {
// TODO: watch for external changes // TODO: watch for external changes
if self.platform.has_throttle_thermal_policy() { if self.platform.has_throttle_thermal_policy() {
let change_epp = self.config.lock().await.platform_policy_linked_epp; let change_epp = self.config.lock().await.throttle_policy_linked_epp;
self.check_and_set_epp(policy, change_epp); let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp);
self.platform self.platform
.set_throttle_thermal_policy(policy.into()) .set_throttle_thermal_policy(policy.into())
.map_err(|err| { .map_err(|err| {
@@ -538,7 +550,7 @@ impl crate::Reloadable for CtrlPlatform {
if let Ok(power_plugged) = self.power.get_online() { if let Ok(power_plugged) = self.power.get_online() {
if self.platform.has_throttle_thermal_policy() { if self.platform.has_throttle_thermal_policy() {
let change_epp = self.config.lock().await.platform_policy_linked_epp; let change_epp = self.config.lock().await.throttle_policy_linked_epp;
self.update_policy_ac_or_bat(power_plugged > 0, change_epp) self.update_policy_ac_or_bat(power_plugged > 0, change_epp)
.await; .await;
} }
@@ -621,7 +633,7 @@ impl CtrlTask for CtrlPlatform {
if let Ok(power_plugged) = platform1.power.get_online() { if let Ok(power_plugged) = platform1.power.get_online() {
if !sleeping && platform1.platform.has_throttle_thermal_policy() { if !sleeping && platform1.platform.has_throttle_thermal_policy() {
let change_epp = let change_epp =
platform1.config.lock().await.platform_policy_linked_epp; platform1.config.lock().await.throttle_policy_linked_epp;
platform1 platform1
.update_policy_ac_or_bat(power_plugged > 0, change_epp) .update_policy_ac_or_bat(power_plugged > 0, change_epp)
.await; .await;
@@ -658,7 +670,7 @@ impl CtrlTask for CtrlPlatform {
// power change // power change
async move { async move {
if platform3.platform.has_throttle_thermal_policy() { if platform3.platform.has_throttle_thermal_policy() {
let change_epp = platform3.config.lock().await.platform_policy_linked_epp; let change_epp = platform3.config.lock().await.throttle_policy_linked_epp;
platform3 platform3
.update_policy_ac_or_bat(power_plugged, change_epp) .update_policy_ac_or_bat(power_plugged, change_epp)
.await; .await;
@@ -705,13 +717,14 @@ impl CtrlTask for CtrlPlatform {
if let Ok(profile) = ctrl if let Ok(profile) = ctrl
.platform .platform
.get_throttle_thermal_policy() .get_throttle_thermal_policy()
.map(PlatformPolicy::from) .map(ThrottlePolicy::from)
.map_err(|e| { .map_err(|e| {
error!("Platform: get_throttle_thermal_policy error: {e}"); error!("Platform: get_throttle_thermal_policy error: {e}");
}) })
{ {
let change_epp = ctrl.config.lock().await.platform_policy_linked_epp; let change_epp = ctrl.config.lock().await.throttle_policy_linked_epp;
ctrl.check_and_set_epp(profile, change_epp); let epp = ctrl.get_config_epp_for_throttle(profile).await;
ctrl.check_and_set_epp(epp, change_epp);
} }
} }
} }

View File

@@ -1,5 +1,5 @@
use egui::{RichText, Ui}; use egui::{RichText, Ui};
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use crate::system_state::{FanCurvesState, SystemState}; use crate::system_state::{FanCurvesState, SystemState};
use crate::widgets::fan_graphs; use crate::widgets::fan_graphs;
@@ -29,7 +29,7 @@ impl RogApp {
} }
fn fan_curve( fn fan_curve(
current: &mut PlatformPolicy, current: &mut ThrottlePolicy,
curves: &mut FanCurvesState, curves: &mut FanCurvesState,
dbus: &RogDbusClientBlocking<'_>, dbus: &RogDbusClientBlocking<'_>,
do_error: &mut Option<String>, do_error: &mut Option<String>,

View File

@@ -10,7 +10,7 @@ use rog_aura::aura_detection::PowerZones;
use rog_aura::layouts::KeyLayout; use rog_aura::layouts::KeyLayout;
use rog_aura::usb::{AuraDevice, AuraPowerDev}; use rog_aura::usb::{AuraDevice, AuraPowerDev};
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
use rog_platform::platform::{GpuMode, PlatformPolicy}; use rog_platform::platform::{GpuMode, ThrottlePolicy};
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::pci_device::{GfxMode, GfxPower};
@@ -34,7 +34,7 @@ pub struct PlatformState {
pub mini_led_mode: Option<bool>, pub mini_led_mode: Option<bool>,
pub dgpu_disable: Option<bool>, pub dgpu_disable: Option<bool>,
pub egpu_enable: Option<bool>, pub egpu_enable: Option<bool>,
pub throttle: Option<PlatformPolicy>, pub throttle: Option<ThrottlePolicy>,
pub charge_limit: Option<u8>, pub charge_limit: Option<u8>,
} }
@@ -65,9 +65,9 @@ impl PlatformState {
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct FanCurvesState { pub struct FanCurvesState {
pub show_curve: PlatformPolicy, pub show_curve: ThrottlePolicy,
pub show_graph: FanCurvePU, pub show_graph: FanCurvePU,
pub curves: BTreeMap<PlatformPolicy, Vec<CurveData>>, pub curves: BTreeMap<ThrottlePolicy, Vec<CurveData>>,
pub available_fans: HashSet<FanCurvePU>, pub available_fans: HashSet<FanCurvePU>,
pub drag_delta: Vec2, pub drag_delta: Vec2,
} }
@@ -75,13 +75,13 @@ pub struct FanCurvesState {
impl FanCurvesState { impl FanCurvesState {
pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> { pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result<Self> {
let profiles = vec![ let profiles = vec![
PlatformPolicy::Balanced, ThrottlePolicy::Balanced,
PlatformPolicy::Quiet, ThrottlePolicy::Quiet,
PlatformPolicy::Performance, ThrottlePolicy::Performance,
]; ];
let mut available_fans = HashSet::new(); let mut available_fans = HashSet::new();
let mut curves: BTreeMap<PlatformPolicy, Vec<CurveData>> = BTreeMap::new(); let mut curves: BTreeMap<ThrottlePolicy, Vec<CurveData>> = BTreeMap::new();
for p in &profiles { for p in &profiles {
if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) { if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) {
if available_fans.is_empty() { if available_fans.is_empty() {

View File

@@ -14,7 +14,7 @@ use notify_rust::{Hint, Notification, NotificationHandle, Urgency};
use rog_dbus::zbus_anime::AnimeProxy; use rog_dbus::zbus_anime::AnimeProxy;
use rog_dbus::zbus_aura::AuraProxy; use rog_dbus::zbus_aura::AuraProxy;
use rog_dbus::zbus_platform::PlatformProxy; use rog_dbus::zbus_platform::PlatformProxy;
use rog_platform::platform::{GpuMode, PlatformPolicy}; use rog_platform::platform::{GpuMode, ThrottlePolicy};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use supergfxctl::actions::UserActionRequired as GfxUserAction; use supergfxctl::actions::UserActionRequired as GfxUserAction;
use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::pci_device::{GfxMode, GfxPower};
@@ -546,11 +546,11 @@ fn _ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle
Ok(base_notification(message, &data).show()?) Ok(base_notification(message, &data).show()?)
} }
fn do_thermal_notif(message: &str, profile: &PlatformPolicy) -> Result<NotificationHandle> { fn do_thermal_notif(message: &str, profile: &ThrottlePolicy) -> Result<NotificationHandle> {
let icon = match profile { let icon = match profile {
PlatformPolicy::Balanced => "asus_notif_yellow", ThrottlePolicy::Balanced => "asus_notif_yellow",
PlatformPolicy::Performance => "asus_notif_red", ThrottlePolicy::Performance => "asus_notif_red",
PlatformPolicy::Quiet => "asus_notif_green", ThrottlePolicy::Quiet => "asus_notif_green",
}; };
let profile: &str = (*profile).into(); let profile: &str = (*profile).into();
let mut notif = base_notification(message, &profile.to_uppercase()); let mut notif = base_notification(message, &profile.to_uppercase());

View File

@@ -1,6 +1,6 @@
use egui::plot::{Line, Plot, Points}; use egui::plot::{Line, Plot, Points};
use egui::Ui; use egui::Ui;
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
@@ -15,7 +15,7 @@ pub fn fan_graphs(
) { ) {
ui.separator(); ui.separator();
let mut item = |profile: PlatformPolicy, ui: &mut Ui| { let mut item = |profile: ThrottlePolicy, ui: &mut Ui| {
ui.group(|ui| { ui.group(|ui| {
if ui if ui
.selectable_value(&mut curves.show_curve, profile, format!("{profile:?}")) .selectable_value(&mut curves.show_curve, profile, format!("{profile:?}"))

View File

@@ -1,5 +1,5 @@
use egui::Ui; use egui::Ui;
use rog_platform::platform::{GpuMode, PlatformPolicy}; use rog_platform::platform::{GpuMode, ThrottlePolicy};
use crate::system_state::SystemState; use crate::system_state::SystemState;
@@ -7,7 +7,7 @@ pub fn platform_profile(states: &mut SystemState, ui: &mut Ui) {
if let Some(mut throttle) = states.bios.throttle { if let Some(mut throttle) = states.bios.throttle {
ui.heading("Platform profile"); ui.heading("Platform profile");
let mut item = |p: PlatformPolicy, ui: &mut Ui| { let mut item = |p: ThrottlePolicy, ui: &mut Ui| {
if ui if ui
.selectable_value(&mut throttle, p, format!("{p:?}")) .selectable_value(&mut throttle, p, format!("{p:?}"))
.clicked() .clicked()
@@ -25,7 +25,7 @@ pub fn platform_profile(states: &mut SystemState, ui: &mut Ui) {
}; };
ui.horizontal_wrapped(|ui| { ui.horizontal_wrapped(|ui| {
for a in PlatformPolicy::list() { for a in ThrottlePolicy::list() {
item(a, ui); item(a, ui);
} }
}); });

View File

@@ -20,7 +20,7 @@
//! //!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use zbus::dbus_proxy; use zbus::dbus_proxy;
@@ -32,30 +32,30 @@ use zbus::dbus_proxy;
)] )]
trait FanCurves { trait FanCurves {
/// Get the fan-curve data for the currently active PlatformProfile /// Get the fan-curve data for the currently active PlatformProfile
fn fan_curve_data(&self, profile: PlatformPolicy) -> zbus::Result<Vec<CurveData>>; fn fan_curve_data(&self, profile: ThrottlePolicy) -> zbus::Result<Vec<CurveData>>;
/// Reset the stored (self) and device curve to the defaults of the /// Reset the stored (self) and device curve to the defaults of the
/// platform. /// platform.
/// ///
/// Each platform_profile has a different default and the defualt can be /// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile. /// read only for the currently active profile.
fn reset_profile_curves(&self, profile: PlatformPolicy) -> zbus::fdo::Result<()>; fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()>;
/// SetActiveCurveToDefaults method /// SetActiveCurveToDefaults method
fn set_active_curve_to_defaults(&self) -> zbus::Result<()>; fn set_active_curve_to_defaults(&self) -> zbus::Result<()>;
/// Set the fan curve for the specified profile, or the profile the user is /// 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. /// currently in if profile == None. Will also activate the fan curve.
fn set_fan_curve(&self, profile: PlatformPolicy, curve: CurveData) -> zbus::Result<()>; fn set_fan_curve(&self, profile: ThrottlePolicy, curve: CurveData) -> zbus::Result<()>;
/// Set a profile fan curve enabled status. Will also activate a fan curve. /// Set a profile fan curve enabled status. Will also activate a fan curve.
fn set_fan_curves_enabled(&self, profile: PlatformPolicy, enabled: bool) -> zbus::Result<()>; fn set_fan_curves_enabled(&self, profile: ThrottlePolicy, enabled: bool) -> zbus::Result<()>;
/// Set a single fan curve for a profile to enabled status. Will also /// Set a single fan curve for a profile to enabled status. Will also
/// activate a fan curve. /// activate a fan curve.
async fn set_profile_fan_curve_enabled( async fn set_profile_fan_curve_enabled(
&self, &self,
profile: PlatformPolicy, profile: ThrottlePolicy,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool,
) -> zbus::Result<()>; ) -> zbus::Result<()>;

View File

@@ -20,7 +20,7 @@
//! //!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces. //! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use rog_platform::platform::{GpuMode, PlatformPolicy, Properties}; use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy};
use zbus::dbus_proxy; use zbus::dbus_proxy;
#[dbus_proxy( #[dbus_proxy(
@@ -120,7 +120,7 @@ trait Platform {
/// PlatformPolicy property /// PlatformPolicy property
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn throttle_thermal_policy(&self) -> zbus::Result<PlatformPolicy>; fn throttle_thermal_policy(&self) -> zbus::Result<ThrottlePolicy>;
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn set_throttle_thermal_policy(&self, value: PlatformPolicy) -> zbus::Result<()>; fn set_throttle_thermal_policy(&self, value: ThrottlePolicy) -> zbus::Result<()>;
} }

View File

@@ -6,7 +6,7 @@ use typeshare::typeshare;
use zbus::zvariant::{OwnedValue, Type, Value}; use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::{PlatformError, Result}; use crate::error::{PlatformError, Result};
use crate::platform::PlatformPolicy; use crate::platform::ThrottlePolicy;
use crate::{read_attr_string, to_device}; use crate::{read_attr_string, to_device};
const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors"; const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors";
@@ -182,10 +182,21 @@ impl From<CPUGovernor> for String {
#[typeshare] #[typeshare]
#[repr(u8)] #[repr(u8)]
#[derive( #[derive(
Deserialize, Serialize, Type, Value, OwnedValue, Debug, PartialEq, PartialOrd, Clone, Copy, Deserialize,
Serialize,
Type,
Value,
OwnedValue,
Default,
Debug,
PartialEq,
PartialOrd,
Clone,
Copy,
)] )]
#[zvariant(signature = "s")] #[zvariant(signature = "s")]
pub enum CPUEPP { pub enum CPUEPP {
#[default]
Default = 0, Default = 0,
Performance = 1, Performance = 1,
BalancePerformance = 2, BalancePerformance = 2,
@@ -193,12 +204,12 @@ pub enum CPUEPP {
Power = 4, Power = 4,
} }
impl From<PlatformPolicy> for CPUEPP { impl From<ThrottlePolicy> for CPUEPP {
fn from(value: PlatformPolicy) -> Self { fn from(value: ThrottlePolicy) -> Self {
match value { match value {
PlatformPolicy::Balanced => CPUEPP::BalancePerformance, ThrottlePolicy::Balanced => CPUEPP::BalancePerformance,
PlatformPolicy::Performance => CPUEPP::Performance, ThrottlePolicy::Performance => CPUEPP::Performance,
PlatformPolicy::Quiet => CPUEPP::Power, ThrottlePolicy::Quiet => CPUEPP::Power,
} }
} }
} }

View File

@@ -268,15 +268,15 @@ impl Display for GpuMode {
)] )]
#[zvariant(signature = "s")] #[zvariant(signature = "s")]
/// `throttle_thermal_policy` in asus_wmi /// `throttle_thermal_policy` in asus_wmi
pub enum PlatformPolicy { pub enum ThrottlePolicy {
#[default] #[default]
Balanced = 0, Balanced = 0,
Performance = 1, Performance = 1,
Quiet = 2, Quiet = 2,
} }
impl PlatformPolicy { impl ThrottlePolicy {
pub const fn next(&self) -> Self { pub const fn next(self) -> Self {
match self { match self {
Self::Balanced => Self::Performance, Self::Balanced => Self::Performance,
Self::Performance => Self::Quiet, Self::Performance => Self::Quiet,
@@ -289,7 +289,7 @@ impl PlatformPolicy {
} }
} }
impl From<u8> for PlatformPolicy { impl From<u8> for ThrottlePolicy {
fn from(num: u8) -> Self { fn from(num: u8) -> Self {
match num { match num {
0 => Self::Balanced, 0 => Self::Balanced,
@@ -303,55 +303,45 @@ impl From<u8> for PlatformPolicy {
} }
} }
impl From<PlatformPolicy> for u8 { impl From<ThrottlePolicy> for u8 {
fn from(p: PlatformPolicy) -> Self { fn from(p: ThrottlePolicy) -> Self {
match p { match p {
PlatformPolicy::Balanced => 0, ThrottlePolicy::Balanced => 0,
PlatformPolicy::Performance => 1, ThrottlePolicy::Performance => 1,
PlatformPolicy::Quiet => 2, ThrottlePolicy::Quiet => 2,
} }
} }
} }
impl From<PlatformPolicy> for &str { impl From<ThrottlePolicy> for &str {
fn from(profile: PlatformPolicy) -> &'static str { fn from(profile: ThrottlePolicy) -> &'static str {
match profile { match profile {
PlatformPolicy::Balanced => "balanced", ThrottlePolicy::Balanced => "balanced",
PlatformPolicy::Performance => "performance", ThrottlePolicy::Performance => "performance",
PlatformPolicy::Quiet => "quiet", ThrottlePolicy::Quiet => "quiet",
} }
} }
} }
impl std::str::FromStr for PlatformPolicy { impl std::str::FromStr for ThrottlePolicy {
type Err = PlatformError; type Err = PlatformError;
fn from_str(profile: &str) -> Result<Self> { fn from_str(profile: &str) -> Result<Self> {
match profile.to_ascii_lowercase().trim() { match profile.to_ascii_lowercase().trim() {
"balanced" => Ok(PlatformPolicy::Balanced), "balanced" => Ok(ThrottlePolicy::Balanced),
"performance" => Ok(PlatformPolicy::Performance), "performance" => Ok(ThrottlePolicy::Performance),
"quiet" => Ok(PlatformPolicy::Quiet), "quiet" => Ok(ThrottlePolicy::Quiet),
_ => Err(PlatformError::NotSupported), _ => Err(PlatformError::NotSupported),
} }
} }
} }
impl Display for PlatformPolicy { impl Display for ThrottlePolicy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self) write!(f, "{:?}", self)
} }
} }
impl PlatformPolicy {
pub fn get_next_profile(current: PlatformPolicy) -> PlatformPolicy {
match current {
PlatformPolicy::Balanced => PlatformPolicy::Performance,
PlatformPolicy::Performance => PlatformPolicy::Quiet,
PlatformPolicy::Quiet => PlatformPolicy::Balanced,
}
}
}
/// CamelCase names of the properties. Intended for use with DBUS /// CamelCase names of the properties. Intended for use with DBUS
#[typeshare] #[typeshare]
#[repr(u8)] #[repr(u8)]
@@ -365,7 +355,7 @@ pub enum Properties {
PanelOd, PanelOd,
MiniLedMode, MiniLedMode,
EgpuEnable, EgpuEnable,
PlatformPolicy, ThrottlePolicy,
PptPl1Spl, PptPl1Spl,
PptPl2Sppt, PptPl2Sppt,
PptFppt, PptFppt,

View File

@@ -4,7 +4,7 @@ pub mod fan_curve_set;
use error::ProfileError; use error::ProfileError;
use fan_curve_set::CurveData; use fan_curve_set::CurveData;
use log::debug; use log::debug;
use rog_platform::platform::PlatformPolicy; use rog_platform::platform::ThrottlePolicy;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare; use typeshare::typeshare;
pub use udev::Device; pub use udev::Device;
@@ -118,7 +118,7 @@ impl FanCurveProfiles {
/// ///
pub fn read_from_dev_profile( pub fn read_from_dev_profile(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
device: &Device, device: &Device,
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = Self::supported_fans()?; let fans = Self::supported_fans()?;
@@ -136,9 +136,9 @@ impl FanCurveProfiles {
} }
match profile { match profile {
PlatformPolicy::Balanced => self.balanced = curves, ThrottlePolicy::Balanced => self.balanced = curves,
PlatformPolicy::Performance => self.performance = curves, ThrottlePolicy::Performance => self.performance = curves,
PlatformPolicy::Quiet => self.quiet = curves, ThrottlePolicy::Quiet => self.quiet = curves,
} }
Ok(()) Ok(())
} }
@@ -150,7 +150,7 @@ impl FanCurveProfiles {
/// read only for the currently active profile. /// read only for the currently active profile.
pub fn set_active_curve_to_defaults( pub fn set_active_curve_to_defaults(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
device: &mut Device, device: &mut Device,
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = Self::supported_fans()?; let fans = Self::supported_fans()?;
@@ -170,13 +170,13 @@ impl FanCurveProfiles {
// TODO: Make this return an error if curve is zeroed // TODO: Make this return an error if curve is zeroed
pub fn write_profile_curve_to_platform( pub fn write_profile_curve_to_platform(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
device: &mut Device, device: &mut Device,
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
let fans = match profile { let fans = match profile {
PlatformPolicy::Balanced => &mut self.balanced, ThrottlePolicy::Balanced => &mut self.balanced,
PlatformPolicy::Performance => &mut self.performance, ThrottlePolicy::Performance => &mut self.performance,
PlatformPolicy::Quiet => &mut self.quiet, ThrottlePolicy::Quiet => &mut self.quiet,
}; };
for fan in fans { for fan in fans {
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}"); debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
@@ -185,19 +185,19 @@ impl FanCurveProfiles {
Ok(()) Ok(())
} }
pub fn set_profile_curves_enabled(&mut self, profile: PlatformPolicy, enabled: bool) { pub fn set_profile_curves_enabled(&mut self, profile: ThrottlePolicy, enabled: bool) {
match profile { match profile {
PlatformPolicy::Balanced => { ThrottlePolicy::Balanced => {
for curve in self.balanced.iter_mut() { for curve in self.balanced.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
} }
PlatformPolicy::Performance => { ThrottlePolicy::Performance => {
for curve in self.performance.iter_mut() { for curve in self.performance.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
} }
PlatformPolicy::Quiet => { ThrottlePolicy::Quiet => {
for curve in self.quiet.iter_mut() { for curve in self.quiet.iter_mut() {
curve.enabled = enabled; curve.enabled = enabled;
} }
@@ -207,12 +207,12 @@ impl FanCurveProfiles {
pub fn set_profile_fan_curve_enabled( pub fn set_profile_fan_curve_enabled(
&mut self, &mut self,
profile: PlatformPolicy, profile: ThrottlePolicy,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool, enabled: bool,
) { ) {
match profile { match profile {
PlatformPolicy::Balanced => { ThrottlePolicy::Balanced => {
for curve in self.balanced.iter_mut() { for curve in self.balanced.iter_mut() {
if curve.fan == fan { if curve.fan == fan {
curve.enabled = enabled; curve.enabled = enabled;
@@ -220,7 +220,7 @@ impl FanCurveProfiles {
} }
} }
} }
PlatformPolicy::Performance => { ThrottlePolicy::Performance => {
for curve in self.performance.iter_mut() { for curve in self.performance.iter_mut() {
if curve.fan == fan { if curve.fan == fan {
curve.enabled = enabled; curve.enabled = enabled;
@@ -228,7 +228,7 @@ impl FanCurveProfiles {
} }
} }
} }
PlatformPolicy::Quiet => { ThrottlePolicy::Quiet => {
for curve in self.quiet.iter_mut() { for curve in self.quiet.iter_mut() {
if curve.fan == fan { if curve.fan == fan {
curve.enabled = enabled; curve.enabled = enabled;
@@ -239,31 +239,31 @@ impl FanCurveProfiles {
} }
} }
pub fn get_fan_curves_for(&self, name: PlatformPolicy) -> &[CurveData] { pub fn get_fan_curves_for(&self, name: ThrottlePolicy) -> &[CurveData] {
match name { match name {
PlatformPolicy::Balanced => &self.balanced, ThrottlePolicy::Balanced => &self.balanced,
PlatformPolicy::Performance => &self.performance, ThrottlePolicy::Performance => &self.performance,
PlatformPolicy::Quiet => &self.quiet, ThrottlePolicy::Quiet => &self.quiet,
} }
} }
pub fn get_fan_curve_for(&self, name: &PlatformPolicy, pu: FanCurvePU) -> Option<&CurveData> { pub fn get_fan_curve_for(&self, name: &ThrottlePolicy, pu: FanCurvePU) -> Option<&CurveData> {
match name { match name {
PlatformPolicy::Balanced => { ThrottlePolicy::Balanced => {
for this_curve in self.balanced.iter() { for this_curve in self.balanced.iter() {
if this_curve.fan == pu { if this_curve.fan == pu {
return Some(this_curve); return Some(this_curve);
} }
} }
} }
PlatformPolicy::Performance => { ThrottlePolicy::Performance => {
for this_curve in self.performance.iter() { for this_curve in self.performance.iter() {
if this_curve.fan == pu { if this_curve.fan == pu {
return Some(this_curve); return Some(this_curve);
} }
} }
} }
PlatformPolicy::Quiet => { ThrottlePolicy::Quiet => {
for this_curve in self.quiet.iter() { for this_curve in self.quiet.iter() {
if this_curve.fan == pu { if this_curve.fan == pu {
return Some(this_curve); return Some(this_curve);
@@ -277,10 +277,10 @@ impl FanCurveProfiles {
pub fn save_fan_curve( pub fn save_fan_curve(
&mut self, &mut self,
curve: CurveData, curve: CurveData,
profile: PlatformPolicy, profile: ThrottlePolicy,
) -> Result<(), ProfileError> { ) -> Result<(), ProfileError> {
match profile { match profile {
PlatformPolicy::Balanced => { ThrottlePolicy::Balanced => {
for this_curve in self.balanced.iter_mut() { for this_curve in self.balanced.iter_mut() {
if this_curve.fan == curve.fan { if this_curve.fan == curve.fan {
*this_curve = curve; *this_curve = curve;
@@ -288,7 +288,7 @@ impl FanCurveProfiles {
} }
} }
} }
PlatformPolicy::Performance => { ThrottlePolicy::Performance => {
for this_curve in self.performance.iter_mut() { for this_curve in self.performance.iter_mut() {
if this_curve.fan == curve.fan { if this_curve.fan == curve.fan {
*this_curve = curve; *this_curve = curve;
@@ -296,7 +296,7 @@ impl FanCurveProfiles {
} }
} }
} }
PlatformPolicy::Quiet => { ThrottlePolicy::Quiet => {
for this_curve in self.quiet.iter_mut() { for this_curve in self.quiet.iter_mut() {
if this_curve.fan == curve.fan { if this_curve.fan == curve.fan {
*this_curve = curve; *this_curve = curve;