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