Home | History | Annotate | Line # | Download | only in dev
valkyriefb.c revision 1.5.18.1
      1  1.5.18.1   thorpej /*	$NetBSD: valkyriefb.c,v 1.5.18.1 2021/03/21 21:09:02 thorpej Exp $	*/
      2       1.1  macallan 
      3       1.1  macallan /*
      4       1.1  macallan  * Copyright (c) 2012 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17       1.1  macallan  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18       1.1  macallan  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19       1.1  macallan  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20       1.1  macallan  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21       1.1  macallan  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22       1.1  macallan  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23       1.1  macallan  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24       1.1  macallan  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25       1.1  macallan  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26       1.1  macallan  */
     27       1.1  macallan 
     28       1.1  macallan /*
     29       1.1  macallan  * A console driver for Apple's Valkyrie onboard video controller, found in
     30       1.1  macallan  * for example the Performa 6360
     31       1.1  macallan  * This should be easy enough to adapt to mac68k but I don't have the hardware
     32       1.1  macallan  */
     33       1.1  macallan 
     34       1.1  macallan #include <sys/cdefs.h>
     35  1.5.18.1   thorpej __KERNEL_RCSID(0, "$NetBSD: valkyriefb.c,v 1.5.18.1 2021/03/21 21:09:02 thorpej Exp $");
     36       1.1  macallan 
     37       1.1  macallan #include <sys/param.h>
     38       1.1  macallan #include <sys/systm.h>
     39       1.1  macallan #include <sys/kernel.h>
     40       1.1  macallan #include <sys/device.h>
     41       1.1  macallan 
     42       1.1  macallan #include <dev/ofw/openfirm.h>
     43       1.1  macallan 
     44       1.1  macallan #include <machine/autoconf.h>
     45       1.1  macallan 
     46       1.5  macallan #include <uvm/uvm_extern.h>
     47       1.5  macallan #include <powerpc/oea/pmap.h>
     48       1.5  macallan 
     49       1.1  macallan #include <dev/wscons/wsdisplayvar.h>
     50       1.1  macallan #include <dev/wscons/wsconsio.h>
     51       1.1  macallan #include <dev/wsfont/wsfont.h>
     52       1.1  macallan #include <dev/rasops/rasops.h>
     53       1.1  macallan #include <dev/wscons/wsdisplay_vconsvar.h>
     54       1.1  macallan 
     55       1.1  macallan #include <dev/videomode/videomode.h>
     56       1.1  macallan 
     57       1.1  macallan #include <arch/macppc/dev/valkyriefbreg.h>
     58       1.1  macallan #include <arch/macppc/dev/videopllvar.h>
     59       1.1  macallan 
     60       1.1  macallan #include "opt_wsemul.h"
     61       1.1  macallan #include "opt_valkyriefb.h"
     62       1.1  macallan 
     63       1.1  macallan #include "videopll.h"
     64       1.1  macallan #if NVIDEOPLL < 1
     65       1.1  macallan #error "valkyriefb requires videopll at iic"
     66       1.1  macallan #endif
     67       1.1  macallan 
     68       1.1  macallan struct valkyriefb_softc {
     69       1.1  macallan 	device_t sc_dev;
     70       1.1  macallan 	int sc_node;
     71       1.1  macallan 	uint8_t *sc_base;
     72       1.2  macallan 	uint8_t *sc_fbaddr;
     73       1.1  macallan 
     74       1.1  macallan 	int sc_depth;
     75       1.1  macallan 	int sc_width, sc_height, sc_linebytes;
     76       1.1  macallan 	const struct videomode *sc_videomode;
     77       1.1  macallan 	uint8_t sc_modereg;
     78       1.1  macallan 
     79       1.1  macallan 	int sc_mode;
     80       1.1  macallan 	uint32_t sc_bg;
     81       1.1  macallan 
     82       1.1  macallan 	u_char sc_cmap_red[256];
     83       1.1  macallan 	u_char sc_cmap_green[256];
     84       1.1  macallan 	u_char sc_cmap_blue[256];
     85       1.1  macallan 
     86       1.1  macallan 	struct vcons_data vd;
     87       1.1  macallan };
     88       1.1  macallan 
     89       1.1  macallan struct valkyriefb_mode {
     90       1.1  macallan 	int width;
     91       1.1  macallan 	int height;
     92       1.1  macallan 	uint8_t mode;
     93       1.1  macallan };
     94       1.1  macallan 
     95       1.1  macallan /*
     96       1.1  macallan  * Translate screen resolutions to values for Valkyrie's mode register.
     97       1.1  macallan  * These numbers seem to roughly correspond to MacOS video mode numbers
     98       1.1  macallan  * there are many numbers that result in the same resolution which in MacOS
     99       1.1  macallan  * only differ by the display refresh rate, which isn't set by Valkyrie at
    100       1.1  macallan  * all, instead there's a PLL chip hooked to cuda's i2c bus. It doesn't seem
    101       1.1  macallan  * to matter which number we use as long as the resolution is right and we
    102       1.1  macallan  * program the PLL for the right pixel clock
    103       1.1  macallan  */
    104       1.1  macallan static struct valkyriefb_mode modetab[] = {
    105       1.1  macallan 	{  640, 480, 6 },
    106       1.1  macallan 	{  800, 600, 12 },
    107       1.1  macallan 	{  832, 624, 9 },
    108       1.1  macallan 	{ 1024, 768, 14},
    109       1.1  macallan };
    110       1.1  macallan 
    111       1.1  macallan static struct vcons_screen valkyriefb_console_screen;
    112       1.1  macallan 
    113       1.1  macallan static int	valkyriefb_match(device_t, cfdata_t, void *);
    114       1.1  macallan static void	valkyriefb_attach(device_t, device_t, void *);
    115       1.1  macallan static int	valkyriefb_init(device_t);
    116       1.1  macallan static int 	valkyriefb_set_mode(struct valkyriefb_softc *,
    117       1.1  macallan 		    const struct videomode *, int);
    118       1.1  macallan 
    119       1.1  macallan CFATTACH_DECL_NEW(valkyriefb, sizeof(struct valkyriefb_softc),
    120       1.1  macallan     valkyriefb_match, valkyriefb_attach, NULL, NULL);
    121       1.1  macallan 
    122       1.1  macallan struct wsscreen_descr valkyriefb_defaultscreen = {
    123       1.1  macallan 	"default",
    124       1.1  macallan 	0, 0,
    125       1.1  macallan 	NULL,
    126       1.1  macallan 	8, 16,
    127       1.1  macallan 	WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
    128       1.1  macallan 	NULL,
    129       1.1  macallan };
    130       1.1  macallan 
    131       1.1  macallan const struct wsscreen_descr *_valkyriefb_scrlist[] = {
    132       1.1  macallan 	&valkyriefb_defaultscreen,
    133       1.1  macallan 	/* XXX other formats, graphics screen? */
    134       1.1  macallan };
    135       1.1  macallan 
    136       1.1  macallan struct wsscreen_list valkyriefb_screenlist = {
    137       1.3  macallan 	sizeof(_valkyriefb_scrlist) / sizeof(struct wsscreen_descr *),
    138       1.3  macallan 	_valkyriefb_scrlist
    139       1.1  macallan };
    140       1.1  macallan 
    141       1.1  macallan static int	valkyriefb_ioctl(void *, void *, u_long, void *, int,
    142       1.1  macallan 		    struct lwp *);
    143       1.1  macallan static paddr_t	valkyriefb_mmap(void *, void *, off_t, int);
    144       1.1  macallan 
    145       1.1  macallan static void	valkyriefb_init_screen(void *, struct vcons_screen *, int,
    146       1.1  macallan 			    long *);
    147       1.1  macallan 
    148       1.1  macallan 
    149       1.1  macallan struct wsdisplay_accessops valkyriefb_accessops = {
    150       1.1  macallan 	valkyriefb_ioctl,
    151       1.1  macallan 	valkyriefb_mmap,
    152       1.1  macallan 	NULL,
    153       1.1  macallan 	NULL,
    154       1.1  macallan 	NULL,
    155       1.1  macallan 	NULL,	/* load_font */
    156       1.1  macallan 	NULL,	/* polls */
    157       1.1  macallan 	NULL,	/* scroll */
    158       1.1  macallan };
    159       1.1  macallan 
    160       1.1  macallan static inline void
    161       1.1  macallan valkyriefb_write_reg(struct valkyriefb_softc *sc, int reg, uint8_t val)
    162       1.1  macallan {
    163       1.1  macallan 	*(sc->sc_base + VAL_REGS_OFFSET + reg) = val;
    164       1.1  macallan 	__asm("eieio; sync;");
    165       1.1  macallan }
    166       1.1  macallan 
    167       1.4  macallan #ifdef VALKYRIEFB_DEBUG
    168       1.1  macallan static inline uint8_t
    169       1.1  macallan valkyriefb_read_reg(struct valkyriefb_softc *sc, int reg)
    170       1.1  macallan {
    171       1.1  macallan 	return *(sc->sc_base + VAL_REGS_OFFSET + reg);
    172       1.1  macallan }
    173       1.4  macallan #endif
    174       1.1  macallan 
    175       1.1  macallan static void
    176       1.1  macallan valkyriefb_write_cmap(struct valkyriefb_softc *sc,
    177       1.1  macallan     int reg, uint8_t r, uint8_t g, uint8_t b)
    178       1.1  macallan {
    179       1.1  macallan 	*(sc->sc_base + VAL_CMAP_OFFSET + VAL_CMAP_ADDR) = reg;
    180       1.1  macallan 	__asm("eieio; sync;");
    181       1.1  macallan 	*(sc->sc_base + VAL_CMAP_OFFSET + VAL_CMAP_LUT) = r;
    182       1.1  macallan 	__asm("eieio; sync;");
    183       1.1  macallan 	*(sc->sc_base + VAL_CMAP_OFFSET + VAL_CMAP_LUT) = g;
    184       1.1  macallan 	__asm("eieio; sync;");
    185       1.1  macallan 	*(sc->sc_base + VAL_CMAP_OFFSET + VAL_CMAP_LUT) = b;
    186       1.1  macallan 	__asm("eieio; sync;");
    187       1.1  macallan }
    188       1.1  macallan 
    189       1.1  macallan static int
    190       1.1  macallan valkyriefb_match(device_t parent, cfdata_t cf, void *aux)
    191       1.1  macallan {
    192       1.1  macallan 	struct confargs *ca = aux;
    193       1.1  macallan 
    194       1.1  macallan 	if (strcmp(ca->ca_name, "valkyrie") != 0)
    195       1.1  macallan 		return 0;
    196       1.1  macallan 	return 1;
    197       1.1  macallan }
    198       1.1  macallan 
    199       1.1  macallan static void
    200       1.1  macallan valkyriefb_attach(device_t parent, device_t self, void *aux)
    201       1.1  macallan {
    202       1.1  macallan 	struct valkyriefb_softc *sc = device_private(self);
    203       1.1  macallan 	struct confargs *ca = aux;
    204       1.1  macallan 
    205       1.1  macallan 	sc->sc_dev = self;
    206       1.1  macallan 	sc->sc_node = ca->ca_node;
    207       1.1  macallan 
    208       1.1  macallan 	aprint_normal(" address 0x%08x\n", ca->ca_reg[0]);
    209       1.1  macallan 	aprint_verbose_dev(sc->sc_dev, "waiting for videopll...\n");
    210       1.1  macallan 	sc->sc_base = (uint8_t *)ca->ca_reg[0];
    211       1.1  macallan #ifdef VALKYRIEFB_DEBUG
    212       1.1  macallan 	for (i = 0; i < 0x40; i += 8) {
    213       1.3  macallan 		aprint_error_dev(sc->sc_dev, "%02x: %02x\n", i,
    214       1.3  macallan 		    valkyriefb_read_reg(sc, i));
    215       1.1  macallan 	}
    216       1.1  macallan #endif
    217       1.1  macallan 	config_finalize_register(sc->sc_dev, valkyriefb_init);
    218       1.2  macallan 	sc->sc_fbaddr = (uint8_t *)(sc->sc_base + 0x1000);
    219       1.1  macallan }
    220       1.1  macallan 
    221       1.1  macallan static int
    222       1.1  macallan valkyriefb_init(device_t self)
    223       1.1  macallan {
    224       1.1  macallan 	struct valkyriefb_softc *sc = device_private(self);
    225       1.1  macallan 	const struct videomode *mode;
    226       1.1  macallan 	struct rasops_info *ri;
    227       1.1  macallan 	prop_dictionary_t dict;
    228       1.1  macallan 	struct wsemuldisplaydev_attach_args aa;
    229       1.1  macallan 	bool console = FALSE;
    230       1.1  macallan 	long defattr;
    231       1.1  macallan 
    232       1.1  macallan 	mode = pick_mode_by_ref(800, 600, 60);
    233       1.1  macallan 	if (mode == NULL)
    234       1.1  macallan 		return 0;
    235       1.1  macallan 
    236       1.1  macallan 	valkyriefb_set_mode(sc, mode, 8);
    237       1.1  macallan 
    238       1.3  macallan 	vcons_init(&sc->vd, sc, &valkyriefb_defaultscreen,
    239       1.3  macallan 	    &valkyriefb_accessops);
    240       1.1  macallan 	sc->vd.init_screen = valkyriefb_init_screen;
    241       1.1  macallan 
    242       1.1  macallan 	dict = device_properties(sc->sc_dev);
    243       1.1  macallan 	prop_dictionary_get_bool(dict, "is_console", &console);
    244       1.1  macallan 
    245       1.1  macallan 	ri = &valkyriefb_console_screen.scr_ri;
    246       1.1  macallan 	vcons_init_screen(&sc->vd, &valkyriefb_console_screen, 1, &defattr);
    247       1.2  macallan 	memset(sc->sc_base + 0x1000, ri->ri_devcmap[(defattr >> 16) & 0xf],
    248       1.2  macallan 	    sc->sc_width * sc->sc_linebytes);
    249       1.1  macallan 	valkyriefb_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
    250       1.1  macallan 
    251       1.1  macallan 	valkyriefb_defaultscreen.textops = &ri->ri_ops;
    252       1.1  macallan 	valkyriefb_defaultscreen.capabilities = ri->ri_caps;
    253       1.1  macallan 	valkyriefb_defaultscreen.nrows = ri->ri_rows;
    254       1.1  macallan 	valkyriefb_defaultscreen.ncols = ri->ri_cols;
    255       1.1  macallan 	if (console) {
    256       1.3  macallan 		wsdisplay_cnattach(&valkyriefb_defaultscreen, ri, 0, 0,
    257       1.3  macallan 		    defattr);
    258       1.2  macallan 		vcons_replay_msgbuf(&valkyriefb_console_screen);
    259       1.1  macallan 	}
    260       1.1  macallan 	aa.console = console;
    261       1.1  macallan 	aa.scrdata = &valkyriefb_screenlist;
    262       1.1  macallan 	aa.accessops = &valkyriefb_accessops;
    263       1.1  macallan 	aa.accesscookie = &sc->vd;
    264       1.1  macallan 
    265  1.5.18.1   thorpej 	config_found(self, &aa, wsemuldisplaydevprint, CFARG_EOL);
    266       1.1  macallan 
    267       1.1  macallan 	return 0;
    268       1.1  macallan }
    269       1.1  macallan 
    270       1.1  macallan static int
    271       1.1  macallan valkyriefb_set_mode(struct valkyriefb_softc *sc,
    272       1.1  macallan     const struct videomode *mode, int depth)
    273       1.1  macallan {
    274       1.1  macallan 	int i;
    275       1.1  macallan 	uint8_t modereg, tmp;
    276       1.1  macallan 
    277       1.1  macallan 	/* first find the parameter for the mode register */
    278       1.1  macallan 	i = 0;
    279       1.1  macallan 	while ((i < __arraycount(modetab)) &&
    280       1.1  macallan 	       (modetab[i].width != mode->hdisplay) &&
    281       1.1  macallan 	       (modetab[i].height != mode->vdisplay))
    282       1.1  macallan 		i++;
    283       1.3  macallan 	if (i >= __arraycount(modetab)) {
    284       1.3  macallan 		aprint_error_dev(sc->sc_dev,
    285       1.3  macallan 		    "Can't find a mode register value for %s\n", mode->name);
    286       1.3  macallan 		return EINVAL;
    287       1.3  macallan 	} else
    288       1.1  macallan 		modereg = modetab[i].mode;
    289       1.1  macallan 
    290       1.1  macallan 	/* check if we have enough video memory */
    291       1.1  macallan 	if ((mode->hdisplay * mode->vdisplay * (depth >> 3)) > 0x100000) {
    292       1.3  macallan 		aprint_error_dev(sc->sc_dev, "Not enough video RAM for %s\n",
    293       1.3  macallan 		    mode->name);
    294       1.1  macallan 		return EINVAL;
    295       1.1  macallan 	}
    296       1.1  macallan 
    297       1.1  macallan 	/* reject depths other than 8 or 16 */
    298       1.1  macallan 	if ((depth != 8) && (depth != 16)) {
    299       1.3  macallan 		aprint_error_dev(sc->sc_dev,
    300       1.3  macallan 		    "Depth [%d] is unsupported for %s\n", depth, mode->name);
    301       1.1  macallan 		return EINVAL;
    302       1.1  macallan 	}
    303       1.1  macallan 
    304       1.1  macallan 	/* now start programming the chip */
    305       1.1  macallan 	valkyriefb_write_reg(sc, VAL_STATUS, 0);
    306       1.1  macallan 	delay(100);
    307       1.1  macallan 	valkyriefb_write_reg(sc, VAL_MODE, modereg | VAL_MODE_STOP);
    308       1.1  macallan 
    309       1.1  macallan 	if (depth == 8) {
    310       1.1  macallan 		sc->sc_depth = 8;
    311       1.1  macallan 		valkyriefb_write_reg(sc, VAL_DEPTH, VAL_DEPTH_8);
    312       1.1  macallan 		for (i = 0; i < 256; i++) {
    313       1.1  macallan 			tmp = i & 0xe0;
    314       1.1  macallan 			/*
    315       1.1  macallan 			 * replicate bits so 0xe0 maps to a red value of 0xff
    316       1.1  macallan 			 * in order to make white look actually white
    317       1.1  macallan 			 */
    318       1.1  macallan 			tmp |= (tmp >> 3) | (tmp >> 6);
    319       1.1  macallan 			sc->sc_cmap_red[i] = tmp;
    320       1.1  macallan 
    321       1.1  macallan 			tmp = (i & 0x1c) << 3;
    322       1.1  macallan 			tmp |= (tmp >> 3) | (tmp >> 6);
    323       1.1  macallan 			sc->sc_cmap_green[i] = tmp;
    324       1.1  macallan 
    325       1.1  macallan 			tmp = (i & 0x03) << 6;
    326       1.1  macallan 			tmp |= tmp >> 2;
    327       1.1  macallan 			tmp |= tmp >> 4;
    328       1.1  macallan 			sc->sc_cmap_blue[i] = tmp;
    329       1.1  macallan 
    330       1.1  macallan 			valkyriefb_write_cmap(sc, i, sc->sc_cmap_red[i],
    331       1.1  macallan 			    sc->sc_cmap_green[i], sc->sc_cmap_blue[i]);
    332       1.1  macallan 		}
    333       1.1  macallan 	} else if (depth == 16) {
    334       1.1  macallan 		sc->sc_depth = 16;
    335       1.1  macallan 		valkyriefb_write_reg(sc, VAL_DEPTH, VAL_DEPTH_16);
    336       1.1  macallan 		/* does the palette have any effect in 16bit? */
    337       1.1  macallan 	}
    338       1.1  macallan 
    339       1.1  macallan 	videopll_set_freq(mode->dot_clock);
    340       1.1  macallan 	delay(100);
    341       1.1  macallan 	valkyriefb_write_reg(sc, VAL_MODE, modereg);
    342       1.1  macallan 
    343       1.1  macallan 	sc->sc_modereg = modereg;
    344       1.1  macallan 	sc->sc_videomode = mode;
    345       1.1  macallan 	sc->sc_width = mode->hdisplay;
    346       1.1  macallan 	sc->sc_height = mode->vdisplay;
    347       1.1  macallan 	sc->sc_linebytes = mode->hdisplay * (sc->sc_depth >> 3);
    348       1.1  macallan 	aprint_normal_dev(sc->sc_dev, "switched to %d x %d in %d bit colour\n",
    349       1.1  macallan 	    sc->sc_width, sc->sc_height, sc->sc_depth);
    350       1.1  macallan 	return 0;
    351       1.1  macallan }
    352       1.1  macallan 
    353       1.1  macallan static int
    354       1.1  macallan valkyriefb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
    355       1.1  macallan 	struct lwp *l)
    356       1.1  macallan {
    357       1.1  macallan 	struct vcons_data *vd = v;
    358       1.1  macallan 	struct valkyriefb_softc *sc = vd->cookie;
    359       1.1  macallan 	struct wsdisplay_fbinfo *wdf;
    360       1.1  macallan 	struct vcons_screen *ms = vd->active;
    361       1.1  macallan 
    362       1.1  macallan 	switch (cmd) {
    363       1.1  macallan 	case WSDISPLAYIO_GTYPE:
    364       1.1  macallan 		*(u_int *)data = WSDISPLAY_TYPE_VALKYRIE;
    365       1.1  macallan 		return 0;
    366       1.1  macallan 
    367       1.1  macallan 	case WSDISPLAYIO_GINFO:
    368       1.1  macallan 		wdf = (void *)data;
    369       1.1  macallan 		wdf->height = ms->scr_ri.ri_height;
    370       1.1  macallan 		wdf->width = ms->scr_ri.ri_width;
    371       1.1  macallan 		wdf->depth = ms->scr_ri.ri_depth;
    372       1.1  macallan 		wdf->cmsize = 256;
    373       1.1  macallan 		return 0;
    374       1.1  macallan #if 0
    375       1.1  macallan 	case WSDISPLAYIO_GETCMAP:
    376       1.1  macallan 		return valkyriefb_getcmap(sc,
    377       1.1  macallan 		    (struct wsdisplay_cmap *)data);
    378       1.1  macallan 
    379       1.1  macallan 	case WSDISPLAYIO_PUTCMAP:
    380       1.1  macallan 		return valkyriefb_putcmap(sc,
    381       1.1  macallan 		    (struct wsdisplay_cmap *)data);
    382       1.1  macallan #endif
    383       1.1  macallan 
    384       1.1  macallan 	case WSDISPLAYIO_SMODE: {
    385       1.1  macallan 		int new_mode = *(int*)data;
    386       1.1  macallan 		if (new_mode != sc->sc_mode) {
    387       1.1  macallan 			sc->sc_mode = new_mode;
    388       1.1  macallan 			if (new_mode == WSDISPLAYIO_MODE_EMUL) {
    389       1.1  macallan 				vcons_redraw_screen(ms);
    390       1.1  macallan 			}
    391       1.1  macallan 		}
    392       1.1  macallan 		}
    393       1.1  macallan 		return 0;
    394       1.1  macallan 	}
    395       1.1  macallan 	return EPASSTHROUGH;
    396       1.1  macallan }
    397       1.1  macallan 
    398       1.1  macallan static paddr_t
    399       1.1  macallan valkyriefb_mmap(void *v, void *vs, off_t offset, int prot)
    400       1.1  macallan {
    401       1.1  macallan 	struct vcons_data *vd = v;
    402       1.1  macallan 	struct valkyriefb_softc *sc = vd->cookie;
    403       1.1  macallan 	paddr_t pa;
    404       1.1  macallan 
    405       1.1  macallan 	/* 'regular' framebuffer mmap()ing */
    406       1.1  macallan 	if (offset < 0x100000) {
    407       1.1  macallan 		pa = (paddr_t)(sc->sc_base + 0x1000 + offset);
    408       1.5  macallan 		pa |= POWERPC_MMAP_FLAG_PREFETCHABLE;
    409       1.1  macallan 		return pa;
    410       1.1  macallan 	}
    411       1.1  macallan 	return -1;
    412       1.1  macallan }
    413       1.1  macallan 
    414       1.1  macallan static void
    415       1.1  macallan valkyriefb_init_screen(void *cookie, struct vcons_screen *scr,
    416       1.1  macallan     int existing, long *defattr)
    417       1.1  macallan {
    418       1.1  macallan 	struct valkyriefb_softc *sc = cookie;
    419       1.1  macallan 	struct rasops_info *ri = &scr->scr_ri;
    420       1.1  macallan 
    421       1.2  macallan 	memset(ri, 0, sizeof(struct rasops_info));
    422       1.1  macallan 	ri->ri_depth = sc->sc_depth;
    423       1.1  macallan 	ri->ri_width = sc->sc_width;
    424       1.1  macallan 	ri->ri_height = sc->sc_height;
    425       1.1  macallan 	ri->ri_stride = sc->sc_linebytes;
    426       1.1  macallan 	ri->ri_flg = RI_CENTER | RI_8BIT_IS_RGB | RI_ENABLE_ALPHA;
    427       1.2  macallan 	ri->ri_bits = sc->sc_fbaddr;
    428       1.2  macallan 
    429       1.1  macallan 	scr->scr_flags |= VCONS_DONT_READ;
    430       1.1  macallan 
    431       1.1  macallan 	rasops_init(ri, 0, 0);
    432       1.1  macallan 	ri->ri_caps = WSSCREEN_WSCOLORS;
    433       1.1  macallan 
    434       1.1  macallan 	rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
    435       1.1  macallan 		    sc->sc_width / ri->ri_font->fontwidth);
    436       1.1  macallan 
    437       1.1  macallan 	ri->ri_hw = scr;
    438       1.1  macallan }
    439