From 56d4042b3888883b0d09babf274e25c5b920d312 Mon Sep 17 00:00:00 2001 From: tobhe Date: Tue, 3 Jan 2023 10:59:00 +0000 Subject: [PATCH] Disable display backlight on Apple Silicon laptops when suspending. ok kettenis@ patrick@ --- sys/dev/fdt/gpiobl.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/dev/fdt/gpiobl.c b/sys/dev/fdt/gpiobl.c index 96c169a68e4..41a613f5d06 100644 --- a/sys/dev/fdt/gpiobl.c +++ b/sys/dev/fdt/gpiobl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpiobl.c,v 1.2 2022/11/09 22:56:44 tobhe Exp $ */ +/* $OpenBSD: gpiobl.c,v 1.3 2023/01/03 10:59:00 tobhe Exp $ */ /* * Copyright (c) 2022 Tobias Heider * @@ -44,9 +44,11 @@ struct gpiobl_softc *sc_gpiobl; int gpiobl_match(struct device *, void *, void *); void gpiobl_attach(struct device *, struct device *, void *); +int gpiobl_activate(struct device *, int); const struct cfattach gpiobl_ca = { - sizeof(struct gpiobl_softc), gpiobl_match, gpiobl_attach + sizeof(struct gpiobl_softc), gpiobl_match, gpiobl_attach, NULL, + gpiobl_activate }; struct cfdriver gpiobl_cd = { @@ -88,6 +90,23 @@ gpiobl_attach(struct device *parent, struct device *self, void *aux) printf("\n"); } +int +gpiobl_activate(struct device *self, int act) +{ + struct gpiobl_softc *sc = (struct gpiobl_softc *)self; + + switch (act) { + case DVACT_QUIESCE: + gpio_controller_set_pin(&sc->sc_gpio[0], 0); + break; + case DVACT_WAKEUP: + gpio_controller_set_pin(&sc->sc_gpio[0], sc->sc_on); + break; + } + + return 0; +} + void gpiobl_set(u_int on) { -- 2.20.1