ffb.c revision 1.37 1 1.37 macallan /* $NetBSD: ffb.c,v 1.37 2009/08/20 02:50:46 macallan Exp $ */
2 1.1 petrov /* $OpenBSD: creator.c,v 1.20 2002/07/30 19:48:15 jason Exp $ */
3 1.1 petrov
4 1.1 petrov /*
5 1.1 petrov * Copyright (c) 2002 Jason L. Wright (jason (at) thought.net)
6 1.1 petrov * All rights reserved.
7 1.1 petrov *
8 1.1 petrov * Redistribution and use in source and binary forms, with or without
9 1.1 petrov * modification, are permitted provided that the following conditions
10 1.1 petrov * are met:
11 1.1 petrov * 1. Redistributions of source code must retain the above copyright
12 1.1 petrov * notice, this list of conditions and the following disclaimer.
13 1.1 petrov * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 petrov * notice, this list of conditions and the following disclaimer in the
15 1.1 petrov * documentation and/or other materials provided with the distribution.
16 1.1 petrov * 3. All advertising materials mentioning features or use of this software
17 1.1 petrov * must display the following acknowledgement:
18 1.1 petrov * This product includes software developed by Jason L. Wright
19 1.1 petrov * 4. The name of the author may not be used to endorse or promote products
20 1.1 petrov * derived from this software without specific prior written permission.
21 1.1 petrov *
22 1.1 petrov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 petrov * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 1.1 petrov * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 1.1 petrov * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
26 1.1 petrov * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 1.1 petrov * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 1.1 petrov * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 petrov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 1.1 petrov * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 1.1 petrov * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 1.1 petrov * POSSIBILITY OF SUCH DAMAGE.
33 1.1 petrov */
34 1.3 lukem
35 1.3 lukem #include <sys/cdefs.h>
36 1.37 macallan __KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.37 2009/08/20 02:50:46 macallan Exp $");
37 1.1 petrov
38 1.1 petrov #include <sys/types.h>
39 1.1 petrov #include <sys/param.h>
40 1.1 petrov #include <sys/systm.h>
41 1.1 petrov #include <sys/kernel.h>
42 1.1 petrov #include <sys/device.h>
43 1.1 petrov #include <sys/conf.h>
44 1.16 macallan #include <sys/ioctl.h>
45 1.16 macallan #include <sys/malloc.h>
46 1.16 macallan #include <sys/mman.h>
47 1.1 petrov
48 1.1 petrov #include <machine/bus.h>
49 1.1 petrov #include <machine/autoconf.h>
50 1.1 petrov #include <machine/openfirm.h>
51 1.11 martin #include <machine/vmparam.h>
52 1.1 petrov
53 1.1 petrov #include <dev/wscons/wsconsio.h>
54 1.11 martin #include <dev/sun/fbio.h>
55 1.11 martin #include <dev/sun/fbvar.h>
56 1.1 petrov
57 1.30 martin #include <dev/wsfont/wsfont.h>
58 1.30 martin #include <dev/wscons/wsdisplay_vconsvar.h>
59 1.30 martin
60 1.1 petrov #include <sparc64/dev/ffbreg.h>
61 1.1 petrov #include <sparc64/dev/ffbvar.h>
62 1.1 petrov
63 1.16 macallan #ifndef WS_DEFAULT_BG
64 1.16 macallan /* Sun -> background should be white */
65 1.16 macallan #define WS_DEFAULT_BG 0xf
66 1.16 macallan #endif
67 1.16 macallan
68 1.11 martin extern struct cfdriver ffb_cd;
69 1.11 martin
70 1.1 petrov struct wsscreen_descr ffb_stdscreen = {
71 1.6 heas "sunffb",
72 1.1 petrov 0, 0, /* will be filled in -- XXX shouldn't, it's global. */
73 1.1 petrov 0,
74 1.1 petrov 0, 0,
75 1.31 martin WSSCREEN_REVERSE | WSSCREEN_WSCOLORS,
76 1.31 martin NULL /* modecookie */
77 1.1 petrov };
78 1.1 petrov
79 1.1 petrov const struct wsscreen_descr *ffb_scrlist[] = {
80 1.1 petrov &ffb_stdscreen,
81 1.1 petrov /* XXX other formats? */
82 1.1 petrov };
83 1.1 petrov
84 1.1 petrov struct wsscreen_list ffb_screenlist = {
85 1.1 petrov sizeof(ffb_scrlist) / sizeof(struct wsscreen_descr *),
86 1.1 petrov ffb_scrlist
87 1.1 petrov };
88 1.1 petrov
89 1.30 martin static struct vcons_screen ffb_console_screen;
90 1.16 macallan
91 1.32 christos int ffb_ioctl(void *, void *, u_long, void *, int, struct lwp *);
92 1.7 heas static int ffb_blank(struct ffb_softc *, u_long, u_int *);
93 1.24 jmmv paddr_t ffb_mmap(void *, void *, off_t, int);
94 1.1 petrov void ffb_ras_fifo_wait(struct ffb_softc *, int);
95 1.1 petrov void ffb_ras_wait(struct ffb_softc *);
96 1.1 petrov void ffb_ras_init(struct ffb_softc *);
97 1.1 petrov void ffb_ras_copyrows(void *, int, int, int);
98 1.1 petrov void ffb_ras_erasecols(void *, int, int, int, long int);
99 1.1 petrov void ffb_ras_eraserows(void *, int, int, long int);
100 1.1 petrov void ffb_ras_do_cursor(struct rasops_info *);
101 1.1 petrov void ffb_ras_fill(struct ffb_softc *);
102 1.1 petrov void ffb_ras_setfg(struct ffb_softc *, int32_t);
103 1.1 petrov
104 1.16 macallan void ffb_clearscreen(struct ffb_softc *);
105 1.16 macallan int ffb_load_font(void *, void *, struct wsdisplay_font *);
106 1.30 martin void ffb_init_screen(void *, struct vcons_screen *, int,
107 1.16 macallan long *);
108 1.16 macallan int ffb_allocattr(void *, int, int, int, long *);
109 1.16 macallan void ffb_putchar(void *, int, int, u_int, long);
110 1.16 macallan void ffb_cursor(void *, int, int, int);
111 1.16 macallan
112 1.11 martin /* frame buffer generic driver */
113 1.11 martin static void ffbfb_unblank(struct device*);
114 1.11 martin dev_type_open(ffbfb_open);
115 1.11 martin dev_type_close(ffbfb_close);
116 1.11 martin dev_type_ioctl(ffbfb_ioctl);
117 1.11 martin dev_type_mmap(ffbfb_mmap);
118 1.16 macallan
119 1.11 martin static struct fbdriver ffb_fbdriver = {
120 1.11 martin ffbfb_unblank, ffbfb_open, ffbfb_close, ffbfb_ioctl, nopoll,
121 1.11 martin ffbfb_mmap, nokqfilter
122 1.11 martin };
123 1.11 martin
124 1.1 petrov struct wsdisplay_accessops ffb_accessops = {
125 1.30 martin .ioctl = ffb_ioctl,
126 1.30 martin .mmap = ffb_mmap,
127 1.1 petrov };
128 1.1 petrov
129 1.1 petrov void
130 1.1 petrov ffb_attach(struct ffb_softc *sc)
131 1.1 petrov {
132 1.1 petrov struct wsemuldisplaydev_attach_args waa;
133 1.16 macallan struct rasops_info *ri;
134 1.16 macallan long defattr;
135 1.15 christos const char *model;
136 1.1 petrov int btype;
137 1.30 martin uint32_t dac;
138 1.4 pk int maxrow, maxcol;
139 1.7 heas u_int blank = WSDISPLAYIO_VIDEO_ON;
140 1.4 pk char buf[6+1];
141 1.1 petrov
142 1.1 petrov printf(":");
143 1.18 macallan
144 1.18 macallan sc->putchar = NULL;
145 1.18 macallan
146 1.1 petrov if (sc->sc_type == FFB_CREATOR) {
147 1.5 pk btype = prom_getpropint(sc->sc_node, "board_type", 0);
148 1.1 petrov if ((btype & 7) == 3)
149 1.1 petrov printf(" Creator3D");
150 1.1 petrov else
151 1.1 petrov printf(" Creator");
152 1.1 petrov } else
153 1.1 petrov printf(" Elite3D");
154 1.1 petrov
155 1.5 pk model = prom_getpropstring(sc->sc_node, "model");
156 1.1 petrov if (model == NULL || strlen(model) == 0)
157 1.1 petrov model = "unknown";
158 1.1 petrov
159 1.1 petrov sc->sc_depth = 24;
160 1.1 petrov sc->sc_linebytes = 8192;
161 1.5 pk sc->sc_height = prom_getpropint(sc->sc_node, "height", 0);
162 1.5 pk sc->sc_width = prom_getpropint(sc->sc_node, "width", 0);
163 1.30 martin
164 1.30 martin sc->sc_locked = 0;
165 1.30 martin sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
166 1.30 martin
167 1.4 pk maxcol = (prom_getoption("screen-#columns", buf, sizeof buf) == 0)
168 1.4 pk ? strtoul(buf, NULL, 10)
169 1.4 pk : 80;
170 1.4 pk
171 1.30 martin maxrow = (prom_getoption("screen-#rows", buf, sizeof buf) != 0)
172 1.4 pk ? strtoul(buf, NULL, 10)
173 1.4 pk : 34;
174 1.4 pk
175 1.16 macallan ffb_ras_init(sc);
176 1.1 petrov
177 1.8 heas /* collect DAC version, as Elite3D cursor enable bit is reversed */
178 1.8 heas DAC_WRITE(sc, FFB_DAC_TYPE, FFB_DAC_GVERS);
179 1.30 martin dac = DAC_READ(sc, FFB_DAC_VALUE);
180 1.30 martin sc->sc_dacrev = (dac >> 28) & 0xf;
181 1.8 heas
182 1.30 martin if (sc->sc_type == FFB_AFB) {
183 1.8 heas sc->sc_dacrev = 10;
184 1.30 martin sc->sc_needredraw = 0;
185 1.30 martin } else {
186 1.30 martin /* see what kind of DAC we have */
187 1.30 martin int pnum = (dac & 0x0ffff000) >> 12;
188 1.30 martin if (pnum == 0x236e) {
189 1.30 martin sc->sc_needredraw = 0;
190 1.30 martin } else {
191 1.30 martin sc->sc_needredraw = 1;
192 1.30 martin }
193 1.30 martin }
194 1.8 heas printf(", model %s, dac %u\n", model, sc->sc_dacrev);
195 1.30 martin if (sc->sc_needredraw)
196 1.30 martin printf("%s: found old DAC, enabling redraw on unblank\n",
197 1.33 cegger device_xname(&sc->sc_dv));
198 1.8 heas
199 1.7 heas ffb_blank(sc, WSDISPLAYIO_SVIDEO, &blank);
200 1.7 heas
201 1.23 thorpej sc->sc_accel = ((device_cfdata(&sc->sc_dv)->cf_flags &
202 1.23 thorpej FFB_CFFLAG_NOACCEL) == 0);
203 1.16 macallan
204 1.16 macallan wsfont_init();
205 1.16 macallan
206 1.30 martin vcons_init(&sc->vd, sc, &ffb_stdscreen, &ffb_accessops);
207 1.30 martin sc->vd.init_screen = ffb_init_screen;
208 1.30 martin
209 1.19 jdc /* we mess with ffb_console_screen only once */
210 1.19 jdc if (sc->sc_console) {
211 1.30 martin vcons_init_screen(&sc->vd, &ffb_console_screen, 1, &defattr);
212 1.30 martin SCREEN_VISIBLE((&ffb_console_screen));
213 1.30 martin /*
214 1.30 martin * XXX we shouldn't use a global variable for the console
215 1.30 martin * screen
216 1.30 martin */
217 1.30 martin sc->vd.active = &ffb_console_screen;
218 1.30 martin ffb_console_screen.scr_flags = VCONS_SCREEN_IS_STATIC;
219 1.30 martin } else {
220 1.30 martin if (ffb_console_screen.scr_ri.ri_rows == 0) {
221 1.30 martin /* do some minimal setup to avoid weirdnesses later */
222 1.30 martin vcons_init_screen(&sc->vd, &ffb_console_screen, 1, &defattr);
223 1.30 martin }
224 1.19 jdc }
225 1.30 martin ri = &ffb_console_screen.scr_ri;
226 1.16 macallan
227 1.16 macallan ffb_stdscreen.nrows = ri->ri_rows;
228 1.16 macallan ffb_stdscreen.ncols = ri->ri_cols;
229 1.16 macallan ffb_stdscreen.textops = &ri->ri_ops;
230 1.16 macallan ffb_stdscreen.capabilities = ri->ri_caps;
231 1.16 macallan
232 1.11 martin sc->sc_fb.fb_driver = &ffb_fbdriver;
233 1.11 martin sc->sc_fb.fb_type.fb_cmsize = 0;
234 1.11 martin sc->sc_fb.fb_type.fb_size = maxrow * sc->sc_linebytes;
235 1.11 martin sc->sc_fb.fb_type.fb_type = FBTYPE_CREATOR;
236 1.12 mhitch sc->sc_fb.fb_type.fb_width = sc->sc_width;
237 1.12 mhitch sc->sc_fb.fb_type.fb_depth = sc->sc_depth;
238 1.12 mhitch sc->sc_fb.fb_type.fb_height = sc->sc_height;
239 1.11 martin sc->sc_fb.fb_device = &sc->sc_dv;
240 1.11 martin fb_attach(&sc->sc_fb, sc->sc_console);
241 1.11 martin
242 1.37 macallan ffb_clearscreen(sc);
243 1.37 macallan
244 1.1 petrov if (sc->sc_console) {
245 1.16 macallan wsdisplay_cnattach(&ffb_stdscreen, ri, 0, 0, defattr);
246 1.37 macallan vcons_replay_msgbuf(&ffb_console_screen);
247 1.1 petrov }
248 1.16 macallan
249 1.1 petrov waa.console = sc->sc_console;
250 1.1 petrov waa.scrdata = &ffb_screenlist;
251 1.1 petrov waa.accessops = &ffb_accessops;
252 1.30 martin waa.accesscookie = &sc->vd;
253 1.1 petrov config_found(&sc->sc_dv, &waa, wsemuldisplaydevprint);
254 1.1 petrov }
255 1.1 petrov
256 1.1 petrov int
257 1.32 christos ffb_ioctl(void *v, void *vs, u_long cmd, void *data, int flags, struct lwp *l)
258 1.1 petrov {
259 1.30 martin struct vcons_data *vd = v;
260 1.30 martin struct ffb_softc *sc = vd->cookie;
261 1.1 petrov struct wsdisplay_fbinfo *wdf;
262 1.30 martin struct vcons_screen *ms = vd->active;
263 1.30 martin
264 1.2 petrov #ifdef FFBDEBUG
265 1.1 petrov printf("ffb_ioctl: %s cmd _IO%s%s('%c', %lu)\n",
266 1.33 cegger device_xname(&sc->sc_dv),
267 1.1 petrov (cmd & IOC_IN) ? "W" : "", (cmd & IOC_OUT) ? "R" : "",
268 1.1 petrov (char)IOCGROUP(cmd), cmd & 0xff);
269 1.2 petrov #endif
270 1.1 petrov
271 1.1 petrov switch (cmd) {
272 1.11 martin case FBIOGTYPE:
273 1.11 martin *(struct fbtype *)data = sc->sc_fb.fb_type;
274 1.11 martin break;
275 1.11 martin case FBIOGATTR:
276 1.11 martin #define fba ((struct fbgattr *)data)
277 1.11 martin fba->real_type = sc->sc_fb.fb_type.fb_type;
278 1.11 martin fba->owner = 0; /* XXX ??? */
279 1.11 martin fba->fbtype = sc->sc_fb.fb_type;
280 1.11 martin fba->sattr.flags = 0;
281 1.11 martin fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type;
282 1.11 martin fba->sattr.dev_specific[0] = -1;
283 1.11 martin fba->emu_types[0] = sc->sc_fb.fb_type.fb_type;
284 1.11 martin fba->emu_types[1] = -1;
285 1.11 martin #undef fba
286 1.11 martin break;
287 1.11 martin
288 1.11 martin case FBIOGETCMAP:
289 1.11 martin case FBIOPUTCMAP:
290 1.11 martin return EIO;
291 1.11 martin
292 1.11 martin case FBIOGVIDEO:
293 1.11 martin case FBIOSVIDEO:
294 1.11 martin return ffb_blank(sc, cmd == FBIOGVIDEO?
295 1.11 martin WSDISPLAYIO_GVIDEO : WSDISPLAYIO_SVIDEO,
296 1.11 martin (u_int *)data);
297 1.11 martin break;
298 1.11 martin case FBIOGCURSOR:
299 1.11 martin case FBIOSCURSOR:
300 1.13 martin /* the console driver is not using the hardware cursor */
301 1.13 martin break;
302 1.11 martin case FBIOGCURPOS:
303 1.33 cegger printf("%s: FBIOGCURPOS not implemented\n", device_xname(&sc->sc_dv));
304 1.11 martin return EIO;
305 1.11 martin case FBIOSCURPOS:
306 1.33 cegger printf("%s: FBIOSCURPOS not implemented\n", device_xname(&sc->sc_dv));
307 1.11 martin return EIO;
308 1.11 martin case FBIOGCURMAX:
309 1.33 cegger printf("%s: FBIOGCURMAX not implemented\n", device_xname(&sc->sc_dv));
310 1.11 martin return EIO;
311 1.11 martin
312 1.1 petrov case WSDISPLAYIO_GTYPE:
313 1.6 heas *(u_int *)data = WSDISPLAY_TYPE_SUNFFB;
314 1.1 petrov break;
315 1.1 petrov case WSDISPLAYIO_SMODE:
316 1.16 macallan {
317 1.16 macallan if (sc->sc_mode != *(u_int *)data) {
318 1.16 macallan sc->sc_mode = *(u_int *)data;
319 1.30 martin if ((sc->sc_mode == WSDISPLAYIO_MODE_EMUL) &&
320 1.30 martin (sc->sc_locked == 0)) {
321 1.16 macallan ffb_ras_init(sc);
322 1.30 martin vcons_redraw_screen(ms);
323 1.16 macallan }
324 1.16 macallan }
325 1.16 macallan }
326 1.1 petrov break;
327 1.1 petrov case WSDISPLAYIO_GINFO:
328 1.1 petrov wdf = (void *)data;
329 1.1 petrov wdf->height = sc->sc_height;
330 1.1 petrov wdf->width = sc->sc_width;
331 1.1 petrov wdf->depth = 32;
332 1.1 petrov wdf->cmsize = 256; /* XXX */
333 1.1 petrov break;
334 1.1 petrov #ifdef WSDISPLAYIO_LINEBYTES
335 1.1 petrov case WSDISPLAYIO_LINEBYTES:
336 1.1 petrov *(u_int *)data = sc->sc_linebytes;
337 1.1 petrov break;
338 1.1 petrov #endif
339 1.1 petrov case WSDISPLAYIO_GETCMAP:
340 1.1 petrov break;/* XXX */
341 1.1 petrov
342 1.1 petrov case WSDISPLAYIO_PUTCMAP:
343 1.1 petrov break;/* XXX */
344 1.1 petrov
345 1.1 petrov case WSDISPLAYIO_SVIDEO:
346 1.1 petrov case WSDISPLAYIO_GVIDEO:
347 1.7 heas return(ffb_blank(sc, cmd, (u_int *)data));
348 1.7 heas break;
349 1.1 petrov case WSDISPLAYIO_GCURPOS:
350 1.1 petrov case WSDISPLAYIO_SCURPOS:
351 1.1 petrov case WSDISPLAYIO_GCURMAX:
352 1.1 petrov case WSDISPLAYIO_GCURSOR:
353 1.1 petrov case WSDISPLAYIO_SCURSOR:
354 1.9 martin return EIO; /* not supported yet */
355 1.1 petrov default:
356 1.9 martin return EPASSTHROUGH;
357 1.1 petrov }
358 1.1 petrov
359 1.1 petrov return (0);
360 1.1 petrov }
361 1.1 petrov
362 1.7 heas /* blank/unblank the screen */
363 1.7 heas static int
364 1.7 heas ffb_blank(struct ffb_softc *sc, u_long cmd, u_int *data)
365 1.7 heas {
366 1.30 martin struct vcons_screen *ms = sc->vd.active;
367 1.7 heas u_int val;
368 1.30 martin
369 1.7 heas DAC_WRITE(sc, FFB_DAC_TYPE, FFB_DAC_GSBLANK);
370 1.7 heas val = DAC_READ(sc, FFB_DAC_VALUE);
371 1.7 heas
372 1.7 heas switch (cmd) {
373 1.7 heas case WSDISPLAYIO_GVIDEO:
374 1.7 heas *data = val & 1;
375 1.7 heas return(0);
376 1.7 heas break;
377 1.7 heas case WSDISPLAYIO_SVIDEO:
378 1.7 heas if (*data == WSDISPLAYIO_VIDEO_OFF)
379 1.7 heas val &= ~1;
380 1.7 heas else if (*data == WSDISPLAYIO_VIDEO_ON)
381 1.7 heas val |= 1;
382 1.7 heas else
383 1.7 heas return(EINVAL);
384 1.7 heas break;
385 1.7 heas default:
386 1.7 heas return(EINVAL);
387 1.7 heas }
388 1.7 heas
389 1.7 heas DAC_WRITE(sc, FFB_DAC_TYPE, FFB_DAC_GSBLANK);
390 1.7 heas DAC_WRITE(sc, FFB_DAC_VALUE, val);
391 1.30 martin
392 1.30 martin if ((val & 1) && sc->sc_needredraw) {
393 1.30 martin if (ms != NULL) {
394 1.30 martin if ((sc->sc_mode == WSDISPLAYIO_MODE_EMUL) &&
395 1.30 martin (sc->sc_locked == 0)) {
396 1.30 martin ffb_ras_init(sc);
397 1.30 martin vcons_redraw_screen(ms);
398 1.30 martin }
399 1.30 martin }
400 1.30 martin }
401 1.7 heas
402 1.7 heas return(0);
403 1.7 heas }
404 1.7 heas
405 1.1 petrov paddr_t
406 1.24 jmmv ffb_mmap(void *vsc, void *vs, off_t off, int prot)
407 1.1 petrov {
408 1.30 martin struct vcons_data *vd = vsc;
409 1.30 martin struct ffb_softc *sc = vd->cookie;
410 1.1 petrov int i;
411 1.1 petrov
412 1.1 petrov switch (sc->sc_mode) {
413 1.1 petrov case WSDISPLAYIO_MODE_MAPPED:
414 1.1 petrov for (i = 0; i < sc->sc_nreg; i++) {
415 1.1 petrov /* Before this set? */
416 1.1 petrov if (off < sc->sc_addrs[i])
417 1.1 petrov continue;
418 1.1 petrov /* After this set? */
419 1.1 petrov if (off >= (sc->sc_addrs[i] + sc->sc_sizes[i]))
420 1.1 petrov continue;
421 1.1 petrov
422 1.1 petrov return (bus_space_mmap(sc->sc_bt, sc->sc_addrs[i],
423 1.1 petrov off - sc->sc_addrs[i], prot, BUS_SPACE_MAP_LINEAR));
424 1.1 petrov }
425 1.1 petrov break;
426 1.1 petrov #ifdef WSDISPLAYIO_MODE_DUMBFB
427 1.1 petrov case WSDISPLAYIO_MODE_DUMBFB:
428 1.1 petrov if (sc->sc_nreg < FFB_REG_DFB24)
429 1.1 petrov break;
430 1.1 petrov if (off >= 0 && off < sc->sc_sizes[FFB_REG_DFB24])
431 1.1 petrov return (bus_space_mmap(sc->sc_bt,
432 1.1 petrov sc->sc_addrs[FFB_REG_DFB24], off, prot,
433 1.1 petrov BUS_SPACE_MAP_LINEAR));
434 1.1 petrov break;
435 1.1 petrov #endif
436 1.1 petrov }
437 1.1 petrov return (-1);
438 1.1 petrov }
439 1.1 petrov
440 1.1 petrov void
441 1.10 martin ffb_ras_fifo_wait(struct ffb_softc *sc, int n)
442 1.1 petrov {
443 1.1 petrov int32_t cache = sc->sc_fifo_cache;
444 1.1 petrov
445 1.1 petrov if (cache < n) {
446 1.1 petrov do {
447 1.1 petrov cache = FBC_READ(sc, FFB_FBC_UCSR);
448 1.1 petrov cache = (cache & FBC_UCSR_FIFO_MASK) - 8;
449 1.1 petrov } while (cache < n);
450 1.1 petrov }
451 1.1 petrov sc->sc_fifo_cache = cache - n;
452 1.1 petrov }
453 1.1 petrov
454 1.1 petrov void
455 1.10 martin ffb_ras_wait(struct ffb_softc *sc)
456 1.1 petrov {
457 1.22 cdi uint32_t ucsr, r;
458 1.1 petrov
459 1.1 petrov while (1) {
460 1.1 petrov ucsr = FBC_READ(sc, FFB_FBC_UCSR);
461 1.1 petrov if ((ucsr & (FBC_UCSR_FB_BUSY|FBC_UCSR_RP_BUSY)) == 0)
462 1.1 petrov break;
463 1.1 petrov r = ucsr & (FBC_UCSR_READ_ERR | FBC_UCSR_FIFO_OVFL);
464 1.1 petrov if (r != 0)
465 1.1 petrov FBC_WRITE(sc, FFB_FBC_UCSR, r);
466 1.1 petrov }
467 1.1 petrov }
468 1.1 petrov
469 1.1 petrov void
470 1.10 martin ffb_ras_init(struct ffb_softc *sc)
471 1.1 petrov {
472 1.1 petrov ffb_ras_fifo_wait(sc, 7);
473 1.1 petrov FBC_WRITE(sc, FFB_FBC_PPC,
474 1.1 petrov FBC_PPC_VCE_DIS | FBC_PPC_TBE_OPAQUE |
475 1.1 petrov FBC_PPC_APE_DIS | FBC_PPC_CS_CONST);
476 1.1 petrov FBC_WRITE(sc, FFB_FBC_FBC,
477 1.1 petrov FFB_FBC_WB_A | FFB_FBC_RB_A | FFB_FBC_SB_BOTH |
478 1.1 petrov FFB_FBC_XE_OFF | FFB_FBC_RGBE_MASK);
479 1.1 petrov FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_NEW);
480 1.1 petrov FBC_WRITE(sc, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
481 1.1 petrov FBC_WRITE(sc, FFB_FBC_PMASK, 0xffffffff);
482 1.1 petrov FBC_WRITE(sc, FFB_FBC_FONTINC, 0x10000);
483 1.1 petrov sc->sc_fg_cache = 0;
484 1.1 petrov FBC_WRITE(sc, FFB_FBC_FG, sc->sc_fg_cache);
485 1.1 petrov ffb_ras_wait(sc);
486 1.1 petrov }
487 1.1 petrov
488 1.1 petrov void
489 1.10 martin ffb_ras_eraserows(void *cookie, int row, int n, long attr)
490 1.1 petrov {
491 1.1 petrov struct rasops_info *ri = cookie;
492 1.30 martin struct vcons_screen *scr = ri->ri_hw;
493 1.30 martin struct ffb_softc *sc = scr->scr_cookie;
494 1.1 petrov
495 1.30 martin if (row < 0) {
496 1.30 martin n += row;
497 1.30 martin row = 0;
498 1.30 martin }
499 1.30 martin if (row + n > ri->ri_rows)
500 1.30 martin n = ri->ri_rows - row;
501 1.30 martin if (n <= 0)
502 1.30 martin return;
503 1.16 macallan
504 1.30 martin ffb_ras_fill(sc);
505 1.30 martin ffb_ras_setfg(sc, ri->ri_devcmap[(attr >> 16) & 0xf]);
506 1.30 martin ffb_ras_fifo_wait(sc, 4);
507 1.30 martin if ((n == ri->ri_rows) && (ri->ri_flg & RI_FULLCLEAR)) {
508 1.30 martin FBC_WRITE(sc, FFB_FBC_BY, 0);
509 1.30 martin FBC_WRITE(sc, FFB_FBC_BX, 0);
510 1.30 martin FBC_WRITE(sc, FFB_FBC_BH, ri->ri_height);
511 1.30 martin FBC_WRITE(sc, FFB_FBC_BW, ri->ri_width);
512 1.30 martin } else {
513 1.30 martin row *= ri->ri_font->fontheight;
514 1.30 martin FBC_WRITE(sc, FFB_FBC_BY, ri->ri_yorigin + row);
515 1.30 martin FBC_WRITE(sc, FFB_FBC_BX, ri->ri_xorigin);
516 1.30 martin FBC_WRITE(sc, FFB_FBC_BH, n * ri->ri_font->fontheight);
517 1.30 martin FBC_WRITE(sc, FFB_FBC_BW, ri->ri_emuwidth);
518 1.1 petrov }
519 1.30 martin ffb_ras_wait(sc);
520 1.1 petrov }
521 1.1 petrov
522 1.1 petrov void
523 1.10 martin ffb_ras_erasecols(void *cookie, int row, int col, int n, long attr)
524 1.1 petrov {
525 1.1 petrov struct rasops_info *ri = cookie;
526 1.30 martin struct vcons_screen *scr = ri->ri_hw;
527 1.30 martin struct ffb_softc *sc = scr->scr_cookie;
528 1.30 martin
529 1.30 martin if ((row < 0) || (row >= ri->ri_rows))
530 1.30 martin return;
531 1.30 martin if (col < 0) {
532 1.30 martin n += col;
533 1.30 martin col = 0;
534 1.30 martin }
535 1.30 martin if (col + n > ri->ri_cols)
536 1.30 martin n = ri->ri_cols - col;
537 1.30 martin if (n <= 0)
538 1.30 martin return;
539 1.30 martin n *= ri->ri_font->fontwidth;
540 1.30 martin col *= ri->ri_font->fontwidth;
541 1.30 martin row *= ri->ri_font->fontheight;
542 1.1 petrov
543 1.30 martin ffb_ras_fill(sc);
544 1.30 martin ffb_ras_setfg(sc, ri->ri_devcmap[(attr >> 16) & 0xf]);
545 1.30 martin ffb_ras_fifo_wait(sc, 4);
546 1.30 martin FBC_WRITE(sc, FFB_FBC_BY, ri->ri_yorigin + row);
547 1.30 martin FBC_WRITE(sc, FFB_FBC_BX, ri->ri_xorigin + col);
548 1.30 martin FBC_WRITE(sc, FFB_FBC_BH, ri->ri_font->fontheight);
549 1.30 martin FBC_WRITE(sc, FFB_FBC_BW, n - 1);
550 1.30 martin ffb_ras_wait(sc);
551 1.1 petrov }
552 1.1 petrov
553 1.1 petrov void
554 1.10 martin ffb_ras_fill(struct ffb_softc *sc)
555 1.1 petrov {
556 1.1 petrov ffb_ras_fifo_wait(sc, 2);
557 1.1 petrov FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_NEW);
558 1.1 petrov FBC_WRITE(sc, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
559 1.1 petrov ffb_ras_wait(sc);
560 1.1 petrov }
561 1.1 petrov
562 1.1 petrov void
563 1.10 martin ffb_ras_copyrows(void *cookie, int src, int dst, int n)
564 1.1 petrov {
565 1.1 petrov struct rasops_info *ri = cookie;
566 1.30 martin struct vcons_screen *scr = ri->ri_hw;
567 1.30 martin struct ffb_softc *sc = scr->scr_cookie;
568 1.1 petrov
569 1.30 martin if (dst == src)
570 1.30 martin return;
571 1.30 martin if (src < 0) {
572 1.30 martin n += src;
573 1.30 martin src = 0;
574 1.30 martin }
575 1.30 martin if ((src + n) > ri->ri_rows)
576 1.30 martin n = ri->ri_rows - src;
577 1.30 martin if (dst < 0) {
578 1.30 martin n += dst;
579 1.30 martin dst = 0;
580 1.30 martin }
581 1.30 martin if ((dst + n) > ri->ri_rows)
582 1.30 martin n = ri->ri_rows - dst;
583 1.30 martin if (n <= 0)
584 1.30 martin return;
585 1.30 martin n *= ri->ri_font->fontheight;
586 1.30 martin src *= ri->ri_font->fontheight;
587 1.30 martin dst *= ri->ri_font->fontheight;
588 1.30 martin
589 1.30 martin ffb_ras_fifo_wait(sc, 8);
590 1.30 martin FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_OLD | (FBC_ROP_OLD << 8));
591 1.30 martin FBC_WRITE(sc, FFB_FBC_DRAWOP, FBC_DRAWOP_VSCROLL);
592 1.30 martin FBC_WRITE(sc, FFB_FBC_BY, ri->ri_yorigin + src);
593 1.30 martin FBC_WRITE(sc, FFB_FBC_BX, ri->ri_xorigin);
594 1.30 martin FBC_WRITE(sc, FFB_FBC_DY, ri->ri_yorigin + dst);
595 1.30 martin FBC_WRITE(sc, FFB_FBC_DX, ri->ri_xorigin);
596 1.30 martin FBC_WRITE(sc, FFB_FBC_BH, n);
597 1.30 martin FBC_WRITE(sc, FFB_FBC_BW, ri->ri_emuwidth);
598 1.30 martin ffb_ras_wait(sc);
599 1.1 petrov }
600 1.1 petrov
601 1.1 petrov void
602 1.10 martin ffb_ras_setfg(struct ffb_softc *sc, int32_t fg)
603 1.1 petrov {
604 1.1 petrov ffb_ras_fifo_wait(sc, 1);
605 1.1 petrov if (fg == sc->sc_fg_cache)
606 1.1 petrov return;
607 1.1 petrov sc->sc_fg_cache = fg;
608 1.1 petrov FBC_WRITE(sc, FFB_FBC_FG, fg);
609 1.1 petrov ffb_ras_wait(sc);
610 1.1 petrov }
611 1.11 martin
612 1.11 martin /* frame buffer generic driver support functions */
613 1.11 martin static void
614 1.11 martin ffbfb_unblank(struct device *dev)
615 1.11 martin {
616 1.35 martin struct ffb_softc *sc = device_private(dev);
617 1.30 martin struct vcons_screen *ms = sc->vd.active;
618 1.29 martin u_int on = 1;
619 1.30 martin int redraw = 0;
620 1.30 martin
621 1.30 martin ffb_ras_init(sc);
622 1.30 martin if (sc->sc_locked) {
623 1.30 martin sc->sc_locked = 0;
624 1.30 martin redraw = 1;
625 1.30 martin }
626 1.30 martin
627 1.36 macallan ffb_blank(sc, WSDISPLAYIO_SVIDEO, &on);
628 1.36 macallan #if 0
629 1.30 martin if ((sc->vd.active != &ffb_console_screen) &&
630 1.30 martin (ffb_console_screen.scr_flags & VCONS_SCREEN_IS_STATIC)) {
631 1.30 martin /*
632 1.30 martin * force-switch to the console screen.
633 1.30 martin * Caveat: the higher layer will think we're still on the
634 1.30 martin * other screen
635 1.30 martin */
636 1.30 martin
637 1.30 martin SCREEN_INVISIBLE(sc->vd.active);
638 1.30 martin sc->vd.active = &ffb_console_screen;
639 1.30 martin SCREEN_VISIBLE(sc->vd.active);
640 1.30 martin ms = sc->vd.active;
641 1.30 martin redraw = 1;
642 1.30 martin }
643 1.36 macallan #endif
644 1.30 martin if (redraw) {
645 1.30 martin vcons_redraw_screen(ms);
646 1.30 martin }
647 1.11 martin }
648 1.11 martin
649 1.11 martin int
650 1.21 christos ffbfb_open(dev_t dev, int flags, int mode, struct lwp *l)
651 1.11 martin {
652 1.30 martin struct ffb_softc *sc;
653 1.11 martin
654 1.34 cegger sc = device_lookup_private(&ffb_cd, minor(dev));
655 1.34 cegger if (sc == NULL)
656 1.11 martin return ENXIO;
657 1.30 martin
658 1.30 martin sc->sc_locked = 1;
659 1.11 martin return 0;
660 1.11 martin }
661 1.11 martin
662 1.11 martin int
663 1.21 christos ffbfb_close(dev_t dev, int flags, int mode, struct lwp *l)
664 1.11 martin {
665 1.34 cegger struct ffb_softc *sc = device_lookup_private(&ffb_cd, minor(dev));
666 1.30 martin struct vcons_screen *ms = sc->vd.active;
667 1.30 martin
668 1.30 martin sc->sc_locked = 0;
669 1.30 martin if (ms != NULL) {
670 1.30 martin if ((sc->sc_mode == WSDISPLAYIO_MODE_EMUL) &&
671 1.30 martin (sc->sc_locked == 0)) {
672 1.30 martin ffb_ras_init(sc);
673 1.30 martin vcons_redraw_screen(ms);
674 1.30 martin }
675 1.30 martin }
676 1.11 martin return 0;
677 1.11 martin }
678 1.11 martin
679 1.11 martin int
680 1.32 christos ffbfb_ioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
681 1.11 martin {
682 1.34 cegger struct ffb_softc *sc = device_lookup_private(&ffb_cd, minor(dev));
683 1.11 martin
684 1.30 martin return ffb_ioctl(&sc->vd, NULL, cmd, data, flags, l);
685 1.11 martin }
686 1.11 martin
687 1.11 martin paddr_t
688 1.11 martin ffbfb_mmap(dev_t dev, off_t off, int prot)
689 1.11 martin {
690 1.34 cegger struct ffb_softc *sc = device_lookup_private(&ffb_cd, minor(dev));
691 1.14 macallan uint64_t size;
692 1.11 martin int i, reg;
693 1.11 martin off_t o;
694 1.11 martin
695 1.11 martin /*
696 1.11 martin * off is a magic cookie (see xfree86/drivers/sunffb/ffb.h),
697 1.11 martin * which we map to an index into the "reg" property, and use
698 1.11 martin * our copy of the firmware data as arguments for the real
699 1.11 martin * mapping.
700 1.11 martin */
701 1.11 martin static struct { unsigned long voff; int reg; } map[] = {
702 1.11 martin { 0x00000000, FFB_REG_SFB8R },
703 1.11 martin { 0x00400000, FFB_REG_SFB8G },
704 1.11 martin { 0x00800000, FFB_REG_SFB8B },
705 1.11 martin { 0x00c00000, FFB_REG_SFB8X },
706 1.11 martin { 0x01000000, FFB_REG_SFB32 },
707 1.11 martin { 0x02000000, FFB_REG_SFB64 },
708 1.11 martin { 0x04000000, FFB_REG_FBC },
709 1.11 martin { 0x04004000, FFB_REG_DFB8R },
710 1.11 martin { 0x04404000, FFB_REG_DFB8G },
711 1.11 martin { 0x04804000, FFB_REG_DFB8B },
712 1.11 martin { 0x04c04000, FFB_REG_DFB8X },
713 1.11 martin { 0x05004000, FFB_REG_DFB24 },
714 1.11 martin { 0x06004000, FFB_REG_DFB32 },
715 1.11 martin { 0x07004000, FFB_REG_DFB422A },
716 1.11 martin { 0x0bc06000, FFB_REG_DAC },
717 1.11 martin { 0x0bc08000, FFB_REG_PROM },
718 1.14 macallan { 0x0bc18000, 0 }
719 1.11 martin };
720 1.11 martin
721 1.11 martin /* special value "FFB_EXP_VOFF" - not backed by any "reg" entry */
722 1.11 martin if (off == 0x0bc18000)
723 1.11 martin return bus_space_mmap(sc->sc_bt, sc->sc_addrs[FFB_REG_PROM],
724 1.11 martin 0x00200000, prot, BUS_SPACE_MAP_LINEAR);
725 1.14 macallan
726 1.14 macallan /*
727 1.14 macallan * FFB_VOFF_FBC_KREGS - used by afbinit to upload firmware. We should
728 1.14 macallan * probably mmap them only on afb boards
729 1.14 macallan */
730 1.14 macallan if ((off >= 0x0bc04000) && (off < 0x0bc06000))
731 1.14 macallan return bus_space_mmap(sc->sc_bt, sc->sc_addrs[FFB_REG_PROM],
732 1.14 macallan 0x00610000 + (off - 0x0bc04000), prot,
733 1.14 macallan BUS_SPACE_MAP_LINEAR);
734 1.14 macallan
735 1.11 martin #define NELEMS(arr) (sizeof(arr)/sizeof((arr)[0]))
736 1.11 martin
737 1.11 martin /* the map is ordered by voff */
738 1.14 macallan for (i = 0; i < NELEMS(map)-1; i++) {
739 1.11 martin reg = map[i].reg;
740 1.16 macallan /* the number of entries in reg seems to vary */
741 1.14 macallan if (reg < sc->sc_nreg) {
742 1.14 macallan size = min((map[i + 1].voff - map[i].voff),
743 1.14 macallan sc->sc_sizes[reg]);
744 1.14 macallan if ((off >= map[i].voff) &&
745 1.14 macallan (off < (map[i].voff + size))) {
746 1.14 macallan o = off - map[i].voff;
747 1.14 macallan return bus_space_mmap(sc->sc_bt,
748 1.14 macallan sc->sc_addrs[reg], o, prot,
749 1.14 macallan BUS_SPACE_MAP_LINEAR);
750 1.14 macallan }
751 1.14 macallan }
752 1.11 martin }
753 1.11 martin
754 1.11 martin return -1;
755 1.11 martin }
756 1.16 macallan
757 1.16 macallan void
758 1.16 macallan ffb_clearscreen(struct ffb_softc *sc)
759 1.16 macallan {
760 1.30 martin struct rasops_info *ri = &ffb_console_screen.scr_ri;
761 1.16 macallan ffb_ras_fill(sc);
762 1.16 macallan ffb_ras_setfg(sc, ri->ri_devcmap[WS_DEFAULT_BG]);
763 1.16 macallan ffb_ras_fifo_wait(sc, 4);
764 1.16 macallan FBC_WRITE(sc, FFB_FBC_BY, 0);
765 1.16 macallan FBC_WRITE(sc, FFB_FBC_BX, 0);
766 1.30 martin FBC_WRITE(sc, FFB_FBC_BH, sc->sc_height);
767 1.30 martin FBC_WRITE(sc, FFB_FBC_BW, sc->sc_width);
768 1.16 macallan }
769 1.16 macallan
770 1.16 macallan void
771 1.16 macallan ffb_cursor(void *cookie, int on, int row, int col)
772 1.16 macallan {
773 1.16 macallan struct rasops_info *ri = cookie;
774 1.30 martin struct vcons_screen *scr;
775 1.30 martin struct ffb_softc *sc;
776 1.16 macallan int x, y, wi, he, coffset;
777 1.16 macallan
778 1.30 martin if (cookie != NULL) {
779 1.30 martin scr = ri->ri_hw;
780 1.30 martin sc = scr->scr_cookie;
781 1.30 martin
782 1.30 martin wi = ri->ri_font->fontwidth;
783 1.30 martin he = ri->ri_font->fontheight;
784 1.30 martin
785 1.30 martin if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
786 1.30 martin x = ri->ri_ccol * wi + ri->ri_xorigin;
787 1.30 martin y = ri->ri_crow * he + ri->ri_yorigin;
788 1.30 martin
789 1.30 martin if (ri->ri_flg & RI_CURSOR) {
790 1.30 martin /* remove cursor */
791 1.30 martin coffset = ri->ri_ccol + (ri->ri_crow *
792 1.30 martin ri->ri_cols);
793 1.36 macallan #ifdef WSDISPLAY_SCROLLSUPPORT
794 1.36 macallan coffset += scr->scr_offset_to_zero;
795 1.36 macallan #endif
796 1.30 martin ffb_ras_wait(sc);
797 1.30 martin sc->putchar(cookie, ri->ri_crow,
798 1.30 martin ri->ri_ccol, scr->scr_chars[coffset],
799 1.30 martin scr->scr_attrs[coffset]);
800 1.30 martin ri->ri_flg &= ~RI_CURSOR;
801 1.30 martin }
802 1.30 martin ri->ri_crow = row;
803 1.30 martin ri->ri_ccol = col;
804 1.30 martin if (on)
805 1.30 martin {
806 1.30 martin long attr, revattr;
807 1.30 martin x = ri->ri_ccol * wi + ri->ri_xorigin;
808 1.30 martin y = ri->ri_crow * he + ri->ri_yorigin;
809 1.30 martin coffset = col + (row * ri->ri_cols);
810 1.36 macallan #ifdef WSDISPLAY_SCROLLSUPPORT
811 1.36 macallan coffset += scr->scr_offset_to_zero;
812 1.36 macallan #endif
813 1.30 martin attr = scr->scr_attrs[coffset];
814 1.16 macallan #ifdef FFB_CURSOR_SWAP_COLOURS
815 1.30 martin revattr=((attr >> 8 ) & 0x000f0000) | ((attr &
816 1.30 martin 0x000f0000)<<8) | (attr & 0x0000ffff);
817 1.16 macallan #else
818 1.30 martin revattr = attr ^ 0xffff0000;
819 1.16 macallan #endif
820 1.30 martin ffb_ras_wait(sc);
821 1.30 martin sc->putchar(cookie, ri->ri_crow, ri->ri_ccol,
822 1.30 martin scr->scr_chars[coffset], revattr);
823 1.30 martin ri->ri_flg |= RI_CURSOR;
824 1.30 martin }
825 1.30 martin } else {
826 1.30 martin ri->ri_crow = row;
827 1.30 martin ri->ri_ccol = col;
828 1.30 martin ri->ri_flg &= ~RI_CURSOR;
829 1.16 macallan }
830 1.16 macallan }
831 1.16 macallan }
832 1.16 macallan
833 1.16 macallan void
834 1.16 macallan ffb_putchar(void *cookie, int row, int col, u_int c, long attr)
835 1.16 macallan {
836 1.16 macallan struct rasops_info *ri = cookie;
837 1.30 martin struct vcons_screen *scr = ri->ri_hw;
838 1.30 martin struct ffb_softc *sc = scr->scr_cookie;
839 1.16 macallan
840 1.30 martin if (sc->putchar != NULL) {
841 1.30 martin /*
842 1.30 martin * the only reason why we need to hook putchar - wait for
843 1.30 martin * the drawing engine to be idle so we don't interfere
844 1.30 martin * ( and we should really use the colour expansion hardware )
845 1.30 martin */
846 1.30 martin ffb_ras_wait(sc);
847 1.30 martin sc->putchar(cookie, row, col, c, attr);
848 1.16 macallan }
849 1.16 macallan }
850 1.16 macallan
851 1.16 macallan int
852 1.16 macallan ffb_allocattr(void *cookie, int fg, int bg, int flags, long *attrp)
853 1.16 macallan {
854 1.16 macallan if ((fg == 0) && (bg == 0))
855 1.16 macallan {
856 1.16 macallan fg = WS_DEFAULT_FG;
857 1.16 macallan bg = WS_DEFAULT_BG;
858 1.16 macallan }
859 1.16 macallan if (flags & WSATTR_REVERSE) {
860 1.16 macallan *attrp = (bg & 0xff) << 24 | (fg & 0xff) << 16 |
861 1.16 macallan (flags & 0xff);
862 1.16 macallan } else
863 1.16 macallan *attrp = (fg & 0xff) << 24 | (bg & 0xff) << 16 |
864 1.16 macallan (flags & 0xff);
865 1.16 macallan return 0;
866 1.16 macallan }
867 1.16 macallan
868 1.16 macallan void
869 1.30 martin ffb_init_screen(void *cookie, struct vcons_screen *scr,
870 1.16 macallan int existing, long *defattr)
871 1.16 macallan {
872 1.30 martin struct ffb_softc *sc = cookie;
873 1.30 martin struct rasops_info *ri = &scr->scr_ri;
874 1.16 macallan
875 1.16 macallan ri->ri_depth = 32;
876 1.16 macallan ri->ri_width = sc->sc_width;
877 1.16 macallan ri->ri_height = sc->sc_height;
878 1.16 macallan ri->ri_stride = sc->sc_linebytes;
879 1.16 macallan ri->ri_flg = RI_CENTER;
880 1.16 macallan
881 1.16 macallan ri->ri_bits = bus_space_vaddr(sc->sc_bt, sc->sc_pixel_h);
882 1.16 macallan
883 1.30 martin #ifdef FFBDEBUG
884 1.16 macallan printf("addr: %08lx\n",(ulong)ri->ri_bits);
885 1.16 macallan #endif
886 1.16 macallan rasops_init(ri, sc->sc_height/8, sc->sc_width/8);
887 1.16 macallan ri->ri_caps = WSSCREEN_WSCOLORS;
888 1.16 macallan rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
889 1.16 macallan sc->sc_width / ri->ri_font->fontwidth);
890 1.16 macallan
891 1.16 macallan /* enable acceleration */
892 1.16 macallan ri->ri_ops.copyrows = ffb_ras_copyrows;
893 1.16 macallan ri->ri_ops.eraserows = ffb_ras_eraserows;
894 1.16 macallan ri->ri_ops.erasecols = ffb_ras_erasecols;
895 1.16 macallan ri->ri_ops.cursor = ffb_cursor;
896 1.16 macallan ri->ri_ops.allocattr = ffb_allocattr;
897 1.16 macallan if (sc->putchar == NULL)
898 1.16 macallan sc->putchar = ri->ri_ops.putchar;
899 1.16 macallan ri->ri_ops.putchar = ffb_putchar;
900 1.16 macallan }
901