fb.c revision 1.5 1 1.5 tsubai /* $NetBSD: fb.c,v 1.5 2000/11/13 16:48:42 tsubai Exp $ */
2 1.5 tsubai
3 1.5 tsubai /*-
4 1.5 tsubai * Copyright (c) 2000 Tsubai Masanari. All rights reserved.
5 1.1 tsubai *
6 1.1 tsubai * Redistribution and use in source and binary forms, with or without
7 1.1 tsubai * modification, are permitted provided that the following conditions
8 1.1 tsubai * are met:
9 1.1 tsubai * 1. Redistributions of source code must retain the above copyright
10 1.1 tsubai * notice, this list of conditions and the following disclaimer.
11 1.1 tsubai * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 tsubai * notice, this list of conditions and the following disclaimer in the
13 1.1 tsubai * documentation and/or other materials provided with the distribution.
14 1.5 tsubai * 3. The name of the author may not be used to endorse or promote products
15 1.5 tsubai * derived from this software without specific prior written permission.
16 1.1 tsubai *
17 1.5 tsubai * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 1.5 tsubai * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 1.5 tsubai * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 1.5 tsubai * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 1.5 tsubai * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 1.5 tsubai * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 1.5 tsubai * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 1.5 tsubai * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 1.5 tsubai * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 1.5 tsubai * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 1.1 tsubai */
28 1.1 tsubai
29 1.1 tsubai #include <sys/param.h>
30 1.1 tsubai #include <sys/device.h>
31 1.5 tsubai #include <sys/ioctl.h>
32 1.5 tsubai #include <sys/malloc.h>
33 1.1 tsubai #include <sys/systm.h>
34 1.1 tsubai
35 1.5 tsubai #include <uvm/uvm_extern.h>
36 1.5 tsubai
37 1.5 tsubai #include <machine/adrsmap.h>
38 1.1 tsubai #include <machine/autoconf.h>
39 1.1 tsubai
40 1.5 tsubai #include <dev/wscons/wsconsio.h>
41 1.5 tsubai #include <dev/wscons/wsdisplayvar.h>
42 1.5 tsubai #include <dev/rasops/rasops.h>
43 1.5 tsubai
44 1.5 tsubai struct fb_devconfig {
45 1.5 tsubai u_char *dc_fbbase; /* VRAM base address */
46 1.5 tsubai struct rasops_info dc_ri;
47 1.5 tsubai };
48 1.1 tsubai
49 1.1 tsubai struct fb_softc {
50 1.1 tsubai struct device sc_dev;
51 1.5 tsubai struct fb_devconfig *sc_dc;
52 1.5 tsubai int sc_nscreens;
53 1.1 tsubai };
54 1.1 tsubai
55 1.5 tsubai int fb_match(struct device *, struct cfdata *, void *);
56 1.5 tsubai void fb_attach(struct device *, struct device *, void *);
57 1.5 tsubai
58 1.5 tsubai int fb_common_init(struct fb_devconfig *);
59 1.5 tsubai int fb_is_console(void);
60 1.5 tsubai
61 1.5 tsubai int fb_ioctl(void *, u_long, caddr_t, int, struct proc *);
62 1.5 tsubai paddr_t fb_mmap(void *, off_t, int);
63 1.5 tsubai int fb_alloc_screen(void *, const struct wsscreen_descr *, void **, int *,
64 1.5 tsubai int *, long *);
65 1.5 tsubai void fb_free_screen(void *, void *);
66 1.5 tsubai int fb_show_screen(void *, void *, int, void (*)(void *, int, int), void *);
67 1.5 tsubai
68 1.5 tsubai void fb_cnattach(void);
69 1.5 tsubai
70 1.5 tsubai static void fb253_init(int);
71 1.1 tsubai
72 1.1 tsubai struct cfattach fb_ca = {
73 1.5 tsubai sizeof(struct fb_softc), fb_match, fb_attach,
74 1.5 tsubai };
75 1.5 tsubai
76 1.5 tsubai struct fb_devconfig fb_console_dc;
77 1.5 tsubai
78 1.5 tsubai struct wsdisplay_accessops fb_accessops = {
79 1.5 tsubai fb_ioctl,
80 1.5 tsubai fb_mmap,
81 1.5 tsubai fb_alloc_screen,
82 1.5 tsubai fb_free_screen,
83 1.5 tsubai fb_show_screen,
84 1.5 tsubai NULL /* load_font */
85 1.5 tsubai };
86 1.5 tsubai
87 1.5 tsubai struct wsscreen_descr fb_stdscreen = {
88 1.5 tsubai "std",
89 1.5 tsubai 0, 0,
90 1.5 tsubai 0,
91 1.5 tsubai 0, 0,
92 1.5 tsubai WSSCREEN_REVERSE
93 1.1 tsubai };
94 1.1 tsubai
95 1.5 tsubai const struct wsscreen_descr *fb_scrlist[] = {
96 1.5 tsubai &fb_stdscreen
97 1.5 tsubai };
98 1.5 tsubai
99 1.5 tsubai struct wsscreen_list fb_screenlist = {
100 1.5 tsubai sizeof(fb_scrlist) / sizeof(fb_scrlist[0]), fb_scrlist
101 1.5 tsubai };
102 1.1 tsubai
103 1.5 tsubai #define NWB253_VRAM ((u_char *) 0x88000000)
104 1.5 tsubai #define NWB253_CTLREG ((u_short *)0xb8ff0000)
105 1.5 tsubai #define NWB253_CRTREG ((u_short *)0xb8fe0000)
106 1.1 tsubai
107 1.5 tsubai static char *devname[8] = { "NWB-512", "NWB-518", "NWE-501" }; /* XXX ? */
108 1.5 tsubai
109 1.5 tsubai int
110 1.5 tsubai fb_match(parent, match, aux)
111 1.1 tsubai struct device *parent;
112 1.5 tsubai struct cfdata *match;
113 1.1 tsubai void *aux;
114 1.1 tsubai {
115 1.1 tsubai struct confargs *ca = aux;
116 1.1 tsubai
117 1.5 tsubai if (strcmp(ca->ca_name, "fb") != 0)
118 1.1 tsubai return 0;
119 1.1 tsubai
120 1.5 tsubai if (badaddr(NWB253_CTLREG, 2) || badaddr(NWB253_CRTREG, 2))
121 1.5 tsubai return 0;
122 1.5 tsubai if ((*(volatile u_short *)NWB253_CTLREG & 7) != 4)
123 1.1 tsubai return 0;
124 1.1 tsubai
125 1.1 tsubai return 1;
126 1.1 tsubai }
127 1.1 tsubai
128 1.5 tsubai void
129 1.5 tsubai fb_attach(parent, self, aux)
130 1.5 tsubai struct device *parent, *self;
131 1.1 tsubai void *aux;
132 1.1 tsubai {
133 1.5 tsubai struct fb_softc *sc = (void *)self;
134 1.5 tsubai struct wsemuldisplaydev_attach_args waa;
135 1.5 tsubai struct fb_devconfig *dc;
136 1.5 tsubai struct rasops_info *ri;
137 1.5 tsubai int console;
138 1.5 tsubai volatile u_short *ctlreg = NWB253_CTLREG;
139 1.5 tsubai int id;
140 1.5 tsubai
141 1.5 tsubai console = fb_is_console();
142 1.5 tsubai
143 1.5 tsubai if (console) {
144 1.5 tsubai dc = &fb_console_dc;
145 1.5 tsubai ri = &dc->dc_ri;
146 1.5 tsubai sc->sc_nscreens = 1;
147 1.5 tsubai } else {
148 1.5 tsubai dc = malloc(sizeof(struct fb_devconfig), M_DEVBUF, M_WAITOK);
149 1.5 tsubai bzero(dc, sizeof(struct fb_devconfig));
150 1.5 tsubai
151 1.5 tsubai dc->dc_fbbase = NWB253_VRAM;
152 1.5 tsubai fb_common_init(dc);
153 1.5 tsubai ri = &dc->dc_ri;
154 1.5 tsubai
155 1.5 tsubai /* clear screen */
156 1.5 tsubai (*ri->ri_ops.eraserows)(ri, 0, ri->ri_rows, 0);
157 1.5 tsubai
158 1.5 tsubai fb253_init(id);
159 1.5 tsubai }
160 1.5 tsubai sc->sc_dc = dc;
161 1.5 tsubai
162 1.5 tsubai id = (*ctlreg >> 8) & 0xf;
163 1.5 tsubai printf(": %s, %d x %d, %dbpp\n", devname[id],
164 1.5 tsubai ri->ri_width, ri->ri_height, ri->ri_depth);
165 1.5 tsubai
166 1.5 tsubai waa.console = console;
167 1.5 tsubai waa.scrdata = &fb_screenlist;
168 1.5 tsubai waa.accessops = &fb_accessops;
169 1.5 tsubai waa.accesscookie = sc;
170 1.1 tsubai
171 1.5 tsubai config_found(self, &waa, wsemuldisplaydevprint);
172 1.1 tsubai }
173 1.1 tsubai
174 1.1 tsubai int
175 1.5 tsubai fb_common_init(dc)
176 1.5 tsubai struct fb_devconfig *dc;
177 1.1 tsubai {
178 1.5 tsubai struct rasops_info *ri = &dc->dc_ri;
179 1.5 tsubai volatile u_short *ctlreg = NWB253_CTLREG;
180 1.5 tsubai int id;
181 1.5 tsubai int width, height, xoff, yoff, cols, rows;
182 1.5 tsubai
183 1.5 tsubai id = (*ctlreg >> 8) & 0xf;
184 1.5 tsubai
185 1.5 tsubai /* initialize rasops */
186 1.5 tsubai switch (id) {
187 1.5 tsubai case 0:
188 1.5 tsubai width = 816;
189 1.5 tsubai height = 1024;
190 1.5 tsubai break;
191 1.5 tsubai case 1:
192 1.5 tsubai case 2:
193 1.5 tsubai width = 1024;
194 1.5 tsubai height = 768;
195 1.5 tsubai break;
196 1.1 tsubai }
197 1.1 tsubai
198 1.5 tsubai ri->ri_width = width;
199 1.5 tsubai ri->ri_height = height;
200 1.5 tsubai ri->ri_depth = 1;
201 1.5 tsubai ri->ri_stride = 2048 / 8;
202 1.5 tsubai ri->ri_bits = dc->dc_fbbase;
203 1.5 tsubai ri->ri_flg = RI_FULLCLEAR;
204 1.5 tsubai
205 1.5 tsubai rasops_init(ri, 24, 80);
206 1.5 tsubai rows = (height - 2) / ri->ri_font->fontheight;
207 1.5 tsubai cols = ((width - 2) / ri->ri_font->fontwidth) & ~7;
208 1.5 tsubai xoff = ((width - cols * ri->ri_font->fontwidth) / 2 / 8) & ~3;
209 1.5 tsubai yoff = (height - rows * ri->ri_font->fontheight) / 2;
210 1.5 tsubai rasops_reconfig(ri, rows, cols);
211 1.5 tsubai
212 1.5 tsubai ri->ri_xorigin = xoff;
213 1.5 tsubai ri->ri_yorigin = yoff;
214 1.5 tsubai ri->ri_bits = dc->dc_fbbase + xoff + ri->ri_stride * yoff;
215 1.5 tsubai
216 1.5 tsubai fb_stdscreen.nrows = ri->ri_rows;
217 1.5 tsubai fb_stdscreen.ncols = ri->ri_cols;
218 1.5 tsubai fb_stdscreen.textops = &ri->ri_ops;
219 1.5 tsubai fb_stdscreen.capabilities = ri->ri_caps;
220 1.1 tsubai
221 1.1 tsubai return 0;
222 1.1 tsubai }
223 1.1 tsubai
224 1.1 tsubai int
225 1.5 tsubai fb_is_console()
226 1.1 tsubai {
227 1.5 tsubai volatile u_int *dipsw = (void *)DIP_SWITCH;
228 1.1 tsubai
229 1.5 tsubai if (*dipsw & 7) /* XXX right? */
230 1.5 tsubai return 1;
231 1.1 tsubai
232 1.1 tsubai return 0;
233 1.1 tsubai }
234 1.1 tsubai
235 1.1 tsubai int
236 1.5 tsubai fb_ioctl(v, cmd, data, flag, p)
237 1.5 tsubai void *v;
238 1.1 tsubai u_long cmd;
239 1.1 tsubai caddr_t data;
240 1.5 tsubai int flag;
241 1.1 tsubai struct proc *p;
242 1.1 tsubai {
243 1.5 tsubai struct fb_softc *sc = v;
244 1.5 tsubai struct fb_devconfig *dc = sc->sc_dc;
245 1.5 tsubai struct wsdisplay_fbinfo *wdf;
246 1.1 tsubai
247 1.5 tsubai switch (cmd) {
248 1.5 tsubai case WSDISPLAYIO_GTYPE:
249 1.5 tsubai *(int *)data = WSDISPLAY_TYPE_UNKNOWN; /* XXX */
250 1.5 tsubai return 0;
251 1.1 tsubai
252 1.5 tsubai case WSDISPLAYIO_GINFO:
253 1.5 tsubai wdf = (void *)data;
254 1.5 tsubai wdf->height = dc->dc_ri.ri_height;
255 1.5 tsubai wdf->width = dc->dc_ri.ri_width;
256 1.5 tsubai wdf->depth = dc->dc_ri.ri_depth;
257 1.5 tsubai wdf->cmsize = 2;
258 1.5 tsubai return 0;
259 1.1 tsubai
260 1.5 tsubai case WSDISPLAYIO_SVIDEO:
261 1.5 tsubai if (*(int *)data == WSDISPLAYIO_VIDEO_OFF) {
262 1.5 tsubai volatile u_short *ctlreg = NWB253_CTLREG;
263 1.5 tsubai *ctlreg = 0; /* stop crtc */
264 1.5 tsubai } else {
265 1.5 tsubai volatile u_short *ctlreg = NWB253_CTLREG;
266 1.5 tsubai int id = (*ctlreg >> 8) & 0xf;
267 1.5 tsubai fb253_init(id);
268 1.5 tsubai }
269 1.5 tsubai return 0;
270 1.1 tsubai
271 1.5 tsubai case WSDISPLAYIO_GETCMAP:
272 1.5 tsubai case WSDISPLAYIO_PUTCMAP:
273 1.1 tsubai }
274 1.5 tsubai return -1;
275 1.1 tsubai }
276 1.1 tsubai
277 1.4 simonb paddr_t
278 1.5 tsubai fb_mmap(v, offset, prot)
279 1.5 tsubai void *v;
280 1.5 tsubai off_t offset;
281 1.4 simonb int prot;
282 1.1 tsubai {
283 1.5 tsubai struct fb_softc *sc = v;
284 1.5 tsubai struct fb_devconfig *dc = sc->sc_dc;
285 1.5 tsubai struct rasops_info *ri = &dc->dc_ri;
286 1.1 tsubai
287 1.5 tsubai if (offset >= (ri->ri_stride * ri->ri_height) || offset < 0)
288 1.1 tsubai return -1;
289 1.1 tsubai
290 1.5 tsubai return mips_btop((int)dc->dc_fbbase + offset);
291 1.5 tsubai }
292 1.1 tsubai
293 1.5 tsubai int
294 1.5 tsubai fb_alloc_screen(v, scrdesc, cookiep, ccolp, crowp, attrp)
295 1.5 tsubai void *v;
296 1.5 tsubai const struct wsscreen_descr *scrdesc;
297 1.5 tsubai void **cookiep;
298 1.5 tsubai int *ccolp, *crowp;
299 1.5 tsubai long *attrp;
300 1.5 tsubai {
301 1.5 tsubai struct fb_softc *sc = v;
302 1.5 tsubai struct rasops_info *ri = &sc->sc_dc->dc_ri;
303 1.5 tsubai long defattr;
304 1.5 tsubai
305 1.5 tsubai if (sc->sc_nscreens > 0)
306 1.5 tsubai return ENOMEM;
307 1.5 tsubai
308 1.5 tsubai *cookiep = ri;
309 1.5 tsubai *ccolp = *crowp = 0;
310 1.5 tsubai (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
311 1.5 tsubai *attrp = defattr;
312 1.5 tsubai sc->sc_nscreens++;
313 1.1 tsubai
314 1.5 tsubai return 0;
315 1.1 tsubai }
316 1.1 tsubai
317 1.5 tsubai void
318 1.5 tsubai fb_free_screen(v, cookie)
319 1.5 tsubai void *v;
320 1.5 tsubai void *cookie;
321 1.1 tsubai {
322 1.5 tsubai struct fb_softc *sc = v;
323 1.5 tsubai
324 1.5 tsubai if (sc->sc_dc == &fb_console_dc)
325 1.5 tsubai panic("fb_free_screen: console");
326 1.5 tsubai
327 1.5 tsubai sc->sc_nscreens--;
328 1.1 tsubai }
329 1.1 tsubai
330 1.5 tsubai int
331 1.5 tsubai fb_show_screen(v, cookie, waitok, cb, cbarg)
332 1.5 tsubai void *v;
333 1.5 tsubai void *cookie;
334 1.5 tsubai int waitok;
335 1.5 tsubai void (*cb)(void *, int, int);
336 1.5 tsubai void *cbarg;
337 1.1 tsubai {
338 1.5 tsubai return 0;
339 1.1 tsubai }
340 1.1 tsubai
341 1.5 tsubai void
342 1.5 tsubai fb_cnattach()
343 1.1 tsubai {
344 1.5 tsubai struct fb_devconfig *dc = &fb_console_dc;
345 1.5 tsubai struct rasops_info *ri = &dc->dc_ri;
346 1.5 tsubai long defattr;
347 1.5 tsubai
348 1.5 tsubai if (!fb_is_console())
349 1.5 tsubai return;
350 1.5 tsubai
351 1.5 tsubai dc->dc_fbbase = NWB253_VRAM;
352 1.5 tsubai fb_common_init(dc);
353 1.5 tsubai
354 1.5 tsubai (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
355 1.5 tsubai wsdisplay_cnattach(&fb_stdscreen, ri, 0, ri->ri_rows - 1, defattr);
356 1.5 tsubai }
357 1.5 tsubai
358 1.5 tsubai static u_char
359 1.5 tsubai nwp512_data1[] = {
360 1.5 tsubai 0x00, 0x44,
361 1.5 tsubai 0x01, 0x33,
362 1.5 tsubai 0x02, 0x3c,
363 1.5 tsubai 0x03, 0x38,
364 1.5 tsubai 0x04, 0x84,
365 1.5 tsubai 0x05, 0x03,
366 1.5 tsubai 0x06, 0x80,
367 1.5 tsubai 0x07, 0x80,
368 1.5 tsubai 0x08, 0x10,
369 1.5 tsubai 0x09, 0x07,
370 1.5 tsubai 0x0a, 0x20,
371 1.5 tsubai 0x0c, 0x00,
372 1.5 tsubai 0x0d, 0x00,
373 1.5 tsubai 0x1b, 0x03
374 1.5 tsubai };
375 1.1 tsubai
376 1.5 tsubai static u_char
377 1.5 tsubai nwp512_data2[] = {
378 1.5 tsubai 0x1e, 0x08,
379 1.5 tsubai 0x20, 0x08,
380 1.5 tsubai 0x21, 0x0d
381 1.5 tsubai };
382 1.1 tsubai
383 1.5 tsubai static u_char
384 1.5 tsubai nwp518_data1[] = {
385 1.5 tsubai 0x00, 0x52,
386 1.5 tsubai 0x01, 0x40,
387 1.5 tsubai 0x02, 0x4a,
388 1.5 tsubai 0x03, 0x49,
389 1.5 tsubai 0x04, 0x63,
390 1.5 tsubai 0x05, 0x02,
391 1.5 tsubai 0x06, 0x60,
392 1.5 tsubai 0x07, 0x60,
393 1.5 tsubai 0x08, 0x10,
394 1.5 tsubai 0x09, 0x07,
395 1.5 tsubai 0x0a, 0x20,
396 1.5 tsubai 0x0c, 0x00,
397 1.5 tsubai 0x0d, 0x00,
398 1.5 tsubai 0x1b, 0x04
399 1.5 tsubai };
400 1.1 tsubai
401 1.5 tsubai static u_char
402 1.5 tsubai nwp518_data2[] = {
403 1.5 tsubai 0x1e, 0x08,
404 1.5 tsubai 0x20, 0x00,
405 1.5 tsubai 0x21, 0x00
406 1.5 tsubai };
407 1.1 tsubai
408 1.5 tsubai static u_char
409 1.5 tsubai nwe501_data1[] = {
410 1.5 tsubai 0x00, 0x4b,
411 1.5 tsubai 0x01, 0x40,
412 1.5 tsubai 0x02, 0x4a,
413 1.5 tsubai 0x03, 0x43,
414 1.5 tsubai 0x04, 0x64,
415 1.5 tsubai 0x05, 0x02,
416 1.5 tsubai 0x06, 0x60,
417 1.5 tsubai 0x07, 0x60,
418 1.5 tsubai 0x08, 0x10,
419 1.5 tsubai 0x09, 0x07,
420 1.5 tsubai 0x0a, 0x20,
421 1.5 tsubai 0x0c, 0x00,
422 1.5 tsubai 0x0d, 0x00,
423 1.5 tsubai 0x1b, 0x04
424 1.5 tsubai };
425 1.1 tsubai
426 1.5 tsubai static u_char
427 1.5 tsubai nwe501_data2[] = {
428 1.5 tsubai 0x1e, 0x08,
429 1.5 tsubai 0x20, 0x00,
430 1.5 tsubai 0x21, 0x00
431 1.5 tsubai };
432 1.1 tsubai
433 1.5 tsubai static u_char
434 1.5 tsubai *crtc_data[3][2] = {
435 1.5 tsubai { nwp512_data1, nwp512_data2 },
436 1.5 tsubai { nwp518_data1, nwp518_data2 },
437 1.5 tsubai { nwe501_data1, nwe501_data2 }
438 1.5 tsubai };
439 1.1 tsubai
440 1.1 tsubai static void
441 1.5 tsubai fb253_init(id)
442 1.5 tsubai int id;
443 1.1 tsubai {
444 1.5 tsubai volatile u_short *ctlreg = NWB253_CTLREG;
445 1.5 tsubai volatile u_short *crtreg = NWB253_CRTREG;
446 1.5 tsubai u_char *p;
447 1.5 tsubai int i;
448 1.5 tsubai
449 1.5 tsubai *ctlreg = 0; /* stop crtc */
450 1.5 tsubai delay(10);
451 1.5 tsubai
452 1.5 tsubai /* initialize crtc without R3{0,1,2} */
453 1.5 tsubai p = crtc_data[id][0];
454 1.5 tsubai for (i = 0; i < 28; i++) {
455 1.5 tsubai *crtreg++ = *p++;
456 1.5 tsubai delay(10);
457 1.5 tsubai }
458 1.5 tsubai
459 1.5 tsubai *ctlreg = 0x02; /* start crtc */
460 1.5 tsubai delay(10);
461 1.5 tsubai
462 1.5 tsubai /* set crtc control reg */
463 1.5 tsubai p = crtc_data[id][1];
464 1.5 tsubai for (i = 0; i < 6; i++) {
465 1.5 tsubai *crtreg++ = *p++;
466 1.5 tsubai delay(10);
467 1.5 tsubai }
468 1.5 tsubai }
469 1.5 tsubai
470 1.5 tsubai #if 0
471 1.5 tsubai static struct wsdisplay_font newsrom8x16;
472 1.5 tsubai static struct wsdisplay_font newsrom12x24;
473 1.5 tsubai static char fontarea16[96][32];
474 1.5 tsubai static char fontarea24[96][96];
475 1.5 tsubai
476 1.5 tsubai void
477 1.5 tsubai initfont(ri)
478 1.5 tsubai struct rasops_info *ri;
479 1.5 tsubai {
480 1.5 tsubai int c, x;
481 1.5 tsubai
482 1.5 tsubai for (c = 0; c < 96; c++) {
483 1.5 tsubai x = ((c & 0x1f) | ((c & 0xe0) << 2)) << 7;
484 1.5 tsubai bcopy((char *)0xb8e00000 + x + 96, fontarea16 + c, 32);
485 1.5 tsubai bcopy((char *)0xb8e00000 + x, fontarea24 + c, 96);
486 1.5 tsubai }
487 1.5 tsubai
488 1.5 tsubai newsrom8x16.name = "rom8x16";
489 1.5 tsubai newsrom8x16.firstchar = 32;
490 1.5 tsubai newsrom8x16.numchars = 96;
491 1.5 tsubai newsrom8x16.encoding = WSDISPLAY_FONTENC_ISO;
492 1.5 tsubai newsrom8x16.fontwidth = 8;
493 1.5 tsubai newsrom8x16.fontheight = 16;
494 1.5 tsubai newsrom8x16.stride = 2;
495 1.5 tsubai newsrom8x16.bitorder = WSDISPLAY_FONTORDER_L2R;
496 1.5 tsubai newsrom8x16.byteorder = WSDISPLAY_FONTORDER_L2R;
497 1.5 tsubai newsrom8x16.data = fontarea16;
498 1.5 tsubai
499 1.5 tsubai newsrom12x24.name = "rom12x24";
500 1.5 tsubai newsrom12x24.firstchar = 32;
501 1.5 tsubai newsrom12x24.numchars = 96;
502 1.5 tsubai newsrom12x24.encoding = WSDISPLAY_FONTENC_ISO;
503 1.5 tsubai newsrom12x24.fontwidth = 12;
504 1.5 tsubai newsrom12x24.fontheight = 24;
505 1.5 tsubai newsrom12x24.stride = 4;
506 1.5 tsubai newsrom12x24.bitorder = WSDISPLAY_FONTORDER_L2R;
507 1.5 tsubai newsrom12x24.byteorder = WSDISPLAY_FONTORDER_L2R;
508 1.5 tsubai newsrom12x24.data = fontarea24;
509 1.5 tsubai
510 1.5 tsubai ri->ri_font = &newsrom8x16;
511 1.5 tsubai ri->ri_font = &newsrom12x24;
512 1.5 tsubai ri->ri_wsfcookie = -1; /* not using wsfont */
513 1.1 tsubai }
514 1.5 tsubai #endif
515