From 348a582c4909dca4bb23a4a19e4b48042619a7df Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Fri, 5 Jul 2024 11:05:22 -0600 Subject: [PATCH] Sync fans based on temp instead of duty Calculate fan duties based on the highest reported temperature instead of using the highest duty calculated for each temperature. Allows having independent fan curves for different fans. Remove `SYNC_FANS` as this is always true. Signed-off-by: Tim Crawford --- src/board/system76/common/fan.c | 15 ++++++--------- src/board/system76/common/include/board/fan.h | 4 ---- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/board/system76/common/fan.c b/src/board/system76/common/fan.c index 1d59b0802..555159602 100644 --- a/src/board/system76/common/fan.c +++ b/src/board/system76/common/fan.c @@ -228,18 +228,15 @@ static uint8_t fan_get_duty(const struct Fan *const fan, int16_t temp) { } void fan_update_duty(void) { -#if defined(FAN2_PWM) && !CONFIG_HAVE_DGPU - int16_t dgpu_temp = peci_temp; +#if CONFIG_HAVE_DGPU + int16_t sys_temp = MAX(peci_temp, dgpu_temp); +#else + int16_t sys_temp = peci_temp; #endif - uint8_t fan1_duty = fan_get_duty(&FAN1, peci_temp); + uint8_t fan1_duty = fan_get_duty(&FAN1, sys_temp); #ifdef FAN2_PWM - uint8_t fan2_duty = fan_get_duty(&FAN2, dgpu_temp); - -#if SYNC_FANS != 0 - fan1_duty = MAX(fan1_duty, fan2_duty); - fan2_duty = MAX(fan1_duty, fan2_duty); -#endif // SYNC_FANS + uint8_t fan2_duty = fan_get_duty(&FAN2, sys_temp); #endif // FAN2_PWM // set FAN1 duty diff --git a/src/board/system76/common/include/board/fan.h b/src/board/system76/common/include/board/fan.h index 184ab21c4..53360f660 100644 --- a/src/board/system76/common/include/board/fan.h +++ b/src/board/system76/common/include/board/fan.h @@ -14,10 +14,6 @@ #define SMOOTH_FANS 1 // default to fan smoothing #endif -#ifndef SYNC_FANS -#define SYNC_FANS 1 // default to syncing fan speeds -#endif - #if SMOOTH_FANS != 0 #ifndef SMOOTH_FANS_UP #define SMOOTH_FANS_UP 45 // default to ~11 seconds for full ramp-up