fb.c revision 1.2.2.3 1 1.2.2.3 bouyer /* $NetBSD: fb.c,v 1.2.2.3 2000/11/22 16:04:52 bouyer Exp $ */
2 1.2.2.2 bouyer
3 1.2.2.2 bouyer /*
4 1.2.2.2 bouyer * Copyright (c) 1992, 1993
5 1.2.2.2 bouyer * The Regents of the University of California. All rights reserved.
6 1.2.2.2 bouyer *
7 1.2.2.2 bouyer * This software was developed by the Computer Systems Engineering group
8 1.2.2.2 bouyer * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 1.2.2.2 bouyer * contributed to Berkeley.
10 1.2.2.2 bouyer *
11 1.2.2.2 bouyer * All advertising materials mentioning features or use of this software
12 1.2.2.2 bouyer * must display the following acknowledgement:
13 1.2.2.2 bouyer * This product includes software developed by the University of
14 1.2.2.2 bouyer * California, Lawrence Berkeley Laboratory.
15 1.2.2.2 bouyer *
16 1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
17 1.2.2.2 bouyer * modification, are permitted provided that the following conditions
18 1.2.2.2 bouyer * are met:
19 1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
20 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer.
21 1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
22 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
23 1.2.2.2 bouyer * documentation and/or other materials provided with the distribution.
24 1.2.2.2 bouyer * 3. All advertising materials mentioning features or use of this software
25 1.2.2.2 bouyer * must display the following acknowledgement:
26 1.2.2.2 bouyer * This product includes software developed by the University of
27 1.2.2.2 bouyer * California, Berkeley and its contributors.
28 1.2.2.2 bouyer * 4. Neither the name of the University nor the names of its contributors
29 1.2.2.2 bouyer * may be used to endorse or promote products derived from this software
30 1.2.2.2 bouyer * without specific prior written permission.
31 1.2.2.2 bouyer *
32 1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 1.2.2.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 1.2.2.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 1.2.2.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 1.2.2.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 1.2.2.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 1.2.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 1.2.2.2 bouyer * SUCH DAMAGE.
43 1.2.2.2 bouyer *
44 1.2.2.2 bouyer * @(#)fb.c 8.1 (Berkeley) 6/11/93
45 1.2.2.2 bouyer */
46 1.2.2.2 bouyer
47 1.2.2.2 bouyer /*
48 1.2.2.2 bouyer * /dev/fb (indirect frame buffer driver). This is gross; we should
49 1.2.2.2 bouyer * just build cdevsw[] dynamically.
50 1.2.2.2 bouyer */
51 1.2.2.2 bouyer
52 1.2.2.2 bouyer #include <sys/param.h>
53 1.2.2.2 bouyer #include <sys/systm.h>
54 1.2.2.2 bouyer #include <sys/device.h>
55 1.2.2.2 bouyer #include <sys/proc.h>
56 1.2.2.2 bouyer #include <sys/conf.h>
57 1.2.2.2 bouyer
58 1.2.2.2 bouyer #include <machine/autoconf.h>
59 1.2.2.2 bouyer #include <machine/kbd.h>
60 1.2.2.2 bouyer #include <machine/conf.h>
61 1.2.2.2 bouyer #include <machine/eeprom.h>
62 1.2.2.2 bouyer #include <sparc/dev/cons.h>
63 1.2.2.2 bouyer
64 1.2.2.2 bouyer #include <dev/sun/fbio.h>
65 1.2.2.2 bouyer #include <dev/sun/fbvar.h>
66 1.2.2.2 bouyer
67 1.2.2.2 bouyer #include "pfour.h"
68 1.2.2.2 bouyer
69 1.2.2.2 bouyer static struct fbdevice *devfb;
70 1.2.2.2 bouyer
71 1.2.2.2 bouyer void
72 1.2.2.2 bouyer fb_unblank()
73 1.2.2.2 bouyer {
74 1.2.2.2 bouyer
75 1.2.2.2 bouyer if (devfb)
76 1.2.2.2 bouyer (*devfb->fb_driver->fbd_unblank)(devfb->fb_device);
77 1.2.2.2 bouyer }
78 1.2.2.2 bouyer
79 1.2.2.2 bouyer /*
80 1.2.2.2 bouyer * Helper function for frame buffer devices. Decides whether
81 1.2.2.2 bouyer * the device can be the console output device according to
82 1.2.2.2 bouyer * PROM info. The result from this function may not be conclusive
83 1.2.2.2 bouyer * on machines with old PROMs; in that case, drivers should consult
84 1.2.2.2 bouyer * other sources of configuration information (e.g. EEPROM entries).
85 1.2.2.2 bouyer */
86 1.2.2.2 bouyer #if defined(SUN4U)
87 1.2.2.2 bouyer /* Temporary special case for sun4u */
88 1.2.2.2 bouyer int
89 1.2.2.2 bouyer fb_is_console(node)
90 1.2.2.2 bouyer int node;
91 1.2.2.2 bouyer {
92 1.2.2.2 bouyer extern int fbnode;
93 1.2.2.2 bouyer return (node == fbnode);
94 1.2.2.2 bouyer }
95 1.2.2.2 bouyer #else
96 1.2.2.2 bouyer int
97 1.2.2.2 bouyer fb_is_console(node)
98 1.2.2.2 bouyer int node;
99 1.2.2.2 bouyer {
100 1.2.2.2 bouyer int fbnode;
101 1.2.2.2 bouyer
102 1.2.2.2 bouyer switch (prom_version()) {
103 1.2.2.2 bouyer case PROM_OLDMON:
104 1.2.2.2 bouyer /* `node' is not valid; just check for any fb device */
105 1.2.2.2 bouyer return (prom_stdout() == PROMDEV_SCREEN);
106 1.2.2.2 bouyer
107 1.2.2.2 bouyer case PROM_OBP_V0:
108 1.2.2.2 bouyer /*
109 1.2.2.3 bouyer * First, check if prom_stdout() represents a frame buffer,
110 1.2.2.3 bouyer * then match on the `fb' property on the root node, if any.
111 1.2.2.2 bouyer */
112 1.2.2.3 bouyer if (prom_stdout() != PROMDEV_SCREEN)
113 1.2.2.3 bouyer return (0);
114 1.2.2.3 bouyer
115 1.2.2.2 bouyer fbnode = getpropint(findroot(), "fb", 0);
116 1.2.2.3 bouyer return (fbnode == 0 || node == fbnode);
117 1.2.2.2 bouyer
118 1.2.2.2 bouyer case PROM_OBP_V2:
119 1.2.2.2 bouyer case PROM_OBP_V3:
120 1.2.2.2 bouyer case PROM_OPENFIRM:
121 1.2.2.2 bouyer /* Just match the nodes */
122 1.2.2.2 bouyer return (node == prom_stdout_node);
123 1.2.2.2 bouyer }
124 1.2.2.2 bouyer
125 1.2.2.2 bouyer return (0);
126 1.2.2.2 bouyer }
127 1.2.2.2 bouyer #endif /* SUN4U */
128 1.2.2.2 bouyer
129 1.2.2.2 bouyer void
130 1.2.2.2 bouyer fb_attach(fb, isconsole)
131 1.2.2.2 bouyer struct fbdevice *fb;
132 1.2.2.2 bouyer int isconsole;
133 1.2.2.2 bouyer {
134 1.2.2.2 bouyer static int no_replace, seen_force;
135 1.2.2.2 bouyer
136 1.2.2.2 bouyer /*
137 1.2.2.2 bouyer * We've already had a framebuffer forced into /dev/fb. Don't
138 1.2.2.2 bouyer * allow any more, even if this is the console.
139 1.2.2.2 bouyer */
140 1.2.2.2 bouyer if (seen_force) {
141 1.2.2.2 bouyer if (devfb) { /* sanity */
142 1.2.2.2 bouyer printf("%s: /dev/fb already full\n",
143 1.2.2.2 bouyer fb->fb_device->dv_xname);
144 1.2.2.2 bouyer return;
145 1.2.2.2 bouyer } else
146 1.2.2.2 bouyer seen_force = 0;
147 1.2.2.2 bouyer }
148 1.2.2.2 bouyer
149 1.2.2.2 bouyer /*
150 1.2.2.2 bouyer * Check to see if we're being forced into /dev/fb.
151 1.2.2.2 bouyer */
152 1.2.2.2 bouyer if (fb->fb_flags & FB_FORCE) {
153 1.2.2.2 bouyer if (devfb)
154 1.2.2.2 bouyer printf("%s: forcefully replacing %s\n",
155 1.2.2.2 bouyer fb->fb_device->dv_xname,
156 1.2.2.2 bouyer devfb->fb_device->dv_xname);
157 1.2.2.2 bouyer devfb = fb;
158 1.2.2.2 bouyer seen_force = no_replace = 1;
159 1.2.2.2 bouyer goto attached;
160 1.2.2.2 bouyer }
161 1.2.2.2 bouyer
162 1.2.2.2 bouyer /*
163 1.2.2.2 bouyer * Check to see if we're the console. If we are, then replace
164 1.2.2.2 bouyer * any currently existing framebuffer.
165 1.2.2.2 bouyer */
166 1.2.2.2 bouyer if (isconsole) {
167 1.2.2.2 bouyer if (devfb)
168 1.2.2.2 bouyer printf("%s: replacing %s\n", fb->fb_device->dv_xname,
169 1.2.2.2 bouyer devfb->fb_device->dv_xname);
170 1.2.2.2 bouyer devfb = fb;
171 1.2.2.2 bouyer no_replace = 1;
172 1.2.2.2 bouyer goto attached;
173 1.2.2.2 bouyer }
174 1.2.2.2 bouyer
175 1.2.2.2 bouyer /*
176 1.2.2.2 bouyer * For the final case, we check to see if we can replace an
177 1.2.2.2 bouyer * existing framebuffer, if not, say so and return.
178 1.2.2.2 bouyer */
179 1.2.2.2 bouyer if (no_replace) {
180 1.2.2.2 bouyer if (devfb) { /* sanity */
181 1.2.2.2 bouyer printf("%s: /dev/fb already full\n",
182 1.2.2.2 bouyer fb->fb_device->dv_xname);
183 1.2.2.2 bouyer return;
184 1.2.2.2 bouyer } else
185 1.2.2.2 bouyer no_replace = 0;
186 1.2.2.2 bouyer }
187 1.2.2.2 bouyer
188 1.2.2.2 bouyer if (devfb)
189 1.2.2.2 bouyer printf("%s: replacing %s\n", fb->fb_device->dv_xname,
190 1.2.2.2 bouyer devfb->fb_device->dv_xname);
191 1.2.2.2 bouyer devfb = fb;
192 1.2.2.2 bouyer
193 1.2.2.2 bouyer attached:
194 1.2.2.2 bouyer printf("%s: attached to /dev/fb\n", devfb->fb_device->dv_xname);
195 1.2.2.2 bouyer }
196 1.2.2.2 bouyer
197 1.2.2.2 bouyer int
198 1.2.2.2 bouyer fbopen(dev, flags, mode, p)
199 1.2.2.2 bouyer dev_t dev;
200 1.2.2.2 bouyer int flags, mode;
201 1.2.2.2 bouyer struct proc *p;
202 1.2.2.2 bouyer {
203 1.2.2.2 bouyer
204 1.2.2.2 bouyer if (devfb == NULL)
205 1.2.2.2 bouyer return (ENXIO);
206 1.2.2.2 bouyer return (devfb->fb_driver->fbd_open)(dev, flags, mode, p);
207 1.2.2.2 bouyer }
208 1.2.2.2 bouyer
209 1.2.2.2 bouyer int
210 1.2.2.2 bouyer fbclose(dev, flags, mode, p)
211 1.2.2.2 bouyer dev_t dev;
212 1.2.2.2 bouyer int flags, mode;
213 1.2.2.2 bouyer struct proc *p;
214 1.2.2.2 bouyer {
215 1.2.2.2 bouyer
216 1.2.2.2 bouyer return (devfb->fb_driver->fbd_close)(dev, flags, mode, p);
217 1.2.2.2 bouyer }
218 1.2.2.2 bouyer
219 1.2.2.2 bouyer int
220 1.2.2.2 bouyer fbioctl(dev, cmd, data, flags, p)
221 1.2.2.2 bouyer dev_t dev;
222 1.2.2.2 bouyer u_long cmd;
223 1.2.2.2 bouyer caddr_t data;
224 1.2.2.2 bouyer int flags;
225 1.2.2.2 bouyer struct proc *p;
226 1.2.2.2 bouyer {
227 1.2.2.2 bouyer
228 1.2.2.2 bouyer return (devfb->fb_driver->fbd_ioctl)(dev, cmd, data, flags, p);
229 1.2.2.2 bouyer }
230 1.2.2.2 bouyer
231 1.2.2.2 bouyer int
232 1.2.2.2 bouyer fbpoll(dev, events, p)
233 1.2.2.2 bouyer dev_t dev;
234 1.2.2.2 bouyer int events;
235 1.2.2.2 bouyer struct proc *p;
236 1.2.2.2 bouyer {
237 1.2.2.2 bouyer
238 1.2.2.2 bouyer return (devfb->fb_driver->fbd_poll)(dev, events, p);
239 1.2.2.2 bouyer }
240 1.2.2.2 bouyer
241 1.2.2.2 bouyer paddr_t
242 1.2.2.2 bouyer fbmmap(dev, off, prot)
243 1.2.2.2 bouyer dev_t dev;
244 1.2.2.2 bouyer off_t off;
245 1.2.2.2 bouyer int prot;
246 1.2.2.2 bouyer {
247 1.2.2.2 bouyer paddr_t (*map)__P((dev_t, off_t, int)) = devfb->fb_driver->fbd_mmap;
248 1.2.2.2 bouyer
249 1.2.2.2 bouyer if (map == NULL)
250 1.2.2.2 bouyer return (-1);
251 1.2.2.2 bouyer return (map(dev, off, prot));
252 1.2.2.2 bouyer }
253 1.2.2.2 bouyer
254 1.2.2.2 bouyer void
255 1.2.2.2 bouyer fb_setsize_obp(fb, depth, def_width, def_height, node)
256 1.2.2.2 bouyer struct fbdevice *fb;
257 1.2.2.2 bouyer int depth, def_width, def_height, node;
258 1.2.2.2 bouyer {
259 1.2.2.2 bouyer fb->fb_type.fb_width = getpropint(node, "width", def_width);
260 1.2.2.2 bouyer fb->fb_type.fb_height = getpropint(node, "height", def_height);
261 1.2.2.2 bouyer fb->fb_linebytes = getpropint(node, "linebytes",
262 1.2.2.2 bouyer (fb->fb_type.fb_width * depth) / 8);
263 1.2.2.2 bouyer }
264 1.2.2.2 bouyer
265 1.2.2.2 bouyer void
266 1.2.2.2 bouyer fb_setsize_eeprom(fb, depth, def_width, def_height)
267 1.2.2.2 bouyer struct fbdevice *fb;
268 1.2.2.2 bouyer int depth, def_width, def_height;
269 1.2.2.2 bouyer {
270 1.2.2.2 bouyer #if defined(SUN4)
271 1.2.2.2 bouyer struct eeprom *eep = (struct eeprom *)eeprom_va;
272 1.2.2.2 bouyer
273 1.2.2.2 bouyer if (!CPU_ISSUN4) {
274 1.2.2.2 bouyer printf("fb_setsize_eeprom: not sun4\n");
275 1.2.2.2 bouyer return;
276 1.2.2.2 bouyer }
277 1.2.2.2 bouyer
278 1.2.2.2 bouyer /* Set up some defaults. */
279 1.2.2.2 bouyer fb->fb_type.fb_width = def_width;
280 1.2.2.2 bouyer fb->fb_type.fb_height = def_height;
281 1.2.2.2 bouyer
282 1.2.2.2 bouyer if (fb->fb_flags & FB_PFOUR) {
283 1.2.2.2 bouyer #if NPFOUR > 0
284 1.2.2.2 bouyer fb_setsize_pfour(fb);
285 1.2.2.2 bouyer #endif
286 1.2.2.2 bouyer } else if (eep != NULL) {
287 1.2.2.2 bouyer switch (eep->eeScreenSize) {
288 1.2.2.2 bouyer case EE_SCR_1152X900:
289 1.2.2.2 bouyer fb->fb_type.fb_width = 1152;
290 1.2.2.2 bouyer fb->fb_type.fb_height = 900;
291 1.2.2.2 bouyer break;
292 1.2.2.2 bouyer
293 1.2.2.2 bouyer case EE_SCR_1024X1024:
294 1.2.2.2 bouyer fb->fb_type.fb_width = 1024;
295 1.2.2.2 bouyer fb->fb_type.fb_height = 1024;
296 1.2.2.2 bouyer break;
297 1.2.2.2 bouyer
298 1.2.2.2 bouyer case EE_SCR_1600X1280:
299 1.2.2.2 bouyer fb->fb_type.fb_width = 1600;
300 1.2.2.2 bouyer fb->fb_type.fb_height = 1280;
301 1.2.2.2 bouyer break;
302 1.2.2.2 bouyer
303 1.2.2.2 bouyer case EE_SCR_1440X1440:
304 1.2.2.2 bouyer fb->fb_type.fb_width = 1440;
305 1.2.2.2 bouyer fb->fb_type.fb_height = 1440;
306 1.2.2.2 bouyer break;
307 1.2.2.2 bouyer
308 1.2.2.2 bouyer default:
309 1.2.2.2 bouyer /*
310 1.2.2.2 bouyer * XXX: Do nothing, I guess.
311 1.2.2.2 bouyer * Should we print a warning about
312 1.2.2.2 bouyer * an unknown value? --thorpej
313 1.2.2.2 bouyer */
314 1.2.2.2 bouyer break;
315 1.2.2.2 bouyer }
316 1.2.2.2 bouyer }
317 1.2.2.2 bouyer
318 1.2.2.2 bouyer fb->fb_linebytes = (fb->fb_type.fb_width * depth) / 8;
319 1.2.2.2 bouyer #endif /* SUN4 */
320 1.2.2.2 bouyer }
321 1.2.2.2 bouyer
322 1.2.2.2 bouyer
323 1.2.2.2 bouyer
324 1.2.2.2 bouyer #ifdef RASTERCONSOLE
325 1.2.2.2 bouyer #include <machine/kbd.h>
326 1.2.2.2 bouyer
327 1.2.2.2 bouyer static void fb_bell __P((int));
328 1.2.2.2 bouyer
329 1.2.2.2 bouyer #if !defined(RASTERCONS_FULLSCREEN)
330 1.2.2.2 bouyer static int a2int __P((char *, int));
331 1.2.2.2 bouyer
332 1.2.2.2 bouyer static int
333 1.2.2.2 bouyer a2int(cp, deflt)
334 1.2.2.2 bouyer register char *cp;
335 1.2.2.2 bouyer register int deflt;
336 1.2.2.2 bouyer {
337 1.2.2.2 bouyer register int i = 0;
338 1.2.2.2 bouyer
339 1.2.2.2 bouyer if (*cp == '\0')
340 1.2.2.2 bouyer return (deflt);
341 1.2.2.2 bouyer while (*cp != '\0')
342 1.2.2.2 bouyer i = i * 10 + *cp++ - '0';
343 1.2.2.2 bouyer return (i);
344 1.2.2.2 bouyer }
345 1.2.2.2 bouyer #endif
346 1.2.2.2 bouyer
347 1.2.2.2 bouyer static void
348 1.2.2.2 bouyer fb_bell(on)
349 1.2.2.2 bouyer int on;
350 1.2.2.2 bouyer {
351 1.2.2.2 bouyer (void)kbd_docmd(on?KBD_CMD_BELL:KBD_CMD_NOBELL, 0);
352 1.2.2.2 bouyer }
353 1.2.2.2 bouyer
354 1.2.2.2 bouyer void
355 1.2.2.2 bouyer fbrcons_init(fb)
356 1.2.2.2 bouyer struct fbdevice *fb;
357 1.2.2.2 bouyer {
358 1.2.2.2 bouyer struct rconsole *rc = &fb->fb_rcons;
359 1.2.2.2 bouyer struct rasops_info *ri = &fb->fb_rinfo;
360 1.2.2.2 bouyer int maxrow, maxcol, *row, *col;
361 1.2.2.2 bouyer
362 1.2.2.2 bouyer /* Set up what rasops needs to know about */
363 1.2.2.2 bouyer bzero(ri, sizeof *ri);
364 1.2.2.2 bouyer ri->ri_stride = fb->fb_linebytes;
365 1.2.2.2 bouyer ri->ri_bits = (caddr_t)fb->fb_pixels;
366 1.2.2.2 bouyer ri->ri_depth = fb->fb_type.fb_depth;
367 1.2.2.2 bouyer ri->ri_width = fb->fb_type.fb_width;
368 1.2.2.2 bouyer ri->ri_height = fb->fb_type.fb_height;
369 1.2.2.2 bouyer maxrow = 5000;
370 1.2.2.2 bouyer maxcol = 5000;
371 1.2.2.2 bouyer
372 1.2.2.2 bouyer #if !defined(RASTERCONS_FULLSCREEN)
373 1.2.2.2 bouyer #if defined(SUN4)
374 1.2.2.2 bouyer if (CPU_ISSUN4) {
375 1.2.2.2 bouyer struct eeprom *eep = (struct eeprom *)eeprom_va;
376 1.2.2.2 bouyer
377 1.2.2.2 bouyer if (eep == NULL) {
378 1.2.2.2 bouyer maxcol = 80;
379 1.2.2.2 bouyer maxrow = 34;
380 1.2.2.2 bouyer } else {
381 1.2.2.2 bouyer maxcol = eep->eeTtyCols;
382 1.2.2.2 bouyer maxrow = eep->eeTtyRows;
383 1.2.2.2 bouyer }
384 1.2.2.2 bouyer }
385 1.2.2.2 bouyer #endif /* SUN4 */
386 1.2.2.2 bouyer if (!CPU_ISSUN4) {
387 1.2.2.2 bouyer maxcol =
388 1.2.2.2 bouyer a2int(getpropstring(optionsnode, "screen-#columns"), 80);
389 1.2.2.2 bouyer maxrow =
390 1.2.2.2 bouyer a2int(getpropstring(optionsnode, "screen-#rows"), 34);
391 1.2.2.2 bouyer }
392 1.2.2.2 bouyer #endif /* !RASTERCONS_FULLSCREEN */
393 1.2.2.2 bouyer /*
394 1.2.2.2 bouyer * - force monochrome output
395 1.2.2.2 bouyer * - eraserows() hack to clear the *entire* display
396 1.2.2.2 bouyer * - cursor is currently enabled
397 1.2.2.2 bouyer * - center output
398 1.2.2.2 bouyer */
399 1.2.2.2 bouyer ri->ri_flg = RI_FULLCLEAR | RI_CURSOR | RI_CENTER;
400 1.2.2.2 bouyer
401 1.2.2.2 bouyer /* Get operations set and connect to rcons */
402 1.2.2.2 bouyer if (rasops_init(ri, maxrow, maxcol))
403 1.2.2.2 bouyer panic("fbrcons_init: rasops_init failed!");
404 1.2.2.2 bouyer
405 1.2.2.2 bouyer if (ri->ri_depth == 8) {
406 1.2.2.2 bouyer int i;
407 1.2.2.2 bouyer for (i = 0; i < 16; i++) {
408 1.2.2.2 bouyer
409 1.2.2.2 bouyer /*
410 1.2.2.2 bouyer * Cmap entries are repeated four times in the
411 1.2.2.2 bouyer * 32 bit wide `devcmap' entries for optimization
412 1.2.2.2 bouyer * purposes; see rasops(9)
413 1.2.2.2 bouyer */
414 1.2.2.2 bouyer #define I_TO_DEVCMAP(i) ((i) | ((i)<<8) | ((i)<<16) | ((i)<<24))
415 1.2.2.2 bouyer
416 1.2.2.2 bouyer /*
417 1.2.2.2 bouyer * Use existing colormap entries for black and white
418 1.2.2.2 bouyer */
419 1.2.2.2 bouyer if ((i & 7) == WSCOL_BLACK) {
420 1.2.2.2 bouyer ri->ri_devcmap[i] = I_TO_DEVCMAP(255);
421 1.2.2.2 bouyer continue;
422 1.2.2.2 bouyer }
423 1.2.2.2 bouyer
424 1.2.2.2 bouyer if ((i & 7) == WSCOL_WHITE) {
425 1.2.2.2 bouyer ri->ri_devcmap[i] = I_TO_DEVCMAP(0);
426 1.2.2.2 bouyer continue;
427 1.2.2.2 bouyer }
428 1.2.2.2 bouyer /*
429 1.2.2.2 bouyer * Other entries refer to ANSI map, which for now
430 1.2.2.2 bouyer * is setup in bt_subr.c
431 1.2.2.2 bouyer */
432 1.2.2.2 bouyer ri->ri_devcmap[i] = I_TO_DEVCMAP(i + 1);
433 1.2.2.2 bouyer #undef I_TO_DEVCMAP
434 1.2.2.2 bouyer }
435 1.2.2.2 bouyer }
436 1.2.2.2 bouyer
437 1.2.2.2 bouyer rc->rc_row = rc->rc_col = 0;
438 1.2.2.2 bouyer #if !defined(RASTERCONS_FULLSCREEN)
439 1.2.2.2 bouyer /* Determine addresses of prom emulator row and column */
440 1.2.2.2 bouyer if (!CPU_ISSUN4 && !romgetcursoraddr(&row, &col)) {
441 1.2.2.2 bouyer rc->rc_row = *row;
442 1.2.2.2 bouyer rc->rc_col = *col;
443 1.2.2.2 bouyer }
444 1.2.2.2 bouyer #endif
445 1.2.2.2 bouyer ri->ri_crow = rc->rc_row;
446 1.2.2.2 bouyer ri->ri_ccol = rc->rc_col;
447 1.2.2.2 bouyer
448 1.2.2.2 bouyer rc->rc_ops = &ri->ri_ops;
449 1.2.2.2 bouyer rc->rc_cookie = ri;
450 1.2.2.2 bouyer rc->rc_bell = fb_bell;
451 1.2.2.2 bouyer rc->rc_maxcol = ri->ri_cols;
452 1.2.2.2 bouyer rc->rc_maxrow = ri->ri_rows;
453 1.2.2.2 bouyer rc->rc_width = ri->ri_emuwidth;
454 1.2.2.2 bouyer rc->rc_height = ri->ri_emuheight;
455 1.2.2.2 bouyer rc->rc_deffgcolor = WSCOL_BLACK;
456 1.2.2.2 bouyer rc->rc_defbgcolor = WSCOL_WHITE;
457 1.2.2.2 bouyer rcons_init(rc, 0);
458 1.2.2.2 bouyer
459 1.2.2.2 bouyer /* Hook up virtual console */
460 1.2.2.2 bouyer v_putc = rcons_cnputc;
461 1.2.2.2 bouyer }
462 1.2.2.2 bouyer
463 1.2.2.2 bouyer int
464 1.2.2.2 bouyer fbrcons_rows()
465 1.2.2.2 bouyer {
466 1.2.2.2 bouyer return (devfb ? devfb->fb_rcons.rc_maxrow : 0);
467 1.2.2.2 bouyer }
468 1.2.2.2 bouyer
469 1.2.2.2 bouyer int
470 1.2.2.2 bouyer fbrcons_cols()
471 1.2.2.2 bouyer {
472 1.2.2.2 bouyer return (devfb ? devfb->fb_rcons.rc_maxcol : 0);
473 1.2.2.2 bouyer }
474 1.2.2.2 bouyer #endif /* RASTERCONSOLE */
475