1 /* $NetBSD: tga_conf.c,v 1.6 2001/12/12 07:50:05 elric Exp $ */
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
7 * Author: Chris G. Demetriou
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: tga_conf.c,v 1.6 2001/12/12 07:50:05 elric Exp $");
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/device.h>
37 #include <dev/pci/pcivar.h>
38 #include <dev/pci/tgareg.h>
39 #include <dev/pci/tgavar.h>
41 #include <dev/ic/bt485var.h>
42 #include <dev/ic/bt463var.h>
43 #include <dev/ic/ibm561var.h>
48 #define MB * 1024 * 1024
50 static const struct tga_conf tga_configs
[TGA_TYPE_UNKNOWN
] = {
58 1, { 2 MB
, 0 }, { 1 MB
, 0 },
59 0, { 0, 0 }, { 0, 0 },
68 1, { 2 MB
, 0 }, { 2 MB
, 0 },
69 0, { 0, 0 }, { 0, 0 },
78 1, { 4 MB
, 0 }, { 2 MB
, 0 },
79 1, { 6 MB
, 0 }, { 2 MB
, 0 },
88 2, { 8 MB
, 12 MB
}, { 2 MB
, 2 MB
},
89 2, { 10 MB
, 14 MB
}, { 2 MB
, 2 MB
},
98 1, { 8 MB
, 0 }, { 4 MB
, 0 },
99 0, { 0, 0 }, { 0, 0 },
101 /* TGA_TYPE_T32_08 */
108 1, { 8 MB
, 0 }, { 8 MB
, 0 },
109 0, { 0, 0 }, { 0, 0 },
111 /* TGA_TYPE_T32_88 */
118 1, { 16 MB
, 0 }, { 8 MB
, 0 },
119 1, { 24 MB
, 0 }, { 8 MB
, 0 },
121 /* TGA_TYPE_POWERSTORM_4D20 */
122 /* XXX: These numbers may be incorrect */
129 1, { 16 MB
, 0 }, { 8 MB
, 0 },
130 1, { 24 MB
, 0 }, { 8 MB
, 0 },
138 tga_identify(struct tga_devconfig
*dc
)
143 int deep
, addrmask
, wide
;
146 gder
= TGARREG(dc
, TGA_REG_GDER
);
147 grev
= TGARREG(dc
, TGA_REG_GREV
);
149 deep
= (gder
& 0x1) != 0; /* XXX */
150 addrmask
= (gder
>> 2) & 0x7; /* XXX */
151 wide
= (gder
& 0x200) == 0; /* XXX */
152 tga2
= (grev
& 0x20) != 0;
154 type
= TGA_TYPE_UNKNOWN
;
157 /* 8bpp frame buffer */
159 if (addrmask
== 0x0) {
160 /* 4MB core map; T8-01 or T8-02 */
163 type
= TGA_TYPE_T8_01
;
165 type
= TGA_TYPE_T8_02
;
166 } else if (addrmask
== 0x1) {
167 /* 8MB core map; T8-22 */
169 if (wide
) /* sanity */
170 type
= TGA_TYPE_T8_22
;
171 } else if (addrmask
== 0x3) {
172 /* 16MB core map; T8-44 */
174 if (wide
) /* sanity */
175 type
= TGA_TYPE_T8_44
;
178 /* 32bpp frame buffer */
179 if (addrmask
== 0x00 && tga2
&& wide
) {
180 /* My PowerStorm 4d20 shows up this way? */
181 type
= TGA_TYPE_POWERSTORM_4D20
;
184 if (addrmask
== 0x3) {
185 /* 16MB core map; T32-04 or T32-08 */
188 type
= TGA_TYPE_T32_04
;
190 type
= TGA_TYPE_T32_08
;
191 } else if (addrmask
== 0x7) {
192 /* 32MB core map; T32-88 */
194 if (wide
&& !tga2
) /* sanity */
195 type
= TGA_TYPE_T32_88
;
202 const struct tga_conf
*
203 tga_getconf(int type
)
206 if (type
>= 0 && type
< TGA_TYPE_UNKNOWN
)
207 return &tga_configs
[type
];