xref: /freebsd/sys/dev/fb/fb.c (revision ab00ac327a66a53edaac95b536b209db3ae2cd9f)
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 
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31 
32 #include "opt_fb.h"
33 
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/conf.h>
37 #include <sys/bus.h>
38 #include <sys/kernel.h>
39 #include <sys/malloc.h>
40 #include <sys/module.h>
41 #include <sys/uio.h>
42 #include <sys/fbio.h>
43 #include <sys/linker_set.h>
44 
45 #include <vm/vm.h>
46 #include <vm/pmap.h>
47 
48 #include <dev/fb/fbreg.h>
49 
50 SET_DECLARE(videodriver_set, const video_driver_t);
51 
52 /* local arrays */
53 
54 /*
55  * We need at least one entry each in order to initialize a video card
56  * for the kernel console.  The arrays will be increased dynamically
57  * when necessary.
58  */
59 
60 static int		vid_malloc;
61 static int		adapters = 1;
62 static video_adapter_t	*adp_ini;
63 static video_adapter_t	**adapter = &adp_ini;
64 static video_switch_t	*vidsw_ini;
65        video_switch_t	**vidsw = &vidsw_ini;
66 
67 #ifdef FB_INSTALL_CDEV
68 static struct cdevsw	*vidcdevsw_ini;
69 static struct cdevsw	**vidcdevsw = &vidcdevsw_ini;
70 #endif
71 
72 #define ARRAY_DELTA	4
73 
74 static int
75 vid_realloc_array(void)
76 {
77 	video_adapter_t **new_adp;
78 	video_switch_t **new_vidsw;
79 #ifdef FB_INSTALL_CDEV
80 	struct cdevsw **new_cdevsw;
81 #endif
82 	int newsize;
83 	int s;
84 
85 	if (!vid_malloc)
86 		return ENOMEM;
87 
88 	s = spltty();
89 	newsize = rounddown(adapters + ARRAY_DELTA, ARRAY_DELTA);
90 	new_adp = malloc(sizeof(*new_adp)*newsize, M_DEVBUF, M_WAITOK | M_ZERO);
91 	new_vidsw = malloc(sizeof(*new_vidsw)*newsize, M_DEVBUF,
92 	    M_WAITOK | M_ZERO);
93 #ifdef FB_INSTALL_CDEV
94 	new_cdevsw = malloc(sizeof(*new_cdevsw)*newsize, M_DEVBUF,
95 	    M_WAITOK | M_ZERO);
96 #endif
97 	bcopy(adapter, new_adp, sizeof(*adapter)*adapters);
98 	bcopy(vidsw, new_vidsw, sizeof(*vidsw)*adapters);
99 #ifdef FB_INSTALL_CDEV
100 	bcopy(vidcdevsw, new_cdevsw, sizeof(*vidcdevsw)*adapters);
101 #endif
102 	if (adapters > 1) {
103 		free(adapter, M_DEVBUF);
104 		free(vidsw, M_DEVBUF);
105 #ifdef FB_INSTALL_CDEV
106 		free(vidcdevsw, M_DEVBUF);
107 #endif
108 	}
109 	adapter = new_adp;
110 	vidsw = new_vidsw;
111 #ifdef FB_INSTALL_CDEV
112 	vidcdevsw = new_cdevsw;
113 #endif
114 	adapters = newsize;
115 	splx(s);
116 
117 	if (bootverbose)
118 		printf("fb: new array size %d\n", adapters);
119 
120 	return 0;
121 }
122 
123 static void
124 vid_malloc_init(void *arg)
125 {
126 	vid_malloc = TRUE;
127 }
128 
129 SYSINIT(vid_mem, SI_SUB_KMEM, SI_ORDER_ANY, vid_malloc_init, NULL);
130 
131 /*
132  * Low-level frame buffer driver functions
133  * frame buffer subdrivers, such as the VGA driver, call these functions
134  * to initialize the video_adapter structure and register it to the virtual
135  * frame buffer driver `fb'.
136  */
137 
138 /* initialize the video_adapter_t structure */
139 void
140 vid_init_struct(video_adapter_t *adp, char *name, int type, int unit)
141 {
142 	adp->va_flags = 0;
143 	adp->va_name = name;
144 	adp->va_type = type;
145 	adp->va_unit = unit;
146 }
147 
148 /* Register a video adapter */
149 int
150 vid_register(video_adapter_t *adp)
151 {
152 	const video_driver_t **list;
153 	const video_driver_t *p;
154 	int index;
155 
156 	for (index = 0; index < adapters; ++index) {
157 		if (adapter[index] == NULL)
158 			break;
159 	}
160 	if (index >= adapters) {
161 		if (vid_realloc_array())
162 			return -1;
163 	}
164 
165 	adp->va_index = index;
166 	adp->va_token = NULL;
167 	SET_FOREACH(list, videodriver_set) {
168 		p = *list;
169 		if (strcmp(p->name, adp->va_name) == 0) {
170 			adapter[index] = adp;
171 			vidsw[index] = p->vidsw;
172 			return index;
173 		}
174 	}
175 
176 	return -1;
177 }
178 
179 int
180 vid_unregister(video_adapter_t *adp)
181 {
182 	if ((adp->va_index < 0) || (adp->va_index >= adapters))
183 		return ENOENT;
184 	if (adapter[adp->va_index] != adp)
185 		return ENOENT;
186 
187 	adapter[adp->va_index] = NULL;
188 	vidsw[adp->va_index] = NULL;
189 	return 0;
190 }
191 
192 /* Get video I/O function table */
193 video_switch_t
194 *vid_get_switch(char *name)
195 {
196 	const video_driver_t **list;
197 	const video_driver_t *p;
198 
199 	SET_FOREACH(list, videodriver_set) {
200 		p = *list;
201 		if (strcmp(p->name, name) == 0)
202 			return p->vidsw;
203 	}
204 
205 	return NULL;
206 }
207 
208 /*
209  * Video card client functions
210  * Video card clients, such as the console driver `syscons' and the frame
211  * buffer cdev driver, use these functions to claim and release a card for
212  * exclusive use.
213  */
214 
215 /* find the video card specified by a driver name and a unit number */
216 int
217 vid_find_adapter(char *driver, int unit)
218 {
219 	int i;
220 
221 	for (i = 0; i < adapters; ++i) {
222 		if (adapter[i] == NULL)
223 			continue;
224 		if (strcmp("*", driver) && strcmp(adapter[i]->va_name, driver))
225 			continue;
226 		if ((unit != -1) && (adapter[i]->va_unit != unit))
227 			continue;
228 		return i;
229 	}
230 	return -1;
231 }
232 
233 /* allocate a video card */
234 int
235 vid_allocate(char *driver, int unit, void *id)
236 {
237 	int index;
238 	int s;
239 
240 	s = spltty();
241 	index = vid_find_adapter(driver, unit);
242 	if (index >= 0) {
243 		if (adapter[index]->va_token) {
244 			splx(s);
245 			return -1;
246 		}
247 		adapter[index]->va_token = id;
248 	}
249 	splx(s);
250 	return index;
251 }
252 
253 int
254 vid_release(video_adapter_t *adp, void *id)
255 {
256 	int error;
257 	int s;
258 
259 	s = spltty();
260 	if (adp->va_token == NULL) {
261 		error = EINVAL;
262 	} else if (adp->va_token != id) {
263 		error = EPERM;
264 	} else {
265 		adp->va_token = NULL;
266 		error = 0;
267 	}
268 	splx(s);
269 	return error;
270 }
271 
272 /* Get a video adapter structure */
273 video_adapter_t
274 *vid_get_adapter(int index)
275 {
276 	if ((index < 0) || (index >= adapters))
277 		return NULL;
278 	return adapter[index];
279 }
280 
281 /* Configure drivers: this is a backdoor for the console driver XXX */
282 int
283 vid_configure(int flags)
284 {
285 	const video_driver_t **list;
286 	const video_driver_t *p;
287 
288 	SET_FOREACH(list, videodriver_set) {
289 		p = *list;
290 		if (p->configure != NULL)
291 			(*p->configure)(flags);
292 	}
293 
294 	return 0;
295 }
296 
297 /*
298  * Virtual frame buffer cdev driver functions
299  * The virtual frame buffer driver dispatches driver functions to
300  * appropriate subdrivers.
301  */
302 
303 #define FB_DRIVER_NAME	"fb"
304 
305 #ifdef FB_INSTALL_CDEV
306 
307 #if 0 /* experimental */
308 
309 static devclass_t	fb_devclass;
310 
311 static int		fbprobe(device_t dev);
312 static int		fbattach(device_t dev);
313 
314 static device_method_t fb_methods[] = {
315 	DEVMETHOD(device_probe,		fbprobe),
316 	DEVMETHOD(device_attach,	fbattach),
317 
318 	DEVMETHOD_END
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
351 
352 #define FB_UNIT(dev)	dev2unit(dev)
353 #define FB_MKMINOR(unit) (u)
354 
355 #if 0 /* 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 
364 static struct cdevsw fb_cdevsw = {
365 	.d_version =	D_VERSION,
366 	.d_flags =	D_NEEDGIANT,
367 	.d_open =	fbopen,
368 	.d_close =	fbclose,
369 	.d_read =	fbread,
370 	.d_write =	fbwrite,
371 	.d_ioctl =	fbioctl,
372 	.d_mmap =	fbmmap,
373 	.d_name =	FB_DRIVER_NAME,
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 	default:
389 		return EOPNOTSUPP;
390 	}
391 	return 0;
392 }
393 
394 static moduledata_t fb_mod = {
395 	"fb",
396 	fb_modevent,
397 	NULL
398 };
399 
400 DECLARE_MODULE(fb, fb_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
401 
402 int
403 fb_attach(int unit, video_adapter_t *adp, struct cdevsw *cdevsw)
404 {
405 	int s;
406 
407 	if (adp->va_index >= adapters)
408 		return EINVAL;
409 	if (adapter[adp->va_index] != adp)
410 		return EINVAL;
411 
412 	s = spltty();
413 	adp->va_minor = unit;
414 	vidcdevsw[adp->va_index] = cdevsw;
415 	splx(s);
416 
417 	printf("fb%d at %s%d\n", adp->va_index, adp->va_name, adp->va_unit);
418 	return 0;
419 }
420 
421 int
422 fb_detach(int unit, video_adapter_t *adp, struct cdevsw *cdevsw)
423 {
424 	int s;
425 
426 	if (adp->va_index >= adapters)
427 		return EINVAL;
428 	if (adapter[adp->va_index] != adp)
429 		return EINVAL;
430 	if (vidcdevsw[adp->va_index] != cdevsw)
431 		return EINVAL;
432 
433 	s = spltty();
434 	vidcdevsw[adp->va_index] = NULL;
435 	splx(s);
436 	return 0;
437 }
438 
439 /*
440  * Generic frame buffer cdev driver functions
441  * Frame buffer subdrivers may call these functions to implement common
442  * driver functions.
443  */
444 
445 int genfbopen(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode,
446 	      struct thread *td)
447 {
448 	int s;
449 
450 	s = spltty();
451 	if (!(sc->gfb_flags & FB_OPEN))
452 		sc->gfb_flags |= FB_OPEN;
453 	splx(s);
454 	return 0;
455 }
456 
457 int genfbclose(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode,
458 	       struct thread *td)
459 {
460 	int s;
461 
462 	s = spltty();
463 	sc->gfb_flags &= ~FB_OPEN;
464 	splx(s);
465 	return 0;
466 }
467 
468 int genfbread(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio,
469 	      int flag)
470 {
471 	int size;
472 	int offset;
473 	int error;
474 	int len;
475 
476 	error = 0;
477 	size = adp->va_buffer_size/adp->va_info.vi_planes;
478 	while (uio->uio_resid > 0) {
479 		if (uio->uio_offset >= size)
480 			break;
481 		offset = uio->uio_offset%adp->va_window_size;
482 		len = imin(uio->uio_resid, size - uio->uio_offset);
483 		len = imin(len, adp->va_window_size - offset);
484 		if (len <= 0)
485 			break;
486 		vidd_set_win_org(adp, uio->uio_offset);
487 		error = uiomove((caddr_t)(adp->va_window + offset), len, uio);
488 		if (error)
489 			break;
490 	}
491 	return error;
492 }
493 
494 int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio,
495 	       int flag)
496 {
497 	return ENODEV;
498 }
499 
500 int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp, u_long cmd,
501 	       caddr_t arg, int flag, struct thread *td)
502 {
503 	int error;
504 
505 	if (adp == NULL)	/* XXX */
506 		return ENXIO;
507 	error = vidd_ioctl(adp, cmd, arg);
508 	if (error == ENOIOCTL)
509 		error = ENODEV;
510 	return error;
511 }
512 
513 int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp, vm_ooffset_t offset,
514 	      vm_offset_t *paddr, int prot, vm_memattr_t *memattr)
515 {
516 	return vidd_mmap(adp, offset, paddr, prot, memattr);
517 }
518 
519 #endif /* FB_INSTALL_CDEV */
520 
521 static char
522 *adapter_name(int type)
523 {
524     static struct {
525 	int type;
526 	char *name;
527     } names[] = {
528 	{ KD_MONO,	"MDA" },
529 	{ KD_HERCULES,	"Hercules" },
530 	{ KD_CGA,	"CGA" },
531 	{ KD_EGA,	"EGA" },
532 	{ KD_VGA,	"VGA" },
533 	{ KD_TGA,	"TGA" },
534 	{ -1,		"Unknown" },
535     };
536     int i;
537 
538     for (i = 0; names[i].type != -1; ++i)
539 	if (names[i].type == type)
540 	    break;
541     return names[i].name;
542 }
543 
544 /*
545  * Generic low-level frame buffer functions
546  * The low-level functions in the frame buffer subdriver may use these
547  * functions.
548  */
549 
550 void
551 fb_dump_adp_info(char *driver, video_adapter_t *adp, int level)
552 {
553     if (level <= 0)
554 	return;
555 
556     printf("%s%d: %s%d, %s, type:%s (%d), flags:0x%x\n",
557 	   FB_DRIVER_NAME, adp->va_index, driver, adp->va_unit, adp->va_name,
558 	   adapter_name(adp->va_type), adp->va_type, adp->va_flags);
559     printf("%s%d: port:0x%lx-0x%lx, crtc:0x%lx, mem:0x%lx 0x%x\n",
560 	   FB_DRIVER_NAME, adp->va_index, (u_long)adp->va_io_base,
561 	   (u_long)adp->va_io_base + adp->va_io_size - 1,
562 	   (u_long)adp->va_crtc_addr, (u_long)adp->va_mem_base,
563 	   adp->va_mem_size);
564     printf("%s%d: init mode:%d, bios mode:%d, current mode:%d\n",
565 	   FB_DRIVER_NAME, adp->va_index,
566 	   adp->va_initial_mode, adp->va_initial_bios_mode, adp->va_mode);
567     printf("%s%d: window:%p size:%dk gran:%dk, buf:%p size:%dk\n",
568 	   FB_DRIVER_NAME, adp->va_index,
569 	   (void *)adp->va_window, (int)adp->va_window_size/1024,
570 	   (int)adp->va_window_gran/1024, (void *)adp->va_buffer,
571 	   (int)adp->va_buffer_size/1024);
572 }
573 
574 void
575 fb_dump_mode_info(char *driver, video_adapter_t *adp, video_info_t *info,
576 		  int level)
577 {
578     if (level <= 0)
579 	return;
580 
581     printf("%s%d: %s, mode:%d, flags:0x%x ",
582 	   driver, adp->va_unit, adp->va_name, info->vi_mode, info->vi_flags);
583     if (info->vi_flags & V_INFO_GRAPHICS)
584 	printf("G %dx%dx%d, %d plane(s), font:%dx%d, ",
585 	       info->vi_width, info->vi_height,
586 	       info->vi_depth, info->vi_planes,
587 	       info->vi_cwidth, info->vi_cheight);
588     else
589 	printf("T %dx%d, font:%dx%d, ",
590 	       info->vi_width, info->vi_height,
591 	       info->vi_cwidth, info->vi_cheight);
592     printf("win:0x%lx\n", (u_long)info->vi_window);
593 }
594 
595 int
596 fb_type(int adp_type)
597 {
598 	static struct {
599 		int	fb_type;
600 		int	va_type;
601 	} types[] = {
602 		{ FBTYPE_MDA,		KD_MONO },
603 		{ FBTYPE_HERCULES,	KD_HERCULES },
604 		{ FBTYPE_CGA,		KD_CGA },
605 		{ FBTYPE_EGA,		KD_EGA },
606 		{ FBTYPE_VGA,		KD_VGA },
607 		{ FBTYPE_TGA,		KD_TGA },
608 	};
609 	int i;
610 
611 	for (i = 0; i < nitems(types); ++i) {
612 		if (types[i].va_type == adp_type)
613 			return types[i].fb_type;
614 	}
615 	return -1;
616 }
617 
618 int
619 fb_commonioctl(video_adapter_t *adp, u_long cmd, caddr_t arg)
620 {
621 	int error;
622 	int s;
623 
624 	/* assert(adp != NULL) */
625 
626 	error = 0;
627 	s = spltty();
628 
629 	switch (cmd) {
630 
631 	case FBIO_ADAPTER:	/* get video adapter index */
632 		*(int *)arg = adp->va_index;
633 		break;
634 
635 	case FBIO_ADPTYPE:	/* get video adapter type */
636 		*(int *)arg = adp->va_type;
637 		break;
638 
639 	case FBIO_ADPINFO:	/* get video adapter info */
640 	        ((video_adapter_info_t *)arg)->va_index = adp->va_index;
641 		((video_adapter_info_t *)arg)->va_type = adp->va_type;
642 		bcopy(adp->va_name, ((video_adapter_info_t *)arg)->va_name,
643 		      imin(strlen(adp->va_name) + 1,
644 			   sizeof(((video_adapter_info_t *)arg)->va_name)));
645 		((video_adapter_info_t *)arg)->va_unit = adp->va_unit;
646 		((video_adapter_info_t *)arg)->va_flags = adp->va_flags;
647 		((video_adapter_info_t *)arg)->va_io_base = adp->va_io_base;
648 		((video_adapter_info_t *)arg)->va_io_size = adp->va_io_size;
649 		((video_adapter_info_t *)arg)->va_crtc_addr = adp->va_crtc_addr;
650 		((video_adapter_info_t *)arg)->va_mem_base = adp->va_mem_base;
651 		((video_adapter_info_t *)arg)->va_mem_size = adp->va_mem_size;
652 		((video_adapter_info_t *)arg)->va_window
653 #if defined(__amd64__) || defined(__i386__)
654 			= vtophys(adp->va_window);
655 #else
656 			= adp->va_window;
657 #endif
658 		((video_adapter_info_t *)arg)->va_window_size
659 			= adp->va_window_size;
660 		((video_adapter_info_t *)arg)->va_window_gran
661 			= adp->va_window_gran;
662 		((video_adapter_info_t *)arg)->va_window_orig
663 			= adp->va_window_orig;
664 		((video_adapter_info_t *)arg)->va_unused0
665 #if defined(__amd64__) || defined(__i386__)
666 			= adp->va_buffer != 0 ? vtophys(adp->va_buffer) : 0;
667 #else
668 			= adp->va_buffer;
669 #endif
670 		((video_adapter_info_t *)arg)->va_buffer_size
671 			= adp->va_buffer_size;
672 		((video_adapter_info_t *)arg)->va_mode = adp->va_mode;
673 		((video_adapter_info_t *)arg)->va_initial_mode
674 			= adp->va_initial_mode;
675 		((video_adapter_info_t *)arg)->va_initial_bios_mode
676 			= adp->va_initial_bios_mode;
677 		((video_adapter_info_t *)arg)->va_line_width
678 			= adp->va_line_width;
679 		((video_adapter_info_t *)arg)->va_disp_start.x
680 			= adp->va_disp_start.x;
681 		((video_adapter_info_t *)arg)->va_disp_start.y
682 			= adp->va_disp_start.y;
683 		break;
684 
685 	case FBIO_MODEINFO:	/* get mode information */
686 		error = vidd_get_info(adp,
687 		    ((video_info_t *)arg)->vi_mode,
688 		    (video_info_t *)arg);
689 		if (error)
690 			error = ENODEV;
691 		break;
692 
693 	case FBIO_FINDMODE:	/* find a matching video mode */
694 		error = vidd_query_mode(adp, (video_info_t *)arg);
695 		break;
696 
697 	case FBIO_GETMODE:	/* get video mode */
698 		*(int *)arg = adp->va_mode;
699 		break;
700 
701 	case FBIO_SETMODE:	/* set video mode */
702 		error = vidd_set_mode(adp, *(int *)arg);
703 		if (error)
704 			error = ENODEV;	/* EINVAL? */
705 		break;
706 
707 	case FBIO_GETWINORG:	/* get frame buffer window origin */
708 		*(u_int *)arg = adp->va_window_orig;
709 		break;
710 
711 	case FBIO_GETDISPSTART:	/* get display start address */
712 		((video_display_start_t *)arg)->x = adp->va_disp_start.x;
713 		((video_display_start_t *)arg)->y = adp->va_disp_start.y;
714 		break;
715 
716 	case FBIO_GETLINEWIDTH:	/* get scan line width in bytes */
717 		*(u_int *)arg = adp->va_line_width;
718 		break;
719 
720 	case FBIO_BLANK:	/* blank display */
721 		error = vidd_blank_display(adp, *(int *)arg);
722 		break;
723 
724 	case FBIO_GETPALETTE:	/* get color palette */
725 	case FBIO_SETPALETTE:	/* set color palette */
726 		/* XXX */
727 
728 	case FBIOPUTCMAP:
729 	case FBIOGETCMAP:
730 	case FBIOPUTCMAPI:
731 	case FBIOGETCMAPI:
732 		/* XXX */
733 
734 	case FBIO_SETWINORG:	/* set frame buffer window origin */
735 	case FBIO_SETDISPSTART:	/* set display start address */
736 	case FBIO_SETLINEWIDTH:	/* set scan line width in pixel */
737 
738 	case FBIOGTYPE:
739 	case FBIOGATTR:
740 	case FBIOSVIDEO:
741 	case FBIOGVIDEO:
742 	case FBIOVERTICAL:
743 	case FBIOSCURSOR:
744 	case FBIOGCURSOR:
745 	case FBIOSCURPOS:
746 	case FBIOGCURPOS:
747 	case FBIOGCURMAX:
748 	case FBIOMONINFO:
749 	case FBIOGXINFO:
750 
751 	default:
752 		error = ENODEV;
753 		break;
754 	}
755 
756 	splx(s);
757 	return error;
758 }
759