GfxDriverInfo.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "GfxDriverInfo.h"
  6. #include "nsIGfxInfo.h"
  7. #include "nsTArray.h"
  8. using namespace mozilla::widget;
  9. int32_t GfxDriverInfo::allFeatures = 0;
  10. uint64_t GfxDriverInfo::allDriverVersions = ~(uint64_t(0));
  11. GfxDeviceFamily* const GfxDriverInfo::allDevices = nullptr;
  12. GfxDeviceFamily* GfxDriverInfo::mDeviceFamilies[DeviceFamilyMax];
  13. nsAString* GfxDriverInfo::mDeviceVendors[DeviceVendorMax];
  14. GfxDriverInfo::GfxDriverInfo()
  15. : mOperatingSystem(OperatingSystem::Unknown),
  16. mOperatingSystemVersion(0),
  17. mAdapterVendor(GfxDriverInfo::GetDeviceVendor(VendorAll)),
  18. mDevices(allDevices),
  19. mDeleteDevices(false),
  20. mFeature(allFeatures),
  21. mFeatureStatus(nsIGfxInfo::FEATURE_STATUS_OK),
  22. mComparisonOp(DRIVER_COMPARISON_IGNORED),
  23. mDriverVersion(0),
  24. mDriverVersionMax(0),
  25. mSuggestedVersion(nullptr),
  26. mRuleId(nullptr),
  27. mGpu2(false)
  28. {}
  29. GfxDriverInfo::GfxDriverInfo(OperatingSystem os, nsAString& vendor,
  30. GfxDeviceFamily* devices,
  31. int32_t feature, int32_t featureStatus,
  32. VersionComparisonOp op,
  33. uint64_t driverVersion,
  34. const char *ruleId,
  35. const char *suggestedVersion /* = nullptr */,
  36. bool ownDevices /* = false */,
  37. bool gpu2 /* = false */)
  38. : mOperatingSystem(os),
  39. mOperatingSystemVersion(0),
  40. mAdapterVendor(vendor),
  41. mDevices(devices),
  42. mDeleteDevices(ownDevices),
  43. mFeature(feature),
  44. mFeatureStatus(featureStatus),
  45. mComparisonOp(op),
  46. mDriverVersion(driverVersion),
  47. mDriverVersionMax(0),
  48. mSuggestedVersion(suggestedVersion),
  49. mRuleId(ruleId),
  50. mGpu2(gpu2)
  51. {}
  52. GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig)
  53. : mOperatingSystem(aOrig.mOperatingSystem),
  54. mOperatingSystemVersion(aOrig.mOperatingSystemVersion),
  55. mAdapterVendor(aOrig.mAdapterVendor),
  56. mFeature(aOrig.mFeature),
  57. mFeatureStatus(aOrig.mFeatureStatus),
  58. mComparisonOp(aOrig.mComparisonOp),
  59. mDriverVersion(aOrig.mDriverVersion),
  60. mDriverVersionMax(aOrig.mDriverVersionMax),
  61. mSuggestedVersion(aOrig.mSuggestedVersion),
  62. mRuleId(aOrig.mRuleId),
  63. mGpu2(aOrig.mGpu2)
  64. {
  65. // If we're managing the lifetime of the device family, we have to make a
  66. // copy of the original's device family.
  67. if (aOrig.mDeleteDevices && aOrig.mDevices) {
  68. mDevices = new GfxDeviceFamily;
  69. *mDevices = *aOrig.mDevices;
  70. } else {
  71. mDevices = aOrig.mDevices;
  72. }
  73. mDeleteDevices = aOrig.mDeleteDevices;
  74. }
  75. GfxDriverInfo::~GfxDriverInfo()
  76. {
  77. if (mDeleteDevices)
  78. delete mDevices;
  79. }
  80. // Macros for appending a device to the DeviceFamily.
  81. #define APPEND_DEVICE(device) APPEND_DEVICE2(#device)
  82. #define APPEND_DEVICE2(device) deviceFamily->AppendElement(NS_LITERAL_STRING(device))
  83. const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id)
  84. {
  85. // The code here is too sensitive to fall through to the default case if the
  86. // code is invalid.
  87. NS_ASSERTION(id >= 0 && id < DeviceFamilyMax, "DeviceFamily id is out of range");
  88. // If it already exists, we must have processed it once, so return it now.
  89. if (mDeviceFamilies[id])
  90. return mDeviceFamilies[id];
  91. mDeviceFamilies[id] = new GfxDeviceFamily;
  92. GfxDeviceFamily* deviceFamily = mDeviceFamilies[id];
  93. switch (id) {
  94. case IntelGMA500:
  95. APPEND_DEVICE(0x8108); /* IntelGMA500_1 */
  96. APPEND_DEVICE(0x8109); /* IntelGMA500_2 */
  97. break;
  98. case IntelGMA900:
  99. APPEND_DEVICE(0x2582); /* IntelGMA900_1 */
  100. APPEND_DEVICE(0x2782); /* IntelGMA900_2 */
  101. APPEND_DEVICE(0x2592); /* IntelGMA900_3 */
  102. APPEND_DEVICE(0x2792); /* IntelGMA900_4 */
  103. break;
  104. case IntelGMA950:
  105. APPEND_DEVICE(0x2772); /* Intel945G_1 */
  106. APPEND_DEVICE(0x2776); /* Intel945G_2 */
  107. APPEND_DEVICE(0x27a2); /* Intel945_1 */
  108. APPEND_DEVICE(0x27a6); /* Intel945_2 */
  109. APPEND_DEVICE(0x27ae); /* Intel945_3 */
  110. break;
  111. case IntelGMA3150:
  112. APPEND_DEVICE(0xa001); /* IntelGMA3150_Nettop_1 */
  113. APPEND_DEVICE(0xa002); /* IntelGMA3150_Nettop_2 */
  114. APPEND_DEVICE(0xa011); /* IntelGMA3150_Netbook_1 */
  115. APPEND_DEVICE(0xa012); /* IntelGMA3150_Netbook_2 */
  116. break;
  117. case IntelGMAX3000:
  118. APPEND_DEVICE(0x2972); /* Intel946GZ_1 */
  119. APPEND_DEVICE(0x2973); /* Intel946GZ_2 */
  120. APPEND_DEVICE(0x2982); /* IntelG35_1 */
  121. APPEND_DEVICE(0x2983); /* IntelG35_2 */
  122. APPEND_DEVICE(0x2992); /* IntelQ965_1 */
  123. APPEND_DEVICE(0x2993); /* IntelQ965_2 */
  124. APPEND_DEVICE(0x29a2); /* IntelG965_1 */
  125. APPEND_DEVICE(0x29a3); /* IntelG965_2 */
  126. APPEND_DEVICE(0x29b2); /* IntelQ35_1 */
  127. APPEND_DEVICE(0x29b3); /* IntelQ35_2 */
  128. APPEND_DEVICE(0x29c2); /* IntelG33_1 */
  129. APPEND_DEVICE(0x29c3); /* IntelG33_2 */
  130. APPEND_DEVICE(0x29d2); /* IntelQ33_1 */
  131. APPEND_DEVICE(0x29d3); /* IntelQ33_2 */
  132. APPEND_DEVICE(0x2a02); /* IntelGL960_1 */
  133. APPEND_DEVICE(0x2a03); /* IntelGL960_2 */
  134. APPEND_DEVICE(0x2a12); /* IntelGM965_1 */
  135. APPEND_DEVICE(0x2a13); /* IntelGM965_2 */
  136. break;
  137. case IntelGMAX4500HD:
  138. APPEND_DEVICE(0x2a42); /* IntelGMA4500MHD_1 */
  139. APPEND_DEVICE(0x2a43); /* IntelGMA4500MHD_2 */
  140. APPEND_DEVICE(0x2e42); /* IntelB43_1 */
  141. APPEND_DEVICE(0x2e43); /* IntelB43_2 */
  142. APPEND_DEVICE(0x2e92); /* IntelB43_3 */
  143. APPEND_DEVICE(0x2e93); /* IntelB43_4 */
  144. APPEND_DEVICE(0x2e32); /* IntelG41_1 */
  145. APPEND_DEVICE(0x2e33); /* IntelG41_2 */
  146. APPEND_DEVICE(0x2e22); /* IntelG45_1 */
  147. APPEND_DEVICE(0x2e23); /* IntelG45_2 */
  148. APPEND_DEVICE(0x2e12); /* IntelQ45_1 */
  149. APPEND_DEVICE(0x2e13); /* IntelQ45_2 */
  150. break;
  151. case IntelHDGraphicsToSandyBridge:
  152. APPEND_DEVICE(0x0042); /* IntelHDGraphics */
  153. APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
  154. APPEND_DEVICE(0x0102); /* IntelSandyBridge_1 */
  155. APPEND_DEVICE(0x0106); /* IntelSandyBridge_2 */
  156. APPEND_DEVICE(0x0112); /* IntelSandyBridge_3 */
  157. APPEND_DEVICE(0x0116); /* IntelSandyBridge_4 */
  158. APPEND_DEVICE(0x0122); /* IntelSandyBridge_5 */
  159. APPEND_DEVICE(0x0126); /* IntelSandyBridge_6 */
  160. APPEND_DEVICE(0x010a); /* IntelSandyBridge_7 */
  161. break;
  162. case IntelHD3000:
  163. APPEND_DEVICE(0x0126);
  164. break;
  165. case IntelMobileHDGraphics:
  166. APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
  167. break;
  168. case NvidiaBlockD3D9Layers:
  169. // Glitches whilst scrolling (see bugs 612007, 644787, 645872)
  170. APPEND_DEVICE(0x00f3); /* NV43 [GeForce 6200 (TM)] */
  171. APPEND_DEVICE(0x0146); /* NV43 [Geforce Go 6600TE/6200TE (TM)] */
  172. APPEND_DEVICE(0x014f); /* NV43 [GeForce 6200 (TM)] */
  173. APPEND_DEVICE(0x0161); /* NV44 [GeForce 6200 TurboCache (TM)] */
  174. APPEND_DEVICE(0x0162); /* NV44 [GeForce 6200SE TurboCache (TM)] */
  175. APPEND_DEVICE(0x0163); /* NV44 [GeForce 6200 LE (TM)] */
  176. APPEND_DEVICE(0x0164); /* NV44 [GeForce Go 6200 (TM)] */
  177. APPEND_DEVICE(0x0167); /* NV43 [GeForce Go 6200/6400 (TM)] */
  178. APPEND_DEVICE(0x0168); /* NV43 [GeForce Go 6200/6400 (TM)] */
  179. APPEND_DEVICE(0x0169); /* NV44 [GeForce 6250 (TM)] */
  180. APPEND_DEVICE(0x0222); /* NV44 [GeForce 6200 A-LE (TM)] */
  181. APPEND_DEVICE(0x0240); /* C51PV [GeForce 6150 (TM)] */
  182. APPEND_DEVICE(0x0241); /* C51 [GeForce 6150 LE (TM)] */
  183. APPEND_DEVICE(0x0244); /* C51 [Geforce Go 6150 (TM)] */
  184. APPEND_DEVICE(0x0245); /* C51 [Quadro NVS 210S/GeForce 6150LE (TM)] */
  185. APPEND_DEVICE(0x0247); /* C51 [GeForce Go 6100 (TM)] */
  186. APPEND_DEVICE(0x03d0); /* C61 [GeForce 6150SE nForce 430 (TM)] */
  187. APPEND_DEVICE(0x03d1); /* C61 [GeForce 6100 nForce 405 (TM)] */
  188. APPEND_DEVICE(0x03d2); /* C61 [GeForce 6100 nForce 400 (TM)] */
  189. APPEND_DEVICE(0x03d5); /* C61 [GeForce 6100 nForce 420 (TM)] */
  190. break;
  191. case RadeonX1000:
  192. // This list is from the ATIRadeonX1000.kext Info.plist
  193. APPEND_DEVICE(0x7187);
  194. APPEND_DEVICE(0x7210);
  195. APPEND_DEVICE(0x71de);
  196. APPEND_DEVICE(0x7146);
  197. APPEND_DEVICE(0x7142);
  198. APPEND_DEVICE(0x7109);
  199. APPEND_DEVICE(0x71c5);
  200. APPEND_DEVICE(0x71c0);
  201. APPEND_DEVICE(0x7240);
  202. APPEND_DEVICE(0x7249);
  203. APPEND_DEVICE(0x7291);
  204. break;
  205. case Geforce7300GT:
  206. APPEND_DEVICE(0x0393);
  207. break;
  208. case Nvidia310M:
  209. APPEND_DEVICE(0x0A70);
  210. break;
  211. case Nvidia8800GTS:
  212. APPEND_DEVICE(0x0193);
  213. break;
  214. case Bug1137716:
  215. APPEND_DEVICE(0x0a29);
  216. APPEND_DEVICE(0x0a2b);
  217. APPEND_DEVICE(0x0a2d);
  218. APPEND_DEVICE(0x0a35);
  219. APPEND_DEVICE(0x0a6c);
  220. APPEND_DEVICE(0x0a70);
  221. APPEND_DEVICE(0x0a72);
  222. APPEND_DEVICE(0x0a7a);
  223. APPEND_DEVICE(0x0caf);
  224. APPEND_DEVICE(0x0dd2);
  225. APPEND_DEVICE(0x0dd3);
  226. // GF180M ids
  227. APPEND_DEVICE(0x0de3);
  228. APPEND_DEVICE(0x0de8);
  229. APPEND_DEVICE(0x0de9);
  230. APPEND_DEVICE(0x0dea);
  231. APPEND_DEVICE(0x0deb);
  232. APPEND_DEVICE(0x0dec);
  233. APPEND_DEVICE(0x0ded);
  234. APPEND_DEVICE(0x0dee);
  235. APPEND_DEVICE(0x0def);
  236. APPEND_DEVICE(0x0df0);
  237. APPEND_DEVICE(0x0df1);
  238. APPEND_DEVICE(0x0df2);
  239. APPEND_DEVICE(0x0df3);
  240. APPEND_DEVICE(0x0df4);
  241. APPEND_DEVICE(0x0df5);
  242. APPEND_DEVICE(0x0df6);
  243. APPEND_DEVICE(0x0df7);
  244. APPEND_DEVICE(0x1050);
  245. APPEND_DEVICE(0x1051);
  246. APPEND_DEVICE(0x1052);
  247. APPEND_DEVICE(0x1054);
  248. APPEND_DEVICE(0x1055);
  249. break;
  250. case Bug1116812:
  251. APPEND_DEVICE(0x2e32);
  252. APPEND_DEVICE(0x2a02);
  253. break;
  254. case Bug1155608:
  255. APPEND_DEVICE(0x2e22); /* IntelG45_1 */
  256. break;
  257. case Bug1207665:
  258. APPEND_DEVICE(0xa001); /* Intel Media Accelerator 3150 */
  259. APPEND_DEVICE(0xa002);
  260. APPEND_DEVICE(0xa011);
  261. APPEND_DEVICE(0xa012);
  262. break;
  263. // This should never happen, but we get a warning if we don't handle this.
  264. case DeviceFamilyMax:
  265. NS_WARNING("Invalid DeviceFamily id");
  266. break;
  267. }
  268. return deviceFamily;
  269. }
  270. // Macro for assigning a device vendor id to a string.
  271. #define DECLARE_VENDOR_ID(name, deviceId) \
  272. case name: \
  273. mDeviceVendors[id]->AssignLiteral(deviceId); \
  274. break;
  275. const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceVendor id)
  276. {
  277. NS_ASSERTION(id >= 0 && id < DeviceVendorMax, "DeviceVendor id is out of range");
  278. if (mDeviceVendors[id])
  279. return *mDeviceVendors[id];
  280. mDeviceVendors[id] = new nsString();
  281. switch (id) {
  282. DECLARE_VENDOR_ID(VendorAll, "");
  283. DECLARE_VENDOR_ID(VendorIntel, "0x8086");
  284. DECLARE_VENDOR_ID(VendorNVIDIA, "0x10de");
  285. DECLARE_VENDOR_ID(VendorAMD, "0x1022");
  286. DECLARE_VENDOR_ID(VendorATI, "0x1002");
  287. DECLARE_VENDOR_ID(VendorMicrosoft, "0x1414");
  288. // Suppress a warning.
  289. DECLARE_VENDOR_ID(DeviceVendorMax, "");
  290. }
  291. return *mDeviceVendors[id];
  292. }