Skip to content

Commit a201bcf

Browse files
allow ACPI to set fan speeds
Smooth ACPI fan pwm values same as EC fan curve points
1 parent f8d1123 commit a201bcf

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/board/system76/common/acpi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <board/acpi.h>
44
#include <board/battery.h>
55
#include <board/dgpu.h>
6+
#include <board/fan.h>
67
#include <board/gpio.h>
78
#include <board/kbled.h>
89
#include <board/lid.h>
@@ -224,5 +225,13 @@ void acpi_write(uint8_t addr, uint8_t data) {
224225
case 0xFD:
225226
fbuf[3] = data;
226227
break;
228+
case 0xCE:
229+
acpi_peci_fan_duty = data;
230+
break;
231+
#if HAVE_DGPU
232+
case 0xCF:
233+
acpi_dgpu_fan_duty = data;
234+
break;
235+
#endif
227236
}
228237
}

src/board/system76/common/fan.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#define MIN_SPEED_TO_SMOOTH PWM_DUTY(SMOOTH_FANS_MIN)
1616

1717
bool fan_max = false;
18+
uint8_t acpi_peci_fan_duty = 0;
19+
uint8_t acpi_dgpu_fan_duty = 0;
1820
uint8_t last_duty_dgpu = 0;
1921
uint8_t last_duty_peci = 0;
2022

@@ -66,16 +68,23 @@ void fan_duty_set(uint8_t peci_fan_duty, uint8_t dgpu_fan_duty) __reentrant {
6668
dgpu_fan_duty = peci_fan_duty > dgpu_fan_duty ? peci_fan_duty : dgpu_fan_duty;
6769
#endif
6870

71+
// allow for ACPI to request a higher duty
72+
peci_fan_duty = peci_fan_duty > acpi_peci_fan_duty ? peci_fan_duty : acpi_peci_fan_duty;
73+
dgpu_fan_duty = dgpu_fan_duty > acpi_dgpu_fan_duty ? dgpu_fan_duty : acpi_dgpu_fan_duty;
74+
6975
// set PECI fan duty
7076
if (peci_fan_duty != DCR2) {
77+
TRACE("PECI acpi_fan_duty_raw=%d\n", acpi_peci_fan_duty);
7178
TRACE("PECI fan_duty_raw=%d\n", peci_fan_duty);
79+
// allow for ACPI to request a higher duty
7280
last_duty_peci = peci_fan_duty = fan_smooth(last_duty_peci, peci_fan_duty);
7381
DCR2 = fan_max ? MAX_FAN_SPEED : peci_fan_duty;
7482
TRACE("PECI fan_duty_smoothed=%d\n", peci_fan_duty);
7583
}
7684

7785
// set dGPU fan duty
7886
if (dgpu_fan_duty != DCR4) {
87+
TRACE("DGPU acpi_fan_duty_raw=%d\n", acpi_peci_fan_duty);
7988
TRACE("DGPU fan_duty_raw=%d\n", dgpu_fan_duty);
8089
last_duty_dgpu = dgpu_fan_duty = fan_smooth(last_duty_dgpu, dgpu_fan_duty);
8190
DCR4 = fan_max ? MAX_FAN_SPEED : dgpu_fan_duty;

src/board/system76/common/include/board/fan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct Fan {
4646
bool interpolate;
4747
};
4848

49+
extern uint8_t acpi_dgpu_fan_duty;
50+
extern uint8_t acpi_peci_fan_duty;
4951
extern bool fan_max;
5052

5153
void fan_reset(void);

0 commit comments

Comments
 (0)