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