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