xref: /original-bsd/sys/hp300/dev/ite_dv.c (revision 9cc8b07d)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: ite_dv.c 1.8 92/01/21$
13  *
14  *	@(#)ite_dv.c	7.6 (Berkeley) 06/05/92
15  */
16 
17 #include "ite.h"
18 #if NITE > 0
19 
20 #include "param.h"
21 #include "conf.h"
22 #include "proc.h"
23 #include "ioctl.h"
24 #include "tty.h"
25 #include "systm.h"
26 
27 #include "hp/dev/itevar.h"
28 #include "hp/dev/itereg.h"
29 #include "grf_dvreg.h"
30 
31 #include "machine/cpu.h"
32 
33 /* XXX */
34 #include "hp/dev/grfioctl.h"
35 #include "hp/dev/grfvar.h"
36 
37 #define REGBASE		((struct dvboxfb *)(ip->regbase))
38 #define WINDOWMOVER	dvbox_windowmove
39 
40 dvbox_init(ip)
41 	register struct ite_softc *ip;
42 {
43 	int i;
44 
45 	/* XXX */
46 	if (ip->regbase == 0) {
47 		struct grf_softc *gp = ip->grf;
48 
49 		ip->regbase = gp->g_regkva;
50 		ip->fbbase = gp->g_fbkva;
51 		ip->fbwidth = gp->g_display.gd_fbwidth;
52 		ip->fbheight = gp->g_display.gd_fbheight;
53 		ip->dwidth = gp->g_display.gd_dwidth;
54 		ip->dheight = gp->g_display.gd_dheight;
55 	}
56 
57 	dv_reset(ip->regbase);
58 
59 	/*
60 	 * Turn on frame buffer, turn on overlay planes, set replacement
61 	 * rule, enable top overlay plane writes for ite, disable all frame
62 	 * buffer planes, set byte per pixel, and display frame buffer 0.
63 	 * Lastly, turn on the box.
64 	 */
65 	REGBASE->interrupt = 0x04;
66 	REGBASE->drive     = 0x10;
67  	REGBASE->rep_rule  = RR_COPY << 4 | RR_COPY;
68 	REGBASE->opwen     = 0x01;
69 	REGBASE->fbwen     = 0x0;
70 	REGBASE->fold      = 0x01;
71 	REGBASE->vdrive    = 0x0;
72 	REGBASE->dispen    = 0x01;
73 
74 	/*
75 	 * Video enable top overlay plane.
76 	 */
77 	REGBASE->opvenp = 0x01;
78 	REGBASE->opvens = 0x01;
79 
80 	/*
81 	 * Make sure that overlay planes override frame buffer planes.
82 	 */
83 	REGBASE->ovly0p  = 0x0;
84 	REGBASE->ovly0s  = 0x0;
85 	REGBASE->ovly1p  = 0x0;
86 	REGBASE->ovly1s  = 0x0;
87 	REGBASE->fv_trig = 0x1;
88 	DELAY(100);
89 
90 	/*
91 	 * Setup the overlay colormaps. Need to set the 0,1 (black/white)
92 	 * color for both banks.
93 	 */
94 
95 	for (i = 0; i <= 1; i++) {
96 		REGBASE->cmapbank = i;
97 		REGBASE->rgb[0].red   = 0x00;
98 		REGBASE->rgb[0].green = 0x00;
99 		REGBASE->rgb[0].blue  = 0x00;
100 		REGBASE->rgb[1].red   = 0xFF;
101 		REGBASE->rgb[1].green = 0xFF;
102 		REGBASE->rgb[1].blue  = 0xFF;
103 	}
104 	REGBASE->cmapbank = 0;
105 
106 	db_waitbusy(ip->regbase);
107 
108 	ite_fontinfo(ip);
109 	ite_fontinit(ip);
110 
111 	/*
112 	 * Clear the (visible) framebuffer.
113 	 */
114 	dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
115 	db_waitbusy(ip->regbase);
116 
117 	/*
118 	 * Stash the inverted cursor.
119 	 */
120 	dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
121 			 ip->cblanky, ip->cblankx, ip->ftheight,
122 			 ip->ftwidth, RR_COPYINVERTED);
123 }
124 
125 dvbox_deinit(ip)
126 	register struct ite_softc *ip;
127 {
128 	dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
129 	db_waitbusy(ip->regbase);
130 
131    	ip->flags &= ~ITE_INITED;
132 }
133 
134 dvbox_putc(ip, c, dy, dx, mode)
135 	register struct ite_softc *ip;
136         register int dy, dx;
137 	int c, mode;
138 {
139         register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
140 
141 	dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
142 			 dy * ip->ftheight, dx * ip->ftwidth,
143 			 ip->ftheight, ip->ftwidth, wrr);
144 }
145 
146 dvbox_cursor(ip, flag)
147 	register struct ite_softc *ip;
148         register int flag;
149 {
150 	if (flag == DRAW_CURSOR)
151 		draw_cursor(ip)
152 	else if (flag == MOVE_CURSOR) {
153 		erase_cursor(ip)
154 		draw_cursor(ip)
155 	}
156 	else
157 		erase_cursor(ip)
158 }
159 
160 dvbox_clear(ip, sy, sx, h, w)
161 	struct ite_softc *ip;
162 	register int sy, sx, h, w;
163 {
164 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
165 			 sy * ip->ftheight, sx * ip->ftwidth,
166 			 h  * ip->ftheight, w  * ip->ftwidth,
167 			 RR_CLEAR);
168 }
169 
170 dvbox_scroll(ip, sy, sx, count, dir)
171         register struct ite_softc *ip;
172         register int sy, count;
173         int dir, sx;
174 {
175 	register int dy;
176 	register int dx = sx;
177 	register int height = 1;
178 	register int width = ip->cols;
179 
180 	dvbox_cursor(ip, ERASE_CURSOR);
181 
182 	if (dir == SCROLL_UP) {
183 		dy = sy - count;
184 		height = ip->rows - sy;
185 	}
186 	else if (dir == SCROLL_DOWN) {
187 		dy = sy + count;
188 		height = ip->rows - dy - 1;
189 	}
190 	else if (dir == SCROLL_RIGHT) {
191 		dy = sy;
192 		dx = sx + count;
193 		width = ip->cols - dx;
194 	}
195 	else {
196 		dy = sy;
197 		dx = sx - count;
198 		width = ip->cols - sx;
199 	}
200 
201 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
202 			 dy * ip->ftheight, dx * ip->ftwidth,
203 			 height * ip->ftheight,
204 			 width  * ip->ftwidth, RR_COPY);
205 }
206 
207 dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
208 	struct ite_softc *ip;
209 	int sy, sx, dy, dx, h, w, func;
210 {
211 	register struct dvboxfb *dp = REGBASE;
212 	if (h == 0 || w == 0)
213 		return;
214 
215 	db_waitbusy(ip->regbase);
216 	dp->rep_rule = func << 4 | func;
217 	dp->source_y = sy;
218 	dp->source_x = sx;
219 	dp->dest_y   = dy;
220 	dp->dest_x   = dx;
221 	dp->wheight  = h;
222 	dp->wwidth   = w;
223 	dp->wmove    = 1;
224 }
225 #endif
226