Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / tga_conf.c
blobb6739f4810bdbb8556f6fb9eb2cc6dba0a605067
1 /* $NetBSD: tga_conf.c,v 1.6 2001/12/12 07:50:05 elric Exp $ */
3 /*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
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>
45 #undef KB
46 #define KB * 1024
47 #undef MB
48 #define MB * 1024 * 1024
50 static const struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = {
51 /* TGA_TYPE_T8_01 */
53 "T8-01",
54 bt485_funcs,
56 4 MB,
57 2 KB,
58 1, { 2 MB, 0 }, { 1 MB, 0 },
59 0, { 0, 0 }, { 0, 0 },
61 /* TGA_TYPE_T8_02 */
63 "T8-02",
64 bt485_funcs,
66 4 MB,
67 4 KB,
68 1, { 2 MB, 0 }, { 2 MB, 0 },
69 0, { 0, 0 }, { 0, 0 },
71 /* TGA_TYPE_T8_22 */
73 "T8-22",
74 bt485_funcs,
76 8 MB,
77 4 KB,
78 1, { 4 MB, 0 }, { 2 MB, 0 },
79 1, { 6 MB, 0 }, { 2 MB, 0 },
81 /* TGA_TYPE_T8_44 */
83 "T8-44",
84 bt485_funcs,
86 16 MB,
87 4 KB,
88 2, { 8 MB, 12 MB }, { 2 MB, 2 MB },
89 2, { 10 MB, 14 MB }, { 2 MB, 2 MB },
91 /* TGA_TYPE_T32_04 */
93 "T32-04",
94 bt463_funcs,
95 32,
96 16 MB,
97 8 KB,
98 1, { 8 MB, 0 }, { 4 MB, 0 },
99 0, { 0, 0 }, { 0, 0 },
101 /* TGA_TYPE_T32_08 */
103 "T32-08",
104 bt463_funcs,
106 16 MB,
107 16 KB,
108 1, { 8 MB, 0 }, { 8 MB, 0 },
109 0, { 0, 0 }, { 0, 0 },
111 /* TGA_TYPE_T32_88 */
113 "T32-88",
114 bt463_funcs,
116 32 MB,
117 16 KB,
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 */
124 "PS4d20",
125 ibm561_funcs,
127 32 MB,
128 16 KB,
129 1, { 16 MB, 0 }, { 8 MB, 0 },
130 1, { 24 MB, 0 }, { 8 MB, 0 },
134 #undef KB
135 #undef MB
138 tga_identify(struct tga_devconfig *dc)
140 int type;
141 int gder;
142 int grev;
143 int deep, addrmask, wide;
144 int tga2;
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;
156 if (!deep) {
157 /* 8bpp frame buffer */
159 if (addrmask == 0x0) {
160 /* 4MB core map; T8-01 or T8-02 */
162 if (!wide)
163 type = TGA_TYPE_T8_01;
164 else
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;
177 } else {
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 */
187 if (!wide)
188 type = TGA_TYPE_T32_04;
189 else
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;
199 return (type);
202 const struct tga_conf *
203 tga_getconf(int type)
206 if (type >= 0 && type < TGA_TYPE_UNKNOWN)
207 return &tga_configs[type];
209 return (NULL);