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 * 12*63728Shibler * from: Utah $Hdr: ite_dv.c 1.10 93/06/25$ 1341480Smckusick * 14*63728Shibler * @(#)ite_dv.c 7.9 (Berkeley) 07/08/93 1541480Smckusick */ 1641480Smckusick 1741480Smckusick #include "ite.h" 1841480Smckusick #if NITE > 0 1941480Smckusick 2056507Sbostic #include <sys/param.h> 2156507Sbostic #include <sys/conf.h> 2256507Sbostic #include <sys/proc.h> 2356507Sbostic #include <sys/ioctl.h> 2456507Sbostic #include <sys/tty.h> 2556507Sbostic #include <sys/systm.h> 2641480Smckusick 2756507Sbostic #include <hp/dev/itevar.h> 2856507Sbostic #include <hp/dev/itereg.h> 2956507Sbostic #include <hp300/dev/grf_dvreg.h> 3041480Smckusick 3156507Sbostic #include <machine/cpu.h> 3241480Smckusick 3341480Smckusick /* XXX */ 3456507Sbostic #include <hp/dev/grfioctl.h> 3556507Sbostic #include <hp/dev/grfvar.h> 3641480Smckusick 3741480Smckusick #define REGBASE ((struct dvboxfb *)(ip->regbase)) 3841480Smckusick #define WINDOWMOVER dvbox_windowmove 3941480Smckusick 4041480Smckusick dvbox_init(ip) 4153929Shibler register struct ite_softc *ip; 4241480Smckusick { 4341480Smckusick int i; 4441480Smckusick 4541480Smckusick /* XXX */ 4641480Smckusick if (ip->regbase == 0) { 4753929Shibler struct grf_softc *gp = ip->grf; 4853929Shibler 4949312Shibler ip->regbase = gp->g_regkva; 5049312Shibler ip->fbbase = gp->g_fbkva; 5153929Shibler ip->fbwidth = gp->g_display.gd_fbwidth; 5253929Shibler ip->fbheight = gp->g_display.gd_fbheight; 5353929Shibler ip->dwidth = gp->g_display.gd_dwidth; 5453929Shibler ip->dheight = gp->g_display.gd_dheight; 55*63728Shibler /* 56*63728Shibler * XXX some displays (e.g. the davinci) appear 57*63728Shibler * to return a display height greater than the 58*63728Shibler * returned FB height. Guess we should go back 59*63728Shibler * to getting the display dimensions from the 60*63728Shibler * fontrom... 61*63728Shibler */ 62*63728Shibler if (ip->dwidth > ip->fbwidth) 63*63728Shibler ip->dwidth = ip->fbwidth; 64*63728Shibler if (ip->dheight > ip->fbheight) 65*63728Shibler ip->dheight = ip->fbheight; 6641480Smckusick } 6741480Smckusick 6853929Shibler dv_reset(ip->regbase); 6941480Smckusick 7041480Smckusick /* 7141480Smckusick * Turn on frame buffer, turn on overlay planes, set replacement 7241480Smckusick * rule, enable top overlay plane writes for ite, disable all frame 7341480Smckusick * buffer planes, set byte per pixel, and display frame buffer 0. 7441480Smckusick * Lastly, turn on the box. 7541480Smckusick */ 7641480Smckusick REGBASE->interrupt = 0x04; 7741480Smckusick REGBASE->drive = 0x10; 7841480Smckusick REGBASE->rep_rule = RR_COPY << 4 | RR_COPY; 7941480Smckusick REGBASE->opwen = 0x01; 8041480Smckusick REGBASE->fbwen = 0x0; 8141480Smckusick REGBASE->fold = 0x01; 8241480Smckusick REGBASE->vdrive = 0x0; 8341480Smckusick REGBASE->dispen = 0x01; 8441480Smckusick 8541480Smckusick /* 8641480Smckusick * Video enable top overlay plane. 8741480Smckusick */ 8841480Smckusick REGBASE->opvenp = 0x01; 8941480Smckusick REGBASE->opvens = 0x01; 9041480Smckusick 9141480Smckusick /* 9241480Smckusick * Make sure that overlay planes override frame buffer planes. 9341480Smckusick */ 9441480Smckusick REGBASE->ovly0p = 0x0; 9541480Smckusick REGBASE->ovly0s = 0x0; 9641480Smckusick REGBASE->ovly1p = 0x0; 9741480Smckusick REGBASE->ovly1s = 0x0; 9841480Smckusick REGBASE->fv_trig = 0x1; 9941480Smckusick DELAY(100); 10041480Smckusick 10141480Smckusick /* 10241480Smckusick * Setup the overlay colormaps. Need to set the 0,1 (black/white) 10341480Smckusick * color for both banks. 10441480Smckusick */ 10541480Smckusick 10641480Smckusick for (i = 0; i <= 1; i++) { 10741480Smckusick REGBASE->cmapbank = i; 10841480Smckusick REGBASE->rgb[0].red = 0x00; 10941480Smckusick REGBASE->rgb[0].green = 0x00; 11041480Smckusick REGBASE->rgb[0].blue = 0x00; 11141480Smckusick REGBASE->rgb[1].red = 0xFF; 11241480Smckusick REGBASE->rgb[1].green = 0xFF; 11341480Smckusick REGBASE->rgb[1].blue = 0xFF; 11441480Smckusick } 11541480Smckusick REGBASE->cmapbank = 0; 11641480Smckusick 11753929Shibler db_waitbusy(ip->regbase); 11841480Smckusick 11953929Shibler ite_fontinfo(ip); 12041480Smckusick ite_fontinit(ip); 12141480Smckusick 12241480Smckusick /* 12341480Smckusick * Clear the (visible) framebuffer. 12441480Smckusick */ 12541480Smckusick dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 12653929Shibler db_waitbusy(ip->regbase); 12741480Smckusick 12841480Smckusick /* 12941480Smckusick * Stash the inverted cursor. 13041480Smckusick */ 13141480Smckusick dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 13241480Smckusick ip->cblanky, ip->cblankx, ip->ftheight, 13341480Smckusick ip->ftwidth, RR_COPYINVERTED); 13441480Smckusick } 13541480Smckusick 13641480Smckusick dvbox_deinit(ip) 13753929Shibler register struct ite_softc *ip; 13841480Smckusick { 13941480Smckusick dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 14053929Shibler db_waitbusy(ip->regbase); 14141480Smckusick 14241480Smckusick ip->flags &= ~ITE_INITED; 14341480Smckusick } 14441480Smckusick 14541480Smckusick dvbox_putc(ip, c, dy, dx, mode) 14641480Smckusick register struct ite_softc *ip; 14741480Smckusick register int dy, dx; 14841480Smckusick int c, mode; 14941480Smckusick { 15041480Smckusick register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 15141480Smckusick 15241480Smckusick dvbox_windowmove(ip, charY(ip, c), charX(ip, c), 15341480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 15441480Smckusick ip->ftheight, ip->ftwidth, wrr); 15541480Smckusick } 15641480Smckusick 15741480Smckusick dvbox_cursor(ip, flag) 15841480Smckusick register struct ite_softc *ip; 15941480Smckusick register int flag; 16041480Smckusick { 16141480Smckusick if (flag == DRAW_CURSOR) 16241480Smckusick draw_cursor(ip) 16341480Smckusick else if (flag == MOVE_CURSOR) { 16441480Smckusick erase_cursor(ip) 16541480Smckusick draw_cursor(ip) 16641480Smckusick } 16741480Smckusick else 16841480Smckusick erase_cursor(ip) 16941480Smckusick } 17041480Smckusick 17141480Smckusick dvbox_clear(ip, sy, sx, h, w) 17241480Smckusick struct ite_softc *ip; 17341480Smckusick register int sy, sx, h, w; 17441480Smckusick { 17541480Smckusick dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 17641480Smckusick sy * ip->ftheight, sx * ip->ftwidth, 17741480Smckusick h * ip->ftheight, w * ip->ftwidth, 17841480Smckusick RR_CLEAR); 17941480Smckusick } 18041480Smckusick 18141480Smckusick dvbox_scroll(ip, sy, sx, count, dir) 18241480Smckusick register struct ite_softc *ip; 18341480Smckusick register int sy, count; 18441480Smckusick int dir, sx; 18541480Smckusick { 18641480Smckusick register int dy; 18741480Smckusick register int dx = sx; 18841480Smckusick register int height = 1; 18941480Smckusick register int width = ip->cols; 19041480Smckusick 19141480Smckusick if (dir == SCROLL_UP) { 19241480Smckusick dy = sy - count; 19341480Smckusick height = ip->rows - sy; 19441480Smckusick } 19541480Smckusick else if (dir == SCROLL_DOWN) { 19641480Smckusick dy = sy + count; 19741480Smckusick height = ip->rows - dy - 1; 19841480Smckusick } 19941480Smckusick else if (dir == SCROLL_RIGHT) { 20041480Smckusick dy = sy; 20141480Smckusick dx = sx + count; 20241480Smckusick width = ip->cols - dx; 20341480Smckusick } 20441480Smckusick else { 20541480Smckusick dy = sy; 20641480Smckusick dx = sx - count; 20741480Smckusick width = ip->cols - sx; 20841480Smckusick } 20941480Smckusick 21041480Smckusick dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 21141480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 21241480Smckusick height * ip->ftheight, 21341480Smckusick width * ip->ftwidth, RR_COPY); 21441480Smckusick } 21541480Smckusick 21641480Smckusick dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func) 21741480Smckusick struct ite_softc *ip; 21841480Smckusick int sy, sx, dy, dx, h, w, func; 21941480Smckusick { 22041480Smckusick register struct dvboxfb *dp = REGBASE; 22141480Smckusick if (h == 0 || w == 0) 22241480Smckusick return; 22341480Smckusick 22453929Shibler db_waitbusy(ip->regbase); 22541480Smckusick dp->rep_rule = func << 4 | func; 22641480Smckusick dp->source_y = sy; 22741480Smckusick dp->source_x = sx; 22841480Smckusick dp->dest_y = dy; 22941480Smckusick dp->dest_x = dx; 23041480Smckusick dp->wheight = h; 23141480Smckusick dp->wwidth = w; 23241480Smckusick dp->wmove = 1; 23341480Smckusick } 23441480Smckusick #endif 235