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