xref: /csrg-svn/sys/hp300/dev/ite_rb.c (revision 49132)
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  *
1245506Smckusick  * from: Utah $Hdr: ite_rb.c 1.1 90/07/09$
1341480Smckusick  *
14*49132Skarels  *	@(#)ite_rb.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_rbreg.h"
3041480Smckusick 
31*49132Skarels #include "machine/cpu.h"
3241480Smckusick 
3341480Smckusick /* XXX */
3441480Smckusick #include "grfioctl.h"
3541480Smckusick #include "grfvar.h"
3641480Smckusick 
3741480Smckusick #define REGBASE		((struct rboxfb *)(ip->regbase))
3841480Smckusick #define WINDOWMOVER	rbox_windowmove
3941480Smckusick 
4041480Smckusick rbox_init(ip)
4141480Smckusick 	struct ite_softc *ip;
4241480Smckusick {
4341480Smckusick 	register 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 	rb_waitbusy(REGADDR);
5341480Smckusick 
5441480Smckusick 	REGBASE->reset = 0x39;
5541480Smckusick 	DELAY(1000);
5641480Smckusick 
5741480Smckusick 	REGBASE->interrupt = 0x04;
5841480Smckusick 	REGBASE->display_enable = 0x01;
5941480Smckusick 	REGBASE->video_enable = 0x01;
6041480Smckusick 	REGBASE->drive = 0x01;
6141480Smckusick 	REGBASE->vdrive = 0x0;
6241480Smckusick 
6341480Smckusick 	ite_devinfo(ip);
6441480Smckusick 
6541480Smckusick 	REGBASE->opwen = 0xFF;
6641480Smckusick 
6741480Smckusick 	/*
6841480Smckusick 	 * Clear the framebuffer.
6941480Smckusick 	 */
7041480Smckusick 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
7141480Smckusick 	rb_waitbusy(REGADDR);
7241480Smckusick 
7341480Smckusick 	for(i = 0; i < 16; i++) {
7441480Smckusick 		*(REGADDR + 0x63c3 + i*4) = 0x0;
7541480Smckusick 		*(REGADDR + 0x6403 + i*4) = 0x0;
7641480Smckusick 		*(REGADDR + 0x6803 + i*4) = 0x0;
7741480Smckusick 		*(REGADDR + 0x6c03 + i*4) = 0x0;
7841480Smckusick 		*(REGADDR + 0x73c3 + i*4) = 0x0;
7941480Smckusick 		*(REGADDR + 0x7403 + i*4) = 0x0;
8041480Smckusick 		*(REGADDR + 0x7803 + i*4) = 0x0;
8141480Smckusick 		*(REGADDR + 0x7c03 + i*4) = 0x0;
8241480Smckusick 	}
8341480Smckusick 
8441480Smckusick 	REGBASE->rep_rule = 0x33;
8541480Smckusick 
8641480Smckusick 	/*
8741480Smckusick 	 * I cannot figure out how to make the blink planes stop. So, we
8841480Smckusick 	 * must set both colormaps so that when the planes blink, and
8941480Smckusick 	 * the secondary colormap is active, we still get text.
9041480Smckusick 	 */
9141480Smckusick 	CM1RED[0x00].value = 0x00;
9241480Smckusick 	CM1GRN[0x00].value = 0x00;
9341480Smckusick 	CM1BLU[0x00].value = 0x00;
9441480Smckusick 	CM1RED[0x01].value = 0xFF;
9541480Smckusick 	CM1GRN[0x01].value = 0xFF;
9641480Smckusick 	CM1BLU[0x01].value = 0xFF;
9741480Smckusick 
9841480Smckusick 	CM2RED[0x00].value = 0x00;
9941480Smckusick 	CM2GRN[0x00].value = 0x00;
10041480Smckusick 	CM2BLU[0x00].value = 0x00;
10141480Smckusick 	CM2RED[0x01].value = 0xFF;
10241480Smckusick 	CM2GRN[0x01].value = 0xFF;
10341480Smckusick 	CM2BLU[0x01].value = 0xFF;
10441480Smckusick 
10541480Smckusick  	REGBASE->blink = 0x00;
10641480Smckusick 	REGBASE->write_enable = 0x01;
10741480Smckusick 	REGBASE->opwen = 0x00;
10841480Smckusick 
10941480Smckusick 	ite_fontinit(ip);
11041480Smckusick 
11141480Smckusick 	/*
11241480Smckusick 	 * Stash the inverted cursor.
11341480Smckusick 	 */
11441480Smckusick 	rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
11541480Smckusick 			    ip->cblanky, ip->cblankx, ip->ftheight,
11641480Smckusick 			    ip->ftwidth, RR_COPYINVERTED);
11741480Smckusick }
11841480Smckusick 
11941480Smckusick rbox_deinit(ip)
12041480Smckusick 	struct ite_softc *ip;
12141480Smckusick {
12241480Smckusick 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
12341480Smckusick 	rb_waitbusy(REGADDR);
12441480Smckusick 
12541480Smckusick    	ip->flags &= ~ITE_INITED;
12641480Smckusick }
12741480Smckusick 
12841480Smckusick rbox_putc(ip, c, dy, dx, mode)
12941480Smckusick 	register struct ite_softc *ip;
13041480Smckusick         register int dy, dx;
13141480Smckusick 	int c, mode;
13241480Smckusick {
13341480Smckusick         register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
13441480Smckusick 
13541480Smckusick 	rbox_windowmove(ip, charY(ip, c), charX(ip, c),
13641480Smckusick 			dy * ip->ftheight, dx * ip->ftwidth,
13741480Smckusick 			ip->ftheight, ip->ftwidth, wrr);
13841480Smckusick }
13941480Smckusick 
14041480Smckusick rbox_cursor(ip, flag)
14141480Smckusick 	register struct ite_softc *ip;
14241480Smckusick         register int flag;
14341480Smckusick {
14441480Smckusick 	if (flag == DRAW_CURSOR)
14541480Smckusick 		draw_cursor(ip)
14641480Smckusick 	else if (flag == MOVE_CURSOR) {
14741480Smckusick 		erase_cursor(ip)
14841480Smckusick 		draw_cursor(ip)
14941480Smckusick 	}
15041480Smckusick 	else
15141480Smckusick 		erase_cursor(ip)
15241480Smckusick }
15341480Smckusick 
15441480Smckusick rbox_clear(ip, sy, sx, h, w)
15541480Smckusick 	struct ite_softc *ip;
15641480Smckusick 	register int sy, sx, h, w;
15741480Smckusick {
15841480Smckusick 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
15941480Smckusick 			sy * ip->ftheight, sx * ip->ftwidth,
16041480Smckusick 			h  * ip->ftheight, w  * ip->ftwidth,
16141480Smckusick 			RR_CLEAR);
16241480Smckusick }
16341480Smckusick 
16441480Smckusick rbox_scroll(ip, sy, sx, count, dir)
16541480Smckusick         register struct ite_softc *ip;
16641480Smckusick         register int sy, count;
16741480Smckusick         int dir, sx;
16841480Smckusick {
16941480Smckusick 	register int dy;
17041480Smckusick 	register int dx = sx;
17141480Smckusick 	register int height = 1;
17241480Smckusick 	register int width = ip->cols;
17341480Smckusick 
17441480Smckusick 	rbox_cursor(ip, ERASE_CURSOR);
17541480Smckusick 
17641480Smckusick 	if (dir == SCROLL_UP) {
17741480Smckusick 		dy = sy - count;
17841480Smckusick 		height = ip->rows - sy;
17941480Smckusick 	}
18041480Smckusick 	else if (dir == SCROLL_DOWN) {
18141480Smckusick 		dy = sy + count;
18241480Smckusick 		height = ip->rows - dy - 1;
18341480Smckusick 	}
18441480Smckusick 	else if (dir == SCROLL_RIGHT) {
18541480Smckusick 		dy = sy;
18641480Smckusick 		dx = sx + count;
18741480Smckusick 		width = ip->cols - dx;
18841480Smckusick 	}
18941480Smckusick 	else {
19041480Smckusick 		dy = sy;
19141480Smckusick 		dx = sx - count;
19241480Smckusick 		width = ip->cols - sx;
19341480Smckusick 	}
19441480Smckusick 
19541480Smckusick 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
19641480Smckusick 			dy * ip->ftheight, dx * ip->ftwidth,
19741480Smckusick 			height * ip->ftheight,
19841480Smckusick 			width  * ip->ftwidth, RR_COPY);
19941480Smckusick }
20041480Smckusick 
20141480Smckusick rbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
20241480Smckusick 	struct ite_softc *ip;
20341480Smckusick 	int sy, sx, dy, dx, h, w, func;
20441480Smckusick {
20541480Smckusick 	register struct rboxfb *rp = REGBASE;
20641480Smckusick 	if (h == 0 || w == 0)
20741480Smckusick 		return;
20841480Smckusick 
20941480Smckusick 	rb_waitbusy(REGADDR);
21041480Smckusick 	rp->rep_rule = func << 4 | func;
21141480Smckusick 	rp->source_y = sy;
21241480Smckusick 	rp->source_x = sx;
21341480Smckusick 	rp->dest_y = dy;
21441480Smckusick 	rp->dest_x = dx;
21541480Smckusick 	rp->wheight = h;
21641480Smckusick 	rp->wwidth  = w;
21741480Smckusick 	rp->wmove = 1;
21841480Smckusick }
21941480Smckusick #endif
220