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