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