141480Smckusick /* 241480Smckusick * Copyright (c) 1988 University of Utah. 341480Smckusick * Copyright (c) 1990 The Regents of the University of California. 441480Smckusick * All rights reserved. 541480Smckusick * 641480Smckusick * This code is derived from software contributed to Berkeley by 741480Smckusick * the Systems Programming Group of the University of Utah Computer 841480Smckusick * Science Department. 941480Smckusick * 1041480Smckusick * %sccs.include.redist.c% 1141480Smckusick * 12*45504Smckusick * from: Utah $Hdr: ite_dv.c 1.1 90/07/09$ 1341480Smckusick * 14*45504Smckusick * @(#)ite_dv.c 7.2 (Berkeley) 11/04/90 1541480Smckusick */ 1641480Smckusick 1741480Smckusick #include "ite.h" 1841480Smckusick #if NITE > 0 1941480Smckusick 2041480Smckusick #include "param.h" 2141480Smckusick #include "conf.h" 2241480Smckusick #include "user.h" 2341480Smckusick #include "proc.h" 2441480Smckusick #include "ioctl.h" 2541480Smckusick #include "tty.h" 2641480Smckusick #include "systm.h" 2741480Smckusick #include "uio.h" 2841480Smckusick 2941480Smckusick #include "itevar.h" 3041480Smckusick #include "itereg.h" 3141480Smckusick #include "grf_dvreg.h" 3241480Smckusick 3341480Smckusick #include "machine/cpu.h" 3441480Smckusick 3541480Smckusick /* XXX */ 3641480Smckusick #include "grfioctl.h" 3741480Smckusick #include "grfvar.h" 3841480Smckusick 3941480Smckusick #define REGBASE ((struct dvboxfb *)(ip->regbase)) 4041480Smckusick #define WINDOWMOVER dvbox_windowmove 4141480Smckusick 4241480Smckusick dvbox_init(ip) 4341480Smckusick struct ite_softc *ip; 4441480Smckusick { 4541480Smckusick int i; 4641480Smckusick 4741480Smckusick /* XXX */ 4841480Smckusick if (ip->regbase == 0) { 4941480Smckusick struct grfinfo *gi = &grf_softc[ip - ite_softc].g_display; 5041480Smckusick ip->regbase = IOV(gi->gd_regaddr); 5141480Smckusick ip->fbbase = IOV(gi->gd_fbaddr); 5241480Smckusick } 5341480Smckusick 5441480Smckusick dv_reset(REGADDR); 5541480Smckusick 5641480Smckusick /* 5741480Smckusick * Turn on frame buffer, turn on overlay planes, set replacement 5841480Smckusick * rule, enable top overlay plane writes for ite, disable all frame 5941480Smckusick * buffer planes, set byte per pixel, and display frame buffer 0. 6041480Smckusick * Lastly, turn on the box. 6141480Smckusick */ 6241480Smckusick REGBASE->interrupt = 0x04; 6341480Smckusick REGBASE->drive = 0x10; 6441480Smckusick REGBASE->rep_rule = RR_COPY << 4 | RR_COPY; 6541480Smckusick REGBASE->opwen = 0x01; 6641480Smckusick REGBASE->fbwen = 0x0; 6741480Smckusick REGBASE->fold = 0x01; 6841480Smckusick REGBASE->vdrive = 0x0; 6941480Smckusick REGBASE->dispen = 0x01; 7041480Smckusick 7141480Smckusick /* 7241480Smckusick * Video enable top overlay plane. 7341480Smckusick */ 7441480Smckusick REGBASE->opvenp = 0x01; 7541480Smckusick REGBASE->opvens = 0x01; 7641480Smckusick 7741480Smckusick /* 7841480Smckusick * Make sure that overlay planes override frame buffer planes. 7941480Smckusick */ 8041480Smckusick REGBASE->ovly0p = 0x0; 8141480Smckusick REGBASE->ovly0s = 0x0; 8241480Smckusick REGBASE->ovly1p = 0x0; 8341480Smckusick REGBASE->ovly1s = 0x0; 8441480Smckusick REGBASE->fv_trig = 0x1; 8541480Smckusick DELAY(100); 8641480Smckusick 8741480Smckusick /* 8841480Smckusick * Setup the overlay colormaps. Need to set the 0,1 (black/white) 8941480Smckusick * color for both banks. 9041480Smckusick */ 9141480Smckusick 9241480Smckusick for (i = 0; i <= 1; i++) { 9341480Smckusick REGBASE->cmapbank = i; 9441480Smckusick REGBASE->rgb[0].red = 0x00; 9541480Smckusick REGBASE->rgb[0].green = 0x00; 9641480Smckusick REGBASE->rgb[0].blue = 0x00; 9741480Smckusick REGBASE->rgb[1].red = 0xFF; 9841480Smckusick REGBASE->rgb[1].green = 0xFF; 9941480Smckusick REGBASE->rgb[1].blue = 0xFF; 10041480Smckusick } 10141480Smckusick REGBASE->cmapbank = 0; 10241480Smckusick 10341480Smckusick db_waitbusy(REGADDR); 10441480Smckusick 10541480Smckusick ite_devinfo(ip); 10641480Smckusick ite_fontinit(ip); 10741480Smckusick 10841480Smckusick /* 10941480Smckusick * Clear the (visible) framebuffer. 11041480Smckusick */ 11141480Smckusick dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 11241480Smckusick db_waitbusy(REGADDR); 11341480Smckusick 11441480Smckusick /* 11541480Smckusick * Stash the inverted cursor. 11641480Smckusick */ 11741480Smckusick dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 11841480Smckusick ip->cblanky, ip->cblankx, ip->ftheight, 11941480Smckusick ip->ftwidth, RR_COPYINVERTED); 12041480Smckusick } 12141480Smckusick 12241480Smckusick dvbox_deinit(ip) 12341480Smckusick struct ite_softc *ip; 12441480Smckusick { 12541480Smckusick dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 12641480Smckusick db_waitbusy(REGADDR); 12741480Smckusick 12841480Smckusick ip->flags &= ~ITE_INITED; 12941480Smckusick } 13041480Smckusick 13141480Smckusick dvbox_putc(ip, c, dy, dx, mode) 13241480Smckusick register struct ite_softc *ip; 13341480Smckusick register int dy, dx; 13441480Smckusick int c, mode; 13541480Smckusick { 13641480Smckusick register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 13741480Smckusick 13841480Smckusick dvbox_windowmove(ip, charY(ip, c), charX(ip, c), 13941480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 14041480Smckusick ip->ftheight, ip->ftwidth, wrr); 14141480Smckusick } 14241480Smckusick 14341480Smckusick dvbox_cursor(ip, flag) 14441480Smckusick register struct ite_softc *ip; 14541480Smckusick register int flag; 14641480Smckusick { 14741480Smckusick if (flag == DRAW_CURSOR) 14841480Smckusick draw_cursor(ip) 14941480Smckusick else if (flag == MOVE_CURSOR) { 15041480Smckusick erase_cursor(ip) 15141480Smckusick draw_cursor(ip) 15241480Smckusick } 15341480Smckusick else 15441480Smckusick erase_cursor(ip) 15541480Smckusick } 15641480Smckusick 15741480Smckusick dvbox_clear(ip, sy, sx, h, w) 15841480Smckusick struct ite_softc *ip; 15941480Smckusick register int sy, sx, h, w; 16041480Smckusick { 16141480Smckusick dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 16241480Smckusick sy * ip->ftheight, sx * ip->ftwidth, 16341480Smckusick h * ip->ftheight, w * ip->ftwidth, 16441480Smckusick RR_CLEAR); 16541480Smckusick } 16641480Smckusick 16741480Smckusick dvbox_scroll(ip, sy, sx, count, dir) 16841480Smckusick register struct ite_softc *ip; 16941480Smckusick register int sy, count; 17041480Smckusick int dir, sx; 17141480Smckusick { 17241480Smckusick register int dy; 17341480Smckusick register int dx = sx; 17441480Smckusick register int height = 1; 17541480Smckusick register int width = ip->cols; 17641480Smckusick 17741480Smckusick dvbox_cursor(ip, ERASE_CURSOR); 17841480Smckusick 17941480Smckusick if (dir == SCROLL_UP) { 18041480Smckusick dy = sy - count; 18141480Smckusick height = ip->rows - sy; 18241480Smckusick } 18341480Smckusick else if (dir == SCROLL_DOWN) { 18441480Smckusick dy = sy + count; 18541480Smckusick height = ip->rows - dy - 1; 18641480Smckusick } 18741480Smckusick else if (dir == SCROLL_RIGHT) { 18841480Smckusick dy = sy; 18941480Smckusick dx = sx + count; 19041480Smckusick width = ip->cols - dx; 19141480Smckusick } 19241480Smckusick else { 19341480Smckusick dy = sy; 19441480Smckusick dx = sx - count; 19541480Smckusick width = ip->cols - sx; 19641480Smckusick } 19741480Smckusick 19841480Smckusick dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 19941480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 20041480Smckusick height * ip->ftheight, 20141480Smckusick width * ip->ftwidth, RR_COPY); 20241480Smckusick } 20341480Smckusick 20441480Smckusick dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func) 20541480Smckusick struct ite_softc *ip; 20641480Smckusick int sy, sx, dy, dx, h, w, func; 20741480Smckusick { 20841480Smckusick register struct dvboxfb *dp = REGBASE; 20941480Smckusick if (h == 0 || w == 0) 21041480Smckusick return; 21141480Smckusick 21241480Smckusick db_waitbusy(REGADDR); 21341480Smckusick dp->rep_rule = func << 4 | func; 21441480Smckusick dp->source_y = sy; 21541480Smckusick dp->source_x = sx; 21641480Smckusick dp->dest_y = dy; 21741480Smckusick dp->dest_x = dx; 21841480Smckusick dp->wheight = h; 21941480Smckusick dp->wwidth = w; 22041480Smckusick dp->wmove = 1; 22141480Smckusick } 22241480Smckusick #endif 223