grf_gv.c revision 1.5 1 /* $NetBSD: grf_gv.c,v 1.5 1998/08/06 14:08:54 minoura Exp $ */
2
3 /*
4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * from: Utah $Hdr: grf_tc.c 1.20 93/08/13$
41 *
42 * @(#)grf_tc.c 8.4 (Berkeley) 1/12/94
43 */
44
45 /*
46 * Graphics routines for the X68K native custom chip set.
47 */
48
49 #include "opt_compat_hpux.h"
50
51 #include <sys/param.h>
52 #include <sys/device.h>
53 #include <sys/errno.h>
54
55 #include <machine/grfioctl.h>
56
57 #include <x68k/dev/grfvar.h>
58 #include <x68k/x68k/iodevice.h>
59
60 #include <machine/cpu.h>
61
62 int gv_init __P((struct grf_softc *, caddr_t));
63 int gv_mode __P((struct grf_softc *, u_long, caddr_t));
64
65 /* Initialize hardware.
66 * Must fill in the grfinfo structure in g_softc.
67 * Returns 0 if hardware not present, non-zero ow.
68 */
69 int
70 gv_init(gp, addr)
71 struct grf_softc *gp;
72 caddr_t addr;
73 {
74 struct grfinfo *gi = &gp->g_display;
75
76 gi->gd_fbwidth = 1024;
77 gi->gd_fbheight = 1024;
78 gi->gd_planes = 4;
79 gi->gd_regaddr = (void *)0x00e80000;
80 gi->gd_regsize = 0x00010000; /* contains system port */
81 gi->gd_fbaddr = (void *)0x00c00000;
82 gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight * 2;
83 gp->g_regkva = addr;
84 gp->g_fbkva = addr;
85 switch(IODEVbase->io_sram[0x1d]) {
86 case 18:
87 /*
88 * mode 18, 24kHz
89 */
90 gi->gd_dwidth = 1024;
91 gi->gd_dheight = 848;
92 break;
93 case 19:
94 /*
95 * mode 19, 31kHz VGA mode
96 */
97 gi->gd_dwidth = 640;
98 gi->gd_dheight = 480;
99 break;
100 default:
101 /*
102 * mode 16, 31kHz (default)
103 */
104 gi->gd_dwidth = 768;
105 gi->gd_dheight = 512;
106 break;
107 }
108 gi->gd_colors = 16;
109
110 return(1);
111 }
112
113 /*
114 * Change the mode of the display.
115 * Right now all we can do is grfon/grfoff.
116 * Return a UNIX error number or 0 for success.
117 */
118 /*ARGSUSED*/
119 int
120 gv_mode(gp, cmd, data)
121 register struct grf_softc *gp;
122 u_long cmd;
123 caddr_t data;
124 {
125 int error = 0;
126
127 switch (cmd) {
128 case GM_GRFON:
129 case GM_GRFOFF:
130 break;
131
132 /*
133 * Remember UVA of mapping for GCDESCRIBE.
134 * XXX this should be per-process.
135 */
136 case GM_MAP:
137 gp->g_data = data;
138 break;
139
140 case GM_UNMAP:
141 gp->g_data = 0;
142 break;
143
144 #ifdef COMPAT_HPUX
145 case GM_DESCRIBE:
146 {
147 struct grf_fbinfo *fi = (struct grf_fbinfo *)data;
148 struct grfinfo *gi = &gp->g_display;
149 int i;
150
151 /* feed it what HP-UX expects */
152 fi->id = gi->gd_id;
153 fi->mapsize = gi->gd_fbsize;
154 fi->dwidth = gi->gd_dwidth;
155 fi->dlength = gi->gd_dheight;
156 fi->width = gi->gd_fbwidth;
157 fi->length = gi->gd_fbheight;
158 fi->bpp = NBBY;
159 fi->xlen = (fi->width * fi->bpp) / NBBY;
160 fi->npl = gi->gd_planes;
161 fi->bppu = fi->npl;
162 fi->nplbytes = fi->xlen * ((fi->length * fi->bpp) / NBBY);
163 /* XXX */
164 switch (gp->g_sw->gd_hwid) {
165 case GID_HRCCATSEYE:
166 bcopy("HP98550", fi->name, 8);
167 break;
168 case GID_LRCATSEYE:
169 bcopy("HP98549", fi->name, 8);
170 break;
171 case GID_HRMCATSEYE:
172 bcopy("HP98548", fi->name, 8);
173 break;
174 case GID_TOPCAT:
175 switch (gi->gd_colors) {
176 case 64:
177 bcopy("HP98547", fi->name, 8);
178 break;
179 case 16:
180 bcopy("HP98545", fi->name, 8);
181 break;
182 case 2:
183 bcopy("HP98544", fi->name, 8);
184 break;
185 }
186 break;
187 }
188 fi->attr = 2; /* HW block mover */
189 /*
190 * If mapped, return the UVA where mapped.
191 */
192 if (gp->g_data) {
193 fi->regbase = gp->g_data;
194 fi->fbbase = fi->regbase + gp->g_display.gd_regsize;
195 } else {
196 fi->fbbase = 0;
197 fi->regbase = 0;
198 }
199 for (i = 0; i < 6; i++)
200 fi->regions[i] = 0;
201 break;
202 }
203 #endif
204 #if 1
205 case GM_GRFSETVMODE:
206 if (*(int *)data == 1) {
207 struct grfinfo *gi = &gp->g_display;
208 volatile struct crtc *crtc = &IODEVbase->io_crtc;
209 /* CRTC $B$K@_Dj$r9T$J$$!"(Bdwidth $B$H(B dheight $B$r$$$8$k(B */
210 crtc->r20 = (crtc->r20 & 0xFF00) | 0x1a;
211 crtc->r08 = 0x1b;
212 crtc->r07 = 0x19c;
213 crtc->r06 = 0x1c;
214 crtc->r05 = 0x02;
215 crtc->r04 = 0x019f;
216 crtc->r03 = 0x9a;
217 crtc->r02 = 0x1a;
218 crtc->r01 = 0x09;
219 crtc->r00 = 0xa4;
220 gi->gd_dwidth = 1024;
221 gi->gd_dheight = 768;
222 }
223 break;
224 #endif
225
226 default:
227 error = EINVAL;
228 break;
229 }
230 return(error);
231 }
232