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*57325Shibler * from: Utah $Hdr: ite_tc.c 1.27 92/12/20$ 1341480Smckusick * 14*57325Shibler * @(#)ite_tc.c 7.7 (Berkeley) 12/27/92 1541480Smckusick */ 1641480Smckusick 1741480Smckusick #include "ite.h" 1841480Smckusick #if NITE > 0 1941480Smckusick 2056507Sbostic #include <sys/param.h> 2156507Sbostic #include <sys/conf.h> 2256507Sbostic #include <sys/proc.h> 2356507Sbostic #include <sys/ioctl.h> 2456507Sbostic #include <sys/tty.h> 2556507Sbostic #include <sys/systm.h> 2641480Smckusick 2756507Sbostic #include <hp300/dev/grf_tcreg.h> 2856507Sbostic #include <hp/dev/grfreg.h> 2956507Sbostic #include <hp/dev/itereg.h> 3056507Sbostic #include <hp/dev/itevar.h> 3141480Smckusick 3256507Sbostic #include <machine/cpu.h> 3341480Smckusick 3453929Shibler /* XXX */ 3556507Sbostic #include <hp/dev/grfioctl.h> 3656507Sbostic #include <hp/dev/grfvar.h> 3753929Shibler 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) { 4653929Shibler struct grf_softc *gp = ip->grf; 4753929Shibler 4849310Shibler ip->regbase = gp->g_regkva; 4949310Shibler ip->fbbase = gp->g_fbkva; 5053929Shibler ip->fbwidth = gp->g_display.gd_fbwidth; 5153929Shibler ip->fbheight = gp->g_display.gd_fbheight; 5253929Shibler ip->dwidth = gp->g_display.gd_dwidth; 5353929Shibler 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 8953929Shibler 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); 9553929Shibler 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) { 10353929Shibler tc_waitbusy(ip->regbase, ip->planemask); 10441480Smckusick REGBASE->nblank = 0x01; 10541480Smckusick 10653929Shibler 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); 11453929Shibler tccm_waitbusy(ip->regbase); 11541480Smckusick REGBASE->rdata = 0x0; 11641480Smckusick REGBASE->gdata = 0x0; 11741480Smckusick REGBASE->bdata = 0x0; 11841480Smckusick REGBASE->cindex = 0x0; 11941480Smckusick 12041480Smckusick DELAY(100); 12153929Shibler 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); 12953929Shibler 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); 14853929Shibler 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 if (dir == SCROLL_UP) { 20041480Smckusick dy = sy - count; 20141480Smckusick height = ip->rows - sy; 20241480Smckusick } 20341480Smckusick else if (dir == SCROLL_DOWN) { 20441480Smckusick dy = sy + count; 20541480Smckusick height = ip->rows - dy - 1; 20641480Smckusick } 20741480Smckusick else if (dir == SCROLL_RIGHT) { 20841480Smckusick dy = sy; 20941480Smckusick dx = sx + count; 21041480Smckusick width = ip->cols - dx; 21141480Smckusick } 21241480Smckusick else { 21341480Smckusick dy = sy; 21441480Smckusick dx = sx - count; 21541480Smckusick width = ip->cols - sx; 21641480Smckusick } 21741480Smckusick 21841480Smckusick topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 21941480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 22041480Smckusick height * ip->ftheight, 22141480Smckusick width * ip->ftwidth, RR_COPY); 22241480Smckusick } 22341480Smckusick 22441480Smckusick topcat_windowmove(ip, sy, sx, dy, dx, h, w, func) 22541480Smckusick struct ite_softc *ip; 22641480Smckusick int sy, sx, dy, dx, h, w, func; 22741480Smckusick { 22841480Smckusick register struct tcboxfb *rp = REGBASE; 22941480Smckusick 23041480Smckusick if (h == 0 || w == 0) 23141480Smckusick return; 23253929Shibler tc_waitbusy(ip->regbase, ip->planemask); 23341480Smckusick rp->wmrr = func; 23441480Smckusick rp->source_y = sy; 23541480Smckusick rp->source_x = sx; 23641480Smckusick rp->dest_y = dy; 23741480Smckusick rp->dest_x = dx; 23841480Smckusick rp->wheight = h; 23941480Smckusick rp->wwidth = w; 24041480Smckusick rp->wmove = ip->planemask; 24141480Smckusick } 24241480Smckusick #endif 243