1 /* $NetBSD: ite_dv.c,v 1.1 1997/02/04 03:52:31 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1988 University of Utah. 5 * Copyright (c) 1990, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * the Systems Programming Group of the University of Utah Computer 10 * Science Department. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. All advertising materials mentioning features or use of this software 21 * must display the following acknowledgement: 22 * This product includes software developed by the University of 23 * California, Berkeley and its contributors. 24 * 4. Neither the name of the University nor the names of its contributors 25 * may be used to endorse or promote products derived from this software 26 * without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 * SUCH DAMAGE. 39 * 40 * from: Utah $Hdr: ite_dv.c 1.2 92/01/20$ 41 * 42 * @(#)ite_dv.c 8.1 (Berkeley) 6/10/93 43 */ 44 45 #ifdef ITECONSOLE 46 47 #include <sys/param.h> 48 49 #include <hp300/dev/itereg.h> 50 #include <hp300/dev/grf_dvreg.h> 51 52 #include <hp300/stand/common/samachdep.h> 53 #include <hp300/stand/common/itevar.h> 54 55 #define REGBASE ((struct dvboxfb *)(ip->regbase)) 56 #define WINDOWMOVER dvbox_windowmove 57 58 void dvbox_windowmove __P((struct ite_data *, int, int, int, int, 59 int, int, int)); 60 61 void 62 dvbox_init(ip) 63 struct ite_data *ip; 64 { 65 int i; 66 67 dv_reset(ip->regbase); 68 DELAY(4000); 69 70 /* 71 * Turn on frame buffer, turn on overlay planes, set replacement 72 * rule, enable top overlay plane writes for ite, disable all frame 73 * buffer planes, set byte per pixel, and display frame buffer 0. 74 * Lastly, turn on the box. 75 */ 76 REGBASE->interrupt = 0x04; 77 REGBASE->drive = 0x10; 78 REGBASE->rep_rule = RR_COPY << 4 | RR_COPY; 79 REGBASE->opwen = 0x01; 80 REGBASE->fbwen = 0x0; 81 REGBASE->fold = 0x01; 82 REGBASE->vdrive = 0x0; 83 REGBASE->dispen = 0x01; 84 85 /* 86 * Video enable top overlay plane. 87 */ 88 REGBASE->opvenp = 0x01; 89 REGBASE->opvens = 0x01; 90 91 /* 92 * Make sure that overlay planes override frame buffer planes. 93 */ 94 REGBASE->ovly0p = 0x0; 95 REGBASE->ovly0s = 0x0; 96 REGBASE->ovly1p = 0x0; 97 REGBASE->ovly1s = 0x0; 98 REGBASE->fv_trig = 0x1; 99 DELAY(400); 100 101 /* 102 * Setup the overlay colormaps. Need to set the 0,1 (black/white) 103 * color for both banks. 104 */ 105 106 for (i = 0; i <= 1; i++) { 107 REGBASE->cmapbank = i; 108 REGBASE->rgb[0].red = 0x00; 109 REGBASE->rgb[0].green = 0x00; 110 REGBASE->rgb[0].blue = 0x00; 111 REGBASE->rgb[1].red = 0xFF; 112 REGBASE->rgb[1].green = 0xFF; 113 REGBASE->rgb[1].blue = 0xFF; 114 } 115 REGBASE->cmapbank = 0; 116 117 db_waitbusy(ip->regbase); 118 119 ite_fontinfo(ip); 120 ite_fontinit(ip); 121 122 /* 123 * Clear the (visible) framebuffer. 124 */ 125 dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 126 db_waitbusy(ip->regbase); 127 128 /* 129 * Stash the inverted cursor. 130 */ 131 dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 132 ip->cblanky, ip->cblankx, ip->ftheight, 133 ip->ftwidth, RR_COPYINVERTED); 134 db_waitbusy(ip->regbase); 135 } 136 137 void 138 dvbox_putc(ip, c, dy, dx, mode) 139 register struct ite_data *ip; 140 register int dy, dx; 141 int c, mode; 142 { 143 dvbox_windowmove(ip, charY(ip, c), charX(ip, c), 144 dy * ip->ftheight, dx * ip->ftwidth, 145 ip->ftheight, ip->ftwidth, RR_COPY); 146 } 147 148 void 149 dvbox_cursor(ip, flag) 150 register struct ite_data *ip; 151 register int flag; 152 { 153 if (flag == DRAW_CURSOR) 154 draw_cursor(ip) 155 else if (flag == MOVE_CURSOR) { 156 erase_cursor(ip) 157 draw_cursor(ip) 158 } 159 else 160 erase_cursor(ip) 161 } 162 163 void 164 dvbox_clear(ip, sy, sx, h, w) 165 struct ite_data *ip; 166 register int sy, sx, h, w; 167 { 168 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 169 sy * ip->ftheight, sx * ip->ftwidth, 170 h * ip->ftheight, w * ip->ftwidth, 171 RR_CLEAR); 172 } 173 174 void 175 dvbox_scroll(ip, sy, sx, count, dir) 176 register struct ite_data *ip; 177 register int sy, count; 178 int dir, sx; 179 { 180 register int dy = sy - count; 181 register int height = ip->rows - sy; 182 183 dvbox_cursor(ip, ERASE_CURSOR); 184 185 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 186 dy * ip->ftheight, sx * ip->ftwidth, 187 height * ip->ftheight, 188 ip->cols * ip->ftwidth, RR_COPY); 189 } 190 191 void 192 dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func) 193 struct ite_data *ip; 194 int sy, sx, dy, dx, h, w, func; 195 { 196 register struct dvboxfb *dp = REGBASE; 197 if (h == 0 || w == 0) 198 return; 199 200 db_waitbusy(ip->regbase); 201 dp->rep_rule = func << 4 | func; 202 dp->source_y = sy; 203 dp->source_x = sx; 204 dp->dest_y = dy; 205 dp->dest_x = dx; 206 dp->wheight = h; 207 dp->wwidth = w; 208 dp->wmove = 1; 209 } 210 211 dv_reset(dbp) 212 register struct dvboxfb *dbp; 213 { 214 dbp->reset = 0x80; 215 DELAY(400); 216 217 dbp->interrupt = 0x04; 218 dbp->en_scan = 0x01; 219 dbp->fbwen = ~0; 220 dbp->opwen = ~0; 221 dbp->fold = 0x01; 222 dbp->drive = 0x01; 223 dbp->rep_rule = 0x33; 224 dbp->alt_rr = 0x33; 225 dbp->zrr = 0x33; 226 227 dbp->fbvenp = 0xFF; 228 dbp->dispen = 0x01; 229 dbp->fbvens = 0x0; 230 dbp->fv_trig = 0x01; 231 DELAY(400); 232 dbp->vdrive = 0x0; 233 dbp->zconfig = 0x0; 234 235 while (dbp->wbusy & 0x01) 236 DELAY(400); 237 238 /* 239 * Start of missing ROM code. 240 */ 241 dbp->cmapbank = 0; 242 243 dbp->red0 = 0; 244 dbp->red1 = 0; 245 dbp->green0 = 0; 246 dbp->green1 = 0; 247 dbp->blue0 = 0; 248 dbp->blue1 = 0; 249 250 dbp->panxh = 0; 251 dbp->panxl = 0; 252 dbp->panyh = 0; 253 dbp->panyl = 0; 254 dbp->zoom = 0; 255 dbp->cdwidth = 0x50; 256 dbp->chstart = 0x52; 257 dbp->cvwidth = 0x22; 258 dbp->pz_trig = 1; 259 /* 260 * End of missing ROM code. 261 */ 262 } 263 264 #endif 265