From f2edca4783582a19cd7116d99d8adf7c1f71e0be Mon Sep 17 00:00:00 2001 From: tobhe Date: Wed, 9 Nov 2022 22:56:44 +0000 Subject: [PATCH] Hook up gpiobl(4) to the screen burner instead of wsdisplay(4) brightness control. This enables automatic screen blanking with X and wscons(4) once wsfb(4) is fixed. "this is fine for now" kettenis@ --- sys/dev/fdt/gpiobl.c | 51 ++++++++++++------------------------------ sys/dev/fdt/simplefb.c | 15 +++++++++++-- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/sys/dev/fdt/gpiobl.c b/sys/dev/fdt/gpiobl.c index 9c218694ccb..96c169a68e4 100644 --- a/sys/dev/fdt/gpiobl.c +++ b/sys/dev/fdt/gpiobl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpiobl.c,v 1.1 2022/11/08 19:06:57 tobhe Exp $ */ +/* $OpenBSD: gpiobl.c,v 1.2 2022/11/09 22:56:44 tobhe Exp $ */ /* * Copyright (c) 2022 Tobias Heider * @@ -31,6 +31,8 @@ #include #include +extern void (*simplefb_burn_hook)(u_int); + struct gpiobl_softc { struct device sc_dev; int sc_on; @@ -51,9 +53,8 @@ struct cfdriver gpiobl_cd = { NULL, "gpiobl", DV_DULL }; +void gpiobl_set(u_int); void gpiobl_task(void *); -int gpiobl_get_param(struct wsdisplay_param *); -int gpiobl_set_param(struct wsdisplay_param *); int gpiobl_match(struct device *parent, void *match, void *aux) @@ -81,47 +82,23 @@ gpiobl_attach(struct device *parent, struct device *self, void *aux) sc_gpiobl = sc; task_set(&sc->sc_task, gpiobl_task, sc); - ws_get_param = gpiobl_get_param; - ws_set_param = gpiobl_set_param; + + simplefb_burn_hook = gpiobl_set; + printf("\n"); } void -gpiobl_task(void *args) -{ - struct gpiobl_softc *sc = args; - gpio_controller_set_pin(&sc->sc_gpio[0], sc->sc_on); -} - -int -gpiobl_get_param(struct wsdisplay_param *dp) +gpiobl_set(u_int on) { struct gpiobl_softc *sc = (struct gpiobl_softc *)sc_gpiobl; - - switch (dp->param) { - case WSDISPLAYIO_PARAM_BRIGHTNESS: - dp->min = 0; - dp->max = 1; - dp->curval = sc->sc_on; - return 0; - default: - return -1; - } + sc->sc_on = on; + task_add(systq, &sc->sc_task); } -int -gpiobl_set_param(struct wsdisplay_param *dp) +void +gpiobl_task(void *args) { - struct gpiobl_softc *sc = (struct gpiobl_softc *)sc_gpiobl; - - switch (dp->param) { - case WSDISPLAYIO_PARAM_BRIGHTNESS: - if (dp->curval == sc->sc_on) - return 0; - sc->sc_on = !sc->sc_on; - task_add(systq, &sc->sc_task); - return 0; - default: - return -1; - } + struct gpiobl_softc *sc = args; + gpio_controller_set_pin(&sc->sc_gpio[0], sc->sc_on); } diff --git a/sys/dev/fdt/simplefb.c b/sys/dev/fdt/simplefb.c index f9f3e1ef4fc..d205fae1392 100644 --- a/sys/dev/fdt/simplefb.c +++ b/sys/dev/fdt/simplefb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: simplefb.c,v 1.18 2022/11/09 22:12:40 kn Exp $ */ +/* $OpenBSD: simplefb.c,v 1.19 2022/11/09 22:56:44 tobhe Exp $ */ /* * Copyright (c) 2016 Mark Kettenis * @@ -74,6 +74,8 @@ struct simplefb_softc { psize_t sc_psize; }; +void (*simplefb_burn_hook)(u_int) = NULL; + struct rasops_info simplefb_ri; struct wsscreen_descr simplefb_wsd = { "std" }; struct wsdisplay_charcell simplefb_bs[SIMPLEFB_WIDTH * SIMPLEFB_HEIGHT]; @@ -95,6 +97,7 @@ int simplefb_wsioctl(void *, u_long, caddr_t, int, struct proc *); paddr_t simplefb_wsmmap(void *, off_t, int); int simplefb_alloc_screen(void *, const struct wsscreen_descr *, void **, int *, int *, uint32_t *); +void simplefb_burn_screen(void *, u_int, u_int); struct wsdisplay_accessops simplefb_accessops = { .ioctl = simplefb_wsioctl, @@ -105,7 +108,8 @@ struct wsdisplay_accessops simplefb_accessops = { .getchar = rasops_getchar, .load_font = rasops_load_font, .list_font = rasops_list_font, - .scrollback = rasops_scrollback + .scrollback = rasops_scrollback, + .burn_screen = simplefb_burn_screen, }; int @@ -309,6 +313,13 @@ simplefb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep, int *curxp, int *curyp, uint32_t *attrp) { return rasops_alloc_screen(v, cookiep, curxp, curyp, attrp); +} + +void +simplefb_burn_screen(void *v, u_int on, u_int flags) +{ + if (simplefb_burn_hook != NULL) + simplefb_burn_hook(on); } #include "ukbd.h" -- 2.20.1