tga_conf.c revision 1.1 1 /* $NetBSD: tga_conf.c,v 1.1 1998/04/15 20:16:32 drochner 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 #undef KB
38 #define KB * 1024
39 #undef MB
40 #define MB * 1024 * 1024
41
42 static const struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = {
43 /* TGA_TYPE_T8_01 */
44 {
45 "T8-01",
46 &tga_ramdac_bt485,
47 8,
48 4 MB,
49 2 KB,
50 1, { 2 MB, 0 }, { 1 MB, 0 },
51 0, { 0, 0 }, { 0, 0 },
52 },
53 /* TGA_TYPE_T8_02 */
54 {
55 "T8-02",
56 &tga_ramdac_bt485,
57 8,
58 4 MB,
59 4 KB,
60 1, { 2 MB, 0 }, { 2 MB, 0 },
61 0, { 0, 0 }, { 0, 0 },
62 },
63 /* TGA_TYPE_T8_22 */
64 {
65 "T8-22",
66 &tga_ramdac_bt485,
67 8,
68 8 MB,
69 4 KB,
70 1, { 4 MB, 0 }, { 2 MB, 0 },
71 1, { 6 MB, 0 }, { 2 MB, 0 },
72 },
73 /* TGA_TYPE_T8_44 */
74 {
75 "T8-44",
76 &tga_ramdac_bt485,
77 8,
78 16 MB,
79 4 KB,
80 2, { 8 MB, 12 MB }, { 2 MB, 2 MB },
81 2, { 10 MB, 14 MB }, { 2 MB, 2 MB },
82 },
83 /* TGA_TYPE_T32_04 */
84 {
85 "T32-04",
86 &tga_ramdac_bt463,
87 32,
88 16 MB,
89 8 KB,
90 1, { 8 MB, 0 }, { 4 MB, 0 },
91 0, { 0, 0 }, { 0, 0 },
92 },
93 /* TGA_TYPE_T32_08 */
94 {
95 "T32-08",
96 &tga_ramdac_bt463,
97 32,
98 16 MB,
99 16 KB,
100 1, { 8 MB, 0 }, { 8 MB, 0 },
101 0, { 0, 0 }, { 0, 0 },
102 },
103 /* TGA_TYPE_T32_88 */
104 {
105 "T32-88",
106 &tga_ramdac_bt463,
107 32,
108 32 MB,
109 16 KB,
110 1, { 16 MB, 0 }, { 8 MB, 0 },
111 1, { 24 MB, 0 }, { 8 MB, 0 },
112 },
113 };
114
115 #undef KB
116 #undef MB
117
118 int
119 tga_identify(regs)
120 tga_reg_t *regs;
121 {
122 int type;
123 int deep, addrmask, wide;
124
125 deep = (regs[TGA_REG_GDER] & 0x1) != 0; /* XXX */
126 addrmask = ((regs[TGA_REG_GDER] >> 2) & 0x7); /* XXX */
127 wide = (regs[TGA_REG_GDER] & 0x200) == 0; /* XXX */
128
129 type = TGA_TYPE_UNKNOWN;
130
131 if (!deep) {
132 /* 8bpp frame buffer */
133
134 if (addrmask == 0x0) {
135 /* 4MB core map; T8-01 or T8-02 */
136
137 if (!wide)
138 type = TGA_TYPE_T8_01;
139 else
140 type = TGA_TYPE_T8_02;
141 } else if (addrmask == 0x1) {
142 /* 8MB core map; T8-22 */
143
144 if (wide) /* sanity */
145 type = TGA_TYPE_T8_22;
146 } else if (addrmask == 0x3) {
147 /* 16MB core map; T8-44 */
148
149 if (wide) /* sanity */
150 type = TGA_TYPE_T8_44;
151 }
152 } else {
153 /* 32bpp frame buffer */
154
155 if (addrmask == 0x3) {
156 /* 16MB core map; T32-04 or T32-08 */
157
158 if (!wide)
159 type = TGA_TYPE_T32_04;
160 else
161 type = TGA_TYPE_T32_08;
162 } else if (addrmask == 0x7) {
163 /* 32MB core map; T32-88 */
164
165 if (wide) /* sanity */
166 type = TGA_TYPE_T32_88;
167 }
168 }
169
170 return (type);
171 }
172
173 const struct tga_conf *
174 tga_getconf(type)
175 int type;
176 {
177
178 if (type >= 0 && type < TGA_TYPE_UNKNOWN)
179 return &tga_configs[type];
180
181 return (NULL);
182 }
183
184