*** /chameleon/trunk/i386/libsaio/nvidia.c	2011-12-11 03:18:19.000000000 +0000
--- /patched/nvidia.c	2011-12-14 19:20:18.000000000 +0000
***************
*** 99,107 ****
  
  static struct nv_chipsets_t NVKnownChipsets[] = {
  	{ 0x00000000, "Unknown" },
- // temporary placement
- 	{ 0x10DE0DF4, "GeForce GT 450M" }, //Azi + issue #99
- 	{ 0x10DE1251, "GeForce GTX 560M" }, // Asus G74SX
  //========================================
  	// 0040 - 004F	
  	{ 0x10DE0040, "GeForce 6800 Ultra" },
--- 99,104 ----
***************
*** 400,405 ****
--- 397,403 ----
  	{ 0x10DE05E2, "GeForce GTX 260" },
  	{ 0x10DE05E3, "GeForce GTX 285" },
  	{ 0x10DE05E6, "GeForce GTX 275" },
+ 	{ 0x10DE05E7, "Tesla C1060" }, 
  	{ 0x10DE05EA, "GeForce GTX 260" },
  	{ 0x10DE05EB, "GeForce GTX 295" },
  	{ 0x10DE05ED, "Quadroplex 2200 D2" },
***************
*** 439,446 ****
--- 437,446 ----
  	{ 0x10DE061B, "Quadro VX 200" },
  	{ 0x10DE061C, "Quadro FX 3600M" },
  	{ 0x10DE061D, "Quadro FX 2800M" },
+ 	{ 0x10DE061E, "Quadro FX 3700M" }, 
  	{ 0x10DE061F, "Quadro FX 3800M" },
  	// 0620 - 062F	
+ 	{ 0x10DE0621, "GeForce GT 230" }, 
  	{ 0x10DE0622, "GeForce 9600 GT" },
  	{ 0x10DE0623, "GeForce 9600 GS" },
  	{ 0x10DE0625, "GeForce 9600 GSO 512"},
***************
*** 448,453 ****
--- 448,454 ----
  	{ 0x10DE0627, "GeForce GT 140" },
  	{ 0x10DE0628, "GeForce 9800M GTS" },
  	{ 0x10DE062A, "GeForce 9700M GTS" },
+ 	{ 0x10DE062B, "GeForce 9800M GS" }, 
  	{ 0x10DE062C, "GeForce 9800M GTS" },
  	{ 0x10DE062D, "GeForce 9600 GT" },
  	{ 0x10DE062E, "GeForce 9600 GT" },
***************
*** 477,482 ****
--- 478,484 ----
  	{ 0x10DE0652, "GeForce GT 130M" },
  	{ 0x10DE0653, "GeForce GT 120M" },
  	{ 0x10DE0654, "GeForce GT 220M" },
+ 	{ 0x10DE0655, "GeForce GT 120" }, 
  	{ 0x10DE0656, "GeForce 9650 S" },
  	{ 0x10DE0658, "Quadro FX 380" },
  	{ 0x10DE0659, "Quadro FX 580" },
***************
*** 507,512 ****
--- 509,515 ----
  	{ 0x10DE06DD, "Quadro 4000" },
  	{ 0x10DE06DE, "Tesla M2050" },	// TODO: sub-device id: 0x0846
  	{ 0x10DE06DE, "Tesla M2070" },	// TODO: sub-device id: ?	
+ 	{ 0x10DE06DF, "Tesla M2070-Q" }, 
  	// 0x10DE06DE also applies to misc S2050, X2070, M2050, M2070
  	// 06E0 - 06EF	
  	{ 0x10DE06E0, "GeForce 9300 GE" },
***************
*** 524,534 ****
--- 527,539 ----
  	{ 0x10DE06EC, "GeForce G 105M" },
  	{ 0x10DE06EF, "GeForce G 103M" },
  	// 06F0 - 06FF	
+ 	{ 0x10DE06F1, "GeForce G105M" }, 
  	{ 0x10DE06F8, "Quadro NVS 420" },
  	{ 0x10DE06F9, "Quadro FX 370 LP" },
  	{ 0x10DE06FA, "Quadro NVS 450" },
  	{ 0x10DE06FB, "Quadro FX 370M" },
  	{ 0x10DE06FD, "Quadro NVS 295" },
+ 	{ 0x10DE06FF, "HICx16 + Graphics" }, 
  	// 0700 - 070F
  	// 0710 - 071F
  	// 0720 - 072F
***************
*** 555,560 ****
--- 560,566 ----
  	// 0820 - 082F
  	// 0830 - 083F
  	// 0840 - 084F
+ 	{ 0x10DE0840, "GeForce 8200M" }, 
  	{ 0x10DE0844, "GeForce 9100M G" },
  	{ 0x10DE0845, "GeForce 8200M G" },
  	{ 0x10DE0846, "GeForce 9200" },
***************
*** 577,582 ****
--- 583,589 ----
  	{ 0x10DE0866, "GeForce 9400M G" },
  	{ 0x10DE0867, "GeForce 9400" },
  	{ 0x10DE0868, "nForce 760i SLI" },
+ 	{ 0x10DE0869, "GeForce 9400" }, 
  	{ 0x10DE086A, "GeForce 9400" },
  	{ 0x10DE086C, "GeForce 9300 / nForce 730i" },
  	{ 0x10DE086D, "GeForce 9200" },
***************
*** 596,601 ****
--- 603,610 ----
  	// 0880 - 088F
  	// 0890 - 089F
  	// 08A0 - 08AF
+ 	{ 0x10DE08A0, "GeForce 320M" }, 
+ 	{ 0x10DE08A4, "GeForce 320M" }, 
  	// 08B0 - 08BF
  	// 08C0 - 08CF
  	// 08D0 - 08DF	
***************
*** 623,628 ****
--- 632,639 ----
  	{ 0x10DE0A20, "GeForce GT220" },
  	{ 0x10DE0A22, "GeForce 315" },
  	{ 0x10DE0A23, "GeForce 210" },
+ 	{ 0x10DE0A26, "GeForce 405" }, 
+ 	{ 0x10DE0A27, "GeForce 405" }, 
  	{ 0x10DE0A28, "GeForce GT 230M" },
  	{ 0x10DE0A29, "GeForce GT 330M" },
  	{ 0x10DE0A2A, "GeForce GT 230M" },
***************
*** 632,637 ****
--- 643,649 ----
  	// 0A30 - 0A3F	
  	{ 0x10DE0A34, "GeForce GT 240M" },
  	{ 0x10DE0A35, "GeForce GT 325M" },
+ 	{ 0x10DE0A38, "Quadro 400" }, 
  	{ 0x10DE0A3C, "Quadro FX 880M" },
  	// 0A40 - 0A4F
  	// 0A50 - 0A5F
***************
*** 656,662 ****
--- 668,676 ----
  	{ 0x10DE0A73, "GeForce 305M" },
  	{ 0x10DE0A74, "GeForce G210M" },
  	{ 0x10DE0A75, "GeForce G310M" },
+ 	{ 0x10DE0A76, "ION" }, 
  	{ 0x10DE0A78, "Quadro FX 380 LP" },
+ 	{ 0x10DE0A7A, "GeForce 315M" }, 
  	{ 0x10DE0A7C, "Quadro FX 380M" },
  	// 0A80 - 0A8F
  	// 0A90 - 0A9F
***************
*** 697,706 ****
  	{ 0x10DE0CA2, "GeForce GT 320" },
  	{ 0x10DE0CA3, "GeForce GT 240" },
  	{ 0x10DE0CA4, "GeForce GT 340" },
  	{ 0x10DE0CA7, "GeForce GT 330" },
  	{ 0x10DE0CA8, "GeForce GTS 260M" },
  	{ 0x10DE0CA9, "GeForce GTS 250M" },
! 	{ 0x10DE0CAC, "GeForce 315" },
  	{ 0x10DE0CAF, "GeForce GT 335M" },
  	// 0CB0 - 0CBF	
  	{ 0x10DE0CB0, "GeForce GTS 350M" },
--- 711,721 ----
  	{ 0x10DE0CA2, "GeForce GT 320" },
  	{ 0x10DE0CA3, "GeForce GT 240" },
  	{ 0x10DE0CA4, "GeForce GT 340" },
+ 	{ 0x10DE0CA5, "GeForce GT 220" }, 
  	{ 0x10DE0CA7, "GeForce GT 330" },
  	{ 0x10DE0CA8, "GeForce GTS 260M" },
  	{ 0x10DE0CA9, "GeForce GTS 250M" },
! 	{ 0x10DE0CAC, "GeForce GT 220" }, 
  	{ 0x10DE0CAF, "GeForce GT 335M" },
  	// 0CB0 - 0CBF	
  	{ 0x10DE0CB0, "GeForce GTS 350M" },
***************
*** 730,740 ****
--- 745,759 ----
  	{ 0x10DE0DC5, "GeForce GTS 450" },
  	{ 0x10DE0DC6, "GeForce GTS 450" },
  	{ 0x10DE0DCA, "GF10x" },
+ 	{ 0x10DE0DCD, "GeForce GT 555M" }, 
+ 	{ 0x10DE0DCE, "GeForce GT 555M" }, 
  	// 0DD0 - 0DDF	
  	{ 0x10DE0DD1, "GeForce GTX 460M" },
  	{ 0x10DE0DD2, "GeForce GT 445M" },
  	{ 0x10DE0DD3, "GeForce GT 435M" },
+ 	{ 0x10DE0DD6, "GeForce GT 550M" }, 
  	{ 0x10DE0DD8, "Quadro 2000" },
+ 	{ 0x10DE0DDA, "Quadro 2000M" }, 
  	{ 0x10DE0DDE, "GF106-ES" },
  	{ 0x10DE0DDF, "GF106-INT" },
  	// 0DE0 - 0DEF	
***************
*** 743,755 ****
--- 762,781 ----
  	{ 0x10DE0DE2, "GeForce GT 420" },
  	{ 0x10DE0DE5, "GeForce GT 530" },
  	{ 0x10DE0DEB, "GeForce GT 555M" },
+ 	{ 0x10DE0DEC, "GeForce GT 525M" }, 
+ 	{ 0x10DE0DED, "GeForce GT 520M" }, 
  	{ 0x10DE0DEE, "GeForce GT 415M" },
  	// 0DF0 - 0DFF	
  	{ 0x10DE0DF0, "GeForce GT 425M" },
  	{ 0x10DE0DF1, "GeForce GT 420M" },
  	{ 0x10DE0DF2, "GeForce GT 435M" },
  	{ 0x10DE0DF3, "GeForce GT 420M" },
+ 	{ 0x10DE0DF4, "GeForce GT 540M" }, 
+ 	{ 0x10DE0DF5, "GeForce GT 525M" }, 
+ 	{ 0x10DE0DF6, "GeForce GT 550M" }, 
+ 	{ 0x10DE0DF7, "GeForce GT 520M" }, 
  	{ 0x10DE0DF8, "Quadro 600" },
+ 	{ 0x10DE0DFA, "Quadro 1000M" }, 
  	{ 0x10DE0DFE, "GF108 ES" },
  	{ 0x10DE0DFF, "GF108 INT" },
  	// 0E00 - 0E0F
***************
*** 762,768 ****
--- 788,797 ----
  	{ 0x10DE0E25, "D12U-50" },
  	// 0E30 - 0E3F	
  	{ 0x10DE0E30, "GeForce GTX 470M" },
+ 	{ 0x10DE0E31, "GeForce GTX 485M" }, 
  	{ 0x10DE0E38, "GF104GL" },
+ 	{ 0x10DE0E3A, "Quadro 3000M" }, 
+ 	{ 0x10DE0E3B, "Quadro 4000M" }, 
  	{ 0x10DE0E3E, "GF104-ES" },
  	{ 0x10DE0E3F, "GF104-INT" },
  	// 0E40 - 0E4F	
***************
*** 798,825 ****
  	// 1020 - 102F
  	// 1030 - 103F
  	// 1040 - 104F
! 	{ 0x10DE1040, "GeForce GT 520" },	
  	// 1050 - 105F
  	{ 0x10DE1050, "GeForce GT 520M" },
  	// 1060 - 106F
  	// 1070 - 107F
  	// 1080 - 108F
  	{ 0x10DE1080, "GeForce GTX 580" },
  	{ 0x10DE1081, "GeForce GTX 570" },
  	{ 0x10DE1082, "GeForce GTX 560 Ti" },
  	{ 0x10DE1083, "D13U" },
  	{ 0x10DE1088, "GeForce GTX 590" },
  	// 1090 - 109F	
  	{ 0x10DE1098, "D13U" },
! 	{ 0x10DE109A, "N12E-Q5" },
  	// 10A0 - 10AF
  	// 10B0 - 10BF
  	// 10C0 - 10CF
  	{ 0x10DE10C3, "GeForce 8400 GS" },
  	// 1200 - 
  	{ 0x10DE1200, "GeForce GTX 560 Ti" },
  	{ 0x10DE1244, "GeForce GTX 550 Ti" },
! 	{ 0x10DE1245, "GeForce GTS 450" },	
  };
  
  static uint16_t swap16(uint16_t x)
