1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. 9 * 10 * %sccs.include.redist.c% 11 * 12 * from: Utah $Hdr: ite_tc.c 1.25 91/03/25$ 13 * 14 * @(#)ite_tc.c 7.4 (Berkeley) 05/07/91 15 */ 16 17 #include "ite.h" 18 #if NITE > 0 19 20 #include "param.h" 21 #include "conf.h" 22 #include "proc.h" 23 #include "ioctl.h" 24 #include "tty.h" 25 #include "systm.h" 26 27 #include "grf_tcreg.h" 28 #include "itereg.h" 29 #include "itevar.h" 30 31 #include "machine/cpu.h" 32 33 #define REGBASE ((struct tcboxfb *)(ip->regbase)) 34 #define WINDOWMOVER topcat_windowmove 35 36 /* XXX */ 37 #include "grfioctl.h" 38 #include "grfvar.h" 39 40 topcat_init(ip) 41 register struct ite_softc *ip; 42 { 43 /* XXX */ 44 if (ip->regbase == NULL) { 45 struct grf_softc *gp = &grf_softc[ip - ite_softc]; 46 ip->regbase = gp->g_regkva; 47 ip->fbbase = gp->g_fbkva; 48 } 49 50 /* 51 * Catseye looks a lot like a topcat, but not completely. 52 * So, we set some bits to make it work. 53 */ 54 if (REGBASE->fbid != GID_TOPCAT) { 55 while ((REGBASE->catseye_status & 1)) 56 ; 57 REGBASE->catseye_status = 0x0; 58 REGBASE->vb_select = 0x0; 59 REGBASE->tcntrl = 0x0; 60 REGBASE->acntrl = 0x0; 61 REGBASE->pncntrl = 0x0; 62 REGBASE->rug_cmdstat = 0x90; 63 } 64 65 /* 66 * Determine the number of planes by writing to the first frame 67 * buffer display location, then reading it back. 68 */ 69 REGBASE->wen = ~0; 70 REGBASE->fben = ~0; 71 REGBASE->prr = RR_COPY; 72 *FBBASE = 0xFF; 73 ip->planemask = *FBBASE; 74 75 /* 76 * Enable reading/writing of all the planes. 77 */ 78 REGBASE->fben = ip->planemask; 79 REGBASE->wen = ip->planemask; 80 REGBASE->ren = ip->planemask; 81 REGBASE->prr = RR_COPY; 82 83 ite_devinfo(ip); 84 85 /* 86 * Clear the framebuffer on all planes. 87 */ 88 topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 89 tc_waitbusy(REGADDR, ip->planemask); 90 91 ite_fontinit(ip); 92 93 /* 94 * Initialize color map for color displays 95 */ 96 if (ip->planemask != 1) { 97 tc_waitbusy(REGADDR, ip->planemask); 98 REGBASE->nblank = 0x01; 99 100 tccm_waitbusy(REGADDR); 101 REGBASE->rdata = 0x0; 102 REGBASE->gdata = 0x0; 103 REGBASE->bdata = 0x0; 104 REGBASE->cindex = 0xFF; 105 REGBASE->strobe = 0xFF; 106 107 DELAY(100); 108 tccm_waitbusy(REGADDR); 109 REGBASE->rdata = 0x0; 110 REGBASE->gdata = 0x0; 111 REGBASE->bdata = 0x0; 112 REGBASE->cindex = 0x0; 113 114 DELAY(100); 115 tccm_waitbusy(REGADDR); 116 REGBASE->rdata = 0xFF; 117 REGBASE->gdata = 0xFF; 118 REGBASE->bdata = 0xFF; 119 REGBASE->cindex = 0xFE; 120 REGBASE->strobe = 0xFF; 121 122 DELAY(100); 123 tccm_waitbusy(REGADDR); 124 REGBASE->rdata = 0x0; 125 REGBASE->gdata = 0x0; 126 REGBASE->bdata = 0x0; 127 REGBASE->cindex = 0x0; 128 } 129 130 /* 131 * Stash the inverted cursor. 132 */ 133 topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 134 ip->cblanky, ip->cblankx, ip->ftheight, 135 ip->ftwidth, RR_COPYINVERTED); 136 } 137 138 topcat_deinit(ip) 139 register struct ite_softc *ip; 140 { 141 topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 142 tc_waitbusy(REGADDR, ip->planemask); 143 144 REGBASE->nblank = ~0; 145 ip->flags &= ~ITE_INITED; 146 } 147 148 topcat_putc(ip, c, dy, dx, mode) 149 register struct ite_softc *ip; 150 int c, dy, dx, mode; 151 { 152 int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 153 154 topcat_windowmove(ip, charY(ip, c), charX(ip, c), 155 dy * ip->ftheight, dx * ip->ftwidth, 156 ip->ftheight, ip->ftwidth, wmrr); 157 } 158 159 topcat_cursor(ip, flag) 160 register struct ite_softc *ip; 161 register int flag; 162 { 163 if (flag == DRAW_CURSOR) 164 draw_cursor(ip) 165 else if (flag == MOVE_CURSOR) { 166 erase_cursor(ip) 167 draw_cursor(ip) 168 } 169 else 170 erase_cursor(ip) 171 } 172 173 topcat_clear(ip, sy, sx, h, w) 174 register struct ite_softc *ip; 175 register int sy, sx, h, w; 176 { 177 topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 178 sy * ip->ftheight, sx * ip->ftwidth, 179 h * ip->ftheight, w * ip->ftwidth, 180 RR_CLEAR); 181 } 182 183 topcat_scroll(ip, sy, sx, count, dir) 184 register struct ite_softc *ip; 185 register int sy, count; 186 int dir, sx; 187 { 188 register int dy; 189 register int dx = sx; 190 register int height = 1; 191 register int width = ip->cols; 192 193 topcat_cursor(ip, ERASE_CURSOR); 194 195 if (dir == SCROLL_UP) { 196 dy = sy - count; 197 height = ip->rows - sy; 198 } 199 else if (dir == SCROLL_DOWN) { 200 dy = sy + count; 201 height = ip->rows - dy - 1; 202 } 203 else if (dir == SCROLL_RIGHT) { 204 dy = sy; 205 dx = sx + count; 206 width = ip->cols - dx; 207 } 208 else { 209 dy = sy; 210 dx = sx - count; 211 width = ip->cols - sx; 212 } 213 214 topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 215 dy * ip->ftheight, dx * ip->ftwidth, 216 height * ip->ftheight, 217 width * ip->ftwidth, RR_COPY); 218 } 219 220 topcat_windowmove(ip, sy, sx, dy, dx, h, w, func) 221 struct ite_softc *ip; 222 int sy, sx, dy, dx, h, w, func; 223 { 224 register struct tcboxfb *rp = REGBASE; 225 226 if (h == 0 || w == 0) 227 return; 228 tc_waitbusy(REGADDR, ip->planemask); 229 rp->wmrr = func; 230 rp->source_y = sy; 231 rp->source_x = sx; 232 rp->dest_y = dy; 233 rp->dest_x = dx; 234 rp->wheight = h; 235 rp->wwidth = w; 236 rp->wmove = ip->planemask; 237 } 238 #endif 239