From: tobhe Date: Fri, 25 Nov 2022 20:33:11 +0000 (+0000) Subject: Disable screen backlight on Apple silicon laptops when lid is closed. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c4d8daa7437db2c4d5dba8f2141e7a4552346f1b;p=openbsd Disable screen backlight on Apple silicon laptops when lid is closed. ok kettenis@ --- 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 * @@ -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