From 65ba339fb5edc55a3f0d582bc8fd7ef3c90c0e27 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 8 Apr 2020 12:15:55 -0600 Subject: [PATCH] Sync fan changes to darp5/galp3-c --- src/board/system76/darp5/peci.c | 16 +++++++++++----- src/board/system76/galp3-c/peci.c | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/board/system76/darp5/peci.c b/src/board/system76/darp5/peci.c index 945a6b2..235c3c9 100644 --- a/src/board/system76/darp5/peci.c +++ b/src/board/system76/darp5/peci.c @@ -8,11 +8,14 @@ #include // Fan speed is the lowest requested over HEATUP seconds -#define HEATUP 5 +#define HEATUP 10 // Fan speed is the highest HEATUP speed over COOLDOWN seconds #define COOLDOWN 10 +// Interpolate duty cycle +#define INTERPOLATE 0 + // Tjunction = 100C for i7-8565U (and probably the same for all WHL-U) #define T_JUNCTION 100 @@ -33,10 +36,9 @@ struct FanPoint { // Fan curve with temperature in degrees C, duty cycle in percent struct FanPoint __code FAN_POINTS[] = { FAN_POINT(65, 40), - FAN_POINT(70, 45), - FAN_POINT(75, 55), - FAN_POINT(80, 75), - FAN_POINT(84, 100) + FAN_POINT(70, 55), + FAN_POINT(75, 75), + FAN_POINT(80, 100) }; // Get duty cycle based on temperature, adapted from @@ -55,6 +57,7 @@ uint8_t fan_duty(int16_t temp) { } else { const struct FanPoint * prev = &FAN_POINTS[i - 1]; +#if INTERPOLATE // If in between current temp and previous temp, interpolate if (temp > prev->temp) { int16_t dtemp = (cur->temp - prev->temp); @@ -64,6 +67,9 @@ uint8_t fan_duty(int16_t temp) { ((temp - prev->temp) * dduty) / dtemp ); } +#else // INTERPOLATE + return prev->duty; +#endif // INTERPOLATE } } } diff --git a/src/board/system76/galp3-c/peci.c b/src/board/system76/galp3-c/peci.c index 945a6b2..235c3c9 100644 --- a/src/board/system76/galp3-c/peci.c +++ b/src/board/system76/galp3-c/peci.c @@ -8,11 +8,14 @@ #include // Fan speed is the lowest requested over HEATUP seconds -#define HEATUP 5 +#define HEATUP 10 // Fan speed is the highest HEATUP speed over COOLDOWN seconds #define COOLDOWN 10 +// Interpolate duty cycle +#define INTERPOLATE 0 + // Tjunction = 100C for i7-8565U (and probably the same for all WHL-U) #define T_JUNCTION 100 @@ -33,10 +36,9 @@ struct FanPoint { // Fan curve with temperature in degrees C, duty cycle in percent struct FanPoint __code FAN_POINTS[] = { FAN_POINT(65, 40), - FAN_POINT(70, 45), - FAN_POINT(75, 55), - FAN_POINT(80, 75), - FAN_POINT(84, 100) + FAN_POINT(70, 55), + FAN_POINT(75, 75), + FAN_POINT(80, 100) }; // Get duty cycle based on temperature, adapted from @@ -55,6 +57,7 @@ uint8_t fan_duty(int16_t temp) { } else { const struct FanPoint * prev = &FAN_POINTS[i - 1]; +#if INTERPOLATE // If in between current temp and previous temp, interpolate if (temp > prev->temp) { int16_t dtemp = (cur->temp - prev->temp); @@ -64,6 +67,9 @@ uint8_t fan_duty(int16_t temp) { ((temp - prev->temp) * dduty) / dtemp ); } +#else // INTERPOLATE + return prev->duty; +#endif // INTERPOLATE } } }