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