xref: /haiku/src/add-ons/kernel/drivers/graphics/radeon/detect.c (revision 1acbe440b8dd798953bec31d18ee589aa3f71b73)
1 /*
2  * Copyright (c) 2002, Thomas Kurschel
3  * Distributed under the terms of the MIT license.
4  */
5 
6 /**	Graphics card detection */
7 
8 
9 #include "radeon_driver.h"
10 
11 #include <stdio.h>
12 #include <string.h>
13 
14 
15 // this table is gathered from different sources
16 // and may even contain some wrong entries
17 #define VENDOR_ID_ATI		0x1002
18 
19 // R100
20 #define DEVICE_ID_RADEON_QD		0x5144
21 #define DEVICE_ID_RADEON_QE		0x5145
22 #define DEVICE_ID_RADEON_QF		0x5146
23 #define DEVICE_ID_RADEON_QG		0x5147
24 
25 // RV100
26 #define DEVICE_ID_RADEON_QY		0x5159
27 #define DEVICE_ID_RADEON_QZ		0x515a
28 
29 #define DEVICE_ID_RN50_515E		0x515E
30 #define DEVICE_ID_RN50_5969		0x5969
31 
32 // M6
33 #define DEVICE_ID_RADEON_LY		0x4c59
34 #define DEVICE_ID_RADEON_LZ		0x4c5a
35 
36 // RV200
37 #define DEVICE_ID_RADEON_QW		0x5157
38 #define DEVICE_ID_RADEON_QX		0x5158
39 
40 // R200 mobility
41 #define DEVICE_ID_RADEON_LW		0x4c57
42 #define DEVICE_ID_RADEON_LX		0x4c58
43 
44 // R200
45 #define DEVICE_ID_RADEON_QH		0x5148
46 #define DEVICE_ID_RADEON_QI		0x5149
47 #define DEVICE_ID_RADEON_QJ		0x514a
48 #define DEVICE_ID_RADEON_QK		0x514b
49 #define DEVICE_ID_RADEON_QL		0x514c
50 #define DEVICE_ID_RADEON_QM		0x514d
51 
52 #define DEVICE_ID_RADEON_Qh		0x5168
53 #define DEVICE_ID_RADEON_Qi		0x5169
54 #define DEVICE_ID_RADEON_Qj		0x516a
55 #define DEVICE_ID_RADEON_Qk		0x516b
56 
57 #define DEVICE_ID_RADEON_BB		0x4242
58 #define DEVICE_ID_RADEON_BC		0x4243
59 
60 // RV250
61 #define DEVICE_ID_RADEON_If     0x4966
62 #define DEVICE_ID_RADEON_Ig     0x4967
63 
64 // M9 (RV250)
65 #define DEVICE_ID_RADEON_Ld     0x4c64
66 #define DEVICE_ID_RADEON_Le     0x4c65
67 #define DEVICE_ID_RADEON_Lf     0x4c66
68 #define DEVICE_ID_RADEON_Lg     0x4c67
69 
70 // RV280
71 #define DEVICE_ID_RADEON_5960	0x5960
72 #define DEVICE_ID_RADEON_Za		0x5961
73 #define DEVICE_ID_RADEON_Zb		0x5962 // new
74 #define DEVICE_ID_RADEON_Zd		0x5964
75 #define DEVICE_ID_RADEON_Ze		0x5965 // new
76 
77 // M9+ (RV280)
78 #define DEVICE_ID_RADEON_5c61   0x5c61
79 #define DEVICE_ID_RADEON_5c63   0x5c63 // new
80 
81 // r300
82 #define DEVICE_ID_RADEON_ND     0x4e44
83 #define DEVICE_ID_RADEON_NE     0x4e45
84 #define DEVICE_ID_RADEON_NF     0x4e46
85 #define DEVICE_ID_RADEON_NG     0x4e47
86 
87 // r300-4P
88 #define DEVICE_ID_RADEON_AD     0x4144
89 #define DEVICE_ID_RADEON_AE     0x4145
90 #define DEVICE_ID_RADEON_AF     0x4146
91 #define DEVICE_ID_RADEON_AG     0x4147
92 
93 // rv350
94 #define DEVICE_ID_RADEON_AP		0x4150
95 #define DEVICE_ID_RADEON_AQ		0x4151
96 #define DEVICE_ID_RADEON_AR		0x4152 // RS360
97 #define DEVICE_ID_RADEON_AS		0x4153 // RV350 ?? on X.org
98 #define DEVICE_ID_RADEON_AT		0x4154 // new
99 #define DEVICE_ID_RADEON_4155	0x4155 // new
100 #define DEVICE_ID_RADEON_AV		0x4156 // new
101 
102 // m10 (rv350)
103 #define DEVICE_ID_RADEON_NP		0x4e50
104 #define DEVICE_ID_RADEON_NQ		0x4e51 // new
105 #define DEVICE_ID_RADEON_NR		0x4e52 // new
106 #define DEVICE_ID_RADEON_NS		0x4e53 // new
107 #define DEVICE_ID_RADEON_NT		0x4e54
108 #define DEVICE_ID_RADEON_NV		0x4e56 // new
109 
110 // r350
111 #define DEVICE_ID_RADEON_AH		0x4148
112 #define DEVICE_ID_RADEON_AI		0x4149 // new
113 #define DEVICE_ID_RADEON_AJ		0x414a // new
114 #define DEVICE_ID_RADEON_AK		0x414b // new
115 #define DEVICE_ID_RADEON_NH		0x4e48
116 #define DEVICE_ID_RADEON_NI		0x4e49
117 #define DEVICE_ID_RADEON_NK		0x4e4b // new
118 
119 // r360
120 #define DEVICE_ID_RADEON_NJ		0x4e4a
121 
122 // rv370 X300
123 //#define DEVICE_ID_RADEON_5b50	0x5b50
124 #define DEVICE_ID_RADEON_5b60	0x5b60
125 #define DEVICE_ID_RADEON_5b62	0x5b62
126 #define DEVICE_ID_RADEON_5b64	0x5b64 // new
127 #define DEVICE_ID_RADEON_5b65	0x5b65 // new
128 #define DEVICE_ID_RADEON_5460	0x5460
129 #define DEVICE_ID_RADEON_5464	0x5464 // new
130 
131 // rv380 X600
132 #define DEVICE_ID_RADEON_3e50	0x3e50
133 #define DEVICE_ID_RADEON_3e54	0x3e54 // new
134 #define DEVICE_ID_RADEON_3150	0x3150 // new
135 #define DEVICE_ID_RADEON_3154	0x3154 // new
136 #define DEVICE_ID_RADEON_5462	0x5462 // new X600SE on Toshiba M50 really an X300???
137 
138 // rv380 X600AIW
139 #define DEVICE_ID_RADEON_5b62	0x5b62
140 
141 // rv410 X700 pro
142 #define DEVICE_ID_RADEON_5e48	0x5e48 // new
143 #define DEVICE_ID_RADEON_564a	0x564a // new
144 #define DEVICE_ID_RADEON_564b	0x564b // new
145 #define DEVICE_ID_RADEON_564f	0x564f // new
146 #define DEVICE_ID_RADEON_5652	0x5652 // new
147 #define DEVICE_ID_RADEON_5653	0x5653 // new
148 #define DEVICE_ID_RADEON_5e4b	0x5e4b
149 #define DEVICE_ID_RADEON_5e4a	0x5e4a // new
150 #define DEVICE_ID_RADEON_5e4d	0x5e4d // new
151 #define DEVICE_ID_RADEON_5e4c	0x5e4c // new
152 #define DEVICE_ID_RADEON_5e4f	0x5e4f // new
153 
154 
155 // r420 X800
156 #define DEVICE_ID_RADEON_JH 	0x4a48 // new
157 #define DEVICE_ID_RADEON_JI		0x4a49
158 #define DEVICE_ID_RADEON_JJ 	0x4a4a
159 #define DEVICE_ID_RADEON_JK		0x4a4b
160 #define DEVICE_ID_RADEON_JL		0x4a4c // new mobility
161 #define DEVICE_ID_RADEON_JM 	0x4a4d // new
162 #define DEVICE_ID_RADEON_JN		0x4a4e // new
163 #define DEVICE_ID_RADEON_JP		0x4a50
164 #define DEVICE_ID_RADEON_4a4f	0x4a4f // new
165 
166 // r423 X800
167 #define DEVICE_ID_RADEON_UH		0x5548 // new
168 #define DEVICE_ID_RADEON_UI		0x5549
169 #define DEVICE_ID_RADEON_UJ		0x554a
170 #define DEVICE_ID_RADEON_UK		0x554b
171 #define DEVICE_ID_RADEON_UQ		0x5551 // new
172 #define DEVICE_ID_RADEON_UR		0x5552 // new
173 #define DEVICE_ID_RADEON_UT		0x5554 // new
174 
175 #define DEVICE_ID_RADEON_UM		0x554d // ?
176 #define DEVICE_ID_RADEON_UO		0x554f // ?
177 
178 #define DEVICE_ID_RADEON_5d57	0x5d57
179 #define DEVICE_ID_RADEON_5550	0x5550 // new
180 
181 // r430 X850
182 #define DEVICE_ID_RADEON_5d49	0x5d49 // new mob
183 #define DEVICE_ID_RADEON_5d4a	0x5d4a // new mob
184 #define DEVICE_ID_RADEON_5d48	0x5d48 // new mob
185 #define DEVICE_ID_RADEON_554f	0x554f // new
186 #define DEVICE_ID_RADEON_554d	0x554d // new
187 #define DEVICE_ID_RADEON_554e	0x554e // new
188 #define DEVICE_ID_RADEON_554c	0x554c // new
189 
190 // r480
191 #define DEVICE_ID_RADEON_5d4c	0x5d4c // new
192 #define DEVICE_ID_RADEON_5d50	0x5d50 // new
193 #define DEVICE_ID_RADEON_5d4e	0x5d4e // new
194 #define DEVICE_ID_RADEON_5d4f	0x5d4f // new
195 #define DEVICE_ID_RADEON_5d52	0x5d52 // new
196 #define DEVICE_ID_RADEON_5d4d	0x5d4d // new
197 
198 // r481
199 #define DEVICE_ID_RADEON_KJ		0x4b4a
200 #define DEVICE_ID_RADEON_KK		0x4b4b
201 #define DEVICE_ID_RADEON_KL		0x4b4c
202 #define DEVICE_ID_RADEON_KI		0x4b49
203 
204 // rs100
205 #define DEVICE_ID_RS100_4136	0x4136
206 #define DEVICE_ID_RS100_4336	0x4336
207 
208 // rs200
209 #define DEVICE_ID_RS200_4337	0x4337
210 #define DEVICE_ID_RS200_4137	0x4137
211 
212 // rs250
213 #define DEVICE_ID_RS250_4237	0x4237
214 #define DEVICE_ID_RS250_4437	0x4437
215 
216 // rs300
217 #define DEVICE_ID_RS300_5834	0x5834
218 #define DEVICE_ID_RS300_5835	0x5835
219 
220 // rs350
221 #define DEVICE_ID_RS350_7834	0x7834
222 #define DEVICE_ID_RS350_7835	0x7835
223 
224 // rs400
225 #define DEVICE_ID_RS400_5a41	0x5a41
226 #define DEVICE_ID_RS400_5a42	0x5a42
227 
228 // rs410
229 #define DEVICE_ID_RS410_5a61	0x5a61
230 #define DEVICE_ID_RS410_5a62	0x5a62
231 
232 // rs480/82
233 #define DEVICE_ID_RS480_5954	0x5954
234 #define DEVICE_ID_RS480_5955	0x5955
235 #define DEVICE_ID_RS482_5974	0x5974
236 #define DEVICE_ID_RS482_5975	0x5975
237 
238 typedef struct {
239 	uint16 device_id;
240 	radeon_type asic;
241 	uint32 features;
242 	char *name;
243 } RadeonDevice;
244 
245 #define STD_RADEON 0 // common as muck PC graphics card (if there is such a thing)
246 #define ISMOBILITY 1 // is mobility
247 #define INTEGRATED 2 // is IGP (Integrated Graphics Processor) built in to PC mainboard northbridge typically uses system RAM for graphics
248 #define MOBILE_IGP ISMOBILITY | INTEGRATED // 2 disabilites for the price of 1
249 
250 // list of supported devices
251 RadeonDevice radeon_device_list[] = {
252 	// original Radeons, now called r100
253 	{ DEVICE_ID_RADEON_QD	,	rt_r100,	STD_RADEON,	"Radeon 7200 / Radeon / ALL-IN-WONDER Radeon" },
254 	{ DEVICE_ID_RADEON_QE	,	rt_r100,	STD_RADEON,	"Radeon QE" },
255 	{ DEVICE_ID_RADEON_QF	,	rt_r100,	STD_RADEON,	"Radeon QF" },
256 	{ DEVICE_ID_RADEON_QG	,	rt_r100,	STD_RADEON,	"Radeon QG" },
257 
258 	// Radeon VE (low-cost, dual CRT, no TCL), was rt_ve now refered to as rv100
259 	{ DEVICE_ID_RADEON_QY	,	rt_rv100,	STD_RADEON,	"Radeon 7000 / Radeon VE" },
260 	{ DEVICE_ID_RADEON_QZ	,	rt_rv100,	STD_RADEON,	"Radeon QZ VE" },
261 
262 	{ DEVICE_ID_RN50_515E	,	rt_rv100,	STD_RADEON,	"ES1000 515E (PCI)" }, // Evans and Sutherland something or other?
263     { DEVICE_ID_RN50_5969	, 	rt_rv100,	STD_RADEON,	"ES1000 5969 (PCI)" },
264 
265 	// mobility version of original Radeon (based on VE), now called M6
266 	{ DEVICE_ID_RADEON_LY	,	rt_rv100,	ISMOBILITY,	"Radeon Mobility" },
267 	{ DEVICE_ID_RADEON_LZ	,	rt_rv100,	ISMOBILITY,	"Radeon Mobility M6 LZ" },
268 
269 	// RV200 (dual CRT)
270 	{ DEVICE_ID_RADEON_QW	,	rt_rv200,	STD_RADEON,	"Radeon 7500 / ALL-IN-WONDER Radeon 7500" },
271 	{ DEVICE_ID_RADEON_QX	,	rt_rv200,	STD_RADEON,	"Radeon 7500 QX" },
272 
273 	// M7 (based on RV200) was rt_m7
274 	{ DEVICE_ID_RADEON_LW	,	rt_rv200,	ISMOBILITY,	"Radeon Mobility 7500" },
275 	{ DEVICE_ID_RADEON_LX	,	rt_rv200,	ISMOBILITY,	"Radeon Mobility 7500 GL" },
276 
277 	// R200
278 	{ DEVICE_ID_RADEON_QH	,	rt_r200,	STD_RADEON,	"Fire GL E1" },	// chip type: fgl8800
279 	{ DEVICE_ID_RADEON_QI	,	rt_r200,	STD_RADEON,	"Radeon 8500 QI" },
280 	{ DEVICE_ID_RADEON_QJ	,	rt_r200,	STD_RADEON,	"Radeon 8500 QJ" },
281 	{ DEVICE_ID_RADEON_QK	,	rt_r200,	STD_RADEON,	"Radeon 8500 QK" },
282 	{ DEVICE_ID_RADEON_QL	,	rt_r200,	STD_RADEON,	"Radeon 8500 / 8500LE / ALL-IN-WONDER Radeon 8500" },
283 	{ DEVICE_ID_RADEON_QM	,	rt_r200,	STD_RADEON,	"Radeon 9100" },
284 
285 	{ DEVICE_ID_RADEON_Qh	,	rt_r200,	STD_RADEON,	"Radeon 8500 Qh" },
286 	{ DEVICE_ID_RADEON_Qi	,	rt_r200,	STD_RADEON,	"Radeon 8500 Qi" },
287 	{ DEVICE_ID_RADEON_Qj	,	rt_r200,	STD_RADEON,	"Radeon 8500 Qj" },
288 	{ DEVICE_ID_RADEON_Qk	,	rt_r200,	STD_RADEON,	"Radeon 8500 Qk" },
289 
290 	{ DEVICE_ID_RADEON_BB	,	rt_r200,	STD_RADEON,	"ALL-IN-Wonder Radeon 8500 DV (BB)" },
291 	{ DEVICE_ID_RADEON_BC	,	rt_r200,	STD_RADEON,	"ALL-IN-Wonder Radeon 8500 DV (BC)" },
292 
293 	// RV250 (cut-down R200 with integrated TV-Out)
294 	{ DEVICE_ID_RADEON_If	,  rt_rv250,	STD_RADEON,	"Radeon 9000" },
295 	{ DEVICE_ID_RADEON_Ig	,  rt_rv250,	STD_RADEON,	"Radeon 9000 Ig" },
296 
297 	// M9 (based on rv250) was rt_m9
298 	{ DEVICE_ID_RADEON_Ld	,	rt_rv250,	ISMOBILITY,	"Radeon Mobility 9000 Ld" },
299 	{ DEVICE_ID_RADEON_Le	,	rt_rv250,	ISMOBILITY,	"Radeon Mobility 9000 Le" },
300 	{ DEVICE_ID_RADEON_Lf	,	rt_rv250,	ISMOBILITY,	"Radeon Mobility 9000 Lf" },
301 	{ DEVICE_ID_RADEON_Lg	,	rt_rv250,	ISMOBILITY,	"Radeon Mobility 9000 Lg" },
302 
303 	// RV280 (rv250 but faster)
304 	{ DEVICE_ID_RADEON_5960	,	rt_rv280,	STD_RADEON,	"Radeon 9200 Pro" },
305 	{ DEVICE_ID_RADEON_Za	,	rt_rv280,	STD_RADEON,	"Radeon 9200" },
306 	{ DEVICE_ID_RADEON_Zb	,	rt_rv280,	STD_RADEON,	"Radeon 9200" },
307 	{ DEVICE_ID_RADEON_Zd	,	rt_rv280,	STD_RADEON,	"Radeon 9200 SE" },
308 	{ DEVICE_ID_RADEON_Ze	,	rt_rv280,	STD_RADEON,	"Ati FireMV 2200" },
309 
310 	// M9+ (based on rv280) was rt_m9plus
311 	{ DEVICE_ID_RADEON_5c61	,	rt_rv280,	ISMOBILITY,	"Radeon Mobility 9200" },
312 	{ DEVICE_ID_RADEON_5c63	,	rt_rv280,	ISMOBILITY,	"Radeon Mobility 9200" },
313 
314 	// R300
315 	{ DEVICE_ID_RADEON_ND	,	rt_r300,	STD_RADEON,	"Radeon 9700 ND" },
316 	{ DEVICE_ID_RADEON_NE	,	rt_r300,	STD_RADEON,	"Radeon 9700 NE" },
317 	{ DEVICE_ID_RADEON_NF	,	rt_r300,	STD_RADEON,	"Radeon 9600 XT" },
318 	{ DEVICE_ID_RADEON_NG	,	rt_r300,	STD_RADEON,	"Radeon 9700 NG" },
319 
320 	// r300-4P
321 	{ DEVICE_ID_RADEON_AD	,	rt_r300,	STD_RADEON,	"Radeon 9700 AD" },
322 	{ DEVICE_ID_RADEON_AE	,	rt_r300,	STD_RADEON,	"Radeon 9700 AE" },
323 	{ DEVICE_ID_RADEON_AF	,	rt_r300,	STD_RADEON,	"Radeon 9700 AF" },
324 	{ DEVICE_ID_RADEON_AG	,	rt_r300,	STD_RADEON,	"Radeon 9700 AG" },
325 
326 	// RV350
327 	{ DEVICE_ID_RADEON_AP	, 	rt_rv350,	STD_RADEON,	"Radeon 9600 AP" },
328 	{ DEVICE_ID_RADEON_AQ	, 	rt_rv350,	STD_RADEON,	"Radeon 9600SE AQ" },
329 	{ DEVICE_ID_RADEON_AR	, 	rt_rv350,	STD_RADEON,	"Radeon 9600XT AR" },
330 	{ DEVICE_ID_RADEON_AS	, 	rt_rv350,	STD_RADEON,	"Radeon 9550 AS" },
331 	{ DEVICE_ID_RADEON_AT	, 	rt_rv350,	STD_RADEON,	"FireGL T2 AT" },
332 	{ DEVICE_ID_RADEON_4155	,	rt_rv350,	STD_RADEON,	"Radeon 9650 4155" },
333 	{ DEVICE_ID_RADEON_AV	, 	rt_rv350,	STD_RADEON,	"Radeon 9600 AQ" },
334 
335 	// rv350 M10 (based on rv350) was rt_m10
336 	{ DEVICE_ID_RADEON_NP	,	rt_rv350,	ISMOBILITY,	"Radeon Mobility 9600/9700 (M10/M11) NP " },
337 	{ DEVICE_ID_RADEON_NQ	,	rt_rv350,	ISMOBILITY,	"Radeon Mobility 9600 (M10) NQ " },
338 	{ DEVICE_ID_RADEON_NR	,	rt_rv350,	ISMOBILITY,	"Radeon Mobility 9600 (M11) NR " },
339 	{ DEVICE_ID_RADEON_NS	,	rt_rv350,	ISMOBILITY,	"Radeon Mobility 9600 (M10) NS " },
340 	{ DEVICE_ID_RADEON_NT	,	rt_rv350,	ISMOBILITY,	"ATI FireGL Mobility T2 (M10) NT" },
341 	{ DEVICE_ID_RADEON_NV	,	rt_rv350,	ISMOBILITY,	"ATI FireGL Mobility T2e (M11) NV" },
342 
343 	// R350
344 	{ DEVICE_ID_RADEON_AH	,	rt_r350,	STD_RADEON,	"Radeon 9800SE AH" },
345 	{ DEVICE_ID_RADEON_AI	,	rt_r350,	STD_RADEON,	"Radeon 9800 AI" },
346 	{ DEVICE_ID_RADEON_AJ	,	rt_r350,	STD_RADEON,	"Radeon 9800 AJ" },
347 	{ DEVICE_ID_RADEON_AK	,	rt_r350,	STD_RADEON,	"FireGL X2 AK" },
348 	{ DEVICE_ID_RADEON_NH	,	rt_r350,	STD_RADEON,	"Radeon 9800 Pro NH" },
349 	{ DEVICE_ID_RADEON_NI	,	rt_r350,	STD_RADEON,	"Radeon 9800 NI" },
350 	{ DEVICE_ID_RADEON_NK	,	rt_r350,	STD_RADEON,	"FireGL X2 NK" },
351 	{ DEVICE_ID_RADEON_NJ	,	rt_r350,	STD_RADEON,	"Radeon 9800 XT" },
352 
353 	// rv370
354 	{ DEVICE_ID_RADEON_5b60	,	rt_rv380,	STD_RADEON,	"Radeon X300 (RV370) 5B60" },
355 	{ DEVICE_ID_RADEON_5b62	,	rt_rv380,	STD_RADEON,	"Radeon X600 (RV370) 5B62" },
356 	{ DEVICE_ID_RADEON_5b64	,	rt_rv380,	STD_RADEON,	"FireGL V3100 (RV370) 5B64" },
357 	{ DEVICE_ID_RADEON_5b65	,	rt_rv380,	STD_RADEON,	"FireGL D1100 (RV370) 5B65" },
358 	{ DEVICE_ID_RADEON_5460 ,	rt_rv380,	ISMOBILITY,	"Radeon Mobility M300 (M22) 5460" },
359 	{ DEVICE_ID_RADEON_5464 ,	rt_rv380,	ISMOBILITY,	"FireGL M22 GL 5464" },
360 
361 	// rv380
362 	{ DEVICE_ID_RADEON_3e50	,	rt_rv380,	STD_RADEON,	"Radeon X600 (RV380) 3E50" },
363 	{ DEVICE_ID_RADEON_3e54	,	rt_rv380,	STD_RADEON,	"FireGL V3200 (RV380) 3E54" },
364 	{ DEVICE_ID_RADEON_3150	,	rt_rv380,	ISMOBILITY,	"Radeon Mobility X600 (M24) 3150" },
365 	{ DEVICE_ID_RADEON_3154	,	rt_rv380,	ISMOBILITY,	"FireGL M24 GL 3154" },
366 	{ DEVICE_ID_RADEON_5462 ,	rt_rv380,	ISMOBILITY,	"Radeon X600SE (RV3?0) 5462" },
367 
368 	// rv380
369 	{ DEVICE_ID_RADEON_5b62	 ,	rt_rv380,	STD_RADEON,	"Radeon X600 AIW" },
370 
371 	// rv410
372 	{ DEVICE_ID_RADEON_5e48	,	rt_r420,	STD_RADEON,	"FireGL V5000 (RV410)" },
373 	{ DEVICE_ID_RADEON_564a	,	rt_r420,	ISMOBILITY,	"Mobility FireGL V5000 (M26)" },
374 	{ DEVICE_ID_RADEON_564b	,	rt_r420,	ISMOBILITY,	"Mobility FireGL V5000 (M26)" },
375 	{ DEVICE_ID_RADEON_564f ,	rt_r420,	ISMOBILITY,	"Mobility Radeon X700 XL (M26)" },
376 	{ DEVICE_ID_RADEON_5652	,	rt_r420,	ISMOBILITY,	"Mobility Radeon X700 (M26)" },
377 	{ DEVICE_ID_RADEON_5653	,	rt_r420,	ISMOBILITY,	"Mobility Radeon X700 (M26)" },
378 	{ DEVICE_ID_RADEON_5e4b	,	rt_r420,	STD_RADEON,	"Radeon X700 PRO (RV410)" },
379 	{ DEVICE_ID_RADEON_5e4a	,	rt_r420,	STD_RADEON,	"Radeon X700 XT (RV410)" },
380 	{ DEVICE_ID_RADEON_5e4d	,	rt_r420,	STD_RADEON,	"Radeon X700 (RV410)" },
381 	{ DEVICE_ID_RADEON_5e4c	,	rt_r420,	STD_RADEON,	"Radeon X700 SE (RV410)" },
382 	{ DEVICE_ID_RADEON_5e4f	,	rt_r420,	STD_RADEON,	"Radeon X700 SE (RV410)" },
383 
384 	// r420
385 	{ DEVICE_ID_RADEON_JH 	,	rt_r420,	STD_RADEON,	"Radeon X800 (R420) JH" },
386 	{ DEVICE_ID_RADEON_JI	,	rt_r420,	STD_RADEON,	"Radeon X800PRO (R420) JI" },
387 	{ DEVICE_ID_RADEON_JJ 	,	rt_r420,	STD_RADEON,	"Radeon X800SE (R420) JJ" },
388 	{ DEVICE_ID_RADEON_JK	,	rt_r420,	STD_RADEON,	"Radeon X800 (R420) JK" },
389 	{ DEVICE_ID_RADEON_JL	,	rt_r420,	STD_RADEON,	"Radeon X800 (R420) JL" },
390 	{ DEVICE_ID_RADEON_JM 	,	rt_r420,	STD_RADEON,	"FireGL X3 (R420) JM" },
391 	{ DEVICE_ID_RADEON_JN	,	rt_r420,	ISMOBILITY,	"Radeon Mobility 9800 (M18) JN" },
392 	{ DEVICE_ID_RADEON_JP	,	rt_r420,	STD_RADEON,	"Radeon X800XT (R420) JP" },
393 	{ DEVICE_ID_RADEON_4a4f	,	rt_r420,	STD_RADEON,	"Radeon X800 SE (R420)" },
394 
395 	// r423
396 	{ DEVICE_ID_RADEON_UH	,	rt_r420,	STD_RADEON,	"Radeon X800 (R423) UH" },
397 	{ DEVICE_ID_RADEON_UI	,	rt_r420,	STD_RADEON,	"Radeon X800PRO (R423) UI" },
398 	{ DEVICE_ID_RADEON_UJ	,	rt_r420,	STD_RADEON,	"Radeon X800LE (R423) UJ" },
399 	{ DEVICE_ID_RADEON_UK	,	rt_r420,	STD_RADEON,	"Radeon X800SE (R423) UK" },
400 	{ DEVICE_ID_RADEON_UQ	,	rt_r420,	STD_RADEON,	"FireGL V7200 (R423) UQ" },
401 	{ DEVICE_ID_RADEON_UR	,	rt_r420,	STD_RADEON,	"FireGL V5100 (R423) UR" },
402 	{ DEVICE_ID_RADEON_UT	,	rt_r420,	STD_RADEON,	"FireGL V7100 (R423) UT" },
403 
404 	{ DEVICE_ID_RADEON_UO	,	rt_r420,	STD_RADEON,	"Radeon X800 UO" },
405 	{ DEVICE_ID_RADEON_UM	,	rt_r420,	STD_RADEON,	"Radeon X800 UM" },
406 
407 	{ DEVICE_ID_RADEON_5d57	,	rt_r420,	STD_RADEON,	"Radeon X800 XT" },
408 	{ DEVICE_ID_RADEON_5550	,	rt_r420,	STD_RADEON,	"FireGL V7100 (R423)" },
409 
410 	// r430
411 	{ DEVICE_ID_RADEON_5d49 ,	rt_r420,	ISMOBILITY,	"Mobility FireGL V5100 (M28)" },
412 	{ DEVICE_ID_RADEON_5d4a	,	rt_r420,	ISMOBILITY,	"Mobility Radeon X800 (M28)" },
413 	{ DEVICE_ID_RADEON_5d48	,	rt_r420,	ISMOBILITY,	"Mobility Radeon X800 XT (M28)" },
414 	{ DEVICE_ID_RADEON_554f ,	rt_r420,	STD_RADEON,	"Radeon X800 (R430)" },
415 	{ DEVICE_ID_RADEON_554d	,	rt_r420,	STD_RADEON,	"Radeon X800 XL (R430)" },
416 	{ DEVICE_ID_RADEON_554e	,	rt_r420,	STD_RADEON,	"Radeon X800 SE (R430)" },
417 	{ DEVICE_ID_RADEON_554c ,	rt_r420,	STD_RADEON,	"Radeon X800 XTP (R430)" },
418 
419 	// r480
420 	{ DEVICE_ID_RADEON_5d4c ,	rt_r420,	STD_RADEON,	"Radeon X850 5D4C" },
421 	{ DEVICE_ID_RADEON_5d50	,	rt_r420,	STD_RADEON,	"Radeon FireGL (R480) GL 5D50" },
422 	{ DEVICE_ID_RADEON_5d4e	,	rt_r420,	STD_RADEON,	"Radeon X850 SE (R480)" },
423 	{ DEVICE_ID_RADEON_5d4f ,	rt_r420,	STD_RADEON,	"Radeon X850 PRO (R480)" },
424 	{ DEVICE_ID_RADEON_5d52	,	rt_r420,	STD_RADEON,	"Radeon X850 XT (R480)" },
425 	{ DEVICE_ID_RADEON_5d4d	,	rt_r420,	STD_RADEON,	"Radeon X850 XT PE (R480)" },
426 
427 	// r481
428 	{ DEVICE_ID_RADEON_KJ	,	rt_r420,	STD_RADEON,	"Radeon X850 PRO (R480)" },
429 	{ DEVICE_ID_RADEON_KK	,	rt_r420,	STD_RADEON,	"Radeon X850 SE (R480)" },
430 	{ DEVICE_ID_RADEON_KL	,	rt_r420,	STD_RADEON,	"Radeon X850 XT (R480)" },
431 	{ DEVICE_ID_RADEON_KI	,	rt_r420,	STD_RADEON,	"Radeon X850 XT PE (R480)" },
432 
433 	// rs100 (aka IGP 320)
434 	{ DEVICE_ID_RS100_4136	, 	rt_rs100,	INTEGRATED,	"Radeon IGP320 (A3) 4136" },
435 	{ DEVICE_ID_RS100_4336	, 	rt_rs100,	MOBILE_IGP,	"Radeon IGP320M (U1) 4336" },
436 
437 	// rs200 (aka IGP 340)
438 	{ DEVICE_ID_RS200_4137	,	rt_rs200,	INTEGRATED,	"Radeon IGP330/340/350 (A4) 4137" },
439 	{ DEVICE_ID_RS200_4337	,	rt_rs200,	MOBILE_IGP,	"Radeon IGP330M/340M/350M (U2) 4337" },
440 
441 	// rs250 (aka 7000 IGP)
442 	{ DEVICE_ID_RS250_4237	,	rt_rs200,	INTEGRATED,	"IGP330M/340M/350M (U2) 4337" },
443 	{ DEVICE_ID_RS250_4437	,	rt_rs200,	MOBILE_IGP,	"Radeon Mobility 7000 IGP 4437" },
444 
445 	// rs300
446 	{ DEVICE_ID_RS300_5834	,	rt_rs300,	INTEGRATED,	"Radeon 9100 IGP (A5) 5834" },
447 	{ DEVICE_ID_RS300_5835	,	rt_rs300,	MOBILE_IGP,	"Radeon Mobility 9100 IGP (U3) 5835" },
448 
449 	// rs350
450 	{ DEVICE_ID_RS350_7834	,	rt_rs300,	INTEGRATED,	"Radeon 9100 PRO IGP 7834" },
451 	{ DEVICE_ID_RS350_7835	,	rt_rs300,	MOBILE_IGP,	"Radeon Mobility 9200 IGP 7835" },
452 
453 	// rs400
454 	{ DEVICE_ID_RS400_5a41	,	rt_rv380,	STD_RADEON,	"Radeon XPRESS 200 5A41" }, // X.org people unsure what this is for now
455 	{ DEVICE_ID_RS400_5a42	,	rt_rv380,	ISMOBILITY,	"Radeon XPRESS 200M 5A42" },
456 
457 	// rs410
458 	{ DEVICE_ID_RS410_5a61	,	rt_rv380,	STD_RADEON,	"Radeon XPRESS 200 5A61" }, // X.org people unsure what this is for now
459 	{ DEVICE_ID_RS410_5a62	,	rt_rv380,	ISMOBILITY,	"Radeon XPRESS 200M 5A62" },
460 
461 	// rs480
462 	{ DEVICE_ID_RS480_5954	,	rt_rv380,	STD_RADEON,	"Radeon XPRESS 200 5954" }, // X.org people unsure what this is for now
463 	{ DEVICE_ID_RS480_5955	,	rt_rv380,	ISMOBILITY,	"Radeon XPRESS 200M 5955" },
464 	{ DEVICE_ID_RS482_5974	,	rt_rv380,	STD_RADEON,	"Radeon XPRESS 200 5974" }, // X.org people unsure what this is for now
465 	{ DEVICE_ID_RS482_5975	,	rt_rv380,	ISMOBILITY,	"Radeon XPRESS 200M 5975" },
466 
467 	{ 0, 0, 0, NULL }
468 };
469 
470 
471 // list of supported vendors (there aren't many ;)
472 static struct {
473 	uint16	vendor_id;
474 	RadeonDevice *devices;
475 } SupportedVendors[] = {
476 	{ VENDOR_ID_ATI, radeon_device_list },
477 	{ 0x0000, NULL }
478 };
479 
480 // check, whether there is *any* supported card plugged in
481 bool Radeon_CardDetect( void )
482 {
483 	long		pci_index = 0;
484 	pci_info	pcii;
485 	bool		found_one = FALSE;
486 
487 	if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK)
488 		return B_ERROR;
489 
490 	while ((*pci_bus->get_nth_pci_info)(pci_index, &pcii) == B_NO_ERROR) {
491 		int vendor = 0;
492 
493 		while (SupportedVendors[vendor].vendor_id) {
494 			if (SupportedVendors[vendor].vendor_id == pcii.vendor_id) {
495 				RadeonDevice *devices = SupportedVendors[vendor].devices;
496 
497 				while (devices->device_id) {
498 					if (devices->device_id == pcii.device_id ) {
499 						rom_info ri;
500 
501 						if( Radeon_MapBIOS( &pcii, &ri ) == B_OK ) {
502 							Radeon_UnmapBIOS( &ri );
503 
504 							SHOW_INFO( 0, "found supported device pci index %ld, device 0x%04x/0x%04x",
505 								pci_index, pcii.vendor_id, pcii.device_id );
506 							found_one = TRUE;
507 							goto done;
508 						}
509 					}
510 					devices++;
511 				}
512 			}
513 			vendor++;
514 		}
515 
516 		pci_index++;
517 	}
518 	SHOW_INFO0( 0, "no supported devices found" );
519 
520 done:
521 	put_module(B_PCI_MODULE_NAME);
522 
523 	return (found_one ? B_OK : B_ERROR);
524 }
525 
526 // !extend this array whenever a new ASIC is a added!
527 static struct {
528 	const char 		*name;			// name of ASIC
529 	tv_chip_type	tv_chip;		// TV-Out chip (if any)
530 	bool 			has_crtc2;		// has second CRTC
531 	bool			has_vip;		// has VIP/I2C
532 	bool			new_pll;		// reference divider of PPLL moved to other location
533 } asic_properties[] =
534 {
535 	{ "r100",	tc_external_rt1,	false,	true,	false,},
536 	{ "rv100",	tc_internal_rt1, 	true,	true,	false,},
537 	{ "rs100",	tc_internal_rt1,	true,	false,	false,},
538 	{ "rv200",	tc_internal_rt2, 	true,	true,	false,},
539 	{ "rs200",	tc_internal_rt1, 	true,	false,	false,},
540 	{ "r200",	tc_external_rt1, 	true,	true,	false,},
541 	{ "rv250",	tc_internal_rt2, 	true,	true,	false,},
542 	{ "rs300",	tc_internal_rt1, 	true,	false,	false,},
543 	{ "rv280",	tc_internal_rt2, 	true,	true,	false,},
544 	{ "r300",	tc_internal_rt2, 	true,	true,	true, },
545 	{ "r350",	tc_internal_rt2, 	true,	true,	true, },
546 	{ "rv350",	tc_internal_rt2, 	true,	true,	true, },
547 	{ "rv380",	tc_internal_rt2, 	true,	true,	true, },
548 	{ "r420",	tc_internal_rt2, 	true,	true,	true, }
549 
550 };
551 
552 
553 // get next supported device
554 static bool probeDevice( device_info *di )
555 {
556 	int vendor;
557 
558 	/* if we match a supported vendor */
559 	for( vendor = 0; SupportedVendors[vendor].vendor_id; ++vendor ) {
560 		RadeonDevice *device;
561 
562 		if( SupportedVendors[vendor].vendor_id != di->pcii.vendor_id )
563 			continue;
564 
565 		for( device = SupportedVendors[vendor].devices; device->device_id; ++device ) {
566 			// avoid double-detection
567 			if (device->device_id != di->pcii.device_id )
568 				continue;
569 
570 			di->num_crtc = asic_properties[device->asic].has_crtc2 ? 2 : 1;
571 			di->tv_chip = asic_properties[device->asic].tv_chip;
572 			di->asic = device->asic;
573 			di->is_mobility = (device->features & ISMOBILITY) ? true : false;
574 			di->has_vip = asic_properties[device->asic].has_vip;
575 			di->new_pll = asic_properties[device->asic].new_pll;
576 			di->is_igp = (device->features & INTEGRATED) ? true : false;
577 
578 			// detect chips with broken I2C
579 			switch( device->device_id)
580 			{
581 		    	case DEVICE_ID_RADEON_LY:
582 				case DEVICE_ID_RADEON_LZ:
583 				case DEVICE_ID_RADEON_LW:
584 				case DEVICE_ID_RADEON_LX:
585 				case DEVICE_ID_RADEON_If:
586 				case DEVICE_ID_RADEON_Ig:
587 				case DEVICE_ID_RADEON_5460:
588 				case DEVICE_ID_RADEON_5464:
589 				di->has_no_i2c = true;
590 				default:
591 				di->has_no_i2c = false;
592 
593 			}
594 
595 			// disable 2d DMA engine for chips that don't work with our
596 			// dma code (yet).  I would have used asic type, but R410s are
597 			// treated same asic as r420s in code, and the AGP x800 works fine.
598 			switch ( device->device_id )
599 			{
600 				// rv370
601 				case DEVICE_ID_RADEON_5b60:
602 				case DEVICE_ID_RADEON_5b62:
603 				case DEVICE_ID_RADEON_5b64:
604 				case DEVICE_ID_RADEON_5b65:
605 				case DEVICE_ID_RADEON_5460:
606 				case DEVICE_ID_RADEON_5464:
607 
608 				// rv380
609 				case DEVICE_ID_RADEON_3e50:
610 				case DEVICE_ID_RADEON_3e54:
611 				case DEVICE_ID_RADEON_3150:
612 				case DEVICE_ID_RADEON_3154:
613 				case DEVICE_ID_RADEON_5462:
614 
615 				// rv410
616 				case DEVICE_ID_RADEON_5e48:
617 				case DEVICE_ID_RADEON_564a:
618 				case DEVICE_ID_RADEON_564b:
619 				case DEVICE_ID_RADEON_564f:
620 				case DEVICE_ID_RADEON_5652:
621 				case DEVICE_ID_RADEON_5653:
622 				case DEVICE_ID_RADEON_5e4b:
623 				case DEVICE_ID_RADEON_5e4a:
624 				case DEVICE_ID_RADEON_5e4d:
625 				case DEVICE_ID_RADEON_5e4c:
626 				case DEVICE_ID_RADEON_5e4f:
627 
628 				// rs400
629 				case DEVICE_ID_RS400_5a41:
630 				case DEVICE_ID_RS400_5a42:
631 
632 				// rs410
633 				case DEVICE_ID_RS410_5a61:
634 				case DEVICE_ID_RS410_5a62:
635 
636 				// rs480
637 				case DEVICE_ID_RS480_5954:
638 				case DEVICE_ID_RS480_5955:
639 				case DEVICE_ID_RS482_5974:
640 				case DEVICE_ID_RS482_5975:
641 
642 					di->acc_dma = false;
643 					break;
644 				default:
645 					di->acc_dma = true;
646 					break;
647 			}
648 
649 			if( Radeon_MapBIOS( &di->pcii, &di->rom ) != B_OK )
650 				// give up checking this device - no BIOS, no fun
651 				return false;
652 
653 			if( Radeon_ReadBIOSData( di ) != B_OK ) {
654 				Radeon_UnmapBIOS( &di->rom );
655 				return false;
656 			}
657 
658 			// we don't need BIOS any more
659 			Radeon_UnmapBIOS( &di->rom );
660 
661 			SHOW_INFO( 0, "found %s; ASIC: %s", device->name, asic_properties[device->asic].name );
662 
663 			sprintf(di->name, "graphics/%04X_%04X_%02X%02X%02X",
664 				di->pcii.vendor_id, di->pcii.device_id,
665 				di->pcii.bus, di->pcii.device, di->pcii.function);
666 			SHOW_FLOW( 3, "making /dev/%s", di->name );
667 
668 			// we always publish it as a video grabber; we should check for Rage
669 			// Theater, but the corresponding code (vip.c) needs a fully initialized
670 			// driver, and this is too much hazzly, so we leave it to the media add-on
671 			// to verify that the card really supports video-in
672 			sprintf(di->video_name, "video/radeon/%04X_%04X_%02X%02X%02X",
673 				di->pcii.vendor_id, di->pcii.device_id,
674 				di->pcii.bus, di->pcii.device, di->pcii.function);
675 
676 			di->is_open = 0;
677 			di->shared_area = -1;
678 			di->si = NULL;
679 
680 			return true;
681 		}
682 	}
683 
684 	return false;
685 }
686 
687 
688 // gather list of supported devices
689 // (currently, we rely on proper BIOS detection, which
690 //  only works for primary graphics adapter, so multiple
691 //  devices won't really work)
692 void Radeon_ProbeDevices( void )
693 {
694 	uint32 pci_index = 0;
695 	uint32 count = 0;
696 	device_info *di = devices->di;
697 
698 	while( count < MAX_DEVICES ) {
699 		memset( di, 0, sizeof( *di ));
700 
701 		if( (*pci_bus->get_nth_pci_info)(pci_index, &(di->pcii)) != B_NO_ERROR)
702 			break;
703 
704 		if( probeDevice( di )) {
705 			devices->device_names[2*count] = di->name;
706 			devices->device_names[2*count+1] = di->video_name;
707 			di++;
708 			count++;
709 		}
710 
711 		pci_index++;
712 	}
713 
714 	devices->count = count;
715 	devices->device_names[2*count] = NULL;
716 
717 	SHOW_INFO( 0, "%ld supported devices", count );
718 }
719