1 /* Authors: 2 Mark Watson 12/1999, 3 Apsed, 4 Rudolf Cornelissen 10/2002-6/2005 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 status_t nv_general_bios_to_powergraphics(void); 14 15 static void nv_dump_configuration_space (void) 16 { 17 #define DUMP_CFG(reg, type) if (si->ps.card_type >= type) do { \ 18 uint32 value = CFGR(reg); \ 19 MSG(("configuration_space 0x%02x %20s 0x%08x\n", \ 20 NVCFG_##reg, #reg, value)); \ 21 } while (0) 22 DUMP_CFG (DEVID, 0); 23 DUMP_CFG (DEVCTRL, 0); 24 DUMP_CFG (CLASS, 0); 25 DUMP_CFG (HEADER, 0); 26 DUMP_CFG (BASE1REGS,0); 27 DUMP_CFG (BASE2FB, 0); 28 DUMP_CFG (BASE3, 0); 29 DUMP_CFG (BASE4, 0); 30 DUMP_CFG (BASE5, 0); 31 DUMP_CFG (BASE6, 0); 32 DUMP_CFG (BASE7, 0); 33 DUMP_CFG (SUBSYSID1,0); 34 DUMP_CFG (ROMBASE, 0); 35 DUMP_CFG (CAPPTR, 0); 36 DUMP_CFG (CFG_1, 0); 37 DUMP_CFG (INTERRUPT,0); 38 DUMP_CFG (SUBSYSID2,0); 39 DUMP_CFG (AGPREF, 0); 40 DUMP_CFG (AGPSTAT, 0); 41 DUMP_CFG (AGPCMD, 0); 42 DUMP_CFG (ROMSHADOW,0); 43 DUMP_CFG (VGA, 0); 44 DUMP_CFG (SCHRATCH, 0); 45 DUMP_CFG (CFG_10, 0); 46 DUMP_CFG (CFG_11, 0); 47 DUMP_CFG (CFG_12, 0); 48 DUMP_CFG (CFG_13, 0); 49 DUMP_CFG (CFG_14, 0); 50 DUMP_CFG (CFG_15, 0); 51 DUMP_CFG (CFG_16, 0); 52 DUMP_CFG (PCIEREF, 0); 53 DUMP_CFG (PCIEDCAP, 0); 54 DUMP_CFG (PCIEDCTST,0); 55 DUMP_CFG (PCIELCAP, 0); 56 DUMP_CFG (PCIELCTST,0); 57 DUMP_CFG (CFG_22, 0); 58 DUMP_CFG (CFG_23, 0); 59 DUMP_CFG (CFG_24, 0); 60 DUMP_CFG (CFG_25, 0); 61 DUMP_CFG (CFG_26, 0); 62 DUMP_CFG (CFG_27, 0); 63 DUMP_CFG (CFG_28, 0); 64 DUMP_CFG (CFG_29, 0); 65 DUMP_CFG (CFG_30, 0); 66 DUMP_CFG (CFG_31, 0); 67 DUMP_CFG (CFG_32, 0); 68 DUMP_CFG (CFG_33, 0); 69 DUMP_CFG (CFG_34, 0); 70 DUMP_CFG (CFG_35, 0); 71 DUMP_CFG (CFG_36, 0); 72 DUMP_CFG (CFG_37, 0); 73 DUMP_CFG (CFG_38, 0); 74 DUMP_CFG (CFG_39, 0); 75 DUMP_CFG (CFG_40, 0); 76 DUMP_CFG (CFG_41, 0); 77 DUMP_CFG (CFG_42, 0); 78 DUMP_CFG (CFG_43, 0); 79 DUMP_CFG (CFG_44, 0); 80 DUMP_CFG (CFG_45, 0); 81 DUMP_CFG (CFG_46, 0); 82 DUMP_CFG (CFG_47, 0); 83 DUMP_CFG (CFG_48, 0); 84 DUMP_CFG (CFG_49, 0); 85 DUMP_CFG (CFG_50, 0); 86 #undef DUMP_CFG 87 } 88 89 status_t nv_general_powerup() 90 { 91 status_t status; 92 93 LOG(1,("POWERUP: Haiku nVidia Accelerant 0.53 running.\n")); 94 95 /* preset no laptop */ 96 si->ps.laptop = false; 97 98 /* detect card type and power it up */ 99 switch(CFGR(DEVID)) 100 { 101 /* Vendor Nvidia */ 102 case 0x002010de: /* Nvidia TNT1 */ 103 si->ps.card_type = NV04; 104 si->ps.card_arch = NV04A; 105 LOG(4,("POWERUP: Detected Nvidia TNT1 (NV04)\n")); 106 status = nvxx_general_powerup(); 107 break; 108 case 0x002810de: /* Nvidia TNT2 (pro) */ 109 case 0x002910de: /* Nvidia TNT2 Ultra */ 110 case 0x002a10de: /* Nvidia TNT2 */ 111 case 0x002b10de: /* Nvidia TNT2 */ 112 si->ps.card_type = NV05; 113 si->ps.card_arch = NV04A; 114 LOG(4,("POWERUP: Detected Nvidia TNT2 (NV05)\n")); 115 status = nvxx_general_powerup(); 116 break; 117 case 0x002c10de: /* Nvidia Vanta (Lt) */ 118 si->ps.card_type = NV05; 119 si->ps.card_arch = NV04A; 120 LOG(4,("POWERUP: Detected Nvidia Vanta (Lt) (NV05)\n")); 121 status = nvxx_general_powerup(); 122 break; 123 case 0x002d10de: /* Nvidia TNT2-M64 (Pro) */ 124 si->ps.card_type = NV05M64; 125 si->ps.card_arch = NV04A; 126 LOG(4,("POWERUP: Detected Nvidia TNT2-M64 (Pro) (NV05M64)\n")); 127 status = nvxx_general_powerup(); 128 break; 129 case 0x002e10de: /* Nvidia NV06 Vanta */ 130 case 0x002f10de: /* Nvidia NV06 Vanta */ 131 si->ps.card_type = NV06; 132 si->ps.card_arch = NV04A; 133 LOG(4,("POWERUP: Detected Nvidia Vanta (NV06)\n")); 134 status = nvxx_general_powerup(); 135 break; 136 case 0x004010de: /* Nvidia GeForce FX 6800 Ultra */ 137 case 0x004110de: /* Nvidia GeForce FX 6800 */ 138 case 0x004210de: /* Nvidia GeForce FX 6800LE */ 139 si->ps.card_type = NV40; 140 si->ps.card_arch = NV40A; 141 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6800 (NV40)\n")); 142 status = nvxx_general_powerup(); 143 break; 144 case 0x004310de: /* Nvidia unknown FX */ 145 si->ps.card_type = NV40; 146 si->ps.card_arch = NV40A; 147 LOG(4,("POWERUP: Detected Nvidia unknown FX (NV40)\n")); 148 status = nvxx_general_powerup(); 149 break; 150 case 0x004510de: /* Nvidia GeForce FX 6800 GT */ 151 si->ps.card_type = NV40; 152 si->ps.card_arch = NV40A; 153 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6800 GT (NV40)\n")); 154 status = nvxx_general_powerup(); 155 break; 156 case 0x004d10de: /* Nvidia Quadro FX 4400 */ 157 case 0x004e10de: /* Nvidia Quadro FX 4000 */ 158 si->ps.card_type = NV40; 159 si->ps.card_arch = NV40A; 160 LOG(4,("POWERUP: Detected Nvidia Quadro FX 4000/4400 (NV40)\n")); 161 status = nvxx_general_powerup(); 162 break; 163 case 0x00a010de: /* Nvidia Aladdin TNT2 */ 164 si->ps.card_type = NV05; 165 si->ps.card_arch = NV04A; 166 LOG(4,("POWERUP: Detected Nvidia Aladdin TNT2 (NV05)\n")); 167 status = nvxx_general_powerup(); 168 break; 169 case 0x00c010de: /* Nvidia unknown FX */ 170 si->ps.card_type = NV41; 171 si->ps.card_arch = NV40A; 172 LOG(4,("POWERUP: Detected Nvidia unknown FX (NV41)\n")); 173 status = nvxx_general_powerup(); 174 break; 175 case 0x00c110de: /* Nvidia GeForce FX 6800 */ 176 case 0x00c210de: /* Nvidia GeForce FX 6800LE */ 177 si->ps.card_type = NV41; 178 si->ps.card_arch = NV40A; 179 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6800 (NV41)\n")); 180 status = nvxx_general_powerup(); 181 break; 182 case 0x00c810de: /* Nvidia GeForce FX 6800 Go */ 183 case 0x00c910de: /* Nvidia GeForce FX 6800 Ultra Go */ 184 si->ps.card_type = NV41; 185 si->ps.card_arch = NV40A; 186 si->ps.laptop = true; 187 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6800 Go (NV41)\n")); 188 status = nvxx_general_powerup(); 189 break; 190 case 0x00cc10de: /* Nvidia Quadro FX 1400 Go */ 191 si->ps.card_type = NV41; 192 si->ps.card_arch = NV40A; 193 si->ps.laptop = true; 194 LOG(4,("POWERUP: Detected Nvidia Quadro FX 1400 Go (NV41)\n")); 195 status = nvxx_general_powerup(); 196 break; 197 case 0x00cd10de: /* Nvidia Quadro FX 3450/4000 SDI */ 198 si->ps.card_type = NV41; 199 si->ps.card_arch = NV40A; 200 LOG(4,("POWERUP: Detected Nvidia Quadro FX 3450/4000 SDI (NV41)\n")); 201 status = nvxx_general_powerup(); 202 break; 203 case 0x00ce10de: /* Nvidia Quadro FX 1400 */ 204 si->ps.card_type = NV41; 205 si->ps.card_arch = NV40A; 206 LOG(4,("POWERUP: Detected Nvidia Quadro FX 1400 (NV41)\n")); 207 status = nvxx_general_powerup(); 208 break; 209 case 0x00f010de: /* Nvidia GeForce FX 6800 (Ultra) AGP(?) */ 210 si->ps.card_type = NV40; 211 si->ps.card_arch = NV40A; 212 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6800 AGP(?) (NV40(?))\n")); 213 status = nvxx_general_powerup(); 214 break; 215 case 0x00f110de: /* Nvidia GeForce FX 6600 GT AGP */ 216 case 0x00f210de: /* Nvidia GeForce FX 6600 AGP */ 217 si->ps.card_type = NV43; 218 si->ps.card_arch = NV40A; 219 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6600 (GT) AGP (NV43)\n")); 220 status = nvxx_general_powerup(); 221 break; 222 case 0x00f310de: /* Nvidia GeForce 6200 */ 223 si->ps.card_type = NV44; 224 si->ps.card_arch = NV40A; 225 LOG(4,("POWERUP: Detected Nvidia GeForce 6200 (NV44)\n")); 226 status = nvxx_general_powerup(); 227 break; 228 case 0x00f810de: /* Nvidia Quadro FX 3400/4400 PCIe */ 229 si->ps.card_type = NV45; 230 si->ps.card_arch = NV40A; 231 LOG(4,("POWERUP: Detected Nvidia Quadro FX 3400 PCIe (NV45)\n")); 232 status = nvxx_general_powerup(); 233 break; 234 case 0x00f910de: /* Nvidia GeForce PCX 6800 PCIe */ 235 si->ps.card_type = NV45; 236 si->ps.card_arch = NV40A; 237 LOG(4,("POWERUP: Detected Nvidia GeForce PCX 6800 PCIe (NV45)\n")); 238 status = nvxx_general_powerup(); 239 break; 240 case 0x00fa10de: /* Nvidia GeForce PCX 5750 PCIe */ 241 si->ps.card_type = NV36; 242 si->ps.card_arch = NV30A; 243 LOG(4,("POWERUP: Detected Nvidia GeForce PCX 5750 PCIe (NV36)\n")); 244 status = nvxx_general_powerup(); 245 break; 246 case 0x00fb10de: /* Nvidia GeForce PCX 5900 PCIe */ 247 si->ps.card_type = NV35; 248 si->ps.card_arch = NV30A; 249 LOG(4,("POWERUP: Detected Nvidia GeForce PCX 5900 PCIe (NV35(?))\n")); 250 status = nvxx_general_powerup(); 251 break; 252 case 0x00fc10de: /* Nvidia GeForce PCX 5300 PCIe */ 253 si->ps.card_type = NV34; 254 si->ps.card_arch = NV30A; 255 LOG(4,("POWERUP: Detected Nvidia GeForce PCX 5300 PCIe (NV34)\n")); 256 status = nvxx_general_powerup(); 257 break; 258 case 0x00fd10de: /* Nvidia Quadro PCX PCIe */ 259 si->ps.card_type = NV45; 260 si->ps.card_arch = NV40A; 261 LOG(4,("POWERUP: Detected Nvidia Quadro PCX PCIe (NV45)\n")); 262 status = nvxx_general_powerup(); 263 break; 264 case 0x00fe10de: /* Nvidia Quadro FX 1300 PCIe(?) */ 265 si->ps.card_type = NV36; 266 si->ps.card_arch = NV30A; 267 LOG(4,("POWERUP: Detected Nvidia Quadro FX 1300 PCIe(?) (NV36(?))\n")); 268 status = nvxx_general_powerup(); 269 break; 270 case 0x00ff10de: /* Nvidia GeForce PCX 4300 PCIe */ 271 si->ps.card_type = NV18; 272 si->ps.card_arch = NV10A; 273 LOG(4,("POWERUP: Detected Nvidia GeForce PCX 4300 PCIe (NV18)\n")); 274 status = nvxx_general_powerup(); 275 break; 276 case 0x010010de: /* Nvidia GeForce256 SDR */ 277 case 0x010110de: /* Nvidia GeForce256 DDR */ 278 case 0x010210de: /* Nvidia GeForce256 Ultra */ 279 si->ps.card_type = NV10; 280 si->ps.card_arch = NV10A; 281 LOG(4,("POWERUP: Detected Nvidia GeForce256 (NV10)\n")); 282 status = nvxx_general_powerup(); 283 break; 284 case 0x010310de: /* Nvidia Quadro */ 285 si->ps.card_type = NV10; 286 si->ps.card_arch = NV10A; 287 LOG(4,("POWERUP: Detected Nvidia Quadro (NV10)\n")); 288 status = nvxx_general_powerup(); 289 break; 290 case 0x011010de: /* Nvidia GeForce2 MX/MX400 */ 291 case 0x011110de: /* Nvidia GeForce2 MX100/MX200 DDR */ 292 si->ps.card_type = NV11; 293 si->ps.card_arch = NV10A; 294 LOG(4,("POWERUP: Detected Nvidia GeForce2 MX (NV11)\n")); 295 status = nvxx_general_powerup(); 296 break; 297 case 0x011210de: /* Nvidia GeForce2 Go */ 298 si->ps.card_type = NV11; 299 si->ps.card_arch = NV10A; 300 si->ps.laptop = true; 301 LOG(4,("POWERUP: Detected Nvidia GeForce2 Go (NV11)\n")); 302 status = nvxx_general_powerup(); 303 break; 304 case 0x011310de: /* Nvidia Quadro2 MXR/EX/Go */ 305 si->ps.card_type = NV11; 306 si->ps.card_arch = NV10A; 307 LOG(4,("POWERUP: Detected Nvidia Quadro2 MXR/EX/Go (NV11)\n")); 308 status = nvxx_general_powerup(); 309 break; 310 case 0x014010de: /* Nvidia GeForce FX 6600 GT */ 311 case 0x014110de: /* Nvidia GeForce FX 6600 */ 312 si->ps.card_type = NV43; 313 si->ps.card_arch = NV40A; 314 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6600 (NV43)\n")); 315 status = nvxx_general_powerup(); 316 break; 317 case 0x014410de: /* Nvidia GeForce FX 6600 Go */ 318 si->ps.card_type = NV43; 319 si->ps.card_arch = NV40A; 320 si->ps.laptop = true; 321 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6600 Go (NV43)\n")); 322 status = nvxx_general_powerup(); 323 break; 324 case 0x014510de: /* Nvidia GeForce FX 6610 XL */ 325 si->ps.card_type = NV43; 326 si->ps.card_arch = NV40A; 327 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6610 XL (NV43)\n")); 328 status = nvxx_general_powerup(); 329 break; 330 case 0x014610de: /* Nvidia GeForce FX 6600 TE Go / 6200 TE Go */ 331 case 0x014810de: /* Nvidia GeForce FX 6600 Go */ 332 si->ps.card_type = NV43; 333 si->ps.card_arch = NV40A; 334 si->ps.laptop = true; 335 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6600 Go / 6200 Go (NV43)\n")); 336 status = nvxx_general_powerup(); 337 break; 338 case 0x014e10de: /* Nvidia Quadro FX 540 */ 339 si->ps.card_type = NV43; 340 si->ps.card_arch = NV40A; 341 LOG(4,("POWERUP: Detected Nvidia Quadro FX 540 (NV43)\n")); 342 status = nvxx_general_powerup(); 343 break; 344 case 0x014f10de: /* Nvidia GeForce 6200 PCIe (128Mb) */ 345 si->ps.card_type = NV44; 346 si->ps.card_arch = NV40A; 347 LOG(4,("POWERUP: Detected Nvidia GeForce 6200 PCIe (128Mb) (NV44)\n")); 348 status = nvxx_general_powerup(); 349 break; 350 case 0x015010de: /* Nvidia GeForce2 GTS/Pro */ 351 case 0x015110de: /* Nvidia GeForce2 Ti DDR */ 352 case 0x015210de: /* Nvidia GeForce2 Ultra */ 353 si->ps.card_type = NV15; 354 si->ps.card_arch = NV10A; 355 LOG(4,("POWERUP: Detected Nvidia GeForce2 (NV15)\n")); 356 status = nvxx_general_powerup(); 357 break; 358 case 0x015310de: /* Nvidia Quadro2 Pro */ 359 si->ps.card_type = NV15; 360 si->ps.card_arch = NV10A; 361 LOG(4,("POWERUP: Detected Nvidia Quadro2 Pro (NV15)\n")); 362 status = nvxx_general_powerup(); 363 break; 364 case 0x016010de: /* Nvidia unknown FX Go */ 365 si->ps.card_type = NV44; 366 si->ps.card_arch = NV40A; 367 si->ps.laptop = true; 368 LOG(4,("POWERUP: Detected Nvidia unknown FX Go (NV44)\n")); 369 status = nvxx_general_powerup(); 370 break; 371 case 0x016110de: /* Nvidia GeForce 6200 TurboCache */ 372 si->ps.card_type = NV44; 373 si->ps.card_arch = NV40A; 374 LOG(4,("POWERUP: Detected Nvidia GeForce 6200 TurboCache (NV44)\n")); 375 status = nvxx_general_powerup(); 376 break; 377 case 0x016210de: /* Nvidia GeForce 6200SE TurboCache */ 378 si->ps.card_type = NV44; 379 si->ps.card_arch = NV40A; 380 LOG(4,("POWERUP: Detected Nvidia GeForce 6200SE TurboCache (NV44)\n")); 381 status = nvxx_general_powerup(); 382 break; 383 case 0x016310de: /* Nvidia unknown FX */ 384 si->ps.card_type = NV44; 385 si->ps.card_arch = NV40A; 386 LOG(4,("POWERUP: Detected Nvidia unknown FX (NV44)\n")); 387 status = nvxx_general_powerup(); 388 break; 389 case 0x016410de: /* Nvidia GeForce FX 6200 Go */ 390 si->ps.card_type = NV44; 391 si->ps.card_arch = NV40A; 392 si->ps.laptop = true; 393 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6200 Go (NV44)\n")); 394 status = nvxx_general_powerup(); 395 break; 396 case 0x016510de: /* Nvidia Quadro FX NVS 285 */ 397 si->ps.card_type = NV44; 398 si->ps.card_arch = NV40A; 399 LOG(4,("POWERUP: Detected Nvidia Quadro FX NVS 285 (NV44)\n")); 400 status = nvxx_general_powerup(); 401 break; 402 case 0x016610de: /* Nvidia unknown FX Go */ 403 si->ps.card_type = NV44; 404 si->ps.card_arch = NV40A; 405 si->ps.laptop = true; 406 LOG(4,("POWERUP: Detected Nvidia unknown FX Go (NV44)\n")); 407 status = nvxx_general_powerup(); 408 break; 409 case 0x016710de: /* Nvidia GeForce 6200 Go */ 410 si->ps.card_type = NV44; 411 si->ps.card_arch = NV40A; 412 si->ps.laptop = true; 413 LOG(4,("POWERUP: Detected Nvidia GeForce 6200 Go (NV44)\n")); 414 status = nvxx_general_powerup(); 415 break; 416 case 0x016810de: /* Nvidia GeForce 6250 Go */ 417 si->ps.card_type = NV44; 418 si->ps.card_arch = NV40A; 419 si->ps.laptop = true; 420 LOG(4,("POWERUP: Detected Nvidia GeForce 6250 Go (NV44)\n")); 421 status = nvxx_general_powerup(); 422 break; 423 case 0x016e10de: /* Nvidia unknown FX */ 424 si->ps.card_type = NV44; 425 si->ps.card_arch = NV40A; 426 LOG(4,("POWERUP: Detected Nvidia unknown FX (NV44)\n")); 427 status = nvxx_general_powerup(); 428 break; 429 case 0x017010de: /* Nvidia GeForce4 MX 460 */ 430 case 0x017110de: /* Nvidia GeForce4 MX 440 */ 431 case 0x017210de: /* Nvidia GeForce4 MX 420 */ 432 case 0x017310de: /* Nvidia GeForce4 MX 440SE */ 433 si->ps.card_type = NV17; 434 si->ps.card_arch = NV10A; 435 LOG(4,("POWERUP: Detected Nvidia GeForce4 MX (NV17)\n")); 436 status = nvxx_general_powerup(); 437 break; 438 case 0x017410de: /* Nvidia GeForce4 440 Go */ 439 case 0x017510de: /* Nvidia GeForce4 420 Go */ 440 case 0x017610de: /* Nvidia GeForce4 420 Go 32M */ 441 case 0x017710de: /* Nvidia GeForce4 460 Go */ 442 case 0x017910de: /* Nvidia GeForce4 440 Go 64M (on PPC GeForce4 MX) */ 443 si->ps.card_type = NV17; 444 si->ps.card_arch = NV10A; 445 si->ps.laptop = true; 446 LOG(4,("POWERUP: Detected Nvidia GeForce4 Go (NV17)\n")); 447 status = nvxx_general_powerup(); 448 break; 449 case 0x017810de: /* Nvidia Quadro4 500 XGL/550 XGL */ 450 case 0x017a10de: /* Nvidia Quadro4 200 NVS/400 NVS */ 451 si->ps.card_type = NV17; 452 si->ps.card_arch = NV10A; 453 LOG(4,("POWERUP: Detected Nvidia Quadro4 (NV17)\n")); 454 status = nvxx_general_powerup(); 455 break; 456 case 0x017c10de: /* Nvidia Quadro4 500 GoGL */ 457 si->ps.card_type = NV17; 458 si->ps.card_arch = NV10A; 459 si->ps.laptop = true; 460 LOG(4,("POWERUP: Detected Nvidia Quadro4 500 GoGL (NV17)\n")); 461 status = nvxx_general_powerup(); 462 break; 463 case 0x017d10de: /* Nvidia GeForce4 410 Go 16M*/ 464 si->ps.card_type = NV17; 465 si->ps.card_arch = NV10A; 466 si->ps.laptop = true; 467 LOG(4,("POWERUP: Detected Nvidia GeForce4 410 Go (NV17)\n")); 468 status = nvxx_general_powerup(); 469 break; 470 case 0x018110de: /* Nvidia GeForce4 MX 440 AGP8X */ 471 case 0x018210de: /* Nvidia GeForce4 MX 440SE AGP8X */ 472 case 0x018310de: /* Nvidia GeForce4 MX 420 AGP8X */ 473 case 0x018510de: /* Nvidia GeForce4 MX 4000 AGP8X */ 474 si->ps.card_type = NV18; 475 si->ps.card_arch = NV10A; 476 LOG(4,("POWERUP: Detected Nvidia GeForce4 MX AGP8X (NV18)\n")); 477 status = nvxx_general_powerup(); 478 break; 479 case 0x018610de: /* Nvidia GeForce4 448 Go */ 480 case 0x018710de: /* Nvidia GeForce4 488 Go */ 481 si->ps.card_type = NV18; 482 si->ps.card_arch = NV10A; 483 si->ps.laptop = true; 484 LOG(4,("POWERUP: Detected Nvidia GeForce4 Go (NV18)\n")); 485 status = nvxx_general_powerup(); 486 break; 487 case 0x018810de: /* Nvidia Quadro4 580 XGL */ 488 si->ps.card_type = NV18; 489 si->ps.card_arch = NV10A; 490 LOG(4,("POWERUP: Detected Nvidia Quadro4 (NV18)\n")); 491 status = nvxx_general_powerup(); 492 break; 493 case 0x018910de: /* Nvidia GeForce4 MX AGP8X */ 494 si->ps.card_type = NV18; 495 si->ps.card_arch = NV10A; 496 LOG(4,("POWERUP: Detected Nvidia GeForce4 MX AGP8X (NV18)\n")); 497 status = nvxx_general_powerup(); 498 break; 499 case 0x018a10de: /* Nvidia Quadro4 280 NVS AGP8X */ 500 case 0x018b10de: /* Nvidia Quadro4 380 XGL */ 501 case 0x018c10de: /* Nvidia Quadro4 NVS 50 PCI */ 502 si->ps.card_type = NV18; 503 si->ps.card_arch = NV10A; 504 LOG(4,("POWERUP: Detected Nvidia Quadro4 (NV18)\n")); 505 status = nvxx_general_powerup(); 506 break; 507 case 0x018d10de: /* Nvidia GeForce4 448 Go */ 508 si->ps.card_type = NV18; 509 si->ps.card_arch = NV10A; 510 si->ps.laptop = true; 511 LOG(4,("POWERUP: Detected Nvidia GeForce4 Go (NV18)\n")); 512 status = nvxx_general_powerup(); 513 break; 514 case 0x01a010de: /* Nvidia GeForce2 Integrated GPU */ 515 si->ps.card_type = NV11; 516 si->ps.card_arch = NV10A; 517 LOG(4,("POWERUP: Detected Nvidia GeForce2 Integrated GPU (CRUSH, NV11)\n")); 518 status = nvxx_general_powerup(); 519 break; 520 case 0x01f010de: /* Nvidia GeForce4 MX Integrated GPU */ 521 si->ps.card_type = NV17; 522 si->ps.card_arch = NV10A; 523 LOG(4,("POWERUP: Detected Nvidia GeForce4 MX Integrated GPU (NFORCE2, NV17)\n")); 524 status = nvxx_general_powerup(); 525 break; 526 case 0x020010de: /* Nvidia GeForce3 */ 527 case 0x020110de: /* Nvidia GeForce3 Ti 200 */ 528 case 0x020210de: /* Nvidia GeForce3 Ti 500 */ 529 si->ps.card_type = NV20; 530 si->ps.card_arch = NV20A; 531 LOG(4,("POWERUP: Detected Nvidia GeForce3 (NV20)\n")); 532 status = nvxx_general_powerup(); 533 break; 534 case 0x020310de: /* Nvidia Quadro DCC */ 535 si->ps.card_type = NV20; 536 si->ps.card_arch = NV20A; 537 LOG(4,("POWERUP: Detected Nvidia Quadro DCC (NV20)\n")); 538 status = nvxx_general_powerup(); 539 break; 540 case 0x021110de: /* Nvidia GeForce FX 6800 */ 541 case 0x021210de: /* Nvidia GeForce FX 6800LE */ 542 case 0x021510de: /* Nvidia GeForce FX 6800 GT */ 543 si->ps.card_type = NV45; /* NV48 is NV45 with 512Mb */ 544 si->ps.card_arch = NV40A; 545 LOG(4,("POWERUP: Detected Nvidia GeForce FX 6800 (NV48)\n")); 546 status = nvxx_general_powerup(); 547 break; 548 case 0x022110de: /* Nvidia GeForce 6200 AGP (256Mb - 128bit) */ 549 si->ps.card_type = NV44; 550 si->ps.card_arch = NV40A; 551 LOG(4,("POWERUP: Detected Nvidia GeForce 6200 AGP (256Mb - 128bit) (NV44)\n")); 552 status = nvxx_general_powerup(); 553 break; 554 case 0x025010de: /* Nvidia GeForce4 Ti 4600 */ 555 case 0x025110de: /* Nvidia GeForce4 Ti 4400 */ 556 case 0x025210de: /* Nvidia GeForce4 Ti 4600 */ 557 case 0x025310de: /* Nvidia GeForce4 Ti 4200 */ 558 si->ps.card_type = NV25; 559 si->ps.card_arch = NV20A; 560 LOG(4,("POWERUP: Detected Nvidia GeForce4 Ti (NV25)\n")); 561 status = nvxx_general_powerup(); 562 break; 563 case 0x025810de: /* Nvidia Quadro4 900 XGL */ 564 case 0x025910de: /* Nvidia Quadro4 750 XGL */ 565 case 0x025b10de: /* Nvidia Quadro4 700 XGL */ 566 si->ps.card_type = NV25; 567 si->ps.card_arch = NV20A; 568 LOG(4,("POWERUP: Detected Nvidia Quadro4 XGL (NV25)\n")); 569 status = nvxx_general_powerup(); 570 break; 571 case 0x028010de: /* Nvidia GeForce4 Ti 4800 AGP8X */ 572 case 0x028110de: /* Nvidia GeForce4 Ti 4200 AGP8X */ 573 si->ps.card_type = NV28; 574 si->ps.card_arch = NV20A; 575 LOG(4,("POWERUP: Detected Nvidia GeForce4 Ti AGP8X (NV28)\n")); 576 status = nvxx_general_powerup(); 577 break; 578 case 0x028210de: /* Nvidia GeForce4 Ti 4800SE */ 579 si->ps.card_type = NV28; 580 si->ps.card_arch = NV20A; 581 LOG(4,("POWERUP: Detected Nvidia GeForce4 Ti 4800SE (NV28)\n")); 582 status = nvxx_general_powerup(); 583 break; 584 case 0x028610de: /* Nvidia GeForce4 4200 Go */ 585 si->ps.card_type = NV28; 586 si->ps.card_arch = NV20A; 587 si->ps.laptop = true; 588 LOG(4,("POWERUP: Detected Nvidia GeForce4 4200 Go (NV28)\n")); 589 status = nvxx_general_powerup(); 590 break; 591 case 0x028810de: /* Nvidia Quadro4 980 XGL */ 592 case 0x028910de: /* Nvidia Quadro4 780 XGL */ 593 si->ps.card_type = NV28; 594 si->ps.card_arch = NV20A; 595 LOG(4,("POWERUP: Detected Nvidia Quadro4 XGL (NV28)\n")); 596 status = nvxx_general_powerup(); 597 break; 598 case 0x028c10de: /* Nvidia Quadro4 700 GoGL */ 599 si->ps.card_type = NV28; 600 si->ps.card_arch = NV20A; 601 si->ps.laptop = true; 602 LOG(4,("POWERUP: Detected Nvidia Quadro4 700 GoGL (NV28)\n")); 603 status = nvxx_general_powerup(); 604 break; 605 case 0x02a010de: /* Nvidia GeForce3 Integrated GPU */ 606 si->ps.card_type = NV20; 607 si->ps.card_arch = NV20A; 608 LOG(4,("POWERUP: Detected Nvidia GeForce3 Integrated GPU (XBOX, NV20)\n")); 609 status = nvxx_general_powerup(); 610 break; 611 case 0x030110de: /* Nvidia GeForce FX 5800 Ultra */ 612 case 0x030210de: /* Nvidia GeForce FX 5800 */ 613 si->ps.card_type = NV30; 614 si->ps.card_arch = NV30A; 615 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5800 (NV30)\n")); 616 status = nvxx_general_powerup(); 617 break; 618 case 0x030810de: /* Nvidia Quadro FX 2000 */ 619 case 0x030910de: /* Nvidia Quadro FX 1000 */ 620 si->ps.card_type = NV30; 621 si->ps.card_arch = NV30A; 622 LOG(4,("POWERUP: Detected Nvidia Quadro FX (NV30)\n")); 623 status = nvxx_general_powerup(); 624 break; 625 case 0x031110de: /* Nvidia GeForce FX 5600 Ultra */ 626 case 0x031210de: /* Nvidia GeForce FX 5600 */ 627 si->ps.card_type = NV31; 628 si->ps.card_arch = NV30A; 629 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5600 (NV31)\n")); 630 status = nvxx_general_powerup(); 631 break; 632 case 0x031310de: /* Nvidia unknown FX */ 633 si->ps.card_type = NV31; 634 si->ps.card_arch = NV30A; 635 LOG(4,("POWERUP: Detected Nvidia unknown FX (NV31)\n")); 636 status = nvxx_general_powerup(); 637 break; 638 case 0x031410de: /* Nvidia GeForce FX 5600XT */ 639 si->ps.card_type = NV31; 640 si->ps.card_arch = NV30A; 641 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5600XT (NV31)\n")); 642 status = nvxx_general_powerup(); 643 break; 644 case 0x031610de: /* Nvidia unknown FX Go */ 645 case 0x031710de: /* Nvidia unknown FX Go */ 646 si->ps.card_type = NV31; 647 si->ps.card_arch = NV30A; 648 si->ps.laptop = true; 649 LOG(4,("POWERUP: Detected Nvidia unknown FX Go (NV31)\n")); 650 status = nvxx_general_powerup(); 651 break; 652 case 0x031a10de: /* Nvidia GeForce FX 5600 Go */ 653 si->ps.card_type = NV31; 654 si->ps.card_arch = NV30A; 655 si->ps.laptop = true; 656 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5600 Go (NV31)\n")); 657 status = nvxx_general_powerup(); 658 break; 659 case 0x031b10de: /* Nvidia GeForce FX 5650 Go */ 660 si->ps.card_type = NV31; 661 si->ps.card_arch = NV30A; 662 si->ps.laptop = true; 663 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5650 Go (NV31)\n")); 664 status = nvxx_general_powerup(); 665 break; 666 case 0x031c10de: /* Nvidia Quadro FX 700 Go */ 667 si->ps.card_type = NV31; 668 si->ps.card_arch = NV30A; 669 si->ps.laptop = true; 670 LOG(4,("POWERUP: Detected Nvidia Quadro FX 700 Go (NV31)\n")); 671 status = nvxx_general_powerup(); 672 break; 673 case 0x031d10de: /* Nvidia unknown FX Go */ 674 case 0x031e10de: /* Nvidia unknown FX Go */ 675 case 0x031f10de: /* Nvidia unknown FX Go */ 676 si->ps.card_type = NV31; 677 si->ps.card_arch = NV30A; 678 si->ps.laptop = true; 679 LOG(4,("POWERUP: Detected Nvidia unknown FX Go (NV31)\n")); 680 status = nvxx_general_powerup(); 681 break; 682 case 0x032010de: /* Nvidia GeForce FX 5200 */ 683 case 0x032110de: /* Nvidia GeForce FX 5200 Ultra */ 684 case 0x032210de: /* Nvidia GeForce FX 5200 */ 685 case 0x032310de: /* Nvidia GeForce FX 5200LE */ 686 si->ps.card_type = NV34; 687 si->ps.card_arch = NV30A; 688 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5200 (NV34)\n")); 689 status = nvxx_general_powerup(); 690 break; 691 case 0x032410de: /* Nvidia GeForce FX 5200 Go */ 692 si->ps.card_type = NV34; 693 si->ps.card_arch = NV30A; 694 si->ps.laptop = true; 695 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5200 Go (NV34)\n")); 696 status = nvxx_general_powerup(); 697 break; 698 case 0x032510de: /* Nvidia GeForce FX 5250 Go */ 699 si->ps.card_type = NV34; 700 si->ps.card_arch = NV30A; 701 si->ps.laptop = true; 702 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5250 Go (NV34)\n")); 703 status = nvxx_general_powerup(); 704 break; 705 case 0x032610de: /* Nvidia GeForce FX 5500 */ 706 si->ps.card_type = NV34; 707 si->ps.card_arch = NV30A; 708 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5500 (NV34)\n")); 709 status = nvxx_general_powerup(); 710 break; 711 case 0x032710de: /* Nvidia GeForce FX 5100 */ 712 si->ps.card_type = NV34; 713 si->ps.card_arch = NV30A; 714 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5100 (NV34)\n")); 715 status = nvxx_general_powerup(); 716 break; 717 case 0x032810de: /* Nvidia GeForce FX 5200 Go 32M/64M */ 718 si->ps.card_type = NV34; 719 si->ps.card_arch = NV30A; 720 si->ps.laptop = true; 721 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5200 Go (NV34)\n")); 722 status = nvxx_general_powerup(); 723 break; 724 case 0x032910de: /* Nvidia GeForce FX 5200 (PPC) */ 725 si->ps.card_type = NV34; 726 si->ps.card_arch = NV30A; 727 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5200 (NV34)\n")); 728 status = nvxx_general_powerup(); 729 break; 730 case 0x032a10de: /* Nvidia Quadro NVS 280 PCI */ 731 si->ps.card_type = NV34; 732 si->ps.card_arch = NV30A; 733 LOG(4,("POWERUP: Detected Nvidia Quadro NVS 280 PCI (NV34)\n")); 734 status = nvxx_general_powerup(); 735 break; 736 case 0x032b10de: /* Nvidia Quadro FX 500/600 PCI */ 737 si->ps.card_type = NV34; 738 si->ps.card_arch = NV30A; 739 LOG(4,("POWERUP: Detected Nvidia Quadro FX 500/600 PCI (NV34)\n")); 740 status = nvxx_general_powerup(); 741 break; 742 case 0x032c10de: /* Nvidia GeForce FX 5300 Go */ 743 case 0x032d10de: /* Nvidia GeForce FX 5100 Go */ 744 si->ps.card_type = NV34; 745 si->ps.card_arch = NV30A; 746 si->ps.laptop = true; 747 LOG(4,("POWERUP: Detected Nvidia GeForce FX Go (NV34)\n")); 748 status = nvxx_general_powerup(); 749 break; 750 case 0x032e10de: /* Nvidia unknown FX Go */ 751 case 0x032f10de: /* Nvidia unknown FX Go */ 752 si->ps.card_type = NV34; 753 si->ps.card_arch = NV30A; 754 si->ps.laptop = true; 755 LOG(4,("POWERUP: Detected Nvidia unknown FX Go (NV34)\n")); 756 status = nvxx_general_powerup(); 757 break; 758 case 0x033010de: /* Nvidia GeForce FX 5900 Ultra */ 759 case 0x033110de: /* Nvidia GeForce FX 5900 */ 760 si->ps.card_type = NV35; 761 si->ps.card_arch = NV30A; 762 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5900 (NV35)\n")); 763 status = nvxx_general_powerup(); 764 break; 765 case 0x033210de: /* Nvidia GeForce FX 5900 XT */ 766 si->ps.card_type = NV35; 767 si->ps.card_arch = NV30A; 768 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5900 XT (NV35)\n")); 769 status = nvxx_general_powerup(); 770 break; 771 case 0x033310de: /* Nvidia GeForce FX 5950 Ultra */ 772 si->ps.card_type = NV38; 773 si->ps.card_arch = NV30A; 774 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5950 Ultra (NV38)\n")); 775 status = nvxx_general_powerup(); 776 break; 777 case 0x033410de: /* Nvidia GeForce FX 5900 ZT */ 778 si->ps.card_type = NV38; 779 si->ps.card_arch = NV30A; 780 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5900 ZT (NV38(?))\n")); 781 status = nvxx_general_powerup(); 782 break; 783 case 0x033810de: /* Nvidia Quadro FX 3000 */ 784 si->ps.card_type = NV35; 785 si->ps.card_arch = NV30A; 786 LOG(4,("POWERUP: Detected Nvidia Quadro FX 3000 (NV35)\n")); 787 status = nvxx_general_powerup(); 788 break; 789 case 0x033f10de: /* Nvidia Quadro FX 700 */ 790 si->ps.card_type = NV35; 791 si->ps.card_arch = NV30A; 792 LOG(4,("POWERUP: Detected Nvidia Quadro FX 700 (NV35)\n")); 793 status = nvxx_general_powerup(); 794 break; 795 case 0x034110de: /* Nvidia GeForce FX 5700 Ultra */ 796 case 0x034210de: /* Nvidia GeForce FX 5700 */ 797 case 0x034310de: /* Nvidia GeForce FX 5700LE */ 798 case 0x034410de: /* Nvidia GeForce FX 5700VE */ 799 si->ps.card_type = NV36; 800 si->ps.card_arch = NV30A; 801 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5700 (NV36)\n")); 802 status = nvxx_general_powerup(); 803 break; 804 case 0x034710de: /* Nvidia GeForce FX 5700 Go */ 805 case 0x034810de: /* Nvidia GeForce FX 5700 Go */ 806 si->ps.card_type = NV36; 807 si->ps.card_arch = NV30A; 808 si->ps.laptop = true; 809 LOG(4,("POWERUP: Detected Nvidia GeForce FX 5700 Go (NV36)\n")); 810 status = nvxx_general_powerup(); 811 break; 812 case 0x034c10de: /* Nvidia Quadro FX 1000 Go */ 813 si->ps.card_type = NV36; 814 si->ps.card_arch = NV30A; 815 si->ps.laptop = true; 816 LOG(4,("POWERUP: Detected Nvidia Quadro FX 1000 Go (NV36)\n")); 817 status = nvxx_general_powerup(); 818 break; 819 case 0x034e10de: /* Nvidia Quadro FX 1100 */ 820 si->ps.card_type = NV36; 821 si->ps.card_arch = NV30A; 822 LOG(4,("POWERUP: Detected Nvidia Quadro FX 1100 (NV36)\n")); 823 status = nvxx_general_powerup(); 824 break; 825 case 0x034f10de: /* Nvidia unknown FX */ 826 si->ps.card_type = NV36; 827 si->ps.card_arch = NV30A; 828 LOG(4,("POWERUP: Detected Nvidia unknown FX (NV36(?))\n")); 829 status = nvxx_general_powerup(); 830 break; 831 /* Vendor Elsa GmbH */ 832 case 0x0c601048: /* Elsa Gladiac Geforce2 MX */ 833 si->ps.card_type = NV11; 834 si->ps.card_arch = NV10A; 835 LOG(4,("POWERUP: Detected Elsa Gladiac Geforce2 MX (NV11)\n")); 836 status = nvxx_general_powerup(); 837 break; 838 /* Vendor Nvidia STB/SGS-Thompson */ 839 case 0x002012d2: /* Nvidia STB/SGS-Thompson TNT1 */ 840 si->ps.card_type = NV04; 841 si->ps.card_arch = NV04A; 842 LOG(4,("POWERUP: Detected Nvidia STB/SGS-Thompson TNT1 (NV04)\n")); 843 status = nvxx_general_powerup(); 844 break; 845 case 0x002812d2: /* Nvidia STB/SGS-Thompson TNT2 (pro) */ 846 case 0x002912d2: /* Nvidia STB/SGS-Thompson TNT2 Ultra */ 847 case 0x002a12d2: /* Nvidia STB/SGS-Thompson TNT2 */ 848 case 0x002b12d2: /* Nvidia STB/SGS-Thompson TNT2 */ 849 si->ps.card_type = NV05; 850 si->ps.card_arch = NV04A; 851 LOG(4,("POWERUP: Detected Nvidia STB/SGS-Thompson TNT2 (NV05)\n")); 852 status = nvxx_general_powerup(); 853 break; 854 case 0x002c12d2: /* Nvidia STB/SGS-Thompson Vanta (Lt) */ 855 si->ps.card_type = NV05; 856 si->ps.card_arch = NV04A; 857 LOG(4,("POWERUP: Detected Nvidia STB/SGS-Thompson Vanta (Lt) (NV05)\n")); 858 status = nvxx_general_powerup(); 859 break; 860 case 0x002d12d2: /* Nvidia STB/SGS-Thompson TNT2-M64 (Pro) */ 861 si->ps.card_type = NV05M64; 862 si->ps.card_arch = NV04A; 863 LOG(4,("POWERUP: Detected Nvidia STB/SGS-Thompson TNT2-M64 (Pro) (NV05M64)\n")); 864 status = nvxx_general_powerup(); 865 break; 866 case 0x002e12d2: /* Nvidia STB/SGS-Thompson NV06 Vanta */ 867 case 0x002f12d2: /* Nvidia STB/SGS-Thompson NV06 Vanta */ 868 si->ps.card_type = NV06; 869 si->ps.card_arch = NV04A; 870 LOG(4,("POWERUP: Detected Nvidia STB/SGS-Thompson Vanta (NV06)\n")); 871 status = nvxx_general_powerup(); 872 break; 873 case 0x00a012d2: /* Nvidia STB/SGS-Thompson Aladdin TNT2 */ 874 si->ps.card_type = NV05; 875 si->ps.card_arch = NV04A; 876 LOG(4,("POWERUP: Detected Nvidia STB/SGS-Thompson Aladdin TNT2 (NV05)\n")); 877 status = nvxx_general_powerup(); 878 break; 879 /* Vendor Varisys Limited */ 880 case 0x35031888: /* Varisys GeForce4 MX440 */ 881 si->ps.card_type = NV17; 882 si->ps.card_arch = NV10A; 883 LOG(4,("POWERUP: Detected Varisys GeForce4 MX440 (NV17)\n")); 884 status = nvxx_general_powerup(); 885 break; 886 case 0x35051888: /* Varisys GeForce4 Ti 4200 */ 887 si->ps.card_type = NV25; 888 si->ps.card_arch = NV20A; 889 LOG(4,("POWERUP: Detected Varisys GeForce4 Ti 4200 (NV25)\n")); 890 status = nvxx_general_powerup(); 891 break; 892 default: 893 LOG(8,("POWERUP: Failed to detect valid card 0x%08x\n",CFGR(DEVID))); 894 return B_ERROR; 895 } 896 897 return status; 898 } 899 900 static status_t test_ram() 901 { 902 uint32 value, offset; 903 status_t result = B_OK; 904 905 /* make sure we don't corrupt the hardware cursor by using fbc.frame_buffer. */ 906 if (si->fbc.frame_buffer == NULL) 907 { 908 LOG(8,("INIT: test_ram detected NULL pointer.\n")); 909 return B_ERROR; 910 } 911 912 for (offset = 0, value = 0x55aa55aa; offset < 256; offset++) 913 { 914 /* write testpattern to cardRAM */ 915 ((uint32 *)si->fbc.frame_buffer)[offset] = value; 916 /* toggle testpattern */ 917 value = 0xffffffff - value; 918 } 919 920 for (offset = 0, value = 0x55aa55aa; offset < 256; offset++) 921 { 922 /* readback and verify testpattern from cardRAM */ 923 if (((uint32 *)si->fbc.frame_buffer)[offset] != value) result = B_ERROR; 924 /* toggle testpattern */ 925 value = 0xffffffff - value; 926 } 927 return result; 928 } 929 930 /* NOTE: 931 * This routine *has* to be done *after* SetDispplayMode has been executed, 932 * or test results will not be representative! 933 * (CAS latency is dependant on NV setup on some (DRAM) boards) */ 934 status_t nv_set_cas_latency() 935 { 936 status_t result = B_ERROR; 937 uint8 latency = 0; 938 939 /* check current RAM access to see if we need to change anything */ 940 if (test_ram() == B_OK) 941 { 942 LOG(4,("INIT: RAM access OK.\n")); 943 return B_OK; 944 } 945 946 /* check if we read PINS at starttime so we have valid registersettings at our disposal */ 947 if (si->ps.pins_status != B_OK) 948 { 949 LOG(4,("INIT: RAM access errors; not fixable: PINS was not read from cardBIOS.\n")); 950 return B_ERROR; 951 } 952 953 /* OK. We might have a problem, try to fix it now.. */ 954 LOG(4,("INIT: RAM access errors; tuning CAS latency if prudent...\n")); 955 956 switch(si->ps.card_type) 957 { 958 default: 959 LOG(4,("INIT: RAM CAS tuning not implemented for this card, aborting.\n")); 960 return B_OK; 961 break; 962 } 963 if (result == B_OK) 964 LOG(4,("INIT: RAM access OK. CAS latency set to %d cycles.\n", latency)); 965 else 966 LOG(4,("INIT: RAM access not fixable. CAS latency set to %d cycles.\n", latency)); 967 968 return result; 969 } 970 971 void setup_virtualized_heads(bool cross) 972 { 973 if (cross) 974 { 975 head1_validate_timing = (crtc_validate_timing) nv_crtc2_validate_timing; 976 head1_set_timing = (crtc_set_timing) nv_crtc2_set_timing; 977 head1_depth = (crtc_depth) nv_crtc2_depth; 978 head1_dpms = (crtc_dpms) nv_crtc2_dpms; 979 head1_dpms_fetch = (crtc_dpms_fetch) nv_crtc2_dpms_fetch; 980 head1_set_display_pitch = (crtc_set_display_pitch) nv_crtc2_set_display_pitch; 981 head1_set_display_start = (crtc_set_display_start) nv_crtc2_set_display_start; 982 head1_cursor_init = (crtc_cursor_init) nv_crtc2_cursor_init; 983 head1_cursor_show = (crtc_cursor_show) nv_crtc2_cursor_show; 984 head1_cursor_hide = (crtc_cursor_hide) nv_crtc2_cursor_hide; 985 head1_cursor_define = (crtc_cursor_define) nv_crtc2_cursor_define; 986 head1_cursor_position = (crtc_cursor_position) nv_crtc2_cursor_position; 987 988 head1_mode = (dac_mode) nv_dac2_mode; 989 head1_palette = (dac_palette) nv_dac2_palette; 990 head1_set_pix_pll = (dac_set_pix_pll) nv_dac2_set_pix_pll; 991 head1_pix_pll_find = (dac_pix_pll_find) nv_dac2_pix_pll_find; 992 993 head2_validate_timing = (crtc_validate_timing) nv_crtc_validate_timing; 994 head2_set_timing = (crtc_set_timing) nv_crtc_set_timing; 995 head2_depth = (crtc_depth) nv_crtc_depth; 996 head2_dpms = (crtc_dpms) nv_crtc_dpms; 997 head2_dpms_fetch = (crtc_dpms_fetch) nv_crtc_dpms_fetch; 998 head2_set_display_pitch = (crtc_set_display_pitch) nv_crtc_set_display_pitch; 999 head2_set_display_start = (crtc_set_display_start) nv_crtc_set_display_start; 1000 head2_cursor_init = (crtc_cursor_init) nv_crtc_cursor_init; 1001 head2_cursor_show = (crtc_cursor_show) nv_crtc_cursor_show; 1002 head2_cursor_hide = (crtc_cursor_hide) nv_crtc_cursor_hide; 1003 head2_cursor_define = (crtc_cursor_define) nv_crtc_cursor_define; 1004 head2_cursor_position = (crtc_cursor_position) nv_crtc_cursor_position; 1005 1006 head2_mode = (dac_mode) nv_dac_mode; 1007 head2_palette = (dac_palette) nv_dac_palette; 1008 head2_set_pix_pll = (dac_set_pix_pll) nv_dac_set_pix_pll; 1009 head2_pix_pll_find = (dac_pix_pll_find) nv_dac_pix_pll_find; 1010 } 1011 else 1012 { 1013 head1_validate_timing = (crtc_validate_timing) nv_crtc_validate_timing; 1014 head1_set_timing = (crtc_set_timing) nv_crtc_set_timing; 1015 head1_depth = (crtc_depth) nv_crtc_depth; 1016 head1_dpms = (crtc_dpms) nv_crtc_dpms; 1017 head1_dpms_fetch = (crtc_dpms_fetch) nv_crtc_dpms_fetch; 1018 head1_set_display_pitch = (crtc_set_display_pitch) nv_crtc_set_display_pitch; 1019 head1_set_display_start = (crtc_set_display_start) nv_crtc_set_display_start; 1020 head1_cursor_init = (crtc_cursor_init) nv_crtc_cursor_init; 1021 head1_cursor_show = (crtc_cursor_show) nv_crtc_cursor_show; 1022 head1_cursor_hide = (crtc_cursor_hide) nv_crtc_cursor_hide; 1023 head1_cursor_define = (crtc_cursor_define) nv_crtc_cursor_define; 1024 head1_cursor_position = (crtc_cursor_position) nv_crtc_cursor_position; 1025 1026 head1_mode = (dac_mode) nv_dac_mode; 1027 head1_palette = (dac_palette) nv_dac_palette; 1028 head1_set_pix_pll = (dac_set_pix_pll) nv_dac_set_pix_pll; 1029 head1_pix_pll_find = (dac_pix_pll_find) nv_dac_pix_pll_find; 1030 1031 head2_validate_timing = (crtc_validate_timing) nv_crtc2_validate_timing; 1032 head2_set_timing = (crtc_set_timing) nv_crtc2_set_timing; 1033 head2_depth = (crtc_depth) nv_crtc2_depth; 1034 head2_dpms = (crtc_dpms) nv_crtc2_dpms; 1035 head2_dpms_fetch = (crtc_dpms_fetch) nv_crtc2_dpms_fetch; 1036 head2_set_display_pitch = (crtc_set_display_pitch) nv_crtc2_set_display_pitch; 1037 head2_set_display_start = (crtc_set_display_start) nv_crtc2_set_display_start; 1038 head2_cursor_init = (crtc_cursor_init) nv_crtc2_cursor_init; 1039 head2_cursor_show = (crtc_cursor_show) nv_crtc2_cursor_show; 1040 head2_cursor_hide = (crtc_cursor_hide) nv_crtc2_cursor_hide; 1041 head2_cursor_define = (crtc_cursor_define) nv_crtc2_cursor_define; 1042 head2_cursor_position = (crtc_cursor_position) nv_crtc2_cursor_position; 1043 1044 head2_mode = (dac_mode) nv_dac2_mode; 1045 head2_palette = (dac_palette) nv_dac2_palette; 1046 head2_set_pix_pll = (dac_set_pix_pll) nv_dac2_set_pix_pll; 1047 head2_pix_pll_find = (dac_pix_pll_find) nv_dac2_pix_pll_find; 1048 } 1049 } 1050 1051 void set_crtc_owner(bool head) 1052 { 1053 if (si->ps.secondary_head) 1054 { 1055 if (!head) 1056 { 1057 /* note: 'OWNER' is a non-standard register in behaviour(!) on NV11's, 1058 * while non-NV11 cards behave normally. 1059 * 1060 * Double-write action needed on those strange NV11 cards: */ 1061 /* RESET: needed on NV11 */ 1062 CRTCW(OWNER, 0xff); 1063 /* enable access to CRTC1, SEQ1, GRPH1, ATB1, ??? */ 1064 CRTCW(OWNER, 0x00); 1065 } 1066 else 1067 { 1068 /* note: 'OWNER' is a non-standard register in behaviour(!) on NV11's, 1069 * while non-NV11 cards behave normally. 1070 * 1071 * Double-write action needed on those strange NV11 cards: */ 1072 /* RESET: needed on NV11 */ 1073 CRTC2W(OWNER, 0xff); 1074 /* enable access to CRTC2, SEQ2, GRPH2, ATB2, ??? */ 1075 CRTC2W(OWNER, 0x03); 1076 } 1077 } 1078 } 1079 1080 static status_t nvxx_general_powerup() 1081 { 1082 LOG(4, ("INIT: NV powerup\n")); 1083 1084 /* setup cardspecs */ 1085 /* note: 1086 * this MUST be done before the driver attempts a card coldstart */ 1087 set_specs(); 1088 1089 /* only process BIOS for finetuning specs and coldstarting card if requested 1090 * by the user; 1091 * note: 1092 * this in fact frees the driver from relying on the BIOS to be executed 1093 * at system power-up POST time. */ 1094 if (!si->settings.usebios) 1095 { 1096 LOG(2, ("INIT: Attempting card coldstart!\n")); 1097 /* update the cardspecs in the shared_info PINS struct according to reported 1098 * specs as much as is possible; 1099 * this also coldstarts the card if possible (executes BIOS CMD script(s)) */ 1100 parse_pins(); 1101 } 1102 else 1103 { 1104 LOG(2, ("INIT: Skipping card coldstart!\n")); 1105 } 1106 1107 /* get RAM size and fake panel startup (panel init code is still missing) */ 1108 fake_panel_start(); 1109 1110 /* log the final card specifications */ 1111 dump_pins(); 1112 1113 /* dump config space as it is after a possible coldstart attempt */ 1114 if (si->settings.logmask & 0x80000000) nv_dump_configuration_space(); 1115 1116 /* setup CRTC and DAC functions access: determined in fake_panel_start */ 1117 setup_virtualized_heads(si->ps.crtc2_prim); 1118 1119 /* do powerup needed from pre-inited card state as done by system POST cardBIOS 1120 * execution or driver coldstart above */ 1121 return nv_general_bios_to_powergraphics(); 1122 } 1123 1124 /* this routine switches the CRTC/DAC sets to 'connectors', but only for analog 1125 * outputs. We need this to make sure the analog 'switch' is set in the same way the 1126 * digital 'switch' is set by the BIOS or we might not be able to use dualhead. */ 1127 status_t nv_general_output_select(bool cross) 1128 { 1129 /* make sure this call is warranted */ 1130 if (si->ps.secondary_head) 1131 { 1132 /* NV11 cards can't switch heads (confirmed) */ 1133 if (si->ps.card_type != NV11) 1134 { 1135 if (cross) 1136 { 1137 LOG(4,("INIT: switching analog outputs to be cross-connected\n")); 1138 1139 /* enable head 2 on connector 1 */ 1140 /* (b8 = select CRTC (head) for output, 1141 * b4 = ??? (confirmed not to be a FP switch), 1142 * b0 = enable CRT) */ 1143 DACW(OUTPUT, 0x00000101); 1144 /* enable head 1 on connector 2 */ 1145 DAC2W(OUTPUT, 0x00000001); 1146 } 1147 else 1148 { 1149 LOG(4,("INIT: switching analog outputs to be straight-through\n")); 1150 1151 /* enable head 1 on connector 1 */ 1152 DACW(OUTPUT, 0x00000001); 1153 /* enable head 2 on connector 2 */ 1154 DAC2W(OUTPUT, 0x00000101); 1155 } 1156 } 1157 else 1158 { 1159 LOG(4,("INIT: NV11 analog outputs are hardwired to be straight-through\n")); 1160 } 1161 return B_OK; 1162 } 1163 else 1164 { 1165 return B_ERROR; 1166 } 1167 } 1168 1169 /* this routine switches CRTC/DAC set use. We need this because it's unknown howto 1170 * switch digital panels to/from a specific CRTC/DAC set. */ 1171 status_t nv_general_head_select(bool cross) 1172 { 1173 /* make sure this call is warranted */ 1174 if (si->ps.secondary_head) 1175 { 1176 /* invert CRTC/DAC use to do switching */ 1177 if (cross) 1178 { 1179 LOG(4,("INIT: switching CRTC/DAC use to be cross-connected\n")); 1180 si->crtc_switch_mode = !si->ps.crtc2_prim; 1181 } 1182 else 1183 { 1184 LOG(4,("INIT: switching CRTC/DAC use to be straight-through\n")); 1185 si->crtc_switch_mode = si->ps.crtc2_prim; 1186 } 1187 /* update CRTC and DAC functions access */ 1188 setup_virtualized_heads(si->crtc_switch_mode); 1189 1190 return B_OK; 1191 } 1192 else 1193 { 1194 return B_ERROR; 1195 } 1196 } 1197 1198 /* basic change of card state from VGA to enhanced mode: 1199 * Should work from VGA BIOS POST init state. */ 1200 static status_t nv_general_bios_to_powergraphics() 1201 { 1202 /* let acc engine make power off/power on cycle to start 'fresh' */ 1203 NV_REG32(NV32_PWRUPCTRL) = 0x13110011; 1204 snooze(1000); 1205 1206 /* power-up all nvidia hardware function blocks */ 1207 /* bit 28: OVERLAY ENGINE (BES), 1208 * bit 25: CRTC2, (> NV04A) 1209 * bit 24: CRTC1, 1210 * bit 20: framebuffer, 1211 * bit 16: PPMI, 1212 * bit 12: PGRAPH, 1213 * bit 8: PFIFO, 1214 * bit 4: PMEDIA, 1215 * bit 0: TVOUT. (> NV04A) */ 1216 NV_REG32(NV32_PWRUPCTRL) = 0x13111111; 1217 1218 /* select colormode CRTC registers base adresses */ 1219 NV_REG8(NV8_MISCW) = 0xcb; 1220 1221 /* enable access to primary head */ 1222 set_crtc_owner(0); 1223 /* unlock head's registers for R/W access */ 1224 CRTCW(LOCK, 0x57); 1225 CRTCW(VSYNCE ,(CRTCR(VSYNCE) & 0x7f)); 1226 if (si->ps.secondary_head) 1227 { 1228 /* enable access to secondary head */ 1229 set_crtc_owner(1); 1230 /* unlock head's registers for R/W access */ 1231 CRTC2W(LOCK, 0x57); 1232 CRTC2W(VSYNCE ,(CRTCR(VSYNCE) & 0x7f)); 1233 } 1234 1235 /* turn off both displays and the hardcursors (also disables transfers) */ 1236 head1_dpms(false, false, false); 1237 head1_cursor_hide(); 1238 if (si->ps.secondary_head) 1239 { 1240 head2_dpms(false, false, false); 1241 head2_cursor_hide(); 1242 } 1243 1244 if (si->ps.secondary_head) 1245 { 1246 /* switch overlay engine to CRTC1 */ 1247 /* bit 17: GPU FP port #1 (confirmed NV25, NV28, confirmed not on NV34), 1248 * bit 16: GPU FP port #2 (confirmed NV25, NV28, NV34), 1249 * bit 12: overlay engine (all cards), 1250 * bit 9: TVout chip #2 (confirmed on NV18, NV25, NV28), 1251 * bit 8: TVout chip #1 (all cards), 1252 * bit 4: both I2C busses (all cards) */ 1253 NV_REG32(NV32_2FUNCSEL) &= ~0x00001000; 1254 NV_REG32(NV32_FUNCSEL) |= 0x00001000; 1255 } 1256 si->overlay.crtc = false; 1257 1258 /* enable 'enhanced' mode on primary head: */ 1259 /* enable access to primary head */ 1260 set_crtc_owner(0); 1261 /* note: 'BUFFER' is a non-standard register in behaviour(!) on most 1262 * NV11's like the GeForce2 MX200, while the MX400 and non-NV11 cards 1263 * behave normally. 1264 * Also readback is not nessesarily what was written before! 1265 * 1266 * Double-write action needed on those strange NV11 cards: */ 1267 /* RESET: don't doublebuffer CRTC access: set programmed values immediately... */ 1268 CRTCW(BUFFER, 0xff); 1269 /* ... and use fine pitched CRTC granularity on > NV4 cards (b2 = 0) */ 1270 /* note: this has no effect on possible bandwidth issues. */ 1271 CRTCW(BUFFER, 0xfb); 1272 /* select VGA mode (old VGA register) */ 1273 CRTCW(MODECTL, 0xc3); 1274 /* select graphics mode (old VGA register) */ 1275 SEQW(MEMMODE, 0x0e); 1276 /* select 8 dots character clocks (old VGA register) */ 1277 SEQW(CLKMODE, 0x21); 1278 /* select VGA mode (old VGA register) */ 1279 GRPHW(MODE, 0x00); 1280 /* select graphics mode (old VGA register) */ 1281 GRPHW(MISC, 0x01); 1282 /* select graphics mode (old VGA register) */ 1283 ATBW(MODECTL, 0x01); 1284 /* enable 'enhanced mode', enable Vsync & Hsync, 1285 * set DAC palette to 8-bit width, disable large screen */ 1286 CRTCW(REPAINT1, 0x04); 1287 1288 /* enable 'enhanced' mode on secondary head: */ 1289 if (si->ps.secondary_head) 1290 { 1291 /* enable access to secondary head */ 1292 set_crtc_owner(1); 1293 /* select colormode CRTC2 registers base adresses */ 1294 NV_REG8(NV8_MISCW) = 0xcb; 1295 /* note: 'BUFFER' is a non-standard register in behaviour(!) on most 1296 * NV11's like the GeForce2 MX200, while the MX400 and non-NV11 cards 1297 * behave normally. 1298 * Also readback is not nessesarily what was written before! 1299 * 1300 * Double-write action needed on those strange NV11 cards: */ 1301 /* RESET: don't doublebuffer CRTC2 access: set programmed values immediately... */ 1302 CRTC2W(BUFFER, 0xff); 1303 /* ... and use fine pitched CRTC granularity on > NV4 cards (b2 = 0) */ 1304 /* note: this has no effect on possible bandwidth issues. */ 1305 CRTC2W(BUFFER, 0xfb); 1306 /* select VGA mode (old VGA register) */ 1307 CRTC2W(MODECTL, 0xc3); 1308 /* select graphics mode (old VGA register) */ 1309 SEQW(MEMMODE, 0x0e); 1310 /* select 8 dots character clocks (old VGA register) */ 1311 SEQW(CLKMODE, 0x21); 1312 /* select VGA mode (old VGA register) */ 1313 GRPHW(MODE, 0x00); 1314 /* select graphics mode (old VGA register) */ 1315 GRPHW(MISC, 0x01); 1316 /* select graphics mode (old VGA register) */ 1317 ATB2W(MODECTL, 0x01); 1318 /* enable 'enhanced mode', enable Vsync & Hsync, 1319 * set DAC palette to 8-bit width, disable large screen */ 1320 CRTC2W(REPAINT1, 0x04); 1321 } 1322 1323 /* enable palettes */ 1324 DACW(GENCTRL, 0x00100100); 1325 if (si->ps.secondary_head) DAC2W(GENCTRL, 0x00100100); 1326 1327 /* enable programmable PLLs */ 1328 DACW(PLLSEL, 0x10000700); 1329 if (si->ps.secondary_head) DACW(PLLSEL, (DACR(PLLSEL) | 0x20000800)); 1330 1331 /* turn on DAC and make sure detection testsignal routing is disabled 1332 * (b16 = disable DAC, 1333 * b12 = enable testsignal output */ 1334 //fixme note: b20 ('DACTM_TEST') when set apparantly blocks a DAC's video output 1335 //(confirmed NV43), while it's timing remains operational (black screen). 1336 //It feels like in some screen configurations it can move the output to the other 1337 //output connector as well... 1338 DACW(TSTCTRL, (DACR(TSTCTRL) & 0xfffeefff)); 1339 /* turn on DAC2 if it exists 1340 * (NOTE: testsignal function block resides in DAC1 only (!)) */ 1341 if (si->ps.secondary_head) DAC2W(TSTCTRL, (DAC2R(TSTCTRL) & 0xfffeefff)); 1342 1343 /* NV40 and NV45 need a 'tweak' to make sure the CRTC FIFO's/shiftregisters get 1344 * their data in time (otherwise momentarily ghost images of windows or such 1345 * may appear on heavy acceleration engine use for instance, especially in 32-bit 1346 * colordepth) */ 1347 if ((si->ps.card_type == NV40) || (si->ps.card_type == NV45)) 1348 { 1349 /* clear b15: some framebuffer config item (unknown) */ 1350 NV_REG32(NV32_PFB_CLS_PAGE2) &= 0xffff7fff; 1351 } 1352 1353 /* setup AGP: 1354 * Note: 1355 * This may only be done when no transfers are in progress on the bus, so now 1356 * is probably a good time.. */ 1357 nv_agp_setup(); 1358 1359 /* turn screen one on */ 1360 head1_dpms(true, true, true); 1361 1362 return B_OK; 1363 } 1364 1365 /* Check if mode virtual_size adheres to the cards _maximum_ contraints, and modify 1366 * virtual_size to the nearest valid maximum for the mode on the card if not so. 1367 * Also: check if virtual_width adheres to the cards granularity constraints, and 1368 * create mode slopspace if not so. 1369 * We use acc or crtc granularity constraints based on the 'worst case' scenario. 1370 * 1371 * Mode slopspace is reflected in fbc->bytes_per_row BTW. */ 1372 status_t nv_general_validate_pic_size (display_mode *target, uint32 *bytes_per_row, bool *acc_mode) 1373 { 1374 uint32 video_pitch; 1375 uint32 acc_mask, crtc_mask; 1376 uint32 max_crtc_width, max_acc_width; 1377 uint8 depth = 8; 1378 1379 /* determine pixel multiple based on acceleration engine constraints */ 1380 /* note: 1381 * because of the seemingly 'random' variations in these constraints we take 1382 * a reasonable 'lowest common denominator' instead of always true constraints. */ 1383 switch (si->ps.card_arch) 1384 { 1385 case NV04A: 1386 /* confirmed for: 1387 * TNT1 (NV04), TNT2 (NV05), TNT2-M64 (NV05M64), GeForce2 MX400 (NV11), 1388 * GeForce4 MX440 (NV18), GeForceFX 5200 (NV34) in PIO acc mode; 1389 * confirmed for: 1390 * TNT1 (NV04), TNT2 (NV05), TNT2-M64 (NV05M64), GeForce4 Ti4200 (NV28), 1391 * GeForceFX 5200 (NV34) in DMA acc mode. */ 1392 switch (target->space) 1393 { 1394 case B_CMAP8: acc_mask = 0x0f; depth = 8; break; 1395 case B_RGB15: acc_mask = 0x07; depth = 16; break; 1396 case B_RGB16: acc_mask = 0x07; depth = 16; break; 1397 case B_RGB24: acc_mask = 0x0f; depth = 24; break; 1398 case B_RGB32: acc_mask = 0x03; depth = 32; break; 1399 default: 1400 LOG(8,("INIT: unknown color space: 0x%08x\n", target->space)); 1401 return B_ERROR; 1402 } 1403 break; 1404 default: 1405 /* confirmed for: 1406 * GeForce4 Ti4200 (NV28), GeForceFX 5600 (NV31) in PIO acc mode; 1407 * confirmed for: 1408 * GeForce2 MX400 (NV11), GeForce4 MX440 (NV18), GeForcePCX 5750 (NV36), 1409 * GeForcePCX 6600 GT (NV43) in DMA acc mode. */ 1410 switch (target->space) 1411 { 1412 case B_CMAP8: acc_mask = 0x3f; depth = 8; break; 1413 case B_RGB15: acc_mask = 0x1f; depth = 16; break; 1414 case B_RGB16: acc_mask = 0x1f; depth = 16; break; 1415 case B_RGB24: acc_mask = 0x3f; depth = 24; break; 1416 case B_RGB32: acc_mask = 0x0f; depth = 32; break; 1417 default: 1418 LOG(8,("INIT: unknown color space: 0x%08x\n", target->space)); 1419 return B_ERROR; 1420 } 1421 break; 1422 } 1423 1424 /* determine pixel multiple based on CRTC memory pitch constraints: 1425 * -> all NV cards have same granularity constraints on CRTC1 and CRTC2, 1426 * provided that the CRTC1 and CRTC2 BUFFER register b2 = 0; 1427 * 1428 * (Note: Don't mix this up with CRTC timing contraints! Those are 1429 * multiples of 8 for horizontal, 1 for vertical timing.) */ 1430 switch (si->ps.card_type) 1431 { 1432 default: 1433 // case NV04: 1434 /* confirmed for: 1435 * TNT1 always; 1436 * TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForce4 Ti4200, 1437 * GeForceFX 5200: if the CRTC1 (and CRTC2) BUFFER register b2 = 0 */ 1438 /* NOTE: 1439 * Unfortunately older cards have a hardware fault that prevents use. 1440 * We need doubled granularity on those to prevent the single top line 1441 * from shifting to the left! 1442 * This is confirmed for TNT2, GeForce2 MX200, GeForce2 MX400. 1443 * Confirmed OK are: 1444 * GeForce4 MX440, GeForce4 Ti4200, GeForceFX 5200. */ 1445 switch (target->space) 1446 { 1447 case B_CMAP8: crtc_mask = 0x0f; break; /* 0x07 */ 1448 case B_RGB15: crtc_mask = 0x07; break; /* 0x03 */ 1449 case B_RGB16: crtc_mask = 0x07; break; /* 0x03 */ 1450 case B_RGB24: crtc_mask = 0x0f; break; /* 0x07 */ 1451 case B_RGB32: crtc_mask = 0x03; break; /* 0x01 */ 1452 default: 1453 LOG(8,("INIT: unknown color space: 0x%08x\n", target->space)); 1454 return B_ERROR; 1455 } 1456 break; 1457 // default: 1458 /* confirmed for: 1459 * TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForce4 Ti4200, 1460 * GeForceFX 5200: if the CRTC1 (and CRTC2) BUFFER register b2 = 1 */ 1461 /* switch (target->space) 1462 { 1463 case B_CMAP8: crtc_mask = 0x1f; break; 1464 case B_RGB15: crtc_mask = 0x0f; break; 1465 case B_RGB16: crtc_mask = 0x0f; break; 1466 case B_RGB24: crtc_mask = 0x1f; break; 1467 case B_RGB32: crtc_mask = 0x07; break; 1468 default: 1469 LOG(8,("INIT: unknown color space: 0x%08x\n", target->space)); 1470 return B_ERROR; 1471 } 1472 break; 1473 */ } 1474 1475 /* set virtual_width limit for accelerated modes */ 1476 /* note: 1477 * because of the seemingly 'random' variations in these constraints we take 1478 * a reasonable 'lowest common denominator' instead of always true constraints. */ 1479 switch (si->ps.card_arch) 1480 { 1481 case NV04A: 1482 /* confirmed for: 1483 * TNT1 (NV04), TNT2 (NV05), TNT2-M64 (NV05M64) in both PIO and DMA acc mode. */ 1484 switch(target->space) 1485 { 1486 case B_CMAP8: max_acc_width = 8176; break; 1487 case B_RGB15: max_acc_width = 4088; break; 1488 case B_RGB16: max_acc_width = 4088; break; 1489 case B_RGB24: max_acc_width = 2720; break; 1490 case B_RGB32: max_acc_width = 2044; break; 1491 default: 1492 LOG(8,("INIT: unknown color space: 0x%08x\n", target->space)); 1493 return B_ERROR; 1494 } 1495 break; 1496 default: 1497 /* confirmed for: 1498 * GeForce4 Ti4200 (NV28), GeForceFX 5600 (NV31) in PIO acc mode; 1499 * GeForce2 MX400 (NV11), GeForce4 MX440 (NV18), GeForceFX 5200 (NV34) can do 1500 * 16368/8184/8184/5456/4092, so a bit better in PIO acc mode; 1501 * confirmed for: 1502 * GeForce2 MX400 (NV11), GeForce4 MX440 (NV18), GeForcePCX 5750 (NV36), 1503 * GeForcePCX 6600 GT (NV43) in DMA acc mode; 1504 * GeForce4 Ti4200 (NV28), GeForceFX 5200 (NV34) can do 1505 * 16368/8184/8184/5456/4092, so a bit better in DMA acc mode. */ 1506 switch(target->space) 1507 { 1508 case B_CMAP8: max_acc_width = 16320; break; 1509 case B_RGB15: max_acc_width = 8160; break; 1510 case B_RGB16: max_acc_width = 8160; break; 1511 case B_RGB24: max_acc_width = 5440; break; 1512 case B_RGB32: max_acc_width = 4080; break; 1513 default: 1514 LOG(8,("INIT: unknown color space: 0x%08x\n", target->space)); 1515 return B_ERROR; 1516 } 1517 break; 1518 } 1519 1520 /* set virtual_width limit for unaccelerated modes */ 1521 switch (si->ps.card_type) 1522 { 1523 default: 1524 // case NV04: 1525 /* confirmed for: 1526 * TNT1 always; 1527 * TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForce4 Ti4200, 1528 * GeForceFX 5200: if the CRTC1 (and CRTC2) BUFFER register b2 = 0 */ 1529 /* NOTE: 1530 * Unfortunately older cards have a hardware fault that prevents use. 1531 * We need doubled granularity on those to prevent the single top line 1532 * from shifting to the left! 1533 * This is confirmed for TNT2, GeForce2 MX200, GeForce2 MX400. 1534 * Confirmed OK are: 1535 * GeForce4 MX440, GeForce4 Ti4200, GeForceFX 5200. */ 1536 switch(target->space) 1537 { 1538 case B_CMAP8: max_crtc_width = 16368; break; /* 16376 */ 1539 case B_RGB15: max_crtc_width = 8184; break; /* 8188 */ 1540 case B_RGB16: max_crtc_width = 8184; break; /* 8188 */ 1541 case B_RGB24: max_crtc_width = 5456; break; /* 5456 */ 1542 case B_RGB32: max_crtc_width = 4092; break; /* 4094 */ 1543 default: 1544 LOG(8,("INIT: unknown color space: 0x%08x\n", target->space)); 1545 return B_ERROR; 1546 } 1547 break; 1548 // default: 1549 /* confirmed for: 1550 * TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForce4 Ti4200, 1551 * GeForceFX 5200: if the CRTC1 (and CRTC2) BUFFER register b2 = 1 */ 1552 /* switch(target->space) 1553 { 1554 case B_CMAP8: max_crtc_width = 16352; break; 1555 case B_RGB15: max_crtc_width = 8176; break; 1556 case B_RGB16: max_crtc_width = 8176; break; 1557 case B_RGB24: max_crtc_width = 5440; break; 1558 case B_RGB32: max_crtc_width = 4088; break; 1559 default: 1560 LOG(8,("INIT: unknown color space: 0x%08x\n", target->space)); 1561 return B_ERROR; 1562 } 1563 break; 1564 */ } 1565 1566 /* check for acc capability, and adjust mode to adhere to hardware constraints */ 1567 if (max_acc_width <= max_crtc_width) 1568 { 1569 /* check if we can setup this mode with acceleration */ 1570 *acc_mode = true; 1571 /* virtual_width */ 1572 if (target->virtual_width > max_acc_width) *acc_mode = false; 1573 /* virtual_height */ 1574 /* (NV cards can even do more than this(?)... 1575 * but 4096 is confirmed on all cards at max. accelerated width.) */ 1576 if (target->virtual_height > 4096) *acc_mode = false; 1577 1578 /* now check virtual_size based on CRTC constraints */ 1579 if (target->virtual_width > max_crtc_width) target->virtual_width = max_crtc_width; 1580 /* virtual_height: The only constraint here is the cards memory size which is 1581 * checked later on in ProposeMode: virtual_height is adjusted then if needed. 1582 * 'Limiting here' to the variable size that's at least available (uint16). */ 1583 if (target->virtual_height > 65535) target->virtual_height = 65535; 1584 1585 /* OK, now we know that virtual_width is valid, and it's needing no slopspace if 1586 * it was confined above, so we can finally calculate safely if we need slopspace 1587 * for this mode... */ 1588 if (*acc_mode) 1589 { 1590 /* the mode needs to adhere to the largest granularity imposed... */ 1591 if (acc_mask < crtc_mask) 1592 video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask); 1593 else 1594 video_pitch = ((target->virtual_width + acc_mask) & ~acc_mask); 1595 } 1596 else /* unaccelerated mode */ 1597 video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask); 1598 } 1599 else /* max_acc_width > max_crtc_width */ 1600 { 1601 /* check if we can setup this mode with acceleration */ 1602 *acc_mode = true; 1603 /* (we already know virtual_width will be no problem) */ 1604 /* virtual_height */ 1605 /* (NV cards can even do more than this(?)... 1606 * but 4096 is confirmed on all cards at max. accelerated width.) */ 1607 if (target->virtual_height > 4096) *acc_mode = false; 1608 1609 /* now check virtual_size based on CRTC constraints */ 1610 if (*acc_mode) 1611 { 1612 /* note that max_crtc_width already adheres to crtc_mask */ 1613 if (target->virtual_width > (max_crtc_width & ~acc_mask)) 1614 target->virtual_width = (max_crtc_width & ~acc_mask); 1615 } 1616 else /* unaccelerated mode */ 1617 { 1618 if (target->virtual_width > max_crtc_width) 1619 target->virtual_width = max_crtc_width; 1620 } 1621 /* virtual_height: The only constraint here is the cards memory size which is 1622 * checked later on in ProposeMode: virtual_height is adjusted then if needed. 1623 * 'Limiting here' to the variable size that's at least available (uint16). */ 1624 if (target->virtual_height > 65535) target->virtual_height = 65535; 1625 1626 /* OK, now we know that virtual_width is valid, and it's needing no slopspace if 1627 * it was confined above, so we can finally calculate safely if we need slopspace 1628 * for this mode... */ 1629 if (*acc_mode) 1630 { 1631 /* the mode needs to adhere to the largest granularity imposed... */ 1632 if (acc_mask < crtc_mask) 1633 video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask); 1634 else 1635 video_pitch = ((target->virtual_width + acc_mask) & ~acc_mask); 1636 } 1637 else /* unaccelerated mode */ 1638 video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask); 1639 } 1640 1641 LOG(2,("INIT: memory pitch will be set to %d pixels for colorspace 0x%08x\n", 1642 video_pitch, target->space)); 1643 if (target->virtual_width != video_pitch) 1644 LOG(2,("INIT: effective mode slopspace is %d pixels\n", 1645 (video_pitch - target->virtual_width))); 1646 1647 /* now calculate bytes_per_row for this mode */ 1648 *bytes_per_row = video_pitch * (depth >> 3); 1649 1650 return B_OK; 1651 } 1652