FreeBSD/Linux Kernel Cross Reference
sys/dev/fb/fb.c
1 /*-
2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer as
10 * the first lines of this file unmodified.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: releng/5.1/sys/dev/fb/fb.c 112569 2003-03-25 00:07:06Z jake $
29 */
30
31 #include "opt_fb.h"
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/conf.h>
36 #include <sys/bus.h>
37 #include <sys/kernel.h>
38 #include <sys/malloc.h>
39 #include <sys/module.h>
40 #include <sys/uio.h>
41 #include <sys/fbio.h>
42 #include <sys/linker_set.h>
43
44 #include <vm/vm.h>
45 #include <vm/pmap.h>
46
47 #include <dev/fb/fbreg.h>
48
49 SET_DECLARE(videodriver_set, const video_driver_t);
50
51 /* local arrays */
52
53 /*
54 * We need at least one entry each in order to initialize a video card
55 * for the kernel console. The arrays will be increased dynamically
56 * when necessary.
57 */
58
59 static int vid_malloc;
60 static int adapters = 1;
61 static video_adapter_t *adp_ini;
62 static video_adapter_t **adapter = &adp_ini;
63 static video_switch_t *vidsw_ini;
64 video_switch_t **vidsw = &vidsw_ini;
65
66 #ifdef FB_INSTALL_CDEV
67 static struct cdevsw *vidcdevsw_ini;
68 static struct cdevsw **vidcdevsw = &vidcdevsw_ini;
69 #endif
70
71 #define ARRAY_DELTA 4
72
73 static int
74 vid_realloc_array(void)
75 {
76 video_adapter_t **new_adp;
77 video_switch_t **new_vidsw;
78 #ifdef FB_INSTALL_CDEV
79 struct cdevsw **new_cdevsw;
80 #endif
81 int newsize;
82 int s;
83
84 if (!vid_malloc)
85 return ENOMEM;
86
87 s = spltty();
88 newsize = ((adapters + ARRAY_DELTA)/ARRAY_DELTA)*ARRAY_DELTA;
89 new_adp = malloc(sizeof(*new_adp)*newsize, M_DEVBUF, M_WAITOK | M_ZERO);
90 new_vidsw = malloc(sizeof(*new_vidsw)*newsize, M_DEVBUF,
91 M_WAITOK | M_ZERO);
92 #ifdef FB_INSTALL_CDEV
93 new_cdevsw = malloc(sizeof(*new_cdevsw)*newsize, M_DEVBUF,
94 M_WAITOK | M_ZERO);
95 #endif
96 bcopy(adapter, new_adp, sizeof(*adapter)*adapters);
97 bcopy(vidsw, new_vidsw, sizeof(*vidsw)*adapters);
98 #ifdef FB_INSTALL_CDEV
99 bcopy(vidcdevsw, new_cdevsw, sizeof(*vidcdevsw)*adapters);
100 #endif
101 if (adapters > 1) {
102 free(adapter, M_DEVBUF);
103 free(vidsw, M_DEVBUF);
104 #ifdef FB_INSTALL_CDEV
105 free(vidcdevsw, M_DEVBUF);
106 #endif
107 }
108 adapter = new_adp;
109 vidsw = new_vidsw;
110 #ifdef FB_INSTALL_CDEV
111 vidcdevsw = new_cdevsw;
112 #endif
113 adapters = newsize;
114 splx(s);
115
116 if (bootverbose)
117 printf("fb: new array size %d\n", adapters);
118
119 return 0;
120 }
121
122 static void
123 vid_malloc_init(void *arg)
124 {
125 vid_malloc = TRUE;
126 }
127
128 SYSINIT(vid_mem, SI_SUB_KMEM, SI_ORDER_ANY, vid_malloc_init, NULL);
129
130 /*
131 * Low-level frame buffer driver functions
132 * frame buffer subdrivers, such as the VGA driver, call these functions
133 * to initialize the video_adapter structure and register it to the virtual
134 * frame buffer driver `fb'.
135 */
136
137 /* initialize the video_adapter_t structure */
138 void
139 vid_init_struct(video_adapter_t *adp, char *name, int type, int unit)
140 {
141 adp->va_flags = 0;
142 adp->va_name = name;
143 adp->va_type = type;
144 adp->va_unit = unit;
145 }
146
147 /* Register a video adapter */
148 int
149 vid_register(video_adapter_t *adp)
150 {
151 const video_driver_t **list;
152 const video_driver_t *p;
153 int index;
154
155 for (index = 0; index < adapters; ++index) {
156 if (adapter[index] == NULL)
157 break;
158 }
159 if (index >= adapters) {
160 if (vid_realloc_array())
161 return -1;
162 }
163
164 adp->va_index = index;
165 adp->va_token = NULL;
166 SET_FOREACH(list, videodriver_set) {
167 p = *list;
168 if (strcmp(p->name, adp->va_name) == 0) {
169 adapter[index] = adp;
170 vidsw[index] = p->vidsw;
171 return index;
172 }
173 }
174
175 return -1;
176 }
177
178 int
179 vid_unregister(video_adapter_t *adp)
180 {
181 if ((adp->va_index < 0) || (adp->va_index >= adapters))
182 return ENOENT;
183 if (adapter[adp->va_index] != adp)
184 return ENOENT;
185
186 adapter[adp->va_index] = NULL;
187 vidsw[adp->va_index] = NULL;
188 return 0;
189 }
190
191 /* Get video I/O function table */
192 video_switch_t
193 *vid_get_switch(char *name)
194 {
195 const video_driver_t **list;
196 const video_driver_t *p;
197
198 SET_FOREACH(list, videodriver_set) {
199 p = *list;
200 if (strcmp(p->name, name) == 0)
201 return p->vidsw;
202 }
203
204 return NULL;
205 }
206
207 /*
208 * Video card client functions
209 * Video card clients, such as the console driver `syscons' and the frame
210 * buffer cdev driver, use these functions to claim and release a card for
211 * exclusive use.
212 */
213
214 /* find the video card specified by a driver name and a unit number */
215 int
216 vid_find_adapter(char *driver, int unit)
217 {
218 int i;
219
220 for (i = 0; i < adapters; ++i) {
221 if (adapter[i] == NULL)
222 continue;
223 if (strcmp("*", driver) && strcmp(adapter[i]->va_name, driver))
224 continue;
225 if ((unit != -1) && (adapter[i]->va_unit != unit))
226 continue;
227 return i;
228 }
229 return -1;
230 }
231
232 /* allocate a video card */
233 int
234 vid_allocate(char *driver, int unit, void *id)
235 {
236 int index;
237 int s;
238
239 s = spltty();
240 index = vid_find_adapter(driver, unit);
241 if (index >= 0) {
242 if (adapter[index]->va_token) {
243 splx(s);
244 return -1;
245 }
246 adapter[index]->va_token = id;
247 }
248 splx(s);
249 return index;
250 }
251
252 int
253 vid_release(video_adapter_t *adp, void *id)
254 {
255 int error;
256 int s;
257
258 s = spltty();
259 if (adp->va_token == NULL) {
260 error = EINVAL;
261 } else if (adp->va_token != id) {
262 error = EPERM;
263 } else {
264 adp->va_token = NULL;
265 error = 0;
266 }
267 splx(s);
268 return error;
269 }
270
271 /* Get a video adapter structure */
272 video_adapter_t
273 *vid_get_adapter(int index)
274 {
275 if ((index < 0) || (index >= adapters))
276 return NULL;
277 return adapter[index];
278 }
279
280 /* Configure drivers: this is a backdoor for the console driver XXX */
281 int
282 vid_configure(int flags)
283 {
284 const video_driver_t **list;
285 const video_driver_t *p;
286
287 SET_FOREACH(list, videodriver_set) {
288 p = *list;
289 if (p->configure != NULL)
290 (*p->configure)(flags);
291 }
292
293 return 0;
294 }
295
296 /*
297 * Virtual frame buffer cdev driver functions
298 * The virtual frame buffer driver dispatches driver functions to
299 * appropriate subdrivers.
300 */
301
302 #define FB_DRIVER_NAME "fb"
303
304 #ifdef FB_INSTALL_CDEV
305
306 #if experimental
307
308 static devclass_t fb_devclass;
309
310 static int fbprobe(device_t dev);
311 static int fbattach(device_t dev);
312
313 static device_method_t fb_methods[] = {
314 DEVMETHOD(device_probe, fbprobe),
315 DEVMETHOD(device_attach, fbattach),
316
317 DEVMETHOD(bus_print_child, bus_generic_print_child),
318 { 0, 0 }
319 };
320
321 static driver_t fb_driver = {
322 FB_DRIVER_NAME,
323 fb_methods,
324 0,
325 };
326
327 static int
328 fbprobe(device_t dev)
329 {
330 int unit;
331
332 unit = device_get_unit(dev);
333 if (unit >= adapters)
334 return ENXIO;
335 if (adapter[unit] == NULL)
336 return ENXIO;
337
338 device_set_desc(dev, "generic frame buffer");
339 return 0;
340 }
341
342 static int
343 fbattach(device_t dev)
344 {
345 printf("fbattach: about to attach children\n");
346 bus_generic_attach(dev);
347 return 0;
348 }
349
350 #endif /* experimental */
351
352 #define FB_UNIT(dev) minor(dev)
353 #define FB_MKMINOR(unit) (u)
354
355 #if experimental
356 static d_open_t fbopen;
357 static d_close_t fbclose;
358 static d_read_t fbread;
359 static d_write_t fbwrite;
360 static d_ioctl_t fbioctl;
361 static d_mmap_t fbmmap;
362
363 #define CDEV_MAJOR 123 /* XXX */
364
365 static struct cdevsw fb_cdevsw = {
366 .d_open = fbopen,
367 .d_close = fbclose,
368 .d_read = fbread,
369 .d_write = fbwrite,
370 .d_ioctl = fbioctl,
371 .d_mmap = fbmmap,
372 .d_name = FB_DRIVER_NAME,
373 .d_maj = CDEV_MAJOR,
374 };
375 #endif
376
377
378 static int
379 fb_modevent(module_t mod, int type, void *data)
380 {
381
382 switch (type) {
383 case MOD_LOAD:
384 break;
385 case MOD_UNLOAD:
386 printf("fb module unload - not possible for this module type\n");
387 return EINVAL;
388 }
389 return 0;
390 }
391
392 static moduledata_t fb_mod = {
393 "fb",
394 fb_modevent,
395 NULL
396 };
397
398 DECLARE_MODULE(fb, fb_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
399
400 int
401 fb_attach(dev_t dev, video_adapter_t *adp, struct cdevsw *cdevsw)
402 {
403 int s;
404
405 if (adp->va_index >= adapters)
406 return EINVAL;
407 if (adapter[adp->va_index] != adp)
408 return EINVAL;
409
410 s = spltty();
411 adp->va_minor = minor(dev);
412 vidcdevsw[adp->va_index] = cdevsw;
413 splx(s);
414
415 printf("fb%d at %s%d\n", adp->va_index, adp->va_name, adp->va_unit);
416 return 0;
417 }
418
419 int
420 fb_detach(dev_t dev, video_adapter_t *adp, struct cdevsw *cdevsw)
421 {
422 int s;
423
424 if (adp->va_index >= adapters)
425 return EINVAL;
426 if (adapter[adp->va_index] != adp)
427 return EINVAL;
428 if (vidcdevsw[adp->va_index] != cdevsw)
429 return EINVAL;
430
431 s = spltty();
432 vidcdevsw[adp->va_index] = NULL;
433 splx(s);
434 return 0;
435 }
436
437 #if experimental
438 static int
439 fbopen(dev_t dev, int flag, int mode, struct thread *td)
440 {
441 int unit;
442
443 unit = FB_UNIT(dev);
444 if (unit >= adapters)
445 return ENXIO;
446 if (vidcdevsw[unit] == NULL)
447 return ENXIO;
448 return (*vidcdevsw[unit]->d_open)(makedev(0, adapter[unit]->va_minor),
449 flag, mode, td);
450 }
451
452 static int
453 fbclose(dev_t dev, int flag, int mode, struct thread *td)
454 {
455 int unit;
456
457 unit = FB_UNIT(dev);
458 if (vidcdevsw[unit] == NULL)
459 return ENXIO;
460 return (*vidcdevsw[unit]->d_close)(makedev(0, adapter[unit]->va_minor),
461 flag, mode, td);
462 }
463
464 static int
465 fbread(dev_t dev, struct uio *uio, int flag)
466 {
467 int unit;
468
469 unit = FB_UNIT(dev);
470 if (vidcdevsw[unit] == NULL)
471 return ENXIO;
472 return (*vidcdevsw[unit]->d_read)(makedev(0, adapter[unit]->va_minor),
473 uio, flag);
474 }
475
476 static int
477 fbwrite(dev_t dev, struct uio *uio, int flag)
478 {
479 int unit;
480
481 unit = FB_UNIT(dev);
482 if (vidcdevsw[unit] == NULL)
483 return ENXIO;
484 return (*vidcdevsw[unit]->d_write)(makedev(0, adapter[unit]->va_minor),
485 uio, flag);
486 }
487
488 static int
489 fbioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
490 {
491 int unit;
492
493 unit = FB_UNIT(dev);
494 if (vidcdevsw[unit] == NULL)
495 return ENXIO;
496 return (*vidcdevsw[unit]->d_ioctl)(makedev(0, adapter[unit]->va_minor),
497 cmd, arg, flag, td);
498 }
499
500 static int
501 fbmmap(dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
502 {
503 int unit;
504
505 unit = FB_UNIT(dev);
506 if (vidcdevsw[unit] == NULL)
507 return ENXIO;
508 return (*vidcdevsw[unit]->d_mmap)(makedev(0, adapter[unit]->va_minor),
509 offset, paddr, nprot);
510 }
511
512 DEV_DRIVER_MODULE(fb, ???, fb_driver, fb_devclass, fb_cdevsw, 0, 0);
513 #endif
514
515 /*
516 * Generic frame buffer cdev driver functions
517 * Frame buffer subdrivers may call these functions to implement common
518 * driver functions.
519 */
520
521 int genfbopen(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode,
522 struct thread *td)
523 {
524 int s;
525
526 s = spltty();
527 if (!(sc->gfb_flags & FB_OPEN))
528 sc->gfb_flags |= FB_OPEN;
529 splx(s);
530 return 0;
531 }
532
533 int genfbclose(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode,
534 struct thread *td)
535 {
536 int s;
537
538 s = spltty();
539 sc->gfb_flags &= ~FB_OPEN;
540 splx(s);
541 return 0;
542 }
543
544 int genfbread(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio,
545 int flag)
546 {
547 int size;
548 int offset;
549 int error;
550 int len;
551
552 error = 0;
553 size = adp->va_buffer_size/adp->va_info.vi_planes;
554 while (uio->uio_resid > 0) {
555 if (uio->uio_offset >= size)
556 break;
557 offset = uio->uio_offset%adp->va_window_size;
558 len = imin(uio->uio_resid, size - uio->uio_offset);
559 len = imin(len, adp->va_window_size - offset);
560 if (len <= 0)
561 break;
562 (*vidsw[adp->va_index]->set_win_org)(adp, uio->uio_offset);
563 error = uiomove((caddr_t)(adp->va_window + offset), len, uio);
564 if (error)
565 break;
566 }
567 return error;
568 }
569
570 int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio,
571 int flag)
572 {
573 return ENODEV;
574 }
575
576 int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp, u_long cmd,
577 caddr_t arg, int flag, struct thread *td)
578 {
579 int error;
580
581 if (adp == NULL) /* XXX */
582 return ENXIO;
583 error = (*vidsw[adp->va_index]->ioctl)(adp, cmd, arg);
584 if (error == ENOIOCTL)
585 error = ENODEV;
586 return error;
587 }
588
589 int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp, vm_offset_t offset,
590 vm_offset_t *paddr, int prot)
591 {
592 return (*vidsw[adp->va_index]->mmap)(adp, offset, paddr, prot);
593 }
594
595 #endif /* FB_INSTALL_CDEV */
596
597 static char
598 *adapter_name(int type)
599 {
600 static struct {
601 int type;
602 char *name;
603 } names[] = {
604 { KD_MONO, "MDA" },
605 { KD_HERCULES, "Hercules" },
606 { KD_CGA, "CGA" },
607 { KD_EGA, "EGA" },
608 { KD_VGA, "VGA" },
609 { KD_PC98, "PC-98x1" },
610 { KD_TGA, "TGA" },
611 { -1, "Unknown" },
612 };
613 int i;
614
615 for (i = 0; names[i].type != -1; ++i)
616 if (names[i].type == type)
617 break;
618 return names[i].name;
619 }
620
621 /*
622 * Generic low-level frame buffer functions
623 * The low-level functions in the frame buffer subdriver may use these
624 * functions.
625 */
626
627 void
628 fb_dump_adp_info(char *driver, video_adapter_t *adp, int level)
629 {
630 if (level <= 0)
631 return;
632
633 printf("%s%d: %s%d, %s, type:%s (%d), flags:0x%x\n",
634 FB_DRIVER_NAME, adp->va_index, driver, adp->va_unit, adp->va_name,
635 adapter_name(adp->va_type), adp->va_type, adp->va_flags);
636 printf("%s%d: port:0x%lx-0x%lx, crtc:0x%lx, mem:0x%lx 0x%x\n",
637 FB_DRIVER_NAME, adp->va_index, (u_long)adp->va_io_base,
638 (u_long)adp->va_io_base + adp->va_io_size - 1,
639 (u_long)adp->va_crtc_addr, (u_long)adp->va_mem_base,
640 adp->va_mem_size);
641 printf("%s%d: init mode:%d, bios mode:%d, current mode:%d\n",
642 FB_DRIVER_NAME, adp->va_index,
643 adp->va_initial_mode, adp->va_initial_bios_mode, adp->va_mode);
644 printf("%s%d: window:%p size:%dk gran:%dk, buf:%p size:%dk\n",
645 FB_DRIVER_NAME, adp->va_index,
646 (void *)adp->va_window, (int)adp->va_window_size/1024,
647 (int)adp->va_window_gran/1024, (void *)adp->va_buffer,
648 (int)adp->va_buffer_size/1024);
649 }
650
651 void
652 fb_dump_mode_info(char *driver, video_adapter_t *adp, video_info_t *info,
653 int level)
654 {
655 if (level <= 0)
656 return;
657
658 printf("%s%d: %s, mode:%d, flags:0x%x ",
659 driver, adp->va_unit, adp->va_name, info->vi_mode, info->vi_flags);
660 if (info->vi_flags & V_INFO_GRAPHICS)
661 printf("G %dx%dx%d, %d plane(s), font:%dx%d, ",
662 info->vi_width, info->vi_height,
663 info->vi_depth, info->vi_planes,
664 info->vi_cwidth, info->vi_cheight);
665 else
666 printf("T %dx%d, font:%dx%d, ",
667 info->vi_width, info->vi_height,
668 info->vi_cwidth, info->vi_cheight);
669 printf("win:0x%lx\n", (u_long)info->vi_window);
670 }
671
672 int
673 fb_type(int adp_type)
674 {
675 static struct {
676 int fb_type;
677 int va_type;
678 } types[] = {
679 { FBTYPE_MDA, KD_MONO },
680 { FBTYPE_HERCULES, KD_HERCULES },
681 { FBTYPE_CGA, KD_CGA },
682 { FBTYPE_EGA, KD_EGA },
683 { FBTYPE_VGA, KD_VGA },
684 { FBTYPE_PC98, KD_PC98 },
685 { FBTYPE_TGA, KD_TGA },
686 };
687 int i;
688
689 for (i = 0; i < sizeof(types)/sizeof(types[0]); ++i) {
690 if (types[i].va_type == adp_type)
691 return types[i].fb_type;
692 }
693 return -1;
694 }
695
696 int
697 fb_commonioctl(video_adapter_t *adp, u_long cmd, caddr_t arg)
698 {
699 int error;
700 int s;
701
702 /* assert(adp != NULL) */
703
704 error = 0;
705 s = spltty();
706
707 switch (cmd) {
708
709 case FBIO_ADAPTER: /* get video adapter index */
710 *(int *)arg = adp->va_index;
711 break;
712
713 case FBIO_ADPTYPE: /* get video adapter type */
714 *(int *)arg = adp->va_type;
715 break;
716
717 case FBIO_ADPINFO: /* get video adapter info */
718 ((video_adapter_info_t *)arg)->va_index = adp->va_index;
719 ((video_adapter_info_t *)arg)->va_type = adp->va_type;
720 bcopy(adp->va_name, ((video_adapter_info_t *)arg)->va_name,
721 imin(strlen(adp->va_name) + 1,
722 sizeof(((video_adapter_info_t *)arg)->va_name)));
723 ((video_adapter_info_t *)arg)->va_unit = adp->va_unit;
724 ((video_adapter_info_t *)arg)->va_flags = adp->va_flags;
725 ((video_adapter_info_t *)arg)->va_io_base = adp->va_io_base;
726 ((video_adapter_info_t *)arg)->va_io_size = adp->va_io_size;
727 ((video_adapter_info_t *)arg)->va_crtc_addr = adp->va_crtc_addr;
728 ((video_adapter_info_t *)arg)->va_mem_base = adp->va_mem_base;
729 ((video_adapter_info_t *)arg)->va_mem_size = adp->va_mem_size;
730 ((video_adapter_info_t *)arg)->va_window
731 #ifdef __i386__
732 = vtophys(adp->va_window);
733 #else
734 = adp->va_window;
735 #endif
736 ((video_adapter_info_t *)arg)->va_window_size
737 = adp->va_window_size;
738 ((video_adapter_info_t *)arg)->va_window_gran
739 = adp->va_window_gran;
740 ((video_adapter_info_t *)arg)->va_window_orig
741 = adp->va_window_orig;
742 ((video_adapter_info_t *)arg)->va_unused0
743 #ifdef __i386__
744 = (adp->va_buffer) ? vtophys(adp->va_buffer) : 0;
745 #else
746 = adp->va_buffer;
747 #endif
748 ((video_adapter_info_t *)arg)->va_buffer_size
749 = adp->va_buffer_size;
750 ((video_adapter_info_t *)arg)->va_mode = adp->va_mode;
751 ((video_adapter_info_t *)arg)->va_initial_mode
752 = adp->va_initial_mode;
753 ((video_adapter_info_t *)arg)->va_initial_bios_mode
754 = adp->va_initial_bios_mode;
755 ((video_adapter_info_t *)arg)->va_line_width
756 = adp->va_line_width;
757 ((video_adapter_info_t *)arg)->va_disp_start.x
758 = adp->va_disp_start.x;
759 ((video_adapter_info_t *)arg)->va_disp_start.y
760 = adp->va_disp_start.y;
761 break;
762
763 case FBIO_MODEINFO: /* get mode information */
764 error = (*vidsw[adp->va_index]->get_info)(adp,
765 ((video_info_t *)arg)->vi_mode,
766 (video_info_t *)arg);
767 if (error)
768 error = ENODEV;
769 break;
770
771 case FBIO_FINDMODE: /* find a matching video mode */
772 error = (*vidsw[adp->va_index]->query_mode)(adp,
773 (video_info_t *)arg);
774 break;
775
776 case FBIO_GETMODE: /* get video mode */
777 *(int *)arg = adp->va_mode;
778 break;
779
780 case FBIO_SETMODE: /* set video mode */
781 error = (*vidsw[adp->va_index]->set_mode)(adp, *(int *)arg);
782 if (error)
783 error = ENODEV; /* EINVAL? */
784 break;
785
786 case FBIO_GETWINORG: /* get frame buffer window origin */
787 *(u_int *)arg = adp->va_window_orig;
788 break;
789
790 case FBIO_GETDISPSTART: /* get display start address */
791 ((video_display_start_t *)arg)->x = adp->va_disp_start.x;
792 ((video_display_start_t *)arg)->y = adp->va_disp_start.y;
793 break;
794
795 case FBIO_GETLINEWIDTH: /* get scan line width in bytes */
796 *(u_int *)arg = adp->va_line_width;
797 break;
798
799 case FBIO_BLANK: /* blank display */
800 error = (*vidsw[adp->va_index]->blank_display)(adp, *(int *)arg);
801 break;
802
803 case FBIO_GETPALETTE: /* get color palette */
804 case FBIO_SETPALETTE: /* set color palette */
805 /* XXX */
806
807 case FBIOPUTCMAP:
808 case FBIOGETCMAP:
809 case FBIOPUTCMAPI:
810 case FBIOGETCMAPI:
811 /* XXX */
812
813 case FBIO_SETWINORG: /* set frame buffer window origin */
814 case FBIO_SETDISPSTART: /* set display start address */
815 case FBIO_SETLINEWIDTH: /* set scan line width in pixel */
816
817 case FBIOGTYPE:
818 case FBIOGATTR:
819 case FBIOSVIDEO:
820 case FBIOGVIDEO:
821 case FBIOVERTICAL:
822 case FBIOSCURSOR:
823 case FBIOGCURSOR:
824 case FBIOSCURPOS:
825 case FBIOGCURPOS:
826 case FBIOGCURMAX:
827 case FBIOMONINFO:
828 case FBIOGXINFO:
829
830 default:
831 error = ENODEV;
832 break;
833 }
834
835 splx(s);
836 return error;
837 }
Cache object: 0dea7c3046acc796a4fbefffdb468e02
|