Fix applying disabled and enabled fan curves

This commit is contained in:
Luke D. Jones
2024-03-14 21:10:23 +13:00
parent 6b0edc6da1
commit e8627fde4c
11 changed files with 191 additions and 141 deletions

View File

@@ -1,6 +1,3 @@
use std::fs::OpenOptions;
use std::io::Write;
use log::trace;
use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare;
@@ -186,14 +183,9 @@ impl CurveData {
}
// Enable must be done *after* all points are written pwm3_enable
// device.syspath()
let mut path = device.syspath().to_path_buf();
path.push(format!("pwm{pwm_num}_enable"));
let mut f = OpenOptions::new().write(true).open(path).unwrap();
f.write_all(&[enable as u8]).unwrap();
// device
// .set_attribute_value(format!("pwm{pwm_num}_enable"), enable.to_string())
// .unwrap();
device
.set_attribute_value(format!("pwm{pwm_num}_enable"), enable.to_string())
.unwrap();
Ok(())
}
}

View File

@@ -183,7 +183,13 @@ impl FanCurveProfiles {
ThrottlePolicy::Performance => &mut self.performance,
ThrottlePolicy::Quiet => &mut self.quiet,
};
for fan in fans {
for fan in fans.iter().filter(|f| !f.enabled) {
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
fan.write_to_device(device)?;
}
// Write enabled fans last because the kernel currently resets *all* if one is
// disabled
for fan in fans.iter().filter(|f| f.enabled) {
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
fan.write_to_device(device)?;
}