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