xref: /original-bsd/sys/sparc/dev/fb.c (revision 13deef58)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * %sccs.include.redist.c%
10  *
11  *	@(#)fb.c	7.1 (Berkeley) 07/13/92
12  *
13  * from: $Header: fb.c,v 1.6 92/06/17 05:35:46 torek Exp $
14  */
15 
16 /*
17  * /dev/fb (indirect frame buffer driver).  This is gross; we should
18  * just build cdevsw[] dynamically.
19  */
20 
21 #include "sys/param.h"
22 #include "sys/conf.h"
23 #include "sys/device.h"
24 #include "sys/proc.h"
25 #include "sys/fbio.h"
26 
27 #include "machine/fbvar.h"
28 
29 static struct fbdevice *devfb;
30 
31 void
32 fb_unblank()
33 {
34 
35 	if (devfb)
36 		(*devfb->fb_driver->fbd_unblank)(devfb->fb_device);
37 }
38 
39 void
40 fb_attach(fb)
41 	struct fbdevice *fb;
42 {
43 
44 if (devfb) panic("multiple /dev/fb declarers");
45 	devfb = fb;
46 }
47 
48 int
49 fbopen(dev, flags, mode, p)
50 	dev_t dev;
51 	int flags, mode;
52 	struct proc *p;
53 {
54 
55 	if (devfb == NULL)
56 		return (ENXIO);
57 	return (cdevsw[devfb->fb_major].d_open(dev, flags, mode, p));
58 }
59 
60 int
61 fbclose(dev, flags, mode, p)
62 	dev_t dev;
63 	int flags, mode;
64 	struct proc *p;
65 {
66 
67 	return (cdevsw[devfb->fb_major].d_close(dev, flags, mode, p));
68 }
69 
70 int
71 fbioctl(dev, cmd, data, flags, p)
72 	dev_t dev;
73 	int cmd;
74 	caddr_t data;
75 	int flags;
76 	struct proc *p;
77 {
78 
79 	return (cdevsw[devfb->fb_major].d_ioctl(dev, cmd, data, flags, p));
80 }
81 
82 int
83 fbmap(dev, off, prot)
84 	dev_t dev;
85 	int off, prot;
86 {
87 	int (*map)() = cdevsw[devfb->fb_major].d_mmap;
88 
89 	if (map == NULL)
90 		return (-1);
91 	return (map(dev, off, prot));
92 }
93