Home | History | Annotate | Line # | Download | only in obio
grf_obio.c revision 1.9
      1  1.9  briggs /*	$NetBSD: grf_obio.c,v 1.9 1995/08/04 02:55:06 briggs 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.1  briggs 
     45  1.1  briggs #include <machine/grfioctl.h>
     46  1.1  briggs #include <machine/cpu.h>
     47  1.1  briggs 
     48  1.1  briggs #include "nubus.h"
     49  1.1  briggs #include "grfvar.h"
     50  1.1  briggs 
     51  1.1  briggs extern int	grfiv_probe __P((struct grf_softc *sc, nubus_slot *ignore));
     52  1.1  briggs extern int	grfiv_init __P((struct grf_softc *sc));
     53  1.1  briggs extern int	grfiv_mode __P((struct grf_softc *sc, int cmd, void *arg));
     54  1.1  briggs 
     55  1.5  briggs extern u_int32_t	mac68k_vidlog;
     56  1.5  briggs extern u_int32_t	mac68k_vidphys;
     57  1.5  briggs 
     58  1.1  briggs extern int
     59  1.2  briggs grfiv_probe(sc, slotinfo)
     60  1.1  briggs 	struct grf_softc *sc;
     61  1.2  briggs 	nubus_slot *slotinfo;
     62  1.1  briggs {
     63  1.9  briggs 	static int	internal_video_found = 0;
     64  1.1  briggs 
     65  1.9  briggs 	if (internal_video_found || (mac68k_vidlog == 0)) {
     66  1.1  briggs 		return 0;
     67  1.2  briggs 	}
     68  1.7  briggs 
     69  1.8  briggs 	if (   (NUBUS_SLOT_TO_BASE(slotinfo->slot) <= mac68k_vidlog)
     70  1.9  briggs 	    && (mac68k_vidlog < NUBUS_SLOT_TO_BASE(slotinfo->slot + 1))) {
     71  1.9  briggs 		internal_video_found++;
     72  1.7  briggs 		return 1;
     73  1.9  briggs 	}
     74  1.7  briggs 
     75  1.9  briggs 	if (slotinfo->slot == NUBUS_INT_VIDEO_PSUEDO_SLOT) {
     76  1.9  briggs 		internal_video_found++;
     77  1.7  briggs 		return 1;
     78  1.9  briggs 	}
     79  1.7  briggs 
     80  1.7  briggs 	return 0;
     81  1.1  briggs }
     82  1.1  briggs 
     83  1.1  briggs extern int
     84  1.1  briggs grfiv_init(sc)
     85  1.1  briggs 	struct	grf_softc *sc;
     86  1.1  briggs {
     87  1.1  briggs 	struct grfmode *gm;
     88  1.1  briggs 	int i, j;
     89  1.1  briggs 
     90  1.1  briggs 	sc->card_id = 0;
     91  1.1  briggs 
     92  1.1  briggs 	strcpy(sc->card_name, "Internal video");
     93  1.1  briggs 
     94  1.1  briggs 	gm = &(sc->curr_mode);
     95  1.1  briggs 	gm->mode_id = 0;
     96  1.1  briggs 	gm->psize = 1;
     97  1.1  briggs 	gm->ptype = 0;
     98  1.1  briggs 	gm->width = 640;	/* XXX */
     99  1.1  briggs 	gm->height = 480;	/* XXX */
    100  1.1  briggs 	gm->rowbytes = 80;	/* XXX Hack */
    101  1.1  briggs 	gm->hres = 80;		/* XXX Hack */
    102  1.1  briggs 	gm->vres = 80;		/* XXX Hack */
    103  1.1  briggs 	gm->fbsize = gm->width * gm->height;
    104  1.5  briggs 	gm->fbbase = (caddr_t) mac68k_vidlog;
    105  1.3  briggs 	gm->fboff = 0;
    106  1.1  briggs 
    107  1.1  briggs 	return 1;
    108  1.1  briggs }
    109  1.1  briggs 
    110  1.1  briggs extern int
    111  1.1  briggs grfiv_mode(sc, cmd, arg)
    112  1.1  briggs 	struct grf_softc *sc;
    113  1.1  briggs 	int cmd;
    114  1.1  briggs 	void *arg;
    115  1.1  briggs {
    116  1.4  briggs 	switch (cmd) {
    117  1.4  briggs 	case GM_GRFON:
    118  1.4  briggs 	case GM_GRFOFF:
    119  1.4  briggs 		return 0;
    120  1.4  briggs 	case GM_CURRMODE:
    121  1.4  briggs 		break;
    122  1.4  briggs 	case GM_NEWMODE:
    123  1.4  briggs 		break;
    124  1.4  briggs 	case GM_LISTMODES:
    125  1.4  briggs 		break;
    126  1.4  briggs 	}
    127  1.4  briggs 	return EINVAL;
    128  1.5  briggs }
    129  1.5  briggs 
    130  1.5  briggs extern caddr_t
    131  1.5  briggs grfiv_phys(gp, addr)
    132  1.5  briggs 	struct grf_softc *gp;
    133  1.5  briggs 	vm_offset_t addr;
    134  1.5  briggs {
    135  1.5  briggs 	/*
    136  1.5  briggs 	 * If we're using IIsi or similar, this will be 0.
    137  1.5  briggs 	 * If we're using IIvx or similar, this will be correct.
    138  1.5  briggs 	 */
    139  1.5  briggs 	return (caddr_t) mac68k_vidphys;
    140  1.1  briggs }
    141