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