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