xref: /csrg-svn/sys/hp300/dev/ite_tc.c (revision 41480)
1*41480Smckusick /*
2*41480Smckusick  * Copyright (c) 1988 University of Utah.
3*41480Smckusick  * Copyright (c) 1990 The Regents of the University of California.
4*41480Smckusick  * All rights reserved.
5*41480Smckusick  *
6*41480Smckusick  * This code is derived from software contributed to Berkeley by
7*41480Smckusick  * the Systems Programming Group of the University of Utah Computer
8*41480Smckusick  * Science Department.
9*41480Smckusick  *
10*41480Smckusick  * %sccs.include.redist.c%
11*41480Smckusick  *
12*41480Smckusick  * from: Utah $Hdr: ite_tc.c 1.22 89/04/11$
13*41480Smckusick  *
14*41480Smckusick  *	@(#)ite_tc.c	7.1 (Berkeley) 05/08/90
15*41480Smckusick  */
16*41480Smckusick 
17*41480Smckusick #include "ite.h"
18*41480Smckusick #if NITE > 0
19*41480Smckusick 
20*41480Smckusick #include "param.h"
21*41480Smckusick #include "conf.h"
22*41480Smckusick #include "user.h"
23*41480Smckusick #include "proc.h"
24*41480Smckusick #include "ioctl.h"
25*41480Smckusick #include "tty.h"
26*41480Smckusick #include "systm.h"
27*41480Smckusick #include "uio.h"
28*41480Smckusick 
29*41480Smckusick #include "grf_tcreg.h"
30*41480Smckusick #include "itereg.h"
31*41480Smckusick #include "itevar.h"
32*41480Smckusick 
33*41480Smckusick #include "machine/cpu.h"
34*41480Smckusick 
35*41480Smckusick #define REGBASE	    	((struct tcboxfb *)(ip->regbase))
36*41480Smckusick #define WINDOWMOVER 	topcat_windowmove
37*41480Smckusick 
38*41480Smckusick /* XXX */
39*41480Smckusick #include "grfioctl.h"
40*41480Smckusick #include "grfvar.h"
41*41480Smckusick 
42*41480Smckusick topcat_init(ip)
43*41480Smckusick 	register struct ite_softc *ip;
44*41480Smckusick {
45*41480Smckusick 	/* XXX */
46*41480Smckusick 	if (ip->regbase == NULL) {
47*41480Smckusick 		struct grfinfo *gi = &grf_softc[ip - ite_softc].g_display;
48*41480Smckusick 		ip->regbase = IOV(gi->gd_regaddr);
49*41480Smckusick 		ip->fbbase = IOV(gi->gd_fbaddr);
50*41480Smckusick 	}
51*41480Smckusick 
52*41480Smckusick 	/*
53*41480Smckusick 	 * Determine the number of planes by writing to the first frame
54*41480Smckusick 	 * buffer display location, then reading it back.
55*41480Smckusick 	 */
56*41480Smckusick 	REGBASE->wen = ~0;
57*41480Smckusick 	REGBASE->fben = ~0;
58*41480Smckusick 	REGBASE->prr = RR_COPY;
59*41480Smckusick 	*FBBASE = 0xFF;
60*41480Smckusick 	ip->planemask = *FBBASE;
61*41480Smckusick 
62*41480Smckusick 	/*
63*41480Smckusick 	 * Enable reading/writing of all the planes.
64*41480Smckusick 	 */
65*41480Smckusick 	REGBASE->fben = ip->planemask;
66*41480Smckusick 	REGBASE->wen  = ip->planemask;
67*41480Smckusick 	REGBASE->ren  = ip->planemask;
68*41480Smckusick 	REGBASE->prr  = RR_COPY;
69*41480Smckusick 
70*41480Smckusick 	ite_devinfo(ip);
71*41480Smckusick 
72*41480Smckusick 	/*
73*41480Smckusick 	 * Clear the framebuffer on all planes.
74*41480Smckusick 	 */
75*41480Smckusick 	topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
76*41480Smckusick 	tc_waitbusy(REGADDR, ip->planemask);
77*41480Smckusick 
78*41480Smckusick 	ite_fontinit(ip);
79*41480Smckusick 
80*41480Smckusick 	/*
81*41480Smckusick 	 * Initialize color map for color displays
82*41480Smckusick 	 */
83*41480Smckusick 	if (ip->planemask != 1) {
84*41480Smckusick 	  	tc_waitbusy(REGADDR, ip->planemask);
85*41480Smckusick 		REGBASE->nblank = 0x01;
86*41480Smckusick 
87*41480Smckusick 		tccm_waitbusy(REGADDR);
88*41480Smckusick 		REGBASE->rdata  = 0x0;
89*41480Smckusick 		REGBASE->gdata  = 0x0;
90*41480Smckusick 		REGBASE->bdata  = 0x0;
91*41480Smckusick 		REGBASE->cindex = 0xFF;
92*41480Smckusick 		REGBASE->strobe = 0xFF;
93*41480Smckusick 
94*41480Smckusick 		DELAY(100);
95*41480Smckusick 		tccm_waitbusy(REGADDR);
96*41480Smckusick 		REGBASE->rdata  = 0x0;
97*41480Smckusick 		REGBASE->gdata  = 0x0;
98*41480Smckusick 		REGBASE->bdata  = 0x0;
99*41480Smckusick 		REGBASE->cindex = 0x0;
100*41480Smckusick 
101*41480Smckusick 		DELAY(100);
102*41480Smckusick 		tccm_waitbusy(REGADDR);
103*41480Smckusick 		REGBASE->rdata  = 0xFF;
104*41480Smckusick 		REGBASE->gdata  = 0xFF;
105*41480Smckusick 		REGBASE->bdata  = 0xFF;
106*41480Smckusick 		REGBASE->cindex = 0xFE;
107*41480Smckusick 		REGBASE->strobe = 0xFF;
108*41480Smckusick 
109*41480Smckusick 		DELAY(100);
110*41480Smckusick 		tccm_waitbusy(REGADDR);
111*41480Smckusick 		REGBASE->rdata  = 0x0;
112*41480Smckusick 		REGBASE->gdata  = 0x0;
113*41480Smckusick 		REGBASE->bdata  = 0x0;
114*41480Smckusick 		REGBASE->cindex = 0x0;
115*41480Smckusick 	}
116*41480Smckusick 
117*41480Smckusick 	/*
118*41480Smckusick 	 * Stash the inverted cursor.
119*41480Smckusick 	 */
120*41480Smckusick 	topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
121*41480Smckusick 			  ip->cblanky, ip->cblankx, ip->ftheight,
122*41480Smckusick 			  ip->ftwidth, RR_COPYINVERTED);
123*41480Smckusick }
124*41480Smckusick 
125*41480Smckusick topcat_deinit(ip)
126*41480Smckusick 	register struct ite_softc *ip;
127*41480Smckusick {
128*41480Smckusick 	topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
129*41480Smckusick 	tc_waitbusy(REGADDR, ip->planemask);
130*41480Smckusick 
131*41480Smckusick 	REGBASE->nblank = ~0;
132*41480Smckusick    	ip->flags &= ~ITE_INITED;
133*41480Smckusick }
134*41480Smckusick 
135*41480Smckusick topcat_putc(ip, c, dy, dx, mode)
136*41480Smckusick 	register struct ite_softc *ip;
137*41480Smckusick 	int c, dy, dx, mode;
138*41480Smckusick {
139*41480Smckusick         int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
140*41480Smckusick 
141*41480Smckusick 	topcat_windowmove(ip, charY(ip, c), charX(ip, c),
142*41480Smckusick 			  dy * ip->ftheight, dx * ip->ftwidth,
143*41480Smckusick 			  ip->ftheight, ip->ftwidth, wmrr);
144*41480Smckusick }
145*41480Smckusick 
146*41480Smckusick topcat_cursor(ip, flag)
147*41480Smckusick 	register struct ite_softc *ip;
148*41480Smckusick 	register int flag;
149*41480Smckusick {
150*41480Smckusick 	if (flag == DRAW_CURSOR)
151*41480Smckusick 		draw_cursor(ip)
152*41480Smckusick 	else if (flag == MOVE_CURSOR) {
153*41480Smckusick 		erase_cursor(ip)
154*41480Smckusick 		draw_cursor(ip)
155*41480Smckusick 	}
156*41480Smckusick 	else
157*41480Smckusick 		erase_cursor(ip)
158*41480Smckusick }
159*41480Smckusick 
160*41480Smckusick topcat_clear(ip, sy, sx, h, w)
161*41480Smckusick 	register struct ite_softc *ip;
162*41480Smckusick 	register int sy, sx, h, w;
163*41480Smckusick {
164*41480Smckusick 	topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
165*41480Smckusick 			  sy * ip->ftheight, sx * ip->ftwidth,
166*41480Smckusick 			  h  * ip->ftheight, w  * ip->ftwidth,
167*41480Smckusick 			  RR_CLEAR);
168*41480Smckusick }
169*41480Smckusick 
170*41480Smckusick topcat_scroll(ip, sy, sx, count, dir)
171*41480Smckusick         register struct ite_softc *ip;
172*41480Smckusick         register int sy, count;
173*41480Smckusick         int dir, sx;
174*41480Smckusick {
175*41480Smckusick 	register int dy;
176*41480Smckusick 	register int dx = sx;
177*41480Smckusick 	register int height = 1;
178*41480Smckusick 	register int width = ip->cols;
179*41480Smckusick 
180*41480Smckusick 	topcat_cursor(ip, ERASE_CURSOR);
181*41480Smckusick 
182*41480Smckusick 	if (dir == SCROLL_UP) {
183*41480Smckusick 		dy = sy - count;
184*41480Smckusick 		height = ip->rows - sy;
185*41480Smckusick 	}
186*41480Smckusick 	else if (dir == SCROLL_DOWN) {
187*41480Smckusick 		dy = sy + count;
188*41480Smckusick 		height = ip->rows - dy - 1;
189*41480Smckusick 	}
190*41480Smckusick 	else if (dir == SCROLL_RIGHT) {
191*41480Smckusick 		dy = sy;
192*41480Smckusick 		dx = sx + count;
193*41480Smckusick 		width = ip->cols - dx;
194*41480Smckusick 	}
195*41480Smckusick 	else {
196*41480Smckusick 		dy = sy;
197*41480Smckusick 		dx = sx - count;
198*41480Smckusick 		width = ip->cols - sx;
199*41480Smckusick 	}
200*41480Smckusick 
201*41480Smckusick 	topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
202*41480Smckusick 			  dy * ip->ftheight, dx * ip->ftwidth,
203*41480Smckusick 			  height * ip->ftheight,
204*41480Smckusick 			  width  * ip->ftwidth, RR_COPY);
205*41480Smckusick }
206*41480Smckusick 
207*41480Smckusick topcat_windowmove(ip, sy, sx, dy, dx, h, w, func)
208*41480Smckusick 	struct ite_softc *ip;
209*41480Smckusick 	int sy, sx, dy, dx, h, w, func;
210*41480Smckusick {
211*41480Smckusick   	register struct tcboxfb *rp = REGBASE;
212*41480Smckusick 
213*41480Smckusick 	if (h == 0 || w == 0)
214*41480Smckusick 		return;
215*41480Smckusick 	tc_waitbusy(REGADDR, ip->planemask);
216*41480Smckusick 	rp->wmrr     = func;
217*41480Smckusick 	rp->source_y = sy;
218*41480Smckusick 	rp->source_x = sx;
219*41480Smckusick 	rp->dest_y   = dy;
220*41480Smckusick 	rp->dest_x   = dx;
221*41480Smckusick 	rp->wheight  = h;
222*41480Smckusick 	rp->wwidth   = w;
223*41480Smckusick 	rp->wmove    = ip->planemask;
224*41480Smckusick }
225*41480Smckusick #endif
226