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*53929Shibler * from: Utah $Hdr: ite_tc.c 1.26 92/01/21$ 1341480Smckusick * 14*53929Shibler * @(#)ite_tc.c 7.5 (Berkeley) 06/05/92 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" 28*53929Shibler #include "hp/dev/grfreg.h" 29*53929Shibler #include "hp/dev/itereg.h" 30*53929Shibler #include "hp/dev/itevar.h" 3141480Smckusick 3249132Skarels #include "machine/cpu.h" 3341480Smckusick 34*53929Shibler /* XXX */ 35*53929Shibler #include "hp/dev/grfioctl.h" 36*53929Shibler #include "hp/dev/grfvar.h" 37*53929Shibler 3841480Smckusick #define REGBASE ((struct tcboxfb *)(ip->regbase)) 3941480Smckusick #define WINDOWMOVER topcat_windowmove 4041480Smckusick 4141480Smckusick topcat_init(ip) 4241480Smckusick register struct ite_softc *ip; 4341480Smckusick { 4441480Smckusick /* XXX */ 4541480Smckusick if (ip->regbase == NULL) { 46*53929Shibler struct grf_softc *gp = ip->grf; 47*53929Shibler 4849310Shibler ip->regbase = gp->g_regkva; 4949310Shibler ip->fbbase = gp->g_fbkva; 50*53929Shibler ip->fbwidth = gp->g_display.gd_fbwidth; 51*53929Shibler ip->fbheight = gp->g_display.gd_fbheight; 52*53929Shibler ip->dwidth = gp->g_display.gd_dwidth; 53*53929Shibler ip->dheight = gp->g_display.gd_dheight; 5441480Smckusick } 5541480Smckusick 5641480Smckusick /* 5749310Shibler * Catseye looks a lot like a topcat, but not completely. 5849310Shibler * So, we set some bits to make it work. 5949310Shibler */ 6049310Shibler if (REGBASE->fbid != GID_TOPCAT) { 6149310Shibler while ((REGBASE->catseye_status & 1)) 6249310Shibler ; 6349310Shibler REGBASE->catseye_status = 0x0; 6449310Shibler REGBASE->vb_select = 0x0; 6549310Shibler REGBASE->tcntrl = 0x0; 6649310Shibler REGBASE->acntrl = 0x0; 6749310Shibler REGBASE->pncntrl = 0x0; 6849310Shibler REGBASE->rug_cmdstat = 0x90; 6949310Shibler } 7049310Shibler 7149310Shibler /* 7241480Smckusick * Determine the number of planes by writing to the first frame 7341480Smckusick * buffer display location, then reading it back. 7441480Smckusick */ 7541480Smckusick REGBASE->wen = ~0; 7641480Smckusick REGBASE->fben = ~0; 7741480Smckusick REGBASE->prr = RR_COPY; 7841480Smckusick *FBBASE = 0xFF; 7941480Smckusick ip->planemask = *FBBASE; 8041480Smckusick 8141480Smckusick /* 8241480Smckusick * Enable reading/writing of all the planes. 8341480Smckusick */ 8441480Smckusick REGBASE->fben = ip->planemask; 8541480Smckusick REGBASE->wen = ip->planemask; 8641480Smckusick REGBASE->ren = ip->planemask; 8741480Smckusick REGBASE->prr = RR_COPY; 8841480Smckusick 89*53929Shibler ite_fontinfo(ip); 9041480Smckusick 9141480Smckusick /* 9241480Smckusick * Clear the framebuffer on all planes. 9341480Smckusick */ 9441480Smckusick topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 95*53929Shibler tc_waitbusy(ip->regbase, ip->planemask); 9641480Smckusick 9741480Smckusick ite_fontinit(ip); 9841480Smckusick 9941480Smckusick /* 10041480Smckusick * Initialize color map for color displays 10141480Smckusick */ 10241480Smckusick if (ip->planemask != 1) { 103*53929Shibler tc_waitbusy(ip->regbase, ip->planemask); 10441480Smckusick REGBASE->nblank = 0x01; 10541480Smckusick 106*53929Shibler tccm_waitbusy(ip->regbase); 10741480Smckusick REGBASE->rdata = 0x0; 10841480Smckusick REGBASE->gdata = 0x0; 10941480Smckusick REGBASE->bdata = 0x0; 11041480Smckusick REGBASE->cindex = 0xFF; 11141480Smckusick REGBASE->strobe = 0xFF; 11241480Smckusick 11341480Smckusick DELAY(100); 114*53929Shibler tccm_waitbusy(ip->regbase); 11541480Smckusick REGBASE->rdata = 0x0; 11641480Smckusick REGBASE->gdata = 0x0; 11741480Smckusick REGBASE->bdata = 0x0; 11841480Smckusick REGBASE->cindex = 0x0; 11941480Smckusick 12041480Smckusick DELAY(100); 121*53929Shibler tccm_waitbusy(ip->regbase); 12241480Smckusick REGBASE->rdata = 0xFF; 12341480Smckusick REGBASE->gdata = 0xFF; 12441480Smckusick REGBASE->bdata = 0xFF; 12541480Smckusick REGBASE->cindex = 0xFE; 12641480Smckusick REGBASE->strobe = 0xFF; 12741480Smckusick 12841480Smckusick DELAY(100); 129*53929Shibler tccm_waitbusy(ip->regbase); 13041480Smckusick REGBASE->rdata = 0x0; 13141480Smckusick REGBASE->gdata = 0x0; 13241480Smckusick REGBASE->bdata = 0x0; 13341480Smckusick REGBASE->cindex = 0x0; 13441480Smckusick } 13541480Smckusick 13641480Smckusick /* 13741480Smckusick * Stash the inverted cursor. 13841480Smckusick */ 13941480Smckusick topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 14041480Smckusick ip->cblanky, ip->cblankx, ip->ftheight, 14141480Smckusick ip->ftwidth, RR_COPYINVERTED); 14241480Smckusick } 14341480Smckusick 14441480Smckusick topcat_deinit(ip) 14541480Smckusick register struct ite_softc *ip; 14641480Smckusick { 14741480Smckusick topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 148*53929Shibler tc_waitbusy(ip->regbase, ip->planemask); 14941480Smckusick 15041480Smckusick REGBASE->nblank = ~0; 15141480Smckusick ip->flags &= ~ITE_INITED; 15241480Smckusick } 15341480Smckusick 15441480Smckusick topcat_putc(ip, c, dy, dx, mode) 15541480Smckusick register struct ite_softc *ip; 15641480Smckusick int c, dy, dx, mode; 15741480Smckusick { 15841480Smckusick int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 15941480Smckusick 16041480Smckusick topcat_windowmove(ip, charY(ip, c), charX(ip, c), 16141480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 16241480Smckusick ip->ftheight, ip->ftwidth, wmrr); 16341480Smckusick } 16441480Smckusick 16541480Smckusick topcat_cursor(ip, flag) 16641480Smckusick register struct ite_softc *ip; 16741480Smckusick register int flag; 16841480Smckusick { 16941480Smckusick if (flag == DRAW_CURSOR) 17041480Smckusick draw_cursor(ip) 17141480Smckusick else if (flag == MOVE_CURSOR) { 17241480Smckusick erase_cursor(ip) 17341480Smckusick draw_cursor(ip) 17441480Smckusick } 17541480Smckusick else 17641480Smckusick erase_cursor(ip) 17741480Smckusick } 17841480Smckusick 17941480Smckusick topcat_clear(ip, sy, sx, h, w) 18041480Smckusick register struct ite_softc *ip; 18141480Smckusick register int sy, sx, h, w; 18241480Smckusick { 18341480Smckusick topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 18441480Smckusick sy * ip->ftheight, sx * ip->ftwidth, 18541480Smckusick h * ip->ftheight, w * ip->ftwidth, 18641480Smckusick RR_CLEAR); 18741480Smckusick } 18841480Smckusick 18941480Smckusick topcat_scroll(ip, sy, sx, count, dir) 19041480Smckusick register struct ite_softc *ip; 19141480Smckusick register int sy, count; 19241480Smckusick int dir, sx; 19341480Smckusick { 19441480Smckusick register int dy; 19541480Smckusick register int dx = sx; 19641480Smckusick register int height = 1; 19741480Smckusick register int width = ip->cols; 19841480Smckusick 19941480Smckusick topcat_cursor(ip, ERASE_CURSOR); 20041480Smckusick 20141480Smckusick if (dir == SCROLL_UP) { 20241480Smckusick dy = sy - count; 20341480Smckusick height = ip->rows - sy; 20441480Smckusick } 20541480Smckusick else if (dir == SCROLL_DOWN) { 20641480Smckusick dy = sy + count; 20741480Smckusick height = ip->rows - dy - 1; 20841480Smckusick } 20941480Smckusick else if (dir == SCROLL_RIGHT) { 21041480Smckusick dy = sy; 21141480Smckusick dx = sx + count; 21241480Smckusick width = ip->cols - dx; 21341480Smckusick } 21441480Smckusick else { 21541480Smckusick dy = sy; 21641480Smckusick dx = sx - count; 21741480Smckusick width = ip->cols - sx; 21841480Smckusick } 21941480Smckusick 22041480Smckusick topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 22141480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 22241480Smckusick height * ip->ftheight, 22341480Smckusick width * ip->ftwidth, RR_COPY); 22441480Smckusick } 22541480Smckusick 22641480Smckusick topcat_windowmove(ip, sy, sx, dy, dx, h, w, func) 22741480Smckusick struct ite_softc *ip; 22841480Smckusick int sy, sx, dy, dx, h, w, func; 22941480Smckusick { 23041480Smckusick register struct tcboxfb *rp = REGBASE; 23141480Smckusick 23241480Smckusick if (h == 0 || w == 0) 23341480Smckusick return; 234*53929Shibler tc_waitbusy(ip->regbase, ip->planemask); 23541480Smckusick rp->wmrr = func; 23641480Smckusick rp->source_y = sy; 23741480Smckusick rp->source_x = sx; 23841480Smckusick rp->dest_y = dy; 23941480Smckusick rp->dest_x = dx; 24041480Smckusick rp->wheight = h; 24141480Smckusick rp->wwidth = w; 24241480Smckusick rp->wmove = ip->planemask; 24341480Smckusick } 24441480Smckusick #endif 245