xref: /csrg-svn/sys/hp300/dev/ite_dv.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_dv.c 1.5 89/04/11$
13*41480Smckusick  *
14*41480Smckusick  *	@(#)ite_dv.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_dvreg.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 dvboxfb *)(ip->regbase))
40*41480Smckusick #define WINDOWMOVER	dvbox_windowmove
41*41480Smckusick 
42*41480Smckusick dvbox_init(ip)
43*41480Smckusick 	struct ite_softc *ip;
44*41480Smckusick {
45*41480Smckusick 	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 	dv_reset(REGADDR);
55*41480Smckusick 
56*41480Smckusick 	/*
57*41480Smckusick 	 * Turn on frame buffer, turn on overlay planes, set replacement
58*41480Smckusick 	 * rule, enable top overlay plane writes for ite, disable all frame
59*41480Smckusick 	 * buffer planes, set byte per pixel, and display frame buffer 0.
60*41480Smckusick 	 * Lastly, turn on the box.
61*41480Smckusick 	 */
62*41480Smckusick 	REGBASE->interrupt = 0x04;
63*41480Smckusick 	REGBASE->drive     = 0x10;
64*41480Smckusick  	REGBASE->rep_rule  = RR_COPY << 4 | RR_COPY;
65*41480Smckusick 	REGBASE->opwen     = 0x01;
66*41480Smckusick 	REGBASE->fbwen     = 0x0;
67*41480Smckusick 	REGBASE->fold      = 0x01;
68*41480Smckusick 	REGBASE->vdrive    = 0x0;
69*41480Smckusick 	REGBASE->dispen    = 0x01;
70*41480Smckusick 
71*41480Smckusick 	/*
72*41480Smckusick 	 * Video enable top overlay plane.
73*41480Smckusick 	 */
74*41480Smckusick 	REGBASE->opvenp = 0x01;
75*41480Smckusick 	REGBASE->opvens = 0x01;
76*41480Smckusick 
77*41480Smckusick 	/*
78*41480Smckusick 	 * Make sure that overlay planes override frame buffer planes.
79*41480Smckusick 	 */
80*41480Smckusick 	REGBASE->ovly0p  = 0x0;
81*41480Smckusick 	REGBASE->ovly0s  = 0x0;
82*41480Smckusick 	REGBASE->ovly1p  = 0x0;
83*41480Smckusick 	REGBASE->ovly1s  = 0x0;
84*41480Smckusick 	REGBASE->fv_trig = 0x1;
85*41480Smckusick 	DELAY(100);
86*41480Smckusick 
87*41480Smckusick 	/*
88*41480Smckusick 	 * Setup the overlay colormaps. Need to set the 0,1 (black/white)
89*41480Smckusick 	 * color for both banks.
90*41480Smckusick 	 */
91*41480Smckusick 
92*41480Smckusick 	for (i = 0; i <= 1; i++) {
93*41480Smckusick 		REGBASE->cmapbank = i;
94*41480Smckusick 		REGBASE->rgb[0].red   = 0x00;
95*41480Smckusick 		REGBASE->rgb[0].green = 0x00;
96*41480Smckusick 		REGBASE->rgb[0].blue  = 0x00;
97*41480Smckusick 		REGBASE->rgb[1].red   = 0xFF;
98*41480Smckusick 		REGBASE->rgb[1].green = 0xFF;
99*41480Smckusick 		REGBASE->rgb[1].blue  = 0xFF;
100*41480Smckusick 	}
101*41480Smckusick 	REGBASE->cmapbank = 0;
102*41480Smckusick 
103*41480Smckusick 	db_waitbusy(REGADDR);
104*41480Smckusick 
105*41480Smckusick 	ite_devinfo(ip);
106*41480Smckusick 	ite_fontinit(ip);
107*41480Smckusick 
108*41480Smckusick 	/*
109*41480Smckusick 	 * Clear the (visible) framebuffer.
110*41480Smckusick 	 */
111*41480Smckusick 	dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
112*41480Smckusick 	db_waitbusy(REGADDR);
113*41480Smckusick 
114*41480Smckusick 	/*
115*41480Smckusick 	 * Stash the inverted cursor.
116*41480Smckusick 	 */
117*41480Smckusick 	dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
118*41480Smckusick 			 ip->cblanky, ip->cblankx, ip->ftheight,
119*41480Smckusick 			 ip->ftwidth, RR_COPYINVERTED);
120*41480Smckusick }
121*41480Smckusick 
122*41480Smckusick dvbox_deinit(ip)
123*41480Smckusick 	struct ite_softc *ip;
124*41480Smckusick {
125*41480Smckusick 	dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
126*41480Smckusick 	db_waitbusy(REGADDR);
127*41480Smckusick 
128*41480Smckusick    	ip->flags &= ~ITE_INITED;
129*41480Smckusick }
130*41480Smckusick 
131*41480Smckusick dvbox_putc(ip, c, dy, dx, mode)
132*41480Smckusick 	register struct ite_softc *ip;
133*41480Smckusick         register int dy, dx;
134*41480Smckusick 	int c, mode;
135*41480Smckusick {
136*41480Smckusick         register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
137*41480Smckusick 
138*41480Smckusick 	dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
139*41480Smckusick 			 dy * ip->ftheight, dx * ip->ftwidth,
140*41480Smckusick 			 ip->ftheight, ip->ftwidth, wrr);
141*41480Smckusick }
142*41480Smckusick 
143*41480Smckusick dvbox_cursor(ip, flag)
144*41480Smckusick 	register struct ite_softc *ip;
145*41480Smckusick         register int flag;
146*41480Smckusick {
147*41480Smckusick 	if (flag == DRAW_CURSOR)
148*41480Smckusick 		draw_cursor(ip)
149*41480Smckusick 	else if (flag == MOVE_CURSOR) {
150*41480Smckusick 		erase_cursor(ip)
151*41480Smckusick 		draw_cursor(ip)
152*41480Smckusick 	}
153*41480Smckusick 	else
154*41480Smckusick 		erase_cursor(ip)
155*41480Smckusick }
156*41480Smckusick 
157*41480Smckusick dvbox_clear(ip, sy, sx, h, w)
158*41480Smckusick 	struct ite_softc *ip;
159*41480Smckusick 	register int sy, sx, h, w;
160*41480Smckusick {
161*41480Smckusick 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
162*41480Smckusick 			 sy * ip->ftheight, sx * ip->ftwidth,
163*41480Smckusick 			 h  * ip->ftheight, w  * ip->ftwidth,
164*41480Smckusick 			 RR_CLEAR);
165*41480Smckusick }
166*41480Smckusick 
167*41480Smckusick dvbox_scroll(ip, sy, sx, count, dir)
168*41480Smckusick         register struct ite_softc *ip;
169*41480Smckusick         register int sy, count;
170*41480Smckusick         int dir, sx;
171*41480Smckusick {
172*41480Smckusick 	register int dy;
173*41480Smckusick 	register int dx = sx;
174*41480Smckusick 	register int height = 1;
175*41480Smckusick 	register int width = ip->cols;
176*41480Smckusick 
177*41480Smckusick 	dvbox_cursor(ip, ERASE_CURSOR);
178*41480Smckusick 
179*41480Smckusick 	if (dir == SCROLL_UP) {
180*41480Smckusick 		dy = sy - count;
181*41480Smckusick 		height = ip->rows - sy;
182*41480Smckusick 	}
183*41480Smckusick 	else if (dir == SCROLL_DOWN) {
184*41480Smckusick 		dy = sy + count;
185*41480Smckusick 		height = ip->rows - dy - 1;
186*41480Smckusick 	}
187*41480Smckusick 	else if (dir == SCROLL_RIGHT) {
188*41480Smckusick 		dy = sy;
189*41480Smckusick 		dx = sx + count;
190*41480Smckusick 		width = ip->cols - dx;
191*41480Smckusick 	}
192*41480Smckusick 	else {
193*41480Smckusick 		dy = sy;
194*41480Smckusick 		dx = sx - count;
195*41480Smckusick 		width = ip->cols - sx;
196*41480Smckusick 	}
197*41480Smckusick 
198*41480Smckusick 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
199*41480Smckusick 			 dy * ip->ftheight, dx * ip->ftwidth,
200*41480Smckusick 			 height * ip->ftheight,
201*41480Smckusick 			 width  * ip->ftwidth, RR_COPY);
202*41480Smckusick }
203*41480Smckusick 
204*41480Smckusick dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
205*41480Smckusick 	struct ite_softc *ip;
206*41480Smckusick 	int sy, sx, dy, dx, h, w, func;
207*41480Smckusick {
208*41480Smckusick 	register struct dvboxfb *dp = REGBASE;
209*41480Smckusick 	if (h == 0 || w == 0)
210*41480Smckusick 		return;
211*41480Smckusick 
212*41480Smckusick 	db_waitbusy(REGADDR);
213*41480Smckusick 	dp->rep_rule = func << 4 | func;
214*41480Smckusick 	dp->source_y = sy;
215*41480Smckusick 	dp->source_x = sx;
216*41480Smckusick 	dp->dest_y   = dy;
217*41480Smckusick 	dp->dest_x   = dx;
218*41480Smckusick 	dp->wheight  = h;
219*41480Smckusick 	dp->wwidth   = w;
220*41480Smckusick 	dp->wmove    = 1;
221*41480Smckusick }
222*41480Smckusick #endif
223