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_dv.c 1.9 92/12/20$ 13 * 14 * @(#)ite_dv.c 7.8 (Berkeley) 12/27/92 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_dvreg.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 dvboxfb *)(ip->regbase)) 38 #define WINDOWMOVER dvbox_windowmove 39 40 dvbox_init(ip) 41 register struct ite_softc *ip; 42 { 43 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 dv_reset(ip->regbase); 58 59 /* 60 * Turn on frame buffer, turn on overlay planes, set replacement 61 * rule, enable top overlay plane writes for ite, disable all frame 62 * buffer planes, set byte per pixel, and display frame buffer 0. 63 * Lastly, turn on the box. 64 */ 65 REGBASE->interrupt = 0x04; 66 REGBASE->drive = 0x10; 67 REGBASE->rep_rule = RR_COPY << 4 | RR_COPY; 68 REGBASE->opwen = 0x01; 69 REGBASE->fbwen = 0x0; 70 REGBASE->fold = 0x01; 71 REGBASE->vdrive = 0x0; 72 REGBASE->dispen = 0x01; 73 74 /* 75 * Video enable top overlay plane. 76 */ 77 REGBASE->opvenp = 0x01; 78 REGBASE->opvens = 0x01; 79 80 /* 81 * Make sure that overlay planes override frame buffer planes. 82 */ 83 REGBASE->ovly0p = 0x0; 84 REGBASE->ovly0s = 0x0; 85 REGBASE->ovly1p = 0x0; 86 REGBASE->ovly1s = 0x0; 87 REGBASE->fv_trig = 0x1; 88 DELAY(100); 89 90 /* 91 * Setup the overlay colormaps. Need to set the 0,1 (black/white) 92 * color for both banks. 93 */ 94 95 for (i = 0; i <= 1; i++) { 96 REGBASE->cmapbank = i; 97 REGBASE->rgb[0].red = 0x00; 98 REGBASE->rgb[0].green = 0x00; 99 REGBASE->rgb[0].blue = 0x00; 100 REGBASE->rgb[1].red = 0xFF; 101 REGBASE->rgb[1].green = 0xFF; 102 REGBASE->rgb[1].blue = 0xFF; 103 } 104 REGBASE->cmapbank = 0; 105 106 db_waitbusy(ip->regbase); 107 108 ite_fontinfo(ip); 109 ite_fontinit(ip); 110 111 /* 112 * Clear the (visible) framebuffer. 113 */ 114 dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 115 db_waitbusy(ip->regbase); 116 117 /* 118 * Stash the inverted cursor. 119 */ 120 dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 121 ip->cblanky, ip->cblankx, ip->ftheight, 122 ip->ftwidth, RR_COPYINVERTED); 123 } 124 125 dvbox_deinit(ip) 126 register struct ite_softc *ip; 127 { 128 dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 129 db_waitbusy(ip->regbase); 130 131 ip->flags &= ~ITE_INITED; 132 } 133 134 dvbox_putc(ip, c, dy, dx, mode) 135 register struct ite_softc *ip; 136 register int dy, dx; 137 int c, mode; 138 { 139 register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 140 141 dvbox_windowmove(ip, charY(ip, c), charX(ip, c), 142 dy * ip->ftheight, dx * ip->ftwidth, 143 ip->ftheight, ip->ftwidth, wrr); 144 } 145 146 dvbox_cursor(ip, flag) 147 register struct ite_softc *ip; 148 register int flag; 149 { 150 if (flag == DRAW_CURSOR) 151 draw_cursor(ip) 152 else if (flag == MOVE_CURSOR) { 153 erase_cursor(ip) 154 draw_cursor(ip) 155 } 156 else 157 erase_cursor(ip) 158 } 159 160 dvbox_clear(ip, sy, sx, h, w) 161 struct ite_softc *ip; 162 register int sy, sx, h, w; 163 { 164 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 165 sy * ip->ftheight, sx * ip->ftwidth, 166 h * ip->ftheight, w * ip->ftwidth, 167 RR_CLEAR); 168 } 169 170 dvbox_scroll(ip, sy, sx, count, dir) 171 register struct ite_softc *ip; 172 register int sy, count; 173 int dir, sx; 174 { 175 register int dy; 176 register int dx = sx; 177 register int height = 1; 178 register int width = ip->cols; 179 180 if (dir == SCROLL_UP) { 181 dy = sy - count; 182 height = ip->rows - sy; 183 } 184 else if (dir == SCROLL_DOWN) { 185 dy = sy + count; 186 height = ip->rows - dy - 1; 187 } 188 else if (dir == SCROLL_RIGHT) { 189 dy = sy; 190 dx = sx + count; 191 width = ip->cols - dx; 192 } 193 else { 194 dy = sy; 195 dx = sx - count; 196 width = ip->cols - sx; 197 } 198 199 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 200 dy * ip->ftheight, dx * ip->ftwidth, 201 height * ip->ftheight, 202 width * ip->ftwidth, RR_COPY); 203 } 204 205 dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func) 206 struct ite_softc *ip; 207 int sy, sx, dy, dx, h, w, func; 208 { 209 register struct dvboxfb *dp = REGBASE; 210 if (h == 0 || w == 0) 211 return; 212 213 db_waitbusy(ip->regbase); 214 dp->rep_rule = func << 4 | func; 215 dp->source_y = sy; 216 dp->source_x = sx; 217 dp->dest_y = dy; 218 dp->dest_x = dx; 219 dp->wheight = h; 220 dp->wwidth = w; 221 dp->wmove = 1; 222 } 223 #endif 224