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