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_rb.c 1.16 91/01/21$ 13 * 14 * @(#)ite_rb.c 7.5 (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 "itevar.h" 28 #include "itereg.h" 29 #include "grf_rbreg.h" 30 31 #include "machine/cpu.h" 32 33 /* XXX */ 34 #include "grfioctl.h" 35 #include "grfvar.h" 36 37 #define REGBASE ((struct rboxfb *)(ip->regbase)) 38 #define WINDOWMOVER rbox_windowmove 39 40 rbox_init(ip) 41 struct ite_softc *ip; 42 { 43 register int i; 44 45 /* XXX */ 46 if (ip->regbase == 0) { 47 struct grf_softc *gp = &grf_softc[ip - ite_softc]; 48 ip->regbase = gp->g_regkva; 49 ip->fbbase = gp->g_fbkva; 50 } 51 52 rb_waitbusy(REGADDR); 53 54 REGBASE->reset = 0x39; 55 DELAY(1000); 56 57 REGBASE->interrupt = 0x04; 58 REGBASE->display_enable = 0x01; 59 REGBASE->video_enable = 0x01; 60 REGBASE->drive = 0x01; 61 REGBASE->vdrive = 0x0; 62 63 ite_devinfo(ip); 64 65 REGBASE->opwen = 0xFF; 66 67 /* 68 * Clear the framebuffer. 69 */ 70 rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 71 rb_waitbusy(REGADDR); 72 73 for(i = 0; i < 16; i++) { 74 *(REGADDR + 0x63c3 + i*4) = 0x0; 75 *(REGADDR + 0x6403 + i*4) = 0x0; 76 *(REGADDR + 0x6803 + i*4) = 0x0; 77 *(REGADDR + 0x6c03 + i*4) = 0x0; 78 *(REGADDR + 0x73c3 + i*4) = 0x0; 79 *(REGADDR + 0x7403 + i*4) = 0x0; 80 *(REGADDR + 0x7803 + i*4) = 0x0; 81 *(REGADDR + 0x7c03 + i*4) = 0x0; 82 } 83 84 REGBASE->rep_rule = 0x33; 85 86 /* 87 * I cannot figure out how to make the blink planes stop. So, we 88 * must set both colormaps so that when the planes blink, and 89 * the secondary colormap is active, we still get text. 90 */ 91 CM1RED[0x00].value = 0x00; 92 CM1GRN[0x00].value = 0x00; 93 CM1BLU[0x00].value = 0x00; 94 CM1RED[0x01].value = 0xFF; 95 CM1GRN[0x01].value = 0xFF; 96 CM1BLU[0x01].value = 0xFF; 97 98 CM2RED[0x00].value = 0x00; 99 CM2GRN[0x00].value = 0x00; 100 CM2BLU[0x00].value = 0x00; 101 CM2RED[0x01].value = 0xFF; 102 CM2GRN[0x01].value = 0xFF; 103 CM2BLU[0x01].value = 0xFF; 104 105 REGBASE->blink = 0x00; 106 REGBASE->write_enable = 0x01; 107 REGBASE->opwen = 0x00; 108 109 ite_fontinit(ip); 110 111 /* 112 * Stash the inverted cursor. 113 */ 114 rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 115 ip->cblanky, ip->cblankx, ip->ftheight, 116 ip->ftwidth, RR_COPYINVERTED); 117 } 118 119 rbox_deinit(ip) 120 struct ite_softc *ip; 121 { 122 rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 123 rb_waitbusy(REGADDR); 124 125 ip->flags &= ~ITE_INITED; 126 } 127 128 rbox_putc(ip, c, dy, dx, mode) 129 register struct ite_softc *ip; 130 register int dy, dx; 131 int c, mode; 132 { 133 register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 134 135 rbox_windowmove(ip, charY(ip, c), charX(ip, c), 136 dy * ip->ftheight, dx * ip->ftwidth, 137 ip->ftheight, ip->ftwidth, wrr); 138 } 139 140 rbox_cursor(ip, flag) 141 register struct ite_softc *ip; 142 register int flag; 143 { 144 if (flag == DRAW_CURSOR) 145 draw_cursor(ip) 146 else if (flag == MOVE_CURSOR) { 147 erase_cursor(ip) 148 draw_cursor(ip) 149 } 150 else 151 erase_cursor(ip) 152 } 153 154 rbox_clear(ip, sy, sx, h, w) 155 struct ite_softc *ip; 156 register int sy, sx, h, w; 157 { 158 rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 159 sy * ip->ftheight, sx * ip->ftwidth, 160 h * ip->ftheight, w * ip->ftwidth, 161 RR_CLEAR); 162 } 163 164 rbox_scroll(ip, sy, sx, count, dir) 165 register struct ite_softc *ip; 166 register int sy, count; 167 int dir, sx; 168 { 169 register int dy; 170 register int dx = sx; 171 register int height = 1; 172 register int width = ip->cols; 173 174 rbox_cursor(ip, ERASE_CURSOR); 175 176 if (dir == SCROLL_UP) { 177 dy = sy - count; 178 height = ip->rows - sy; 179 } 180 else if (dir == SCROLL_DOWN) { 181 dy = sy + count; 182 height = ip->rows - dy - 1; 183 } 184 else if (dir == SCROLL_RIGHT) { 185 dy = sy; 186 dx = sx + count; 187 width = ip->cols - dx; 188 } 189 else { 190 dy = sy; 191 dx = sx - count; 192 width = ip->cols - sx; 193 } 194 195 rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 196 dy * ip->ftheight, dx * ip->ftwidth, 197 height * ip->ftheight, 198 width * ip->ftwidth, RR_COPY); 199 } 200 201 rbox_windowmove(ip, sy, sx, dy, dx, h, w, func) 202 struct ite_softc *ip; 203 int sy, sx, dy, dx, h, w, func; 204 { 205 register struct rboxfb *rp = REGBASE; 206 if (h == 0 || w == 0) 207 return; 208 209 rb_waitbusy(REGADDR); 210 rp->rep_rule = func << 4 | func; 211 rp->source_y = sy; 212 rp->source_x = sx; 213 rp->dest_y = dy; 214 rp->dest_x = dx; 215 rp->wheight = h; 216 rp->wwidth = w; 217 rp->wmove = 1; 218 } 219 #endif 220