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