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