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`
|
/// Write this curve to the device fan specified by `self.fan`
|
||||||
pub fn write_to_device(&self, device: &mut Device) -> std::io::Result<()> {
|
pub fn write_to_device(&self, device: &mut Device) -> std::io::Result<()> {
|
||||||
let pwm_num: char = self.fan.into();
|
let pwm_num: char = self.fan.into();
|
||||||
let enable = if self.enabled { '1' } else { '2' };
|
|
||||||
|
|
||||||
for (index, out) in self.pwm.iter().enumerate() {
|
for (index, out) in self.pwm.iter().enumerate() {
|
||||||
let pwm = pwm_str(pwm_num, index);
|
let pwm = pwm_str(pwm_num, index);
|
||||||
@@ -176,10 +175,20 @@ impl CurveData {
|
|||||||
device.set_attribute_value(&temp, out.to_string())?;
|
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
|
device
|
||||||
.set_attribute_value(format!("pwm{pwm_num}_enable"), enable.to_string())
|
.set_attribute_value(&enable_attr, enable.to_string())
|
||||||
.map_err(|e| error!("Failed to set pwm{pwm_num}_enable to {enable}: {e:?}"))
|
.map_err(|e| error!("Failed to set {enable_attr} to {enable}: {e:?}"))
|
||||||
.ok();
|
.ok();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,15 +181,29 @@ impl FanCurveProfiles {
|
|||||||
PlatformProfile::Quiet | PlatformProfile::LowPower => &mut self.quiet,
|
PlatformProfile::Quiet | PlatformProfile::LowPower => &mut self.quiet,
|
||||||
PlatformProfile::Custom => &mut self.custom,
|
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)?;
|
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) {
|
for fan in fans.iter().filter(|f| f.enabled) {
|
||||||
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
|
debug!(
|
||||||
fan.write_to_device(device)?;
|
"write_profile_curve_to_platform: enabling fan for profile:{profile}, {:?}",
|
||||||
|
fan.fan
|
||||||
|
);
|
||||||
|
fan.set_enable(device)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user