xref: /csrg-svn/sys/hp300/dev/ite_rb.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_rb.c 1.15 89/04/11$
13*41480Smckusick  *
14*41480Smckusick  *	@(#)ite_rb.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 "itevar.h"
30*41480Smckusick #include "itereg.h"
31*41480Smckusick #include "grf_rbreg.h"
32*41480Smckusick 
33*41480Smckusick #include "machine/cpu.h"
34*41480Smckusick 
35*41480Smckusick /* XXX */
36*41480Smckusick #include "grfioctl.h"
37*41480Smckusick #include "grfvar.h"
38*41480Smckusick 
39*41480Smckusick #define REGBASE		((struct rboxfb *)(ip->regbase))
40*41480Smckusick #define WINDOWMOVER	rbox_windowmove
41*41480Smckusick 
42*41480Smckusick rbox_init(ip)
43*41480Smckusick 	struct ite_softc *ip;
44*41480Smckusick {
45*41480Smckusick 	register int i;
46*41480Smckusick 
47*41480Smckusick 	/* XXX */
48*41480Smckusick 	if (ip->regbase == 0) {
49*41480Smckusick 		struct grfinfo *gi = &grf_softc[ip - ite_softc].g_display;
50*41480Smckusick 		ip->regbase = IOV(gi->gd_regaddr);
51*41480Smckusick 		ip->fbbase = IOV(gi->gd_fbaddr);
52*41480Smckusick 	}
53*41480Smckusick 
54*41480Smckusick 	rb_waitbusy(REGADDR);
55*41480Smckusick 
56*41480Smckusick 	REGBASE->reset = 0x39;
57*41480Smckusick 	DELAY(1000);
58*41480Smckusick 
59*41480Smckusick 	REGBASE->interrupt = 0x04;
60*41480Smckusick 	REGBASE->display_enable = 0x01;
61*41480Smckusick 	REGBASE->video_enable = 0x01;
62*41480Smckusick 	REGBASE->drive = 0x01;
63*41480Smckusick 	REGBASE->vdrive = 0x0;
64*41480Smckusick 
65*41480Smckusick 	ite_devinfo(ip);
66*41480Smckusick 
67*41480Smckusick 	REGBASE->opwen = 0xFF;
68*41480Smckusick 
69*41480Smckusick 	/*
70*41480Smckusick 	 * Clear the framebuffer.
71*41480Smckusick 	 */
72*41480Smckusick 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
73*41480Smckusick 	rb_waitbusy(REGADDR);
74*41480Smckusick 
75*41480Smckusick 	for(i = 0; i < 16; i++) {
76*41480Smckusick 		*(REGADDR + 0x63c3 + i*4) = 0x0;
77*41480Smckusick 		*(REGADDR + 0x6403 + i*4) = 0x0;
78*41480Smckusick 		*(REGADDR + 0x6803 + i*4) = 0x0;
79*41480Smckusick 		*(REGADDR + 0x6c03 + i*4) = 0x0;
80*41480Smckusick 		*(REGADDR + 0x73c3 + i*4) = 0x0;
81*41480Smckusick 		*(REGADDR + 0x7403 + i*4) = 0x0;
82*41480Smckusick 		*(REGADDR + 0x7803 + i*4) = 0x0;
83*41480Smckusick 		*(REGADDR + 0x7c03 + i*4) = 0x0;
84*41480Smckusick 	}
85*41480Smckusick 
86*41480Smckusick 	REGBASE->rep_rule = 0x33;
87*41480Smckusick 
88*41480Smckusick 	/*
89*41480Smckusick 	 * I cannot figure out how to make the blink planes stop. So, we
90*41480Smckusick 	 * must set both colormaps so that when the planes blink, and
91*41480Smckusick 	 * the secondary colormap is active, we still get text.
92*41480Smckusick 	 */
93*41480Smckusick 	CM1RED[0x00].value = 0x00;
94*41480Smckusick 	CM1GRN[0x00].value = 0x00;
95*41480Smckusick 	CM1BLU[0x00].value = 0x00;
96*41480Smckusick 	CM1RED[0x01].value = 0xFF;
97*41480Smckusick 	CM1GRN[0x01].value = 0xFF;
98*41480Smckusick 	CM1BLU[0x01].value = 0xFF;
99*41480Smckusick 
100*41480Smckusick 	CM2RED[0x00].value = 0x00;
101*41480Smckusick 	CM2GRN[0x00].value = 0x00;
102*41480Smckusick 	CM2BLU[0x00].value = 0x00;
103*41480Smckusick 	CM2RED[0x01].value = 0xFF;
104*41480Smckusick 	CM2GRN[0x01].value = 0xFF;
105*41480Smckusick 	CM2BLU[0x01].value = 0xFF;
106*41480Smckusick 
107*41480Smckusick  	REGBASE->blink = 0x00;
108*41480Smckusick 	REGBASE->write_enable = 0x01;
109*41480Smckusick 	REGBASE->opwen = 0x00;
110*41480Smckusick 
111*41480Smckusick 	ite_fontinit(ip);
112*41480Smckusick 
113*41480Smckusick 	/*
114*41480Smckusick 	 * Stash the inverted cursor.
115*41480Smckusick 	 */
116*41480Smckusick 	rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
117*41480Smckusick 			    ip->cblanky, ip->cblankx, ip->ftheight,
118*41480Smckusick 			    ip->ftwidth, RR_COPYINVERTED);
119*41480Smckusick }
120*41480Smckusick 
121*41480Smckusick rbox_deinit(ip)
122*41480Smckusick 	struct ite_softc *ip;
123*41480Smckusick {
124*41480Smckusick 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
125*41480Smckusick 	rb_waitbusy(REGADDR);
126*41480Smckusick 
127*41480Smckusick    	ip->flags &= ~ITE_INITED;
128*41480Smckusick }
129*41480Smckusick 
130*41480Smckusick rbox_putc(ip, c, dy, dx, mode)
131*41480Smckusick 	register struct ite_softc *ip;
132*41480Smckusick         register int dy, dx;
133*41480Smckusick 	int c, mode;
134*41480Smckusick {
135*41480Smckusick         register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
136*41480Smckusick 
137*41480Smckusick 	rbox_windowmove(ip, charY(ip, c), charX(ip, c),
138*41480Smckusick 			dy * ip->ftheight, dx * ip->ftwidth,
139*41480Smckusick 			ip->ftheight, ip->ftwidth, wrr);
140*41480Smckusick }
141*41480Smckusick 
142*41480Smckusick rbox_cursor(ip, flag)
143*41480Smckusick 	register struct ite_softc *ip;
144*41480Smckusick         register int flag;
145*41480Smckusick {
146*41480Smckusick 	if (flag == DRAW_CURSOR)
147*41480Smckusick 		draw_cursor(ip)
148*41480Smckusick 	else if (flag == MOVE_CURSOR) {
149*41480Smckusick 		erase_cursor(ip)
150*41480Smckusick 		draw_cursor(ip)
151*41480Smckusick 	}
152*41480Smckusick 	else
153*41480Smckusick 		erase_cursor(ip)
154*41480Smckusick }
155*41480Smckusick 
156*41480Smckusick rbox_clear(ip, sy, sx, h, w)
157*41480Smckusick 	struct ite_softc *ip;
158*41480Smckusick 	register int sy, sx, h, w;
159*41480Smckusick {
160*41480Smckusick 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
161*41480Smckusick 			sy * ip->ftheight, sx * ip->ftwidth,
162*41480Smckusick 			h  * ip->ftheight, w  * ip->ftwidth,
163*41480Smckusick 			RR_CLEAR);
164*41480Smckusick }
165*41480Smckusick 
166*41480Smckusick rbox_scroll(ip, sy, sx, count, dir)
167*41480Smckusick         register struct ite_softc *ip;
168*41480Smckusick         register int sy, count;
169*41480Smckusick         int dir, sx;
170*41480Smckusick {
171*41480Smckusick 	register int dy;
172*41480Smckusick 	register int dx = sx;
173*41480Smckusick 	register int height = 1;
174*41480Smckusick 	register int width = ip->cols;
175*41480Smckusick 
176*41480Smckusick 	rbox_cursor(ip, ERASE_CURSOR);
177*41480Smckusick 
178*41480Smckusick 	if (dir == SCROLL_UP) {
179*41480Smckusick 		dy = sy - count;
180*41480Smckusick 		height = ip->rows - sy;
181*41480Smckusick 	}
182*41480Smckusick 	else if (dir == SCROLL_DOWN) {
183*41480Smckusick 		dy = sy + count;
184*41480Smckusick 		height = ip->rows - dy - 1;
185*41480Smckusick 	}
186*41480Smckusick 	else if (dir == SCROLL_RIGHT) {
187*41480Smckusick 		dy = sy;
188*41480Smckusick 		dx = sx + count;
189*41480Smckusick 		width = ip->cols - dx;
190*41480Smckusick 	}
191*41480Smckusick 	else {
192*41480Smckusick 		dy = sy;
193*41480Smckusick 		dx = sx - count;
194*41480Smckusick 		width = ip->cols - sx;
195*41480Smckusick 	}
196*41480Smckusick 
197*41480Smckusick 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
198*41480Smckusick 			dy * ip->ftheight, dx * ip->ftwidth,
199*41480Smckusick 			height * ip->ftheight,
200*41480Smckusick 			width  * ip->ftwidth, RR_COPY);
201*41480Smckusick }
202*41480Smckusick 
203*41480Smckusick rbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
204*41480Smckusick 	struct ite_softc *ip;
205*41480Smckusick 	int sy, sx, dy, dx, h, w, func;
206*41480Smckusick {
207*41480Smckusick 	register struct rboxfb *rp = REGBASE;
208*41480Smckusick 	if (h == 0 || w == 0)
209*41480Smckusick 		return;
210*41480Smckusick 
211*41480Smckusick 	rb_waitbusy(REGADDR);
212*41480Smckusick 	rp->rep_rule = func << 4 | func;
213*41480Smckusick 	rp->source_y = sy;
214*41480Smckusick 	rp->source_x = sx;
215*41480Smckusick 	rp->dest_y = dy;
216*41480Smckusick 	rp->dest_x = dx;
217*41480Smckusick 	rp->wheight = h;
218*41480Smckusick 	rp->wwidth  = w;
219*41480Smckusick 	rp->wmove = 1;
220*41480Smckusick }
221*41480Smckusick #endif
222