zx.c revision 1.33 1 /* $NetBSD: zx.c,v 1.33 2009/09/19 11:55:09 tsutsui 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.33 2009/09/19 11:55:09 tsutsui 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 #include "ioconf.h"
86
87 #if (NWSDISPLAY == 0) && !defined(RASTERCONSOLE)
88 #error Sorry, this driver needs WSCONS or RASTERCONSOLE
89 #endif
90
91 #if (NWSDISPLAY > 0) && defined(RASTERCONSOLE)
92 #error Sorry, RASTERCONSOLE and WSCONS are mutually exclusive
93 #endif
94
95 #define ZX_STD_ROP (ZX_ROP_NEW | ZX_ATTR_WE_ENABLE | \
96 ZX_ATTR_OE_ENABLE | ZX_ATTR_FORCE_WID)
97
98 static void zx_attach(device_t, device_t, void *);
99 static int zx_match(device_t, cfdata_t, void *);
100
101 static void zx_blank(device_t);
102 static int zx_cmap_put(struct zx_softc *);
103 static void zx_copyrect(struct zx_softc *, int, int, int, int, int, int);
104 static int zx_cross_loadwid(struct zx_softc *, u_int, u_int, u_int);
105 static int zx_cross_wait(struct zx_softc *);
106 static void zx_fillrect(struct zx_softc *, int, int, int, int, uint32_t, int);
107 static int zx_intr(void *);
108 static void zx_reset(struct zx_softc *);
109 static void zx_unblank(device_t);
110
111 static void zx_cursor_blank(struct zx_softc *);
112 static void zx_cursor_color(struct zx_softc *);
113 static void zx_cursor_move(struct zx_softc *);
114 static void zx_cursor_set(struct zx_softc *);
115 static void zx_cursor_unblank(struct zx_softc *);
116
117 static void zx_copycols(void *, int, int, int, int);
118 static void zx_copyrows(void *, int, int, int);
119 static void zx_do_cursor(void *, int, int, int);
120 static void zx_erasecols(void *, int, int, int, long);
121 static void zx_eraserows(void *, int, int, long);
122 static void zx_putchar(void *, int, int, u_int, long);
123
124 struct zx_mmo {
125 off_t mo_va;
126 off_t mo_pa;
127 off_t mo_size;
128 } static const zx_mmo[] = {
129 { ZX_FB0_VOFF, ZX_OFF_SS0, 0x00800000 },
130 { ZX_LC0_VOFF, ZX_OFF_LC_SS0_USR, 0x00001000 },
131 { ZX_LD0_VOFF, ZX_OFF_LD_SS0, 0x00001000 },
132 { ZX_LX0_CURSOR_VOFF, ZX_OFF_LX_CURSOR, 0x00001000 },
133 { ZX_FB1_VOFF, ZX_OFF_SS1, 0x00800000 },
134 { ZX_LC1_VOFF, ZX_OFF_LC_SS1_USR, 0x00001000 },
135 { ZX_LD1_VOFF, ZX_OFF_LD_SS1, 0x00001000 },
136 { ZX_LX_KRN_VOFF, ZX_OFF_LX_CROSS, 0x00001000 },
137 { ZX_LC0_KRN_VOFF, ZX_OFF_LC_SS0_KRN, 0x00001000 },
138 { ZX_LC1_KRN_VOFF, ZX_OFF_LC_SS1_KRN, 0x00001000 },
139 { ZX_LD_GBL_VOFF, ZX_OFF_LD_GBL, 0x00001000 },
140 };
141
142 CFATTACH_DECL_NEW(zx, sizeof(struct zx_softc),
143 zx_match, zx_attach, NULL, NULL);
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, cfdata_t 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, width, height;
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 (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_SS0,
233 0x800000, BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE, &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 = (uint32_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 if (sa->sa_nintr != 0)
298 bus_intr_establish(bt, sa->sa_pri, IPL_NONE, zx_intr, sc);
299
300 sc->sc_cmap = malloc(768, M_DEVBUF, M_NOWAIT);
301 zx_reset(sc);
302
303 #if NWSDISPLAY > 0
304 sc->sc_width = fb->fb_type.fb_width;
305 sc->sc_stride = 8192; /* 32 bit */
306 sc->sc_height = fb->fb_type.fb_height;
307
308 /* setup rasops and so on for wsdisplay */
309 wsfont_init();
310 sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
311 sc->sc_bg = WS_DEFAULT_BG;
312
313 vcons_init(&sc->vd, sc, &zx_defaultscreen, &zx_accessops);
314 sc->vd.init_screen = zx_init_screen;
315
316 if (isconsole) {
317 /* we mess with zx_console_screen only once */
318 vcons_init_screen(&sc->vd, &zx_console_screen, 1,
319 &defattr);
320 zx_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
321
322 zx_defaultscreen.textops = &ri->ri_ops;
323 zx_defaultscreen.capabilities = WSSCREEN_WSCOLORS;
324 zx_defaultscreen.nrows = ri->ri_rows;
325 zx_defaultscreen.ncols = ri->ri_cols;
326 zx_fillrect(sc, 0, 0, width, height,
327 ri->ri_devcmap[defattr >> 16], ZX_STD_ROP);
328 wsdisplay_cnattach(&zx_defaultscreen, ri, 0, 0, defattr);
329 } else {
330 /*
331 * we're not the console so we just clear the screen and don't
332 * set up any sort of text display
333 */
334 if (zx_defaultscreen.textops == NULL) {
335 /*
336 * ugly, but...
337 * we want the console settings to win, so we only
338 * touch anything when we find an untouched screen
339 * definition. In this case we fill it from fb to
340 * avoid problems in case no zx is the console
341 */
342 ri = &sc->sc_fb.fb_rinfo;
343 zx_defaultscreen.textops = &ri->ri_ops;
344 zx_defaultscreen.capabilities = ri->ri_caps;
345 zx_defaultscreen.nrows = ri->ri_rows;
346 zx_defaultscreen.ncols = ri->ri_cols;
347 }
348 }
349
350 aa.scrdata = &zx_screenlist;
351 aa.console = isconsole;
352 aa.accessops = &zx_accessops;
353 aa.accesscookie = &sc->vd;
354 config_found(sc->sc_dv, &aa, wsemuldisplaydevprint);
355 #endif
356 fb_attach(&sc->sc_fb, isconsole);
357 }
358
359 static int
360 zxopen(dev_t dev, int flags, int mode, struct lwp *l)
361 {
362
363 if (device_lookup(&zx_cd, minor(dev)) == NULL)
364 return (ENXIO);
365 return (0);
366 }
367
368 static int
369 zxclose(dev_t dev, int flags, int mode, struct lwp *l)
370 {
371 struct zx_softc *sc;
372
373 sc = device_lookup_private(&zx_cd, minor(dev));
374
375 zx_reset(sc);
376 zx_cursor_blank(sc);
377 return (0);
378 }
379
380 static int
381 zxioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
382 {
383 struct zx_softc *sc;
384 struct fbcmap *cm;
385 struct fbcursor *cu;
386 uint32_t curbits[2][32];
387 int rv, v, count, i;
388
389 sc = device_lookup_private(&zx_cd, minor(dev));
390
391 switch (cmd) {
392 case FBIOGTYPE:
393 *(struct fbtype *)data = sc->sc_fb.fb_type;
394 break;
395
396 case FBIOGATTR:
397 #define fba ((struct fbgattr *)data)
398 fba->real_type = sc->sc_fb.fb_type.fb_type;
399 fba->owner = 0; /* XXX ??? */
400 fba->fbtype = sc->sc_fb.fb_type;
401 fba->sattr.flags = 0;
402 fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type;
403 fba->sattr.dev_specific[0] = -1;
404 fba->emu_types[0] = sc->sc_fb.fb_type.fb_type;
405 fba->emu_types[1] = -1;
406 fba->emu_types[2] = -1;
407 #undef fba
408 break;
409
410 case FBIOGVIDEO:
411 *(int *)data = ((sc->sc_flags & ZX_BLANKED) != 0);
412 break;
413
414 case FBIOSVIDEO:
415 if (*(int *)data)
416 zx_unblank(sc->sc_dv);
417 else
418 zx_blank(sc->sc_dv);
419 break;
420
421 case FBIOGETCMAP:
422 cm = (struct fbcmap *)data;
423 if (cm->index > 256 || cm->count > 256 - cm->index)
424 return (EINVAL);
425 rv = copyout(sc->sc_cmap + cm->index, cm->red, cm->count);
426 if (rv == 0)
427 rv = copyout(sc->sc_cmap + 256 + cm->index, cm->green,
428 cm->count);
429 if (rv == 0)
430 rv = copyout(sc->sc_cmap + 512 + cm->index, cm->blue,
431 cm->count);
432 return (rv);
433
434 case FBIOPUTCMAP:
435 cm = (struct fbcmap *)data;
436 if (cm->index > 256 || cm->count > 256 - cm->index)
437 return (EINVAL);
438 rv = copyin(cm->red, sc->sc_cmap + cm->index, cm->count);
439 if (rv == 0)
440 rv = copyin(cm->green, sc->sc_cmap + 256 + cm->index,
441 cm->count);
442 if (rv == 0)
443 rv = copyin(cm->blue, sc->sc_cmap + 512 + cm->index,
444 cm->count);
445 zx_cmap_put(sc);
446 return (rv);
447
448 case FBIOGCURPOS:
449 *(struct fbcurpos *)data = sc->sc_curpos;
450 break;
451
452 case FBIOSCURPOS:
453 sc->sc_curpos = *(struct fbcurpos *)data;
454 zx_cursor_move(sc);
455 break;
456
457 case FBIOGCURMAX:
458 ((struct fbcurpos *)data)->x = 32;
459 ((struct fbcurpos *)data)->y = 32;
460 break;
461
462 case FBIOSCURSOR:
463 cu = (struct fbcursor *)data;
464 v = cu->set;
465
466 if ((v & FB_CUR_SETSHAPE) != 0) {
467 if ((u_int)cu->size.x > 32 || (u_int)cu->size.y > 32)
468 return (EINVAL);
469 count = cu->size.y * 4;
470 rv = copyin(cu->mask, curbits[0], count);
471 if (rv)
472 return rv;
473 rv = copyin(cu->image, curbits[1], count);
474 if (rv)
475 return rv;
476 }
477 if ((v & FB_CUR_SETCUR) != 0) {
478 if (cu->enable)
479 zx_cursor_unblank(sc);
480 else
481 zx_cursor_blank(sc);
482 }
483 if ((v & (FB_CUR_SETPOS | FB_CUR_SETHOT)) != 0) {
484 if ((v & FB_CUR_SETPOS) != 0)
485 sc->sc_curpos = cu->pos;
486 if ((v & FB_CUR_SETHOT) != 0)
487 sc->sc_curhot = cu->hot;
488 zx_cursor_move(sc);
489 }
490 if ((v & FB_CUR_SETCMAP) != 0) {
491 if (cu->cmap.index > 2 ||
492 cu->cmap.count > 2 - cu->cmap.index)
493 return (EINVAL);
494 for (i = 0; i < cu->cmap.count; i++) {
495 if ((v = fubyte(&cu->cmap.red[i])) < 0)
496 return (EFAULT);
497 sc->sc_curcmap[i + cu->cmap.index + 0] = v;
498 if ((v = fubyte(&cu->cmap.green[i])) < 0)
499 return (EFAULT);
500 sc->sc_curcmap[i + cu->cmap.index + 2] = v;
501 if ((v = fubyte(&cu->cmap.blue[i])) < 0)
502 return (EFAULT);
503 sc->sc_curcmap[i + cu->cmap.index + 4] = v;
504 }
505 zx_cursor_color(sc);
506 }
507 if ((v & FB_CUR_SETSHAPE) != 0) {
508 sc->sc_cursize = cu->size;
509 count = cu->size.y * 4;
510 memset(sc->sc_curbits, 0, sizeof(sc->sc_curbits));
511 memcpy(sc->sc_curbits[0], curbits[0], count);
512 memcpy(sc->sc_curbits[1], curbits[1], count);
513 zx_cursor_set(sc);
514 }
515 break;
516
517 case FBIOGCURSOR:
518 cu = (struct fbcursor *)data;
519
520 cu->set = FB_CUR_SETALL;
521 cu->enable = ((sc->sc_flags & ZX_CURSOR) != 0);
522 cu->pos = sc->sc_curpos;
523 cu->hot = sc->sc_curhot;
524 cu->size = sc->sc_cursize;
525
526 if (cu->image != NULL) {
527 count = sc->sc_cursize.y * 4;
528 rv = copyout(sc->sc_curbits[1], cu->image, count);
529 if (rv)
530 return (rv);
531 rv = copyout(sc->sc_curbits[0], cu->mask, count);
532 if (rv)
533 return (rv);
534 }
535 if (cu->cmap.red != NULL) {
536 if (cu->cmap.index > 2 ||
537 cu->cmap.count > 2 - cu->cmap.index)
538 return (EINVAL);
539 for (i = 0; i < cu->cmap.count; i++) {
540 v = sc->sc_curcmap[i + cu->cmap.index + 0];
541 if (subyte(&cu->cmap.red[i], v))
542 return (EFAULT);
543 v = sc->sc_curcmap[i + cu->cmap.index + 2];
544 if (subyte(&cu->cmap.green[i], v))
545 return (EFAULT);
546 v = sc->sc_curcmap[i + cu->cmap.index + 4];
547 if (subyte(&cu->cmap.blue[i], v))
548 return (EFAULT);
549 }
550 } else {
551 cu->cmap.index = 0;
552 cu->cmap.count = 2;
553 }
554 break;
555
556 default:
557 #ifdef DEBUG
558 log(LOG_NOTICE, "zxioctl(0x%lx) (%s[%d])\n", cmd,
559 l->l_proc->p_comm, l->l_proc->p_pid);
560 #endif
561 return (ENOTTY);
562 }
563
564 return (0);
565 }
566
567 static int
568 zx_intr(void *cookie)
569 {
570
571 return (1);
572 }
573
574 static void
575 zx_reset(struct zx_softc *sc)
576 {
577 struct fbtype *fbt;
578 u_int i;
579
580 fbt = &sc->sc_fb.fb_type;
581
582 zx_cross_loadwid(sc, ZX_WID_DBL_8, 0, 0x2c0);
583 zx_cross_loadwid(sc, ZX_WID_DBL_8, 1, 0x30);
584 zx_cross_loadwid(sc, ZX_WID_DBL_8, 2, 0x20);
585 zx_cross_loadwid(sc, ZX_WID_DBL_24, 1, 0x30);
586
587 i = bus_space_read_4(sc->sc_bt, sc->sc_bhzdss1, zd_misc);
588 i |= ZX_SS1_MISC_ENABLE;
589 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss1, zd_misc, i);
590
591 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_wid, 1);
592 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_widclip, 0);
593 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_wmask, 0xffff);
594 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_vclipmin, 0);
595 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_vclipmax,
596 (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 16));
597 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, 0);
598 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_planemask, 0xffffffff);
599 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP);
600
601 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent,
602 (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 11));
603 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_addrspace,
604 ZX_ADDRSPC_FONT_OBGR);
605 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontt, 0);
606
607 for (i = 0; i < 256; i++) {
608 sc->sc_cmap[i] = rasops_cmap[i * 3];
609 sc->sc_cmap[i + 256] = rasops_cmap[i * 3 + 1];
610 sc->sc_cmap[i + 512] = rasops_cmap[i * 3 + 2];
611 }
612
613 zx_cmap_put(sc);
614 }
615
616 static int
617 zx_cross_wait(struct zx_softc *sc)
618 {
619 int i;
620
621 for (i = 300000; i != 0; i--) {
622 if ((bus_space_read_4(sc->sc_bt, sc->sc_bhzx, zx_csr) &
623 ZX_CROSS_CSR_PROGRESS) == 0)
624 break;
625 DELAY(1);
626 }
627
628 if (i == 0)
629 printf("zx_cross_wait: timed out\n");
630
631 return (i);
632 }
633
634 static int
635 zx_cross_loadwid(struct zx_softc *sc, u_int type, u_int index, u_int value)
636 {
637 u_int tmp = 0;
638
639 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_WID);
640
641 if (zx_cross_wait(sc))
642 return (1);
643
644 if (type == ZX_WID_DBL_8)
645 tmp = (index & 0x0f) + 0x40;
646 else if (type == ZX_WID_DBL_24)
647 tmp = index & 0x3f;
648
649 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, 0x5800 + tmp);
650 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_value, value);
651 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_WID);
652 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_csr,
653 ZX_CROSS_CSR_UNK | ZX_CROSS_CSR_UNK2);
654
655 return (0);
656 }
657
658 static int
659 zx_cmap_put(struct zx_softc *sc)
660 {
661 const u_char *b;
662 u_int i, t;
663
664 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_CLUT0);
665
666 zx_cross_wait(sc);
667
668 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type,
669 ZX_CROSS_TYPE_CLUTDATA);
670
671 for (i = 0, b = sc->sc_cmap; i < 256; i++) {
672 t = b[i];
673 t |= b[i + 256] << 8;
674 t |= b[i + 512] << 16;
675 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_value, t);
676 }
677
678 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_CLUT0);
679 i = bus_space_read_4(sc->sc_bt, sc->sc_bhzx, zx_csr);
680 i = i | ZX_CROSS_CSR_UNK | ZX_CROSS_CSR_UNK2;
681 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_csr, i);
682 return (0);
683 }
684
685 static void
686 zx_cursor_move(struct zx_softc *sc)
687 {
688 int sx, sy, x, y;
689
690 x = sc->sc_curpos.x - sc->sc_curhot.x;
691 y = sc->sc_curpos.y - sc->sc_curhot.y;
692
693 if (x < 0) {
694 sx = min(-x, 32);
695 x = 0;
696 } else
697 sx = 0;
698
699 if (y < 0) {
700 sy = min(-y, 32);
701 y = 0;
702 } else
703 sy = 0;
704
705 if (sx != sc->sc_shiftx || sy != sc->sc_shifty) {
706 sc->sc_shiftx = sx;
707 sc->sc_shifty = sy;
708 zx_cursor_set(sc);
709 }
710
711 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_sxy,
712 ((y & 0x7ff) << 11) | (x & 0x7ff));
713 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
714 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x30);
715
716 /* XXX Necessary? */
717 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
718 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80);
719 }
720
721 static void
722 zx_cursor_set(struct zx_softc *sc)
723 {
724 int i, j, data;
725
726 if ((sc->sc_flags & ZX_CURSOR) != 0)
727 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
728 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) &
729 ~0x80);
730
731 for (j = 0; j < 2; j++) {
732 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_type, 0x20 << j);
733
734 for (i = sc->sc_shifty; i < 32; i++) {
735 data = sc->sc_curbits[j][i];
736 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_data,
737 data >> sc->sc_shiftx);
738 }
739 for (i = sc->sc_shifty; i != 0; i--)
740 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_data, 0);
741 }
742
743 if ((sc->sc_flags & ZX_CURSOR) != 0)
744 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
745 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80);
746 }
747
748 static void
749 zx_cursor_blank(struct zx_softc *sc)
750 {
751
752 sc->sc_flags &= ~ZX_CURSOR;
753 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
754 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) & ~0x80);
755 }
756
757 static void
758 zx_cursor_unblank(struct zx_softc *sc)
759 {
760
761 sc->sc_flags |= ZX_CURSOR;
762 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
763 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80);
764 }
765
766 static void
767 zx_cursor_color(struct zx_softc *sc)
768 {
769 uint8_t tmp;
770
771 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_type, 0x50);
772
773 tmp = sc->sc_curcmap[0] | (sc->sc_curcmap[2] << 8) |
774 (sc->sc_curcmap[4] << 16);
775 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_data, tmp);
776
777 tmp = sc->sc_curcmap[1] | (sc->sc_curcmap[3] << 8) |
778 (sc->sc_curcmap[5] << 16);
779 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_data, sc->sc_curcmap[1]);
780
781 bus_space_write_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc,
782 bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x03);
783 }
784
785 static void
786 zx_blank(device_t dv)
787 {
788 struct zx_softc *sc;
789
790 sc = device_private(dv);
791
792 if ((sc->sc_flags & ZX_BLANKED) != 0)
793 return;
794 sc->sc_flags |= ZX_BLANKED;
795
796 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_VIDEO);
797 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_csr,
798 bus_space_read_4(sc->sc_bt, sc->sc_bhzx, zx_csr) &
799 ~ZX_CROSS_CSR_ENABLE);
800 }
801
802 static void
803 zx_unblank(device_t dv)
804 {
805 struct zx_softc *sc;
806
807 sc = device_private(dv);
808
809 if ((sc->sc_flags & ZX_BLANKED) == 0)
810 return;
811 sc->sc_flags &= ~ZX_BLANKED;
812
813 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_VIDEO);
814 bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_csr,
815 bus_space_read_4(sc->sc_bt, sc->sc_bhzx, zx_csr) |
816 ZX_CROSS_CSR_ENABLE);
817 }
818
819 static paddr_t
820 zxmmap(dev_t dev, off_t off, int prot)
821 {
822 struct zx_softc *sc;
823 const struct zx_mmo *mm, *mmmax;
824
825 sc = device_lookup_private(&zx_cd, minor(dev));
826 off = trunc_page(off);
827 mm = zx_mmo;
828 mmmax = mm + sizeof(zx_mmo) / sizeof(zx_mmo[0]);
829
830 for (; mm < mmmax; mm++)
831 if (off >= mm->mo_va && off < mm->mo_va + mm->mo_size) {
832 off = off - mm->mo_va + mm->mo_pa;
833 return (bus_space_mmap(sc->sc_bt, sc->sc_paddr,
834 off, prot, BUS_SPACE_MAP_LINEAR));
835 }
836
837 return (-1);
838 }
839
840 static void
841 zx_fillrect(struct zx_softc *sc, int x, int y, int w, int h, uint32_t bg,
842 int rop)
843 {
844
845
846 while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) &
847 ZX_CSR_BLT_BUSY) != 0)
848 ;
849
850 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, rop);
851 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, bg);
852 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent, w | (h << 11));
853 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fill,
854 x | (y << 11) | 0x80000000);
855 }
856
857 static void
858 zx_copyrect(struct zx_softc *sc, int sx, int sy, int dx, int dy, int w,
859 int h)
860 {
861 uint32_t dir;
862
863 if (sy < dy || sx < dx) {
864 dir = 0x80000000;
865 sx += w;
866 sy += h;
867 dx += w;
868 dy += h;
869 } else
870 dir = 0;
871
872 while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) &
873 ZX_CSR_BLT_BUSY) != 0)
874 ;
875
876 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP);
877 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent,
878 w | (h << 11) | dir);
879 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_src, sx | (sy << 11));
880 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_copy, dx | (dy << 11));
881 }
882
883 static void
884 zx_do_cursor(void *cookie, int on, int row, int col)
885 {
886 struct rasops_info *ri = cookie;
887 struct vcons_screen *scr = ri->ri_hw;
888 struct zx_softc *sc = scr->scr_cookie;
889 int x, y, wi, he;
890
891 wi = ri->ri_font->fontwidth;
892 he = ri->ri_font->fontheight;
893
894 if (ri->ri_flg & RI_CURSOR) {
895 x = ri->ri_ccol * wi + ri->ri_xorigin;
896 y = ri->ri_crow * he + ri->ri_yorigin;
897 zx_fillrect(sc, x, y, wi, he, 0xff000000,
898 ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE |
899 ZX_ATTR_FORCE_WID);
900 ri->ri_flg &= ~RI_CURSOR;
901 }
902
903 ri->ri_crow = row;
904 ri->ri_ccol = col;
905
906 if (on)
907 {
908 x = ri->ri_ccol * wi + ri->ri_xorigin;
909 y = ri->ri_crow * he + ri->ri_yorigin;
910 zx_fillrect(sc, x, y, wi, he, 0xff000000,
911 ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE |
912 ZX_ATTR_FORCE_WID);
913 ri->ri_flg |= RI_CURSOR;
914 }
915 }
916
917 static void
918 zx_erasecols(void *cookie, int row, int startcol, int ncols, long attr)
919 {
920 struct rasops_info *ri = cookie;
921 struct vcons_screen *scr = ri->ri_hw;
922 struct zx_softc *sc = scr->scr_cookie;
923 int32_t x, y, width, height, bg;
924
925 x = ri->ri_xorigin + ri->ri_font->fontwidth * startcol;
926 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
927 width = ri->ri_font->fontwidth * ncols;
928 height = ri->ri_font->fontheight;
929 bg = ((uint32_t)ri->ri_devcmap[(attr >> 16) & 0xff]) << 24;
930 zx_fillrect(sc, x, y, width, height, bg, ZX_STD_ROP);
931 }
932
933 static void
934 zx_eraserows(void *cookie, int row, int nrows, long attr)
935 {
936 struct rasops_info *ri = cookie;
937 struct vcons_screen *scr = ri->ri_hw;
938 struct zx_softc *sc = scr->scr_cookie;
939 int32_t x, y, width, height, bg;
940
941 if ((row == 0) && (nrows == ri->ri_rows)) {
942 x = y = 0;
943 width = ri->ri_width;
944 height = ri->ri_height;
945 } else {
946 x = ri->ri_xorigin;
947 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
948 width = ri->ri_emuwidth;
949 height = ri->ri_font->fontheight * nrows;
950 }
951 bg = ((uint32_t)ri->ri_devcmap[(attr >> 16) & 0xff]) << 24;
952 zx_fillrect(sc, x, y, width, height, bg, ZX_STD_ROP);
953 }
954
955 static void
956 zx_copyrows(void *cookie, int srcrow, int dstrow, int nrows)
957 {
958 struct rasops_info *ri = cookie;
959 struct vcons_screen *scr = ri->ri_hw;
960 struct zx_softc *sc = scr->scr_cookie;
961 int32_t x, ys, yd, width, height;
962
963 x = ri->ri_xorigin;
964 ys = ri->ri_yorigin + ri->ri_font->fontheight * srcrow;
965 yd = ri->ri_yorigin + ri->ri_font->fontheight * dstrow;
966 width = ri->ri_emuwidth;
967 height = ri->ri_font->fontheight * nrows;
968 zx_copyrect(sc, x, ys, x, yd, width, height);
969 }
970
971 static void
972 zx_copycols(void *cookie, int row, int srccol, int dstcol, int ncols)
973 {
974 struct rasops_info *ri = cookie;
975 struct vcons_screen *scr = ri->ri_hw;
976 struct zx_softc *sc = scr->scr_cookie;
977 int32_t xs, xd, y, width, height;
978
979 xs = ri->ri_xorigin + ri->ri_font->fontwidth * srccol;
980 xd = ri->ri_xorigin + ri->ri_font->fontwidth * dstcol;
981 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
982 width = ri->ri_font->fontwidth * ncols;
983 height = ri->ri_font->fontheight;
984 zx_copyrect(sc, xs, y, xd, y, width, height);
985 }
986
987 static void
988 zx_putchar(void *cookie, int row, int col, u_int uc, long attr)
989 {
990 struct rasops_info *ri = cookie;
991 struct vcons_screen *scr = ri->ri_hw;
992 struct zx_softc *sc = scr->scr_cookie;
993 struct wsdisplay_font *font;
994 volatile uint32_t *dp;
995 uint8_t *fb;
996 int fs, i, ul;
997 uint32_t fg, bg;
998
999 rasops_unpack_attr(attr, &fg, &bg, &ul);
1000 bg = ((uint32_t)ri->ri_devcmap[bg]) << 24;
1001 fg = ((uint32_t)ri->ri_devcmap[fg]) << 24;
1002 if (uc == ' ') {
1003 int x, y;
1004
1005 x = ri->ri_xorigin + ri->ri_font->fontwidth * col;
1006 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
1007 zx_fillrect(sc, x, y, ri->ri_font->fontwidth,
1008 ri->ri_font->fontheight, bg, ZX_STD_ROP);
1009 return;
1010 }
1011
1012 font = ri->ri_font;
1013
1014 dp = (volatile uint32_t *)sc->sc_pixels +
1015 ((row * font->fontheight + ri->ri_yorigin) << 11) +
1016 (col * font->fontwidth + ri->ri_xorigin);
1017 fb = (uint8_t *)font->data + (uc - font->firstchar) *
1018 ri->ri_fontscale;
1019 fs = font->stride;
1020
1021 while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) &
1022 ZX_CSR_BLT_BUSY) != 0)
1023 ;
1024
1025 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP);
1026 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, fg);
1027 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_bg, bg);
1028 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontmsk,
1029 0xffffffff << (32 - font->fontwidth));
1030
1031 if (font->fontwidth <= 8) {
1032 for (i = font->fontheight; i != 0; i--, dp += 2048) {
1033 *dp = *fb << 24;
1034 fb += fs;
1035 }
1036 } else {
1037 for (i = font->fontheight; i != 0; i--, dp += 2048) {
1038 *dp = *((uint16_t *)fb) << 16;
1039 fb += fs;
1040 }
1041 }
1042
1043 if (ul) {
1044 dp -= 4096;
1045 *dp = 0xffffffff;
1046 }
1047 }
1048
1049 #if NWSDISPLAY > 0
1050 static int
1051 zx_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
1052 struct lwp *l)
1053 {
1054 /* we'll probably need to add more stuff here */
1055 struct vcons_data *vd = v;
1056 struct zx_softc *sc = vd->cookie;
1057 struct wsdisplay_fbinfo *wdf;
1058 struct rasops_info *ri = &sc->sc_fb.fb_rinfo;
1059 struct vcons_screen *ms = sc->vd.active;
1060 switch (cmd) {
1061 case WSDISPLAYIO_GTYPE:
1062 *(u_int *)data = WSDISPLAY_TYPE_SUNTCX;
1063 return 0;
1064 case WSDISPLAYIO_GINFO:
1065 wdf = (void *)data;
1066 wdf->height = ri->ri_height;
1067 wdf->width = ri->ri_width;
1068 wdf->depth = ri->ri_depth;
1069 wdf->cmsize = 256;
1070 return 0;
1071
1072 case WSDISPLAYIO_GETCMAP:
1073 return zx_getcmap(sc,
1074 (struct wsdisplay_cmap *)data);
1075 case WSDISPLAYIO_PUTCMAP:
1076 return zx_putcmap(sc,
1077 (struct wsdisplay_cmap *)data);
1078
1079 case WSDISPLAYIO_SMODE:
1080 {
1081 int new_mode = *(int*)data;
1082 if (new_mode != sc->sc_mode)
1083 {
1084 sc->sc_mode = new_mode;
1085 if(new_mode == WSDISPLAYIO_MODE_EMUL)
1086 {
1087 vcons_redraw_screen(ms);
1088 }
1089 }
1090 }
1091 }
1092 return EPASSTHROUGH;
1093 }
1094
1095 static paddr_t
1096 zx_mmap(void *v, void *vs, off_t offset, int prot)
1097 {
1098 /* I'm not at all sure this is the right thing to do */
1099 return zxmmap(0, offset, prot); /* assume minor dev 0 for now */
1100 }
1101
1102 static int
1103 zx_putcmap(struct zx_softc *sc, struct wsdisplay_cmap *cm)
1104 {
1105 u_int index = cm->index;
1106 u_int count = cm->count;
1107 int error,i;
1108 if (index >= 256 || count > 256 || index + count > 256)
1109 return EINVAL;
1110
1111 for (i = 0; i < count; i++)
1112 {
1113 error = copyin(&cm->red[i],
1114 &sc->sc_cmap[index + i], 1);
1115 if (error)
1116 return error;
1117 error = copyin(&cm->green[i],
1118 &sc->sc_cmap[index + i + 256], 1);
1119 if (error)
1120 return error;
1121 error = copyin(&cm->blue[i],
1122 &sc->sc_cmap[index + i + 512], 1);
1123 if (error)
1124 return error;
1125 }
1126 zx_cmap_put(sc);
1127
1128 return 0;
1129 }
1130
1131 static int
1132 zx_getcmap(struct zx_softc *sc, struct wsdisplay_cmap *cm)
1133 {
1134 u_int index = cm->index;
1135 u_int count = cm->count;
1136 int error,i;
1137
1138 if (index >= 256 || count > 256 || index + count > 256)
1139 return EINVAL;
1140
1141 for (i = 0; i < count; i++)
1142 {
1143 error = copyout(&sc->sc_cmap[index + i],
1144 &cm->red[i], 1);
1145 if (error)
1146 return error;
1147 error = copyout(&sc->sc_cmap[index + i + 256],
1148 &cm->green[i], 1);
1149 if (error)
1150 return error;
1151 error = copyout(&sc->sc_cmap[index + i + 256],
1152 &cm->blue[i], 1);
1153 if (error)
1154 return error;
1155 }
1156
1157 return 0;
1158 }
1159
1160 static void
1161 zx_init_screen(void *cookie, struct vcons_screen *scr,
1162 int existing, long *defattr)
1163 {
1164 struct zx_softc *sc = cookie;
1165 struct rasops_info *ri = &scr->scr_ri;
1166
1167 ri->ri_depth = 8; /*sc->sc_fb.fb_type.fb_depth = 32;*/
1168 ri->ri_width = sc->sc_width;
1169 ri->ri_height = sc->sc_height;
1170 ri->ri_stride = sc->sc_stride;
1171 ri->ri_flg = RI_CENTER;
1172
1173 ri->ri_bits = (void *)sc->sc_pixels;
1174
1175 rasops_init(ri, sc->sc_height/8, sc->sc_width/8);
1176 ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_REVERSE;
1177 rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
1178 sc->sc_width / ri->ri_font->fontwidth);
1179
1180 ri->ri_hw = scr;
1181
1182 ri->ri_ops.cursor = zx_do_cursor;
1183 ri->ri_ops.copycols = zx_copycols;
1184 ri->ri_ops.copyrows = zx_copyrows;
1185 ri->ri_ops.erasecols = zx_erasecols;
1186 ri->ri_ops.eraserows = zx_eraserows;
1187 ri->ri_ops.putchar = zx_putchar;
1188 }
1189
1190 #endif /* NWSDISPLAY > 0 */
1191