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