Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/GfxDriverInfo.cpp
Line
Count
Source (jump to first uncovered line)
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::sDeviceFamilies[DeviceFamilyMax];
18
nsAString* GfxDriverInfo::sDeviceVendors[DeviceVendorMax];
19
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
0
{}
35
36
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
                             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
    mGpu2(gpu2)
58
0
{}
59
60
GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig)
61
  : mOperatingSystem(aOrig.mOperatingSystem),
62
    mOperatingSystemVersion(aOrig.mOperatingSystemVersion),
63
    mAdapterVendor(aOrig.mAdapterVendor),
64
    mFeature(aOrig.mFeature),
65
    mFeatureStatus(aOrig.mFeatureStatus),
66
    mComparisonOp(aOrig.mComparisonOp),
67
    mDriverVersion(aOrig.mDriverVersion),
68
    mDriverVersionMax(aOrig.mDriverVersionMax),
69
    mSuggestedVersion(aOrig.mSuggestedVersion),
70
    mRuleId(aOrig.mRuleId),
71
    mGpu2(aOrig.mGpu2)
72
0
{
73
0
  // If we're managing the lifetime of the device family, we have to make a
74
0
  // 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
0
  } else {
79
0
    mDevices = aOrig.mDevices;
80
0
  }
81
0
82
0
  mDeleteDevices = aOrig.mDeleteDevices;
