xref: /haiku/src/add-ons/accelerants/nvidia/engine/nv_general.c (revision ed6250c95736c0b55da79d6e9dd01369532260c0)
1 /* Authors:
2    Mark Watson 12/1999,
3    Apsed,
4    Rudolf Cornelissen 10/2002-10/2007
5 */
6 
7 #define MODULE_BIT 0x00008000
8 
9 #include "nv_std.h"
10 
11 static status_t test_ram(void);
12 static status_t nvxx_general_powerup (void);
13 static void unlock_card(void);
14 static status_t nv_general_bios_to_powergraphics(void);
15 
16 static void nv_dump_configuration_space (void)
17 {
18 #define DUMP_CFG(reg, type) if (si->ps.card_type >= type) do { \
19 	uint32 value = CFGR(reg); \
20 	MSG(("configuration_space 0x%02x %20s 0x%08x\n", \
21 		NVCFG_##reg, #reg, value)); \
22 } while (0)
23 	DUMP_CFG (DEVID,	0);
24 	DUMP_CFG (DEVCTRL,	0);
25 	DUMP_CFG (CLASS,	0);
26 	DUMP_CFG (HEADER,	0);
27 	DUMP_CFG (BASE1REGS,0);
28 	DUMP_CFG (BASE2FB,	0);
29 	DUMP_CFG (BASE3,	0);
30 	DUMP_CFG (BASE4,	0);
31 	DUMP_CFG (BASE5,	0);
32 	DUMP_CFG (BASE6,	0);
33 	DUMP_CFG (BASE7,	0);
34 	DUMP_CFG (SUBSYSID1,0);
35 	DUMP_CFG (ROMBASE,	0);
36 	DUMP_CFG (CAPPTR,	0);
37 	DUMP_CFG (CFG_1,	0);
38 	DUMP_CFG (INTERRUPT,0);
39 	DUMP_CFG (SUBSYSID2,0);
40 	DUMP_CFG (AGPREF,	0);
41 	DUMP_CFG (AGPSTAT,	0);
42 	DUMP_CFG (AGPCMD,	0);
43 	DUMP_CFG (ROMSHADOW,0);
44 	DUMP_CFG (VGA,		0);
45 	DUMP_CFG (SCHRATCH,	0);
46 	DUMP_CFG (CFG_10,	0);
47 	DUMP_CFG (CFG_11,	0);
48 	DUMP_CFG (CFG_12,	0);
49 	DUMP_CFG (CFG_13,	0);
50 	DUMP_CFG (CFG_14,	0);
51 	DUMP_CFG (CFG_15,	0);
52 	DUMP_CFG (CFG_16,	0);
53 	DUMP_CFG (PCIEREF,	0);
54 	DUMP_CFG (PCIEDCAP,	0);
55 	DUMP_CFG (PCIEDCTST,0);
56 	DUMP_CFG (PCIELCAP,	0);
57 	DUMP_CFG (PCIELCTST,0);
58 	DUMP_CFG (CFG_22,	0);
59 	DUMP_CFG (CFG_23,	0);
60 	DUMP_CFG (CFG_24,	0);
61 	DUMP_CFG (CFG_25,	0);
62 	DUMP_CFG (CFG_26,	0);
63 	DUMP_CFG (CFG_27,	0);
64 	DUMP_CFG (CFG_28,	0);
65 	DUMP_CFG (CFG_29,	0);
66 	DUMP_CFG (CFG_30,	0);
67 	DUMP_CFG (CFG_31,	0);
68 	DUMP_CFG (CFG_32,	0);
69 	DUMP_CFG (CFG_33,	0);
70 	DUMP_CFG (CFG_34,	0);
71 	DUMP_CFG (CFG_35,	0);
72 	DUMP_CFG (CFG_36,	0);
73 	DUMP_CFG (CFG_37,	0);
74 	DUMP_CFG (CFG_38,	0);
75 	DUMP_CFG (CFG_39,	0);
76 	DUMP_CFG (CFG_40,	0);
77 	DUMP_CFG (CFG_41,	0);
78 	DUMP_CFG (CFG_42,	0);
79 	DUMP_CFG (CFG_43,	0);
80 	DUMP_CFG (CFG_44,	0);
81 	DUMP_CFG (CFG_45,	0);
82 	DUMP_CFG (CFG_46,	0);
83 	DUMP_CFG (CFG_47,	0);
84 	DUMP_CFG (CFG_48,	0);
85 	DUMP_CFG (CFG_49,	0);
86 	DUMP_CFG (CFG_50,	0);
87 #undef DUMP_CFG
88 }
89 
90 status_t nv_general_powerup()
91 {
92 	status_t status;
93 
94 	LOG(1,("POWERUP: Haiku nVidia Accelerant 0.84 running.\n"));
95 
96 	/* log VBLANK INT usability status */
97 	if (si->ps.int_assigned)
98 		LOG(4,("POWERUP: Usable INT assigned to HW; Vblank semaphore enabled\n"));
99 	else
100 		LOG(4,("POWERUP: No (usable) INT assigned to HW; Vblank semaphore disabled\n"));
101 
102 	/* preset no laptop */
103 	si->ps.laptop = false;
104 
105 	/* WARNING:
106 	 * _adi.name_ and _adi.chipset_ can contain 31 readable characters max.!!! */
107 
108 	/* detect card type and power it up */
109 	switch(CFGR(DEVID))
110 	{
111 	/* Vendor Nvidia */
112 	case 0x002010de: /* Nvidia TNT1 */
113 		si->ps.card_type = NV04;
114 		si->ps.card_arch = NV04A;
115 		sprintf(si->adi.name, "Nvidia TNT1");
116 		sprintf(si->adi.chipset, "NV04");
117 		status = nvxx_general_powerup();
118 		break;
119 	case 0x002810de: /* Nvidia TNT2 (pro) */
120 	case 0x002910de: /* Nvidia TNT2 Ultra */
121 	case 0x002a10de: /* Nvidia TNT2 */
122 	case 0x002b10de: /* Nvidia TNT2 */
123 		si->ps.card_type = NV05;
124 		si->ps.card_arch = NV04A;
125 		sprintf(si->adi.name, "Nvidia TNT2");
126 		sprintf(si->adi.chipset, "NV05");
127 		status = nvxx_general_powerup();
128 		break;
129 	case 0x002c10de: /* Nvidia Vanta (Lt) */
130 		si->ps.card_type = NV05;
131 		si->ps.card_arch = NV04A;
132 		sprintf(si->adi.name, "Nvidia Vanta (Lt)");
133 		sprintf(si->adi.chipset, "NV05");
134 		status = nvxx_general_powerup();
135 		break;
136 	case 0x002d10de: /* Nvidia TNT2-M64 (Pro) */
137 		si->ps.card_type = NV05M64;
138 		si->ps.card_arch = NV04A;
139 		sprintf(si->adi.name, "Nvidia TNT2-M64 (Pro)");
140 		sprintf(si->adi.chipset, "NV05 model 64");
141 		status = nvxx_general_powerup();
142 		break;
143 	case 0x002e10de: /* Nvidia NV06 Vanta */
144 	case 0x002f10de: /* Nvidia NV06 Vanta */
145 		si->ps.card_type = NV06;
146 		si->ps.card_arch = NV04A;
147 		sprintf(si->adi.name, "Nvidia Vanta");
148 		sprintf(si->adi.chipset, "NV06");
149 		status = nvxx_general_powerup();
150 		break;
151 	case 0x004010de: /* Nvidia GeForce FX 6800 Ultra */
152 	case 0x004110de: /* Nvidia GeForce FX 6800 */
153 	case 0x004210de: /* Nvidia GeForce FX 6800LE */
154 		si->ps.card_type = NV40;
155 		si->ps.card_arch = NV40A;
156 		sprintf(si->adi.name, "Nvidia GeForce FX 6800");
157 		sprintf(si->adi.chipset, "NV40");
158 		status = nvxx_general_powerup();
159 		break;
160 	case 0x004310de: /* Nvidia GeForce 6800 XE */
161 		si->ps.card_type = NV40;
162 		si->ps.card_arch = NV40A;
163 		sprintf(si->adi.name, "Nvidia GeForce 6800 XE");
164 		sprintf(si->adi.chipset, "NV40");
165 		status = nvxx_general_powerup();
166 		break;
167 	case 0x004510de: /* Nvidia GeForce FX 6800 GT */
168 	case 0x004610de: /* Nvidia GeForce FX 6800 GT */
169 	case 0x004710de: /* Nvidia GeForce FX 6800 GS */
170 	case 0x004810de: /* Nvidia GeForce FX 6800 XT */
171 		si->ps.card_type = NV40;
172 		si->ps.card_arch = NV40A;
173 		sprintf(si->adi.name, "Nvidia GeForce FX 6800");
174 		sprintf(si->adi.chipset, "NV40");
175 		status = nvxx_general_powerup();
176 		break;
177 	case 0x004910de: /* Nvidia unknown FX */
178 		si->ps.card_type = NV40;
179 		si->ps.card_arch = NV40A;
180 		sprintf(si->adi.name, "Nvidia unknown FX");
181 		sprintf(si->adi.chipset, "NV40");
182 		status = nvxx_general_powerup();
183 		break;
184 	case 0x004d10de: /* Nvidia Quadro FX 4400 */
185 	case 0x004e10de: /* Nvidia Quadro FX 4000 */
186 		si->ps.card_type = NV40;
187 		si->ps.card_arch = NV40A;
188 		sprintf(si->adi.name, "Nvidia Quadro FX 4000/4400");
189 		sprintf(si->adi.chipset, "NV40");
190 		status = nvxx_general_powerup();
191 		break;
192 	case 0x009110de: /* Nvidia GeForce 7800 GTX PCIe */
193 	case 0x009210de: /* Nvidia Geforce 7800 GT PCIe */
194 		si->ps.card_type = G70;
195 		si->ps.card_arch = NV40A;
196 		sprintf(si->adi.name, "Nvidia Geforce 7800 GT PCIe");
197 		sprintf(si->adi.chipset, "G70");
198 		status = nvxx_general_powerup();
199 		break;
200 	case 0x009810de: /* Nvidia Geforce 7800 Go PCIe */
201 	case 0x009910de: /* Nvidia Geforce 7800 GTX Go PCIe */
202 		si->ps.card_type = G70;
203 		si->ps.card_arch = NV40A;
204 		si->ps.laptop = true;
205 		sprintf(si->adi.name, "Nvidia Geforce 7800 GTX Go PCIe");
206 		sprintf(si->adi.chipset, "G70");
207 		status = nvxx_general_powerup();
208 		break;
209 	case 0x009d10de: /* Nvidia Quadro FX 4500 */
210 		si->ps.card_type = G70;
211 		si->ps.card_arch = NV40A;
212 		sprintf(si->adi.name, "Nvidia Quadro FX 4500");
213 		sprintf(si->adi.chipset, "G70");
214 		status = nvxx_general_powerup();
215 		break;
216 	case 0x00a010de: /* Nvidia Aladdin TNT2 */
217 		si->ps.card_type = NV05;
218 		si->ps.card_arch = NV04A;
219 		sprintf(si->adi.name, "Nvidia Aladdin TNT2");
220 		sprintf(si->adi.chipset, "NV05");
221 		status = nvxx_general_powerup();
222 		break;
223 	case 0x00c010de: /* Nvidia GeForce 6800 GS */
224 		si->ps.card_type = NV41;
225 		si->ps.card_arch = NV40A;
226 		sprintf(si->adi.name, "Nvidia GeForce 6800 GS");
227 		sprintf(si->adi.chipset, "NV41");
228 		status = nvxx_general_powerup();
229 		break;
230 	case 0x00c110de: /* Nvidia GeForce FX 6800 */
231 	case 0x00c210de: /* Nvidia GeForce FX 6800LE */
232 	case 0x00c310de: /* Nvidia GeForce FX 6800 XT */
233 		si->ps.card_type = NV41;
234 		si->ps.card_arch = NV40A;
235 		sprintf(si->adi.name, "Nvidia GeForce FX 6800");
236 		sprintf(si->adi.chipset, "NV41");
237 		status = nvxx_general_powerup();
238 		break;
239 	case 0x00c810de: /* Nvidia GeForce FX 6800 Go */
240 	case 0x00c910de: /* Nvidia GeForce FX 6800 Ultra Go */
241 		si->ps.card_type = NV41;
242 		si->ps.card_arch = NV40A;
243 		si->ps.laptop = true;
244 		sprintf(si->adi.name, "Nvidia GeForce FX 6800 Go");
245 		sprintf(si->adi.chipset, "NV41");
246 		status = nvxx_general_powerup();
247 		break;
248 	case 0x00cc10de: /* Nvidia Quadro FX 1400 Go */
249 		si->ps.card_type = NV41;
250 		si->ps.card_arch = NV40A;
251 		si->ps.laptop = true;
252 		sprintf(si->adi.name, "Nvidia Quadro FX 1400 Go");
253 		sprintf(si->adi.chipset, "NV41");
254 		status = nvxx_general_powerup();
255 		break;
256 	case 0x00cd10de: /* Nvidia Quadro FX 3450/4000 SDI */
257 		si->ps.card_type = NV41;
258 		si->ps.card_arch = NV40A;
259 		sprintf(si->adi.name, "Nvidia Quadro FX 3450/4000 SDI");
260 		sprintf(si->adi.chipset, "NV41");
261 		status = nvxx_general_powerup();
262 		break;
263 	case 0x00ce10de: /* Nvidia Quadro FX 1400 */
264 		si->ps.card_type = NV41;
265 		si->ps.card_arch = NV40A;
266 		sprintf(si->adi.name, "Nvidia Quadro FX 1400");
267 		sprintf(si->adi.chipset, "NV41");
268 		status = nvxx_general_powerup();
269 		break;
270 	case 0x00f010de: /* Nvidia GeForce FX 6800 (Ultra) AGP(?) */
271 		si->ps.card_type = NV40;
272 		si->ps.card_arch = NV40A;
273 		sprintf(si->adi.name, "Nvidia GeForce FX 6800 AGP(?)");
274 		sprintf(si->adi.chipset, "NV40(?)");
275 		status = nvxx_general_powerup();
276 		break;
277 	case 0x00f110de: /* Nvidia GeForce FX 6600 GT AGP */
278 	case 0x00f210de: /* Nvidia GeForce FX 6600 AGP */
279 		si->ps.card_type = NV43;
280 		si->ps.card_arch = NV40A;
281 		sprintf(si->adi.name, "Nvidia GeForce FX 6600 (GT) AGP");
282 		sprintf(si->adi.chipset, "NV43");
283 		status = nvxx_general_powerup();
284 		break;
285 	case 0x00f310de: /* Nvidia GeForce 6200 */
286 		si->ps.card_type = NV44;
287 		si->ps.card_arch = NV40A;
288 		sprintf(si->adi.name, "Nvidia GeForce 6200");
289 		sprintf(si->adi.chipset, "NV44");
290 		status = nvxx_general_powerup();
291 		break;
292 	case 0x00f410de: /* Nvidia GeForce 6600 LE */
293 		si->ps.card_type = NV43;
294 		si->ps.card_arch = NV40A;
295 		sprintf(si->adi.name, "Nvidia GeForce 6600 LE");
296 		sprintf(si->adi.chipset, "NV43");
297 		status = nvxx_general_powerup();
298 		break;
299 	case 0x00f510de: /* Nvidia GeForce FX 7800 GS AGP */
300 		si->ps.card_type = G70;
301 		si->ps.card_arch = NV40A;
302 		sprintf(si->adi.name, "Nvidia GeForce 7800 GS AGP");
303 		sprintf(si->adi.chipset, "G70");
304 		status = nvxx_general_powerup();
305 		break;
306 	case 0x00f610de: /* Nvidia GeForce 6800 GS */
307 		si->ps.card_type = NV43;
308 		si->ps.card_arch = NV40A;
309 		sprintf(si->adi.name, "Nvidia GeForce 6800 GS");
310 		sprintf(si->adi.chipset, "NV43");
311 		status = nvxx_general_powerup();
312 		break;
313 	case 0x00f810de: /* Nvidia Quadro FX 3400/4400 PCIe */
314 		si->ps.card_type = NV45;
315 		si->ps.card_arch = NV40A;
316 		sprintf(si->adi.name, "Nvidia Quadro FX 3400 PCIe");
317 		sprintf(si->adi.chipset, "NV45");
318 		status = nvxx_general_powerup();
319 		break;
320 	case 0x00f910de: /* Nvidia GeForce PCX 6800 PCIe */
321 		si->ps.card_type = NV45;
322 		si->ps.card_arch = NV40A;
323 		sprintf(si->adi.name, "Nvidia GeForce PCX 6800 PCIe");
324 		sprintf(si->adi.chipset, "NV45");
325 		status = nvxx_general_powerup();
326 		break;
327 	case 0x00fa10de: /* Nvidia GeForce PCX 5750 PCIe */
328 		si->ps.card_type = NV36;
329 		si->ps.card_arch = NV30A;
330 		sprintf(si->adi.name, "Nvidia GeForce PCX 5750 PCIe");
331 		sprintf(si->adi.chipset, "NV36");
332 		status = nvxx_general_powerup();
333 		break;
334 	case 0x00fb10de: /* Nvidia GeForce PCX 5900 PCIe */
335 		si->ps.card_type = NV35;
336 		si->ps.card_arch = NV30A;
337 		sprintf(si->adi.name, "Nvidia GeForce PCX 5900 PCIe");
338 		sprintf(si->adi.chipset, "NV35(?)");
339 		status = nvxx_general_powerup();
340 		break;
341 	case 0x00fc10de: /* Nvidia GeForce PCX 5300 PCIe */
342 		si->ps.card_type = NV34;
343 		si->ps.card_arch = NV30A;
344 		sprintf(si->adi.name, "Nvidia GeForce PCX 5300 PCIe");
345 		sprintf(si->adi.chipset, "NV34");
346 		status = nvxx_general_powerup();
347 		break;
348 	case 0x00fd10de: /* Nvidia Quadro PCX PCIe */
349 		si->ps.card_type = NV45;
350 		si->ps.card_arch = NV40A;
351 		sprintf(si->adi.name, "Nvidia Quadro PCX PCIe");
352 		sprintf(si->adi.chipset, "NV45");
353 		status = nvxx_general_powerup();
354 		break;
355 	case 0x00fe10de: /* Nvidia Quadro FX 1300 PCIe(?) */
356 		si->ps.card_type = NV36;
357 		si->ps.card_arch = NV30A;
358 		sprintf(si->adi.name, "Nvidia Quadro FX 1300 PCIe(?)");
359 		sprintf(si->adi.chipset, "NV36(?)");
360 		status = nvxx_general_powerup();
361 		break;
362 	case 0x00ff10de: /* Nvidia GeForce PCX 4300 PCIe */
363 		si->ps.card_type = NV18;
364 		si->ps.card_arch = NV10A;
365 		sprintf(si->adi.name, "Nvidia GeForce PCX 4300 PCIe");
366 		sprintf(si->adi.chipset, "NV18");
367 		status = nvxx_general_powerup();
368 		break;
369 	case 0x010010de: /* Nvidia GeForce256 SDR */
370 	case 0x010110de: /* Nvidia GeForce256 DDR */
371 	case 0x010210de: /* Nvidia GeForce256 Ultra */
372 		si->ps.card_type = NV10;
373 		si->ps.card_arch = NV10A;
374 		sprintf(si->adi.name, "Nvidia GeForce256");
375 		sprintf(si->adi.chipset, "NV10");
376 		status = nvxx_general_powerup();
377 		break;
378 	case 0x010310de: /* Nvidia Quadro */
379 		si->ps.card_type = NV10;
380 		si->ps.card_arch = NV10A;
381 		sprintf(si->adi.name, "Nvidia Quadro");
382 		sprintf(si->adi.chipset, "NV10");
383 		status = nvxx_general_powerup();
384 		break;
385 	case 0x011010de: /* Nvidia GeForce2 MX/MX400 */
386 	case 0x011110de: /* Nvidia GeForce2 MX100/MX200 DDR */
387 		si->ps.card_type = NV11;
388 		si->ps.card_arch = NV10A;
389 		sprintf(si->adi.name, "Nvidia GeForce2 MX");
390 		sprintf(si->adi.chipset, "NV11");
391 		status = nvxx_general_powerup();
392 		break;
393 	case 0x011210de: /* Nvidia GeForce2 Go */
394 		si->ps.card_type = NV11;
395 		si->ps.card_arch = NV10A;
396 		si->ps.laptop = true;
397 		sprintf(si->adi.name, "Nvidia GeForce2 Go");
398 		sprintf(si->adi.chipset, "NV11");
399 		status = nvxx_general_powerup();
400 		break;
401 	case 0x011310de: /* Nvidia Quadro2 MXR/EX/Go */
402 		si->ps.card_type = NV11;
403 		si->ps.card_arch = NV10A;
404 		sprintf(si->adi.name, "Nvidia Quadro2 MXR/EX/Go");
405 		sprintf(si->adi.chipset, "NV11");
406 		status = nvxx_general_powerup();
407 		break;
408 	case 0x014010de: /* Nvidia GeForce FX 6600 GT */
409 	case 0x014110de: /* Nvidia GeForce FX 6600 */
410 	case 0x014210de: /* Nvidia GeForce FX 6600LE */
411 		si->ps.card_type = NV43;
412 		si->ps.card_arch = NV40A;
413 		sprintf(si->adi.name, "Nvidia GeForce FX 6600");
414 		sprintf(si->adi.chipset, "NV43");
415 		status = nvxx_general_powerup();
416 		break;
417 	case 0x014310de: /* Nvidia GeForce 6600 VE */
418 		si->ps.card_type = NV43;
419 		si->ps.card_arch = NV40A;
420 		sprintf(si->adi.name, "Nvidia GeForce 6600 VE");
421 		sprintf(si->adi.chipset, "NV43");
422 		status = nvxx_general_powerup();
423 		break;
424 	case 0x014410de: /* Nvidia GeForce FX 6600 Go */
425 		si->ps.card_type = NV43;
426 		si->ps.card_arch = NV40A;
427 		si->ps.laptop = true;
428 		sprintf(si->adi.name, "Nvidia GeForce FX 6600 Go");
429 		sprintf(si->adi.chipset, "NV43");
430 		status = nvxx_general_powerup();
431 		break;
432 	case 0x014510de: /* Nvidia GeForce FX 6610 XL */
433 		si->ps.card_type = NV43;
434 		si->ps.card_arch = NV40A;
435 		sprintf(si->adi.name, "Nvidia GeForce FX 6610 XL");
436 		sprintf(si->adi.chipset, "NV43");
437 		status = nvxx_general_powerup();
438 		break;
439 	case 0x014710de: /* Nvidia GeForce FX 6700 XL */
440 		si->ps.card_type = NV43;
441 		si->ps.card_arch = NV40A;
442 		sprintf(si->adi.name, "Nvidia GeForce FX 6700 XL");
443 		sprintf(si->adi.chipset, "NV43");
444 		status = nvxx_general_powerup();
445 		break;
446 	case 0x014610de: /* Nvidia GeForce FX 6600 TE Go / 6200 TE Go */
447 	case 0x014810de: /* Nvidia GeForce FX 6600 Go */
448 	case 0x014910de: /* Nvidia GeForce FX 6600 GT Go */
449 		si->ps.card_type = NV43;
450 		si->ps.card_arch = NV40A;
451 		si->ps.laptop = true;
452 		sprintf(si->adi.name, "Nvidia GeForce FX 6600Go/6200Go");
453 		sprintf(si->adi.chipset, "NV43");
454 		status = nvxx_general_powerup();
455 		break;
456 	case 0x014b10de: /* Nvidia unknown FX */
457 	case 0x014c10de: /* Nvidia Quadro FX 540 MXM */
458 	case 0x014d10de: /* Nvidia unknown FX */
459 		si->ps.card_type = NV43;
460 		si->ps.card_arch = NV40A;
461 		sprintf(si->adi.name, "Nvidia Quadro FX");
462 		sprintf(si->adi.chipset, "NV43");
463 		status = nvxx_general_powerup();
464 		break;
465 	case 0x014e10de: /* Nvidia Quadro FX 540 */
466 		si->ps.card_type = NV43;
467 		si->ps.card_arch = NV40A;
468 		sprintf(si->adi.name, "Nvidia Quadro FX 540");
469 		sprintf(si->adi.chipset, "NV43");
470 		status = nvxx_general_powerup();
471 		break;
472 	case 0x014f10de: /* Nvidia GeForce 6200 PCIe (128Mb) */
473 		si->ps.card_type = NV44;
474 		si->ps.card_arch = NV40A;
475 		sprintf(si->adi.name, "Nvidia GeForce 6200 PCIe 128Mb");
476 		sprintf(si->adi.chipset, "NV44");
477 		status = nvxx_general_powerup();
478 		break;
479 	case 0x015010de: /* Nvidia GeForce2 GTS/Pro */
480 	case 0x015110de: /* Nvidia GeForce2 Ti DDR */
481 	case 0x015210de: /* Nvidia GeForce2 Ultra */
482 		si->ps.card_type = NV15;
483 		si->ps.card_arch = NV10A;
484 		sprintf(si->adi.name, "Nvidia GeForce2");
485 		sprintf(si->adi.chipset, "NV15");
486 		status = nvxx_general_powerup();
487 		break;
488 	case 0x015310de: /* Nvidia Quadro2 Pro */
489 		si->ps.card_type = NV15;
490 		si->ps.card_arch = NV10A;
491 		sprintf(si->adi.name, "Nvidia Quadro2 Pro");
492 		sprintf(si->adi.chipset, "NV15");
493 		status = nvxx_general_powerup();
494 		break;
495 	case 0x016010de: /* Nvidia GeForce 6500 Go */
496 		si->ps.card_type = NV44;
497 		si->ps.card_arch = NV40A;
498 		si->ps.laptop = true;
499 		sprintf(si->adi.name, "Nvidia GeForce 6500 Go");
500 		sprintf(si->adi.chipset, "NV44");
501 		status = nvxx_general_powerup();
502 		break;
503 	case 0x016110de: /* Nvidia GeForce 6200 TurboCache */
504 		si->ps.card_type = NV44;
505 		si->ps.card_arch = NV40A;
506 		sprintf(si->adi.name, "Nvidia GeForce 6200 TC");
507 		sprintf(si->adi.chipset, "NV44");
508 		status = nvxx_general_powerup();
509 		break;
510 	case 0x016210de: /* Nvidia GeForce 6200SE TurboCache */
511 		si->ps.card_type = NV44;
512 		si->ps.card_arch = NV40A;
513 		sprintf(si->adi.name, "Nvidia GeForce 6200SE TC");
514 		sprintf(si->adi.chipset, "NV44");
515 		status = nvxx_general_powerup();
516 		break;
517 	case 0x016310de: /* Nvidia GeForce 6200LE */
518 		si->ps.card_type = NV44;
519 		si->ps.card_arch = NV40A;
520 		sprintf(si->adi.name, "Nvidia GeForce 6200LE");
521 		sprintf(si->adi.chipset, "NV44");
522 		status = nvxx_general_powerup();
523 		break;
524 	case 0x016410de: /* Nvidia GeForce FX 6200 Go */
525 		si->ps.card_type = NV44;
526 		si->ps.card_arch = NV40A;
527 		si->ps.laptop = true;
528 		sprintf(si->adi.name, "Nvidia GeForce FX 6200 Go");
529 		sprintf(si->adi.chipset, "NV44");
530 		status = nvxx_general_powerup();
531 		break;
532 	case 0x016510de: /* Nvidia Quadro FX NVS 285 */
533 		si->ps.card_type = NV44;
534 		si->ps.card_arch = NV40A;
535 		sprintf(si->adi.name, "Nvidia Quadro FX NVS 285");
536 		sprintf(si->adi.chipset, "NV44");
537 		status = nvxx_general_powerup();
538 		break;
539 	case 0x016610de: /* Nvidia GeForce 6400 Go */
540 		si->ps.card_type = NV44;
541 		si->ps.card_arch = NV40A;
542 		si->ps.laptop = true;
543 		sprintf(si->adi.name, "Nvidia GeForce 6400 Go");
544 		sprintf(si->adi.chipset, "NV44");
545 		status = nvxx_general_powerup();
546 		break;
547 	case 0x016710de: /* Nvidia GeForce 6200 Go */
548 		si->ps.card_type = NV44;
549 		si->ps.card_arch = NV40A;
550 		si->ps.laptop = true;
551 		sprintf(si->adi.name, "Nvidia GeForce 6200 Go");
552 		sprintf(si->adi.chipset, "NV44");
553 		status = nvxx_general_powerup();
554 		break;
555 	case 0x016810de: /* Nvidia GeForce 6400 Go */
556 		si->ps.card_type = NV44;
557 		si->ps.card_arch = NV40A;
558 		si->ps.laptop = true;
559 		sprintf(si->adi.name, "Nvidia GeForce 6400 Go");
560 		sprintf(si->adi.chipset, "NV44");
561 		status = nvxx_general_powerup();
562 		break;
563 	case 0x016910de: /* Nvidia GeForce 6250 Go */
564 		si->ps.card_type = NV44;
565 		si->ps.card_arch = NV40A;
566 		si->ps.laptop = true;
567 		sprintf(si->adi.name, "Nvidia GeForce 6250 Go");
568 		sprintf(si->adi.chipset, "NV44");
569 		status = nvxx_general_powerup();
570 		break;
571 	case 0x016a10de: /* Nvidia 7100 GS */
572 		si->ps.card_type = NV44;
573 		si->ps.card_arch = NV40A;
574 		sprintf(si->adi.name, "Nvidia GeForce 7100 GS");
575 		sprintf(si->adi.chipset, "NV44");
576 		status = nvxx_general_powerup();
577 		break;
578 	case 0x016b10de: /* Nvidia unknown FX Go */
579 	case 0x016c10de: /* Nvidia unknown FX Go */
580 	case 0x016d10de: /* Nvidia unknown FX Go */
581 		si->ps.card_type = NV44;
582 		si->ps.card_arch = NV40A;
583 		si->ps.laptop = true;
584 		sprintf(si->adi.name, "Nvidia unknown FX Go");
585 		sprintf(si->adi.chipset, "NV44");
586 		status = nvxx_general_powerup();
587 		break;
588 	case 0x016e10de: /* Nvidia unknown FX */
589 		si->ps.card_type = NV44;
590 		si->ps.card_arch = NV40A;
591 		sprintf(si->adi.name, "Nvidia unknown FX");
592 		sprintf(si->adi.chipset, "NV44");
593 		status = nvxx_general_powerup();
594 		break;
595 	case 0x017010de: /* Nvidia GeForce4 MX 460 */
596 	case 0x017110de: /* Nvidia GeForce4 MX 440 */
597 	case 0x017210de: /* Nvidia GeForce4 MX 420 */
598 	case 0x017310de: /* Nvidia GeForce4 MX 440SE */
599 		si->ps.card_type = NV17;
600 		si->ps.card_arch = NV10A;
601 		sprintf(si->adi.name, "Nvidia GeForce4 MX");
602 		sprintf(si->adi.chipset, "NV17");
603 		status = nvxx_general_powerup();
604 		break;
605 	case 0x017410de: /* Nvidia GeForce4 440 Go */
606 	case 0x017510de: /* Nvidia GeForce4 420 Go */
607 	case 0x017610de: /* Nvidia GeForce4 420 Go 32M */
608 	case 0x017710de: /* Nvidia GeForce4 460 Go */
609 	case 0x017910de: /* Nvidia GeForce4 440 Go 64M (on PPC GeForce4 MX) */
610 		si->ps.card_type = NV17;
611 		si->ps.card_arch = NV10A;
612 		si->ps.laptop = true;
613 		sprintf(si->adi.name, "Nvidia GeForce4 Go");
614 		sprintf(si->adi.chipset, "NV17");
615 		status = nvxx_general_powerup();
616 		break;
617 	case 0x017810de: /* Nvidia Quadro4 500 XGL/550 XGL */
618 	case 0x017a10de: /* Nvidia Quadro4 200 NVS/400 NVS */
619 		si->ps.card_type = NV17;
620 		si->ps.card_arch = NV10A;
621 		sprintf(si->adi.name, "Nvidia Quadro4");
622 		sprintf(si->adi.chipset, "NV17");
623 		status = nvxx_general_powerup();
624 		break;
625 	case 0x017c10de: /* Nvidia Quadro4 500 GoGL */
626 		si->ps.card_type = NV17;
627 		si->ps.card_arch = NV10A;
628 		si->ps.laptop = true;
629 		sprintf(si->adi.name, "Nvidia Quadro4 500 GoGL");
630 		sprintf(si->adi.chipset, "NV17");
631 		status = nvxx_general_powerup();
632 		break;
633 	case 0x017d10de: /* Nvidia GeForce4 410 Go 16M*/
634 		si->ps.card_type = NV17;
635 		si->ps.card_arch = NV10A;
636 		si->ps.laptop = true;
637 		sprintf(si->adi.name, "Nvidia GeForce4 410 Go");
638 		sprintf(si->adi.chipset, "NV17");
639 		status = nvxx_general_powerup();
640 		break;
641 	case 0x018110de: /* Nvidia GeForce4 MX 440 AGP8X */
642 	case 0x018210de: /* Nvidia GeForce4 MX 440SE AGP8X */
643 	case 0x018310de: /* Nvidia GeForce4 MX 420 AGP8X */
644 	case 0x018510de: /* Nvidia GeForce4 MX 4000 AGP8X */
645 		si->ps.card_type = NV18;
646 		si->ps.card_arch = NV10A;
647 		sprintf(si->adi.name, "Nvidia GeForce4 MX AGP8X");
648 		sprintf(si->adi.chipset, "NV18");
649 		status = nvxx_general_powerup();
650 		break;
651 	case 0x018610de: /* Nvidia GeForce4 448 Go */
652 	case 0x018710de: /* Nvidia GeForce4 488 Go */
653 		si->ps.card_type = NV18;
654 		si->ps.card_arch = NV10A;
655 		si->ps.laptop = true;
656 		sprintf(si->adi.name, "Nvidia GeForce4 Go");
657 		sprintf(si->adi.chipset, "NV18");
658 		status = nvxx_general_powerup();
659 		break;
660 	case 0x018810de: /* Nvidia Quadro4 580 XGL */
661 		si->ps.card_type = NV18;
662 		si->ps.card_arch = NV10A;
663 		sprintf(si->adi.name, "Nvidia Quadro4");
664 		sprintf(si->adi.chipset, "NV18");
665 		status = nvxx_general_powerup();
666 		break;
667 	case 0x018910de: /* Nvidia GeForce4 MX AGP8X (PPC) */
668 		si->ps.card_type = NV18;
669 		si->ps.card_arch = NV10A;
670 		sprintf(si->adi.name, "Nvidia GeForce4 MX AGP8X");
671 		sprintf(si->adi.chipset, "NV18");
672 		status = nvxx_general_powerup();
673 		break;
674 	case 0x018a10de: /* Nvidia Quadro4 280 NVS AGP8X */
675 	case 0x018b10de: /* Nvidia Quadro4 380 XGL */
676 	case 0x018c10de: /* Nvidia Quadro4 NVS 50 PCI */
677 		si->ps.card_type = NV18;
678 		si->ps.card_arch = NV10A;
679 		sprintf(si->adi.name, "Nvidia Quadro4");
680 		sprintf(si->adi.chipset, "NV18");
681 		status = nvxx_general_powerup();
682 		break;
683 	case 0x018d10de: /* Nvidia GeForce4 448 Go */
684 		si->ps.card_type = NV18;
685 		si->ps.card_arch = NV10A;
686 		si->ps.laptop = true;
687 		sprintf(si->adi.name, "Nvidia GeForce4 Go");
688 		sprintf(si->adi.chipset, "NV18");
689 		status = nvxx_general_powerup();
690 		break;
691 	case 0x019110de: /* Nvidia GeForce 8800 GTX */
692 	case 0x019310de: /* Nvidia GeForce 8800 GTS */
693 		si->ps.card_type = G80;
694 		si->ps.card_arch = NV50A;
695 		sprintf(si->adi.name, "Nvidia GeForce 8800");
696 		sprintf(si->adi.chipset, "G80");
697 		status = nvxx_general_powerup();
698 		break;
699 	case 0x01a010de: /* Nvidia GeForce2 Integrated GPU */
700 		si->ps.card_type = NV11;
701 		si->ps.card_arch = NV10A;
702 		sprintf(si->adi.name, "Nvidia GeForce2 Integrated GPU");
703 		sprintf(si->adi.chipset, "CRUSH, NV11");
704 		status = nvxx_general_powerup();
705 		break;
706 	case 0x01d110de: /* Nvidia GeForce 7300 LE */
707 	case 0x01d310de: /* Nvidia GeForce 7300 SE */
708 	case 0x01df10de: /* Nvidia GeForce 7300 GS */
709 		si->ps.card_type = G72;
710 		si->ps.card_arch = NV40A;
711 		sprintf(si->adi.name, "Nvidia GeForce 7300");
712 		sprintf(si->adi.chipset, "G72");
713 		status = nvxx_general_powerup();
714 		break;
715 	case 0x01d810de: /* Nvidia GeForce 7400 GO */
716 		si->ps.card_type = G72;
717 		si->ps.card_arch = NV40A;
718 		sprintf(si->adi.name, "Nvidia GeForce 7400 Go");
719 		sprintf(si->adi.chipset, "G72");
720 		status = nvxx_general_powerup();
721 		break;
722 	case 0x01dd10de: /* Nvidia GeForce 7500 LE */
723 		si->ps.card_type = G72;
724 		si->ps.card_arch = NV40A;
725 		sprintf(si->adi.name, "Nvidia GeForce 7500 LE");
726 		sprintf(si->adi.chipset, "G72");
727 		status = nvxx_general_powerup();
728 		break;
729 	case 0x01f010de: /* Nvidia GeForce4 MX Integrated GPU */
730 		si->ps.card_type = NV17;
731 		si->ps.card_arch = NV10A;
732 		sprintf(si->adi.name, "Nvidia GeForce4 MX Integr. GPU");
733 		sprintf(si->adi.chipset, "NFORCE2, NV17");
734 		status = nvxx_general_powerup();
735 		break;
736 	case 0x020010de: /* Nvidia GeForce3 */
737 	case 0x020110de: /* Nvidia GeForce3 Ti 200 */
738 	case 0x020210de: /* Nvidia GeForce3 Ti 500 */
739 		si->ps.card_type = NV20;
740 		si->ps.card_arch = NV20A;
741 		sprintf(si->adi.name, "Nvidia GeForce3");
742 		sprintf(si->adi.chipset, "NV20");
743 		status = nvxx_general_powerup();
744 		break;
745 	case 0x020310de: /* Nvidia Quadro DCC */
746 		si->ps.card_type = NV20;
747 		si->ps.card_arch = NV20A;
748 		sprintf(si->adi.name, "Nvidia Quadro DCC");
749 		sprintf(si->adi.chipset, "NV20");
750 		status = nvxx_general_powerup();
751 		break;
752 	case 0x021110de: /* Nvidia GeForce FX 6800 */
753 	case 0x021210de: /* Nvidia GeForce FX 6800LE */
754 	case 0x021510de: /* Nvidia GeForce FX 6800 GT */
755 		si->ps.card_type = NV45; /* NV48 is NV45 with 512Mb */
756 		si->ps.card_arch = NV40A;
757 		sprintf(si->adi.name, "Nvidia GeForce FX 6800");
758 		sprintf(si->adi.chipset, "NV48");
759 		status = nvxx_general_powerup();
760 		break;
761 	case 0x021810de: /* Nvidia GeForce 6800 XT */
762 		si->ps.card_type = NV40;
763 		si->ps.card_arch = NV40A;
764 		sprintf(si->adi.name, "Nvidia GeForce 6800 XT");
765 		sprintf(si->adi.chipset, "NV40");
766 		status = nvxx_general_powerup();
767 		break;
768 	case 0x022010de: /* Nvidia unknown FX */
769 		si->ps.card_type = NV44;
770 		si->ps.card_arch = NV40A;
771 		sprintf(si->adi.name, "Nvidia unknown FX");
772 		sprintf(si->adi.chipset, "NV44");
773 		status = nvxx_general_powerup();
774 		break;
775 	case 0x022110de: /* Nvidia GeForce 6200 AGP (256Mb - 128bit) */
776 		si->ps.card_type = NV44;
777 		si->ps.card_arch = NV40A;
778 		sprintf(si->adi.name, "Nvidia GeForce 6200 AGP 256Mb");
779 		sprintf(si->adi.chipset, "NV44");
780 		status = nvxx_general_powerup();
781 		break;
782 	case 0x022210de: /* Nvidia unknown FX */
783 		si->ps.card_type = NV44;
784 		si->ps.card_arch = NV40A;
785 		sprintf(si->adi.name, "Nvidia unknown FX");
786 		sprintf(si->adi.chipset, "NV44");
787 		status = nvxx_general_powerup();
788 		break;
789 	case 0x022810de: /* Nvidia unknown FX Go */
790 		si->ps.card_type = NV44;
791 		si->ps.card_arch = NV40A;
792 		si->ps.laptop = true;
793 		sprintf(si->adi.name, "Nvidia unknown FX Go");
794 		sprintf(si->adi.chipset, "NV44");
795 		status = nvxx_general_powerup();
796 		break;
797 	case 0x024010de: /* Nvidia GeForce 6150 (NFORCE4 Integr.GPU) */
798 	case 0x024110de: /* Nvidia GeForce 6150 LE (NFORCE4 Integr.GPU) */
799 		si->ps.card_type = NV44;
800 		si->ps.card_arch = NV40A;
801 		sprintf(si->adi.name, "Nvidia GeForce 6150");
802 		sprintf(si->adi.chipset, "NV44");
803 		status = nvxx_general_powerup();
804 		break;
805 	case 0x024210de: /* Nvidia GeForce 6100 (NFORCE4 Integr.GPU) */
806 		si->ps.card_type = NV44;
807 		si->ps.card_arch = NV40A;
808 		sprintf(si->adi.name, "Nvidia GeForce 6100");
809 		sprintf(si->adi.chipset, "NV44");
810 		status = nvxx_general_powerup();
811 		break;
812 	case 0x024510de: /* Nvidia Quadro NVS 210S / NVIDIA GeForce 6150LE (NFORCE4 Integr.GPU) */
813 		si->ps.card_type = NV44;
814 		si->ps.card_arch = NV40A;
815 		sprintf(si->adi.name, "Nvidia GeForce 6150");
816 		sprintf(si->adi.chipset, "NV44");
817 		status = nvxx_general_powerup();
818 		break;
819 	case 0x025010de: /* Nvidia GeForce4 Ti 4600 */
820 	case 0x025110de: /* Nvidia GeForce4 Ti 4400 */
821 	case 0x025210de: /* Nvidia GeForce4 Ti 4600 */
822 	case 0x025310de: /* Nvidia GeForce4 Ti 4200 */
823 		si->ps.card_type = NV25;
824 		si->ps.card_arch = NV20A;
825 		sprintf(si->adi.name, "Nvidia GeForce4 Ti");
826 		sprintf(si->adi.chipset, "NV25");
827 		status = nvxx_general_powerup();
828 		break;
829 	case 0x025810de: /* Nvidia Quadro4 900 XGL */
830 	case 0x025910de: /* Nvidia Quadro4 750 XGL */
831 	case 0x025b10de: /* Nvidia Quadro4 700 XGL */
832 		si->ps.card_type = NV25;
833 		si->ps.card_arch = NV20A;
834 		sprintf(si->adi.name, "Nvidia Quadro4 XGL");
835 		sprintf(si->adi.chipset, "NV25");
836 		status = nvxx_general_powerup();
837 		break;
838 	case 0x028010de: /* Nvidia GeForce4 Ti 4800 AGP8X */
839 	case 0x028110de: /* Nvidia GeForce4 Ti 4200 AGP8X */
840 		si->ps.card_type = NV28;
841 		si->ps.card_arch = NV20A;
842 		sprintf(si->adi.name, "Nvidia GeForce4 Ti AGP8X");
843 		sprintf(si->adi.chipset, "NV28");
844 		status = nvxx_general_powerup();
845 		break;
846 	case 0x028210de: /* Nvidia GeForce4 Ti 4800SE */
847 		si->ps.card_type = NV28;
848 		si->ps.card_arch = NV20A;
849 		sprintf(si->adi.name, "Nvidia GeForce4 Ti 4800SE");
850 		sprintf(si->adi.chipset, "NV28");
851 		status = nvxx_general_powerup();
852 		break;
853 	case 0x028610de: /* Nvidia GeForce4 4200 Go */
854 		si->ps.card_type = NV28;
855 		si->ps.card_arch = NV20A;
856 		si->ps.laptop = true;
857 		sprintf(si->adi.name, "Nvidia GeForce4 4200 Go");
858 		sprintf(si->adi.chipset, "NV28");
859 		status = nvxx_general_powerup();
860 		break;
861 	case 0x028810de: /* Nvidia Quadro4 980 XGL */
862 	case 0x028910de: /* Nvidia Quadro4 780 XGL */
863 		si->ps.card_type = NV28;
864 		si->ps.card_arch = NV20A;
865 		sprintf(si->adi.name, "Nvidia Quadro4 XGL");
866 		sprintf(si->adi.chipset, "NV28");
867 		status = nvxx_general_powerup();
868 		break;
869 	case 0x028c10de: /* Nvidia Quadro4 700 GoGL */
870 		si->ps.card_type = NV28;
871 		si->ps.card_arch = NV20A;
872 		si->ps.laptop = true;
873 		sprintf(si->adi.name, "Nvidia Quadro4 700 GoGL");
874 		sprintf(si->adi.chipset, "NV28");
875 		status = nvxx_general_powerup();
876 		break;
877 	case 0x029010de: /* Nvidia GeForce 7900 GTX */
878 	case 0x029110de: /* Nvidia GeForce 7900 GT */
879 	case 0x029310de: /* Nvidia GeForce 7900 GX2 */
880 		si->ps.card_type = G71;
881 		si->ps.card_arch = NV40A;
882 		sprintf(si->adi.name, "Nvidia GeForce 7900");
883 		sprintf(si->adi.chipset, "G71");
884 		status = nvxx_general_powerup();
885 		break;
886 	case 0x029410de: /* Nvidia GeForce 7950 GX2 */
887 	case 0x029510de: /* Nvidia GeForce 7950 GT */
888 		si->ps.card_type = G71;
889 		si->ps.card_arch = NV40A;
890 		sprintf(si->adi.name, "Nvidia GeForce 7950");
891 		sprintf(si->adi.chipset, "G71");
892 		status = nvxx_general_powerup();
893 		break;
894 	case 0x029810de: /* Nvidia GeForce Go 7900 GS */
895 	case 0x029910de: /* Nvidia GeForce Go 7900 GTX */
896 		si->ps.card_type = G71;
897 		si->ps.card_arch = NV40A;
898 		si->ps.laptop = true;
899 		sprintf(si->adi.name, "Nvidia GeForce Go 7900");
900 		sprintf(si->adi.chipset, "G71");
901 		status = nvxx_general_powerup();
902 		break;
903 	case 0x029c10de: /* Nvidia Quadro FX 5500 */
904 		si->ps.card_type = G71;
905 		si->ps.card_arch = NV40A;
906 		sprintf(si->adi.name, "Nvidia Quadro FX 5500");
907 		sprintf(si->adi.chipset, "G71");
908 		status = nvxx_general_powerup();
909 		break;
910 	case 0x029f10de: /* Nvidia Quadro FX 4500 X2 */
911 		si->ps.card_type = G70;
912 		si->ps.card_arch = NV40A;
913 		sprintf(si->adi.name, "Nvidia Quadro FX 4500 X2");
914 		sprintf(si->adi.chipset, "G70");
915 		status = nvxx_general_powerup();
916 		break;
917 	case 0x02a010de: /* Nvidia GeForce3 Integrated GPU */
918 		si->ps.card_type = NV20;
919 		si->ps.card_arch = NV20A;
920 		sprintf(si->adi.name, "Nvidia GeForce3 Integrated GPU");
921 		sprintf(si->adi.chipset, "XBOX, NV20");
922 		status = nvxx_general_powerup();
923 		break;
924 	case 0x02e110de:
925 		si->ps.card_type = G73;
926 		si->ps.card_arch = NV40A;
927 		sprintf(si->adi.name, "Nvidia GeForce 7600 GS");
928 		sprintf(si->adi.chipset, "G73");
929 		status = nvxx_general_powerup();
930 		break;
931 	case 0x030110de: /* Nvidia GeForce FX 5800 Ultra */
932 	case 0x030210de: /* Nvidia GeForce FX 5800 */
933 		si->ps.card_type = NV30;
934 		si->ps.card_arch = NV30A;
935 		sprintf(si->adi.name, "Nvidia GeForce FX 5800");
936 		sprintf(si->adi.chipset, "NV30");
937 		status = nvxx_general_powerup();
938 		break;
939 	case 0x030810de: /* Nvidia Quadro FX 2000 */
940 	case 0x030910de: /* Nvidia Quadro FX 1000 */
941 		si->ps.card_type = NV30;
942 		si->ps.card_arch = NV30A;
943 		sprintf(si->adi.name, "Nvidia Quadro FX");
944 		sprintf(si->adi.chipset, "NV30");
945 		status = nvxx_general_powerup();
946 		break;
947 	case 0x031110de: /* Nvidia GeForce FX 5600 Ultra */
948 	case 0x031210de: /* Nvidia GeForce FX 5600 */
949 		si->ps.card_type = NV31;
950 		si->ps.card_arch = NV30A;
951 		sprintf(si->adi.name, "Nvidia GeForce FX 5600");
952 		sprintf(si->adi.chipset, "NV31");
953 		status = nvxx_general_powerup();
954 		break;
955 	case 0x031310de: /* Nvidia unknown FX */
956 		si->ps.card_type = NV31;
957 		si->ps.card_arch = NV30A;
958 		sprintf(si->adi.name, "Nvidia unknown FX");
959 		sprintf(si->adi.chipset, "NV31");
960 		status = nvxx_general_powerup();
961 		break;
962 	case 0x031410de: /* Nvidia GeForce FX 5600XT */
963 		si->ps.card_type = NV31;
964 		si->ps.card_arch = NV30A;
965 		sprintf(si->adi.name, "Nvidia GeForce FX 5600XT");
966 		sprintf(si->adi.chipset, "NV31");
967 		status = nvxx_general_powerup();
968 		break;
969 	case 0x031610de: /* Nvidia unknown FX Go */
970 	case 0x031710de: /* Nvidia unknown FX Go */
971 		si->ps.card_type = NV31;
972 		si->ps.card_arch = NV30A;
973 		si->ps.laptop = true;
974 		sprintf(si->adi.name, "Nvidia unknown FX Go");
975 		sprintf(si->adi.chipset, "NV31");
976 		status = nvxx_general_powerup();
977 		break;
978 	case 0x031a10de: /* Nvidia GeForce FX 5600 Go */
979 		si->ps.card_type = NV31;
980 		si->ps.card_arch = NV30A;
981 		si->ps.laptop = true;
982 		sprintf(si->adi.name, "Nvidia GeForce FX 5600 Go");
983 		sprintf(si->adi.chipset, "NV31");
984 		status = nvxx_general_powerup();
985 		break;
986 	case 0x031b10de: /* Nvidia GeForce FX 5650 Go */
987 		si->ps.card_type = NV31;
988 		si->ps.card_arch = NV30A;
989 		si->ps.laptop = true;
990 		sprintf(si->adi.name, "Nvidia GeForce FX 5650 Go");
991 		sprintf(si->adi.chipset, "NV31");
992 		status = nvxx_general_powerup();
993 		break;
994 	case 0x031c10de: /* Nvidia Quadro FX 700 Go */
995 		si->ps.card_type = NV31;
996 		si->ps.card_arch = NV30A;
997 		si->ps.laptop = true;
998 		sprintf(si->adi.name, "Nvidia Quadro FX 700 Go");
999 		sprintf(si->adi.chipset, "NV31");
1000 		status = nvxx_general_powerup();
1001 		break;
1002 	case 0x031d10de: /* Nvidia unknown FX Go */
1003 	case 0x031e10de: /* Nvidia unknown FX Go */
1004 	case 0x031f10de: /* Nvidia unknown FX Go */
1005 		si->ps.card_type = NV31;
1006 		si->ps.card_arch = NV30A;
1007 		si->ps.laptop = true;
1008 		sprintf(si->adi.name, "Nvidia unknown FX Go");
1009 		sprintf(si->adi.chipset, "NV31");
1010 		status = nvxx_general_powerup();
1011 		break;
1012 	case 0x032010de: /* Nvidia GeForce FX 5200 */
1013 	case 0x032110de: /* Nvidia GeForce FX 5200 Ultra */
1014 	case 0x032210de: /* Nvidia GeForce FX 5200 */
1015 	case 0x032310de: /* Nvidia GeForce FX 5200LE */
1016 		si->ps.card_type = NV34;
1017 		si->ps.card_arch = NV30A;
1018 		sprintf(si->adi.name, "Nvidia GeForce FX 5200");
1019 		sprintf(si->adi.chipset, "NV34");
1020 		status = nvxx_general_powerup();
1021 		break;
1022 	case 0x032410de: /* Nvidia GeForce FX 5200 Go */
1023 		si->ps.card_type = NV34;
1024 		si->ps.card_arch = NV30A;
1025 		si->ps.laptop = true;
1026 		sprintf(si->adi.name, "Nvidia GeForce FX 5200 Go");
1027 		sprintf(si->adi.chipset, "NV34");
1028 		status = nvxx_general_powerup();
1029 		break;
1030 	case 0x032510de: /* Nvidia GeForce FX 5250 Go */
1031 		si->ps.card_type = NV34;
1032 		si->ps.card_arch = NV30A;
1033 		si->ps.laptop = true;
1034 		sprintf(si->adi.name, "Nvidia GeForce FX 5250 Go");
1035 		sprintf(si->adi.chipset, "NV34");
1036 		status = nvxx_general_powerup();
1037 		break;
1038 	case 0x032610de: /* Nvidia GeForce FX 5500 */
1039 		si->ps.card_type = NV34;
1040 		si->ps.card_arch = NV30A;
1041 		sprintf(si->adi.name, "Nvidia GeForce FX 5500");
1042 		sprintf(si->adi.chipset, "NV34");
1043 		status = nvxx_general_powerup();
1044 		break;
1045 	case 0x032710de: /* Nvidia GeForce FX 5100 */
1046 		si->ps.card_type = NV34;
1047 		si->ps.card_arch = NV30A;
1048 		sprintf(si->adi.name, "Nvidia GeForce FX 5100");
1049 		sprintf(si->adi.chipset, "NV34");
1050 		status = nvxx_general_powerup();
1051 		break;
1052 	case 0x032810de: /* Nvidia GeForce FX 5200 Go 32M/64M */
1053 		si->ps.card_type = NV34;
1054 		si->ps.card_arch = NV30A;
1055 		si->ps.laptop = true;
1056 		sprintf(si->adi.name, "Nvidia GeForce FX 5200 Go");
1057 		sprintf(si->adi.chipset, "NV34");
1058 		status = nvxx_general_powerup();
1059 		break;
1060 	case 0x032910de: /* Nvidia GeForce FX 5200 (PPC) */
1061 		si->ps.card_type = NV34;
1062 		si->ps.card_arch = NV30A;
1063 		sprintf(si->adi.name, "Nvidia GeForce FX 5200");
1064 		sprintf(si->adi.chipset, "NV34");
1065 		status = nvxx_general_powerup();
1066 		break;
1067 	case 0x032a10de: /* Nvidia Quadro NVS 280 PCI */
1068 		si->ps.card_type = NV34;
1069 		si->ps.card_arch = NV30A;
1070 		sprintf(si->adi.name, "Nvidia Quadro NVS 280 PCI");
1071 		sprintf(si->adi.chipset, "NV34");
1072 		status = nvxx_general_powerup();
1073 		break;
1074 	case 0x032b10de: /* Nvidia Quadro FX 500/600 PCI */
1075 		si->ps.card_type = NV34;
1076 		si->ps.card_arch = NV30A;
1077 		sprintf(si->adi.name, "Nvidia Quadro FX 500/600 PCI");
1078 		sprintf(si->adi.chipset, "NV34");
1079 		status = nvxx_general_powerup();
1080 		break;
1081 	case 0x032c10de: /* Nvidia GeForce FX 5300 Go */
1082 	case 0x032d10de: /* Nvidia GeForce FX 5100 Go */
1083 		si->ps.card_type = NV34;
1084 		si->ps.card_arch = NV30A;
1085 		si->ps.laptop = true;
1086 		sprintf(si->adi.name, "Nvidia GeForce FX Go");
1087 		sprintf(si->adi.chipset, "NV34");
1088 		status = nvxx_general_powerup();
1089 		break;
1090 	case 0x032e10de: /* Nvidia unknown FX Go */
1091 	case 0x032f10de: /* Nvidia unknown FX Go */
1092 		si->ps.card_type = NV34;
1093 		si->ps.card_arch = NV30A;
1094 		si->ps.laptop = true;
1095 		sprintf(si->adi.name, "Nvidia unknown FX Go");
1096 		sprintf(si->adi.chipset, "NV34");
1097 		status = nvxx_general_powerup();
1098 		break;
1099 	case 0x033010de: /* Nvidia GeForce FX 5900 Ultra */
1100 	case 0x033110de: /* Nvidia GeForce FX 5900 */
1101 		si->ps.card_type = NV35;
1102 		si->ps.card_arch = NV30A;
1103 		sprintf(si->adi.name, "Nvidia GeForce FX 5900");
1104 		sprintf(si->adi.chipset, "NV35");
1105 		status = nvxx_general_powerup();
1106 		break;
1107 	case 0x033210de: /* Nvidia GeForce FX 5900 XT */
1108 		si->ps.card_type = NV35;
1109 		si->ps.card_arch = NV30A;
1110 		sprintf(si->adi.name, "Nvidia GeForce FX 5900 XT");
1111 		sprintf(si->adi.chipset, "NV35");
1112 		status = nvxx_general_powerup();
1113 		break;
1114 	case 0x033310de: /* Nvidia GeForce FX 5950 Ultra */
1115 		si->ps.card_type = NV38;
1116 		si->ps.card_arch = NV30A;
1117 		sprintf(si->adi.name, "Nvidia GeForce FX 5950 Ultra");
1118 		sprintf(si->adi.chipset, "NV38");
1119 		status = nvxx_general_powerup();
1120 		break;
1121 	case 0x033410de: /* Nvidia GeForce FX 5900 ZT */
1122 		si->ps.card_type = NV38;
1123 		si->ps.card_arch = NV30A;
1124 		sprintf(si->adi.name, "Nvidia GeForce FX 5900 ZT");
1125 		sprintf(si->adi.chipset, "NV38(?)");
1126 		status = nvxx_general_powerup();
1127 		break;
1128 	case 0x033810de: /* Nvidia Quadro FX 3000 */
1129 		si->ps.card_type = NV35;
1130 		si->ps.card_arch = NV30A;
1131 		sprintf(si->adi.name, "Nvidia Quadro FX 3000");
1132 		sprintf(si->adi.chipset, "NV35");
1133 		status = nvxx_general_powerup();
1134 		break;
1135 	case 0x033f10de: /* Nvidia Quadro FX 700 */
1136 		si->ps.card_type = NV35;
1137 		si->ps.card_arch = NV30A;
1138 		sprintf(si->adi.name, "Nvidia Quadro FX 700");
1139 		sprintf(si->adi.chipset, "NV35");
1140 		status = nvxx_general_powerup();
1141 		break;
1142 	case 0x034110de: /* Nvidia GeForce FX 5700 Ultra */
1143 	case 0x034210de: /* Nvidia GeForce FX 5700 */
1144 	case 0x034310de: /* Nvidia GeForce FX 5700LE */
1145 	case 0x034410de: /* Nvidia GeForce FX 5700VE */
1146 		si->ps.card_type = NV36;
1147 		si->ps.card_arch = NV30A;
1148 		sprintf(si->adi.name, "Nvidia GeForce FX 5700");
1149 		sprintf(si->adi.chipset, "NV36");
1150 		status = nvxx_general_powerup();
1151 		break;
1152 	case 0x034510de: /* Nvidia unknown FX */
1153 		si->ps.card_type = NV36;
1154 		si->ps.card_arch = NV30A;
1155 		sprintf(si->adi.name, "Nvidia unknown FX");
1156 		sprintf(si->adi.chipset, "NV36");
1157 		status = nvxx_general_powerup();
1158 		break;
1159 	case 0x034710de: /* Nvidia GeForce FX 5700 Go */
1160 	case 0x034810de: /* Nvidia GeForce FX 5700 Go */
1161 		si->ps.card_type = NV36;
1162 		si->ps.card_arch = NV30A;
1163 		si->ps.laptop = true;
1164 		sprintf(si->adi.name, "Nvidia GeForce FX 5700 Go");
1165 		sprintf(si->adi.chipset, "NV36");
1166 		status = nvxx_general_powerup();
1167 		break;
1168 	case 0x034910de: /* Nvidia unknown FX Go */
1169 	case 0x034b10de: /* Nvidia unknown FX Go */
1170 		si->ps.card_type = NV36;
1171 		si->ps.card_arch = NV30A;
1172 		si->ps.laptop = true;
1173 		sprintf(si->adi.name, "Nvidia unknown FX Go");
1174 		sprintf(si->adi.chipset, "NV36");
1175 		status = nvxx_general_powerup();
1176 		break;
1177 	case 0x034c10de: /* Nvidia Quadro FX 1000 Go */
1178 		si->ps.card_type = NV36;
1179 		si->ps.card_arch = NV30A;
1180 		si->ps.laptop = true;
1181 		sprintf(si->adi.name, "Nvidia Quadro FX 1000 Go");
1182 		sprintf(si->adi.chipset, "NV36");
1183 		status = nvxx_general_powerup();
1184 		break;
1185 	case 0x034e10de: /* Nvidia Quadro FX 1100 */
1186 		si->ps.card_type = NV36;
1187 		si->ps.card_arch = NV30A;
1188 		sprintf(si->adi.name, "Nvidia Quadro FX 1100");
1189 		sprintf(si->adi.chipset, "NV36");
1190 		status = nvxx_general_powerup();
1191 		break;
1192 	case 0x034f10de: /* Nvidia unknown FX */
1193 		si->ps.card_type = NV36;
1194 		si->ps.card_arch = NV30A;
1195 		sprintf(si->adi.name, "Nvidia unknown FX");
1196 		sprintf(si->adi.chipset, "NV36(?)");
1197 		status = nvxx_general_powerup();
1198 		break;
1199 	case 0x039110de: /* Nvidia GeForce 7600 GT */
1200 		si->ps.card_type = G73;
1201 		si->ps.card_arch = NV40A;
1202 		sprintf(si->adi.name, "Nvidia GeForce 7600 GT");
1203 		sprintf(si->adi.chipset, "G73");
1204 		status = nvxx_general_powerup();
1205 		break;
1206 	case 0x039210de: /* Nvidia GeForce 7600 GS */
1207 		si->ps.card_type = G73;
1208 		si->ps.card_arch = NV40A;
1209 		sprintf(si->adi.name, "Nvidia GeForce 7600 GS");
1210 		sprintf(si->adi.chipset, "G73");
1211 		status = nvxx_general_powerup();
1212 		break;
1213 	case 0x039310de: /* Nvidia GeForce 7300 GT */
1214 		si->ps.card_type = G73;
1215 		si->ps.card_arch = NV40A;
1216 		sprintf(si->adi.name, "Nvidia GeForce 7300 GT");
1217 		sprintf(si->adi.chipset, "G73");
1218 		status = nvxx_general_powerup();
1219 		break;
1220 	case 0x039410de: /* Nvidia GeForce 7600 LE */
1221 		si->ps.card_type = G70;
1222 		si->ps.card_arch = NV40A;
1223 		sprintf(si->adi.name, "Nvidia GeForce 7600 LE");
1224 		sprintf(si->adi.chipset, "G70");
1225 		status = nvxx_general_powerup();
1226 		break;
1227 	case 0x039810de: /* Nvidia GeForce 7600 GO */
1228 		si->ps.card_type = G73;
1229 		si->ps.card_arch = NV40A;
1230 		si->ps.laptop = true;
1231 		sprintf(si->adi.name, "Nvidia GeForce 7600 GO");
1232 		sprintf(si->adi.chipset, "G73");
1233 		status = nvxx_general_powerup();
1234 		break;
1235 	case 0x03d010de: /* Nvidia GeForce 6100 nForce 430 */
1236 	case 0x03d110de: /* Nvidia GeForce 6100 nForce 405 */
1237 	case 0x03d210de: /* Nvidia GeForce 6100 nForce 400 */
1238 		si->ps.card_type = NV44;
1239 		si->ps.card_arch = NV40A;
1240 		sprintf(si->adi.name, "Nvidia GeForce 6100 nForce");
1241 		sprintf(si->adi.chipset, "NV44");
1242 		status = nvxx_general_powerup();
1243 		break;
1244 	case 0x040010de: /* Nvidia GeForce 8600 GTS */
1245 	case 0x040210de: /* Nvidia GeForce 8600 GT */
1246 		si->ps.card_type = G84;
1247 		si->ps.card_arch = NV50A;
1248 		sprintf(si->adi.name, "Nvidia GeForce 8600");
1249 		sprintf(si->adi.chipset, "G84");
1250 		status = nvxx_general_powerup();
1251 		break;
1252 	case 0x040710de: /* Nvidia GeForce 8600M GT */
1253 		si->ps.card_type = G86;
1254 		si->ps.card_arch = NV50A;
1255 		si->ps.laptop = true;
1256 		sprintf(si->adi.name, "Nvidia GeForce 8600M GT");
1257 		sprintf(si->adi.chipset, "G86");
1258 		status = nvxx_general_powerup();
1259 		break;
1260 	case 0x042110de: /* Nvidia GeForce 8500 GT */
1261 		si->ps.card_type = G86;
1262 		si->ps.card_arch = NV50A;
1263 		sprintf(si->adi.name, "Nvidia GeForce 8500 GT");
1264 		sprintf(si->adi.chipset, "G86");
1265 		status = nvxx_general_powerup();
1266 		break;
1267 	case 0x042210de: /* Nvidia GeForce 8400 GS */
1268 		si->ps.card_type = G86;
1269 		si->ps.card_arch = NV50A;
1270 		sprintf(si->adi.name, "Nvidia GeForce 8400 GS");
1271 		sprintf(si->adi.chipset, "G86");
1272 		status = nvxx_general_powerup();
1273 		break;
1274 	case 0x042310de: /* Nvidia GeForce 8300 GS */
1275 		si->ps.card_type = G86;
1276 		si->ps.card_arch = NV50A;
1277 		sprintf(si->adi.name, "Nvidia GeForce 8300 GS");
1278 		sprintf(si->adi.chipset, "G86");
1279 		status = nvxx_general_powerup();
1280 		break;
1281 	/* Vendor Elsa GmbH */
1282 	case 0x0c601048: /* Elsa Gladiac Geforce2 MX */
1283 		si->ps.card_type = NV11;
1284 		si->ps.card_arch = NV10A;
1285 		sprintf(si->adi.name, "Elsa Gladiac Geforce2 MX");
1286 		sprintf(si->adi.chipset, "NV11");
1287 		status = nvxx_general_powerup();
1288 		break;
1289 	/* Vendor Nvidia STB/SGS-Thompson */
1290 	case 0x002012d2: /* Nvidia STB/SGS-Thompson TNT1 */
1291 		si->ps.card_type = NV04;
1292 		si->ps.card_arch = NV04A;
1293 		sprintf(si->adi.name, "Nvidia STB/SGS-Thompson TNT1");
1294 		sprintf(si->adi.chipset, "NV04");
1295 		status = nvxx_general_powerup();
1296 		break;
1297 	case 0x002812d2: /* Nvidia STB/SGS-Thompson TNT2 (pro) */
1298 	case 0x002912d2: /* Nvidia STB/SGS-Thompson TNT2 Ultra */
1299 	case 0x002a12d2: /* Nvidia STB/SGS-Thompson TNT2 */
1300 	case 0x002b12d2: /* Nvidia STB/SGS-Thompson TNT2 */
1301 		si->ps.card_type = NV05;
1302 		si->ps.card_arch = NV04A;
1303 		sprintf(si->adi.name, "Nvidia STB/SGS-Thompson TNT2");
1304 		sprintf(si->adi.chipset, "NV05");
1305 		status = nvxx_general_powerup();
1306 		break;
1307 	case 0x002c12d2: /* Nvidia STB/SGS-Thompson Vanta (Lt) */
1308 		si->ps.card_type = NV05;
1309 		si->ps.card_arch = NV04A;
1310 		sprintf(si->adi.name, "Nvidia STB/SGS-Thompson Vanta");
1311 		sprintf(si->adi.chipset, "NV05");
1312 		status = nvxx_general_powerup();
1313 		break;
1314 	case 0x002d12d2: /* Nvidia STB/SGS-Thompson TNT2-M64 (Pro) */
1315 		si->ps.card_type = NV05M64;
1316 		si->ps.card_arch = NV04A;
1317 		sprintf(si->adi.name, "Nvidia STB/SGS-Thompson TNT2M64");
1318 		sprintf(si->adi.chipset, "NV05 model 64");
1319 		status = nvxx_general_powerup();
1320 		break;
1321 	case 0x002e12d2: /* Nvidia STB/SGS-Thompson NV06 Vanta */
1322 	case 0x002f12d2: /* Nvidia STB/SGS-Thompson NV06 Vanta */
1323 		si->ps.card_type = NV06;
1324 		si->ps.card_arch = NV04A;
1325 		sprintf(si->adi.name, "Nvidia STB/SGS-Thompson Vanta");
1326 		sprintf(si->adi.chipset, "NV06");
1327 		status = nvxx_general_powerup();
1328 		break;
1329 	case 0x00a012d2: /* Nvidia STB/SGS-Thompson Aladdin TNT2 */
1330 		si->ps.card_type = NV05;
1331 		si->ps.card_arch = NV04A;
1332 		sprintf(si->adi.name, "Nvidia STB/SGS-Thompson TNT2");
1333 		sprintf(si->adi.chipset, "NV05");
1334 		status = nvxx_general_powerup();
1335 		break;
1336 	/* Vendor Varisys Limited */
1337 	case 0x35031888: /* Varisys GeForce4 MX440 */
1338 		si->ps.card_type = NV17;
1339 		si->ps.card_arch = NV10A;
1340 		sprintf(si->adi.name, "Varisys GeForce4 MX440");
1341 		sprintf(si->adi.chipset, "NV17");
1342 		status = nvxx_general_powerup();
1343 		break;
1344 	case 0x35051888: /* Varisys GeForce4 Ti 4200 */
1345 		si->ps.card_type = NV25;
1346 		si->ps.card_arch = NV20A;
1347 		sprintf(si->adi.name, "Varisys GeForce4 Ti 4200");
1348 		sprintf(si->adi.chipset, "NV25");
1349 		status = nvxx_general_powerup();
1350 		break;
1351 	default:
1352 		LOG(8,("POWERUP: Failed to detect valid card 0x%08x\n",CFGR(DEVID)));
1353 		return B_ERROR;
1354 	}
1355 
1356 	return status;
1357 }
1358 
1359 static status_t test_ram()
1360 {
1361 	uint32 value, offset;
1362 	status_t result = B_OK;
1363 
1364 	/* make sure we don't corrupt the hardware cursor by using fbc.frame_buffer. */
1365 	if (si->fbc.frame_buffer == NULL)
1366 	{
1367 		LOG(8,("INIT: test_ram detected NULL pointer.\n"));
1368 		return B_ERROR;
1369 	}
1370 
1371 	for (offset = 0, value = 0x55aa55aa; offset < 256; offset++)
1372 	{
1373 		/* write testpattern to cardRAM */
1374 		((uint32 *)si->fbc.frame_buffer)[offset] = value;
1375 		/* toggle testpattern */
1376 		value = 0xffffffff - value;
1377 	}
1378 
1379 	for (offset = 0, value = 0x55aa55aa; offset < 256; offset++)
1380 	{
1381 		/* readback and verify testpattern from cardRAM */
1382 		if (((uint32 *)si->fbc.frame_buffer)[offset] != value) result = B_ERROR;
1383 		/* toggle testpattern */
1384 		value = 0xffffffff - value;
1385 	}
1386 	return result;
1387 }
1388 
1389 /* NOTE:
1390  * This routine *has* to be done *after* SetDispplayMode has been executed,
1391  * or test results will not be representative!
1392  * (CAS latency is dependant on NV setup on some (DRAM) boards) */
1393 status_t nv_set_cas_latency()
1394 {
1395 	status_t result = B_ERROR;
1396 	uint8 latency = 0;
1397 
1398 	/* check current RAM access to see if we need to change anything */
1399 	if (test_ram() == B_OK)
1400 	{
1401 		LOG(4,("INIT: RAM access OK.\n"));
1402 		return B_OK;
1403 	}
1404 
1405 	/* check if we read PINS at starttime so we have valid registersettings at our disposal */
1406 	if (si->ps.pins_status != B_OK)
1407 	{
1408 		LOG(4,("INIT: RAM access errors; not fixable: PINS was not read from cardBIOS.\n"));
1409 		return B_ERROR;
1410 	}
1411 
1412 	/* OK. We might have a problem, try to fix it now.. */
1413 	LOG(4,("INIT: RAM access errors; tuning CAS latency if prudent...\n"));
1414 
1415 	switch(si->ps.card_type)
1416 	{
1417 	default:
1418 			LOG(4,("INIT: RAM CAS tuning not implemented for this card, aborting.\n"));
1419 			return B_OK;
1420 			break;
1421 	}
1422 	if (result == B_OK)
1423 		LOG(4,("INIT: RAM access OK. CAS latency set to %d cycles.\n", latency));
1424 	else
1425 		LOG(4,("INIT: RAM access not fixable. CAS latency set to %d cycles.\n", latency));
1426 
1427 	return result;
1428 }
1429 
1430 void setup_virtualized_heads(bool cross)
1431 {
1432 	if (cross)
1433 	{
1434 		head1_interrupt_enable	= (crtc_interrupt_enable)	nv_crtc2_interrupt_enable;
1435 		head1_update_fifo		= (crtc_update_fifo)		nv_crtc2_update_fifo;
1436 		head1_validate_timing	= (crtc_validate_timing)	nv_crtc2_validate_timing;
1437 		head1_set_timing		= (crtc_set_timing)			nv_crtc2_set_timing;
1438 		head1_depth				= (crtc_depth)				nv_crtc2_depth;
1439 		head1_dpms				= (crtc_dpms)				nv_crtc2_dpms;
1440 		head1_set_display_pitch	= (crtc_set_display_pitch)	nv_crtc2_set_display_pitch;
1441 		head1_set_display_start	= (crtc_set_display_start)	nv_crtc2_set_display_start;
1442 		head1_cursor_init		= (crtc_cursor_init)		nv_crtc2_cursor_init;
1443 		head1_cursor_show		= (crtc_cursor_show)		nv_crtc2_cursor_show;
1444 		head1_cursor_hide		= (crtc_cursor_hide)		nv_crtc2_cursor_hide;
1445 		head1_cursor_define		= (crtc_cursor_define)		nv_crtc2_cursor_define;
1446 		head1_cursor_position	= (crtc_cursor_position)	nv_crtc2_cursor_position;
1447 		head1_stop_tvout		= (crtc_stop_tvout)			nv_crtc2_stop_tvout;
1448 		head1_start_tvout		= (crtc_start_tvout)		nv_crtc2_start_tvout;
1449 
1450 		head1_mode				= (dac_mode)				nv_dac2_mode;
1451 		head1_palette			= (dac_palette)				nv_dac2_palette;
1452 		head1_set_pix_pll		= (dac_set_pix_pll)			nv_dac2_set_pix_pll;
1453 		head1_pix_pll_find		= (dac_pix_pll_find)		nv_dac2_pix_pll_find;
1454 
1455 		head2_interrupt_enable	= (crtc_interrupt_enable)	nv_crtc_interrupt_enable;
1456 		head2_update_fifo		= (crtc_update_fifo)		nv_crtc_update_fifo;
1457 		head2_validate_timing	= (crtc_validate_timing)	nv_crtc_validate_timing;
1458 		head2_set_timing		= (crtc_set_timing)			nv_crtc_set_timing;
1459 		head2_depth				= (crtc_depth)				nv_crtc_depth;
1460 		head2_dpms				= (crtc_dpms)				nv_crtc_dpms;
1461 		head2_set_display_pitch	= (crtc_set_display_pitch)	nv_crtc_set_display_pitch;
1462 		head2_set_display_start	= (crtc_set_display_start)	nv_crtc_set_display_start;
1463 		head2_cursor_init		= (crtc_cursor_init)		nv_crtc_cursor_init;
1464 		head2_cursor_show		= (crtc_cursor_show)		nv_crtc_cursor_show;
1465 		head2_cursor_hide		= (crtc_cursor_hide)		nv_crtc_cursor_hide;
1466 		head2_cursor_define		= (crtc_cursor_define)		nv_crtc_cursor_define;
1467 		head2_cursor_position	= (crtc_cursor_position)	nv_crtc_cursor_position;
1468 		head2_stop_tvout		= (crtc_stop_tvout)			nv_crtc_stop_tvout;
1469 		head2_start_tvout		= (crtc_start_tvout)		nv_crtc_start_tvout;
1470 
1471 		head2_mode				= (dac_mode)				nv_dac_mode;
1472 		head2_palette			= (dac_palette)				nv_dac_palette;
1473 		head2_set_pix_pll		= (dac_set_pix_pll)			nv_dac_set_pix_pll;
1474 		head2_pix_pll_find		= (dac_pix_pll_find)		nv_dac_pix_pll_find;
1475 	}
1476 	else
1477 	{
1478 		head1_interrupt_enable	= (crtc_interrupt_enable)	nv_crtc_interrupt_enable;
1479 		head1_update_fifo		= (crtc_update_fifo)		nv_crtc_update_fifo;
1480 		head1_validate_timing	= (crtc_validate_timing)	nv_crtc_validate_timing;
1481 		head1_set_timing		= (crtc_set_timing)			nv_crtc_set_timing;
1482 		head1_depth				= (crtc_depth)				nv_crtc_depth;
1483 		head1_dpms				= (crtc_dpms)				nv_crtc_dpms;
1484 		head1_set_display_pitch	= (crtc_set_display_pitch)	nv_crtc_set_display_pitch;
1485 		head1_set_display_start	= (crtc_set_display_start)	nv_crtc_set_display_start;
1486 		head1_cursor_init		= (crtc_cursor_init)		nv_crtc_cursor_init;
1487 		head1_cursor_show		= (crtc_cursor_show)		nv_crtc_cursor_show;
1488 		head1_cursor_hide		= (crtc_cursor_hide)		nv_crtc_cursor_hide;
1489 		head1_cursor_define		= (crtc_cursor_define)		nv_crtc_cursor_define;
1490 		head1_cursor_position	= (crtc_cursor_position)	nv_crtc_cursor_position;
1491 		head1_stop_tvout		= (crtc_stop_tvout)			nv_crtc_stop_tvout;
1492 		head1_start_tvout		= (crtc_start_tvout)		nv_crtc_start_tvout;
1493 
1494 		head1_mode				= (dac_mode)				nv_dac_mode;
1495 		head1_palette			= (dac_palette)				nv_dac_palette;
1496 		head1_set_pix_pll		= (dac_set_pix_pll)			nv_dac_set_pix_pll;
1497 		head1_pix_pll_find		= (dac_pix_pll_find)		nv_dac_pix_pll_find;
1498 
1499 		head2_interrupt_enable	= (crtc_interrupt_enable)	nv_crtc2_interrupt_enable;
1500 		head2_update_fifo		= (crtc_update_fifo)		nv_crtc2_update_fifo;
1501 		head2_validate_timing	= (crtc_validate_timing)	nv_crtc2_validate_timing;
1502 		head2_set_timing		= (crtc_set_timing)			nv_crtc2_set_timing;
1503 		head2_depth				= (crtc_depth)				nv_crtc2_depth;
1504 		head2_dpms				= (crtc_dpms)				nv_crtc2_dpms;
1505 		head2_set_display_pitch	= (crtc_set_display_pitch)	nv_crtc2_set_display_pitch;
1506 		head2_set_display_start	= (crtc_set_display_start)	nv_crtc2_set_display_start;
1507 		head2_cursor_init		= (crtc_cursor_init)		nv_crtc2_cursor_init;
1508 		head2_cursor_show		= (crtc_cursor_show)		nv_crtc2_cursor_show;
1509 		head2_cursor_hide		= (crtc_cursor_hide)		nv_crtc2_cursor_hide;
1510 		head2_cursor_define		= (crtc_cursor_define)		nv_crtc2_cursor_define;
1511 		head2_cursor_position	= (crtc_cursor_position)	nv_crtc2_cursor_position;
1512 		head2_stop_tvout		= (crtc_stop_tvout)			nv_crtc2_stop_tvout;
1513 		head2_start_tvout		= (crtc_start_tvout)		nv_crtc2_start_tvout;
1514 
1515 		head2_mode				= (dac_mode)				nv_dac2_mode;
1516 		head2_palette			= (dac_palette)				nv_dac2_palette;
1517 		head2_set_pix_pll		= (dac_set_pix_pll)			nv_dac2_set_pix_pll;
1518 		head2_pix_pll_find		= (dac_pix_pll_find)		nv_dac2_pix_pll_find;
1519 	}
1520 }
1521 
1522 void set_crtc_owner(bool head)
1523 {
1524 	if (si->ps.secondary_head)
1525 	{
1526 		if (!head)
1527 		{
1528 			/* note: 'OWNER' is a non-standard register in behaviour(!) on NV11's,
1529 			 * while non-NV11 cards behave normally.
1530 			 *
1531 			 * Double-write action needed on those strange NV11 cards: */
1532 			/* RESET: needed on NV11 */
1533 			CRTCW(OWNER, 0xff);
1534 			/* enable access to CRTC1, SEQ1, GRPH1, ATB1, ??? */
1535 			CRTCW(OWNER, 0x00);
1536 		}
1537 		else
1538 		{
1539 			/* note: 'OWNER' is a non-standard register in behaviour(!) on NV11's,
1540 			 * while non-NV11 cards behave normally.
1541 			 *
1542 			 * Double-write action needed on those strange NV11 cards: */
1543 			/* RESET: needed on NV11 */
1544 			CRTC2W(OWNER, 0xff);
1545 			/* enable access to CRTC2, SEQ2, GRPH2, ATB2, ??? */
1546 			CRTC2W(OWNER, 0x03);
1547 		}
1548 	}
1549 }
1550 
1551 static status_t nvxx_general_powerup()
1552 {
1553 	LOG(4, ("INIT: NV powerup\n"));
1554 	LOG(4,("POWERUP: Detected %s (%s)\n", si->adi.name, si->adi.chipset));
1555 
1556 	if (si->ps.card_arch >= NV50A)
1557 	{
1558 		LOG(8,("POWERUP: G80 and higher support not implemented: different architecture!\n"));
1559 		return B_ERROR;
1560 	}
1561 
1562 	/* setup cardspecs */
1563 	/* note:
1564 	 * this MUST be done before the driver attempts a card coldstart */
1565 	set_specs();
1566 
1567 	/* only process BIOS for finetuning specs and coldstarting card if requested
1568 	 * by the user;
1569 	 * note:
1570 	 * this in fact frees the driver from relying on the BIOS to be executed
1571 	 * at system power-up POST time. */
1572 	if (!si->settings.usebios)
1573 	{
1574 		/* Make sure we are running in PCI (not AGP) mode:
1575 		 * This is a requirement for safely coldstarting cards!
1576 		 * (some cards reset their AGP PLL during startup which makes acceleration
1577 		 *  engine DMA fail later on. A reboot is needed to overcome that.)
1578 		 * Note:
1579 		 * This may only be done when no transfers are in progress on the bus, so now
1580 		 * is probably a good time.. */
1581 		nv_agp_setup(false);
1582 
1583 		LOG(2, ("INIT: Attempting card coldstart!\n"));
1584 		/* update the cardspecs in the shared_info PINS struct according to reported
1585 		 * specs as much as is possible;
1586 		 * this also coldstarts the card if possible (executes BIOS CMD script(s)) */
1587 		parse_pins();
1588 	}
1589 	else
1590 	{
1591 		LOG(2, ("INIT: Skipping card coldstart!\n"));
1592 	}
1593 
1594 	unlock_card();
1595 
1596 	/* get RAM size, detect TV encoder and do fake panel startup (panel init code
1597 	 *  is still missing). */
1598 	fake_panel_start();
1599 
1600 	/* log the final card specifications */
1601 	dump_pins();
1602 
1603 	/* dump config space as it is after a possible coldstart attempt */
1604 	if (si->settings.logmask & 0x80000000) nv_dump_configuration_space();
1605 
1606 	/* setup CRTC and DAC functions access: determined in fake_panel_start */
1607 	setup_virtualized_heads(si->ps.crtc2_prim);
1608 
1609 	/* do powerup needed from pre-inited card state as done by system POST cardBIOS
1610 	 * execution or driver coldstart above */
1611 	return nv_general_bios_to_powergraphics();
1612 }
1613 
1614 /* this routine switches the CRTC/DAC sets to 'connectors', but only for analog
1615  * outputs. We need this to make sure the analog 'switch' is set in the same way the
1616  * digital 'switch' is set by the BIOS or we might not be able to use dualhead. */
1617 status_t nv_general_output_select(bool cross)
1618 {
1619 	/* make sure this call is warranted */
1620 	if (si->ps.secondary_head)
1621 	{
1622 		/* NV11 cards can't switch heads (confirmed) */
1623 		if (si->ps.card_type != NV11)
1624 		{
1625 			if (cross)
1626 			{
1627 				LOG(4,("INIT: switching analog outputs to be cross-connected\n"));
1628 
1629 				/* enable head 2 on connector 1 */
1630 				/* (b8 = select CRTC (head) for output,
1631 				 *  b4 = ??? (confirmed not to be a FP switch),
1632 				 *  b0 = enable CRT) */
1633 				DACW(OUTPUT, 0x00000101);
1634 				/* enable head 1 on connector 2 */
1635 				DAC2W(OUTPUT, 0x00000001);
1636 			}
1637 			else
1638 			{
1639 				LOG(4,("INIT: switching analog outputs to be straight-through\n"));
1640 
1641 				/* enable head 1 on connector 1 */
1642 				DACW(OUTPUT, 0x00000001);
1643 				/* enable head 2 on connector 2 */
1644 				DAC2W(OUTPUT, 0x00000101);
1645 			}
1646 		}
1647 		else
1648 		{
1649 			LOG(4,("INIT: NV11 analog outputs are hardwired to be straight-through\n"));
1650 		}
1651 		return B_OK;
1652 	}
1653 	else
1654 	{
1655 		return B_ERROR;
1656 	}
1657 }
1658 
1659 /* this routine switches CRTC/DAC set use. We need this because it's unknown howto
1660  * switch digital panels to/from a specific CRTC/DAC set. */
1661 status_t nv_general_head_select(bool cross)
1662 {
1663 	/* make sure this call is warranted */
1664 	if (si->ps.secondary_head)
1665 	{
1666 		/* invert CRTC/DAC use to do switching */
1667 		if (cross)
1668 		{
1669 			LOG(4,("INIT: switching CRTC/DAC use to be cross-connected\n"));
1670 			si->crtc_switch_mode = !si->ps.crtc2_prim;
1671 		}
1672 		else
1673 		{
1674 			LOG(4,("INIT: switching CRTC/DAC use to be straight-through\n"));
1675 			si->crtc_switch_mode = si->ps.crtc2_prim;
1676 		}
1677 		/* update CRTC and DAC functions access */
1678 		setup_virtualized_heads(si->crtc_switch_mode);
1679 
1680 		return B_OK;
1681 	}
1682 	else
1683 	{
1684 		return B_ERROR;
1685 	}
1686 }
1687 
1688 static void unlock_card(void)
1689 {
1690 	/* power-up all nvidia hardware function blocks */
1691 	/* bit 28: OVERLAY ENGINE (BES),
1692 	 * bit 25: CRTC2, (> NV04A)
1693 	 * bit 24: CRTC1,
1694 	 * bit 20: framebuffer,
1695 	 * bit 16: PPMI,
1696 	 * bit 12: PGRAPH,
1697 	 * bit  8: PFIFO,
1698 	 * bit  4: PMEDIA,
1699 	 * bit  0: TVOUT. (> NV04A) */
1700 	NV_REG32(NV32_PWRUPCTRL) = 0x13111111;
1701 
1702 	/* select colormode CRTC registers base adresses */
1703 	NV_REG8(NV8_MISCW) = 0xcb;
1704 
1705 	/* enable access to primary head */
1706 	set_crtc_owner(0);
1707 	/* unlock head's registers for R/W access */
1708 	CRTCW(LOCK, 0x57);
1709 	CRTCW(VSYNCE ,(CRTCR(VSYNCE) & 0x7f));
1710 	if (si->ps.secondary_head)
1711 	{
1712 		/* enable access to secondary head */
1713 		set_crtc_owner(1);
1714 		/* unlock head's registers for R/W access */
1715 		CRTC2W(LOCK, 0x57);
1716 		CRTC2W(VSYNCE ,(CRTCR(VSYNCE) & 0x7f));
1717 	}
1718 }
1719 
1720 /* basic change of card state from VGA to enhanced mode:
1721  * Should work from VGA BIOS POST init state. */
1722 static status_t nv_general_bios_to_powergraphics()
1723 {
1724 	/* let acc engine make power off/power on cycle to start 'fresh' */
1725 	NV_REG32(NV32_PWRUPCTRL) = 0x13110011;
1726 	snooze(1000);
1727 	NV_REG32(NV32_PWRUPCTRL) = 0x13111111;
1728 
1729 	unlock_card();
1730 
1731 	/* turn off both displays and the hardcursors (also disables transfers) */
1732 	head1_dpms(false, false, false, true);
1733 	head1_cursor_hide();
1734 	if (si->ps.secondary_head)
1735 	{
1736 		head2_dpms(false, false, false, true);
1737 		head2_cursor_hide();
1738 	}
1739 
1740 	if (si->ps.secondary_head)
1741 	{
1742 		/* switch overlay engine and TV encoder to CRTC1 */
1743 		/* bit 17: GPU FP port #1	(confirmed NV25, NV28, confirmed not on NV34),
1744 		 * bit 16: GPU FP port #2	(confirmed NV25, NV28, NV34),
1745 		 * bit 12: overlay engine	(all cards),
1746 		 * bit  9: TVout chip #2	(confirmed on NV18, NV25, NV28),
1747 		 * bit  8: TVout chip #1	(all cards),
1748 		 * bit  4: both I2C busses	(all cards) */
1749 		NV_REG32(NV32_2FUNCSEL) &= ~0x00001100;
1750 		NV_REG32(NV32_FUNCSEL) |= 0x00001100;
1751 	}
1752 	si->overlay.crtc = false;
1753 
1754 	/* enable 'enhanced' mode on primary head: */
1755 	/* enable access to primary head */
1756 	set_crtc_owner(0);
1757 	/* note: 'BUFFER' is a non-standard register in behaviour(!) on most
1758 	 * NV11's like the GeForce2 MX200, while the MX400 and non-NV11 cards
1759 	 * behave normally.
1760 	 * Also readback is not nessesarily what was written before!
1761 	 *
1762 	 * Double-write action needed on those strange NV11 cards: */
1763 	/* RESET: don't doublebuffer CRTC access: set programmed values immediately... */
1764 	CRTCW(BUFFER, 0xff);
1765 	/* ... and use fine pitched CRTC granularity on > NV4 cards (b2 = 0) */
1766 	/* note: this has no effect on possible bandwidth issues. */
1767 	CRTCW(BUFFER, 0xfb);
1768 	/* select VGA mode (old VGA register) */
1769 	CRTCW(MODECTL, 0xc3);
1770 	/* select graphics mode (old VGA register) */
1771 	SEQW(MEMMODE, 0x0e);
1772 	/* select 8 dots character clocks (old VGA register) */
1773 	SEQW(CLKMODE, 0x21);
1774 	/* select VGA mode (old VGA register) */
1775 	GRPHW(MODE, 0x00);
1776 	/* select graphics mode (old VGA register) */
1777 	GRPHW(MISC, 0x01);
1778 	/* select graphics mode (old VGA register) */
1779 	ATBW(MODECTL, 0x01);
1780 	/* enable 'enhanced mode', enable Vsync & Hsync,
1781 	 * set DAC palette to 8-bit width, disable large screen */
1782 	CRTCW(REPAINT1, 0x04);
1783 
1784 	/* enable 'enhanced' mode on secondary head: */
1785 	if (si->ps.secondary_head)
1786 	{
1787 		/* enable access to secondary head */
1788 		set_crtc_owner(1);
1789 		/* select colormode CRTC2 registers base adresses */
1790 		NV_REG8(NV8_MISCW) = 0xcb;
1791 		/* note: 'BUFFER' is a non-standard register in behaviour(!) on most
1792 		 * NV11's like the GeForce2 MX200, while the MX400 and non-NV11 cards
1793 		 * behave normally.
1794 		 * Also readback is not nessesarily what was written before!
1795 		 *
1796 		 * Double-write action needed on those strange NV11 cards: */
1797 		/* RESET: don't doublebuffer CRTC2 access: set programmed values immediately... */
1798 		CRTC2W(BUFFER, 0xff);
1799 		/* ... and use fine pitched CRTC granularity on > NV4 cards (b2 = 0) */
1800 		/* note: this has no effect on possible bandwidth issues. */
1801 		CRTC2W(BUFFER, 0xfb);
1802 		/* select VGA mode (old VGA register) */
1803 		CRTC2W(MODECTL, 0xc3);
1804 		/* select graphics mode (old VGA register) */
1805 		SEQW(MEMMODE, 0x0e);
1806 		/* select 8 dots character clocks (old VGA register) */
1807 		SEQW(CLKMODE, 0x21);
1808 		/* select VGA mode (old VGA register) */
1809 		GRPHW(MODE, 0x00);
1810 		/* select graphics mode (old VGA register) */
1811 		GRPHW(MISC, 0x01);
1812 		/* select graphics mode (old VGA register) */
1813 		ATB2W(MODECTL, 0x01);
1814 		/* enable 'enhanced mode', enable Vsync & Hsync,
1815 		 * set DAC palette to 8-bit width, disable large screen */
1816 		CRTC2W(REPAINT1, 0x04);
1817 	}
1818 
1819 	/* enable palettes */
1820 	DACW(GENCTRL, 0x00100100);
1821 	if (si->ps.secondary_head) DAC2W(GENCTRL, 0x00100100);
1822 
1823 	/* enable programmable PLLs */
1824 	/* (confirmed PLLSEL to be a write-only register on NV04 and NV11!) */
1825 	if (si->ps.secondary_head)
1826 		DACW(PLLSEL, 0x30000f00);
1827 	else
1828 		DACW(PLLSEL, 0x10000700);
1829 
1830 	/* turn on DAC and make sure detection testsignal routing is disabled
1831 	 * (b16 = disable DAC,
1832 	 *  b12 = enable testsignal output */
1833 	//fixme note: b20 ('DACTM_TEST') when set apparantly blocks a DAC's video output
1834 	//(confirmed NV43), while it's timing remains operational (black screen).
1835 	//It feels like in some screen configurations it can move the output to the other
1836 	//output connector as well...
1837 	DACW(TSTCTRL, (DACR(TSTCTRL) & 0xfffeefff));
1838 	/* turn on DAC2 if it exists
1839 	 * (NOTE: testsignal function block resides in DAC1 only (!)) */
1840 	if (si->ps.secondary_head) DAC2W(TSTCTRL, (DAC2R(TSTCTRL) & 0xfffeefff));
1841 
1842 	/* NV40 and NV45 need a 'tweak' to make sure the CRTC FIFO's/shiftregisters get
1843 	 * their data in time (otherwise momentarily ghost images of windows or such
1844 	 * may appear on heavy acceleration engine use for instance, especially in 32-bit
1845 	 * colordepth) */
1846 	if ((si->ps.card_type == NV40) || (si->ps.card_type == NV45))
1847 	{
1848 		/* clear b15: some framebuffer config item (unknown) */
1849 		NV_REG32(NV32_PFB_CLS_PAGE2) &= 0xffff7fff;
1850 	}
1851 
1852 	/* tweak card GPU-core and RAM speeds if requested (hoping we'll survive)... */
1853 	if (si->settings.gpu_clk)
1854 	{
1855 		LOG(2,("INIT: tweaking GPU clock!\n"));
1856 
1857 		set_pll(NV32_COREPLL, si->settings.gpu_clk);
1858 		snooze(1000);
1859 	}
1860 	if (si->settings.ram_clk)
1861 	{
1862 		LOG(2,("INIT: tweaking cardRAM clock!\n"));
1863 
1864 		set_pll(NV32_MEMPLL, si->settings.ram_clk);
1865 		snooze(1000);
1866 	}
1867 
1868 	/* setup AGP:
1869 	 * Note:
1870 	 * This may only be done when no transfers are in progress on the bus, so now
1871 	 * is probably a good time.. */
1872 	nv_agp_setup(true);
1873 
1874 	return B_OK;
1875 }
1876 
1877 /* Check if mode virtual_size adheres to the cards _maximum_ contraints, and modify
1878  * virtual_size to the nearest valid maximum for the mode on the card if not so.
1879  * Also: check if virtual_width adheres to the cards granularity constraints, and
1880  * create mode slopspace if not so.
1881  * We use acc or crtc granularity constraints based on the 'worst case' scenario.
1882  *
1883  * Mode slopspace is reflected in fbc->bytes_per_row BTW. */
1884 status_t nv_general_validate_pic_size (display_mode *target, uint32 *bytes_per_row, bool *acc_mode)
1885 {
1886 	uint32 video_pitch;
1887 	uint32 acc_mask, crtc_mask;
1888 	uint32 max_crtc_width, max_acc_width;
1889 	uint8 depth = 8;
1890 
1891 	/* determine pixel multiple based on acceleration engine constraints */
1892 	/* note:
1893 	 * because of the seemingly 'random' variations in these constraints we take
1894 	 * a reasonable 'lowest common denominator' instead of always true constraints. */
1895 	switch (si->ps.card_arch)
1896 	{
1897 	case NV04A:
1898 		/* confirmed for:
1899 		 * TNT1 (NV04), TNT2 (NV05), TNT2-M64 (NV05M64), GeForce2 MX400 (NV11),
1900 		 * GeForce4 MX440 (NV18), GeForceFX 5200 (NV34) in PIO acc mode;
1901 		 * confirmed for:
1902 		 * TNT1 (NV04), TNT2 (NV05), TNT2-M64 (NV05M64), GeForce4 Ti4200 (NV28),
1903 		 * GeForceFX 5200 (NV34) in DMA acc mode. */
1904 		switch (target->space)
1905 		{
1906 			case B_CMAP8: acc_mask = 0x0f; depth =  8; break;
1907 			case B_RGB15: acc_mask = 0x07; depth = 16; break;
1908 			case B_RGB16: acc_mask = 0x07; depth = 16; break;
1909 			case B_RGB24: acc_mask = 0x0f; depth = 24; break;
1910 			case B_RGB32: acc_mask = 0x03; depth = 32; break;
1911 			default:
1912 				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));
1913 				return B_ERROR;
1914 		}
1915 		break;
1916 	default:
1917 		/* confirmed for:
1918 		 * GeForce4 Ti4200 (NV28), GeForceFX 5600 (NV31) in PIO acc mode;
1919 		 * confirmed for:
1920 		 * GeForce2 MX400 (NV11), GeForce4 MX440 (NV18), GeForcePCX 5750 (NV36),
1921 		 * GeForcePCX 6600 GT (NV43) in DMA acc mode. */
1922 		switch (target->space)
1923 		{
1924 			case B_CMAP8: acc_mask = 0x3f; depth =  8; break;
1925 			case B_RGB15: acc_mask = 0x1f; depth = 16; break;
1926 			case B_RGB16: acc_mask = 0x1f; depth = 16; break;
1927 			case B_RGB24: acc_mask = 0x3f; depth = 24; break;
1928 			case B_RGB32: acc_mask = 0x0f; depth = 32; break;
1929 			default:
1930 				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));
1931 				return B_ERROR;
1932 		}
1933 		break;
1934 	}
1935 
1936 	/* determine pixel multiple based on CRTC memory pitch constraints:
1937 	 * -> all NV cards have same granularity constraints on CRTC1 and CRTC2,
1938 	 *    provided that the CRTC1 and CRTC2 BUFFER register b2 = 0;
1939 	 *
1940 	 * (Note: Don't mix this up with CRTC timing contraints! Those are
1941 	 *        multiples of 8 for horizontal, 1 for vertical timing.) */
1942 	switch (si->ps.card_type)
1943 	{
1944 	default:
1945 //	case NV04:
1946 		/* confirmed for:
1947 		 * TNT1 always;
1948 		 * TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForce4 Ti4200,
1949 		 * GeForceFX 5200: if the CRTC1 (and CRTC2) BUFFER register b2 = 0 */
1950 		/* NOTE:
1951 		 * Unfortunately older cards have a hardware fault that prevents use.
1952 		 * We need doubled granularity on those to prevent the single top line
1953 		 * from shifting to the left!
1954 		 * This is confirmed for TNT2, GeForce2 MX200, GeForce2 MX400.
1955 		 * Confirmed OK are:
1956 		 * GeForce4 MX440, GeForce4 Ti4200, GeForceFX 5200. */
1957 		switch (target->space)
1958 		{
1959 			case B_CMAP8: crtc_mask = 0x0f; break; /* 0x07 */
1960 			case B_RGB15: crtc_mask = 0x07; break; /* 0x03 */
1961 			case B_RGB16: crtc_mask = 0x07; break; /* 0x03 */
1962 			case B_RGB24: crtc_mask = 0x0f; break; /* 0x07 */
1963 			case B_RGB32: crtc_mask = 0x03; break; /* 0x01 */
1964 			default:
1965 				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));
1966 				return B_ERROR;
1967 		}
1968 		break;
1969 //	default:
1970 		/* confirmed for:
1971 		 * TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForce4 Ti4200,
1972 		 * GeForceFX 5200: if the CRTC1 (and CRTC2) BUFFER register b2 = 1 */
1973 /*		switch (target->space)
1974 		{
1975 			case B_CMAP8: crtc_mask = 0x1f; break;
1976 			case B_RGB15: crtc_mask = 0x0f; break;
1977 			case B_RGB16: crtc_mask = 0x0f; break;
1978 			case B_RGB24: crtc_mask = 0x1f; break;
1979 			case B_RGB32: crtc_mask = 0x07; break;
1980 			default:
1981 				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));
1982 				return B_ERROR;
1983 		}
1984 		break;
1985 */	}
1986 
1987 	/* set virtual_width limit for accelerated modes */
1988 	/* note:
1989 	 * because of the seemingly 'random' variations in these constraints we take
1990 	 * a reasonable 'lowest common denominator' instead of always true constraints. */
1991 	switch (si->ps.card_arch)
1992 	{
1993 	case NV04A:
1994 		/* confirmed for:
1995 		 * TNT1 (NV04), TNT2 (NV05), TNT2-M64 (NV05M64) in both PIO and DMA acc mode. */
1996 		switch(target->space)
1997 		{
1998 			case B_CMAP8: max_acc_width = 8176; break;
1999 			case B_RGB15: max_acc_width = 4088; break;
2000 			case B_RGB16: max_acc_width = 4088; break;
2001 			case B_RGB24: max_acc_width = 2720; break;
2002 			case B_RGB32: max_acc_width = 2044; break;
2003 			default:
2004 				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));
2005 				return B_ERROR;
2006 		}
2007 		break;
2008 	default:
2009 		/* confirmed for:
2010 		 * GeForce4 Ti4200 (NV28), GeForceFX 5600 (NV31) in PIO acc mode;
2011 		 * GeForce2 MX400 (NV11), GeForce4 MX440 (NV18), GeForceFX 5200 (NV34) can do
2012 		 * 16368/8184/8184/5456/4092, so a bit better in PIO acc mode;
2013 		 * confirmed for:
2014 		 * GeForce2 MX400 (NV11), GeForce4 MX440 (NV18), GeForcePCX 5750 (NV36),
2015 		 * GeForcePCX 6600 GT (NV43) in DMA acc mode;
2016 		 * GeForce4 Ti4200 (NV28), GeForceFX 5200 (NV34) can do
2017 		 * 16368/8184/8184/5456/4092, so a bit better in DMA acc mode. */
2018 		switch(target->space)
2019 		{
2020 			case B_CMAP8: max_acc_width = 16320; break;
2021 			case B_RGB15: max_acc_width =  8160; break;
2022 			case B_RGB16: max_acc_width =  8160; break;
2023 			case B_RGB24: max_acc_width =  5440; break;
2024 			case B_RGB32: max_acc_width =  4080; break;
2025 			default:
2026 				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));
2027 				return B_ERROR;
2028 		}
2029 		break;
2030 	}
2031 
2032 	/* set virtual_width limit for unaccelerated modes */
2033 	switch (si->ps.card_type)
2034 	{
2035 	default:
2036 //	case NV04:
2037 		/* confirmed for:
2038 		 * TNT1 always;
2039 		 * TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForce4 Ti4200,
2040 		 * GeForceFX 5200: if the CRTC1 (and CRTC2) BUFFER register b2 = 0 */
2041 		/* NOTE:
2042 		 * Unfortunately older cards have a hardware fault that prevents use.
2043 		 * We need doubled granularity on those to prevent the single top line
2044 		 * from shifting to the left!
2045 		 * This is confirmed for TNT2, GeForce2 MX200, GeForce2 MX400.
2046 		 * Confirmed OK are:
2047 		 * GeForce4 MX440, GeForce4 Ti4200, GeForceFX 5200. */
2048 		switch(target->space)
2049 		{
2050 			case B_CMAP8: max_crtc_width = 16368; break; /* 16376 */
2051 			case B_RGB15: max_crtc_width =  8184; break; /*  8188 */
2052 			case B_RGB16: max_crtc_width =  8184; break; /*  8188 */
2053 			case B_RGB24: max_crtc_width =  5456; break; /*  5456 */
2054 			case B_RGB32: max_crtc_width =  4092; break; /*  4094 */
2055 			default:
2056 				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));
2057 				return B_ERROR;
2058 		}
2059 		break;
2060 //	default:
2061 		/* confirmed for:
2062 		 * TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForce4 Ti4200,
2063 		 * GeForceFX 5200: if the CRTC1 (and CRTC2) BUFFER register b2 = 1 */
2064 /*		switch(target->space)
2065 		{
2066 			case B_CMAP8: max_crtc_width = 16352; break;
2067 			case B_RGB15: max_crtc_width =  8176; break;
2068 			case B_RGB16: max_crtc_width =  8176; break;
2069 			case B_RGB24: max_crtc_width =  5440; break;
2070 			case B_RGB32: max_crtc_width =  4088; break;
2071 			default:
2072 				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));
2073 				return B_ERROR;
2074 		}
2075 		break;
2076 */	}
2077 
2078 	/* check for acc capability, and adjust mode to adhere to hardware constraints */
2079 	if (max_acc_width <= max_crtc_width)
2080 	{
2081 		/* check if we can setup this mode with acceleration */
2082 		*acc_mode = true;
2083 		//no acc support for G8x yet!
2084 		if (si->ps.card_arch >= NV50A) *acc_mode = false;
2085 
2086 		/* virtual_width */
2087 		if (target->virtual_width > max_acc_width) *acc_mode = false;
2088 		/* virtual_height */
2089 		/* (NV cards can even do more than this(?)...
2090 		 *  but 4096 is confirmed on all cards at max. accelerated width.) */
2091 		if (target->virtual_height > 4096) *acc_mode = false;
2092 
2093 		/* now check virtual_size based on CRTC constraints */
2094 		if (target->virtual_width > max_crtc_width) target->virtual_width = max_crtc_width;
2095 		/* virtual_height: The only constraint here is the cards memory size which is
2096 		 * checked later on in ProposeMode: virtual_height is adjusted then if needed.
2097 		 * 'Limiting here' to the variable size that's at least available (uint16). */
2098 		if (target->virtual_height > 65535) target->virtual_height = 65535;
2099 
2100 		/* OK, now we know that virtual_width is valid, and it's needing no slopspace if
2101 		 * it was confined above, so we can finally calculate safely if we need slopspace
2102 		 * for this mode... */
2103 		if (*acc_mode)
2104 		{
2105 			/* the mode needs to adhere to the largest granularity imposed... */
2106 			if (acc_mask < crtc_mask)
2107 				video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask);
2108 			else
2109 				video_pitch = ((target->virtual_width + acc_mask) & ~acc_mask);
2110 		}
2111 		else /* unaccelerated mode */
2112 			video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask);
2113 	}
2114 	else /* max_acc_width > max_crtc_width */
2115 	{
2116 		/* check if we can setup this mode with acceleration */
2117 		*acc_mode = true;
2118 		//no acc support for G8x yet!
2119 		if (si->ps.card_arch >= NV50A) *acc_mode = false;
2120 		/* (we already know virtual_width will be no problem) */
2121 		/* virtual_height */
2122 		/* (NV cards can even do more than this(?)...
2123 		 *  but 4096 is confirmed on all cards at max. accelerated width.) */
2124 		if (target->virtual_height > 4096) *acc_mode = false;
2125 
2126 		/* now check virtual_size based on CRTC constraints */
2127 		if (*acc_mode)
2128 		{
2129 			/* note that max_crtc_width already adheres to crtc_mask */
2130 			if (target->virtual_width > (max_crtc_width & ~acc_mask))
2131 					target->virtual_width = (max_crtc_width & ~acc_mask);
2132 		}
2133 		else /* unaccelerated mode */
2134 		{
2135 			if (target->virtual_width > max_crtc_width)
2136 					target->virtual_width = max_crtc_width;
2137 		}
2138 		/* virtual_height: The only constraint here is the cards memory size which is
2139 		 * checked later on in ProposeMode: virtual_height is adjusted then if needed.
2140 		 * 'Limiting here' to the variable size that's at least available (uint16). */
2141 		if (target->virtual_height > 65535) target->virtual_height = 65535;
2142 
2143 		/* OK, now we know that virtual_width is valid, and it's needing no slopspace if
2144 		 * it was confined above, so we can finally calculate safely if we need slopspace
2145 		 * for this mode... */
2146 		if (*acc_mode)
2147 		{
2148 			/* the mode needs to adhere to the largest granularity imposed... */
2149 			if (acc_mask < crtc_mask)
2150 				video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask);
2151 			else
2152 				video_pitch = ((target->virtual_width + acc_mask) & ~acc_mask);
2153 		}
2154 		else /* unaccelerated mode */
2155 			video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask);
2156 	}
2157 
2158 	LOG(2,("INIT: memory pitch will be set to %d pixels for colorspace 0x%08x\n",
2159 														video_pitch, target->space));
2160 	if (target->virtual_width != video_pitch)
2161 		LOG(2,("INIT: effective mode slopspace is %d pixels\n",
2162 											(video_pitch - target->virtual_width)));
2163 
2164 	/* now calculate bytes_per_row for this mode */
2165 	*bytes_per_row = video_pitch * (depth >> 3);
2166 
2167 	return B_OK;
2168 }
2169