141480Smckusick /* 241480Smckusick * Copyright (c) 1988 University of Utah. 341480Smckusick * Copyright (c) 1990 The Regents of the University of California. 441480Smckusick * All rights reserved. 541480Smckusick * 641480Smckusick * This code is derived from software contributed to Berkeley by 741480Smckusick * the Systems Programming Group of the University of Utah Computer 841480Smckusick * Science Department. 941480Smckusick * 1041480Smckusick * %sccs.include.redist.c% 1141480Smckusick * 1245504Smckusick * from: Utah $Hdr: ite_dv.c 1.1 90/07/09$ 1341480Smckusick * 14*49132Skarels * @(#)ite_dv.c 7.4 (Berkeley) 05/04/91 1541480Smckusick */ 1641480Smckusick 1741480Smckusick #include "ite.h" 1841480Smckusick #if NITE > 0 1941480Smckusick 20*49132Skarels #include "param.h" 21*49132Skarels #include "conf.h" 22*49132Skarels #include "proc.h" 23*49132Skarels #include "ioctl.h" 24*49132Skarels #include "tty.h" 25*49132Skarels #include "systm.h" 2641480Smckusick 2741480Smckusick #include "itevar.h" 2841480Smckusick #include "itereg.h" 2941480Smckusick #include "grf_dvreg.h" 3041480Smckusick 31*49132Skarels #include "machine/cpu.h" 3241480Smckusick 3341480Smckusick /* XXX */ 3441480Smckusick #include "grfioctl.h" 3541480Smckusick #include "grfvar.h" 3641480Smckusick 3741480Smckusick #define REGBASE ((struct dvboxfb *)(ip->regbase)) 3841480Smckusick #define WINDOWMOVER dvbox_windowmove 3941480Smckusick 4041480Smckusick dvbox_init(ip) 4141480Smckusick struct ite_softc *ip; 4241480Smckusick { 4341480Smckusick int i; 4441480Smckusick 4541480Smckusick /* XXX */ 4641480Smckusick if (ip->regbase == 0) { 4741480Smckusick struct grfinfo *gi = &grf_softc[ip - ite_softc].g_display; 4841480Smckusick ip->regbase = IOV(gi->gd_regaddr); 4941480Smckusick ip->fbbase = IOV(gi->gd_fbaddr); 5041480Smckusick } 5141480Smckusick 5241480Smckusick dv_reset(REGADDR); 5341480Smckusick 5441480Smckusick /* 5541480Smckusick * Turn on frame buffer, turn on overlay planes, set replacement 5641480Smckusick * rule, enable top overlay plane writes for ite, disable all frame 5741480Smckusick * buffer planes, set byte per pixel, and display frame buffer 0. 5841480Smckusick * Lastly, turn on the box. 5941480Smckusick */ 6041480Smckusick REGBASE->interrupt = 0x04; 6141480Smckusick REGBASE->drive = 0x10; 6241480Smckusick REGBASE->rep_rule = RR_COPY << 4 | RR_COPY; 6341480Smckusick REGBASE->opwen = 0x01; 6441480Smckusick REGBASE->fbwen = 0x0; 6541480Smckusick REGBASE->fold = 0x01; 6641480Smckusick REGBASE->vdrive = 0x0; 6741480Smckusick REGBASE->dispen = 0x01; 6841480Smckusick 6941480Smckusick /* 7041480Smckusick * Video enable top overlay plane. 7141480Smckusick */ 7241480Smckusick REGBASE->opvenp = 0x01; 7341480Smckusick REGBASE->opvens = 0x01; 7441480Smckusick 7541480Smckusick /* 7641480Smckusick * Make sure that overlay planes override frame buffer planes. 7741480Smckusick */ 7841480Smckusick REGBASE->ovly0p = 0x0; 7941480Smckusick REGBASE->ovly0s = 0x0; 8041480Smckusick REGBASE->ovly1p = 0x0; 8141480Smckusick REGBASE->ovly1s = 0x0; 8241480Smckusick REGBASE->fv_trig = 0x1; 8341480Smckusick DELAY(100); 8441480Smckusick 8541480Smckusick /* 8641480Smckusick * Setup the overlay colormaps. Need to set the 0,1 (black/white) 8741480Smckusick * color for both banks. 8841480Smckusick */ 8941480Smckusick 9041480Smckusick for (i = 0; i <= 1; i++) { 9141480Smckusick REGBASE->cmapbank = i; 9241480Smckusick REGBASE->rgb[0].red = 0x00; 9341480Smckusick REGBASE->rgb[0].green = 0x00; 9441480Smckusick REGBASE->rgb[0].blue = 0x00; 9541480Smckusick REGBASE->rgb[1].red = 0xFF; 9641480Smckusick REGBASE->rgb[1].green = 0xFF; 9741480Smckusick REGBASE->rgb[1].blue = 0xFF; 9841480Smckusick } 9941480Smckusick REGBASE->cmapbank = 0; 10041480Smckusick 10141480Smckusick db_waitbusy(REGADDR); 10241480Smckusick 10341480Smckusick ite_devinfo(ip); 10441480Smckusick ite_fontinit(ip); 10541480Smckusick 10641480Smckusick /* 10741480Smckusick * Clear the (visible) framebuffer. 10841480Smckusick */ 10941480Smckusick dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 11041480Smckusick db_waitbusy(REGADDR); 11141480Smckusick 11241480Smckusick /* 11341480Smckusick * Stash the inverted cursor. 11441480Smckusick */ 11541480Smckusick dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 11641480Smckusick ip->cblanky, ip->cblankx, ip->ftheight, 11741480Smckusick ip->ftwidth, RR_COPYINVERTED); 11841480Smckusick } 11941480Smckusick 12041480Smckusick dvbox_deinit(ip) 12141480Smckusick struct ite_softc *ip; 12241480Smckusick { 12341480Smckusick dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 12441480Smckusick db_waitbusy(REGADDR); 12541480Smckusick 12641480Smckusick ip->flags &= ~ITE_INITED; 12741480Smckusick } 12841480Smckusick 12941480Smckusick dvbox_putc(ip, c, dy, dx, mode) 13041480Smckusick register struct ite_softc *ip; 13141480Smckusick register int dy, dx; 13241480Smckusick int c, mode; 13341480Smckusick { 13441480Smckusick register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 13541480Smckusick 13641480Smckusick dvbox_windowmove(ip, charY(ip, c), charX(ip, c), 13741480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 13841480Smckusick ip->ftheight, ip->ftwidth, wrr); 13941480Smckusick } 14041480Smckusick 14141480Smckusick dvbox_cursor(ip, flag) 14241480Smckusick register struct ite_softc *ip; 14341480Smckusick register int flag; 14441480Smckusick { 14541480Smckusick if (flag == DRAW_CURSOR) 14641480Smckusick draw_cursor(ip) 14741480Smckusick else if (flag == MOVE_CURSOR) { 14841480Smckusick erase_cursor(ip) 14941480Smckusick draw_cursor(ip) 15041480Smckusick } 15141480Smckusick else 15241480Smckusick erase_cursor(ip) 15341480Smckusick } 15441480Smckusick 15541480Smckusick dvbox_clear(ip, sy, sx, h, w) 15641480Smckusick struct ite_softc *ip; 15741480Smckusick register int sy, sx, h, w; 15841480Smckusick { 15941480Smckusick dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 16041480Smckusick sy * ip->ftheight, sx * ip->ftwidth, 16141480Smckusick h * ip->ftheight, w * ip->ftwidth, 16241480Smckusick RR_CLEAR); 16341480Smckusick } 16441480Smckusick 16541480Smckusick dvbox_scroll(ip, sy, sx, count, dir) 16641480Smckusick register struct ite_softc *ip; 16741480Smckusick register int sy, count; 16841480Smckusick int dir, sx; 16941480Smckusick { 17041480Smckusick register int dy; 17141480Smckusick register int dx = sx; 17241480Smckusick register int height = 1; 17341480Smckusick register int width = ip->cols; 17441480Smckusick 17541480Smckusick dvbox_cursor(ip, ERASE_CURSOR); 17641480Smckusick 17741480Smckusick if (dir == SCROLL_UP) { 17841480Smckusick dy = sy - count; 17941480Smckusick height = ip->rows - sy; 18041480Smckusick } 18141480Smckusick else if (dir == SCROLL_DOWN) { 18241480Smckusick dy = sy + count; 18341480Smckusick height = ip->rows - dy - 1; 18441480Smckusick } 18541480Smckusick else if (dir == SCROLL_RIGHT) { 18641480Smckusick dy = sy; 18741480Smckusick dx = sx + count; 18841480Smckusick width = ip->cols - dx; 18941480Smckusick } 19041480Smckusick else { 19141480Smckusick dy = sy; 19241480Smckusick dx = sx - count; 19341480Smckusick width = ip->cols - sx; 19441480Smckusick } 19541480Smckusick 19641480Smckusick dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 19741480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 19841480Smckusick height * ip->ftheight, 19941480Smckusick width * ip->ftwidth, RR_COPY); 20041480Smckusick } 20141480Smckusick 20241480Smckusick dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func) 20341480Smckusick struct ite_softc *ip; 20441480Smckusick int sy, sx, dy, dx, h, w, func; 20541480Smckusick { 20641480Smckusick register struct dvboxfb *dp = REGBASE; 20741480Smckusick if (h == 0 || w == 0) 20841480Smckusick return; 20941480Smckusick 21041480Smckusick db_waitbusy(REGADDR); 21141480Smckusick dp->rep_rule = func << 4 | func; 21241480Smckusick dp->source_y = sy; 21341480Smckusick dp->source_x = sx; 21441480Smckusick dp->dest_y = dy; 21541480Smckusick dp->dest_x = dx; 21641480Smckusick dp->wheight = h; 21741480Smckusick dp->wwidth = w; 21841480Smckusick dp->wmove = 1; 21941480Smckusick } 22041480Smckusick #endif 221