zx.c revision 1.37 1 /* $NetBSD: zx.c,v 1.37 2010/11/13 13:52:10 uebayasi 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.37 2010/11/13 13:52:10 uebayasi 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 <dev/sun/fbio.h>
65 #include <dev/sun/fbvar.h>
66
67 #include "wsdisplay.h"
68 #if NWSDISPLAY > 0
69 #include <dev/wscons/wsconsio.h>
70 #include <dev/wsfont/wsfont.h>
71 #include <dev/rasops/rasops.h>
72 #include <dev/wscons/wsdisplay_vconsvar.h>
73
74 #include "opt_wsemul.h"
75 #endif
76
77 #include <dev/sbus/zxreg.h>
78 #include <dev/sbus/zxvar.h>
79 #include <dev/sbus/sbusvar.h>
80
81 #include <dev/wscons/wsconsio.h>
82
83 #include "ioconf.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, cfdata_t, 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 static dev_type_open(zxopen);
144 static dev_type_close(zxclose);
145 static dev_type_ioctl(zxioctl);
146 static dev_type_mmap(zxmmap);
147
148 static struct fbdriver zx_fbdriver = {
149 zx_unblank, zxopen, zxclose, zxioctl, nopoll, zxmmap
150 };
151
152 #if NWSDISPLAY > 0
153 struct wsscreen_descr zx_defaultscreen = {
154 "std",
155 0, 0, /* will be filled in -- XXX shouldn't, it's global */
156 /* doesn't matter - you can't really have more than one leo */
157 NULL, /* textops */
158 8, 16, /* font width/height */
159 WSSCREEN_WSCOLORS, /* capabilities */
160 NULL /* modecookie */
161 };
162
163 static int zx_ioctl(void *, void *, u_long, void *, int, struct lwp *);
164 static paddr_t zx_mmap(void *, void *, off_t, int);
165 static void zx_init_screen(void *, struct vcons_screen *, int, long *);
166
167 static int zx_putcmap(struct zx_softc *, struct wsdisplay_cmap *);
168 static int zx_getcmap(struct zx_softc *, struct wsdisplay_cmap *);
169
170 struct wsdisplay_accessops zx_accessops = {
171 zx_ioctl,
172 zx_mmap,
173 NULL, /* alloc_screen */
174 NULL, /* free_screen */
175 NULL, /* show_screen */
176 NULL, /* load_font */
177 NULL, /* pollc */
178 NULL /* scroll */
179 };
180
181 const struct wsscreen_descr *_zx_scrlist[] = {
182 &zx_defaultscreen
183 };
184
185 struct wsscreen_list zx_screenlist = {
186 sizeof(_zx_scrlist) / sizeof(struct wsscreen_descr *),
187 _zx_scrlist
188 };
189
190
191 extern const u_char rasops_cmap[768];
192
193 static struct vcons_screen zx_console_screen;
194 #endif /* NWSDISPLAY > 0 */
195
196 static int
197 zx_match(device_t parent, cfdata_t cf, void *aux)
198 {
199 struct sbus_attach_args *sa;
200
201 sa = (struct sbus_attach_args *)aux;
202
203 return (strcmp(sa->sa_name, "SUNW,leo") == 0);
204 }
205
206 static void
207 zx_attach(device_t parent, device_t self, void *args)
208 {
209 struct zx_softc *sc;
210 struct sbus_attach_args *sa;
211 bus_space_handle_t bh;
212 bus_space_tag_t bt;
213 struct fbdevice *fb;
214 #if NWSDISPLAY > 0
215 struct wsemuldisplaydev_attach_args aa;
216 struct rasops_info *ri = &zx_console_screen.scr_ri;
217 unsigned long defattr;
218 #endif
219 int isconsole, width, height;
220
221 sc = device_private(self);
222 sc->sc_dv = self;
223
224 sa = args;
225 fb = &sc->sc_fb;
226 bt = sa->sa_bustag;
227 sc->sc_bt = bt;
228 sc->sc_paddr = sbus_bus_addr(bt, sa->sa_slot, sa->sa_offset);
229
230 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_SS0,
231 0x800000, BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE, &bh) != 0) {
232 aprint_error_dev(self, "can't map bits\n");
233 return;
234 }
235 fb->fb_pixels = (void *)bus_space_vaddr(bt, bh);
236 sc->sc_pixels = (uint32_t *)fb->fb_pixels;
237
238 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LC_SS0_USR,
239 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
240 aprint_error_dev(self, "can't map zc\n");
241 return;
242 }
243
244 sc->sc_bhzc = bh;
245
246 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS0,
247 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
248 aprint_error_dev(self, "can't map ld/ss0\n");
249 return;
250 }
251 sc->sc_bhzdss0 = bh;
252
253 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS1,
254 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
255 aprint_error_dev(self, "can't map ld/ss1\n");
256 return;
257 }
258 sc->sc_bhzdss1 = bh;
259
260 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CROSS,
261 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
262 aprint_error_dev(self, "can't map zx\n");
263 return;
264 }
265 sc->sc_bhzx = bh;
266
267 if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CURSOR,
268 PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
269 aprint_error_dev(self, "can't map zcu\n");
270 return;
271 }
272 sc->sc_bhzcu = bh;
273
274 fb->fb_driver = &zx_fbdriver;
275 fb->fb_device = sc->sc_dv;
276 fb->fb_flags = device_cfdata(sc->sc_dv)->cf_flags & FB_USERMASK;
277 fb->fb_pfour = NULL;
278 fb->fb_linebytes = prom_getpropint(sa->sa_node, "linebytes", 8192);
279
280 width = prom_getpropint(sa->sa_node, "width", 1280);
281 height = prom_getpropint(sa->sa_node, "height", 1024);
282 fb_setsize_obp(fb, 32, width, height, sa->sa_node);
283
284 fb->fb_type.fb_cmsize = 256;
285 fb->fb_type.fb_depth = 32;
286 fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
287 fb->fb_type.fb_type = FBTYPE_SUNLEO;
288
289 printf(": %d x %d", fb->fb_type.fb_width, fb->fb_type.fb_height);
290 isconsole = fb_is_console(sa->sa_node);
291 if (isconsole)
292 printf(" (console)");
293 printf("\n");
294
295 if (sa->sa_nintr != 0)
296 bus_intr_establish(bt, sa->sa_pri, IPL_NONE, zx_intr, sc);
297
298 sc->sc_cmap = malloc(768, M_DEVBUF, M_NOWAIT);
299 zx_reset(sc);
300
301 #if NWSDISPLAY > 0
302 sc->sc_width = fb->fb_type.fb_width;
303 sc->sc_stride = 8192; /* 32 bit */
304 sc->sc_height = fb->fb_type.fb_height;
305
306 /* setup rasops and so on for wsdisplay */
307 wsfont_init();
308 sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
309 sc->sc_bg = WS_DEFAULT_BG;
310
311 vcons_init(&sc->vd, sc, &zx_defaultscreen, &zx_accessops);
312 sc->vd.init_screen = zx_init_screen;
313
314 if (isconsole) {
315 /* we mess with zx_console_screen only once */
316 vcons_init_screen(&sc->vd, &zx_console_screen, 1,
317 &defattr);
318 zx_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
319
320 zx_defaultscreen.textops = &ri->ri_ops;
321 zx_defaultscreen.capabilities = WSSCREEN_WSCOLORS;
322 zx_defaultscreen.nrows = ri->ri_rows;
323 zx_defaultscreen.ncols = ri->ri_cols;
324 zx_fillrect(sc, 0, 0, width, height,
325 ri->ri_devcmap[defattr >> 16], ZX_STD_ROP);
326 wsdisplay_cnattach(&zx_defaultscreen, ri, 0, 0, defattr);
327 vcons_replay_msgbuf(&zx_console_screen);
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 uint8_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,
852 (w - 1) | ((h - 1) << 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 w -= 1;
864 h -= 1;
865
866 if (sy < dy || sx < dx) {
867 dir = 0x80000000;
868 sx += w;
869 sy += h;
870 dx += w;
871 dy += h;
872 } else
873 dir = 0;
874
875 while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) &
876 ZX_CSR_BLT_BUSY) != 0)
877 ;
878
879 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP);
880 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent,
881 w | (h << 11) | dir);
882 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_src, sx | (sy << 11));
883 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_copy, dx | (dy << 11));
884 }
885
886 static void
887 zx_do_cursor(void *cookie, int on, int row, int col)
888 {
889 struct rasops_info *ri = cookie;
890 struct vcons_screen *scr = ri->ri_hw;
891 struct zx_softc *sc = scr->scr_cookie;
892 int x, y, wi, he;
893
894 wi = ri->ri_font->fontwidth;
895 he = ri->ri_font->fontheight;
896
897 if (ri->ri_flg & RI_CURSOR) {
898 x = ri->ri_ccol * wi + ri->ri_xorigin;
899 y = ri->ri_crow * he + ri->ri_yorigin;
900 zx_fillrect(sc, x, y, wi, he, 0xff000000,
901 ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE |
902 ZX_ATTR_FORCE_WID);
903 ri->ri_flg &= ~RI_CURSOR;
904 }
905
906 ri->ri_crow = row;
907 ri->ri_ccol = col;
908
909 if (on)
910 {
911 x = ri->ri_ccol * wi + ri->ri_xorigin;
912 y = ri->ri_crow * he + ri->ri_yorigin;
913 zx_fillrect(sc, x, y, wi, he, 0xff000000,
914 ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE |
915 ZX_ATTR_FORCE_WID);
916 ri->ri_flg |= RI_CURSOR;
917 }
918 }
919
920 static void
921 zx_erasecols(void *cookie, int row, int startcol, int ncols, long attr)
922 {
923 struct rasops_info *ri = cookie;
924 struct vcons_screen *scr = ri->ri_hw;
925 struct zx_softc *sc = scr->scr_cookie;
926 int32_t x, y, width, height, bg;
927
928 x = ri->ri_xorigin + ri->ri_font->fontwidth * startcol;
929 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
930 width = ri->ri_font->fontwidth * ncols;
931 height = ri->ri_font->fontheight;
932 bg = ((uint32_t)ri->ri_devcmap[(attr >> 16) & 0xff]) << 24;
933 zx_fillrect(sc, x, y, width, height, bg, ZX_STD_ROP);
934 }
935
936 static void
937 zx_eraserows(void *cookie, int row, int nrows, long attr)
938 {
939 struct rasops_info *ri = cookie;
940 struct vcons_screen *scr = ri->ri_hw;
941 struct zx_softc *sc = scr->scr_cookie;
942 int32_t x, y, width, height, bg;
943
944 if ((row == 0) && (nrows == ri->ri_rows)) {
945 x = y = 0;
946 width = ri->ri_width;
947 height = ri->ri_height;
948 } else {
949 x = ri->ri_xorigin;
950 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
951 width = ri->ri_emuwidth;
952 height = ri->ri_font->fontheight * nrows;
953 }
954 bg = ((uint32_t)ri->ri_devcmap[(attr >> 16) & 0xff]) << 24;
955 zx_fillrect(sc, x, y, width, height, bg, ZX_STD_ROP);
956 }
957
958 static void
959 zx_copyrows(void *cookie, int srcrow, int dstrow, int nrows)
960 {
961 struct rasops_info *ri = cookie;
962 struct vcons_screen *scr = ri->ri_hw;
963 struct zx_softc *sc = scr->scr_cookie;
964 int32_t x, ys, yd, width, height;
965
966 x = ri->ri_xorigin;
967 ys = ri->ri_yorigin + ri->ri_font->fontheight * srcrow;
968 yd = ri->ri_yorigin + ri->ri_font->fontheight * dstrow;
969 width = ri->ri_emuwidth;
970 height = ri->ri_font->fontheight * nrows;
971 zx_copyrect(sc, x, ys, x, yd, width, height);
972 }
973
974 static void
975 zx_copycols(void *cookie, int row, int srccol, int dstcol, int ncols)
976 {
977 struct rasops_info *ri = cookie;
978 struct vcons_screen *scr = ri->ri_hw;
979 struct zx_softc *sc = scr->scr_cookie;
980 int32_t xs, xd, y, width, height;
981
982 xs = ri->ri_xorigin + ri->ri_font->fontwidth * srccol;
983 xd = ri->ri_xorigin + ri->ri_font->fontwidth * dstcol;
984 y = ri->ri_yorigin + ri->ri_font->fontheight * row;
985 width = ri->ri_font->fontwidth * ncols;
986 height = ri->ri_font->fontheight;
987 zx_copyrect(sc, xs, y, xd, y, width, height);
988 }
989
990 static void
991 zx_putchar(void *cookie, int row, int col, u_int uc, long attr)
992 {
993 struct rasops_info *ri = cookie;
994 struct wsdisplay_font *font = PICK_FONT(ri, uc);
995 struct vcons_screen *scr = ri->ri_hw;
996 struct zx_softc *sc = scr->scr_cookie;
997 volatile uint32_t *dp;
998 uint8_t *fb;
999 int fs, i, ul;
1000 uint32_t fg, bg;
1001
1002 rasops_unpack_attr(attr, &fg, &bg, &ul);
1003 bg = ((uint32_t)ri->ri_devcmap[bg]) << 24;
1004 fg = ((uint32_t)ri->ri_devcmap[fg]) << 24;
1005 if (uc == ' ') {
1006 int x, y;
1007
1008 x = ri->ri_xorigin + font->fontwidth * col;
1009 y = ri->ri_yorigin + font->fontheight * row;
1010 zx_fillrect(sc, x, y, font->fontwidth,
1011 font->fontheight, bg, ZX_STD_ROP);
1012 return;
1013 }
1014
1015 dp = (volatile uint32_t *)sc->sc_pixels +
1016 ((row * font->fontheight + ri->ri_yorigin) << 11) +
1017 (col * font->fontwidth + ri->ri_xorigin);
1018 fb = (uint8_t *)font->data + (uc - font->firstchar) *
1019 ri->ri_fontscale;
1020 fs = font->stride;
1021
1022 while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) &
1023 ZX_CSR_BLT_BUSY) != 0)
1024 ;
1025
1026 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP);
1027 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, fg);
1028 bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_bg, bg);
1029 bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontmsk,
1030 0xffffffff << (32 - font->fontwidth));
1031
1032 if (font->fontwidth <= 8) {
1033 for (i = font->fontheight; i != 0; i--, dp += 2048) {
1034 *dp = *fb << 24;
1035 fb += fs;
1036 }
1037 } else {
1038 for (i = font->fontheight; i != 0; i--, dp += 2048) {
1039 *dp = *((uint16_t *)fb) << 16;
1040 fb += fs;
1041 }
1042 }
1043
1044 if (ul) {
1045 dp -= 4096;
1046 *dp = 0xffffffff;
1047 }
1048 }
1049
1050 #if NWSDISPLAY > 0
1051 static int
1052 zx_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
1053 struct lwp *l)
1054 {
1055 /* we'll probably need to add more stuff here */
1056 struct vcons_data *vd = v;
1057 struct zx_softc *sc = vd->cookie;
1058 struct wsdisplay_fbinfo *wdf;
1059 struct rasops_info *ri = &sc->sc_fb.fb_rinfo;
1060 struct vcons_screen *ms = sc->vd.active;
1061 switch (cmd) {
1062 case WSDISPLAYIO_GTYPE:
1063 *(u_int *)data = WSDISPLAY_TYPE_SUNTCX;
1064 return 0;
1065 case WSDISPLAYIO_GINFO:
1066 wdf = (void *)data;
1067 wdf->height = ri->ri_height;
1068 wdf->width = ri->ri_width;
1069 wdf->depth = ri->ri_depth;
1070 wdf->cmsize = 256;
1071 return 0;
1072
1073 case WSDISPLAYIO_GETCMAP:
1074 return zx_getcmap(sc,
1075 (struct wsdisplay_cmap *)data);
1076 case WSDISPLAYIO_PUTCMAP:
1077 return zx_putcmap(sc,
1078 (struct wsdisplay_cmap *)data);
1079
1080 case WSDISPLAYIO_SMODE:
1081 {
1082 int new_mode = *(int*)data;
1083 if (new_mode != sc->sc_mode)
1084 {
1085 sc->sc_mode = new_mode;
1086 if(new_mode == WSDISPLAYIO_MODE_EMUL)
1087 {
1088 zx_reset(sc);
1089 vcons_redraw_screen(ms);
1090 }
1091 }
1092 }
1093 }
1094 return EPASSTHROUGH;
1095 }
1096
1097 static paddr_t
1098 zx_mmap(void *v, void *vs, off_t offset, int prot)
1099 {
1100 /* I'm not at all sure this is the right thing to do */
1101 return zxmmap(0, offset, prot); /* assume minor dev 0 for now */
1102 }
1103
1104 static int
1105 zx_putcmap(struct zx_softc *sc, struct wsdisplay_cmap *cm)
1106 {
1107 u_int index = cm->index;
1108 u_int count = cm->count;
1109 int error,i;
1110 if (index >= 256 || count > 256 || index + count > 256)
1111 return EINVAL;
1112
1113 for (i = 0; i < count; i++)
1114 {
1115 error = copyin(&cm->red[i],
1116 &sc->sc_cmap[index + i], 1);
1117 if (error)
1118 return error;
1119 error = copyin(&cm->green[i],
1120 &sc->sc_cmap[index + i + 256], 1);
1121 if (error)
1122 return error;
1123 error = copyin(&cm->blue[i],
1124 &sc->sc_cmap[index + i + 512], 1);
1125 if (error)
1126 return error;
1127 }
1128 zx_cmap_put(sc);
1129
1130 return 0;
1131 }
1132
1133 static int
1134 zx_getcmap(struct zx_softc *sc, struct wsdisplay_cmap *cm)
1135 {
1136 u_int index = cm->index;
1137 u_int count = cm->count;
1138 int error,i;
1139
1140 if (index >= 256 || count > 256 || index + count > 256)
1141 return EINVAL;
1142
1143 for (i = 0; i < count; i++)
1144 {
1145 error = copyout(&sc->sc_cmap[index + i],
1146 &cm->red[i], 1);
1147 if (error)
1148 return error;
1149 error = copyout(&sc->sc_cmap[index + i + 256],
1150 &cm->green[i], 1);
1151 if (error)
1152 return error;
1153 error = copyout(&sc->sc_cmap[index + i + 256],
1154 &cm->blue[i], 1);
1155 if (error)
1156 return error;
1157 }
1158
1159 return 0;
1160 }
1161
1162 static void
1163 zx_init_screen(void *cookie, struct vcons_screen *scr,
1164 int existing, long *defattr)
1165 {
1166 struct zx_softc *sc = cookie;
1167 struct rasops_info *ri = &scr->scr_ri;
1168
1169 ri->ri_depth = 8; /*sc->sc_fb.fb_type.fb_depth = 32;*/
1170 ri->ri_width = sc->sc_width;
1171 ri->ri_height = sc->sc_height;
1172 ri->ri_stride = sc->sc_stride;
1173 ri->ri_flg = RI_CENTER;
1174
1175 ri->ri_bits = (void *)sc->sc_pixels;
1176
1177 rasops_init(ri, sc->sc_height/8, sc->sc_width/8);
1178 ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_REVERSE;
1179 rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
1180 sc->sc_width / ri->ri_font->fontwidth);
1181
1182 ri->ri_hw = scr;
1183
1184 ri->ri_ops.cursor = zx_do_cursor;
1185 ri->ri_ops.copycols = zx_copycols;
1186 ri->ri_ops.copyrows = zx_copyrows;
1187 ri->ri_ops.erasecols = zx_erasecols;
1188 ri->ri_ops.eraserows = zx_eraserows;
1189 ri->ri_ops.putchar = zx_putchar;
1190 }
1191
1192 #endif /* NWSDISPLAY > 0 */
1193