xref: /netbsd-src/sys/arch/hp300/stand/common/ite_dv.c (revision d20841bb642898112fe68f0ad3f7b26dddf56f07)
1 /*	$NetBSD: ite_dv.c,v 1.3 2003/11/14 16:52:40 tsutsui Exp $	*/
2 
3 /*
4  * Copyright (c) 1990, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * the Systems Programming Group of the University of Utah Computer
9  * Science Department.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  * from: Utah $Hdr: ite_dv.c 1.2 92/01/20$
36  *
37  *	@(#)ite_dv.c	8.1 (Berkeley) 6/10/93
38  */
39 /*
40  * Copyright (c) 1988 University of Utah.
41  *
42  * This code is derived from software contributed to Berkeley by
43  * the Systems Programming Group of the University of Utah Computer
44  * Science Department.
45  *
46  * Redistribution and use in source and binary forms, with or without
47  * modification, are permitted provided that the following conditions
48  * are met:
49  * 1. Redistributions of source code must retain the above copyright
50  *    notice, this list of conditions and the following disclaimer.
51  * 2. Redistributions in binary form must reproduce the above copyright
52  *    notice, this list of conditions and the following disclaimer in the
53  *    documentation and/or other materials provided with the distribution.
54  * 3. All advertising materials mentioning features or use of this software
55  *    must display the following acknowledgement:
56  *	This product includes software developed by the University of
57  *	California, Berkeley and its contributors.
58  * 4. Neither the name of the University nor the names of its contributors
59  *    may be used to endorse or promote products derived from this software
60  *    without specific prior written permission.
61  *
62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72  * SUCH DAMAGE.
73  *
74  * from: Utah $Hdr: ite_dv.c 1.2 92/01/20$
75  *
76  *	@(#)ite_dv.c	8.1 (Berkeley) 6/10/93
77  */
78 
79 #ifdef ITECONSOLE
80 
81 #include <sys/param.h>
82 
83 #include <hp300/dev/itereg.h>
84 #include <hp300/dev/grf_dvreg.h>
85 
86 #include <hp300/stand/common/samachdep.h>
87 #include <hp300/stand/common/itevar.h>
88 
89 #define WINDOWMOVER	dvbox_windowmove
90 
91 static void dv_reset(struct dvboxfb *);
92 static void dvbox_windowmove(struct ite_data *, int, int, int, int,
93     int, int, int);
94 
95 void
96 dvbox_init(ip)
97 	struct ite_data *ip;
98 {
99 	struct dvboxfb *regbase;
100 	int i;
101 
102 	regbase = (void *)ip->regbase;
103 	dv_reset(regbase);
104 	DELAY(4000);
105 
106 	/*
107 	 * Turn on frame buffer, turn on overlay planes, set replacement
108 	 * rule, enable top overlay plane writes for ite, disable all frame
109 	 * buffer planes, set byte per pixel, and display frame buffer 0.
110 	 * Lastly, turn on the box.
111 	 */
112 	regbase->interrupt = 0x04;
113 	regbase->drive     = 0x10;
114 	regbase->rep_rule  = RR_COPY << 4 | RR_COPY;
115 	regbase->opwen     = 0x01;
116 	regbase->fbwen     = 0x0;
117 	regbase->fold      = 0x01;
118 	regbase->vdrive    = 0x0;
119 	regbase->dispen    = 0x01;
120 
121 	/*
122 	 * Video enable top overlay plane.
123 	 */
124 	regbase->opvenp = 0x01;
125 	regbase->opvens = 0x01;
126 
127 	/*
128 	 * Make sure that overlay planes override frame buffer planes.
129 	 */
130 	regbase->ovly0p  = 0x0;
131 	regbase->ovly0s  = 0x0;
132 	regbase->ovly1p  = 0x0;
133 	regbase->ovly1s  = 0x0;
134 	regbase->fv_trig = 0x1;
135 	DELAY(400);
136 
137 	/*
138 	 * Setup the overlay colormaps. Need to set the 0,1 (black/white)
139 	 * color for both banks.
140 	 */
141 
142 	for (i = 0; i <= 1; i++) {
143 		regbase->cmapbank = i;
144 		regbase->rgb[0].red   = 0x00;
145 		regbase->rgb[0].green = 0x00;
146 		regbase->rgb[0].blue  = 0x00;
147 		regbase->rgb[1].red   = 0xFF;
148 		regbase->rgb[1].green = 0xFF;
149 		regbase->rgb[1].blue  = 0xFF;
150 	}
151 
152 	regbase->cmapbank = 0;
153 
154 	db_waitbusy(regbase);
155 
156 	ite_fontinfo(ip);
157 	ite_fontinit(ip);
158 
159 	/*
160 	 * Clear the (visible) framebuffer.
161 	 */
162 	dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
163 	db_waitbusy(regbase);
164 
165 	/*
166 	 * Stash the inverted cursor.
167 	 */
168 	dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
169 			 ip->cblanky, ip->cblankx, ip->ftheight,
170 			 ip->ftwidth, RR_COPYINVERTED);
171 	db_waitbusy(regbase);
172 }
173 
174 void
175 dvbox_putc(ip, c, dy, dx, mode)
176 	struct ite_data *ip;
177 	int dy, dx;
178 	int c, mode;
179 {
180 	dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
181 			 dy * ip->ftheight, dx * ip->ftwidth,
182 			 ip->ftheight, ip->ftwidth, RR_COPY);
183 }
184 
185 void
186 dvbox_cursor(ip, flag)
187 	struct ite_data *ip;
188 	int flag;
189 {
190 	if (flag == DRAW_CURSOR)
191 		draw_cursor(ip)
192 	else if (flag == MOVE_CURSOR) {
193 		erase_cursor(ip)
194 		draw_cursor(ip)
195 	}
196 	else
197 		erase_cursor(ip)
198 }
199 
200 void
201 dvbox_clear(ip, sy, sx, h, w)
202 	struct ite_data *ip;
203 	int sy, sx, h, w;
204 {
205 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
206 			 sy * ip->ftheight, sx * ip->ftwidth,
207 			 h  * ip->ftheight, w  * ip->ftwidth,
208 			 RR_CLEAR);
209 }
210 
211 void
212 dvbox_scroll(ip, sy, sx, count, dir)
213 	struct ite_data *ip;
214 	int sy, count;
215 	int dir, sx;
216 {
217 	int dy = sy - count;
218 	int height = ip->rows - sy;
219 
220 	dvbox_cursor(ip, ERASE_CURSOR);
221 
222 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
223 			 dy * ip->ftheight, sx * ip->ftwidth,
224 			 height * ip->ftheight,
225 			 ip->cols * ip->ftwidth, RR_COPY);
226 }
227 
228 void
229 dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
230 	struct ite_data *ip;
231 	int sy, sx, dy, dx, h, w, func;
232 {
233 	struct dvboxfb *dp = (void *)ip->regbase;
234 	if (h == 0 || w == 0)
235 		return;
236 
237 	db_waitbusy(dp);
238 	dp->rep_rule = func << 4 | func;
239 	dp->source_y = sy;
240 	dp->source_x = sx;
241 	dp->dest_y   = dy;
242 	dp->dest_x   = dx;
243 	dp->wheight  = h;
244 	dp->wwidth   = w;
245 	dp->wmove    = 1;
246 }
247 
248 static void
249 dv_reset(dbp)
250 	struct dvboxfb *dbp;
251 {
252 
253 	dbp->reset = 0x80;
254 	DELAY(400);
255 
256 	dbp->interrupt = 0x04;
257 	dbp->en_scan   = 0x01;
258 	dbp->fbwen     = ~0;
259 	dbp->opwen     = ~0;
260 	dbp->fold      = 0x01;
261 	dbp->drive     = 0x01;
262 	dbp->rep_rule  = 0x33;
263 	dbp->alt_rr    = 0x33;
264 	dbp->zrr       = 0x33;
265 
266 	dbp->fbvenp    = 0xFF;
267 	dbp->dispen    = 0x01;
268 	dbp->fbvens    = 0x0;
269 	dbp->fv_trig   = 0x01;
270 	DELAY(400);
271 	dbp->vdrive    = 0x0;
272 	dbp->zconfig   = 0x0;
273 
274 	while (dbp->wbusy & 0x01)
275 		DELAY(400);
276 
277 	/*
278 	 * Start of missing ROM code.
279 	 */
280 	dbp->cmapbank = 0;
281 
282 	dbp->red0   = 0;
283 	dbp->red1   = 0;
284 	dbp->green0 = 0;
285 	dbp->green1 = 0;
286 	dbp->blue0  = 0;
287 	dbp->blue1  = 0;
288 
289 	dbp->panxh   = 0;
290 	dbp->panxl   = 0;
291 	dbp->panyh   = 0;
292 	dbp->panyl   = 0;
293 	dbp->zoom    = 0;
294 	dbp->cdwidth = 0x50;
295 	dbp->chstart = 0x52;
296 	dbp->cvwidth = 0x22;
297 	dbp->pz_trig = 1;
298 	/*
299 	 * End of missing ROM code.
300 	 */
301 }
302 
303 #endif
304