Fix the fan curve defaults again

This commit is contained in:
Luke D. Jones
2024-03-13 21:19:01 +13:00
parent 78f18959fb
commit d51384c3a1
2 changed files with 19 additions and 19 deletions

View File

@@ -1,5 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_lite::StreamExt; use futures_lite::StreamExt;
@@ -65,27 +67,25 @@ impl CtrlFanCurveZbus {
if config.profiles.balanced.is_empty() || !config.file_path().exists() { if config.profiles.balanced.is_empty() || !config.file_path().exists() {
info!("{MOD_NAME}: Fetching default fan curves"); info!("{MOD_NAME}: Fetching default fan curves");
let current = platform.get_throttle_thermal_policy()?;
for this in [ for this in [
ThrottlePolicy::Balanced, ThrottlePolicy::Balanced,
ThrottlePolicy::Performance, ThrottlePolicy::Performance,
ThrottlePolicy::Quiet, ThrottlePolicy::Quiet,
] { ] {
let mut dev = find_fan_curve_node()?;
// 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 = ThrottlePolicy::next(this); platform.set_throttle_thermal_policy(this.into())?;
platform.set_throttle_thermal_policy(next.into())?; fan_curves.set_active_curve_to_defaults(this, &mut dev)?;
let active = platform info!("{MOD_NAME}: {this:?}:");
.get_throttle_thermal_policy() for curve in fan_curves.get_fan_curves_for(this) {
.map_or(ThrottlePolicy::Balanced, |t| t.into());
fan_curves.read_from_dev_profile(active, &find_fan_curve_node()?)?;
info!("{MOD_NAME}: {active:?}:");
for curve in fan_curves.get_fan_curves_for(active) {
info!("{}", String::from(curve)); info!("{}", String::from(curve));
} }
} }
platform.set_throttle_thermal_policy(current)?;
config.profiles = fan_curves; config.profiles = fan_curves;
config.write(); config.write();
} else { } else {

View File

@@ -67,6 +67,16 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// supported.add_to_server(&mut connection).await; // supported.add_to_server(&mut connection).await;
match CtrlFanCurveZbus::new() {
Ok(ctrl) => {
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?;
}
Err(err) => {
error!("FanCurves: {}", err);
}
}
match CtrlPlatform::new( match CtrlPlatform::new(
config.clone(), config.clone(),
&cfg_path, &cfg_path,
@@ -81,16 +91,6 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
} }
} }
match CtrlFanCurveZbus::new() {
Ok(ctrl) => {
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?;
start_tasks(ctrl, &mut connection, sig_ctx).await?;
}
Err(err) => {
error!("FanCurves: {}", err);
}
}
match CtrlAnime::new(AnimeConfig::new().load()) { match CtrlAnime::new(AnimeConfig::new().load()) {
Ok(ctrl) => { Ok(ctrl) => {
let zbus = CtrlAnimeZbus(Arc::new(Mutex::new(ctrl))); let zbus = CtrlAnimeZbus(Arc::new(Mutex::new(ctrl)));