zx.c revision 1.24.4.1 1 /* $NetBSD: zx.c,v 1.24.4.1 2009/04/28 07:36:32 skrll Exp $ */
2
3 /*
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * Driver for the Sun ZX display adapter. This would be called 'leo', but
34 * NetBSD/amiga already has a driver by that name. The XFree86 and Linux
35 * drivers were used as "living documentation" when writing this; thanks
36 * to the authors.
37 *
38 * Issues (which can be solved with wscons, happily enough):
39 *
40 * o There is lots of unnecessary mucking about rasops in here, primarily
41 * to appease the sparc fb code.
42 *
43 * o RASTERCONSOLE is required. X needs the board set up correctly, and
44 * that's difficult to reconcile with using the PROM for output.
45 */
46
47 #include <sys/cdefs.h>
48 __KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.24.4.1 2009/04/28 07:36:32 skrll Exp $");
49
50 #include <sys/param.h>
51 #include <sys/systm.h>
52 #include <sys/device.h>
53 #include <sys/ioctl.h>
54 #include <sys/malloc.h>
55 #include <sys/mman.h>
56 #include <sys/tty.h>
57 #include <sys/conf.h>
58 #include <sys/syslog.h>
59 #include <sys/buf.h>
60
61 #include <sys/bus.h>
62 #include <machine/autoconf.h>
63
64 #include <uvm/uvm_extern.h>
65
66 #include <dev/sun/fbio.h>
67 #include <dev/sun/fbvar.h>
68
69 #include "wsdisplay.h"
70 #if NWSDISPLAY > 0
71 #include <dev/wscons/wsconsio.h>
72 #include <dev/wsfont/wsfont.h>
73 #include <dev/rasops/rasops.h>
74 #include <dev/wscons/wsdisplay_vconsvar.h>
75
76 #include "opt_wsemul.h"
77 #endif
78
79 #include <dev/sbus/zxreg.h>
80 #include <dev/sbus/zxvar.h>
81 #include <dev/sbus/sbusvar.h>
82
83 #include <dev/wscons/wsconsio.h>
84
85 #if (NWSDISPLAY == 0) && !defined(RASTERCONSOLE)
86 #error Sorry, this driver needs WSCONS or RASTERCONSOLE
87 #endif
88
89 #if (NWSDISPLAY > 0) && defined(RASTERCONSOLE)
90 #error Sorry, RASTERCONSOLE and WSCONS are mutually exclusive
91 #endif
92
93 #define ZX_STD_ROP (ZX_ROP_NEW | ZX_ATTR_WE_ENABLE | \
94 ZX_ATTR_OE_ENABLE | ZX_ATTR_FORCE_WID)
95
96 static void zx_attach(device_t, device_t, void *);
97 static int zx_match(device_t, struct cfdata *, void *);
98
99 static void zx_blank(device_t);
100 static int zx_cmap_put(struct zx_softc *);
101 static void zx_copyrect(struct zx_softc *, int, int, int, int, int, int);
102 static int zx_cross_loadwid(struct zx_softc *, u_int, u_int, u_int);
103 static int zx_cross_wait(struct zx_softc *);
104 static void zx_fillrect(struct zx_softc *, int, int, int, int, uint32_t, int);
105 static int zx_intr(void *);
106 static void zx_reset(struct zx_softc *);
107 static void zx_unblank(device_t);
108
109 static void zx_cursor_blank(struct zx_softc *);
110 static void zx_cursor_color(struct zx_softc *);
111 static void zx_cursor_move(struct zx_softc *);
112 static void zx_cursor_set(struct zx_softc *);
113 static void zx_cursor_unblank(struct zx_softc *);
114
115 static void zx_copycols(void *, int, int, int, int);
116 static void zx_copyrows(void *, int, int, int);
117 static void zx_do_cursor(void *, int, int, int);
118 static void zx_erasecols(void *, int, int, int, long);
119 static void zx_eraserows(void *, int, int, long);
120 static void zx_putchar(void *, int, int, u_int, long);
121
122 struct zx_mmo {
123 off_t mo_va;
124 off_t mo_pa;
125 off_t mo_size;
126 } static const zx_mmo[] = {
127 { ZX_FB0_VOFF, ZX_OFF_SS0, 0x00800000 },
128 { ZX_LC0_VOFF, ZX_OFF_LC_SS0_USR, 0x00001000 },
129 { ZX_LD0_VOFF, ZX_OFF_LD_SS0, 0x00001000 },
130 { ZX_LX0_CURSOR_VOFF, ZX_OFF_LX_CURSOR, 0x00001000 },
131 { ZX_FB1_VOFF, ZX_OFF_SS1, 0x00800000 },
132 { ZX_LC1_VOFF, ZX_OFF_LC_SS1_USR, 0x00001000 },
133 { ZX_LD1_VOFF, ZX_OFF_LD_SS1, 0x00001000 },
134 { ZX_LX_KRN_VOFF, ZX_OFF_LX_CROSS, 0x00001000 },
135 { ZX_LC0_KRN_VOFF, ZX_OFF_LC_SS0_KRN, 0x00001000 },
136 { ZX_LC1_KRN_VOFF, ZX_OFF_LC_SS1_KRN, 0x00001000 },
137 { ZX_LD_GBL_VOFF, ZX_OFF_LD_GBL, 0x00001000 },
138 };
139
140 CFATTACH_DECL_NEW(zx, sizeof(struct zx_softc),
141 zx_match, zx_attach, NULL, NULL);
142
143 extern struct cfdriver zx_cd;
144
145 static dev_type_open(zxopen);
146 static dev_type_close(zxclose);
147 static dev_type_ioctl(zxioctl);
148 static dev_type_mmap(zxmmap);
149
150 static struct fbdriver zx_fbdriver = {
151 zx_unblank, zxopen, zxclose, zxioctl, nopoll, zxmmap
152 };
153
154 #if NWSDISPLAY > 0
155 struct wsscreen_descr zx_defaultscreen = {
156 "std",
157 0, 0, /* will be filled in -- XXX shouldn't, it's global */
158 /* doesn't matter - you can't really have more than one leo */
159 NULL, /* textops */
160 8, 16, /* font width/height */
161 WSSCREEN_WSCOLORS, /* capabilities */
162 NULL /* modecookie */
163 };
164
165 static int zx_ioctl(void *, void *, u_long, void *, int, struct lwp *);
166 static paddr_t zx_mmap(void *, void *, off_t, int);
167 static void zx_init_screen(void *, struct vcons_screen *, int, long *);
168
169 static int zx_putcmap(struct zx_softc *, struct wsdisplay_cmap *);
170 static int zx_getcmap(struct zx_softc *, struct wsdisplay_cmap *);
171
172 struct wsdisplay_accessops zx_accessops = {
173 zx_ioctl,
174 zx_mmap,
175 NULL, /* alloc_screen */
176 NULL, /* free_screen */
177 NULL, /* show_screen */
178 NULL, /* load_font */
179 NULL, /* pollc */
180 NULL /* scroll */
181 };
182
183 const struct wsscreen_descr *_zx_scrlist[] = {
184 &zx_defaultscreen
185 };
186
187 struct wsscreen_list zx_screenlist = {
188 sizeof(_zx_scrlist) / sizeof(struct wsscreen_descr *),
189 _zx_scrlist
190 };
191
192
193 extern const u_char rasops_cmap[768];
194
195 static struct vcons_screen zx_console_screen;
196 #endif /* NWSDISPLAY > 0 */
197
198 static int
199 zx_match(device_t parent, struct cfdata *cf, void *aux)
200 {
201 struct sbus_attach_args *sa;
202
203 sa = (struct sbus_attach_args *)aux;
204
205 return (strcmp(sa->sa_name, "SUNW,leo") == 0);
206 }
207
208 static void
209 zx_attach(device_t parent, device_t self, void *args)
210 {
211 struct zx_softc *sc;
212 struct sbus_attach_args *sa;
213 bus_space_handle_t bh;
214 bus_space_tag_t bt;
215 struct fbdevice *fb;
216 #if NWSDISPLAY > 0
217 struct wsemuldisplaydev_attach_args aa;
218 struct rasops_info *ri = &zx_console_screen.scr_ri;
219 unsigned long defattr;
220 #endif
221 int isconsole;
222
223 sc = device_private(self);
224 sc->sc_dv = self;
225
226 sa = args;
227 fb = &sc->sc_fb;
228 bt = sa->sa_bustag;
229 sc->sc_bt = bt;
230 sc->sc_paddr = sbus_bus_addr(bt, sa->sa_slot, sa->sa_offset);
231
232 if (sparc_bus_map_large(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_SS0,
233 0x800000, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
234 aprint_error_dev(self, "can't map bits\n");
235 return;
236 }
237 fb->fb_pixels = (void *)bus_space_vaddr(bt, bh);
238 sc->sc_pixels = (u_int32_t *)fb->fb_pixels;
239
240 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LC_SS0_USR,
241 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
242 aprint_error_dev(self, "can't map zc\n");
243 return;
244 }
245
246 sc->sc_bhzc = bh;
247
248 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS0,
249 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
250 aprint_error_dev(self, "can't map ld/ss0\n");
251 return;
252 }
253 sc->sc_bhzdss0 = bh;
254
255 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS1,
256 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
257 aprint_error_dev(self, "can't map ld/ss1\n");
258 return;
259 }
260 sc->sc_bhzdss1 = bh;
261
262 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CROSS,
263 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
264 aprint_error_dev(self, "can't map zx\n");
265 return;
266 }
267 sc->sc_bhzx = bh;
268
269 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CURSOR,
270 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
271 aprint_error_dev(self, "can't map zcu\n");
272 return;
273 }
274 sc->sc_bhzcu = bh;
275
276 fb->fb_driver = &zx_fbdriver;
277 fb->fb_device = sc->sc_dv;
278 fb->fb_flags = device_cfdata(sc->sc_dv)->cf_flags & FB_USERMASK;
279 fb->fb_pfour = NULL;
280 fb->fb_linebytes = prom_getpropint(sa->sa_node, "linebytes", 8192);
281
282 width = prom_getpropint(sa->sa_node, "width", 1280);
283 height = prom_getpropint(sa->sa_node, "height", 1024);
284 fb_setsize_obp(fb, 32, width, height, sa->sa_node);
285
286 fb->fb_type.fb_cmsize = 256;
287 fb->fb_type.fb_depth = 32;
288 fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
289 fb->fb_type.fb_type = FBTYPE_SUNLEO;
290
291 printf(": %d x %d", fb->fb_type.fb_width, fb->fb_type.fb_height);
292 isconsole = fb_is_console(sa->sa_node);
293 if (isconsole)
294 printf(" (console)");
295 printf("\n");
296
297 sbus_establish(&sc->sc_sd, sc->sc_dv);
298 if (sa->sa_nintr != 0)
299 bus_intr_establish(bt, sa->sa_pri, IPL_NONE, zx_intr, sc);
300
301 sc->sc_cmap = malloc(768, M_DEVBUF, M_NOWAIT);
302 zx_reset(sc);
303
304 #if NWSDISPLAY > 0
305 sc->sc_width = fb->fb_type.fb_width;
306 sc->sc_stride = 8192; /* 32 bit */
307 sc->sc_height = fb->fb_type.fb_height;
308
309 /* setup rasops and so on for wsdisplay */
310 wsfont_init();
311 sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
312 sc->sc_bg = WS_DEFAULT_BG;
313
314 vcons_init(&sc->vd, sc, &zx_defaultscreen, &zx_accessops);
315 sc->vd.init_screen = zx_init_screen;
316
317 if (isconsole) {
318 /* we mess with zx_console_screen only once */
319 vcons_init_screen(&sc->vd, &zx_console_screen, 1,
320 &defattr);
321 zx_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
322
323 zx_defaultscreen.textops = &ri->ri_ops;
324 zx_defaultscreen.capabilities = WSSCREEN_WSCOLORS;
325 zx_defaultscreen.nrows = ri->ri_rows;
326 zx_defaultscreen.ncols = ri->ri_cols;
327 wsdisplay_cnattach(&zx_defaultscreen, ri, 0, 0, defattr);
328 } else {
329 /*
330 * we're not the console so we just clear the screen and don't
331 * set up any sort of text display
332 */
333 if (zx_defaultscreen.textops == NULL) {
334 /*
335 * ugly, but...
336 * we want the console settings to win, so we only
337 * touch anything when we find an untouched screen
338 * definition. In this case we fill it from fb to
339 * avoid problems in case no zx is the console
340 */
341 ri = &sc->sc_fb.fb_rinfo;
342 zx_defaultscreen.textops = &ri->ri_ops;
343 zx_defaultscreen.capabilities = ri->ri_caps;
344 zx_defaultscreen.nrows = ri->ri_rows;
345 zx_defaultscreen.ncols = ri->ri_cols;
346 }
347 }
348
349 aa.scrdata = &zx_screenlist;
350 aa.console = isconsole;
351 aa.accessops = &zx_accessops;
352 aa.accesscookie = &sc->vd;
353 config_found(sc->sc_dv, &aa, wsemuldisplaydevprint);
354 #endif
355 fb_attach(&sc->sc_fb, isconsole);
356 }
357
358 static int
359 zxopen(dev_t dev, int flags, int mode, struct lwp *l)
360 {
361
362 if (device_lookup(&zx_cd, minor(dev)) == NULL)
363 return (ENXIO);
364 return (0);
365 }
366
367 static int
368 zxclose(dev_t dev, int flags, int mode, struct lwp *l)
369 {
370 struct zx_softc *sc;
371
372 sc = device_lookup_private(&zx_cd, minor(dev));
373
374 zx_reset(sc);
375 zx_cursor_blank(sc);
376 return (0);
377 }
378
379 static int
380 zxioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
381 {
382 struct zx_softc *sc;
383 struct fbcmap *cm;
384 struct fbcursor *cu;
385 uint32_t curbits[2][32];
386 int rv, v, count, i;
387
388 sc = device_lookup_private(&zx_cd, minor(dev));
389
390 switch (cmd) {
391 case FBIOGTYPE:
392 *(struct fbtype *)data = sc->sc_fb.fb_type;
393 break;
394
395 case FBIOGATTR:
396 #define fba ((struct fbgattr *)data)
397 fba->real_type = sc->sc_fb.fb_type.fb_type;
398 fba->owner = 0; /* XXX ??? */
399 fba->fbtype = sc->sc_fb.fb_type;
400 fba->sattr.flags = 0;
401 fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type;
402 fba->sattr.dev_specific[0] = -1;
403 fba->emu_types[0] = sc->sc_fb.fb_type.fb_type;
404 fba->emu_types[1] = -1;
405 fba->emu_types[2] = -1;
406 #undef fba
407 break;
408
409 case FBIOGVIDEO:
410 *(int *)data = ((sc->sc_flags & ZX_BLANKED) != 0);
411 break;
412
413 case FBIOSVIDEO:
414 if (*(int *)data)
415 zx_unblank(sc->sc_dv);
416 else
417 zx_blank(sc->sc_dv);
418 break;
419
420 case FBIOGETCMAP:
421 cm = (struct fbcmap *)data;
422 if (cm->index > 256 || cm->count > 256 - cm->index)
423 return (EINVAL);
424 rv = copyout(sc->sc_cmap + cm->index, cm->red, cm->count);
425 if (rv == 0)
426 rv = copyout(sc->sc_cmap + 256 + cm->index, cm->green,
427 cm->count);
428 if (rv == 0)
429 rv = copyout(sc->sc_cmap + 512 + cm->index, cm->blue,
430 cm->count);
431 return (rv);
432
433 case FBIOPUTCMAP:
434 cm = (struct fbcmap *)data;
435 if (cm->index > 256 || cm->count > 256 - cm->index)
436 return (EINVAL);
437 rv = copyin(cm->red, sc->sc_cmap + cm->index, cm->count);
438 if (rv == 0)
439 rv = copyin(cm->green, sc->sc_cmap + 256 + cm->index,
440 cm->count);
441 if (rv == 0)
442 rv = copyin(cm->blue, sc->sc_cmap + 512 + cm->index,
443 cm->count);
444 zx_cmap_put(sc);
445 return (rv);
446
447 case FBIOGCURPOS:
448 *(struct fbcurpos *)data = sc->sc_curpos;
449 break;
450
451 case FBIOSCURPOS:
452 sc->sc_curpos = *(struct fbcurpos *)data;
453 zx_cursor_move(sc);
454 break;
455
456 case FBIOGCURMAX:
457 ((struct fbcurpos *)data)->x = 32;
458 ((struct fbcurpos *)data)->y = 32;
459 break;
460
461 case FBIOSCURSOR:
462 cu = (struct fbcursor *)data;
463 v = cu->set;
464
465 if ((v & FB_CUR_SETSHAPE) != 0) {
466 if ((u_int)cu->size.x > 32 || (u_int)cu->size.y > 32)
467 return (EINVAL);
468 count = cu->size.y * 4;
469 rv = copyin(cu->mask, curbits[0], count);
470 if (rv)
471 return rv;
472 rv = copyin(cu->image, curbits[1], count);
473 if (rv)
474 return rv;
475 }
476 if ((v & FB_CUR_SETCUR) != 0) {
477 if (cu->enable)
478 zx_cursor_unblank(sc);
479 else
480 zx_cursor_blank(sc);
481 }
482 if ((v & (FB_CUR_SETPOS | FB_CUR_SETHOT)) != 0) {
483 if ((v & FB_CUR_SETPOS) != 0)
484 sc->sc_curpos = cu->pos;
485 if ((v & FB_CUR_SETHOT) != 0)
486 sc->sc_curhot = cu->hot;
487 zx_cursor_move(sc);
488 }
489 if ((v & FB_CUR_SETCMAP) != 0) {
490 if (cu->cmap.index > 2 ||
491 cu->cmap.count > 2 - cu->cmap.index)
492 return (EINVAL);
493 for (i = 0; i < cu->cmap.count; i++) {
494 if ((v = fubyte(&cu->cmap.red[i])) < 0)
495 return (EFAULT);
496 sc->sc_curcmap[i + cu->cmap.index + 0] = v;
497 if ((v = fubyte(&cu->cmap.green[i])) < 0)
498 return (EFAULT);
499 sc->sc_curcmap[i + cu->cmap.index + 2] = v;
500 if ((v = fubyte(&cu->cmap.blue[i])) < 0)
501 return (EFAULT);
502 sc->sc_curcmap[i + cu->cmap.index + 4] = v;
503 }
504 zx_cursor_color(sc);
505 }
506 if ((v & FB_CUR_SETSHAPE) != 0) {
507 sc->sc_cursize = cu->size;
508 count = cu->size.y * 4;
509 memset(sc->sc_curbits, 0, sizeof(sc->sc_curbits));
510 memcpy(sc->sc_curbits[0], curbits[0], count);
511 memcpy(sc->sc_curbits[1], curbits[1], count);
512 zx_cursor_set(sc);
513 }
514 break;
515
516 case FBIOGCURSOR:
517 cu = (struct fbcursor *)data;
518
519 cu->set = FB_CUR_SETALL;
520 cu->enable = ((sc->sc_flags & ZX_CURSOR) != 0);
521 cu->pos = sc->sc_curpos;
522 cu->hot = sc->sc_curhot;
523 cu->size = sc->sc_cursize;
524
525 if (cu->image != NULL) {
526 count = sc->sc_cursize.y * 4;
527 rv = copyout(sc->sc_curbits[1], cu->image, count);
528 if (rv)
529 return (rv);
530 rv = copyout(sc->sc_curbits[0], cu->mask, count);
531 if (rv)
532 return (rv);
533 }
534 if (cu->cmap.red != NULL) {
535 if (cu->cmap.index > 2 ||
536 cu->cmap.count > 2 - cu->cmap.index)
537 return (EINVAL);
538 for (i = 0; i < cu->cmap.count; i++) {
539 v = sc->sc_curcmap[i + cu->cmap.index + 0];
540 if (subyte(&cu->cmap.red[i], v))
541 return (EFAULT);
542 v = sc->sc_curcmap[i + cu->cmap.index + 2];
543 if (subyte(&cu->cmap.green[i], v))
544 return (EFAULT);
545 v = sc->sc_curcmap[i + cu->cmap.index + 4];
546 if (subyte(&cu->cmap.blue[i], v))
547 return (EFAULT);
548 }
549 } else {
550 cu->cmap.index = 0;
551 cu->cmap.count = 2;
552 }
553 break;
554
555 default:
556 #ifdef DEBUG
557 log(LOG_NOTICE, "zxioctl(0x%lx) (%s[%d])\n", cmd,
558 l->l_proc->p_comm, l->l_proc->p_pid);
559 #endif
560 return (ENOTTY);
561 }
562
563 return (0);
564 }
565
566 static int
567 zx_intr(void *cookie)
568 {
569
570 return (1);
571 }
572
573 static void
574 zx_reset(struct zx_softc *sc)
575 {
576 struct fbtype *fbt;
577 u_int i;
578
579 fbt = &sc->sc_fb.fb_type;
580
581 zx_cross_loadwid(sc, ZX_WID_DBL_8, 0, 0x2c0);
582 zx_cross_loadwid(sc, ZX_WID_DBL_8, 1, 0x30);
583 zx_cross_loadwid(sc, ZX_WID_DBL_8, 2, 0x20);
584 zx_cross_loadwid(sc, ZX_WID_DBL_24, 1, 0x30);
585
586 i = bus_space_read_4(sc->sc_bt, sc->sc_bhzdss1, zd_misc);
587 i |= ZX_SS1_MISC_ENABLE;
588 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss1, zd_misc, i);
589
590 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_wid, 1);
591 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_widclip, 0);
592 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_wmask, 0xffff);
593 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_vclipmin, 0);
594 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_vclipmax,
595 (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 16));
596 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, 0);
597 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_planemask, 0xffffffff);
598 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP);
599
600 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent,
601 (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 11));
602 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_addrspace,
603 ZX_ADDRSPC_FONT_OBGR);
604 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontt, 0);
605
606 for (i = 0; i < 256; i++) {
607 sc->sc_cmap[i] = rasops_cmap[i * 3];
608 sc->sc_cmap[i + 256] = rasops_cmap[i * 3 + 1];
609 sc->sc_cmap[i + 512] = rasops_cmap[i * 3 + 2];
610 }
611
612 zx_cmap_put(sc);
613 }
614
615 static int
616 zx_cross_wait(struct zx_softc *sc)
617 {
618 int i;
619
620 for (i = 300000; i != 0; i--) {
621 if ((bus_space_read_4(sc->sc_bt, sc->sc_bhzx, zx_csr) &
622 ZX_CROSS_CSR_PROGRESS) == 0)
623 break;
624 DELAY(1);
625 }
626
627 if (i == 0)
628 printf("zx_cross_wait: timed out\n");
629
630 return (i);
631 }
632
633 static int
634 zx_cross_loadwid(struct zx_softc *sc, u_int type, u_int index, u_int value)
635 {
636 u_int tmp = 0;
637
638 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_WID);
639
640 if (zx_cross_wait(sc))
641 return (1);
642
643 if (type == ZX_WID_DBL_8)
644 tmp = (index & 0x0f) + 0x40;
645 else if (type == ZX_WID_DBL_24)
646 tmp = index & 0x3f;
647
648 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, 0x5800 + tmp);
649 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_value, value);
650 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_WID);
651 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_csr,
652 ZX_CROSS_CSR_UNK | ZX_CROSS_CSR_UNK2);
653
654 return (0);
655 }
656
657 static int
658 zx_cmap_put(struct zx_softc *sc)
659 {
660 const u_char *b;
661 u_int i, t;
662
663 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_CLUT0);
664
665 zx_cross_wait(sc);
666
667 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type,
668 ZX_CROSS_TYPE_CLUTDATA);
669
670 for (i = 0, b = sc->sc_cmap; i < 256; i++) {
671 t = b[i];
672 t |= b[i + 256] << 8;
673 t |= b[i + 512] << 16;
674 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_value, t);
675 }
676
677 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_CLUT0);
678 i = bus_space_read_4(sc->sc_bt, sc->sc_bhzx, zx_csr);
679 i = i | ZX_CROSS_CSR_UNK | ZX_CROSS_CSR_UNK2;
680 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_csr, i);
681 return (0);
682 }
683
684 static void
685 zx_cursor_move(struct zx_softc *sc)
686 {
687 int sx, sy, x, y;
688
689 x = sc->sc_curpos.x - sc->sc_curhot.x;
690 y = sc->sc_curpos.y - sc->sc_curhot.y;
691
692 if (x < 0) {
693 sx = min(-x, 32);
694 x = 0;
695 } else
696 sx = 0;
697
698 if (y < 0) {
699 sy = min(-y, 32);
700 y = 0;
701 } else
702 sy = 0;
703
704 if (sx != sc->sc_shiftx || sy != sc->sc_shifty) {
705 sc->sc_shiftx = sx;
706 sc->sc_shifty = sy;
707 zx_cursor_set(sc);
708 }
709
710 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_sxy,
711 ((y & 0x7ff) << 11) | (x & 0x7ff));
712 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
713 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x30);
714
715 /* XXX Necessary? */
716 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
717 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80);
718 }
719
720 static void
721 zx_cursor_set(struct zx_softc *sc)
722 {
723 int i, j, data;
724
725 if ((sc->sc_flags & ZX_CURSOR) != 0)
726 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
727 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) &
728 ~0x80);
729
730 for (j = 0; j < 2; j++) {
731 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_type, 0x20 << j);
732
733 for (i = sc->sc_shifty; i < 32; i++) {
734 data = sc->sc_curbits[j][i];
735 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_data,
736 data >> sc->sc_shiftx);
737 }
738 for (i = sc->sc_shifty; i != 0; i--)
739 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_data, 0);
740 }
741
742 if ((sc->sc_flags & ZX_CURSOR) != 0)
743 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
744 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80);
745 }
746
747 static void
748 zx_cursor_blank(struct zx_softc *sc)
749 {
750
751 sc->sc_flags &= ~ZX_CURSOR;
752 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
753 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) & ~0x80);
754 }
755
756 static void
757 zx_cursor_unblank(struct zx_softc *sc)
758 {
759
760 sc->sc_flags |= ZX_CURSOR;
761 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
762 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80);
763 }
764
765 static void
766 zx_cursor_color(struct zx_softc *sc)
767 {
768 u_int8_t tmp;
769
770 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_type, 0x50);
771
772 tmp = sc->sc_curcmap[0] | (sc->sc_curcmap[2] << 8) |
773 (sc->sc_curcmap[4] << 16);
774 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_data, tmp);
775
776 tmp = sc->sc_curcmap[1] | (sc->sc_curcmap[3] << 8) |
777 (sc->sc_curcmap[5] << 16);
778 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_data, sc->sc_curcmap[1]);
779
780 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
781 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x03);
782 }
783
784 static void
785 zx_blank(device_t dv)
786 {
787 struct zx_softc *sc;
788
789 sc = device_private(dv);
790
791 if ((sc->sc_flags & ZX_BLANKED) != 0)
792 return;
793 sc->sc_flags |= ZX_BLANKED;
794
795 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_VIDEO);
796 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_csr,
797 bus_space_read_4(sc->sc_bt, sc->sc_bhzx, zx_csr) &
798 ~ZX_CROSS_CSR_ENABLE);
799 }
800
801 static void
802 zx_unblank(device_t dv)
803 {
804 struct zx_softc *sc;
805
806 sc = device_private(dv);
807
808 if ((sc->sc_flags & ZX_BLANKED) == 0)
809 return;
810 sc->sc_flags &= ~ZX_BLANKED;
811
812 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_VIDEO);
813 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_csr,
814 bus_space_read_4(sc->sc_bt, sc->sc_bhzx, zx_csr) |
815 ZX_CROSS_CSR_ENABLE);
816 }
817
818 static paddr_t
819 zxmmap(dev_t dev, off_t off, int prot)
820 {
821 struct zx_softc *sc;
822 const struct zx_mmo *mm, *mmmax;
823
824 sc = device_lookup_private(&zx_cd, minor(dev));
825 off = trunc_page(off);
826 mm = zx_mmo;
827 mmmax = mm + sizeof(zx_mmo) / sizeof(zx_mmo[0]);
828
829 for (; mm < mmmax; mm++)
830 if (off >= mm->mo_va && off < mm->mo_va + mm->mo_size) {
831 off = off - mm->mo_va + mm->mo_pa;
832 return (bus_space_mmap(sc->sc_bt, sc->sc_paddr,
833 off, prot, BUS_SPACE_MAP_LINEAR));
834 }
835
836 return (-1);
837 }
838
839 static void
840 zx_fillrect(struct zx_softc *sc, int x, int y, int w, int h, uint32_t bg,
841 int rop)
842 {
843
844
845 while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) &
846 ZX_CSR_BLT_BUSY) != 0)
847 ;
848
849 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, rop);
850 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, bg);
851 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent, w | (h << 11));
852 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fill,
853 x | (y << 11) | 0x80000000);
854 }
855
856 static void
857 zx_copyrect(struct zx_softc *sc, int sx, int sy, int dx, int dy, int w,
858 int h)
859 {
860 uint32_t dir;
861
862 if (sy < dy || sx < dx) {
863 dir = 0x80000000;
864 sx += w;
865 sy += h;
866 dx += w;
867 dy += h;
868 } else
869 dir = 0;
870
871 while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) &
872 ZX_CSR_BLT_BUSY) != 0)
873 ;
874
875 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP);
876 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent,
877 w | (h << 11) | dir);
878 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_src, sx | (sy << 11));
879 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_copy, dx | (dy << 11));
880 }
881
882 static void
883 zx_do_cursor(void *cookie, int on, int row, int col)
884 {
885 struct rasops_info *ri = cookie;
886 struct vcons_screen *scr = ri->ri_hw;
887 struct zx_softc *sc = scr->scr_cookie;
888 int x, y, wi, he;
889
890 wi = ri->ri_font->fontwidth;
891 he = ri->ri_font->fontheight;
892
893 if (ri->ri_flg & RI_CURSOR) {
894 x = ri->ri_ccol * wi + ri->ri_xorigin;
895 y = ri->ri_crow * he + ri->ri_yorigin;
896 zx_fillrect(sc, x, y, wi, he, 0xff000000,
897 ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE |
898 ZX_ATTR_FORCE_WID);
899 ri->ri_flg &= ~RI_CURSOR;
900 }
901
902 ri->ri_crow = row;
903 ri->ri_ccol = col;
904
905 if (on)
906 {
907 x = ri->ri_ccol * wi + ri->ri_xorigin;
908 y = ri->ri_crow * he + ri->ri_yorigin;
909 zx_fillrect(sc, x, y, wi, he, 0xff000000,
910 ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE |
911 ZX_ATTR_FORCE_WID);
912 ri->ri_flg |= RI_CURSOR;
913 }
914 }
915
916 static void
917 zx_erasecols(void *cookie, int row, int startcol, int ncols, long attr)
918 {
919 struct rasops_info *ri = cookie;
920 struct vcons_screen *scr = ri->ri_hw;
921 struct zx_softc *sc = scr->scr_cookie;
922 int32_t x, y, width, height, bg;
923
924 x = ri->ri_xorigin + ri->ri_font->fontwidth * startcol;
925 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
926 width = ri->ri_font->fontwidth * ncols;
927 height = ri->ri_font->fontheight;
928 bg = ((uint32_t)ri->ri_devcmap[(attr >> 16) & 0xff]) << 24;
929 zx_fillrect(sc, x, y, width, height, bg, ZX_STD_ROP);
930 }
931
932 static void
933 zx_eraserows(void *cookie, int row, int nrows, long attr)
934 {
935 struct rasops_info *ri = cookie;
936 struct vcons_screen *scr = ri->ri_hw;
937 struct zx_softc *sc = scr->scr_cookie;
938 int32_t x, y, width, height, bg;
939
940 if ((row == 0) && (nrows == ri->ri_rows)) {
941 x = y = 0;
942 width = ri->ri_width;
943 height = ri->ri_height;
944 } else {
945 x = ri->ri_xorigin;
946 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
947 width = ri->ri_emuwidth;
948 height = ri->ri_font->fontheight * nrows;
949 }
950 bg = ((uint32_t)ri->ri_devcmap[(attr >> 16) & 0xff]) << 24;
951 zx_fillrect(sc, x, y, width, height, bg, ZX_STD_ROP);
952 }
953
954 static void
955 zx_copyrows(void *cookie, int srcrow, int dstrow, int nrows)
956 {
957 struct rasops_info *ri = cookie;
958 struct vcons_screen *scr = ri->ri_hw;
959 struct zx_softc *sc = scr->scr_cookie;
960 int32_t x, ys, yd, width, height;
961
962 x = ri->ri_xorigin;
963 ys = ri->ri_yorigin + ri->ri_font->fontheight * srcrow;
964 yd = ri->ri_yorigin + ri->ri_font->fontheight * dstrow;
965 width = ri->ri_emuwidth;
966 height = ri->ri_font->fontheight * nrows;
967 zx_copyrect(sc, x, ys, x, yd, width, height);
968 }
969
970 static void
971 zx_copycols(void *cookie, int row, int srccol, int dstcol, int ncols)
972 {
973 struct rasops_info *ri = cookie;
974 struct vcons_screen *scr = ri->ri_hw;
975 struct zx_softc *sc = scr->scr_cookie;
976 int32_t xs, xd, y, width, height;
977
978 xs = ri->ri_xorigin + ri->ri_font->fontwidth * srccol;
979 xd = ri->ri_xorigin + ri->ri_font->fontwidth * dstcol;
980 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
981 width = ri->ri_font->fontwidth * ncols;
982 height = ri->ri_font->fontheight;
983 zx_copyrect(sc, xs, y, xd, y, width, height);
984 }
985
986 static void
987 zx_putchar(void *cookie, int row, int col, u_int uc, long attr)
988 {
989 struct rasops_info *ri = cookie;
990 struct vcons_screen *scr = ri->ri_hw;
991 struct zx_softc *sc = scr->scr_cookie;
992 struct wsdisplay_font *font;
993 volatile u_int32_t *dp;
994 u_int8_t *fb;
995 int fs, i, ul;
996 uint32_t fg, bg;
997
998 rasops_unpack_attr(attr, &fg, &bg, &ul);
999 bg = ((uint32_t)ri->ri_devcmap[bg]) << 24;
1000 fg = ((uint32_t)ri->ri_devcmap[fg]) << 24;
1001 if (uc == ' ') {
1002 int x, y;
1003
1004 x = ri->ri_xorigin + ri->ri_font->fontwidth * col;
1005 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
1006 zx_fillrect(sc, x, y, ri->ri_font->fontwidth,
1007 ri->ri_font->fontheight, bg, ZX_STD_ROP);
1008 return;
1009 }
1010
1011 font = ri->ri_font;
1012
1013 dp = (volatile u_int32_t *)sc->sc_pixels +
1014 ((row * font->fontheight + ri->ri_yorigin) << 11) +
1015 (col * font->fontwidth + ri->ri_xorigin);
1016 fb = (u_int8_t *)font->data + (uc - font->firstchar) *
1017 ri->ri_fontscale;
1018 fs = font->stride;
1019
1020 while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) &
1021 ZX_CSR_BLT_BUSY) != 0)
1022 ;
1023
1024 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP);
1025 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, fg);
1026 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_bg, bg);
1027 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontmsk,
1028 0xffffffff << (32 - font->fontwidth));
1029
1030 if (font->fontwidth <= 8) {
1031 for (i = font->fontheight; i != 0; i--, dp += 2048) {
1032 *dp = *fb << 24;
1033 fb += fs;
1034 }
1035 } else {
1036 for (i = font->fontheight; i != 0; i--, dp += 2048) {
1037 *dp = *((u_int16_t *)fb) << 16;
1038 fb += fs;
1039 }
1040 }
1041
1042 if (ul) {
1043 dp -= 4096;
1044 *dp = 0xffffffff;
1045 }
1046 }
1047
1048 #if NWSDISPLAY > 0
1049 static int
1050 zx_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
1051 struct lwp *l)
1052 {
1053 /* we'll probably need to add more stuff here */
1054 struct vcons_data *vd = v;
1055 struct zx_softc *sc = vd->cookie;
1056 struct wsdisplay_fbinfo *wdf;
1057 struct rasops_info *ri = &sc->sc_fb.fb_rinfo;
1058 struct vcons_screen *ms = sc->vd.active;
1059 switch (cmd) {
1060 case WSDISPLAYIO_GTYPE:
1061 *(u_int *)data = WSDISPLAY_TYPE_SUNTCX;
1062 return 0;
1063 case WSDISPLAYIO_GINFO:
1064 wdf = (void *)data;
1065 wdf->height = ri->ri_height;
1066 wdf->width = ri->ri_width;
1067 wdf->depth = ri->ri_depth;
1068 wdf->cmsize = 256;
1069 return 0;
1070
1071 case WSDISPLAYIO_GETCMAP:
1072 return zx_getcmap(sc,
1073 (struct wsdisplay_cmap *)data);
1074 case WSDISPLAYIO_PUTCMAP:
1075 return zx_putcmap(sc,
1076 (struct wsdisplay_cmap *)data);
1077
1078 case WSDISPLAYIO_SMODE:
1079 {
1080 int new_mode = *(int*)data;
1081 if (new_mode != sc->sc_mode)
1082 {
1083 sc->sc_mode = new_mode;
1084 if(new_mode == WSDISPLAYIO_MODE_EMUL)
1085 {
1086 vcons_redraw_screen(ms);
1087 }
1088 }
1089 }
1090 }
1091 return EPASSTHROUGH;
1092 }
1093
1094 static paddr_t
1095 zx_mmap(void *v, void *vs, off_t offset, int prot)
1096 {
1097 /* I'm not at all sure this is the right thing to do */
1098 return zxmmap(0, offset, prot); /* assume minor dev 0 for now */
1099 }
1100
1101 static int
1102 zx_putcmap(struct zx_softc *sc, struct wsdisplay_cmap *cm)
1103 {
1104 u_int index = cm->index;
1105 u_int count = cm->count;
1106 int error,i;
1107 if (index >= 256 || count > 256 || index + count > 256)
1108 return EINVAL;
1109
1110 for (i = 0; i < count; i++)
1111 {
1112 error = copyin(&cm->red[i],
1113 &sc->sc_cmap[index + i], 1);
1114 if (error)
1115 return error;
1116 error = copyin(&cm->green[i],
1117 &sc->sc_cmap[index + i + 256], 1);
1118 if (error)
1119 return error;
1120 error = copyin(&cm->blue[i],
1121 &sc->sc_cmap[index + i + 512], 1);
1122 if (error)
1123 return error;
1124 }
1125 zx_cmap_put(sc);
1126
1127 return 0;
1128 }
1129
1130 static int
1131 zx_getcmap(struct zx_softc *sc, struct wsdisplay_cmap *cm)
1132 {
1133 u_int index = cm->index;
1134 u_int count = cm->count;
1135 int error,i;
1136
1137 if (index >= 256 || count > 256 || index + count > 256)
1138 return EINVAL;
1139
1140 for (i = 0; i < count; i++)
1141 {
1142 error = copyout(&sc->sc_cmap[index + i],
1143 &cm->red[i], 1);
1144 if (error)
1145 return error;
1146 error = copyout(&sc->sc_cmap[index + i + 256],
1147 &cm->green[i], 1);
1148 if (error)
1149 return error;
1150 error = copyout(&sc->sc_cmap[index + i + 256],
1151 &cm->blue[i], 1);
1152 if (error)
1153 return error;
1154 }
1155
1156 return 0;
1157 }
1158
1159 static void
1160 zx_init_screen(void *cookie, struct vcons_screen *scr,
1161 int existing, long *defattr)
1162 {
1163 struct zx_softc *sc = cookie;
1164 struct rasops_info *ri = &scr->scr_ri;
1165
1166 ri->ri_depth = 8; /*sc->sc_fb.fb_type.fb_depth = 32;*/
1167 ri->ri_width = sc->sc_width;
1168 ri->ri_height = sc->sc_height;
1169 ri->ri_stride = sc->sc_stride;
1170 ri->ri_flg = RI_CENTER;
1171
1172 ri->ri_bits = (void *)sc->sc_pixels;
1173
1174 rasops_init(ri, sc->sc_height/8, sc->sc_width/8);
1175 ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_REVERSE;
1176 rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
1177 sc->sc_width / ri->ri_font->fontwidth);
1178
1179 ri->ri_hw = scr;
1180
1181 ri->ri_ops.cursor = zx_do_cursor;
1182 ri->ri_ops.copycols = zx_copycols;
1183 ri->ri_ops.copyrows = zx_copyrows;
1184 ri->ri_ops.erasecols = zx_erasecols;
1185 ri->ri_ops.eraserows = zx_eraserows;
1186 ri->ri_ops.putchar = zx_putchar;
1187 }
1188
1189 #endif /* NWSDISPLAY > 0 */
1190