83
0
}
84
85
GfxDriverInfo::~GfxDriverInfo()
86
0
{
87
0
  if (mDeleteDevices)
88
0
    delete mDevices;
89
0
}
90
91
// Macros for appending a device to the DeviceFamily.
92
0
#define APPEND_DEVICE(device) APPEND_DEVICE2(#device)
93
0
#define APPEND_DEVICE2(device) deviceFamily->AppendElement(NS_LITERAL_STRING(device))
94
95
const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id)
96
0
{
97
0
  // The code here is too sensitive to fall through to the default case if the
98
0
  // code is invalid.
99
0
  NS_ASSERTION(id >= 0 && id < DeviceFamilyMax, "DeviceFamily id is out of range");
100
0
101
0
  // If it already exists, we must have processed it once, so return it now.
102
0
  if (sDeviceFamilies[id])
103
0
    return sDeviceFamilies[id];
104
0
105
0
  sDeviceFamilies[id] = new GfxDeviceFamily;
106
0
  GfxDeviceFamily* deviceFamily = sDeviceFamilies[id];
107
0
108
0
  switch (id) {
109
0
    case IntelGMA500:
110
0
      APPEND_DEVICE(0x8108); /* IntelGMA500_1 */
111
0
      APPEND_DEVICE(0x8109); /* IntelGMA500_2 */
112
0
      break;
113
0
    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
0
    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
0
    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
0
    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
0
    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
0
    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
0
    case IntelHDGraphicsToHaswell:
178
0
      APPEND_DEVICE(0x0402); /* IntelHaswell_GT1_1 */
179
0
      APPEND_DEVICE(0x0406); /* IntelHaswell_GT1_2 */
180
0
      APPEND_DEVICE(0x040A); /* IntelHaswell_GT1_3 */
181
0
      APPEND_DEVICE(0x040B); /* IntelHaswell_GT1_4 */
182
0
      APPEND_DEVICE(0x040E); /* IntelHaswell_GT1_5 */
183
0
      APPEND_DEVICE(0x0A02); /* IntelHaswell_GT1_6 */
184
0
      APPEND_DEVICE(0x0A06); /* IntelHaswell_GT1_7 */
185
0
      APPEND_DEVICE(0x0A0A); /* IntelHaswell_GT1_8 */
186
0
      APPEND_DEVICE(0x0A0B); /* IntelHaswell_GT1_9 */
187
0
      APPEND_DEVICE(0x0A0E); /* IntelHaswell_GT1_10 */
188
0
      APPEND_DEVICE(0x0412); /* IntelHaswell_GT2_1 */
189
0
      APPEND_DEVICE(0x0416); /* IntelHaswell_GT2_2 */
190
0
      APPEND_DEVICE(0x041A); /* IntelHaswell_GT2_3 */
191
0
      APPEND_DEVICE(0x041B); /* IntelHaswell_GT2_4 */
192
0
      APPEND_DEVICE(0x041E); /* IntelHaswell_GT2_5 */
193
0
      APPEND_DEVICE(0x0A12); /* IntelHaswell_GT2_6 */
194
0
      APPEND_DEVICE(0x0A16); /* IntelHaswell_GT2_7 */
195
0
      APPEND_DEVICE(0x0A1A); /* IntelHaswell_GT2_8 */
196
0
      APPEND_DEVICE(0x0A1B); /* IntelHaswell_GT2_9 */
197
0
      APPEND_DEVICE(0x0A1E); /* IntelHaswell_GT2_10 */
198
0
      APPEND_DEVICE(0x0422); /* IntelHaswell_GT3_1 */
199
0
      APPEND_DEVICE(0x0426); /* IntelHaswell_GT3_2 */
200
0
      APPEND_DEVICE(0x042A); /* IntelHaswell_GT3_3 */
201
0
      APPEND_DEVICE(0x042B); /* IntelHaswell_GT3_4 */
202
0
      APPEND_DEVICE(0x042E); /* IntelHaswell_GT3_5 */
203
0
      APPEND_DEVICE(0x0A22); /* IntelHaswell_GT3_6 */
204
0
      APPEND_DEVICE(0x0A26); /* IntelHaswell_GT3_7 */
205
0
      APPEND_DEVICE(0x0A2A); /* IntelHaswell_GT3_8 */
206
0
      APPEND_DEVICE(0x0A2B); /* IntelHaswell_GT3_9 */
207
0
      APPEND_DEVICE(0x0A2E); /* IntelHaswell_GT3_10 */
208
0
      APPEND_DEVICE(0x0D22); /* IntelHaswell_GT3e_1 */
209
0
      APPEND_DEVICE(0x0D26); /* IntelHaswell_GT3e_2 */
210
0
      APPEND_DEVICE(0x0D2A); /* IntelHaswell_GT3e_3 */
211
0
      APPEND_DEVICE(0x0D2B); /* IntelHaswell_GT3e_4 */
212
0
      APPEND_DEVICE(0x0D2E); /* IntelHaswell_GT3e_5 */
213
0
      break;
214
0
    case IntelHD3000:
215
0
      APPEND_DEVICE(0x0126);
216
0
      break;
217
0
    case IntelMobileHDGraphics:
218
0
      APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
219
0
      break;
220
0
    case NvidiaBlockD3D9Layers:
221
0
      // Glitches whilst scrolling (see bugs 612007, 644787, 645872)
222
0
      APPEND_DEVICE(0x00f3); /* NV43 [GeForce 6200 (TM)] */
223
0
      APPEND_DEVICE(0x0146); /* NV43 [Geforce Go 6600TE/6200TE (TM)] */
224
0
      APPEND_DEVICE(0x014f); /* NV43 [GeForce 6200 (TM)] */
225
0
      APPEND_DEVICE(0x0161); /* NV44 [GeForce 6200 TurboCache (TM)] */
226
0
      APPEND_DEVICE(0x0162); /* NV44 [GeForce 6200SE TurboCache (TM)] */
227
0
      APPEND_DEVICE(0x0163); /* NV44 [GeForce 6200 LE (TM)] */
228
0
      APPEND_DEVICE(0x0164); /* NV44 [GeForce Go 6200 (TM)] */
229
0
      APPEND_DEVICE(0x0167); /* NV43 [GeForce Go 6200/6400 (TM)] */
230
0
      APPEND_DEVICE(0x0168); /* NV43 [GeForce Go 6200/6400 (TM)] */
231
0
      APPEND_DEVICE(0x0169); /* NV44 [GeForce 6250 (TM)] */
232
0
      APPEND_DEVICE(0x0222); /* NV44 [GeForce 6200 A-LE (TM)] */
233
0
      APPEND_DEVICE(0x0240); /* C51PV [GeForce 6150 (TM)] */
234
0
      APPEND_DEVICE(0x0241); /* C51 [GeForce 6150 LE (TM)] */
235
0
      APPEND_DEVICE(0x0244); /* C51 [Geforce Go 6150 (TM)] */
236
0
      APPEND_DEVICE(0x0245); /* C51 [Quadro NVS 210S/GeForce 6150LE (TM)] */
237
0
      APPEND_DEVICE(0x0247); /* C51 [GeForce Go 6100 (TM)] */
238
0
      APPEND_DEVICE(0x03d0); /* C61 [GeForce 6150SE nForce 430 (TM)] */
239
0
      APPEND_DEVICE(0x03d1); /* C61 [GeForce 6100 nForce 405 (TM)] */
240
0
      APPEND_DEVICE(0x03d2); /* C61 [GeForce 6100 nForce 400 (TM)] */
241
0
      APPEND_DEVICE(0x03d5); /* C61 [GeForce 6100 nForce 420 (TM)] */
242
0
      break;
243
0
    case RadeonX1000:
244
0
      // This list is from the ATIRadeonX1000.kext Info.plist
245
0
      APPEND_DEVICE(0x7187);
246
0
      APPEND_DEVICE(0x7210);
247
0
      APPEND_DEVICE(0x71de);
248
0
      APPEND_DEVICE(0x7146);
249
0
      APPEND_DEVICE(0x7142);
250
0
      APPEND_DEVICE(0x7109);
251
0
      APPEND_DEVICE(0x71c5);
252
0
      APPEND_DEVICE(0x71c0);
253
0
      APPEND_DEVICE(0x7240);
254
0
      APPEND_DEVICE(0x7249);
255
0
      APPEND_DEVICE(0x7291);
256
0
      break;
257
0
    case Geforce7300GT:
258
0
      APPEND_DEVICE(0x0393);
259
0
      break;
260
0
    case Nvidia310M:
261
0
      APPEND_DEVICE(0x0A70);
262
0
      break;
263
0
    case Nvidia8800GTS:
264
0
      APPEND_DEVICE(0x0193);
265
0
      break;
266
0
    case Bug1137716:
267
0
      APPEND_DEVICE(0x0a29);
268
0
      APPEND_DEVICE(0x0a2b);
269
0
      APPEND_DEVICE(0x0a2d);
270
0
      APPEND_DEVICE(0x0a35);
271
0
      APPEND_DEVICE(0x0a6c);
272
0
      APPEND_DEVICE(0x0a70);
273
0
      APPEND_DEVICE(0x0a72);
274
0
      APPEND_DEVICE(0x0a7a);
275
0
      APPEND_DEVICE(0x0caf);
276
0
      APPEND_DEVICE(0x0dd2);
277
0
      APPEND_DEVICE(0x0dd3);
278
0
      // GF180M ids
279
0
      APPEND_DEVICE(0x0de3);
280
0
      APPEND_DEVICE(0x0de8);
281
0
      APPEND_DEVICE(0x0de9);
282
0
      APPEND_DEVICE(0x0dea);
283
0
      APPEND_DEVICE(0x0deb);
284
0
      APPEND_DEVICE(0x0dec);
285
0
      APPEND_DEVICE(0x0ded);
286
0
      APPEND_DEVICE(0x0dee);
287
0
      APPEND_DEVICE(0x0def);
288
0
      APPEND_DEVICE(0x0df0);
289
0
      APPEND_DEVICE(0x0df1);
290
0
      APPEND_DEVICE(0x0df2);
291
0
      APPEND_DEVICE(0x0df3);
292
0
      APPEND_DEVICE(0x0df4);
293
0
      APPEND_DEVICE(0x0df5);
294
0
      APPEND_DEVICE(0x0df6);
295
0
      APPEND_DEVICE(0x0df7);
296
0
      APPEND_DEVICE(0x1050);
297
0
      APPEND_DEVICE(0x1051);
298
0
      APPEND_DEVICE(0x1052);
299
0
      APPEND_DEVICE(0x1054);
300
0
      APPEND_DEVICE(0x1055);
301
0
      break;
302
0
    case Bug1116812:
303
0
      APPEND_DEVICE(0x2e32);
304
0
      APPEND_DEVICE(0x2a02);
305
0
      break;
306
0
    case Bug1155608:
307
0
      APPEND_DEVICE(0x2e22); /* IntelG45_1 */
308
0
      break;
309
0
    case Bug1447141:
310
0
      APPEND_DEVICE(0x9991);
311
0
      APPEND_DEVICE(0x9993);
312
0
      APPEND_DEVICE(0x9996);
313
0
      APPEND_DEVICE(0x9998);
314
0
      APPEND_DEVICE(0x9901);
315
0
      APPEND_DEVICE(0x990b);
316
0
      break;
317
0
    case Bug1207665:
318
0
      APPEND_DEVICE(0xa001); /* Intel Media Accelerator 3150 */
319
0
      APPEND_DEVICE(0xa002);
320
0
      APPEND_DEVICE(0xa011);
321
0
      APPEND_DEVICE(0xa012);
322
0
      break;
323
0
    // This should never happen, but we get a warning if we don't handle this.
324
0
    case DeviceFamilyMax:
325
0
      NS_WARNING("Invalid DeviceFamily id");
326
0
      break;
327
0
  }
328
0
329
0
  return deviceFamily;
330
0
}
331
332
// Macro for assigning a device vendor id to a string.
333
#define DECLARE_VENDOR_ID(name, deviceId) \
334
0
  case name: \
