141488Smckusick /* 241488Smckusick * Copyright (c) 1988 University of Utah. 341488Smckusick * Copyright (c) 1990 The Regents of the University of California. 441488Smckusick * All rights reserved. 541488Smckusick * 641488Smckusick * This code is derived from software contributed to Berkeley by 741488Smckusick * the Systems Programming Group of the University of Utah Computer 841488Smckusick * Science Department. 941488Smckusick * 1041488Smckusick * %sccs.include.redist.c% 1141488Smckusick * 1241488Smckusick * from: Utah $Hdr: ite_dv.c 1.1 89/02/28$ 1341488Smckusick * 14*45790Sbostic * @(#)ite_dv.c 7.2 (Berkeley) 12/16/90 1541488Smckusick */ 1641488Smckusick 1741488Smckusick #include "samachdep.h" 1841488Smckusick 1941488Smckusick #ifdef ITECONSOLE 2041488Smckusick 21*45790Sbostic #include "sys/param.h" 22*45790Sbostic #include "../dev/itevar.h" 23*45790Sbostic #include "../dev/itereg.h" 24*45790Sbostic #include "../dev/grfvar.h" 25*45790Sbostic #include "../dev/grf_dvreg.h" 2641488Smckusick 2741488Smckusick #define REGBASE ((struct dvboxfb *)(ip->regbase)) 2841488Smckusick #define WINDOWMOVER dvbox_windowmove 2941488Smckusick 3041488Smckusick dvbox_init(ip) 3141488Smckusick struct ite_softc *ip; 3241488Smckusick { 3341488Smckusick int i; 3441488Smckusick 3541488Smckusick dv_reset(REGADDR); 3641488Smckusick DELAY(4000); 3741488Smckusick 3841488Smckusick /* 3941488Smckusick * Turn on frame buffer, turn on overlay planes, set replacement 4041488Smckusick * rule, enable top overlay plane writes for ite, disable all frame 4141488Smckusick * buffer planes, set byte per pixel, and display frame buffer 0. 4241488Smckusick * Lastly, turn on the box. 4341488Smckusick */ 4441488Smckusick REGBASE->interrupt = 0x04; 4541488Smckusick REGBASE->drive = 0x10; 4641488Smckusick REGBASE->rep_rule = RR_COPY << 4 | RR_COPY; 4741488Smckusick REGBASE->opwen = 0x01; 4841488Smckusick REGBASE->fbwen = 0x0; 4941488Smckusick REGBASE->fold = 0x01; 5041488Smckusick REGBASE->vdrive = 0x0; 5141488Smckusick REGBASE->dispen = 0x01; 5241488Smckusick 5341488Smckusick /* 5441488Smckusick * Video enable top overlay plane. 5541488Smckusick */ 5641488Smckusick REGBASE->opvenp = 0x01; 5741488Smckusick REGBASE->opvens = 0x01; 5841488Smckusick 5941488Smckusick /* 6041488Smckusick * Make sure that overlay planes override frame buffer planes. 6141488Smckusick */ 6241488Smckusick REGBASE->ovly0p = 0x0; 6341488Smckusick REGBASE->ovly0s = 0x0; 6441488Smckusick REGBASE->ovly1p = 0x0; 6541488Smckusick REGBASE->ovly1s = 0x0; 6641488Smckusick REGBASE->fv_trig = 0x1; 6741488Smckusick DELAY(400); 6841488Smckusick 6941488Smckusick /* 7041488Smckusick * Setup the overlay colormaps. Need to set the 0,1 (black/white) 7141488Smckusick * color for both banks. 7241488Smckusick */ 7341488Smckusick 7441488Smckusick for (i = 0; i <= 1; i++) { 7541488Smckusick REGBASE->cmapbank = i; 7641488Smckusick REGBASE->rgb[0].red = 0x00; 7741488Smckusick REGBASE->rgb[0].green = 0x00; 7841488Smckusick REGBASE->rgb[0].blue = 0x00; 7941488Smckusick REGBASE->rgb[1].red = 0xFF; 8041488Smckusick REGBASE->rgb[1].green = 0xFF; 8141488Smckusick REGBASE->rgb[1].blue = 0xFF; 8241488Smckusick } 8341488Smckusick REGBASE->cmapbank = 0; 8441488Smckusick 8541488Smckusick db_waitbusy(REGADDR); 8641488Smckusick 8741488Smckusick ite_devinfo(ip); 8841488Smckusick ite_fontinit(ip); 8941488Smckusick 9041488Smckusick /* 9141488Smckusick * Clear the (visible) framebuffer. 9241488Smckusick */ 9341488Smckusick dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 9441488Smckusick db_waitbusy(REGADDR); 9541488Smckusick 9641488Smckusick /* 9741488Smckusick * Stash the inverted cursor. 9841488Smckusick */ 9941488Smckusick dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 10041488Smckusick ip->cblanky, ip->cblankx, ip->ftheight, 10141488Smckusick ip->ftwidth, RR_COPYINVERTED); 10241488Smckusick db_waitbusy(REGADDR); 10341488Smckusick } 10441488Smckusick 10541488Smckusick dvbox_putc(ip, c, dy, dx, mode) 10641488Smckusick register struct ite_softc *ip; 10741488Smckusick register int dy, dx; 10841488Smckusick int c, mode; 10941488Smckusick { 11041488Smckusick dvbox_windowmove(ip, charY(ip, c), charX(ip, c), 11141488Smckusick dy * ip->ftheight, dx * ip->ftwidth, 11241488Smckusick ip->ftheight, ip->ftwidth, RR_COPY); 11341488Smckusick } 11441488Smckusick 11541488Smckusick dvbox_cursor(ip, flag) 11641488Smckusick register struct ite_softc *ip; 11741488Smckusick register int flag; 11841488Smckusick { 11941488Smckusick if (flag == DRAW_CURSOR) 12041488Smckusick draw_cursor(ip) 12141488Smckusick else if (flag == MOVE_CURSOR) { 12241488Smckusick erase_cursor(ip) 12341488Smckusick draw_cursor(ip) 12441488Smckusick } 12541488Smckusick else 12641488Smckusick erase_cursor(ip) 12741488Smckusick } 12841488Smckusick 12941488Smckusick dvbox_clear(ip, sy, sx, h, w) 13041488Smckusick struct ite_softc *ip; 13141488Smckusick register int sy, sx, h, w; 13241488Smckusick { 13341488Smckusick dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 13441488Smckusick sy * ip->ftheight, sx * ip->ftwidth, 13541488Smckusick h * ip->ftheight, w * ip->ftwidth, 13641488Smckusick RR_CLEAR); 13741488Smckusick } 13841488Smckusick 13941488Smckusick dvbox_scroll(ip, sy, sx, count, dir) 14041488Smckusick register struct ite_softc *ip; 14141488Smckusick register int sy, count; 14241488Smckusick int dir, sx; 14341488Smckusick { 14441488Smckusick register int dy = sy - count; 14541488Smckusick register int height = ip->rows - sy; 14641488Smckusick 14741488Smckusick dvbox_cursor(ip, ERASE_CURSOR); 14841488Smckusick 14941488Smckusick dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 15041488Smckusick dy * ip->ftheight, sx * ip->ftwidth, 15141488Smckusick height * ip->ftheight, 15241488Smckusick ip->cols * ip->ftwidth, RR_COPY); 15341488Smckusick } 15441488Smckusick 15541488Smckusick dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func) 15641488Smckusick struct ite_softc *ip; 15741488Smckusick int sy, sx, dy, dx, h, w, func; 15841488Smckusick { 15941488Smckusick register struct dvboxfb *dp = REGBASE; 16041488Smckusick if (h == 0 || w == 0) 16141488Smckusick return; 16241488Smckusick 16341488Smckusick db_waitbusy(REGADDR); 16441488Smckusick dp->rep_rule = func << 4 | func; 16541488Smckusick dp->source_y = sy; 16641488Smckusick dp->source_x = sx; 16741488Smckusick dp->dest_y = dy; 16841488Smckusick dp->dest_x = dx; 16941488Smckusick dp->wheight = h; 17041488Smckusick dp->wwidth = w; 17141488Smckusick dp->wmove = 1; 17241488Smckusick } 17341488Smckusick 17441488Smckusick dv_reset(dbp) 17541488Smckusick register struct dvboxfb *dbp; 17641488Smckusick { 17741488Smckusick dbp->reset = 0x80; 17841488Smckusick DELAY(400); 17941488Smckusick 18041488Smckusick dbp->interrupt = 0x04; 18141488Smckusick dbp->en_scan = 0x01; 18241488Smckusick dbp->fbwen = ~0; 18341488Smckusick dbp->opwen = ~0; 18441488Smckusick dbp->fold = 0x01; 18541488Smckusick dbp->drive = 0x01; 18641488Smckusick dbp->rep_rule = 0x33; 18741488Smckusick dbp->alt_rr = 0x33; 18841488Smckusick dbp->zrr = 0x33; 18941488Smckusick 19041488Smckusick dbp->fbvenp = 0xFF; 19141488Smckusick dbp->dispen = 0x01; 19241488Smckusick dbp->fbvens = 0x0; 19341488Smckusick dbp->fv_trig = 0x01; 19441488Smckusick DELAY(400); 19541488Smckusick dbp->vdrive = 0x0; 19641488Smckusick dbp->zconfig = 0x0; 19741488Smckusick 19841488Smckusick while (dbp->wbusy & 0x01) 19941488Smckusick DELAY(400); 20041488Smckusick 20141488Smckusick /* 20241488Smckusick * Start of missing ROM code. 20341488Smckusick */ 20441488Smckusick dbp->cmapbank = 0; 20541488Smckusick 20641488Smckusick dbp->red0 = 0; 20741488Smckusick dbp->red1 = 0; 20841488Smckusick dbp->green0 = 0; 20941488Smckusick dbp->green1 = 0; 21041488Smckusick dbp->blue0 = 0; 21141488Smckusick dbp->blue1 = 0; 21241488Smckusick 21341488Smckusick dbp->panxh = 0; 21441488Smckusick dbp->panxl = 0; 21541488Smckusick dbp->panyh = 0; 21641488Smckusick dbp->panyl = 0; 21741488Smckusick dbp->zoom = 0; 21841488Smckusick dbp->cdwidth = 0x50; 21941488Smckusick dbp->chstart = 0x52; 22041488Smckusick dbp->cvwidth = 0x22; 22141488Smckusick dbp->pz_trig = 1; 22241488Smckusick /* 22341488Smckusick * End of missing ROM code. 22441488Smckusick */ 22541488Smckusick } 22641488Smckusick 22741488Smckusick #endif 228