--- 827,873 ----
  	// 1020 - 102F
  	// 1030 - 103F
  	// 1040 - 104F
! 	{ 0x10DE1040, "GeForce GT 520" },
  	// 1050 - 105F
  	{ 0x10DE1050, "GeForce GT 520M" },
+ 	{ 0x10DE1054, "GeForce GT 410M" }, 
+ 	{ 0x10DE1056, "NVS 4200M" }, 
+ 	{ 0x10DE1057, "NVS 4200M" }, 
  	// 1060 - 106F
  	// 1070 - 107F
+ 	{ 0x10DE107F, "NVIDIA GF119-ES" }, 
  	// 1080 - 108F
  	{ 0x10DE1080, "GeForce GTX 580" },
  	{ 0x10DE1081, "GeForce GTX 570" },
  	{ 0x10DE1082, "GeForce GTX 560 Ti" },
  	{ 0x10DE1083, "D13U" },
+ 	{ 0x10DE1084, "GeForce GTX 560" }, 
+ 	{ 0x10DE1086, "GeForce GTX 570" }, 
+ 	{ 0x10DE1087, "GeForce GTX 560 Ti-448" }, 
  	{ 0x10DE1088, "GeForce GTX 590" },
+ 	{ 0x10DE1089, "GeForce GTX 580" }, 
+ 	{ 0x10DE108B, "GeForce GTX 590" }, 
  	// 1090 - 109F	
