grf_obio.c revision 1.16 1 /* $NetBSD: grf_obio.c,v 1.16 1996/12/16 16:17:06 scottr 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 *, struct cfdata *, void *));
61 static void grfiv_attach __P((struct device *, struct device *, void *));
62
63 struct cfdriver intvid_cd = {
64 NULL, "intvid", DV_DULL
65 };
66
67 struct cfattach intvid_ca = {
68 sizeof(struct grfbus_softc), grfiv_match, grfiv_attach
69 };
70
71 static int
72 grfiv_match(parent, cf, aux)
73 struct device *parent;
74 struct cfdata *cf;
75 void *aux;
76 {
77 static int internal_video_found = 0;
78
79 if (internal_video_found || (mac68k_vidlog == 0)) {
80 return 0;
81 }
82
83 return 1;
84 }
85
86 static void
87 grfiv_attach(parent, self, aux)
88 struct device *parent, *self;
89 void *aux;
90 {
91 struct grfbus_softc *sc;
92 struct grfmode *gm;
93
94 sc = (struct grfbus_softc *) self;
95
96 sc->card_id = 0;
97
98 printf(": Internal Video\n");
99
100 gm = &(sc->curr_mode);
101 gm->mode_id = 0;
102 gm->psize = videobitdepth;
103 gm->ptype = 0;
104 gm->width = videosize & 0xffff;
105 gm->height = (videosize >> 16) & 0xffff;
106 gm->rowbytes = videorowbytes;
107 gm->hres = 80; /* XXX Hack */
108 gm->vres = 80; /* XXX Hack */
109 gm->fbsize = gm->rowbytes * gm->height;
110 gm->fbbase = (caddr_t) mac68k_vidlog;
111 gm->fboff = 0;
112
113 /* Perform common video attachment. */
114 grf_establish(sc, NULL, grfiv_mode, grfiv_phys);
115 }
116
117 static int
118 grfiv_mode(sc, cmd, arg)
119 struct grf_softc *sc;
120 int cmd;
121 void *arg;
122 {
123 switch (cmd) {
124 case GM_GRFON:
125 case GM_GRFOFF:
126 return 0;
127 case GM_CURRMODE:
128 break;
129 case GM_NEWMODE:
130 break;
131 case GM_LISTMODES:
132 break;
133 }
134 return EINVAL;
135 }
136
137 static caddr_t
138 grfiv_phys(gp, addr)
139 struct grf_softc *gp;
140 vm_offset_t addr;
141 {
142 /*
143 * If we're using IIsi or similar, this will be 0.
144 * If we're using IIvx or similar, this will be correct.
145 */
146 return (caddr_t) mac68k_vidphys;
147 }
148