mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
fix: only set PMFW options when they're different from the current value
This commit is contained in:
parent
0d675c5b3a
commit
ca3e54015a
@ -363,7 +363,7 @@ impl GpuController {
|
|||||||
|
|
||||||
// Use PMFW curve functionality for static speed when it is available
|
// Use PMFW curve functionality for static speed when it is available
|
||||||
if let Ok(current_curve) = self.handle.get_fan_curve() {
|
if let Ok(current_curve) = self.handle.get_fan_curve() {
|
||||||
let allowed_ranges = current_curve.allowed_ranges.ok_or_else(|| {
|
let allowed_ranges = current_curve.allowed_ranges.clone().ok_or_else(|| {
|
||||||
anyhow!("The GPU does not allow setting custom fan values (is overdrive enabled?)")
|
anyhow!("The GPU does not allow setting custom fan values (is overdrive enabled?)")
|
||||||
})?;
|
})?;
|
||||||
let min_temperature = allowed_ranges.temperature_range.start();
|
let min_temperature = allowed_ranges.temperature_range.start();
|
||||||
@ -383,11 +383,15 @@ impl GpuController {
|
|||||||
allowed_ranges: Some(allowed_ranges),
|
allowed_ranges: Some(allowed_ranges),
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("setting static curve {new_curve:?}");
|
if new_curve == current_curve {
|
||||||
|
debug!("fan curve unchanged");
|
||||||
|
} else {
|
||||||
|
debug!("setting static curve {new_curve:?}");
|
||||||
|
|
||||||
self.handle
|
self.handle
|
||||||
.set_fan_curve(&new_curve)
|
.set_fan_curve(&new_curve)
|
||||||
.context("Could not set fan curve")?;
|
.context("Could not set fan curve")?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
@ -425,13 +429,18 @@ impl GpuController {
|
|||||||
match self.handle.get_fan_curve() {
|
match self.handle.get_fan_curve() {
|
||||||
Ok(current_curve) => {
|
Ok(current_curve) => {
|
||||||
let new_curve = curve
|
let new_curve = curve
|
||||||
.into_pmfw_curve(current_curve)
|
.into_pmfw_curve(current_curve.clone())
|
||||||
.context("Invalid fan curve")?;
|
.context("Invalid fan curve")?;
|
||||||
debug!("setting pmfw curve {new_curve:?}");
|
|
||||||
|
|
||||||
self.handle
|
if new_curve == current_curve {
|
||||||
.set_fan_curve(&new_curve)
|
debug!("fan curve unchanged");
|
||||||
.context("Could not set fan curve")?;
|
} else {
|
||||||
|
debug!("setting pmfw curve {new_curve:?}");
|
||||||
|
|
||||||
|
self.handle
|
||||||
|
.set_fan_curve(&new_curve)
|
||||||
|
.context("Could not set fan curve")?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -820,24 +829,56 @@ impl GpuController {
|
|||||||
|
|
||||||
let pmfw = &config.pmfw_options;
|
let pmfw = &config.pmfw_options;
|
||||||
if let Some(acoustic_limit) = pmfw.acoustic_limit {
|
if let Some(acoustic_limit) = pmfw.acoustic_limit {
|
||||||
self.handle
|
if self
|
||||||
.set_fan_acoustic_limit(acoustic_limit)
|
.handle
|
||||||
.context("Could not set acoustic limit")?;
|
.get_fan_acoustic_limit()
|
||||||
|
.context("Could not get acoustic limit")?
|
||||||
|
.current
|
||||||
|
!= acoustic_limit
|
||||||
|
{
|
||||||
|
self.handle
|
||||||
|
.set_fan_acoustic_limit(acoustic_limit)
|
||||||
|
.context("Could not set acoustic limit")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(acoustic_target) = pmfw.acoustic_target {
|
if let Some(acoustic_target) = pmfw.acoustic_target {
|
||||||
self.handle
|
if self
|
||||||
.set_fan_acoustic_target(acoustic_target)
|
.handle
|
||||||
.context("Could not set acoustic target")?;
|
.get_fan_acoustic_target()
|
||||||
|
.context("Could not get acoustic target")?
|
||||||
|
.current
|
||||||
|
!= acoustic_target
|
||||||
|
{
|
||||||
|
self.handle
|
||||||
|
.set_fan_acoustic_target(acoustic_target)
|
||||||
|
.context("Could not set acoustic target")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(target_temperature) = pmfw.target_temperature {
|
if let Some(target_temperature) = pmfw.target_temperature {
|
||||||
self.handle
|
if self
|
||||||
.set_fan_target_temperature(target_temperature)
|
.handle
|
||||||
.context("Could not set target temperature")?;
|
.get_fan_target_temperature()
|
||||||
|
.context("Could not get target temperature")?
|
||||||
|
.current
|
||||||
|
!= target_temperature
|
||||||
|
{
|
||||||
|
self.handle
|
||||||
|
.set_fan_target_temperature(target_temperature)
|
||||||
|
.context("Could not set target temperature")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(minimum_pwm) = pmfw.minimum_pwm {
|
if let Some(minimum_pwm) = pmfw.minimum_pwm {
|
||||||
self.handle
|
if self
|
||||||
.set_fan_minimum_pwm(minimum_pwm)
|
.handle
|
||||||
.context("Could not set minimum pwm")?;
|
.get_fan_minimum_pwm()
|
||||||
|
.context("Could not get minimum pwm")?
|
||||||
|
.current
|
||||||
|
!= minimum_pwm
|
||||||
|
{
|
||||||
|
self.handle
|
||||||
|
.set_fan_minimum_pwm(minimum_pwm)
|
||||||
|
.context("Could not set minimum pwm")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user