mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fix fan controls on z13
This commit is contained in:
@@ -162,7 +162,6 @@ impl CurveData {
|
||||
/// Write this curve to the device fan specified by `self.fan`
|
||||
pub fn write_to_device(&self, device: &mut Device) -> std::io::Result<()> {
|
||||
let pwm_num: char = self.fan.into();
|
||||
let enable = if self.enabled { '1' } else { '2' };
|
||||
|
||||
for (index, out) in self.pwm.iter().enumerate() {
|
||||
let pwm = pwm_str(pwm_num, index);
|
||||
@@ -176,10 +175,20 @@ impl CurveData {
|
||||
device.set_attribute_value(&temp, out.to_string())?;
|
||||
}
|
||||
|
||||
// Enable must be done *after* all points are written pwm3_enable
|
||||
// Note: pwm_enable is set by write_profile_curve_to_platform after all
|
||||
// curves are written, because on some devices (e.g., ASUS Z13 2025)
|
||||
// setting any pwm_enable to 2 resets ALL fan enables.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the enable state for this fan curve
|
||||
pub fn set_enable(&self, device: &mut Device) -> std::io::Result<()> {
|
||||
let pwm_num: char = self.fan.into();
|
||||
let enable = if self.enabled { "1" } else { "2" };
|
||||
let enable_attr = format!("pwm{pwm_num}_enable");
|
||||
device
|
||||
.set_attribute_value(format!("pwm{pwm_num}_enable"), enable.to_string())
|
||||
.map_err(|e| error!("Failed to set pwm{pwm_num}_enable to {enable}: {e:?}"))
|
||||
.set_attribute_value(&enable_attr, enable.to_string())
|
||||
.map_err(|e| error!("Failed to set {enable_attr} to {enable}: {e:?}"))
|
||||
.ok();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -181,15 +181,29 @@ impl FanCurveProfiles {
|
||||
PlatformProfile::Quiet | PlatformProfile::LowPower => &mut self.quiet,
|
||||
PlatformProfile::Custom => &mut self.custom,
|
||||
};
|
||||
for fan in fans.iter().filter(|f| !f.enabled) {
|
||||
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
|
||||
|
||||
// First write all curve data (pwm/temp values) for all fans
|
||||
for fan in fans.iter() {
|
||||
debug!("write_profile_curve_to_platform: writing curve data for profile:{profile}, {fan:?}");
|
||||
fan.write_to_device(device)?;
|
||||
}
|
||||
// Write enabled fans last because the kernel currently resets *all* if one is
|
||||
// disabled
|
||||
|
||||
// Then set enables: disabled fans first, then enabled fans last.
|
||||
// This order is important because on some devices (e.g., ASUS Z13 2025)
|
||||
// setting any pwm_enable to 2 (disabled) resets ALL fan enables.
|
||||
for fan in fans.iter().filter(|f| !f.enabled) {
|
||||
debug!(
|
||||
"write_profile_curve_to_platform: disabling fan for profile:{profile}, {:?}",
|
||||
fan.fan
|
||||
);
|
||||
fan.set_enable(device)?;
|
||||
}
|
||||
for fan in fans.iter().filter(|f| f.enabled) {
|
||||
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
|
||||
fan.write_to_device(device)?;
|
||||
debug!(
|
||||
"write_profile_curve_to_platform: enabling fan for profile:{profile}, {:?}",
|
||||
fan.fan
|
||||
);
|
||||
fan.set_enable(device)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user