Home | History | Annotate | Line # | Download | only in obio
grf_obio.c revision 1.16
      1  1.15  christos /*	$NetBSD: grf_obio.c,v 1.16 1996/12/16 16:17:06 scottr Exp $	*/
      2   1.1    briggs 
      3   1.1    briggs /*
      4   1.1    briggs  * Copyright (c) 1995 Allen Briggs.  All rights reserved.
      5   1.1    briggs  *
      6   1.1    briggs  * Redistribution and use in source and binary forms, with or without
      7   1.1    briggs  * modification, are permitted provided that the following conditions
      8   1.1    briggs  * are met:
      9   1.1    briggs  * 1. Redistributions of source code must retain the above copyright
     10   1.1    briggs  *    notice, this list of conditions and the following disclaimer.
     11   1.1    briggs  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.1    briggs  *    notice, this list of conditions and the following disclaimer in the
     13   1.1    briggs  *    documentation and/or other materials provided with the distribution.
     14   1.1    briggs  * 3. All advertising materials mentioning features or use of this software
     15   1.1    briggs  *    must display the following acknowledgement:
     16   1.1    briggs  *	This product includes software developed by Allen Briggs.
     17   1.1    briggs  * 4. The name of the author may not be used to endorse or promote products
     18   1.1    briggs  *    derived from this software without specific prior written permission.
     19   1.1    briggs  *
     20   1.1    briggs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21   1.1    briggs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22   1.1    briggs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23   1.1    briggs  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24   1.1    briggs  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25   1.1    briggs  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26   1.1    briggs  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27   1.1    briggs  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28   1.1    briggs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29   1.1    briggs  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30   1.1    briggs  */
     31   1.1    briggs /*
     32   1.1    briggs  * Graphics display driver for the Macintosh internal video for machines
     33   1.1    briggs  * that don't map it into a fake nubus card.
     34   1.1    briggs  */
     35   1.1    briggs 
     36   1.1    briggs #include <sys/param.h>
     37   1.1    briggs 
     38   1.1    briggs #include <sys/device.h>
     39   1.1    briggs #include <sys/ioctl.h>
     40   1.1    briggs #include <sys/file.h>
     41   1.1    briggs #include <sys/malloc.h>
     42   1.1    briggs #include <sys/mman.h>
     43   1.1    briggs #include <sys/proc.h>
     44  1.11    briggs #include <sys/systm.h>
     45   1.1    briggs 
     46   1.1    briggs #include <machine/grfioctl.h>
     47   1.1    briggs #include <machine/cpu.h>
     48   1.1    briggs 
     49   1.1    briggs #include "nubus.h"
     50   1.1    briggs #include "grfvar.h"
     51   1.1    briggs 
     52   1.5    briggs extern u_int32_t	mac68k_vidlog;
     53   1.5    briggs extern u_int32_t	mac68k_vidphys;
     54  1.10    briggs extern long		videorowbytes;
     55  1.10    briggs extern long		videobitdepth;
     56  1.10    briggs extern unsigned long	videosize;
     57   1.5    briggs 
     58  1.11    briggs static int	grfiv_mode __P((struct grf_softc *gp, int cmd, void *arg));
     59  1.11    briggs static caddr_t	grfiv_phys __P((struct grf_softc *gp, vm_offset_t addr));
     60  1.16    scottr static int	grfiv_match __P((struct device *, struct cfdata *, void *));
     61  1.11    briggs static void	grfiv_attach __P((struct device *, struct device *, void *));
     62  1.11    briggs 
     63  1.12    scottr struct cfdriver intvid_cd = {
     64  1.12    scottr 	NULL, "intvid", DV_DULL
     65  1.12    scottr };
     66  1.12    scottr 
     67  1.12    scottr struct cfattach intvid_ca = {
     68  1.12    scottr 	sizeof(struct grfbus_softc), grfiv_match, grfiv_attach
     69  1.11    briggs };
     70  1.11    briggs 
     71  1.11    briggs static int
     72  1.16    scottr grfiv_match(parent, cf, aux)
     73  1.16    scottr 	struct device *parent;
     74  1.16    scottr 	struct cfdata *cf;
     75  1.16    scottr 	void *aux;
     76   1.1    briggs {
     77   1.9    briggs 	static int	internal_video_found = 0;
     78   1.1    briggs 
     79   1.9    briggs 	if (internal_video_found || (mac68k_vidlog == 0)) {
     80   1.1    briggs 		return 0;
     81   1.2    briggs 	}
     82   1.7    briggs 
     83  1.11    briggs 	return 1;
     84   1.1    briggs }
     85   1.1    briggs 
     86  1.11    briggs static void
     87  1.11    briggs grfiv_attach(parent, self, aux)
     88  1.11    briggs 	struct device *parent, *self;
     89  1.11    briggs 	void   *aux;
     90   1.1    briggs {
     91  1.12    scottr 	struct grfbus_softc	*sc;
     92  1.11    briggs 	struct grfmode		*gm;
     93  1.11    briggs 
     94  1.12    scottr 	sc = (struct grfbus_softc *) self;
     95   1.1    briggs 
     96   1.1    briggs 	sc->card_id = 0;
     97   1.1    briggs 
     98  1.15  christos 	printf(": Internal Video\n");
     99   1.1    briggs 
    100   1.1    briggs 	gm = &(sc->curr_mode);
    101   1.1    briggs 	gm->mode_id = 0;
    102  1.10    briggs 	gm->psize = videobitdepth;
    103   1.1    briggs 	gm->ptype = 0;
    104  1.10    briggs 	gm->width = videosize & 0xffff;
    105  1.10    briggs 	gm->height = (videosize >> 16) & 0xffff;
    106  1.10    briggs 	gm->rowbytes = videorowbytes;
    107   1.1    briggs 	gm->hres = 80;		/* XXX Hack */
    108   1.1    briggs 	gm->vres = 80;		/* XXX Hack */
    109  1.10    briggs 	gm->fbsize = gm->rowbytes * gm->height;
    110   1.5    briggs 	gm->fbbase = (caddr_t) mac68k_vidlog;
    111   1.3    briggs 	gm->fboff = 0;
    112   1.1    briggs 
    113  1.12    scottr 	/* Perform common video attachment. */
    114  1.13    scottr 	grf_establish(sc, NULL, grfiv_mode, grfiv_phys);
    115   1.1    briggs }
    116   1.1    briggs 
    117  1.11    briggs static int
    118   1.1    briggs grfiv_mode(sc, cmd, arg)
    119   1.1    briggs 	struct grf_softc *sc;
    120   1.1    briggs 	int cmd;
    121   1.1    briggs 	void *arg;
    122   1.1    briggs {
    123   1.4    briggs 	switch (cmd) {
    124   1.4    briggs 	case GM_GRFON:
    125   1.4    briggs 	case GM_GRFOFF:
    126   1.4    briggs 		return 0;
    127   1.4    briggs 	case GM_CURRMODE:
    128   1.4    briggs 		break;
    129   1.4    briggs 	case GM_NEWMODE:
    130   1.4    briggs 		break;
    131   1.4    briggs 	case GM_LISTMODES:
    132   1.4    briggs 		break;
    133   1.4    briggs 	}
    134   1.4    briggs 	return EINVAL;
    135   1.5    briggs }
    136   1.5    briggs 
    137  1.11    briggs static caddr_t
    138   1.5    briggs grfiv_phys(gp, addr)
    139   1.5    briggs 	struct grf_softc *gp;
    140   1.5    briggs 	vm_offset_t addr;
    141   1.5    briggs {
    142   1.5    briggs 	/*
    143   1.5    briggs 	 * If we're using IIsi or similar, this will be 0.
    144   1.5    briggs 	 * If we're using IIvx or similar, this will be correct.
    145   1.5    briggs 	 */
    146   1.5    briggs 	return (caddr_t) mac68k_vidphys;
    147   1.1    briggs }
    148