1 /*
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1990, 1993
4 * The Regents of the University of California. 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.2 92/01/20$
13 *
14 * @(#)ite_dv.c 8.1 (Berkeley) 06/10/93
15 */
16
17 #include <hp300/stand/samachdep.h>
18
19 #ifdef ITECONSOLE
20
21 #include <sys/param.h>
22 #include <hp/dev/itevar.h>
23 #include <hp/dev/itereg.h>
24 #include <hp300/dev/grf_dvreg.h>
25
26 #define REGBASE ((struct dvboxfb *)(ip->regbase))
27 #define WINDOWMOVER dvbox_windowmove
28
29 dvbox_init(ip)
30 struct ite_softc *ip;
31 {
32 int i;
33
34 dv_reset(ip->regbase);
35 DELAY(4000);
36
37 /*
38 * Turn on frame buffer, turn on overlay planes, set replacement
39 * rule, enable top overlay plane writes for ite, disable all frame
40 * buffer planes, set byte per pixel, and display frame buffer 0.
41 * Lastly, turn on the box.
42 */
43 REGBASE->interrupt = 0x04;
44 REGBASE->drive = 0x10;
45 REGBASE->rep_rule = RR_COPY << 4 | RR_COPY;
46 REGBASE->opwen = 0x01;
47 REGBASE->fbwen = 0x0;
48 REGBASE->fold = 0x01;
49 REGBASE->vdrive = 0x0;
50 REGBASE->dispen = 0x01;
51
52 /*
53 * Video enable top overlay plane.
54 */
55 REGBASE->opvenp = 0x01;
56 REGBASE->opvens = 0x01;
57
58 /*
59 * Make sure that overlay planes override frame buffer planes.
60 */
61 REGBASE->ovly0p = 0x0;
62 REGBASE->ovly0s = 0x0;
63 REGBASE->ovly1p = 0x0;
64 REGBASE->ovly1s = 0x0;
65 REGBASE->fv_trig = 0x1;
66 DELAY(400);
67
68 /*
69 * Setup the overlay colormaps. Need to set the 0,1 (black/white)
70 * color for both banks.
71 */
72
73 for (i = 0; i <= 1; i++) {
74 REGBASE->cmapbank = i;
75 REGBASE->rgb[0].red = 0x00;
76 REGBASE->rgb[0].green = 0x00;
77 REGBASE->rgb[0].blue = 0x00;
78 REGBASE->rgb[1].red = 0xFF;
79 REGBASE->rgb[1].green = 0xFF;
80 REGBASE->rgb[1].blue = 0xFF;
81 }
82 REGBASE->cmapbank = 0;
83
84 db_waitbusy(ip->regbase);
85
86 ite_fontinfo(ip);
87 ite_fontinit(ip);
88
89 /*
90 * Clear the (visible) framebuffer.
91 */
92 dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
93 db_waitbusy(ip->regbase);
94
95 /*
96 * Stash the inverted cursor.
97 */
98 dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
99 ip->cblanky, ip->cblankx, ip->ftheight,
100 ip->ftwidth, RR_COPYINVERTED);
101 db_waitbusy(ip->regbase);
102 }
103
dvbox_putc(ip,c,dy,dx,mode)104 dvbox_putc(ip, c, dy, dx, mode)
105 register struct ite_softc *ip;
106 register int dy, dx;
107 int c, mode;
108 {
109 dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
110 dy * ip->ftheight, dx * ip->ftwidth,
111 ip->ftheight, ip->ftwidth, RR_COPY);
112 }
113
dvbox_cursor(ip,flag)114 dvbox_cursor(ip, flag)
115 register struct ite_softc *ip;
116 register int flag;
117 {
118 if (flag == DRAW_CURSOR)
119 draw_cursor(ip)
120 else if (flag == MOVE_CURSOR) {
121 erase_cursor(ip)
122 draw_cursor(ip)
123 }
124 else
125 erase_cursor(ip)
126 }
127
128 dvbox_clear(ip, sy, sx, h, w)
129 struct ite_softc *ip;
130 register int sy, sx, h, w;
131 {
132 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
133 sy * ip->ftheight, sx * ip->ftwidth,
134 h * ip->ftheight, w * ip->ftwidth,
135 RR_CLEAR);
136 }
137
dvbox_scroll(ip,sy,sx,count,dir)138 dvbox_scroll(ip, sy, sx, count, dir)
139 register struct ite_softc *ip;
140 register int sy, count;
141 int dir, sx;
142 {
143 register int dy = sy - count;
144 register int height = ip->rows - sy;
145
146 dvbox_cursor(ip, ERASE_CURSOR);
147
148 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
149 dy * ip->ftheight, sx * ip->ftwidth,
150 height * ip->ftheight,
151 ip->cols * ip->ftwidth, RR_COPY);
152 }
153
154 dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
155 struct ite_softc *ip;
156 int sy, sx, dy, dx, h, w, func;
157 {
158 register struct dvboxfb *dp = REGBASE;
159 if (h == 0 || w == 0)
160 return;
161
162 db_waitbusy(ip->regbase);
163 dp->rep_rule = func << 4 | func;
164 dp->source_y = sy;
165 dp->source_x = sx;
166 dp->dest_y = dy;
167 dp->dest_x = dx;
168 dp->wheight = h;
169 dp->wwidth = w;
170 dp->wmove = 1;
171 }
172
dv_reset(dbp)173 dv_reset(dbp)
174 register struct dvboxfb *dbp;
175 {
176 dbp->reset = 0x80;
177 DELAY(400);
178
179 dbp->interrupt = 0x04;
180 dbp->en_scan = 0x01;
181 dbp->fbwen = ~0;
182 dbp->opwen = ~0;
183 dbp->fold = 0x01;
184 dbp->drive = 0x01;
185 dbp->rep_rule = 0x33;
186 dbp->alt_rr = 0x33;
187 dbp->zrr = 0x33;
188
189 dbp->fbvenp = 0xFF;
190 dbp->dispen = 0x01;
191 dbp->fbvens = 0x0;
192 dbp->fv_trig = 0x01;
193 DELAY(400);
194 dbp->vdrive = 0x0;
195 dbp->zconfig = 0x0;
196
197 while (dbp->wbusy & 0x01)
198 DELAY(400);
199
200 /*
201 * Start of missing ROM code.
202 */
203 dbp->cmapbank = 0;
204
205 dbp->red0 = 0;
206 dbp->red1 = 0;
207 dbp->green0 = 0;
208 dbp->green1 = 0;
209 dbp->blue0 = 0;
210 dbp->blue1 = 0;
211
212 dbp->panxh = 0;
213 dbp->panxl = 0;
214 dbp->panyh = 0;
215 dbp->panyl = 0;
216 dbp->zoom = 0;
217 dbp->cdwidth = 0x50;
218 dbp->chstart = 0x52;
219 dbp->cvwidth = 0x22;
220 dbp->pz_trig = 1;
221 /*
222 * End of missing ROM code.
223 */
224 }
225
226 #endif
227