+ 	{ 0x10DE1091, "Tesla M2090" }, 
  	{ 0x10DE1098, "D13U" },
! 	{ 0x10DE109A, "Quadro 5010M" }, 
! 	{ 0x10DE109B, "Quadro 7000" }, 
  	// 10A0 - 10AF
  	// 10B0 - 10BF
  	// 10C0 - 10CF
+ 	{ 0x10DE10C0, "GeForce 9300 GS" }, 
  	{ 0x10DE10C3, "GeForce 8400 GS" },
+ 	{ 0x10DE10C5, "GeForce 405" }, 
+ 	// 10D0 - 10DF
+ 	{ 0x10DE10D8, "NVS 300" }, 
  	// 1200 - 
  	{ 0x10DE1200, "GeForce GTX 560 Ti" },
+ 	{ 0x10DE1201, "GeForce GTX 560" }, 
+ 	{ 0x10DE1241, "GeForce GT 545" }, 
+ 	{ 0x10DE1243, "GeForce GT 545" }, 
  	{ 0x10DE1244, "GeForce GTX 550 Ti" },
! 	{ 0x10DE1245, "GeForce GTS 450" },
! 	{ 0x10DE1251, "GeForce GTX 560M" }, 
  };
  
  static uint16_t swap16(uint16_t x)
