diff options
author | Tobias Heider <tobhe@cvs.openbsd.org> | 2022-11-25 20:33:12 +0000 |
---|---|---|
committer | Tobias Heider <tobhe@cvs.openbsd.org> | 2022-11-25 20:33:12 +0000 |
commit | a6e7e6e1d05cd78cf79b7edc3755035fa2e84a9a (patch) | |
tree | cfe1d1219e0ae0fb26da2619b2607282dbc00dfe | |
parent | 30f04e646e5f539b2c42edf98b2f8b0a74018d52 (diff) |
Disable screen backlight on Apple silicon laptops when lid is closed.
ok kettenis@
-rw-r--r-- | sys/arch/arm64/dev/aplsmc.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sys/arch/arm64/dev/aplsmc.c b/sys/arch/arm64/dev/aplsmc.c index e3a82a7dd6f..449a4f7ce66 100644 --- a/sys/arch/arm64/dev/aplsmc.c +++ b/sys/arch/arm64/dev/aplsmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aplsmc.c,v 1.18 2022/11/14 11:11:17 kettenis Exp $ */ +/* $OpenBSD: aplsmc.c,v 1.19 2022/11/25 20:33:11 tobhe Exp $ */ /* * Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org> * @@ -37,6 +37,8 @@ #include "apm.h" +extern void (*simplefb_burn_hook)(u_int); + extern void (*cpuresetfn)(void); extern void (*powerdownfn)(void); @@ -96,6 +98,10 @@ struct aplsmc_sensor { #define SMC_PWRBTN_TOUCHID 0x06 #define SMC_PWRBTN_LONG 0xfe +/* Lid events */ +#define SMC_LID_OPEN 0x00 +#define SMC_LID_CLOSE 0x01 + #define APLSMC_BE (1 << 0) #define APLSMC_HIDDEN (1 << 1) @@ -372,7 +378,20 @@ aplsmc_handle_notification(struct aplsmc_softc *sc, uint64_t data) } break; case SMC_EV_TYPE_LID: - /* XXX Handle lid events. */ + switch (SMC_EV_SUBTYPE(data)) { + case SMC_LID_OPEN: + if (simplefb_burn_hook) + simplefb_burn_hook(1); + break; + case SMC_LID_CLOSE: + if (simplefb_burn_hook) + simplefb_burn_hook(0); + break; + default: + printf("%s: SMV_EV_TYPE_LID 0x%016llx\n", + sc->sc_dev.dv_xname, data); + break; + } break; default: #ifdef APLSMC_DEBUG |