ROGCC: better handling of platform profile

This commit is contained in:
Luke Jones
2025-03-03 16:31:43 +13:00
parent f164583792
commit 192e5ccaa3
14 changed files with 190 additions and 46 deletions

View File

@@ -113,6 +113,7 @@ pub struct FanCurveProfiles {
pub balanced: Vec<CurveData>,
pub performance: Vec<CurveData>,
pub quiet: Vec<CurveData>,
pub custom: Vec<CurveData>,
}
impl FanCurveProfiles {
@@ -146,6 +147,7 @@ impl FanCurveProfiles {
PlatformProfile::Balanced => self.balanced = curves,
PlatformProfile::Performance => self.performance = curves,
PlatformProfile::Quiet | PlatformProfile::LowPower => self.quiet = curves,
PlatformProfile::Custom => self.custom = curves,
}
Ok(())
}
@@ -182,6 +184,7 @@ impl FanCurveProfiles {
PlatformProfile::Balanced => &mut self.balanced,
PlatformProfile::Performance => &mut self.performance,
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:?}");
@@ -213,6 +216,11 @@ impl FanCurveProfiles {
curve.enabled = enabled;
}
}
PlatformProfile::Custom => {
for curve in self.custom.iter_mut() {
curve.enabled = enabled;
}
}
}
}
@@ -247,6 +255,14 @@ impl FanCurveProfiles {
}
}
}
PlatformProfile::Custom => {
for curve in self.custom.iter_mut() {
if curve.fan == fan {
curve.enabled = enabled;
break;
}
}
}
}
}
@@ -255,6 +271,7 @@ impl FanCurveProfiles {
PlatformProfile::Balanced => &self.balanced,
PlatformProfile::Performance => &self.performance,
PlatformProfile::Quiet | PlatformProfile::LowPower => &self.quiet,
PlatformProfile::Custom => &self.custom,
}
}
@@ -281,6 +298,13 @@ impl FanCurveProfiles {
}
}
}
PlatformProfile::Custom => {
for this_curve in self.custom.iter() {
if this_curve.fan == pu {
return Some(this_curve);
}
}
}
}
None
}
@@ -315,6 +339,14 @@ impl FanCurveProfiles {
}
}
}
PlatformProfile::Custom => {
for this_curve in self.custom.iter_mut() {
if this_curve.fan == curve.fan {
*this_curve = curve;
break;
}
}
}
}
Ok(())
}