***************
*** 830,839 ****
  static uint16_t read16(uint8_t *ptr, uint16_t offset)
  {
  	uint8_t ret[2];
! 	
  	ret[0] = ptr[offset+1];
  	ret[1] = ptr[offset];
! 	
  	return *((uint16_t*)&ret);
  }
  
--- 878,887 ----
  static uint16_t read16(uint8_t *ptr, uint16_t offset)
  {
  	uint8_t ret[2];
! 
  	ret[0] = ptr[offset+1];
  	ret[1] = ptr[offset];
! 
  	return *((uint16_t*)&ret);
  }
  
***************
*** 851,862 ****
  static uint32_t read32(uint8_t *ptr, uint16_t offset)
  {
  	uint8_t ret[4];
! 	
  	ret[0] = ptr[offset+3];
  	ret[1] = ptr[offset+2];
  	ret[2] = ptr[offset+1];
  	ret[3] = ptr[offset];
! 	
  	return *((uint32_t*)&ret);
  }
  #endif
--- 899,910 ----
  static uint32_t read32(uint8_t *ptr, uint16_t offset)
  {
  	uint8_t ret[4];
! 
  	ret[0] = ptr[offset+3];
  	ret[1] = ptr[offset+2];
  	ret[2] = ptr[offset+1];
  	ret[3] = ptr[offset];
! 
  	return *((uint32_t*)&ret);
  }
  #endif