335
0
    sDeviceVendors[id]->AssignLiteral(deviceId); \
336
0
    break;
337
338
const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceVendor id)
339
0
{
340
0
  NS_ASSERTION(id >= 0 && id < DeviceVendorMax, "DeviceVendor id is out of range");
341
0
342
0
  if (sDeviceVendors[id])
343
0
    return *sDeviceVendors[id];
344
0
345
0
  sDeviceVendors[id] = new nsString();
346
0
347
0
  switch (id) {
348
0
    DECLARE_VENDOR_ID(VendorAll, "");
349
0
    DECLARE_VENDOR_ID(VendorIntel, "0x8086");
350
0
    DECLARE_VENDOR_ID(VendorNVIDIA, "0x10de");
351
0
    DECLARE_VENDOR_ID(VendorAMD, "0x1022");
352
0
    DECLARE_VENDOR_ID(VendorATI, "0x1002");
353
0
    DECLARE_VENDOR_ID(VendorMicrosoft, "0x1414");
354
0
    DECLARE_VENDOR_ID(VendorParallels, "0x1ab8");
355
0
    // Choose an arbitrary Qualcomm PCI VENdor ID for now.
356
0
    // TODO: This should be "QCOM" when Windows device ID parsing is reworked.
357
0
    DECLARE_VENDOR_ID(VendorQualcomm, "0x5143");
358
0
    // Suppress a warning.
359
0
    DECLARE_VENDOR_ID(DeviceVendorMax, "");
360
0
  }
361
0
362
0
  return *sDeviceVendors[id];
363
0
}