1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1990, 1993 4 * The Regents of the University of California. 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_gb.c 1.20 92/12/20$ 13 * 14 * @(#)ite_gb.c 8.1 (Berkeley) 06/10/93 15 */ 16 17 #include "ite.h" 18 #if NITE > 0 19 20 #include <sys/param.h> 21 #include <sys/conf.h> 22 #include <sys/proc.h> 23 #include <sys/ioctl.h> 24 #include <sys/tty.h> 25 #include <sys/systm.h> 26 27 #include <hp/dev/itevar.h> 28 #include <hp/dev/itereg.h> 29 #include <hp300/dev/grf_gbreg.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 gboxfb *)(ip->regbase)) 38 #define WINDOWMOVER gbox_windowmove 39 40 gbox_init(ip) 41 register struct ite_softc *ip; 42 { 43 /* XXX */ 44 if (ip->regbase == 0) { 45 struct grf_softc *gp = ip->grf; 46 47 ip->regbase = gp->g_regkva; 48 ip->fbbase = gp->g_fbkva; 49 ip->fbwidth = gp->g_display.gd_fbwidth; 50 ip->fbheight = gp->g_display.gd_fbheight; 51 ip->dwidth = gp->g_display.gd_dwidth; 52 ip->dheight = gp->g_display.gd_dheight; 53 } 54 55 REGBASE->write_protect = 0x0; 56 REGBASE->interrupt = 0x4; 57 REGBASE->rep_rule = RR_COPY; 58 REGBASE->blink1 = 0xff; 59 REGBASE->blink2 = 0xff; 60 gb_microcode(ip->regbase); 61 REGBASE->sec_interrupt = 0x01; 62 63 /* 64 * Set up the color map entries. We use three entries in the 65 * color map. The first, is for black, the second is for 66 * white, and the very last entry is for the inverted cursor. 67 */ 68 REGBASE->creg_select = 0x00; 69 REGBASE->cmap_red = 0x00; 70 REGBASE->cmap_grn = 0x00; 71 REGBASE->cmap_blu = 0x00; 72 REGBASE->cmap_write = 0x00; 73 gbcm_waitbusy(ip->regbase); 74 75 REGBASE->creg_select = 0x01; 76 REGBASE->cmap_red = 0xFF; 77 REGBASE->cmap_grn = 0xFF; 78 REGBASE->cmap_blu = 0xFF; 79 REGBASE->cmap_write = 0x01; 80 gbcm_waitbusy(ip->regbase); 81 82 REGBASE->creg_select = 0xFF; 83 REGBASE->cmap_red = 0xFF; 84 REGBASE->cmap_grn = 0xFF; 85 REGBASE->cmap_blu = 0xFF; 86 REGBASE->cmap_write = 0x01; 87 gbcm_waitbusy(ip->regbase); 88 89 ite_fontinfo(ip); 90 ite_fontinit(ip); 91 92 /* 93 * Clear the display. This used to be before the font unpacking 94 * but it crashes. Figure it out later. 95 */ 96 gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 97 tile_mover_waitbusy(ip->regbase); 98 99 /* 100 * Stash the inverted cursor. 101 */ 102 gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 103 ip->cblanky, ip->cblankx, ip->ftheight, 104 ip->ftwidth, RR_COPYINVERTED); 105 } 106 107 gbox_deinit(ip) 108 struct ite_softc *ip; 109 { 110 gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 111 tile_mover_waitbusy(ip->regbase); 112 113 ip->flags &= ~ITE_INITED; 114 } 115 116 gbox_putc(ip, c, dy, dx, mode) 117 register struct ite_softc *ip; 118 register int dy, dx; 119 int c, mode; 120 { 121 register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 122 123 gbox_windowmove(ip, charY(ip, c), charX(ip, c), 124 dy * ip->ftheight, dx * ip->ftwidth, 125 ip->ftheight, ip->ftwidth, wrr); 126 } 127 128 gbox_cursor(ip, flag) 129 register struct ite_softc *ip; 130 register int flag; 131 { 132 if (flag == DRAW_CURSOR) 133 draw_cursor(ip) 134 else if (flag == MOVE_CURSOR) { 135 erase_cursor(ip) 136 draw_cursor(ip) 137 } 138 else 139 erase_cursor(ip) 140 } 141 142 gbox_clear(ip, sy, sx, h, w) 143 struct ite_softc *ip; 144 register int sy, sx, h, w; 145 { 146 gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 147 sy * ip->ftheight, sx * ip->ftwidth, 148 h * ip->ftheight, w * ip->ftwidth, 149 RR_CLEAR); 150 } 151 #define gbox_blockmove(ip, sy, sx, dy, dx, h, w) \ 152 gbox_windowmove((ip), \ 153 (sy) * ip->ftheight, \ 154 (sx) * ip->ftwidth, \ 155 (dy) * ip->ftheight, \ 156 (dx) * ip->ftwidth, \ 157 (h) * ip->ftheight, \ 158 (w) * ip->ftwidth, \ 159 RR_COPY) 160 161 gbox_scroll(ip, sy, sx, count, dir) 162 register struct ite_softc *ip; 163 register int sy; 164 int dir, sx, count; 165 { 166 register int height, dy, i; 167 168 tile_mover_waitbusy(ip->regbase); 169 REGBASE->write_protect = 0x0; 170 171 if (dir == SCROLL_UP) { 172 dy = sy - count; 173 height = ip->rows - sy; 174 for (i = 0; i < height; i++) 175 gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols); 176 } 177 else if (dir == SCROLL_DOWN) { 178 dy = sy + count; 179 height = ip->rows - dy; 180 for (i = (height - 1); i >= 0; i--) 181 gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols); 182 } 183 else if (dir == SCROLL_RIGHT) { 184 gbox_blockmove(ip, sy, sx, sy, sx + count, 185 1, ip->cols - (sx + count)); 186 } 187 else { 188 gbox_blockmove(ip, sy, sx, sy, sx - count, 189 1, ip->cols - sx); 190 } 191 } 192 193 gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask) 194 register struct ite_softc *ip; 195 int sy, sx, dy, dx, mask; 196 register int h, w; 197 { 198 register int src, dest; 199 200 src = (sy * 1024) + sx; /* upper left corner in pixels */ 201 dest = (dy * 1024) + dx; 202 203 tile_mover_waitbusy(ip->regbase); 204 REGBASE->width = -(w / 4); 205 REGBASE->height = -(h / 4); 206 if (src < dest) 207 REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask; 208 else { 209 REGBASE->rep_rule = MOVE_UP_LEFT|mask; 210 /* 211 * Adjust to top of lower right tile of the block. 212 */ 213 src = src + ((h - 4) * 1024) + (w - 4); 214 dest= dest + ((h - 4) * 1024) + (w - 4); 215 } 216 FBBASE[dest] = FBBASE[src]; 217 } 218 #endif 219