xref: /csrg-svn/sys/hp300/dev/ite_tc.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  *
1241480Smckusick  * from: Utah $Hdr: ite_tc.c 1.22 89/04/11$
1341480Smckusick  *
14*49132Skarels  *	@(#)ite_tc.c	7.3 (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 "grf_tcreg.h"
2841480Smckusick #include "itereg.h"
2941480Smckusick #include "itevar.h"
3041480Smckusick 
31*49132Skarels #include "machine/cpu.h"
3241480Smckusick 
3341480Smckusick #define REGBASE	    	((struct tcboxfb *)(ip->regbase))
3441480Smckusick #define WINDOWMOVER 	topcat_windowmove
3541480Smckusick 
3641480Smckusick /* XXX */
3741480Smckusick #include "grfioctl.h"
3841480Smckusick #include "grfvar.h"
3941480Smckusick 
4041480Smckusick topcat_init(ip)
4141480Smckusick 	register struct ite_softc *ip;
4241480Smckusick {
4341480Smckusick 	/* XXX */
4441480Smckusick 	if (ip->regbase == NULL) {
4541480Smckusick 		struct grfinfo *gi = &grf_softc[ip - ite_softc].g_display;
4641480Smckusick 		ip->regbase = IOV(gi->gd_regaddr);
4741480Smckusick 		ip->fbbase = IOV(gi->gd_fbaddr);
4841480Smckusick 	}
4941480Smckusick 
5041480Smckusick 	/*
5141480Smckusick 	 * Determine the number of planes by writing to the first frame
5241480Smckusick 	 * buffer display location, then reading it back.
5341480Smckusick 	 */
5441480Smckusick 	REGBASE->wen = ~0;
5541480Smckusick 	REGBASE->fben = ~0;
5641480Smckusick 	REGBASE->prr = RR_COPY;
5741480Smckusick 	*FBBASE = 0xFF;
5841480Smckusick 	ip->planemask = *FBBASE;
5941480Smckusick 
6041480Smckusick 	/*
6141480Smckusick 	 * Enable reading/writing of all the planes.
6241480Smckusick 	 */
6341480Smckusick 	REGBASE->fben = ip->planemask;
6441480Smckusick 	REGBASE->wen  = ip->planemask;
6541480Smckusick 	REGBASE->ren  = ip->planemask;
6641480Smckusick 	REGBASE->prr  = RR_COPY;
6741480Smckusick 
6841480Smckusick 	ite_devinfo(ip);
6941480Smckusick 
7041480Smckusick 	/*
7141480Smckusick 	 * Clear the framebuffer on all planes.
7241480Smckusick 	 */
7341480Smckusick 	topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
7441480Smckusick 	tc_waitbusy(REGADDR, ip->planemask);
7541480Smckusick 
7641480Smckusick 	ite_fontinit(ip);
7741480Smckusick 
7841480Smckusick 	/*
7941480Smckusick 	 * Initialize color map for color displays
8041480Smckusick 	 */
8141480Smckusick 	if (ip->planemask != 1) {
8241480Smckusick 	  	tc_waitbusy(REGADDR, ip->planemask);
8341480Smckusick 		REGBASE->nblank = 0x01;
8441480Smckusick 
8541480Smckusick 		tccm_waitbusy(REGADDR);
8641480Smckusick 		REGBASE->rdata  = 0x0;
8741480Smckusick 		REGBASE->gdata  = 0x0;
8841480Smckusick 		REGBASE->bdata  = 0x0;
8941480Smckusick 		REGBASE->cindex = 0xFF;
9041480Smckusick 		REGBASE->strobe = 0xFF;
9141480Smckusick 
9241480Smckusick 		DELAY(100);
9341480Smckusick 		tccm_waitbusy(REGADDR);
9441480Smckusick 		REGBASE->rdata  = 0x0;
9541480Smckusick 		REGBASE->gdata  = 0x0;
9641480Smckusick 		REGBASE->bdata  = 0x0;
9741480Smckusick 		REGBASE->cindex = 0x0;
9841480Smckusick 
9941480Smckusick 		DELAY(100);
10041480Smckusick 		tccm_waitbusy(REGADDR);
10141480Smckusick 		REGBASE->rdata  = 0xFF;
10241480Smckusick 		REGBASE->gdata  = 0xFF;
10341480Smckusick 		REGBASE->bdata  = 0xFF;
10441480Smckusick 		REGBASE->cindex = 0xFE;
10541480Smckusick 		REGBASE->strobe = 0xFF;
10641480Smckusick 
10741480Smckusick 		DELAY(100);
10841480Smckusick 		tccm_waitbusy(REGADDR);
10941480Smckusick 		REGBASE->rdata  = 0x0;
11041480Smckusick 		REGBASE->gdata  = 0x0;
11141480Smckusick 		REGBASE->bdata  = 0x0;
11241480Smckusick 		REGBASE->cindex = 0x0;
11341480Smckusick 	}
11441480Smckusick 
11541480Smckusick 	/*
11641480Smckusick 	 * Stash the inverted cursor.
11741480Smckusick 	 */
11841480Smckusick 	topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
11941480Smckusick 			  ip->cblanky, ip->cblankx, ip->ftheight,
12041480Smckusick 			  ip->ftwidth, RR_COPYINVERTED);
12141480Smckusick }
12241480Smckusick 
12341480Smckusick topcat_deinit(ip)
12441480Smckusick 	register struct ite_softc *ip;
12541480Smckusick {
12641480Smckusick 	topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
12741480Smckusick 	tc_waitbusy(REGADDR, ip->planemask);
12841480Smckusick 
12941480Smckusick 	REGBASE->nblank = ~0;
13041480Smckusick    	ip->flags &= ~ITE_INITED;
13141480Smckusick }
13241480Smckusick 
13341480Smckusick topcat_putc(ip, c, dy, dx, mode)
13441480Smckusick 	register struct ite_softc *ip;
13541480Smckusick 	int c, dy, dx, mode;
13641480Smckusick {
13741480Smckusick         int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
13841480Smckusick 
13941480Smckusick 	topcat_windowmove(ip, charY(ip, c), charX(ip, c),
14041480Smckusick 			  dy * ip->ftheight, dx * ip->ftwidth,
14141480Smckusick 			  ip->ftheight, ip->ftwidth, wmrr);
14241480Smckusick }
14341480Smckusick 
14441480Smckusick topcat_cursor(ip, flag)
14541480Smckusick 	register struct ite_softc *ip;
14641480Smckusick 	register int flag;
14741480Smckusick {
14841480Smckusick 	if (flag == DRAW_CURSOR)
14941480Smckusick 		draw_cursor(ip)
15041480Smckusick 	else if (flag == MOVE_CURSOR) {
15141480Smckusick 		erase_cursor(ip)
15241480Smckusick 		draw_cursor(ip)
15341480Smckusick 	}
15441480Smckusick 	else
15541480Smckusick 		erase_cursor(ip)
15641480Smckusick }
15741480Smckusick 
15841480Smckusick topcat_clear(ip, sy, sx, h, w)
15941480Smckusick 	register struct ite_softc *ip;
16041480Smckusick 	register int sy, sx, h, w;
16141480Smckusick {
16241480Smckusick 	topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
16341480Smckusick 			  sy * ip->ftheight, sx * ip->ftwidth,
16441480Smckusick 			  h  * ip->ftheight, w  * ip->ftwidth,
16541480Smckusick 			  RR_CLEAR);
16641480Smckusick }
16741480Smckusick 
16841480Smckusick topcat_scroll(ip, sy, sx, count, dir)
16941480Smckusick         register struct ite_softc *ip;
17041480Smckusick         register int sy, count;
17141480Smckusick         int dir, sx;
17241480Smckusick {
17341480Smckusick 	register int dy;
17441480Smckusick 	register int dx = sx;
17541480Smckusick 	register int height = 1;
17641480Smckusick 	register int width = ip->cols;
17741480Smckusick 
17841480Smckusick 	topcat_cursor(ip, ERASE_CURSOR);
17941480Smckusick 
18041480Smckusick 	if (dir == SCROLL_UP) {
18141480Smckusick 		dy = sy - count;
18241480Smckusick 		height = ip->rows - sy;
18341480Smckusick 	}
18441480Smckusick 	else if (dir == SCROLL_DOWN) {
18541480Smckusick 		dy = sy + count;
18641480Smckusick 		height = ip->rows - dy - 1;
18741480Smckusick 	}
18841480Smckusick 	else if (dir == SCROLL_RIGHT) {
18941480Smckusick 		dy = sy;
19041480Smckusick 		dx = sx + count;
19141480Smckusick 		width = ip->cols - dx;
19241480Smckusick 	}
19341480Smckusick 	else {
19441480Smckusick 		dy = sy;
19541480Smckusick 		dx = sx - count;
19641480Smckusick 		width = ip->cols - sx;
19741480Smckusick 	}
19841480Smckusick 
19941480Smckusick 	topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
20041480Smckusick 			  dy * ip->ftheight, dx * ip->ftwidth,
20141480Smckusick 			  height * ip->ftheight,
20241480Smckusick 			  width  * ip->ftwidth, RR_COPY);
20341480Smckusick }
20441480Smckusick 
20541480Smckusick topcat_windowmove(ip, sy, sx, dy, dx, h, w, func)
20641480Smckusick 	struct ite_softc *ip;
20741480Smckusick 	int sy, sx, dy, dx, h, w, func;
20841480Smckusick {
20941480Smckusick   	register struct tcboxfb *rp = REGBASE;
21041480Smckusick 
21141480Smckusick 	if (h == 0 || w == 0)
21241480Smckusick 		return;
21341480Smckusick 	tc_waitbusy(REGADDR, ip->planemask);
21441480Smckusick 	rp->wmrr     = func;
21541480Smckusick 	rp->source_y = sy;
21641480Smckusick 	rp->source_x = sx;
21741480Smckusick 	rp->dest_y   = dy;
21841480Smckusick 	rp->dest_x   = dx;
21941480Smckusick 	rp->wheight  = h;
22041480Smckusick 	rp->wwidth   = w;
22141480Smckusick 	rp->wmove    = ip->planemask;
22241480Smckusick }
22341480Smckusick #endif
224