summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2023-04-25 11:21:02 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2023-04-25 11:21:02 +0000
commita3534aae6df0c2d2cc89760cd0f698cef59f6261 (patch)
tree1571f49b7265690d2756c6cd75bc126ab67efe24 /sys
parentecb78a82fc23da1507500d3494f5fba27ff65aec (diff)
Add suspend/resume support to pwmbl(4), so that when suspending the x13s
the display turns off and it actually looks like it's properly suspended. ok kettenis@ tobhe@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fdt/pwmbl.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/sys/dev/fdt/pwmbl.c b/sys/dev/fdt/pwmbl.c
index 08b63f7c3c9..e55484085b9 100644
--- a/sys/dev/fdt/pwmbl.c
+++ b/sys/dev/fdt/pwmbl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwmbl.c,v 1.7 2022/11/14 07:22:44 miod Exp $ */
+/* $OpenBSD: pwmbl.c,v 1.8 2023/04/25 11:21:01 patrick Exp $ */
/*
* Copyright (c) 2019 Krystian Lewandowski
* Copyright (c) 2019 Mark Kettenis <kettenis@openbsd.org>
@@ -39,15 +39,18 @@ struct pwmbl_softc {
int sc_nlevels;
uint32_t sc_max_level;
uint32_t sc_def_level;
+ struct pwm_state sc_ps_saved;
};
struct pwmbl_softc *sc_pwmbl;
int pwmbl_match(struct device *, void *, void *);
void pwmbl_attach(struct device *, struct device *, void *);
+int pwmbl_activate(struct device *, int);
const struct cfattach pwmbl_ca = {
- sizeof(struct pwmbl_softc), pwmbl_match, pwmbl_attach
+ sizeof(struct pwmbl_softc), pwmbl_match, pwmbl_attach, NULL,
+ pwmbl_activate
};
struct cfdriver pwmbl_cd = {
@@ -122,6 +125,29 @@ pwmbl_attach(struct device *parent, struct device *self, void *aux)
}
int
+pwmbl_activate(struct device *self, int act)
+{
+ struct pwmbl_softc *sc = (struct pwmbl_softc *)self;
+ struct pwm_state ps;
+ int error;
+
+ switch (act) {
+ case DVACT_QUIESCE:
+ error = pwm_get_state(sc->sc_pwm, &sc->sc_ps_saved);
+ if (error)
+ return error;
+
+ pwm_init_state(sc->sc_pwm, &ps);
+ ps.ps_pulse_width = 0;
+ ps.ps_enabled = 0;
+ return pwm_set_state(sc->sc_pwm, &ps);
+ case DVACT_WAKEUP:
+ return pwm_set_state(sc->sc_pwm, &sc->sc_ps_saved);
+ }
+ return 0;
+}
+
+int
pwmbl_get_brightness(void *cookie, uint32_t *level)
{
struct pwmbl_softc *sc = cookie;