xref: /csrg-svn/sys/hp300/dev/ite_dv.c (revision 53929)
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*53929Shibler  * from: Utah $Hdr: ite_dv.c 1.8 92/01/21$
1341480Smckusick  *
14*53929Shibler  *	@(#)ite_dv.c	7.6 (Berkeley) 06/05/92
1541480Smckusick  */
1641480Smckusick 
1741480Smckusick #include "ite.h"
1841480Smckusick #if NITE > 0
1941480Smckusick 
2049132Skarels #include "param.h"
2149132Skarels #include "conf.h"
2249132Skarels #include "proc.h"
2349132Skarels #include "ioctl.h"
2449132Skarels #include "tty.h"
2549132Skarels #include "systm.h"
2641480Smckusick 
27*53929Shibler #include "hp/dev/itevar.h"
28*53929Shibler #include "hp/dev/itereg.h"
2941480Smckusick #include "grf_dvreg.h"
3041480Smckusick 
3149132Skarels #include "machine/cpu.h"
3241480Smckusick 
3341480Smckusick /* XXX */
34*53929Shibler #include "hp/dev/grfioctl.h"
35*53929Shibler #include "hp/dev/grfvar.h"
3641480Smckusick 
3741480Smckusick #define REGBASE		((struct dvboxfb *)(ip->regbase))
3841480Smckusick #define WINDOWMOVER	dvbox_windowmove
3941480Smckusick 
4041480Smckusick dvbox_init(ip)
41*53929Shibler 	register struct ite_softc *ip;
4241480Smckusick {
4341480Smckusick 	int i;
4441480Smckusick 
4541480Smckusick 	/* XXX */
4641480Smckusick 	if (ip->regbase == 0) {
47*53929Shibler 		struct grf_softc *gp = ip->grf;
48*53929Shibler 
4949312Shibler 		ip->regbase = gp->g_regkva;
5049312Shibler 		ip->fbbase = gp->g_fbkva;
51*53929Shibler 		ip->fbwidth = gp->g_display.gd_fbwidth;
52*53929Shibler 		ip->fbheight = gp->g_display.gd_fbheight;
53*53929Shibler 		ip->dwidth = gp->g_display.gd_dwidth;
54*53929Shibler 		ip->dheight = gp->g_display.gd_dheight;
5541480Smckusick 	}
5641480Smckusick 
57*53929Shibler 	dv_reset(ip->regbase);
5841480Smckusick 
5941480Smckusick 	/*
6041480Smckusick 	 * Turn on frame buffer, turn on overlay planes, set replacement
6141480Smckusick 	 * rule, enable top overlay plane writes for ite, disable all frame
6241480Smckusick 	 * buffer planes, set byte per pixel, and display frame buffer 0.
6341480Smckusick 	 * Lastly, turn on the box.
6441480Smckusick 	 */
6541480Smckusick 	REGBASE->interrupt = 0x04;
6641480Smckusick 	REGBASE->drive     = 0x10;
6741480Smckusick  	REGBASE->rep_rule  = RR_COPY << 4 | RR_COPY;
6841480Smckusick 	REGBASE->opwen     = 0x01;
6941480Smckusick 	REGBASE->fbwen     = 0x0;
7041480Smckusick 	REGBASE->fold      = 0x01;
7141480Smckusick 	REGBASE->vdrive    = 0x0;
7241480Smckusick 	REGBASE->dispen    = 0x01;
7341480Smckusick 
7441480Smckusick 	/*
7541480Smckusick 	 * Video enable top overlay plane.
7641480Smckusick 	 */
7741480Smckusick 	REGBASE->opvenp = 0x01;
7841480Smckusick 	REGBASE->opvens = 0x01;
7941480Smckusick 
8041480Smckusick 	/*
8141480Smckusick 	 * Make sure that overlay planes override frame buffer planes.
8241480Smckusick 	 */
8341480Smckusick 	REGBASE->ovly0p  = 0x0;
8441480Smckusick 	REGBASE->ovly0s  = 0x0;
8541480Smckusick 	REGBASE->ovly1p  = 0x0;
8641480Smckusick 	REGBASE->ovly1s  = 0x0;
8741480Smckusick 	REGBASE->fv_trig = 0x1;
8841480Smckusick 	DELAY(100);
8941480Smckusick 
9041480Smckusick 	/*
9141480Smckusick 	 * Setup the overlay colormaps. Need to set the 0,1 (black/white)
9241480Smckusick 	 * color for both banks.
9341480Smckusick 	 */
9441480Smckusick 
9541480Smckusick 	for (i = 0; i <= 1; i++) {
9641480Smckusick 		REGBASE->cmapbank = i;
9741480Smckusick 		REGBASE->rgb[0].red   = 0x00;
9841480Smckusick 		REGBASE->rgb[0].green = 0x00;
9941480Smckusick 		REGBASE->rgb[0].blue  = 0x00;
10041480Smckusick 		REGBASE->rgb[1].red   = 0xFF;
10141480Smckusick 		REGBASE->rgb[1].green = 0xFF;
10241480Smckusick 		REGBASE->rgb[1].blue  = 0xFF;
10341480Smckusick 	}
10441480Smckusick 	REGBASE->cmapbank = 0;
10541480Smckusick 
106*53929Shibler 	db_waitbusy(ip->regbase);
10741480Smckusick 
108*53929Shibler 	ite_fontinfo(ip);
10941480Smckusick 	ite_fontinit(ip);
11041480Smckusick 
11141480Smckusick 	/*
11241480Smckusick 	 * Clear the (visible) framebuffer.
11341480Smckusick 	 */
11441480Smckusick 	dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
115*53929Shibler 	db_waitbusy(ip->regbase);
11641480Smckusick 
11741480Smckusick 	/*
11841480Smckusick 	 * Stash the inverted cursor.
11941480Smckusick 	 */
12041480Smckusick 	dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
12141480Smckusick 			 ip->cblanky, ip->cblankx, ip->ftheight,
12241480Smckusick 			 ip->ftwidth, RR_COPYINVERTED);
12341480Smckusick }
12441480Smckusick 
12541480Smckusick dvbox_deinit(ip)
126*53929Shibler 	register struct ite_softc *ip;
12741480Smckusick {
12841480Smckusick 	dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
129*53929Shibler 	db_waitbusy(ip->regbase);
13041480Smckusick 
13141480Smckusick    	ip->flags &= ~ITE_INITED;
13241480Smckusick }
13341480Smckusick 
13441480Smckusick dvbox_putc(ip, c, dy, dx, mode)
13541480Smckusick 	register struct ite_softc *ip;
13641480Smckusick         register int dy, dx;
13741480Smckusick 	int c, mode;
13841480Smckusick {
13941480Smckusick         register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
14041480Smckusick 
14141480Smckusick 	dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
14241480Smckusick 			 dy * ip->ftheight, dx * ip->ftwidth,
14341480Smckusick 			 ip->ftheight, ip->ftwidth, wrr);
14441480Smckusick }
14541480Smckusick 
14641480Smckusick dvbox_cursor(ip, flag)
14741480Smckusick 	register struct ite_softc *ip;
14841480Smckusick         register int flag;
14941480Smckusick {
15041480Smckusick 	if (flag == DRAW_CURSOR)
15141480Smckusick 		draw_cursor(ip)
15241480Smckusick 	else if (flag == MOVE_CURSOR) {
15341480Smckusick 		erase_cursor(ip)
15441480Smckusick 		draw_cursor(ip)
15541480Smckusick 	}
15641480Smckusick 	else
15741480Smckusick 		erase_cursor(ip)
15841480Smckusick }
15941480Smckusick 
16041480Smckusick dvbox_clear(ip, sy, sx, h, w)
16141480Smckusick 	struct ite_softc *ip;
16241480Smckusick 	register int sy, sx, h, w;
16341480Smckusick {
16441480Smckusick 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
16541480Smckusick 			 sy * ip->ftheight, sx * ip->ftwidth,
16641480Smckusick 			 h  * ip->ftheight, w  * ip->ftwidth,
16741480Smckusick 			 RR_CLEAR);
16841480Smckusick }
16941480Smckusick 
17041480Smckusick dvbox_scroll(ip, sy, sx, count, dir)
17141480Smckusick         register struct ite_softc *ip;
17241480Smckusick         register int sy, count;
17341480Smckusick         int dir, sx;
17441480Smckusick {
17541480Smckusick 	register int dy;
17641480Smckusick 	register int dx = sx;
17741480Smckusick 	register int height = 1;
17841480Smckusick 	register int width = ip->cols;
17941480Smckusick 
18041480Smckusick 	dvbox_cursor(ip, ERASE_CURSOR);
18141480Smckusick 
18241480Smckusick 	if (dir == SCROLL_UP) {
18341480Smckusick 		dy = sy - count;
18441480Smckusick 		height = ip->rows - sy;
18541480Smckusick 	}
18641480Smckusick 	else if (dir == SCROLL_DOWN) {
18741480Smckusick 		dy = sy + count;
18841480Smckusick 		height = ip->rows - dy - 1;
18941480Smckusick 	}
19041480Smckusick 	else if (dir == SCROLL_RIGHT) {
19141480Smckusick 		dy = sy;
19241480Smckusick 		dx = sx + count;
19341480Smckusick 		width = ip->cols - dx;
19441480Smckusick 	}
19541480Smckusick 	else {
19641480Smckusick 		dy = sy;
19741480Smckusick 		dx = sx - count;
19841480Smckusick 		width = ip->cols - sx;
19941480Smckusick 	}
20041480Smckusick 
20141480Smckusick 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
20241480Smckusick 			 dy * ip->ftheight, dx * ip->ftwidth,
20341480Smckusick 			 height * ip->ftheight,
20441480Smckusick 			 width  * ip->ftwidth, RR_COPY);
20541480Smckusick }
20641480Smckusick 
20741480Smckusick dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
20841480Smckusick 	struct ite_softc *ip;
20941480Smckusick 	int sy, sx, dy, dx, h, w, func;
21041480Smckusick {
21141480Smckusick 	register struct dvboxfb *dp = REGBASE;
21241480Smckusick 	if (h == 0 || w == 0)
21341480Smckusick 		return;
21441480Smckusick 
215*53929Shibler 	db_waitbusy(ip->regbase);
21641480Smckusick 	dp->rep_rule = func << 4 | func;
21741480Smckusick 	dp->source_y = sy;
21841480Smckusick 	dp->source_x = sx;
21941480Smckusick 	dp->dest_y   = dy;
22041480Smckusick 	dp->dest_x   = dx;
22141480Smckusick 	dp->wheight  = h;
22241480Smckusick 	dp->wwidth   = w;
22341480Smckusick 	dp->wmove    = 1;
22441480Smckusick }
22541480Smckusick #endif
226