vga_subr.c revision 1.14 1 1.14 tsutsui /* $NetBSD: vga_subr.c,v 1.14 2003/01/31 21:57:26 tsutsui Exp $ */
2 1.1 drochner
3 1.1 drochner /*
4 1.1 drochner * Copyright (c) 1998
5 1.1 drochner * Matthias Drochner. All rights reserved.
6 1.1 drochner *
7 1.1 drochner * Redistribution and use in source and binary forms, with or without
8 1.1 drochner * modification, are permitted provided that the following conditions
9 1.1 drochner * are met:
10 1.1 drochner * 1. Redistributions of source code must retain the above copyright
11 1.1 drochner * notice, this list of conditions and the following disclaimer.
12 1.1 drochner * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 drochner * notice, this list of conditions and the following disclaimer in the
14 1.1 drochner * documentation and/or other materials provided with the distribution.
15 1.1 drochner * 3. All advertising materials mentioning features or use of this software
16 1.1 drochner * must display the following acknowledgement:
17 1.1 drochner * This product includes software developed for the NetBSD Project
18 1.1 drochner * by Matthias Drochner.
19 1.1 drochner * 4. The name of the author may not be used to endorse or promote products
20 1.1 drochner * derived from this software without specific prior written permission.
21 1.1 drochner *
22 1.1 drochner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 drochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 drochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 drochner * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 drochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 drochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 drochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 drochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 drochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 drochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 drochner *
33 1.1 drochner */
34 1.7 lukem
35 1.7 lukem #include <sys/cdefs.h>
36 1.14 tsutsui __KERNEL_RCSID(0, "$NetBSD: vga_subr.c,v 1.14 2003/01/31 21:57:26 tsutsui Exp $");
37 1.1 drochner
38 1.1 drochner #include <sys/param.h>
39 1.1 drochner #include <sys/systm.h>
40 1.1 drochner #include <sys/device.h>
41 1.1 drochner #include <sys/queue.h>
42 1.1 drochner #include <machine/bus.h>
43 1.1 drochner
44 1.2 drochner #include <dev/ic/mc6845reg.h>
45 1.14 tsutsui #include <dev/ic/pcdisplay.h>
46 1.2 drochner #include <dev/ic/pcdisplayvar.h>
47 1.1 drochner #include <dev/ic/vgareg.h>
48 1.1 drochner #include <dev/ic/vgavar.h>
49 1.1 drochner
50 1.1 drochner #include <dev/wscons/wsdisplayvar.h>
51 1.1 drochner
52 1.8 junyoung static void fontram(struct vga_handle *);
53 1.8 junyoung static void textram(struct vga_handle *);
54 1.14 tsutsui #ifdef VGA_RESET
55 1.14 tsutsui static void vga_initregs(struct vga_handle *);
56 1.14 tsutsui #endif
57 1.1 drochner
58 1.1 drochner static void
59 1.8 junyoung fontram(struct vga_handle *vh)
60 1.1 drochner {
61 1.12 tsutsui
62 1.1 drochner /* program sequencer to access character generator */
63 1.1 drochner
64 1.1 drochner vga_ts_write(vh, syncreset, 0x01); /* synchronous reset */
65 1.1 drochner vga_ts_write(vh, wrplmask, 0x04); /* write to map 2 */
66 1.1 drochner vga_ts_write(vh, memmode, 0x07); /* sequential addressing */
67 1.1 drochner vga_ts_write(vh, syncreset, 0x03); /* clear synchronous reset */
68 1.1 drochner
69 1.1 drochner /* program graphics controller to access character generator */
70 1.1 drochner
71 1.1 drochner vga_gdc_write(vh, rdplanesel, 0x02); /* select map 2 for cpu reads */
72 1.1 drochner vga_gdc_write(vh, mode, 0x00); /* disable odd-even addressing */
73 1.1 drochner vga_gdc_write(vh, misc, 0x04); /* map starts at 0xA000 */
74 1.1 drochner }
75 1.1 drochner
76 1.1 drochner static void
77 1.8 junyoung textram(struct vga_handle *vh)
78 1.1 drochner {
79 1.12 tsutsui
80 1.1 drochner /* program sequencer to access video ram */
81 1.1 drochner
82 1.1 drochner vga_ts_write(vh, syncreset, 0x01); /* synchronous reset */
83 1.1 drochner vga_ts_write(vh, wrplmask, 0x03); /* write to map 0 & 1 */
84 1.1 drochner vga_ts_write(vh, memmode, 0x03); /* odd-even addressing */
85 1.1 drochner vga_ts_write(vh, syncreset, 0x03); /* clear synchronous reset */
86 1.1 drochner
87 1.1 drochner /* program graphics controller for text mode */
88 1.1 drochner
89 1.1 drochner vga_gdc_write(vh, rdplanesel, 0x00); /* select map 0 for cpu reads */
90 1.1 drochner vga_gdc_write(vh, mode, 0x10); /* enable odd-even addressing */
91 1.1 drochner /* map starts at 0xb800 or 0xb000 (mono) */
92 1.2 drochner vga_gdc_write(vh, misc, (vh->vh_mono ? 0x0a : 0x0e));
93 1.1 drochner }
94 1.1 drochner
95 1.11 junyoung #ifndef VGA_RASTERCONSOLE
96 1.1 drochner void
97 1.10 drochner vga_loadchars(struct vga_handle *vh, int fontset, int first, int num, int lpc,
98 1.8 junyoung char *data)
99 1.1 drochner {
100 1.1 drochner int offset, i, j, s;
101 1.1 drochner
102 1.1 drochner /* fontset number swizzle done in vga_setfontset() */
103 1.1 drochner offset = (fontset << 13) | (first << 5);
104 1.1 drochner
105 1.1 drochner s = splhigh();
106 1.1 drochner fontram(vh);
107 1.1 drochner
108 1.10 drochner for (i = 0; i < num; i++)
109 1.10 drochner for (j = 0; j < lpc; j++)
110 1.10 drochner bus_space_write_1(vh->vh_memt, vh->vh_allmemh,
111 1.12 tsutsui offset + (i << 5) + j, data[i * lpc + j]);
112 1.1 drochner
113 1.1 drochner textram(vh);
114 1.1 drochner splx(s);
115 1.1 drochner }
116 1.1 drochner
117 1.1 drochner void
118 1.12 tsutsui vga_readoutchars(struct vga_handle *vh, int fontset, int first, int num,
119 1.12 tsutsui int lpc, char *data)
120 1.1 drochner {
121 1.10 drochner int offset, i, j, s;
122 1.10 drochner
123 1.10 drochner /* fontset number swizzle done in vga_setfontset() */
124 1.10 drochner offset = (fontset << 13) | (first << 5);
125 1.10 drochner
126 1.10 drochner s = splhigh();
127 1.10 drochner fontram(vh);
128 1.10 drochner
129 1.10 drochner for (i = 0; i < num; i++)
130 1.10 drochner for (j = 0; j < lpc; j++)
131 1.12 tsutsui data[i * lpc + j] = bus_space_read_1(vh->vh_memt,
132 1.12 tsutsui vh->vh_allmemh, offset + (i << 5) + j);
133 1.10 drochner
134 1.10 drochner textram(vh);
135 1.10 drochner splx(s);
136 1.10 drochner }
137 1.10 drochner
138 1.9 junyoung #ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
139 1.10 drochner void
140 1.10 drochner vga_copyfont01(struct vga_handle *vh)
141 1.10 drochner {
142 1.9 junyoung int s;
143 1.9 junyoung
144 1.9 junyoung s = splhigh();
145 1.9 junyoung fontram(vh);
146 1.10 drochner
147 1.12 tsutsui bus_space_copy_region_1(vh->vh_memt, vh->vh_allmemh, 0,
148 1.12 tsutsui vh->vh_allmemh, 1 << 13, 1 << 13);
149 1.10 drochner
150 1.9 junyoung textram(vh);
151 1.9 junyoung splx(s);
152 1.10 drochner }
153 1.10 drochner #endif
154 1.10 drochner
155 1.10 drochner void
156 1.10 drochner vga_setfontset(struct vga_handle *vh, int fontset1, int fontset2)
157 1.10 drochner {
158 1.1 drochner u_int8_t cmap;
159 1.13 tsutsui static const u_int8_t cmaptaba[] = {
160 1.3 drochner 0x00, 0x10, 0x01, 0x11,
161 1.3 drochner 0x02, 0x12, 0x03, 0x13
162 1.1 drochner };
163 1.13 tsutsui static const u_int8_t cmaptabb[] = {
164 1.3 drochner 0x00, 0x20, 0x04, 0x24,
165 1.3 drochner 0x08, 0x28, 0x0c, 0x2c
166 1.1 drochner };
167 1.1 drochner
168 1.4 drochner /* extended font if fontset1 != fontset2 */
169 1.3 drochner cmap = cmaptaba[fontset1] | cmaptabb[fontset2];
170 1.1 drochner
171 1.1 drochner vga_ts_write(vh, fontsel, cmap);
172 1.1 drochner }
173 1.1 drochner
174 1.1 drochner void
175 1.8 junyoung vga_setscreentype(struct vga_handle *vh, const struct wsscreen_descr *type)
176 1.1 drochner {
177 1.12 tsutsui
178 1.1 drochner vga_6845_write(vh, maxrow, type->fontheight - 1);
179 1.1 drochner
180 1.1 drochner /* lo byte */
181 1.1 drochner vga_6845_write(vh, vde, type->fontheight * type->nrows - 1);
182 1.1 drochner
183 1.6 ad #ifndef PCDISPLAY_SOFTCURSOR
184 1.1 drochner /* set cursor to last 2 lines */
185 1.1 drochner vga_6845_write(vh, curstart, type->fontheight - 2);
186 1.1 drochner vga_6845_write(vh, curend, type->fontheight - 1);
187 1.5 ad #endif
188 1.3 drochner /*
189 1.3 drochner * disable colour plane 3 if needed for font selection
190 1.3 drochner */
191 1.3 drochner if (type->capabilities & WSSCREEN_HILIT) {
192 1.3 drochner /*
193 1.3 drochner * these are the screens which don't support
194 1.3 drochner * 512-character fonts
195 1.3 drochner */
196 1.3 drochner vga_attr_write(vh, colplen, 0x0f);
197 1.3 drochner } else
198 1.3 drochner vga_attr_write(vh, colplen, 0x07);
199 1.1 drochner }
200 1.11 junyoung
201 1.11 junyoung #else /* !VGA_RASTERCONSOLE */
202 1.11 junyoung void
203 1.11 junyoung vga_load_builtinfont(struct vga_handle *vh, u_int8_t *font, int firstchar,
204 1.11 junyoung int numchars)
205 1.11 junyoung {
206 1.11 junyoung int i, s;
207 1.12 tsutsui
208 1.11 junyoung s = splhigh();
209 1.11 junyoung fontram(vh);
210 1.11 junyoung
211 1.11 junyoung for (i = firstchar; i < firstchar + numchars; i++)
212 1.11 junyoung bus_space_read_region_1(vh->vh_memt, vh->vh_allmemh, i * 32,
213 1.12 tsutsui font + i * 16, 16);
214 1.12 tsutsui
215 1.11 junyoung textram(vh);
216 1.11 junyoung splx(s);
217 1.11 junyoung }
218 1.11 junyoung #endif /* !VGA_RASTERCONSOLE */
219 1.14 tsutsui
220 1.14 tsutsui #ifdef VGA_RESET
221 1.14 tsutsui /*
222 1.14 tsutsui * vga_reset():
223 1.14 tsutsui * Reset VGA registers to put it into 80x25 text mode. (mode 3)
224 1.14 tsutsui * This function should be called from MD consinit() on ports
225 1.14 tsutsui * whose firmware does not use text mode at boot time.
226 1.14 tsutsui */
227 1.14 tsutsui void
228 1.14 tsutsui vga_reset(vh, md_initfunc)
229 1.14 tsutsui struct vga_handle *vh;
230 1.14 tsutsui void (*md_initfunc)(struct vga_handle *);
231 1.14 tsutsui {
232 1.14 tsutsui u_int8_t reg;
233 1.14 tsutsui
234 1.14 tsutsui if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga))
235 1.14 tsutsui return;
236 1.14 tsutsui
237 1.14 tsutsui reg = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_MISC_DATAR);
238 1.14 tsutsui vh->vh_mono = !(reg & 0x01);
239 1.14 tsutsui
240 1.14 tsutsui if (bus_space_map(vh->vh_iot, vh->vh_mono ? 0x3b0 : 0x3d0, 0x10,
241 1.14 tsutsui 0, &vh->vh_ioh_6845))
242 1.14 tsutsui goto out1;
243 1.14 tsutsui
244 1.14 tsutsui if (bus_space_map(vh->vh_memt, 0xa0000, 0x20000, 0, &vh->vh_allmemh))
245 1.14 tsutsui goto out2;
246 1.14 tsutsui
247 1.14 tsutsui if (bus_space_subregion(vh->vh_memt, vh->vh_allmemh,
248 1.14 tsutsui vh->vh_mono ? 0x10000 : 0x18000, 0x8000, &vh->vh_memh))
249 1.14 tsutsui goto out3;
250 1.14 tsutsui
251 1.14 tsutsui /* check if VGA already in text mode. */
252 1.14 tsutsui if ((vga_gdc_read(vh, misc) & 0x01) == 0)
253 1.14 tsutsui goto out3;
254 1.14 tsutsui
255 1.14 tsutsui /* initialize common VGA registers */
256 1.14 tsutsui vga_initregs(vh);
257 1.14 tsutsui
258 1.14 tsutsui /* initialize chipset specific registers */
259 1.14 tsutsui if (md_initfunc != NULL)
260 1.14 tsutsui (*md_initfunc)(vh);
261 1.14 tsutsui
262 1.14 tsutsui delay(10000);
263 1.14 tsutsui
264 1.14 tsutsui /* clear text buffer RAM */
265 1.14 tsutsui bus_space_set_region_2(vh->vh_memt, vh->vh_memh, 0,
266 1.14 tsutsui ((BG_BLACK | FG_LIGHTGREY) << 8) | ' ', 80 * 25 /*XXX*/);
267 1.14 tsutsui
268 1.14 tsutsui out3:
269 1.14 tsutsui bus_space_unmap(vh->vh_memt, vh->vh_allmemh, 0x20000);
270 1.14 tsutsui out2:
271 1.14 tsutsui bus_space_unmap(vh->vh_iot, vh->vh_ioh_6845, 0x10);
272 1.14 tsutsui out1:
273 1.14 tsutsui bus_space_unmap(vh->vh_iot, vh->vh_ioh_vga, 0x10);
274 1.14 tsutsui }
275 1.14 tsutsui
276 1.14 tsutsui /*
277 1.14 tsutsui * values to initialize registers.
278 1.14 tsutsui */
279 1.14 tsutsui
280 1.14 tsutsui /* miscellaneous output register */
281 1.14 tsutsui #define VGA_MISCOUT 0x66
282 1.14 tsutsui
283 1.14 tsutsui /* sequencer registers */
284 1.14 tsutsui static const u_int8_t vga_ts[] = {
285 1.14 tsutsui 0x03, /* 00: reset */
286 1.14 tsutsui 0x00, /* 01: clocking mode */
287 1.14 tsutsui 0x03, /* 02: map mask */
288 1.14 tsutsui 0x00, /* 03: character map select */
289 1.14 tsutsui 0x02 /* 04: memory mode */
290 1.14 tsutsui };
291 1.14 tsutsui
292 1.14 tsutsui /* CRT controller registers */
293 1.14 tsutsui static const u_int8_t vga_crtc[] = {
294 1.14 tsutsui 0x5f, /* 00: horizontal total */
295 1.14 tsutsui 0x4f, /* 01: horizontal display-enable end */
296 1.14 tsutsui 0x50, /* 02: start horizontal blanking */
297 1.14 tsutsui 0x82, /* 03: display skew control / end horizontal blanking */
298 1.14 tsutsui 0x55, /* 04: start horizontal retrace pulse */
299 1.14 tsutsui 0x81, /* 05: horizontal retrace delay / end horizontal retrace */
300 1.14 tsutsui 0xbf, /* 06: vetical total */
301 1.14 tsutsui 0x1f, /* 07: overflow register */
302 1.14 tsutsui 0x00, /* 08: preset row scan */
303 1.14 tsutsui 0x4f, /* 09: overflow / maximum scan line */
304 1.14 tsutsui 0x0d, /* 0A: cursor off / cursor start */
305 1.14 tsutsui 0x0e, /* 0B: cursor skew / cursor end */
306 1.14 tsutsui 0x00, /* 0C: start regenerative buffer address high */
307 1.14 tsutsui 0x00, /* 0D: start regenerative buffer address low */
308 1.14 tsutsui 0x00, /* 0E: cursor location high */
309 1.14 tsutsui 0x00, /* 0F: cursor location low */
310 1.14 tsutsui 0x9c, /* 10: vertical retrace start */
311 1.14 tsutsui 0x8e, /* 11: vertical interrupt / vertical retrace end */
312 1.14 tsutsui 0x8f, /* 12: vertical display enable end */
313 1.14 tsutsui 0x28, /* 13: logical line width */
314 1.14 tsutsui 0x00, /* 14: underline location */
315 1.14 tsutsui 0x96, /* 15: start vertical blanking */
316 1.14 tsutsui 0xb9, /* 16: end vertical blanking */
317 1.14 tsutsui 0xa3, /* 17: CRT mode control */
318 1.14 tsutsui 0xff /* 18: line compare */
319 1.14 tsutsui };
320 1.14 tsutsui
321 1.14 tsutsui /* graphics controller registers */
322 1.14 tsutsui static const u_int8_t vga_gdc[] = {
323 1.14 tsutsui 0x00, /* 00: set/reset map */
324 1.14 tsutsui 0x00, /* 01: enable set/reset */
325 1.14 tsutsui 0x00, /* 02: color compare */
326 1.14 tsutsui 0x00, /* 03: data rotate */
327 1.14 tsutsui 0x00, /* 04: read map select */
328 1.14 tsutsui 0x10, /* 05: graphics mode */
329 1.14 tsutsui 0x0e, /* 06: miscellaneous */
330 1.14 tsutsui 0x00, /* 07: color don't care */
331 1.14 tsutsui 0xff /* 08: bit mask */
332 1.14 tsutsui };
333 1.14 tsutsui
334 1.14 tsutsui /* attribute controller registers */
335 1.14 tsutsui static const u_int8_t vga_atc[] = {
336 1.14 tsutsui 0x00, /* 00: internal palette 0 */
337 1.14 tsutsui 0x01, /* 01: internal palette 1 */
338 1.14 tsutsui 0x02, /* 02: internal palette 2 */
339 1.14 tsutsui 0x03, /* 03: internal palette 3 */
340 1.14 tsutsui 0x04, /* 04: internal palette 4 */
341 1.14 tsutsui 0x05, /* 05: internal palette 5 */
342 1.14 tsutsui 0x14, /* 06: internal palette 6 */
343 1.14 tsutsui 0x07, /* 07: internal palette 7 */
344 1.14 tsutsui 0x38, /* 08: internal palette 8 */
345 1.14 tsutsui 0x39, /* 09: internal palette 9 */
346 1.14 tsutsui 0x3a, /* 0A: internal palette 10 */
347 1.14 tsutsui 0x3b, /* 0B: internal palette 11 */
348 1.14 tsutsui 0x3c, /* 0C: internal palette 12 */
349 1.14 tsutsui 0x3d, /* 0D: internal palette 13 */
350 1.14 tsutsui 0x3e, /* 0E: internal palette 14 */
351 1.14 tsutsui 0x3f, /* 0F: internal palette 15 */
352 1.14 tsutsui 0x0c, /* 10: attribute mode control */
353 1.14 tsutsui 0x00, /* 11: overscan color */
354 1.14 tsutsui 0x0f, /* 12: color plane enable */
355 1.14 tsutsui 0x08, /* 13: horizontal PEL panning */
356 1.14 tsutsui 0x00 /* 14: color select */
357 1.14 tsutsui };
358 1.14 tsutsui
359 1.14 tsutsui /* video DAC palette registers */
360 1.14 tsutsui /* XXX only set up 16 colors used by internal palette in ATC regsters */
361 1.14 tsutsui static const u_int8_t vga_dacpal[] = {
362 1.14 tsutsui /* R G B */
363 1.14 tsutsui 0x00, 0x00, 0x00, /* BLACK */
364 1.14 tsutsui 0x00, 0x00, 0x2a, /* BLUE */
365 1.14 tsutsui 0x00, 0x2a, 0x00, /* GREEN */
366 1.14 tsutsui 0x00, 0x2a, 0x2a, /* CYAN */
367 1.14 tsutsui 0x2a, 0x00, 0x00, /* RED */
368 1.14 tsutsui 0x2a, 0x00, 0x2a, /* MAGENTA */
369 1.14 tsutsui 0x2a, 0x15, 0x00, /* BROWN */
370 1.14 tsutsui 0x2a, 0x2a, 0x2a, /* LIGHTGREY */
371 1.14 tsutsui 0x15, 0x15, 0x15, /* DARKGREY */
372 1.14 tsutsui 0x15, 0x15, 0x3f, /* LIGHTBLUE */
373 1.14 tsutsui 0x15, 0x3f, 0x15, /* LIGHTGREEN */
374 1.14 tsutsui 0x15, 0x3f, 0x3f, /* LIGHTCYAN */
375 1.14 tsutsui 0x3f, 0x15, 0x15, /* LIGHTRED */
376 1.14 tsutsui 0x3f, 0x15, 0x3f, /* LIGHTMAGENTA */
377 1.14 tsutsui 0x3f, 0x3f, 0x15, /* YELLOW */
378 1.14 tsutsui 0x3f, 0x3f, 0x3f /* WHITE */
379 1.14 tsutsui };
380 1.14 tsutsui
381 1.14 tsutsui static void
382 1.14 tsutsui vga_initregs(vh)
383 1.14 tsutsui struct vga_handle *vh;
384 1.14 tsutsui {
385 1.14 tsutsui int i;
386 1.14 tsutsui
387 1.14 tsutsui /* disable video */
388 1.14 tsutsui vga_ts_write(vh, mode, vga_ts[1] | VGA_TS_MODE_BLANK);
389 1.14 tsutsui
390 1.14 tsutsui /* synchronous reset */
391 1.14 tsutsui vga_ts_write(vh, syncreset, 0x01);
392 1.14 tsutsui /* set TS regsters */
393 1.14 tsutsui for (i = 2; i < VGA_TS_NREGS; i++)
394 1.14 tsutsui _vga_ts_write(vh, i, vga_ts[i]);
395 1.14 tsutsui /* clear synchronous reset */
396 1.14 tsutsui vga_ts_write(vh, syncreset, 0x03);
397 1.14 tsutsui
398 1.14 tsutsui /* unprotect CRTC regsters */
399 1.14 tsutsui vga_6845_write(vh, vsynce, vga_6845_read(vh, vsynce) & ~0x80);
400 1.14 tsutsui /* set CRTC regsters */
401 1.14 tsutsui for (i = 0; i < MC6845_NREGS; i++)
402 1.14 tsutsui _vga_6845_write(vh, i, vga_crtc[i]);
403 1.14 tsutsui
404 1.14 tsutsui /* set GDC regsters */
405 1.14 tsutsui for (i = 0; i < VGA_GDC_NREGS; i++)
406 1.14 tsutsui _vga_gdc_write(vh, i, vga_gdc[i]);
407 1.14 tsutsui
408 1.14 tsutsui /* set ATC regsters */
409 1.14 tsutsui for (i = 0; i < VGA_ATC_NREGS; i++)
410 1.14 tsutsui _vga_attr_write(vh, i, vga_atc[i]);
411 1.14 tsutsui
412 1.14 tsutsui /* set DAC palette */
413 1.14 tsutsui if (!vh->vh_mono) {
414 1.14 tsutsui for (i = 0; i < 16; i++) {
415 1.14 tsutsui bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga,
416 1.14 tsutsui VGA_DAC_ADDRW, vga_atc[i]);
417 1.14 tsutsui bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga,
418 1.14 tsutsui VGA_DAC_PALETTE, vga_dacpal[i * 3 + 0]);
419 1.14 tsutsui bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga,
420 1.14 tsutsui VGA_DAC_PALETTE, vga_dacpal[i * 3 + 1]);
421 1.14 tsutsui bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga,
422 1.14 tsutsui VGA_DAC_PALETTE, vga_dacpal[i * 3 + 2]);
423 1.14 tsutsui }
424 1.14 tsutsui }
425 1.14 tsutsui
426 1.14 tsutsui /* set misc output register */
427 1.14 tsutsui bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga,
428 1.14 tsutsui VGA_MISC_DATAW, VGA_MISCOUT | (vh->vh_mono ? 0 : 0x01));
429 1.14 tsutsui
430 1.14 tsutsui /* reenable video */
431 1.14 tsutsui vga_ts_write(vh, mode, vga_ts[1] & ~VGA_TS_MODE_BLANK);
432 1.14 tsutsui }
433 1.14 tsutsui #endif /* VGA_RESET */
434