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