Home | History | Annotate | Line # | Download | only in dev
grf.c revision 1.27
      1  1.27   gehenna /*	$NetBSD: grf.c,v 1.27 2002/09/06 13:18:43 gehenna Exp $	*/
      2   1.1       leo 
      3   1.1       leo /*
      4   1.1       leo  * Copyright (c) 1995 Leo Weppelman
      5   1.1       leo  * Copyright (c) 1988 University of Utah.
      6   1.1       leo  * Copyright (c) 1990 The Regents of the University of California.
      7   1.1       leo  * All rights reserved.
      8   1.1       leo  *
      9   1.1       leo  * This code is derived from software contributed to Berkeley by
     10   1.1       leo  * the Systems Programming Group of the University of Utah Computer
     11   1.1       leo  * Science Department.
     12   1.1       leo  *
     13   1.1       leo  * Redistribution and use in source and binary forms, with or without
     14   1.1       leo  * modification, are permitted provided that the following conditions
     15   1.1       leo  * are met:
     16   1.1       leo  * 1. Redistributions of source code must retain the above copyright
     17   1.1       leo  *    notice, this list of conditions and the following disclaimer.
     18   1.1       leo  * 2. Redistributions in binary form must reproduce the above copyright
     19   1.1       leo  *    notice, this list of conditions and the following disclaimer in the
     20   1.1       leo  *    documentation and/or other materials provided with the distribution.
     21   1.1       leo  * 3. All advertising materials mentioning features or use of this software
     22   1.1       leo  *    must display the following acknowledgement:
     23   1.1       leo  *	This product includes software developed by the University of
     24   1.1       leo  *	California, Berkeley and its contributors.
     25   1.1       leo  * 4. Neither the name of the University nor the names of its contributors
     26   1.1       leo  *    may be used to endorse or promote products derived from this software
     27   1.1       leo  *    without specific prior written permission.
     28   1.1       leo  *
     29   1.1       leo  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     30   1.1       leo  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     31   1.1       leo  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     32   1.1       leo  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     33   1.1       leo  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     34   1.1       leo  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     35   1.1       leo  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     36   1.1       leo  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     37   1.1       leo  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     38   1.1       leo  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     39   1.1       leo  * SUCH DAMAGE.
     40   1.1       leo  *
     41   1.1       leo  * from: Utah $Hdr: grf.c 1.31 91/01/21$
     42   1.1       leo  *
     43   1.1       leo  *	@(#)grf.c	7.8 (Berkeley) 5/7/91
     44   1.1       leo  */
     45   1.1       leo 
     46   1.1       leo /*
     47   1.1       leo  * Graphics display driver for the Atari
     48   1.1       leo  * This is the hardware-independent portion of the driver.
     49   1.1       leo  * Hardware access is through the grf_softc->g_mode routine.
     50   1.1       leo  */
     51   1.1       leo 
     52   1.1       leo #include <sys/param.h>
     53   1.1       leo #include <sys/proc.h>
     54   1.1       leo #include <sys/ioctl.h>
     55   1.1       leo #include <sys/device.h>
     56   1.1       leo #include <sys/file.h>
     57   1.1       leo #include <sys/malloc.h>
     58   1.1       leo #include <sys/conf.h>
     59   1.1       leo #include <sys/systm.h>
     60   1.1       leo #include <sys/vnode.h>
     61   1.1       leo #include <sys/mman.h>
     62  1.13       leo #include <sys/poll.h>
     63  1.25       mrg 
     64   1.1       leo #include <machine/cpu.h>
     65  1.25       mrg 
     66  1.25       mrg #include <uvm/uvm_extern.h>
     67  1.25       mrg 
     68   1.1       leo #include <atari/atari/device.h>
     69   1.1       leo #include <atari/dev/grfioctl.h>
     70   1.1       leo #include <atari/dev/grfabs_reg.h>
     71   1.1       leo #include <atari/dev/grfvar.h>
     72   1.1       leo #include <atari/dev/itevar.h>
     73   1.1       leo #include <atari/dev/viewioctl.h>
     74   1.1       leo #include <atari/dev/viewvar.h>
     75   1.1       leo 
     76  1.12       leo #include "grfcc.h"
     77  1.12       leo #include "grfet.h"
     78  1.12       leo #define	NGRF	(NGRFCC + NGRFET)
     79  1.12       leo 
     80   1.1       leo #if NGRF > 0
     81   1.1       leo 
     82   1.1       leo #include "ite.h"
     83   1.1       leo #if NITE == 0
     84   1.1       leo #define	ite_on(u,f)
     85   1.1       leo #define	ite_off(u,f)
     86   1.1       leo #define ite_reinit(d)
     87   1.1       leo #endif
     88   1.1       leo 
     89   1.1       leo int grfon __P((dev_t));
     90   1.1       leo int grfoff __P((dev_t));
     91   1.1       leo int grfsinfo __P((dev_t, struct grfdyninfo *));
     92   1.1       leo 
     93  1.11       cgd int grfbusprint __P((void *auxp, const char *));
     94  1.17       leo int grfbusmatch __P((struct device *, struct cfdata *, void *));
     95   1.1       leo void grfbusattach __P((struct device *, struct device *, void *));
     96   1.1       leo 
     97   1.1       leo /*
     98   1.1       leo  * pointers to grf drivers device structs
     99   1.1       leo  */
    100  1.12       leo struct grf_softc *grfsp[NGRF]; /* XXX */
    101   1.1       leo 
    102   1.8   thorpej struct cfattach grfbus_ca = {
    103   1.8   thorpej 	sizeof(struct device), grfbusmatch, grfbusattach
    104   1.8   thorpej };
    105   1.8   thorpej 
    106  1.21   thorpej extern struct cfdriver grfbus_cd;
    107   1.1       leo 
    108  1.27   gehenna dev_type_open(grfopen);
    109  1.27   gehenna dev_type_close(grfclose);
    110  1.27   gehenna dev_type_ioctl(grfioctl);
    111  1.27   gehenna dev_type_poll(grfpoll);
    112  1.27   gehenna dev_type_mmap(grfmmap);
    113  1.27   gehenna 
    114  1.27   gehenna const struct cdevsw grf_cdevsw = {
    115  1.27   gehenna 	grfopen, grfclose, noread, nowrite, grfioctl,
    116  1.27   gehenna 	nostop, notty, grfpoll, grfmmap,
    117  1.27   gehenna };
    118  1.27   gehenna 
    119   1.1       leo /*
    120   1.1       leo  * only used in console init.
    121   1.1       leo  */
    122   1.1       leo static struct cfdata *cfdata_gbus  = NULL;
    123   1.1       leo 
    124   1.1       leo int
    125  1.17       leo grfbusmatch(pdp, cfp, auxp)
    126   1.1       leo struct device	*pdp;
    127  1.17       leo struct cfdata	*cfp;
    128  1.17       leo void		*auxp;
    129   1.1       leo {
    130   1.8   thorpej 	if(strcmp(auxp, grfbus_cd.cd_name))
    131   1.1       leo 		return(0);
    132   1.1       leo 
    133  1.12       leo 	if(atari_realconfig == 0)
    134  1.12       leo 		cfdata_gbus = cfp;
    135   1.1       leo 	return(1);	/* Always there	*/
    136   1.1       leo }
    137   1.1       leo 
    138   1.1       leo void
    139   1.1       leo grfbusattach(pdp, dp, auxp)
    140   1.1       leo struct device	*pdp, *dp;
    141   1.1       leo void		*auxp;
    142   1.1       leo {
    143  1.12       leo     grf_auxp_t	grf_auxp;
    144  1.12       leo 
    145  1.12       leo     grf_auxp.busprint       = grfbusprint;
    146  1.12       leo     grf_auxp.from_bus_match = 1;
    147   1.1       leo 
    148  1.12       leo     if(dp == NULL) /* Console init	*/
    149  1.12       leo 	atari_config_found(cfdata_gbus, NULL, (void*)&grf_auxp, grfbusprint);
    150  1.12       leo     else {
    151  1.16  christos 	printf("\n");
    152  1.12       leo 	config_found(dp, (void*)&grf_auxp, grfbusprint);
    153  1.12       leo     }
    154   1.1       leo }
    155   1.1       leo 
    156   1.1       leo int
    157   1.1       leo grfbusprint(auxp, name)
    158  1.12       leo void		*auxp;
    159  1.12       leo const char	*name;
    160   1.1       leo {
    161   1.1       leo 	if(name == NULL)
    162   1.1       leo 		return(UNCONF);
    163   1.1       leo 	return(QUIET);
    164   1.1       leo }
    165   1.1       leo 
    166   1.1       leo /*ARGSUSED*/
    167   1.1       leo int
    168   1.1       leo grfopen(dev, flags, devtype, p)
    169   1.1       leo 	dev_t dev;
    170   1.1       leo 	int flags, devtype;
    171   1.1       leo 	struct proc *p;
    172   1.1       leo {
    173   1.1       leo 	struct grf_softc *gp;
    174   1.1       leo 
    175   1.1       leo 	if (GRFUNIT(dev) >= NGRF)
    176   1.1       leo 		return(ENXIO);
    177   1.1       leo 
    178   1.1       leo 	gp = grfsp[GRFUNIT(dev)];
    179  1.19       leo 	if (gp == NULL)
    180  1.19       leo 		return(ENXIO);
    181   1.1       leo 
    182   1.1       leo 	if ((gp->g_flags & GF_ALIVE) == 0)
    183   1.1       leo 		return(ENXIO);
    184   1.1       leo 
    185   1.1       leo 	if ((gp->g_flags & (GF_OPEN|GF_EXCLUDE)) == (GF_OPEN|GF_EXCLUDE))
    186   1.1       leo 		return(EBUSY);
    187   1.6       leo 	grf_viewsync(gp);
    188   1.1       leo 
    189   1.1       leo 	return(0);
    190   1.1       leo }
    191   1.1       leo 
    192   1.1       leo /*ARGSUSED*/
    193   1.1       leo int
    194  1.10       leo grfclose(dev, flags, mode, p)
    195  1.10       leo 	dev_t		dev;
    196  1.10       leo 	int		flags;
    197  1.10       leo 	int		mode;
    198  1.10       leo 	struct proc	*p;
    199   1.1       leo {
    200   1.1       leo 	struct grf_softc *gp;
    201   1.1       leo 
    202   1.1       leo 	gp = grfsp[GRFUNIT(dev)];
    203   1.1       leo 	(void)grfoff(dev);
    204   1.1       leo 	gp->g_flags &= GF_ALIVE;
    205   1.1       leo 	return(0);
    206   1.1       leo }
    207   1.1       leo 
    208   1.1       leo /*ARGSUSED*/
    209   1.1       leo int
    210   1.1       leo grfioctl(dev, cmd, data, flag, p)
    211   1.1       leo dev_t		dev;
    212   1.1       leo u_long		cmd;
    213   1.1       leo int		flag;
    214   1.1       leo caddr_t		data;
    215   1.1       leo struct proc	*p;
    216   1.1       leo {
    217   1.1       leo 	struct grf_softc	*gp;
    218   1.1       leo 	int			error;
    219  1.27   gehenna 	extern const struct cdevsw view_cdevsw;
    220   1.1       leo 
    221   1.1       leo 	gp = grfsp[GRFUNIT(dev)];
    222   1.1       leo 	error = 0;
    223   1.1       leo 
    224   1.1       leo 	switch (cmd) {
    225   1.1       leo 	case OGRFIOCGINFO:
    226   1.1       leo 	        /* argl.. no bank-member.. */
    227   1.1       leo 	  	bcopy((caddr_t)&gp->g_display, data, sizeof(struct grfinfo)-4);
    228   1.1       leo 		break;
    229   1.1       leo 	case GRFIOCGINFO:
    230   1.1       leo 		bcopy((caddr_t)&gp->g_display, data, sizeof(struct grfinfo));
    231   1.1       leo 		break;
    232   1.1       leo 	case GRFIOCON:
    233   1.1       leo 		error = grfon(dev);
    234   1.1       leo 		break;
    235   1.1       leo 	case GRFIOCOFF:
    236   1.1       leo 		error = grfoff(dev);
    237   1.1       leo 		break;
    238   1.1       leo 	case GRFIOCSINFO:
    239   1.1       leo 		error = grfsinfo(dev, (struct grfdyninfo *) data);
    240   1.1       leo 		break;
    241   1.1       leo 	case GRFGETVMODE:
    242   1.7       leo 		return(gp->g_mode(gp, GM_GRFGETVMODE, data, 0, 0));
    243   1.1       leo 	case GRFSETVMODE:
    244   1.7       leo 		error = gp->g_mode(gp, GM_GRFSETVMODE, data, 0, 0);
    245   1.1       leo 		if (error == 0 && gp->g_itedev)
    246   1.1       leo 			ite_reinit(gp->g_itedev);
    247   1.1       leo 		break;
    248   1.1       leo 	case GRFGETNUMVM:
    249   1.7       leo 		return(gp->g_mode(gp, GM_GRFGETNUMVM, data, 0, 0));
    250   1.1       leo 	/*
    251   1.1       leo 	 * these are all hardware dependant, and have to be resolved
    252   1.1       leo 	 * in the respective driver.
    253   1.1       leo 	 */
    254   1.1       leo 	case GRFIOCPUTCMAP:
    255   1.1       leo 	case GRFIOCGETCMAP:
    256   1.1       leo 	case GRFIOCSSPRITEPOS:
    257   1.1       leo 	case GRFIOCGSPRITEPOS:
    258   1.1       leo 	case GRFIOCSSPRITEINF:
    259   1.1       leo 	case GRFIOCGSPRITEINF:
    260   1.1       leo 	case GRFIOCGSPRITEMAX:
    261   1.1       leo 	default:
    262   1.1       leo 		/*
    263   1.1       leo 		 * check to see whether it's a command recognized by the
    264   1.1       leo 		 * view code.
    265   1.1       leo 		 */
    266  1.27   gehenna 		return((*view_cdevsw.d_ioctl)(gp->g_viewdev, cmd, data, flag,
    267  1.27   gehenna 					      p));
    268   1.1       leo 		error = EINVAL;
    269   1.1       leo 		break;
    270   1.1       leo 
    271   1.1       leo 	}
    272   1.1       leo 	return(error);
    273   1.1       leo }
    274   1.1       leo 
    275   1.1       leo /*ARGSUSED*/
    276   1.1       leo int
    277  1.13       leo grfpoll(dev, events, p)
    278  1.10       leo 	dev_t		dev;
    279  1.13       leo 	int		events;
    280  1.10       leo 	struct proc	*p;
    281   1.1       leo {
    282  1.13       leo 	int revents = 0;
    283  1.13       leo 
    284  1.13       leo 	if (events & (POLLOUT | POLLWRNORM))
    285  1.13       leo 		revents |= events & (POLLOUT | POLLWRNORM);
    286  1.13       leo 	return (revents);
    287   1.1       leo }
    288   1.1       leo 
    289   1.1       leo /*
    290   1.1       leo  * map the contents of a graphics display card into process'
    291   1.1       leo  * memory space.
    292   1.1       leo  */
    293  1.23    simonb paddr_t
    294   1.2   mycroft grfmmap(dev, off, prot)
    295  1.23    simonb 	dev_t	dev;
    296  1.23    simonb 	off_t	off;
    297  1.23    simonb 	int	prot;
    298   1.1       leo {
    299   1.5       leo 	struct grf_softc	*gp;
    300   1.5       leo 	struct grfinfo		*gi;
    301  1.22    thomas 	u_int			vgabase, linbase;
    302   1.5       leo 
    303   1.5       leo 	gp = grfsp[GRFUNIT(dev)];
    304   1.5       leo 	gi = &gp->g_display;
    305  1.18       leo 
    306  1.22    thomas 	vgabase = gi->gd_vgabase;
    307  1.22    thomas 	linbase = gi->gd_linbase;
    308  1.22    thomas 
    309  1.18       leo 	/*
    310  1.18       leo 	 * control registers
    311  1.18       leo 	 */
    312  1.18       leo 	if (off >= 0 && off < gi->gd_regsize)
    313  1.23    simonb 		return(((paddr_t)gi->gd_regaddr + off) >> PGSHIFT);
    314   1.5       leo 
    315   1.5       leo 	/*
    316  1.22    thomas 	 * VGA memory
    317  1.22    thomas 	 */
    318  1.22    thomas 	if (off >= vgabase && off < (vgabase + gi->gd_vgasize))
    319  1.23    simonb 		return(((paddr_t)gi->gd_vgaaddr - vgabase + off) >> PGSHIFT);
    320  1.22    thomas 
    321  1.22    thomas 	/*
    322   1.5       leo 	 * frame buffer
    323   1.5       leo 	 */
    324  1.22    thomas 	if (off >= linbase && off < (linbase + gi->gd_fbsize))
    325  1.23    simonb 		return(((paddr_t)gi->gd_fbaddr - linbase + off) >> PGSHIFT);
    326   1.5       leo 	return(-1);
    327   1.1       leo }
    328   1.1       leo 
    329   1.1       leo int
    330   1.1       leo grfon(dev)
    331   1.1       leo 	dev_t dev;
    332   1.1       leo {
    333   1.1       leo 	struct grf_softc *gp;
    334   1.1       leo 
    335   1.1       leo 	gp = grfsp[GRFUNIT(dev)];
    336   1.1       leo 
    337   1.1       leo 	if (gp->g_flags & GF_GRFON)
    338   1.1       leo 		return(0);
    339   1.1       leo 
    340   1.1       leo 	gp->g_flags |= GF_GRFON;
    341   1.1       leo 	if (gp->g_itedev != NODEV)
    342   1.1       leo 		ite_off(gp->g_itedev, 3);
    343   1.1       leo 
    344   1.7       leo 	return(gp->g_mode(gp, (dev & GRFOVDEV) ? GM_GRFOVON : GM_GRFON,
    345   1.7       leo 							NULL, 0, 0));
    346   1.1       leo }
    347   1.1       leo 
    348   1.1       leo int
    349   1.1       leo grfoff(dev)
    350   1.1       leo 	dev_t dev;
    351   1.1       leo {
    352   1.1       leo 	struct grf_softc *gp;
    353   1.1       leo 	int error;
    354   1.1       leo 
    355   1.1       leo 	gp = grfsp[GRFUNIT(dev)];
    356   1.1       leo 
    357   1.1       leo 	if ((gp->g_flags & GF_GRFON) == 0)
    358   1.1       leo 		return(0);
    359   1.1       leo 
    360   1.1       leo 	gp->g_flags &= ~GF_GRFON;
    361   1.7       leo 	error = gp->g_mode(gp, (dev & GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF,
    362   1.7       leo 						NULL, 0, 0);
    363   1.1       leo 
    364   1.1       leo 	/*
    365   1.1       leo 	 * Closely tied together no X's
    366   1.1       leo 	 */
    367   1.1       leo 	if (gp->g_itedev != NODEV)
    368   1.1       leo 		ite_on(gp->g_itedev, 2);
    369   1.1       leo 
    370   1.1       leo 	return(error);
    371   1.1       leo }
    372   1.1       leo 
    373   1.1       leo int
    374   1.1       leo grfsinfo(dev, dyninfo)
    375   1.1       leo 	dev_t dev;
    376   1.1       leo 	struct grfdyninfo *dyninfo;
    377   1.1       leo {
    378   1.1       leo 	struct grf_softc *gp;
    379   1.1       leo 	int error;
    380   1.1       leo 
    381   1.1       leo 	gp = grfsp[GRFUNIT(dev)];
    382   1.7       leo 	error = gp->g_mode(gp, GM_GRFCONFIG, dyninfo, 0, 0);
    383   1.1       leo 
    384   1.1       leo 	/*
    385   1.1       leo 	 * Closely tied together no X's
    386   1.1       leo 	 */
    387   1.1       leo 	if (gp->g_itedev != NODEV)
    388   1.1       leo 		ite_reinit(gp->g_itedev);
    389   1.1       leo 	return(error);
    390   1.1       leo }
    391   1.1       leo 
    392   1.1       leo /*
    393   1.1       leo  * Get the grf-info in sync with underlying view.
    394   1.1       leo  */
    395  1.12       leo void
    396   1.1       leo grf_viewsync(gp)
    397   1.1       leo struct grf_softc *gp;
    398   1.1       leo {
    399   1.1       leo 	struct view_size	vs;
    400   1.1       leo 	bmap_t			bm;
    401   1.1       leo 	struct grfinfo		*gi;
    402  1.27   gehenna 	extern const struct cdevsw view_cdevsw;
    403   1.1       leo 
    404   1.1       leo 	gi = &gp->g_display;
    405   1.1       leo 
    406  1.27   gehenna 	(*view_cdevsw.d_ioctl)(gp->g_viewdev, VIOCGBMAP, (caddr_t)&bm,
    407  1.27   gehenna 			       0, NOPROC);
    408   1.1       leo 
    409   1.1       leo 	gp->g_data = (caddr_t) 0xDeadBeaf; /* not particularly clean.. */
    410   1.1       leo 
    411   1.1       leo 	gi->gd_fbaddr  = bm.hw_address;
    412  1.20       leo 	gi->gd_fbsize  = bm.phys_mappable;
    413  1.22    thomas 	gi->gd_linbase = bm.lin_base;
    414  1.12       leo 	gi->gd_regaddr = bm.hw_regs;
    415  1.12       leo 	gi->gd_regsize = bm.reg_size;
    416  1.22    thomas 	gi->gd_vgaaddr = bm.vga_address;
    417  1.22    thomas 	gi->gd_vgasize = bm.vga_mappable;
    418  1.22    thomas 	gi->gd_vgabase = bm.vga_base;
    419   1.1       leo 
    420  1.27   gehenna 	if((*view_cdevsw.d_ioctl)(gp->g_viewdev, VIOCGSIZE, (caddr_t)&vs, 0,
    421  1.27   gehenna 				  NOPROC)) {
    422   1.1       leo 		/*
    423   1.1       leo 		 * fill in some default values...
    424   1.1       leo 		 * XXX: Should _never_ happen
    425   1.1       leo 		 */
    426   1.1       leo 		vs.width  = 640;
    427   1.1       leo 		vs.height = 400;
    428   1.3       leo 		vs.depth  = 1;
    429   1.1       leo 	}
    430   1.1       leo 	gi->gd_colors = 1 << vs.depth;
    431   1.1       leo 	gi->gd_planes = vs.depth;
    432   1.1       leo 
    433   1.1       leo 	gi->gd_fbwidth         = vs.width;
    434   1.1       leo 	gi->gd_fbheight        = vs.height;
    435   1.1       leo 	gi->gd_dyn.gdi_fbx     = 0;
    436   1.1       leo 	gi->gd_dyn.gdi_fby     = 0;
    437   1.1       leo 	gi->gd_dyn.gdi_dwidth  = vs.width;
    438   1.1       leo 	gi->gd_dyn.gdi_dheight = vs.height;
    439   1.1       leo 	gi->gd_dyn.gdi_dx      = 0;
    440   1.1       leo 	gi->gd_dyn.gdi_dy      = 0;
    441   1.1       leo }
    442   1.1       leo 
    443   1.1       leo /*
    444   1.1       leo  * Change the mode of the display.
    445   1.1       leo  * Right now all we can do is grfon/grfoff.
    446   1.1       leo  * Return a UNIX error number or 0 for success.
    447   1.1       leo  */
    448   1.1       leo /*ARGSUSED*/
    449  1.12       leo int
    450   1.1       leo grf_mode(gp, cmd, arg, a2, a3)
    451   1.1       leo struct grf_softc	*gp;
    452   1.1       leo int			cmd, a2, a3;
    453   1.1       leo void			*arg;
    454   1.1       leo {
    455  1.27   gehenna 	extern const struct cdevsw view_cdevsw;
    456  1.27   gehenna 
    457   1.1       leo 	switch (cmd) {
    458   1.1       leo 		case GM_GRFON:
    459   1.1       leo 			/*
    460   1.1       leo 			 * Get in sync with view, ite might have changed it.
    461   1.1       leo 			 */
    462   1.1       leo 			grf_viewsync(gp);
    463  1.27   gehenna 			(*view_cdevsw.d_ioctl)(gp->g_viewdev, VIOCDISPLAY,
    464  1.27   gehenna 					       NULL, 0, NOPROC);
    465   1.1       leo 			return(0);
    466   1.1       leo 	case GM_GRFOFF:
    467  1.27   gehenna 			(*view_cdevsw.d_ioctl)(gp->g_viewdev, VIOCREMOVE,
    468  1.27   gehenna 					       NULL, 0, NOPROC);
    469   1.1       leo 			return(0);
    470   1.1       leo 	case GM_GRFCONFIG:
    471   1.1       leo 	default:
    472   1.1       leo 			break;
    473   1.1       leo 	}
    474  1.26    atatat 	return(EPASSTHROUGH);
    475   1.1       leo }
    476   1.1       leo #endif	/* NGRF > 0 */
    477