***************
*** 869,875 ****
  	}
  	
  	uint16_t dcbptr = swap16(read16(rom, 0x36));
! 	
  	if (!dcbptr) {
  		printf("no dcb table found\n");
  		return PATCH_ROM_FAILED;
--- 917,923 ----
  	}
  	
  	uint16_t dcbptr = swap16(read16(rom, 0x36));
! 
  	if (!dcbptr) {
  		printf("no dcb table found\n");
  		return PATCH_ROM_FAILED;
***************
*** 892,898 ****
  			headerlength = dcbtable[1];
  			numentries	 = dcbtable[2];
  			recordlength = dcbtable[3];
! 			
  			sig = *(uint32_t *)&dcbtable[6];
  		}
  		else
--- 940,946 ----
  			headerlength = dcbtable[1];
  			numentries	 = dcbtable[2];
  			recordlength = dcbtable[3];
! 
  			sig = *(uint32_t *)&dcbtable[6];
  		}
  		else
***************
*** 942,948 ****
  	{
  		uint32_t connection;
  		connection = *(uint32_t *)&dcbtable[headerlength + recordlength * i];
! 		
  		/* Should we allow discontinuous DCBs? Certainly DCB I2C tables can be discontinuous */
  		if ((connection & 0x0000000f) == 0x0000000f) /* end of records */ 
  			continue;
--- 990,996 ----
  	{
  		uint32_t connection;
  		connection = *(uint32_t *)&dcbtable[headerlength + recordlength * i];
! 
  		/* Should we allow discontinuous DCBs? Certainly DCB I2C tables can be discontinuous */
  		if ((connection & 0x0000000f) == 0x0000000f) /* end of records */ 
  			continue;
***************
*** 1201,1212 ****
  		vram_size *= REG32(NVC0_MEM_CTRLR_COUNT);
  	}
  	
! 	// Workaround for GT 420/430 & 9600M GT
  	switch (nvda_dev->device_id)
  	{
  		case 0x0DE1: vram_size = 1024*1024*1024; break; // GT 430
  		case 0x0DE2: vram_size = 1024*1024*1024; break; // GT 420
! 		case 0x0649: vram_size = 512*1024*1024; break;	// 9600M GT
  		default: break;
  	}
  	
--- 1249,1262 ----
  		vram_size *= REG32(NVC0_MEM_CTRLR_COUNT);
  	}
  	
! 	// Workaround for 9600M GT, GT 420/430/440 & GT 525M
  	switch (nvda_dev->device_id)
  	{
+ 		case 0x0649: vram_size = 512*1024*1024; break;	// 9600M GT
+ 		case 0x0DE0: vram_size = 1024*1024*1024; break; // GT 440
  		case 0x0DE1: vram_size = 1024*1024*1024; break; // GT 430
  		case 0x0DE2: vram_size = 1024*1024*1024; break; // GT 420
! 		case 0x0DEC: vram_size = 1024*1024*1024; break; // GT 525M
  		default: break;
  	}
  	
