ite_dv.c revision 1.6 1 /* $NetBSD: ite_dv.c,v 1.6 2006/01/28 12:00:56 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(struct ite_data *ip)
97 {
98 struct dvboxfb *regbase;
99 int i;
100
101 regbase = (void *)ip->regbase;
102 dv_reset(regbase);
103 DELAY(4000);
104
105 /*
106 * Turn on frame buffer, turn on overlay planes, set replacement
107 * rule, enable top overlay plane writes for ite, disable all frame
108 * buffer planes, set byte per pixel, and display frame buffer 0.
109 * Lastly, turn on the box.
110 */
111 regbase->interrupt = 0x04;
112 regbase->drive = 0x10;
113 regbase->rep_rule = RR_COPY << 4 | RR_COPY;
114 regbase->opwen = 0x01;
115 regbase->fbwen = 0x0;
116 regbase->fold = 0x01;
117 regbase->vdrive = 0x0;
118 regbase->dispen = 0x01;
119
120 /*
121 * Video enable top overlay plane.
122 */
123 regbase->opvenp = 0x01;
124 regbase->opvens = 0x01;
125
126 /*
127 * Make sure that overlay planes override frame buffer planes.
128 */
129 regbase->ovly0p = 0x0;
130 regbase->ovly0s = 0x0;
131 regbase->ovly1p = 0x0;
132 regbase->ovly1s = 0x0;
133 regbase->fv_trig = 0x1;
134 DELAY(400);
135
136 /*
137 * Setup the overlay colormaps. Need to set the 0,1 (black/white)
138 * color for both banks.
139 */
140
141 for (i = 0; i <= 1; i++) {
142 regbase->cmapbank = i;
143 regbase->rgb[0].red = 0x00;
144 regbase->rgb[0].green = 0x00;
145 regbase->rgb[0].blue = 0x00;
146 regbase->rgb[1].red = 0xFF;
147 regbase->rgb[1].green = 0xFF;
148 regbase->rgb[1].blue = 0xFF;
149 }
150
151 regbase->cmapbank = 0;
152
153 db_waitbusy(regbase);
154
155 ite_fontinfo(ip);
156 ite_fontinit(ip);
157
158 /*
159 * Clear the (visible) framebuffer.
160 */
161 dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
162 db_waitbusy(regbase);
163
164 /*
165 * Stash the inverted cursor.
166 */
167 dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
168 ip->cblanky, ip->cblankx, ip->ftheight,
169 ip->ftwidth, RR_COPYINVERTED);
170 db_waitbusy(regbase);
171 }
172
173 void
174 dvbox_putc(struct ite_data *ip, int c, int dy, int dx, int mode)
175 {
176
177 dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
178 dy * ip->ftheight, dx * ip->ftwidth,
179 ip->ftheight, ip->ftwidth, RR_COPY);
180 }
181
182 void
183 dvbox_cursor(struct ite_data *ip, int flag)
184 {
185 if (flag == DRAW_CURSOR)
186 draw_cursor(ip)
187 else if (flag == MOVE_CURSOR) {
188 erase_cursor(ip)
189 draw_cursor(ip)
190 }
191 else
192 erase_cursor(ip)
193 }
194
195 void
196 dvbox_clear(struct ite_data *ip, int sy, int sx, int h, int w)
197 {
198
199 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
200 sy * ip->ftheight, sx * ip->ftwidth,
201 h * ip->ftheight, w * ip->ftwidth,
202 RR_CLEAR);
203 }
204
205 void
206 dvbox_scroll(struct ite_data *ip, int sy, int sx, int count, int dir)
207 {
208 int dy = sy - count;
209 int height = ip->rows - sy;
210
211 dvbox_cursor(ip, ERASE_CURSOR);
212
213 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
214 dy * ip->ftheight, sx * ip->ftwidth,
215 height * ip->ftheight,
216 ip->cols * ip->ftwidth, RR_COPY);
217 }
218
219 void
220 dvbox_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx,
221 int h, int w, int func)
222 {
223 struct dvboxfb *dp = (void *)ip->regbase;
224
225 if (h == 0 || w == 0)
226 return;
227
228 db_waitbusy(dp);
229 dp->rep_rule = func << 4 | func;
230 dp->source_y = sy;
231 dp->source_x = sx;
232 dp->dest_y = dy;
233 dp->dest_x = dx;
234 dp->wheight = h;
235 dp->wwidth = w;
236 dp->wmove = 1;
237 }
238
239 static void
240 dv_reset(struct dvboxfb *dbp)
241 {
242
243 dbp->reset = 0x80;
244 DELAY(400);
245
246 dbp->interrupt = 0x04;
247 dbp->en_scan = 0x01;
248 dbp->fbwen = ~0;
249 dbp->opwen = ~0;
250 dbp->fold = 0x01;
251 dbp->drive = 0x01;
252 dbp->rep_rule = 0x33;
253 dbp->alt_rr = 0x33;
254 dbp->zrr = 0x33;
255
256 dbp->fbvenp = 0xFF;
257 dbp->dispen = 0x01;
258 dbp->fbvens = 0x0;
259 dbp->fv_trig = 0x01;
260 DELAY(400);
261 dbp->vdrive = 0x0;
262 dbp->zconfig = 0x0;
263
264 while (dbp->wbusy & 0x01)
265 DELAY(400);
266
267 /*
268 * Start of missing ROM code.
269 */
270 dbp->cmapbank = 0;
271
272 dbp->red0 = 0;
273 dbp->red1 = 0;
274 dbp->green0 = 0;
275 dbp->green1 = 0;
276 dbp->blue0 = 0;
277 dbp->blue1 = 0;
278
279 dbp->panxh = 0;
280 dbp->panxl = 0;
281 dbp->panyh = 0;
282 dbp->panyl = 0;
283 dbp->zoom = 0;
284 dbp->cdwidth = 0x50;
285 dbp->chstart = 0x52;
286 dbp->cvwidth = 0x22;
287 dbp->pz_trig = 1;
288 /*
289 * End of missing ROM code.
290 */
291 }
292
293 #endif
294