Home | History | Annotate | Line # | Download | only in wsfb
genfb.c revision 1.56.2.3
      1  1.56.2.3     skrll /*	$NetBSD: genfb.c,v 1.56.2.3 2017/08/28 17:52:31 skrll Exp $ */
      2       1.1  macallan 
      3       1.1  macallan /*-
      4       1.1  macallan  * Copyright (c) 2007 Michael Lorenz
      5       1.1  macallan  * All rights reserved.
      6       1.1  macallan  *
      7       1.1  macallan  * Redistribution and use in source and binary forms, with or without
      8       1.1  macallan  * modification, are permitted provided that the following conditions
      9       1.1  macallan  * are met:
     10       1.1  macallan  * 1. Redistributions of source code must retain the above copyright
     11       1.1  macallan  *    notice, this list of conditions and the following disclaimer.
     12       1.1  macallan  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1  macallan  *    notice, this list of conditions and the following disclaimer in the
     14       1.1  macallan  *    documentation and/or other materials provided with the distribution.
     15       1.1  macallan  *
     16       1.1  macallan  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17       1.1  macallan  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18       1.1  macallan  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19       1.1  macallan  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20       1.1  macallan  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21       1.1  macallan  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22       1.1  macallan  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23       1.1  macallan  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24       1.1  macallan  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25       1.1  macallan  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26       1.1  macallan  * POSSIBILITY OF SUCH DAMAGE.
     27       1.1  macallan  */
     28       1.1  macallan 
     29       1.1  macallan #include <sys/cdefs.h>
     30  1.56.2.3     skrll __KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.56.2.3 2017/08/28 17:52:31 skrll Exp $");
     31       1.1  macallan 
     32       1.1  macallan #include <sys/param.h>
     33       1.1  macallan #include <sys/systm.h>
     34       1.1  macallan #include <sys/kernel.h>
     35       1.1  macallan #include <sys/device.h>
     36       1.1  macallan #include <sys/proc.h>
     37       1.1  macallan #include <sys/mutex.h>
     38       1.1  macallan #include <sys/ioctl.h>
     39       1.1  macallan #include <sys/kernel.h>
     40       1.1  macallan #include <sys/systm.h>
     41      1.23  jmcneill #include <sys/kmem.h>
     42       1.1  macallan 
     43       1.1  macallan #include <dev/wscons/wsconsio.h>
     44       1.1  macallan #include <dev/wscons/wsdisplayvar.h>
     45       1.1  macallan #include <dev/rasops/rasops.h>
     46       1.1  macallan #include <dev/wsfont/wsfont.h>
     47       1.1  macallan 
     48       1.1  macallan #include <dev/wscons/wsdisplay_vconsvar.h>
     49       1.1  macallan 
     50       1.1  macallan #include <dev/wsfb/genfbvar.h>
     51       1.1  macallan 
     52      1.29     ahoka #ifdef GENFB_DISABLE_TEXT
     53      1.29     ahoka #include <sys/reboot.h>
     54      1.29     ahoka #define DISABLESPLASH (boothowto & (RB_SINGLE | RB_USERCONF | RB_ASKNAME | \
     55      1.29     ahoka 		AB_VERBOSE | AB_DEBUG) )
     56      1.29     ahoka #endif
     57      1.29     ahoka 
     58      1.53  riastrad #ifdef _KERNEL_OPT
     59       1.1  macallan #include "opt_genfb.h"
     60       1.1  macallan #include "opt_wsfb.h"
     61      1.53  riastrad #endif
     62       1.1  macallan 
     63      1.11  macallan #ifdef GENFB_DEBUG
     64      1.11  macallan #define GPRINTF panic
     65      1.11  macallan #else
     66      1.49  jmcneill #define GPRINTF aprint_debug
     67      1.11  macallan #endif
     68      1.11  macallan 
     69      1.42  macallan #define GENFB_BRIGHTNESS_STEP 15
     70      1.42  macallan 
     71       1.1  macallan static int	genfb_ioctl(void *, void *, u_long, void *, int, struct lwp *);
     72       1.1  macallan static paddr_t	genfb_mmap(void *, void *, off_t, int);
     73      1.52     skrll static void	genfb_pollc(void *, int);
     74      1.52     skrll 
     75       1.1  macallan static void	genfb_init_screen(void *, struct vcons_screen *, int, long *);
     76       1.1  macallan 
     77       1.1  macallan static int	genfb_putcmap(struct genfb_softc *, struct wsdisplay_cmap *);
     78       1.1  macallan static int 	genfb_getcmap(struct genfb_softc *, struct wsdisplay_cmap *);
     79       1.1  macallan static int 	genfb_putpalreg(struct genfb_softc *, uint8_t, uint8_t,
     80       1.1  macallan 			    uint8_t, uint8_t);
     81      1.45  macallan static void	genfb_init_palette(struct genfb_softc *);
     82       1.1  macallan 
     83      1.31  macallan static void	genfb_brightness_up(device_t);
     84      1.31  macallan static void	genfb_brightness_down(device_t);
     85      1.31  macallan 
     86       1.1  macallan extern const u_char rasops_cmap[768];
     87       1.1  macallan 
     88      1.18  jmcneill static int genfb_cnattach_called = 0;
     89      1.20  jmcneill static int genfb_enabled = 1;
     90      1.18  jmcneill 
     91      1.19  jmcneill static struct genfb_softc *genfb_softc = NULL;
     92      1.19  jmcneill 
     93       1.2  macallan void
     94       1.2  macallan genfb_init(struct genfb_softc *sc)
     95       1.2  macallan {
     96       1.2  macallan 	prop_dictionary_t dict;
     97      1.42  macallan 	uint64_t cmap_cb, pmf_cb, mode_cb, bl_cb, br_cb, fbaddr;
     98       1.2  macallan 	uint32_t fboffset;
     99      1.31  macallan 	bool console;
    100       1.2  macallan 
    101      1.32  macallan 	dict = device_properties(sc->sc_dev);
    102       1.2  macallan #ifdef GENFB_DEBUG
    103      1.54  riastrad 	printf("%s", prop_dictionary_externalize(dict));
    104       1.2  macallan #endif
    105      1.31  macallan 	prop_dictionary_get_bool(dict, "is_console", &console);
    106      1.31  macallan 
    107      1.11  macallan 	if (!prop_dictionary_get_uint32(dict, "width", &sc->sc_width)) {
    108      1.12  macallan 		GPRINTF("no width property\n");
    109      1.11  macallan 		return;
    110      1.11  macallan 	}
    111      1.11  macallan 	if (!prop_dictionary_get_uint32(dict, "height", &sc->sc_height)) {
    112      1.12  macallan 		GPRINTF("no height property\n");
    113      1.11  macallan 		return;
    114      1.11  macallan 	}
    115      1.11  macallan 	if (!prop_dictionary_get_uint32(dict, "depth", &sc->sc_depth)) {
    116      1.12  macallan 		GPRINTF("no depth property\n");
    117      1.11  macallan 		return;
    118      1.11  macallan 	}
    119       1.2  macallan 
    120       1.2  macallan 	/* XXX should be a 64bit value */
    121      1.11  macallan 	if (!prop_dictionary_get_uint32(dict, "address", &fboffset)) {
    122      1.12  macallan 		GPRINTF("no address property\n");
    123      1.11  macallan 		return;
    124      1.11  macallan 	}
    125      1.11  macallan 
    126       1.2  macallan 	sc->sc_fboffset = fboffset;
    127       1.2  macallan 
    128      1.39  macallan 	sc->sc_fbaddr = NULL;
    129      1.39  macallan 	if (prop_dictionary_get_uint64(dict, "virtual_address", &fbaddr)) {
    130      1.40  macallan 		sc->sc_fbaddr = (void *)(uintptr_t)fbaddr;
    131      1.39  macallan 	}
    132      1.39  macallan 
    133  1.56.2.3     skrll 	sc->sc_shadowfb = NULL;
    134  1.56.2.3     skrll 	if (!prop_dictionary_get_bool(dict, "enable_shadowfb",
    135  1.56.2.3     skrll 	    &sc->sc_enable_shadowfb))
    136  1.56.2.3     skrll #ifdef GENFB_SHADOWFB
    137  1.56.2.3     skrll 		sc->sc_enable_shadowfb = true;
    138  1.56.2.3     skrll #else
    139  1.56.2.3     skrll 		sc->sc_enable_shadowfb = false;
    140  1.56.2.3     skrll #endif
    141  1.56.2.3     skrll 
    142       1.2  macallan 	if (!prop_dictionary_get_uint32(dict, "linebytes", &sc->sc_stride))
    143       1.2  macallan 		sc->sc_stride = (sc->sc_width * sc->sc_depth) >> 3;
    144      1.13  macallan 
    145      1.13  macallan 	/*
    146      1.13  macallan 	 * deal with a bug in the Raptor firmware which always sets
    147      1.13  macallan 	 * stride = width even when depth != 8
    148      1.13  macallan 	 */
    149      1.13  macallan 	if (sc->sc_stride < sc->sc_width * (sc->sc_depth >> 3))
    150      1.13  macallan 		sc->sc_stride = sc->sc_width * (sc->sc_depth >> 3);
    151      1.13  macallan 
    152       1.6  macallan 	sc->sc_fbsize = sc->sc_height * sc->sc_stride;
    153       1.4  macallan 
    154       1.4  macallan 	/* optional colour map callback */
    155       1.4  macallan 	sc->sc_cmcb = NULL;
    156       1.4  macallan 	if (prop_dictionary_get_uint64(dict, "cmap_callback", &cmap_cb)) {
    157       1.4  macallan 		if (cmap_cb != 0)
    158       1.4  macallan 			sc->sc_cmcb = (void *)(vaddr_t)cmap_cb;
    159       1.4  macallan 	}
    160      1.31  macallan 
    161      1.28  jmcneill 	/* optional pmf callback */
    162      1.28  jmcneill 	sc->sc_pmfcb = NULL;
    163      1.28  jmcneill 	if (prop_dictionary_get_uint64(dict, "pmf_callback", &pmf_cb)) {
    164      1.28  jmcneill 		if (pmf_cb != 0)
    165      1.28  jmcneill 			sc->sc_pmfcb = (void *)(vaddr_t)pmf_cb;
    166      1.28  jmcneill 	}
    167      1.31  macallan 
    168      1.34  jmcneill 	/* optional mode callback */
    169      1.34  jmcneill 	sc->sc_modecb = NULL;
    170      1.34  jmcneill 	if (prop_dictionary_get_uint64(dict, "mode_callback", &mode_cb)) {
    171      1.34  jmcneill 		if (mode_cb != 0)
    172      1.34  jmcneill 			sc->sc_modecb = (void *)(vaddr_t)mode_cb;
    173      1.34  jmcneill 	}
    174      1.34  jmcneill 
    175      1.31  macallan 	/* optional backlight control callback */
    176      1.31  macallan 	sc->sc_backlight = NULL;
    177      1.31  macallan 	if (prop_dictionary_get_uint64(dict, "backlight_callback", &bl_cb)) {
    178      1.31  macallan 		if (bl_cb != 0) {
    179      1.31  macallan 			sc->sc_backlight = (void *)(vaddr_t)bl_cb;
    180      1.42  macallan 			aprint_naive_dev(sc->sc_dev,
    181      1.31  macallan 			    "enabling backlight control\n");
    182      1.42  macallan 		}
    183      1.42  macallan 	}
    184      1.42  macallan 
    185      1.42  macallan 	/* optional brightness control callback */
    186      1.42  macallan 	sc->sc_brightness = NULL;
    187      1.42  macallan 	if (prop_dictionary_get_uint64(dict, "brightness_callback", &br_cb)) {
    188      1.42  macallan 		if (br_cb != 0) {
    189      1.42  macallan 			sc->sc_brightness = (void *)(vaddr_t)br_cb;
    190      1.42  macallan 			aprint_naive_dev(sc->sc_dev,
    191      1.42  macallan 			    "enabling brightness control\n");
    192      1.42  macallan 			if (console &&
    193      1.42  macallan 			    sc->sc_brightness->gpc_upd_parameter != NULL) {
    194      1.42  macallan 				pmf_event_register(sc->sc_dev,
    195      1.31  macallan 				    PMFE_DISPLAY_BRIGHTNESS_UP,
    196      1.31  macallan 				    genfb_brightness_up, TRUE);
    197      1.42  macallan 				pmf_event_register(sc->sc_dev,
    198      1.31  macallan 				    PMFE_DISPLAY_BRIGHTNESS_DOWN,
    199      1.31  macallan 				    genfb_brightness_down, TRUE);
    200      1.31  macallan 			}
    201      1.31  macallan 		}
    202      1.31  macallan 	}
    203       1.2  macallan }
    204       1.2  macallan 
    205       1.2  macallan int
    206       1.2  macallan genfb_attach(struct genfb_softc *sc, struct genfb_ops *ops)
    207       1.1  macallan {
    208       1.1  macallan 	struct wsemuldisplaydev_attach_args aa;
    209       1.1  macallan 	prop_dictionary_t dict;
    210       1.1  macallan 	struct rasops_info *ri;
    211      1.21  jmcneill 	uint16_t crow;
    212       1.1  macallan 	long defattr;
    213       1.7  macallan 	bool console;
    214      1.33  jmcneill #ifdef SPLASHSCREEN
    215      1.45  macallan 	int i, j;
    216      1.33  jmcneill 	int error = ENXIO;
    217      1.33  jmcneill #endif
    218       1.9      jmmv 
    219      1.32  macallan 	dict = device_properties(sc->sc_dev);
    220      1.14       phx 	prop_dictionary_get_bool(dict, "is_console", &console);
    221      1.14       phx 
    222      1.21  jmcneill 	if (prop_dictionary_get_uint16(dict, "cursor-row", &crow) == false)
    223      1.21  jmcneill 		crow = 0;
    224      1.21  jmcneill 	if (prop_dictionary_get_bool(dict, "clear-screen", &sc->sc_want_clear)
    225      1.21  jmcneill 	    == false)
    226      1.21  jmcneill 		sc->sc_want_clear = true;
    227      1.21  jmcneill 
    228      1.42  macallan 	aprint_verbose_dev(sc->sc_dev, "framebuffer at %p, size %dx%d, depth %d, "
    229      1.42  macallan 	    "stride %d\n",
    230      1.26  christos 	    sc->sc_fboffset ? (void *)(intptr_t)sc->sc_fboffset : sc->sc_fbaddr,
    231       1.9      jmmv 	    sc->sc_width, sc->sc_height, sc->sc_depth, sc->sc_stride);
    232       1.9      jmmv 
    233       1.1  macallan 	sc->sc_defaultscreen_descr = (struct wsscreen_descr){
    234       1.1  macallan 		"default",
    235       1.1  macallan 		0, 0,
    236       1.1  macallan 		NULL,
    237       1.1  macallan 		8, 16,
    238  1.56.2.3     skrll 		WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
    239  1.56.2.3     skrll 		  WSSCREEN_RESIZE,
    240       1.3  macallan 		NULL
    241       1.1  macallan 	};
    242       1.1  macallan 	sc->sc_screens[0] = &sc->sc_defaultscreen_descr;
    243       1.1  macallan 	sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens};
    244       1.1  macallan 	memcpy(&sc->sc_ops, ops, sizeof(struct genfb_ops));
    245       1.1  macallan 	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
    246      1.36       phx 	if (sc->sc_modecb != NULL)
    247      1.34  jmcneill 		sc->sc_modecb->gmc_setmode(sc, sc->sc_mode);
    248       1.1  macallan 
    249      1.41  macallan 	sc->sc_accessops.ioctl = genfb_ioctl;
    250      1.41  macallan 	sc->sc_accessops.mmap = genfb_mmap;
    251      1.52     skrll 	sc->sc_accessops.pollc = genfb_pollc;
    252      1.41  macallan 
    253  1.56.2.3     skrll 	if (sc->sc_enable_shadowfb) {
    254  1.56.2.3     skrll 		sc->sc_shadowfb = kmem_alloc(sc->sc_fbsize, KM_SLEEP);
    255  1.56.2.3     skrll 		if (sc->sc_want_clear == false)
    256  1.56.2.3     skrll 			memcpy(sc->sc_shadowfb, sc->sc_fbaddr, sc->sc_fbsize);
    257  1.56.2.3     skrll 	}
    258       1.5  macallan 
    259       1.1  macallan 	vcons_init(&sc->vd, sc, &sc->sc_defaultscreen_descr,
    260      1.41  macallan 	    &sc->sc_accessops);
    261       1.1  macallan 	sc->vd.init_screen = genfb_init_screen;
    262       1.1  macallan 
    263      1.10      jmmv 	/* Do not print anything between this point and the screen
    264      1.10      jmmv 	 * clear operation below.  Otherwise it will be lost. */
    265      1.10      jmmv 
    266       1.1  macallan 	ri = &sc->sc_console_screen.scr_ri;
    267       1.1  macallan 
    268      1.14       phx 	vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
    269      1.14       phx 	    &defattr);
    270      1.14       phx 	sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
    271      1.14       phx 
    272      1.29     ahoka #ifdef SPLASHSCREEN
    273      1.29     ahoka /*
    274      1.29     ahoka  * If system isn't going to go multiuser, or user has requested to see
    275      1.29     ahoka  * boot text, don't render splash screen immediately
    276      1.29     ahoka  */
    277      1.29     ahoka 	if (DISABLESPLASH)
    278      1.29     ahoka #endif
    279      1.29     ahoka 		vcons_redraw_screen(&sc->sc_console_screen);
    280      1.29     ahoka 
    281      1.14       phx 	sc->sc_defaultscreen_descr.textops = &ri->ri_ops;
    282      1.14       phx 	sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
    283      1.14       phx 	sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
    284      1.14       phx 	sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
    285      1.41  macallan 
    286      1.44  macallan 	if (crow >= ri->ri_rows) {
    287      1.44  macallan 		crow = 0;
    288      1.44  macallan 		sc->sc_want_clear = 1;
    289      1.44  macallan 	}
    290      1.44  macallan 
    291      1.41  macallan 	if (console)
    292      1.41  macallan 		wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, crow,
    293      1.41  macallan 		    defattr);
    294       1.1  macallan 
    295      1.10      jmmv 	/* Clear the whole screen to bring it to a known state. */
    296      1.21  jmcneill 	if (sc->sc_want_clear)
    297      1.21  jmcneill 		(*ri->ri_ops.eraserows)(ri, 0, ri->ri_rows, defattr);
    298      1.10      jmmv 
    299      1.45  macallan #ifdef SPLASHSCREEN
    300       1.1  macallan 	j = 0;
    301      1.27  macallan 	for (i = 0; i < min(1 << sc->sc_depth, 256); i++) {
    302      1.33  jmcneill 		if (i >= SPLASH_CMAP_OFFSET &&
    303      1.29     ahoka 		    i < SPLASH_CMAP_OFFSET + SPLASH_CMAP_SIZE) {
    304      1.33  jmcneill 			splash_get_cmap(i,
    305      1.33  jmcneill 			    &sc->sc_cmap_red[i],
    306      1.33  jmcneill 			    &sc->sc_cmap_green[i],
    307      1.33  jmcneill 			    &sc->sc_cmap_blue[i]);
    308      1.29     ahoka 		} else {
    309      1.29     ahoka 			sc->sc_cmap_red[i] = rasops_cmap[j];
    310      1.29     ahoka 			sc->sc_cmap_green[i] = rasops_cmap[j + 1];
    311      1.29     ahoka 			sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
    312      1.29     ahoka 		}
    313      1.29     ahoka 		j += 3;
    314       1.1  macallan 	}
    315      1.33  jmcneill 	genfb_restore_palette(sc);
    316       1.1  macallan 
    317      1.29     ahoka 	sc->sc_splash.si_depth = sc->sc_depth;
    318  1.56.2.2     skrll 	sc->sc_splash.si_bits = sc->sc_console_screen.scr_ri.ri_origbits;
    319      1.29     ahoka 	sc->sc_splash.si_hwbits = sc->sc_fbaddr;
    320      1.29     ahoka 	sc->sc_splash.si_width = sc->sc_width;
    321      1.29     ahoka 	sc->sc_splash.si_height = sc->sc_height;
    322      1.29     ahoka 	sc->sc_splash.si_stride = sc->sc_stride;
    323      1.29     ahoka 	sc->sc_splash.si_fillrect = NULL;
    324      1.33  jmcneill 	if (!DISABLESPLASH) {
    325      1.33  jmcneill 		error = splash_render(&sc->sc_splash,
    326      1.33  jmcneill 		    SPLASH_F_CENTER|SPLASH_F_FILL);
    327      1.33  jmcneill 		if (error) {
    328      1.33  jmcneill 			SCREEN_ENABLE_DRAWING(&sc->sc_console_screen);
    329      1.45  macallan 			genfb_init_palette(sc);
    330      1.33  jmcneill 			vcons_replay_msgbuf(&sc->sc_console_screen);
    331      1.33  jmcneill 		}
    332      1.33  jmcneill 	}
    333      1.29     ahoka #else
    334      1.45  macallan 	genfb_init_palette(sc);
    335      1.53  riastrad 	if (console)
    336      1.53  riastrad 		vcons_replay_msgbuf(&sc->sc_console_screen);
    337      1.29     ahoka #endif
    338      1.27  macallan 
    339      1.19  jmcneill 	if (genfb_softc == NULL)
    340      1.19  jmcneill 		genfb_softc = sc;
    341      1.19  jmcneill 
    342       1.1  macallan 	aa.console = console;
    343       1.1  macallan 	aa.scrdata = &sc->sc_screenlist;
    344      1.41  macallan 	aa.accessops = &sc->sc_accessops;
    345       1.1  macallan 	aa.accesscookie = &sc->vd;
    346       1.1  macallan 
    347      1.29     ahoka #ifdef GENFB_DISABLE_TEXT
    348      1.33  jmcneill 	if (!DISABLESPLASH && error == 0)
    349      1.29     ahoka 		SCREEN_DISABLE_DRAWING(&sc->sc_console_screen);
    350      1.29     ahoka #endif
    351      1.29     ahoka 
    352      1.53  riastrad 	config_found_ia(sc->sc_dev, "wsemuldisplaydev", &aa,
    353      1.53  riastrad 	    wsemuldisplaydevprint);
    354       1.1  macallan 
    355       1.1  macallan 	return 0;
    356       1.1  macallan }
    357       1.1  macallan 
    358       1.1  macallan static int
    359       1.1  macallan genfb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
    360       1.1  macallan 	struct lwp *l)
    361       1.1  macallan {
    362       1.1  macallan 	struct vcons_data *vd = v;
    363       1.1  macallan 	struct genfb_softc *sc = vd->cookie;
    364       1.1  macallan 	struct wsdisplay_fbinfo *wdf;
    365       1.1  macallan 	struct vcons_screen *ms = vd->active;
    366      1.31  macallan 	struct wsdisplay_param *param;
    367      1.56  macallan 	int new_mode, error, val, ret;
    368       1.1  macallan 
    369       1.1  macallan 	switch (cmd) {
    370       1.1  macallan 		case WSDISPLAYIO_GINFO:
    371       1.6  macallan 			if (ms == NULL)
    372       1.6  macallan 				return ENODEV;
    373       1.1  macallan 			wdf = (void *)data;
    374       1.1  macallan 			wdf->height = ms->scr_ri.ri_height;
    375       1.1  macallan 			wdf->width = ms->scr_ri.ri_width;
    376       1.1  macallan 			wdf->depth = ms->scr_ri.ri_depth;
    377       1.1  macallan 			wdf->cmsize = 256;
    378       1.1  macallan 			return 0;
    379       1.1  macallan 
    380       1.1  macallan 		case WSDISPLAYIO_GETCMAP:
    381       1.1  macallan 			return genfb_getcmap(sc,
    382       1.1  macallan 			    (struct wsdisplay_cmap *)data);
    383       1.1  macallan 
    384       1.1  macallan 		case WSDISPLAYIO_PUTCMAP:
    385       1.1  macallan 			return genfb_putcmap(sc,
    386       1.1  macallan 			    (struct wsdisplay_cmap *)data);
    387       1.1  macallan 
    388       1.3  macallan 		case WSDISPLAYIO_LINEBYTES:
    389       1.3  macallan 			*(u_int *)data = sc->sc_stride;
    390       1.3  macallan 			return 0;
    391       1.3  macallan 
    392       1.1  macallan 		case WSDISPLAYIO_SMODE:
    393      1.24  jmcneill 			new_mode = *(int *)data;
    394      1.11  macallan 
    395      1.24  jmcneill 			/* notify the bus backend */
    396      1.24  jmcneill 			error = 0;
    397      1.24  jmcneill 			if (sc->sc_ops.genfb_ioctl)
    398      1.24  jmcneill 				error = sc->sc_ops.genfb_ioctl(sc, vs,
    399      1.11  macallan 					    cmd, data, flag, l);
    400      1.50  jmcneill 			if (error && error != EPASSTHROUGH)
    401      1.24  jmcneill 				return error;
    402      1.11  macallan 
    403      1.24  jmcneill 			if (new_mode != sc->sc_mode) {
    404      1.24  jmcneill 				sc->sc_mode = new_mode;
    405      1.36       phx 				if (sc->sc_modecb != NULL)
    406      1.34  jmcneill 					sc->sc_modecb->gmc_setmode(sc,
    407      1.34  jmcneill 					    sc->sc_mode);
    408      1.24  jmcneill 				if (new_mode == WSDISPLAYIO_MODE_EMUL) {
    409      1.24  jmcneill 					genfb_restore_palette(sc);
    410      1.24  jmcneill 					vcons_redraw_screen(ms);
    411       1.1  macallan 				}
    412       1.1  macallan 			}
    413       1.1  macallan 			return 0;
    414  1.56.2.2     skrll 
    415      1.29     ahoka 		case WSDISPLAYIO_SSPLASH:
    416      1.29     ahoka #if defined(SPLASHSCREEN)
    417      1.29     ahoka 			if(*(int *)data == 1) {
    418      1.29     ahoka 				SCREEN_DISABLE_DRAWING(&sc->sc_console_screen);
    419      1.29     ahoka 				splash_render(&sc->sc_splash,
    420      1.29     ahoka 						SPLASH_F_CENTER|SPLASH_F_FILL);
    421      1.29     ahoka 			} else {
    422      1.29     ahoka 				SCREEN_ENABLE_DRAWING(&sc->sc_console_screen);
    423      1.45  macallan 				genfb_init_palette(sc);
    424      1.29     ahoka 			}
    425      1.29     ahoka 			vcons_redraw_screen(ms);
    426      1.29     ahoka 			return 0;
    427      1.29     ahoka #else
    428      1.29     ahoka 			return ENODEV;
    429      1.29     ahoka #endif
    430      1.31  macallan 		case WSDISPLAYIO_GETPARAM:
    431      1.31  macallan 			param = (struct wsdisplay_param *)data;
    432      1.31  macallan 			switch (param->param) {
    433      1.31  macallan 			case WSDISPLAYIO_PARAM_BRIGHTNESS:
    434      1.42  macallan 				if (sc->sc_brightness == NULL)
    435      1.42  macallan 					return EPASSTHROUGH;
    436      1.31  macallan 				param->min = 0;
    437      1.31  macallan 				param->max = 255;
    438      1.42  macallan 				return sc->sc_brightness->gpc_get_parameter(
    439      1.42  macallan 				    sc->sc_brightness->gpc_cookie,
    440      1.42  macallan 				    &param->curval);
    441      1.31  macallan 			case WSDISPLAYIO_PARAM_BACKLIGHT:
    442      1.42  macallan 				if (sc->sc_backlight == NULL)
    443      1.42  macallan 					return EPASSTHROUGH;
    444      1.31  macallan 				param->min = 0;
    445      1.31  macallan 				param->max = 1;
    446      1.42  macallan 				return sc->sc_backlight->gpc_get_parameter(
    447      1.42  macallan 				    sc->sc_backlight->gpc_cookie,
    448      1.42  macallan 				    &param->curval);
    449      1.31  macallan 			}
    450      1.31  macallan 			return EPASSTHROUGH;
    451      1.31  macallan 
    452      1.31  macallan 		case WSDISPLAYIO_SETPARAM:
    453      1.31  macallan 			param = (struct wsdisplay_param *)data;
    454      1.31  macallan 			switch (param->param) {
    455      1.31  macallan 			case WSDISPLAYIO_PARAM_BRIGHTNESS:
    456      1.42  macallan 				if (sc->sc_brightness == NULL)
    457      1.42  macallan 					return EPASSTHROUGH;
    458      1.42  macallan 				val = param->curval;
    459      1.42  macallan 				if (val < 0) val = 0;
    460      1.42  macallan 				if (val > 255) val = 255;
    461      1.42  macallan 				return sc->sc_brightness->gpc_set_parameter(
    462      1.42  macallan 				    sc->sc_brightness->gpc_cookie, val);
    463      1.31  macallan 			case WSDISPLAYIO_PARAM_BACKLIGHT:
    464      1.42  macallan 				if (sc->sc_backlight == NULL)
    465      1.42  macallan 					return EPASSTHROUGH;
    466      1.42  macallan 				val = param->curval;
    467      1.42  macallan 				if (val < 0) val = 0;
    468      1.42  macallan 				if (val > 1) val = 1;
    469      1.42  macallan 				return sc->sc_backlight->gpc_set_parameter(
    470      1.42  macallan 				    sc->sc_backlight->gpc_cookie, val);
    471      1.31  macallan 			}
    472  1.56.2.2     skrll 			return EPASSTHROUGH;
    473      1.56  macallan 	}
    474      1.56  macallan 	ret = EPASSTHROUGH;
    475      1.56  macallan 	if (sc->sc_ops.genfb_ioctl)
    476      1.56  macallan 		ret = sc->sc_ops.genfb_ioctl(sc, vs, cmd, data, flag, l);
    477      1.56  macallan 	if (ret != EPASSTHROUGH)
    478      1.56  macallan 		return ret;
    479      1.56  macallan 	/*
    480      1.56  macallan 	 * XXX
    481      1.56  macallan 	 * handle these only if there either is no ioctl() handler or it didn't
    482      1.56  macallan 	 * know how to deal with them. This allows bus frontends to override
    483      1.56  macallan 	 * them but still provides fallback implementations
    484      1.56  macallan 	 */
    485      1.56  macallan 	switch (cmd) {
    486      1.42  macallan 		case WSDISPLAYIO_GET_EDID: {
    487  1.56.2.2     skrll 
    488      1.42  macallan 			struct wsdisplayio_edid_info *d = data;
    489      1.42  macallan 			return wsdisplayio_get_edid(sc->sc_dev, d);
    490      1.42  macallan 		}
    491  1.56.2.2     skrll 
    492      1.51  macallan 		case WSDISPLAYIO_GET_FBINFO: {
    493      1.51  macallan 			struct wsdisplayio_fbinfo *fbi = data;
    494      1.51  macallan 			return wsdisplayio_get_fbinfo(&ms->scr_ri, fbi);
    495      1.51  macallan 		}
    496       1.1  macallan 	}
    497       1.1  macallan 	return EPASSTHROUGH;
    498       1.1  macallan }
    499       1.1  macallan 
    500       1.1  macallan static paddr_t
    501       1.1  macallan genfb_mmap(void *v, void *vs, off_t offset, int prot)
    502       1.1  macallan {
    503       1.1  macallan 	struct vcons_data *vd = v;
    504       1.1  macallan 	struct genfb_softc *sc = vd->cookie;
    505       1.1  macallan 
    506       1.1  macallan 	if (sc->sc_ops.genfb_mmap)
    507       1.1  macallan 		return sc->sc_ops.genfb_mmap(sc, vs, offset, prot);
    508       1.1  macallan 
    509       1.1  macallan 	return -1;
    510       1.1  macallan }
    511       1.1  macallan 
    512       1.1  macallan static void
    513      1.52     skrll genfb_pollc(void *v, int on)
    514      1.52     skrll {
    515      1.52     skrll 	struct vcons_data *vd = v;
    516      1.52     skrll 	struct genfb_softc *sc = vd->cookie;
    517      1.52     skrll 
    518      1.52     skrll 	if (sc == NULL)
    519      1.52     skrll 		return;
    520      1.52     skrll 
    521      1.52     skrll 	if (on)
    522      1.52     skrll 		genfb_enable_polling(sc->sc_dev);
    523      1.52     skrll 	else
    524      1.52     skrll 		genfb_disable_polling(sc->sc_dev);
    525      1.52     skrll }
    526      1.52     skrll 
    527      1.52     skrll static void
    528       1.1  macallan genfb_init_screen(void *cookie, struct vcons_screen *scr,
    529       1.1  macallan     int existing, long *defattr)
    530       1.1  macallan {
    531       1.1  macallan 	struct genfb_softc *sc = cookie;
    532       1.1  macallan 	struct rasops_info *ri = &scr->scr_ri;
    533       1.1  macallan 
    534       1.1  macallan 	ri->ri_depth = sc->sc_depth;
    535       1.1  macallan 	ri->ri_width = sc->sc_width;
    536       1.1  macallan 	ri->ri_height = sc->sc_height;
    537       1.1  macallan 	ri->ri_stride = sc->sc_stride;
    538      1.21  jmcneill 	ri->ri_flg = RI_CENTER;
    539      1.21  jmcneill 	if (sc->sc_want_clear)
    540      1.21  jmcneill 		ri->ri_flg |= RI_FULLCLEAR;
    541       1.1  macallan 
    542  1.56.2.3     skrll 	scr->scr_flags |= VCONS_LOADFONT;
    543       1.5  macallan 
    544  1.56.2.3     skrll 	if (sc->sc_shadowfb != NULL) {
    545       1.5  macallan 		ri->ri_hwbits = (char *)sc->sc_fbaddr;
    546       1.5  macallan 		ri->ri_bits = (char *)sc->sc_shadowfb;
    547  1.56.2.3     skrll 	} else {
    548       1.5  macallan 		ri->ri_bits = (char *)sc->sc_fbaddr;
    549      1.30  macallan 		scr->scr_flags |= VCONS_DONT_READ;
    550      1.30  macallan 	}
    551       1.1  macallan 
    552      1.21  jmcneill 	if (existing && sc->sc_want_clear) {
    553       1.1  macallan 		ri->ri_flg |= RI_CLEAR;
    554       1.1  macallan 	}
    555       1.1  macallan 
    556  1.56.2.1     skrll 	if (ri->ri_depth == 32 || ri->ri_depth == 24) {
    557      1.48  macallan 		bool is_bgr = false;
    558      1.48  macallan 
    559  1.56.2.1     skrll 		if (ri->ri_depth == 32) {
    560  1.56.2.1     skrll 			ri->ri_flg |= RI_ENABLE_ALPHA;
    561  1.56.2.1     skrll 		}
    562      1.48  macallan 		prop_dictionary_get_bool(device_properties(sc->sc_dev),
    563      1.48  macallan 		    "is_bgr", &is_bgr);
    564      1.48  macallan 		if (is_bgr) {
    565      1.48  macallan 			/* someone requested BGR */
    566      1.48  macallan 			ri->ri_rnum = 8;
    567      1.48  macallan 			ri->ri_gnum = 8;
    568      1.48  macallan 			ri->ri_bnum = 8;
    569      1.48  macallan 			ri->ri_rpos = 0;
    570      1.48  macallan 			ri->ri_gpos = 8;
    571      1.48  macallan 			ri->ri_bpos = 16;
    572      1.48  macallan 		} else {
    573      1.48  macallan 			/* assume RGB */
    574      1.48  macallan 			ri->ri_rnum = 8;
    575      1.48  macallan 			ri->ri_gnum = 8;
    576      1.48  macallan 			ri->ri_bnum = 8;
    577      1.48  macallan 			ri->ri_rpos = 16;
    578      1.48  macallan 			ri->ri_gpos = 8;
    579      1.48  macallan 			ri->ri_bpos = 0;
    580      1.48  macallan 		}
    581  1.56.2.1     skrll 	}
    582      1.43  macallan 
    583      1.47       phx 	if (ri->ri_depth == 8 && sc->sc_cmcb != NULL)
    584      1.45  macallan 		ri->ri_flg |= RI_ENABLE_ALPHA | RI_8BIT_IS_RGB;
    585      1.45  macallan 
    586      1.45  macallan 
    587      1.46  macallan 	rasops_init(ri, 0, 0);
    588  1.56.2.3     skrll 	ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
    589  1.56.2.3     skrll 		  WSSCREEN_RESIZE;
    590       1.1  macallan 	rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
    591       1.1  macallan 		    sc->sc_width / ri->ri_font->fontwidth);
    592       1.1  macallan 
    593      1.27  macallan 	/* TODO: actually center output */
    594       1.1  macallan 	ri->ri_hw = scr;
    595      1.29     ahoka 
    596      1.29     ahoka #ifdef GENFB_DISABLE_TEXT
    597      1.29     ahoka 	if (scr == &sc->sc_console_screen && !DISABLESPLASH)
    598      1.29     ahoka 		SCREEN_DISABLE_DRAWING(&sc->sc_console_screen);
    599      1.29     ahoka #endif
    600       1.1  macallan }
    601       1.1  macallan 
    602       1.1  macallan static int
    603       1.1  macallan genfb_putcmap(struct genfb_softc *sc, struct wsdisplay_cmap *cm)
    604       1.1  macallan {
    605       1.1  macallan 	u_char *r, *g, *b;
    606       1.1  macallan 	u_int index = cm->index;
    607       1.1  macallan 	u_int count = cm->count;
    608       1.1  macallan 	int i, error;
    609       1.1  macallan 	u_char rbuf[256], gbuf[256], bbuf[256];
    610       1.1  macallan 
    611       1.1  macallan #ifdef GENFB_DEBUG
    612       1.1  macallan 	aprint_debug("putcmap: %d %d\n",index, count);
    613       1.1  macallan #endif
    614       1.1  macallan 	if (cm->index >= 256 || cm->count > 256 ||
    615       1.1  macallan 	    (cm->index + cm->count) > 256)
    616       1.1  macallan 		return EINVAL;
    617       1.1  macallan 	error = copyin(cm->red, &rbuf[index], count);
    618       1.1  macallan 	if (error)
    619       1.1  macallan 		return error;
    620       1.1  macallan 	error = copyin(cm->green, &gbuf[index], count);
    621       1.1  macallan 	if (error)
    622       1.1  macallan 		return error;
    623       1.1  macallan 	error = copyin(cm->blue, &bbuf[index], count);
    624       1.1  macallan 	if (error)
    625       1.1  macallan 		return error;
    626       1.1  macallan 
    627       1.1  macallan 	memcpy(&sc->sc_cmap_red[index], &rbuf[index], count);
    628       1.1  macallan 	memcpy(&sc->sc_cmap_green[index], &gbuf[index], count);
    629       1.1  macallan 	memcpy(&sc->sc_cmap_blue[index], &bbuf[index], count);
    630       1.1  macallan 
    631       1.1  macallan 	r = &sc->sc_cmap_red[index];
    632       1.1  macallan 	g = &sc->sc_cmap_green[index];
    633       1.1  macallan 	b = &sc->sc_cmap_blue[index];
    634       1.1  macallan 
    635       1.1  macallan 	for (i = 0; i < count; i++) {
    636       1.1  macallan 		genfb_putpalreg(sc, index, *r, *g, *b);
    637       1.1  macallan 		index++;
    638       1.1  macallan 		r++, g++, b++;
    639       1.1  macallan 	}
    640       1.1  macallan 	return 0;
    641       1.1  macallan }
    642       1.1  macallan 
    643       1.1  macallan static int
    644       1.1  macallan genfb_getcmap(struct genfb_softc *sc, struct wsdisplay_cmap *cm)
    645       1.1  macallan {
    646       1.1  macallan 	u_int index = cm->index;
    647       1.1  macallan 	u_int count = cm->count;
    648       1.1  macallan 	int error;
    649       1.1  macallan 
    650       1.1  macallan 	if (index >= 255 || count > 256 || index + count > 256)
    651       1.1  macallan 		return EINVAL;
    652       1.1  macallan 
    653       1.1  macallan 	error = copyout(&sc->sc_cmap_red[index],   cm->red,   count);
    654       1.1  macallan 	if (error)
    655       1.1  macallan 		return error;
    656       1.1  macallan 	error = copyout(&sc->sc_cmap_green[index], cm->green, count);
    657       1.1  macallan 	if (error)
    658       1.1  macallan 		return error;
    659       1.1  macallan 	error = copyout(&sc->sc_cmap_blue[index],  cm->blue,  count);
    660       1.1  macallan 	if (error)
    661       1.1  macallan 		return error;
    662       1.1  macallan 
    663       1.1  macallan 	return 0;
    664       1.1  macallan }
    665       1.1  macallan 
    666      1.28  jmcneill void
    667       1.1  macallan genfb_restore_palette(struct genfb_softc *sc)
    668       1.1  macallan {
    669       1.1  macallan 	int i;
    670       1.1  macallan 
    671      1.27  macallan 	if (sc->sc_depth <= 8) {
    672      1.27  macallan 		for (i = 0; i < (1 << sc->sc_depth); i++) {
    673      1.27  macallan 			genfb_putpalreg(sc, i, sc->sc_cmap_red[i],
    674      1.27  macallan 			    sc->sc_cmap_green[i], sc->sc_cmap_blue[i]);
    675      1.27  macallan 		}
    676       1.1  macallan 	}
    677       1.1  macallan }
    678       1.1  macallan 
    679      1.45  macallan static void
    680      1.45  macallan genfb_init_palette(struct genfb_softc *sc)
    681      1.45  macallan {
    682      1.45  macallan 	int i, j, tmp;
    683      1.45  macallan 
    684      1.45  macallan 	if (sc->sc_depth == 8) {
    685      1.45  macallan 		/* generate an r3g3b2 colour map */
    686      1.45  macallan 		for (i = 0; i < 256; i++) {
    687      1.45  macallan 			tmp = i & 0xe0;
    688      1.45  macallan 			/*
    689      1.45  macallan 			 * replicate bits so 0xe0 maps to a red value of 0xff
    690      1.45  macallan 			 * in order to make white look actually white
    691      1.45  macallan 			 */
    692      1.45  macallan 			tmp |= (tmp >> 3) | (tmp >> 6);
    693      1.45  macallan 			sc->sc_cmap_red[i] = tmp;
    694      1.45  macallan 
    695      1.45  macallan 			tmp = (i & 0x1c) << 3;
    696      1.45  macallan 			tmp |= (tmp >> 3) | (tmp >> 6);
    697      1.45  macallan 			sc->sc_cmap_green[i] = tmp;
    698      1.45  macallan 
    699      1.45  macallan 			tmp = (i & 0x03) << 6;
    700      1.45  macallan 			tmp |= tmp >> 2;
    701      1.45  macallan 			tmp |= tmp >> 4;
    702      1.45  macallan 			sc->sc_cmap_blue[i] = tmp;
    703      1.45  macallan 
    704      1.45  macallan 			genfb_putpalreg(sc, i, sc->sc_cmap_red[i],
    705      1.45  macallan 				       sc->sc_cmap_green[i],
    706      1.45  macallan 				       sc->sc_cmap_blue[i]);
    707      1.45  macallan 		}
    708      1.45  macallan 	} else {
    709      1.45  macallan 		/* steal rasops' ANSI cmap */
    710      1.45  macallan 		j = 0;
    711      1.45  macallan 		for (i = 0; i < 256; i++) {
    712      1.45  macallan 			sc->sc_cmap_red[i] = rasops_cmap[j];
    713      1.45  macallan 			sc->sc_cmap_green[i] = rasops_cmap[j + 1];
    714      1.45  macallan 			sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
    715      1.45  macallan 			j += 3;
    716      1.45  macallan 		}
    717      1.45  macallan 	}
    718      1.45  macallan }
    719      1.45  macallan 
    720       1.1  macallan static int
    721       1.1  macallan genfb_putpalreg(struct genfb_softc *sc, uint8_t idx, uint8_t r, uint8_t g,
    722       1.1  macallan     uint8_t b)
    723       1.1  macallan {
    724       1.1  macallan 
    725       1.4  macallan 	if (sc->sc_cmcb) {
    726       1.4  macallan 
    727       1.4  macallan 		sc->sc_cmcb->gcc_set_mapreg(sc->sc_cmcb->gcc_cookie,
    728       1.4  macallan 		    idx, r, g, b);
    729       1.4  macallan 	}
    730       1.1  macallan 	return 0;
    731       1.1  macallan }
    732       1.1  macallan 
    733      1.18  jmcneill void
    734      1.18  jmcneill genfb_cnattach(void)
    735      1.18  jmcneill {
    736      1.18  jmcneill 	genfb_cnattach_called = 1;
    737      1.18  jmcneill }
    738      1.18  jmcneill 
    739      1.20  jmcneill void
    740      1.20  jmcneill genfb_disable(void)
    741      1.20  jmcneill {
    742      1.20  jmcneill 	genfb_enabled = 0;
    743      1.20  jmcneill }
    744      1.20  jmcneill 
    745      1.18  jmcneill int
    746      1.18  jmcneill genfb_is_console(void)
    747      1.18  jmcneill {
    748      1.18  jmcneill 	return genfb_cnattach_called;
    749      1.18  jmcneill }
    750      1.19  jmcneill 
    751      1.19  jmcneill int
    752      1.20  jmcneill genfb_is_enabled(void)
    753      1.20  jmcneill {
    754      1.20  jmcneill 	return genfb_enabled;
    755      1.20  jmcneill }
    756      1.20  jmcneill 
    757      1.20  jmcneill int
    758      1.19  jmcneill genfb_borrow(bus_addr_t addr, bus_space_handle_t *hdlp)
    759      1.19  jmcneill {
    760      1.19  jmcneill 	struct genfb_softc *sc = genfb_softc;
    761      1.19  jmcneill 
    762      1.19  jmcneill 	if (sc && sc->sc_ops.genfb_borrow)
    763      1.19  jmcneill 		return sc->sc_ops.genfb_borrow(sc, addr, hdlp);
    764      1.19  jmcneill 	return 0;
    765      1.19  jmcneill }
    766      1.31  macallan 
    767      1.31  macallan static void
    768      1.31  macallan genfb_brightness_up(device_t dev)
    769      1.31  macallan {
    770      1.31  macallan 	struct genfb_softc *sc = device_private(dev);
    771      1.31  macallan 
    772      1.42  macallan 	KASSERT(sc->sc_brightness != NULL &&
    773      1.42  macallan 		sc->sc_brightness->gpc_upd_parameter != NULL);
    774      1.42  macallan 
    775      1.42  macallan 	(void)sc->sc_brightness->gpc_upd_parameter(
    776      1.42  macallan 	    sc->sc_brightness->gpc_cookie, GENFB_BRIGHTNESS_STEP);
    777      1.31  macallan }
    778      1.31  macallan 
    779      1.31  macallan static void
    780      1.31  macallan genfb_brightness_down(device_t dev)
    781      1.31  macallan {
    782      1.31  macallan 	struct genfb_softc *sc = device_private(dev);
    783      1.31  macallan 
    784      1.42  macallan 	KASSERT(sc->sc_brightness != NULL &&
    785      1.42  macallan 		sc->sc_brightness->gpc_upd_parameter != NULL);
    786      1.42  macallan 
    787      1.42  macallan 	(void)sc->sc_brightness->gpc_upd_parameter(
    788      1.42  macallan 	    sc->sc_brightness->gpc_cookie, - GENFB_BRIGHTNESS_STEP);
    789      1.31  macallan }
    790      1.35  jmcneill 
    791      1.35  jmcneill void
    792      1.35  jmcneill genfb_enable_polling(device_t dev)
    793      1.35  jmcneill {
    794      1.35  jmcneill 	struct genfb_softc *sc = device_private(dev);
    795      1.35  jmcneill 
    796      1.38  jmcneill 	if (sc->sc_console_screen.scr_vd) {
    797      1.38  jmcneill 		SCREEN_ENABLE_DRAWING(&sc->sc_console_screen);
    798      1.38  jmcneill 		vcons_hard_switch(&sc->sc_console_screen);
    799      1.38  jmcneill 		vcons_enable_polling(&sc->vd);
    800      1.55  riastrad 		if (sc->sc_ops.genfb_enable_polling)
    801      1.55  riastrad 			(*sc->sc_ops.genfb_enable_polling)(sc);
    802      1.38  jmcneill 	}
    803      1.35  jmcneill }
    804      1.35  jmcneill 
    805      1.35  jmcneill void
    806      1.35  jmcneill genfb_disable_polling(device_t dev)
    807      1.35  jmcneill {
    808      1.35  jmcneill 	struct genfb_softc *sc = device_private(dev);
    809      1.35  jmcneill 
    810      1.38  jmcneill 	if (sc->sc_console_screen.scr_vd) {
    811      1.55  riastrad 		if (sc->sc_ops.genfb_disable_polling)
    812      1.55  riastrad 			(*sc->sc_ops.genfb_disable_polling)(sc);
    813      1.38  jmcneill 		vcons_disable_polling(&sc->vd);
    814      1.38  jmcneill 	}
    815      1.35  jmcneill }
    816