tga_conf.c revision 1.4 1 /* $NetBSD: tga_conf.c,v 1.4 2000/04/02 18:59:32 nathanw Exp $ */
2
3 /*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
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.
14 *
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.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30 #include <sys/param.h>
31 #include <sys/device.h>
32
33 #include <dev/pci/pcivar.h>
34 #include <dev/pci/tgareg.h>
35 #include <dev/pci/tgavar.h>
36
37 #include <dev/ic/bt485var.h>
38 #include <dev/ic/bt463var.h>
39
40 #undef KB
41 #define KB * 1024
42 #undef MB
43 #define MB * 1024 * 1024
44
45 static const struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = {
46 /* TGA_TYPE_T8_01 */
47 {
48 "T8-01",
49 bt485_funcs,
50 8,
51 4 MB,
52 2 KB,
53 1, { 2 MB, 0 }, { 1 MB, 0 },
54 0, { 0, 0 }, { 0, 0 },
55 },
56 /* TGA_TYPE_T8_02 */
57 {
58 "T8-02",
59 bt485_funcs,
60 8,
61 4 MB,
62 4 KB,
63 1, { 2 MB, 0 }, { 2 MB, 0 },
64 0, { 0, 0 }, { 0, 0 },
65 },
66 /* TGA_TYPE_T8_22 */
67 {
68 "T8-22",
69 bt485_funcs,
70 8,
71 8 MB,
72 4 KB,
73 1, { 4 MB, 0 }, { 2 MB, 0 },
74 1, { 6 MB, 0 }, { 2 MB, 0 },
75 },
76 /* TGA_TYPE_T8_44 */
77 {
78 "T8-44",
79 bt485_funcs,
80 8,
81 16 MB,
82 4 KB,
83 2, { 8 MB, 12 MB }, { 2 MB, 2 MB },
84 2, { 10 MB, 14 MB }, { 2 MB, 2 MB },
85 },
86 /* TGA_TYPE_T32_04 */
87 {
88 "T32-04",
89 bt463_funcs,
90 32,
91 16 MB,
92 8 KB,
93 1, { 8 MB, 0 }, { 4 MB, 0 },
94 0, { 0, 0 }, { 0, 0 },
95 },
96 /* TGA_TYPE_T32_08 */
97 {
98 "T32-08",
99 bt463_funcs,
100 32,
101 16 MB,
102 16 KB,
103 1, { 8 MB, 0 }, { 8 MB, 0 },
104 0, { 0, 0 }, { 0, 0 },
105 },
106 /* TGA_TYPE_T32_88 */
107 {
108 "T32-88",
109 bt463_funcs,
110 32,
111 32 MB,
112 16 KB,
113 1, { 16 MB, 0 }, { 8 MB, 0 },
114 1, { 24 MB, 0 }, { 8 MB, 0 },
115 },
116 };
117
118 #undef KB
119 #undef MB
120
121 int
122 tga_identify(dc)
123 struct tga_devconfig *dc;
124 {
125 int type;
126 int gder;
127 int deep, addrmask, wide;
128
129 gder = TGARREG(dc, TGA_REG_GDER);
130
131 deep = (gder & 0x1) != 0; /* XXX */
132 addrmask = (gder >> 2) & 0x7; /* XXX */
133 wide = (gder & 0x200) == 0; /* XXX */
134
135
136 type = TGA_TYPE_UNKNOWN;
137
138 if (!deep) {
139 /* 8bpp frame buffer */
140
141 if (addrmask == 0x0) {
142 /* 4MB core map; T8-01 or T8-02 */
143
144 if (!wide)
145 type = TGA_TYPE_T8_01;
146 else
147 type = TGA_TYPE_T8_02;
148 } else if (addrmask == 0x1) {
149 /* 8MB core map; T8-22 */
150
151 if (wide) /* sanity */
152 type = TGA_TYPE_T8_22;
153 } else if (addrmask == 0x3) {
154 /* 16MB core map; T8-44 */
155
156 if (wide) /* sanity */
157 type = TGA_TYPE_T8_44;
158 }
159 } else {
160 /* 32bpp frame buffer */
161
162 if (addrmask == 0x3) {
163 /* 16MB core map; T32-04 or T32-08 */
164
165 if (!wide)
166 type = TGA_TYPE_T32_04;
167 else
168 type = TGA_TYPE_T32_08;
169 } else if (addrmask == 0x7) {
170 /* 32MB core map; T32-88 */
171
172 if (wide) /* sanity */
173 type = TGA_TYPE_T32_88;
174 }
175 }
176
177 return (type);
178 }
179
180 const struct tga_conf *
181 tga_getconf(type)
182 int type;
183 {
184
185 if (type >= 0 && type < TGA_TYPE_UNKNOWN)
186 return &tga_configs[type];
187
188 return (NULL);
189 }
190
191