1 /*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. 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 * All advertising materials mentioning features or use of this software
10 * must display the following acknowledgement:
11 * This product includes software developed by the University of
12 * California, Lawrence Berkeley Laboratory.
13 *
14 * %sccs.include.redist.c%
15 *
16 * @(#)fb.c 8.1 (Berkeley) 06/11/93
17 *
18 * from: $Header: fb.c,v 1.7 92/11/26 01:12:48 torek Exp $
19 */
20
21 /*
22 * /dev/fb (indirect frame buffer driver). This is gross; we should
23 * just build cdevsw[] dynamically.
24 */
25
26 #include <sys/param.h>
27 #include <sys/conf.h>
28 #include <sys/device.h>
29 #include <sys/proc.h>
30 #include <sys/fbio.h>
31
32 #include <machine/fbvar.h>
33
34 static struct fbdevice *devfb;
35
36 void
fb_unblank()37 fb_unblank()
38 {
39
40 if (devfb)
41 (*devfb->fb_driver->fbd_unblank)(devfb->fb_device);
42 }
43
44 void
fb_attach(fb)45 fb_attach(fb)
46 struct fbdevice *fb;
47 {
48
49 if (devfb) panic("multiple /dev/fb declarers");
50 devfb = fb;
51 }
52
53 int
fbopen(dev,flags,mode,p)54 fbopen(dev, flags, mode, p)
55 dev_t dev;
56 int flags, mode;
57 struct proc *p;
58 {
59
60 if (devfb == NULL)
61 return (ENXIO);
62 return (cdevsw[devfb->fb_major].d_open(dev, flags, mode, p));
63 }
64
65 int
fbclose(dev,flags,mode,p)66 fbclose(dev, flags, mode, p)
67 dev_t dev;
68 int flags, mode;
69 struct proc *p;
70 {
71
72 return (cdevsw[devfb->fb_major].d_close(dev, flags, mode, p));
73 }
74
75 int
fbioctl(dev,cmd,data,flags,p)76 fbioctl(dev, cmd, data, flags, p)
77 dev_t dev;
78 int cmd;
79 caddr_t data;
80 int flags;
81 struct proc *p;
82 {
83
84 return (cdevsw[devfb->fb_major].d_ioctl(dev, cmd, data, flags, p));
85 }
86
87 int
fbmap(dev,off,prot)88 fbmap(dev, off, prot)
89 dev_t dev;
90 int off, prot;
91 {
92 int (*map)() = cdevsw[devfb->fb_major].d_mmap;
93
94 if (map == NULL)
95 return (-1);
96 return (map(dev, off, prot));
97 }
98