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 * 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 7.4 (Berkeley) 04/20/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 37 fb_unblank() 38 { 39 40 if (devfb) 41 (*devfb->fb_driver->fbd_unblank)(devfb->fb_device); 42 } 43 44 void 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 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 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 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 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