diff options
Diffstat (limited to 'zephyr/program/skyrim/winterhold/src/thermal.c')
-rw-r--r-- | zephyr/program/skyrim/winterhold/src/thermal.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/zephyr/program/skyrim/winterhold/src/thermal.c b/zephyr/program/skyrim/winterhold/src/thermal.c new file mode 100644 index 0000000000..2c9432be09 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/thermal.c @@ -0,0 +1,32 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "hooks.h" +#include "host_command.h" +#include "temp_sensor/temp_sensor.h" + +#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_THERMAL, format, ##args) + +#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_sensor_amb)) + +static int last_amb_temp = -1; + +/* Set SCI event to host for temperature change */ +static void detect_temp_change(void) +{ + int t, rv; + + rv = temp_sensor_read(TEMP_AMB, &t); + if (rv == EC_SUCCESS) { + if (last_amb_temp != t) { + last_amb_temp = t; + host_set_single_event(EC_HOST_EVENT_THERMAL_THRESHOLD); + } + } else if (rv == EC_ERROR_INVAL) { + CPRINTS("Temp sensor: Invalid id"); + } +} +DECLARE_HOOK(HOOK_SECOND, detect_temp_change, HOOK_PRIO_TEMP_SENSOR_DONE); |