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*49310Shibler * from: Utah $Hdr: ite_tc.c 1.25 91/03/25$ 1341480Smckusick * 14*49310Shibler * @(#)ite_tc.c 7.4 (Berkeley) 05/07/91 1541480Smckusick */ 1641480Smckusick 1741480Smckusick #include "ite.h" 1841480Smckusick #if NITE > 0 1941480Smckusick 2049132Skarels #include "param.h" 2149132Skarels #include "conf.h" 2249132Skarels #include "proc.h" 2349132Skarels #include "ioctl.h" 2449132Skarels #include "tty.h" 2549132Skarels #include "systm.h" 2641480Smckusick 2741480Smckusick #include "grf_tcreg.h" 2841480Smckusick #include "itereg.h" 2941480Smckusick #include "itevar.h" 3041480Smckusick 3149132Skarels #include "machine/cpu.h" 3241480Smckusick 3341480Smckusick #define REGBASE ((struct tcboxfb *)(ip->regbase)) 3441480Smckusick #define WINDOWMOVER topcat_windowmove 3541480Smckusick 3641480Smckusick /* XXX */ 3741480Smckusick #include "grfioctl.h" 3841480Smckusick #include "grfvar.h" 3941480Smckusick 4041480Smckusick topcat_init(ip) 4141480Smckusick register struct ite_softc *ip; 4241480Smckusick { 4341480Smckusick /* XXX */ 4441480Smckusick if (ip->regbase == NULL) { 45*49310Shibler struct grf_softc *gp = &grf_softc[ip - ite_softc]; 46*49310Shibler ip->regbase = gp->g_regkva; 47*49310Shibler ip->fbbase = gp->g_fbkva; 4841480Smckusick } 4941480Smckusick 5041480Smckusick /* 51*49310Shibler * Catseye looks a lot like a topcat, but not completely. 52*49310Shibler * So, we set some bits to make it work. 53*49310Shibler */ 54*49310Shibler if (REGBASE->fbid != GID_TOPCAT) { 55*49310Shibler while ((REGBASE->catseye_status & 1)) 56*49310Shibler ; 57*49310Shibler REGBASE->catseye_status = 0x0; 58*49310Shibler REGBASE->vb_select = 0x0; 59*49310Shibler REGBASE->tcntrl = 0x0; 60*49310Shibler REGBASE->acntrl = 0x0; 61*49310Shibler REGBASE->pncntrl = 0x0; 62*49310Shibler REGBASE->rug_cmdstat = 0x90; 63*49310Shibler } 64*49310Shibler 65*49310Shibler /* 6641480Smckusick * Determine the number of planes by writing to the first frame 6741480Smckusick * buffer display location, then reading it back. 6841480Smckusick */ 6941480Smckusick REGBASE->wen = ~0; 7041480Smckusick REGBASE->fben = ~0; 7141480Smckusick REGBASE->prr = RR_COPY; 7241480Smckusick *FBBASE = 0xFF; 7341480Smckusick ip->planemask = *FBBASE; 7441480Smckusick 7541480Smckusick /* 7641480Smckusick * Enable reading/writing of all the planes. 7741480Smckusick */ 7841480Smckusick REGBASE->fben = ip->planemask; 7941480Smckusick REGBASE->wen = ip->planemask; 8041480Smckusick REGBASE->ren = ip->planemask; 8141480Smckusick REGBASE->prr = RR_COPY; 8241480Smckusick 8341480Smckusick ite_devinfo(ip); 8441480Smckusick 8541480Smckusick /* 8641480Smckusick * Clear the framebuffer on all planes. 8741480Smckusick */ 8841480Smckusick topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 8941480Smckusick tc_waitbusy(REGADDR, ip->planemask); 9041480Smckusick 9141480Smckusick ite_fontinit(ip); 9241480Smckusick 9341480Smckusick /* 9441480Smckusick * Initialize color map for color displays 9541480Smckusick */ 9641480Smckusick if (ip->planemask != 1) { 9741480Smckusick tc_waitbusy(REGADDR, ip->planemask); 9841480Smckusick REGBASE->nblank = 0x01; 9941480Smckusick 10041480Smckusick tccm_waitbusy(REGADDR); 10141480Smckusick REGBASE->rdata = 0x0; 10241480Smckusick REGBASE->gdata = 0x0; 10341480Smckusick REGBASE->bdata = 0x0; 10441480Smckusick REGBASE->cindex = 0xFF; 10541480Smckusick REGBASE->strobe = 0xFF; 10641480Smckusick 10741480Smckusick DELAY(100); 10841480Smckusick tccm_waitbusy(REGADDR); 10941480Smckusick REGBASE->rdata = 0x0; 11041480Smckusick REGBASE->gdata = 0x0; 11141480Smckusick REGBASE->bdata = 0x0; 11241480Smckusick REGBASE->cindex = 0x0; 11341480Smckusick 11441480Smckusick DELAY(100); 11541480Smckusick tccm_waitbusy(REGADDR); 11641480Smckusick REGBASE->rdata = 0xFF; 11741480Smckusick REGBASE->gdata = 0xFF; 11841480Smckusick REGBASE->bdata = 0xFF; 11941480Smckusick REGBASE->cindex = 0xFE; 12041480Smckusick REGBASE->strobe = 0xFF; 12141480Smckusick 12241480Smckusick DELAY(100); 12341480Smckusick tccm_waitbusy(REGADDR); 12441480Smckusick REGBASE->rdata = 0x0; 12541480Smckusick REGBASE->gdata = 0x0; 12641480Smckusick REGBASE->bdata = 0x0; 12741480Smckusick REGBASE->cindex = 0x0; 12841480Smckusick } 12941480Smckusick 13041480Smckusick /* 13141480Smckusick * Stash the inverted cursor. 13241480Smckusick */ 13341480Smckusick topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 13441480Smckusick ip->cblanky, ip->cblankx, ip->ftheight, 13541480Smckusick ip->ftwidth, RR_COPYINVERTED); 13641480Smckusick } 13741480Smckusick 13841480Smckusick topcat_deinit(ip) 13941480Smckusick register struct ite_softc *ip; 14041480Smckusick { 14141480Smckusick topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 14241480Smckusick tc_waitbusy(REGADDR, ip->planemask); 14341480Smckusick 14441480Smckusick REGBASE->nblank = ~0; 14541480Smckusick ip->flags &= ~ITE_INITED; 14641480Smckusick } 14741480Smckusick 14841480Smckusick topcat_putc(ip, c, dy, dx, mode) 14941480Smckusick register struct ite_softc *ip; 15041480Smckusick int c, dy, dx, mode; 15141480Smckusick { 15241480Smckusick int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 15341480Smckusick 15441480Smckusick topcat_windowmove(ip, charY(ip, c), charX(ip, c), 15541480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 15641480Smckusick ip->ftheight, ip->ftwidth, wmrr); 15741480Smckusick } 15841480Smckusick 15941480Smckusick topcat_cursor(ip, flag) 16041480Smckusick register struct ite_softc *ip; 16141480Smckusick register int flag; 16241480Smckusick { 16341480Smckusick if (flag == DRAW_CURSOR) 16441480Smckusick draw_cursor(ip) 16541480Smckusick else if (flag == MOVE_CURSOR) { 16641480Smckusick erase_cursor(ip) 16741480Smckusick draw_cursor(ip) 16841480Smckusick } 16941480Smckusick else 17041480Smckusick erase_cursor(ip) 17141480Smckusick } 17241480Smckusick 17341480Smckusick topcat_clear(ip, sy, sx, h, w) 17441480Smckusick register struct ite_softc *ip; 17541480Smckusick register int sy, sx, h, w; 17641480Smckusick { 17741480Smckusick topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 17841480Smckusick sy * ip->ftheight, sx * ip->ftwidth, 17941480Smckusick h * ip->ftheight, w * ip->ftwidth, 18041480Smckusick RR_CLEAR); 18141480Smckusick } 18241480Smckusick 18341480Smckusick topcat_scroll(ip, sy, sx, count, dir) 18441480Smckusick register struct ite_softc *ip; 18541480Smckusick register int sy, count; 18641480Smckusick int dir, sx; 18741480Smckusick { 18841480Smckusick register int dy; 18941480Smckusick register int dx = sx; 19041480Smckusick register int height = 1; 19141480Smckusick register int width = ip->cols; 19241480Smckusick 19341480Smckusick topcat_cursor(ip, ERASE_CURSOR); 19441480Smckusick 19541480Smckusick if (dir == SCROLL_UP) { 19641480Smckusick dy = sy - count; 19741480Smckusick height = ip->rows - sy; 19841480Smckusick } 19941480Smckusick else if (dir == SCROLL_DOWN) { 20041480Smckusick dy = sy + count; 20141480Smckusick height = ip->rows - dy - 1; 20241480Smckusick } 20341480Smckusick else if (dir == SCROLL_RIGHT) { 20441480Smckusick dy = sy; 20541480Smckusick dx = sx + count; 20641480Smckusick width = ip->cols - dx; 20741480Smckusick } 20841480Smckusick else { 20941480Smckusick dy = sy; 21041480Smckusick dx = sx - count; 21141480Smckusick width = ip->cols - sx; 21241480Smckusick } 21341480Smckusick 21441480Smckusick topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 21541480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 21641480Smckusick height * ip->ftheight, 21741480Smckusick width * ip->ftwidth, RR_COPY); 21841480Smckusick } 21941480Smckusick 22041480Smckusick topcat_windowmove(ip, sy, sx, dy, dx, h, w, func) 22141480Smckusick struct ite_softc *ip; 22241480Smckusick int sy, sx, dy, dx, h, w, func; 22341480Smckusick { 22441480Smckusick register struct tcboxfb *rp = REGBASE; 22541480Smckusick 22641480Smckusick if (h == 0 || w == 0) 22741480Smckusick return; 22841480Smckusick tc_waitbusy(REGADDR, ip->planemask); 22941480Smckusick rp->wmrr = func; 23041480Smckusick rp->source_y = sy; 23141480Smckusick rp->source_x = sx; 23241480Smckusick rp->dest_y = dy; 23341480Smckusick rp->dest_x = dx; 23441480Smckusick rp->wheight = h; 23541480Smckusick rp->wwidth = w; 23641480Smckusick rp->wmove = ip->planemask; 23741480Smckusick } 23841480Smckusick #endif 239