Skip to content

Commit

Permalink
Sync fans based on temp instead of duty
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
crawfxrd committed Jul 15, 2024
1 parent c1c7363 commit fc588f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
15 changes: 6 additions & 9 deletions src/board/system76/common/fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,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
Expand Down
4 changes: 0 additions & 4 deletions src/board/system76/common/include/board/fan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc588f7

Please sign in to comment.