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