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