• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 Patrick Rudolph <siro@das-labor.org>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22 
23 #include <string.h>
24 #include "adapter9.h"
25 
26 #define DBG_CHANNEL DBG_ADAPTER
27 
28 /* prototypes */
29 void
30 d3d_match_vendor_id( D3DADAPTER_IDENTIFIER9* drvid,
31         unsigned fallback_ven,
32         unsigned fallback_dev,
33         const char* fallback_name );
34 void d3d_fill_driver_version(D3DADAPTER_IDENTIFIER9* drvid);
35 void d3d_fill_cardname(D3DADAPTER_IDENTIFIER9* drvid);
36 
37 enum d3d_vendor_id
38 {
39     HW_VENDOR_SOFTWARE              = 0x0000,
40     HW_VENDOR_AMD                   = 0x1002,
41     HW_VENDOR_NVIDIA                = 0x10de,
42     HW_VENDOR_VMWARE                = 0x15ad,
43     HW_VENDOR_INTEL                 = 0x8086,
44 };
45 
46 struct card_lookup_table {
47     const char *mesaname;
48     const char *d3d9name;
49 }
50 cards_amd[] = {
51     {"HAWAII",                      "AMD Radeon R9 290"},
52     {"KAVERI",                      "AMD Radeon(TM) R7 Graphics"},
53     {"KABINI",                      "AMD Radeon HD 8400 / R3 Series"},
54     {"BONAIRE",                     "AMD Radeon HD 8770"},
55     {"OLAND",                       "AMD Radeon HD 8670"},
56     {"HAINAN",                      "AMD Radeon HD 8600M Series"},
57     {"TAHITI",                      "AMD Radeon HD 7900 Series"},
58     {"PITCAIRN",                    "AMD Radeon HD 7800 Series"},
59     {"CAPE VERDE",                  "AMD Radeon HD 7700 Series"},
60     {"ARUBA",                       "AMD Radeon HD 7660D"},
61     {"CAYMAN",                      "AMD Radeon HD 6900 Series"},
62     {"BARTS",                       "AMD Radeon HD 6800 Series"},
63     {"TURKS",                       "AMD Radeon HD 6600 Series"},
64     {"SUMO2",                       "AMD Radeon HD 6410D"},
65     {"SUMO",                        "AMD Radeon HD 6550D"},
66     {"CAICOS",                      "AMD Radeon HD 6400 Series"},
67     {"PALM",                        "AMD Radeon HD 6300 series Graphics"},
68     {"HEMLOCK",                     "ATI Radeon HD 5900 Series"},
69     {"CYPRESS",                     "ATI Radeon HD 5800 Series"},
70     {"JUNIPER",                     "ATI Radeon HD 5700 Series"},
71     {"REDWOOD",                     "ATI Radeon HD 5600 Series"},
72     {"CEDAR",                       "ATI Radeon HD 5500 Series"},
73     {"R700",                        "ATI Radeon HD 4800 Series"},
74     {"RV790",                       "ATI Radeon HD 4800 Series"},
75     {"RV770",                       "ATI Radeon HD 4800 Series"},
76     {"RV740",                       "ATI Radeon HD 4700 Series"},
77     {"RV730",                       "ATI Radeon HD 4600 Series"},
78     {"RV710",                       "ATI Radeon HD 4350"},
79     {"RS880",                       "ATI Mobility Radeon HD 4200"},
80     {"RS780",                       "ATI Radeon HD 3200 Graphics"},
81     {"R680",                        "ATI Radeon HD 2900 XT"},
82     {"R600",                        "ATI Radeon HD 2900 XT"},
83     {"RV670",                       "ATI Radeon HD 2900 XT"},
84     {"RV635",                       "ATI Mobility Radeon HD 2600"},
85     {"RV630",                       "ATI Mobility Radeon HD 2600"},
86     {"RV620",                       "ATI Mobility Radeon HD 2350"},
87     {"RV610",                       "ATI Mobility Radeon HD 2350"},
88     {"R580",                        "ATI Radeon X1600 Series"},
89     {"R520",                        "ATI Radeon X1600 Series"},
90     {"RV570",                       "ATI Radeon X1600 Series"},
91     {"RV560",                       "ATI Radeon X1600 Series"},
92     {"RV535",                       "ATI Radeon X1600 Series"},
93     {"RV530",                       "ATI Radeon X1600 Series"},
94     {"RV516",                       "ATI Radeon X700 SE"},
95     {"RV515",                       "ATI Radeon X700 SE"},
96     {"R481",                        "ATI Radeon X700 SE"},
97     {"R480",                        "ATI Radeon X700 SE"},
98     {"R430",                        "ATI Radeon X700 SE"},
99     {"R423",                        "ATI Radeon X700 SE"},
100     {"R420",                        "ATI Radeon X700 SE"},
101     {"R410",                        "ATI Radeon X700 SE"},
102     {"RV410",                       "ATI Radeon X700 SE"},
103     {"RS740",                       "ATI RADEON XPRESS 200M Series"},
104     {"RS690",                       "ATI RADEON XPRESS 200M Series"},
105     {"RS600",                       "ATI RADEON XPRESS 200M Series"},
106     {"RS485",                       "ATI RADEON XPRESS 200M Series"},
107     {"RS482",                       "ATI RADEON XPRESS 200M Series"},
108     {"RS480",                       "ATI RADEON XPRESS 200M Series"},
109     {"RS400",                       "ATI RADEON XPRESS 200M Series"},
110     {"R360",                        "ATI Radeon 9500"},
111     {"R350",                        "ATI Radeon 9500"},
112     {"R300",                        "ATI Radeon 9500"},
113     {"RV370",                       "ATI Radeon 9500"},
114     {"RV360",                       "ATI Radeon 9500"},
115     {"RV351",                       "ATI Radeon 9500"},
116     {"RV350",                       "ATI Radeon 9500"},
117 },
118 cards_nvidia[] =
119 {
120     {"NV124",                       "NVIDIA GeForce GTX 970"},
121     {"NV117",                       "NVIDIA GeForce GTX 750"},
122     {"NVF1",                        "NVIDIA GeForce GTX 780 Ti"},
123     {"NVF0",                        "NVIDIA GeForce GTX 780"},
124     {"NVE6",                        "NVIDIA GeForce GTX 770M"},
125     {"NVE4",                        "NVIDIA GeForce GTX 680"},
126     {"NVD9",                        "NVIDIA GeForce GT 520"},
127     {"NVCF",                        "NVIDIA GeForce GTX 550 Ti"},
128     {"NVCE",                        "NVIDIA GeForce GTX 560"},
129     {"NVC8",                        "NVIDIA GeForce GTX 570"},
130     {"NVC4",                        "NVIDIA GeForce GTX 460"},
131     {"NVC3",                        "NVIDIA GeForce GT 440"},
132     {"NVC1",                        "NVIDIA GeForce GT 420"},
133     {"NVC0",                        "NVIDIA GeForce GTX 480"},
134     {"NVAF",                        "NVIDIA GeForce GT 320M"},
135     {"NVAC",                        "NVIDIA GeForce 8200"},
136     {"NVAA",                        "NVIDIA GeForce 8200"},
137     {"NVA8",                        "NVIDIA GeForce 210"},
138     {"NVA5",                        "NVIDIA GeForce GT 220"},
139     {"NVA3",                        "NVIDIA GeForce GT 240"},
140     {"NVA0",                        "NVIDIA GeForce GTX 280"},
141     {"NV98",                        "NVIDIA GeForce 9200"},
142     {"NV96",                        "NVIDIA GeForce 9400 GT"},
143     {"NV94",                        "NVIDIA GeForce 9600 GT"},
144     {"NV92",                        "NVIDIA GeForce 9800 GT"},
145     {"NV86",                        "NVIDIA GeForce 8500 GT"},
146     {"NV84",                        "NVIDIA GeForce 8600 GT"},
147     {"NV50",                        "NVIDIA GeForce 8800 GTX"},
148     {"NV68",                        "NVIDIA GeForce 6200"},
149     {"NV67",                        "NVIDIA GeForce 6200"},
150     {"NV63",                        "NVIDIA GeForce 6200"},
151     {"NV4E",                        "NVIDIA GeForce 6200"},
152     {"NV4C",                        "NVIDIA GeForce 6200"},
153     {"NV4B",                        "NVIDIA GeForce 7600 GT"},
154     {"NV4A",                        "NVIDIA GeForce 6200"},
155     {"NV49",                        "NVIDIA GeForce 7800 GT"},
156     {"NV47",                        "NVIDIA GeForce 7800 GT"},
157     {"NV46",                        "NVIDIA GeForce Go 7400",},
158     {"NV45",                        "NVIDIA GeForce 6800"},
159     {"NV44",                        "NVIDIA GeForce 6200"},
160     {"NV43",                        "NVIDIA GeForce 6600 GT"},
161     {"NV42",                        "NVIDIA GeForce 6800"},
162     {"NV41",                        "NVIDIA GeForce 6800"},
163     {"NV40",                        "NVIDIA GeForce 6800"},
164     {"NV38",                        "NVIDIA GeForce FX 5800"},
165     {"NV36",                        "NVIDIA GeForce FX 5800"},
166     {"NV35",                        "NVIDIA GeForce FX 5800"},
167     {"NV34",                        "NVIDIA GeForce FX 5200"},
168     {"NV31",                        "NVIDIA GeForce FX 5600"},
169     {"NV30",                        "NVIDIA GeForce FX 5800"},
170     {"nv28",                        "NVIDIA GeForce4 Ti 4200"},
171     {"nv25",                        "NVIDIA GeForce4 Ti 4200"},
172     {"nv20",                        "NVIDIA GeForce3"},
173     {"nv1F",                        "NVIDIA GeForce4 MX 460"},
174     {"nv1A",                        "NVIDIA GeForce2 GTS/GeForce2 Pro"},
175     {"nv18",                        "NVIDIA GeForce4 MX 460"},
176     {"nv17",                        "NVIDIA GeForce4 MX 460"},
177     {"nv16",                        "NVIDIA GeForce2 GTS/GeForce2 Pro"},
178     {"nv15",                        "NVIDIA GeForce2 GTS/GeForce2 Pro"},
179     {"nv11",                        "NVIDIA GeForce2 MX/MX 400"},
180     {"nv10",                        "NVIDIA GeForce 256"},
181 },
182 cards_vmware[] =
183 {
184     {"SVGA3D",                      "VMware SVGA 3D (Microsoft Corporation - WDDM)"},
185 },
186 cards_intel[] =
187 {
188     {"Haswell Mobile",              "Intel(R) Haswell Mobile"},
189     {"Ivybridge Server",            "Intel(R) Ivybridge Server"},
190     {"Ivybridge Mobile",            "Intel(R) Ivybridge Mobile"},
191     {"Ivybridge Desktop",           "Intel(R) Ivybridge Desktop"},
192     {"Sandybridge Server",          "Intel(R) Sandybridge Server"},
193     {"Sandybridge Mobile",          "Intel(R) Sandybridge Mobile"},
194     {"Sandybridge Desktop",         "Intel(R) Sandybridge Desktop"},
195     {"Ironlake Mobile",             "Intel(R) Ironlake Mobile"},
196     {"Ironlake Desktop",            "Intel(R) Ironlake Desktop"},
197     {"B43",                         "Intel(R) B43"},
198     {"G41",                         "Intel(R) G41"},
199     {"G45",                         "Intel(R) G45/G43"},
200     {"Q45",                         "Intel(R) Q45/Q43"},
201     {"Integrated Graphics Device",  "Intel(R) Integrated Graphics Device"},
202     {"GM45",                        "Mobile Intel(R) GM45 Express Chipset Family"},
203     {"965GME",                      "Intel(R) 965GME"},
204     {"965GM",                       "Mobile Intel(R) 965 Express Chipset Family"},
205     {"946GZ",                       "Intel(R) 946GZ"},
206     {"965G",                        "Intel(R) 965G"},
207     {"965Q",                        "Intel(R) 965Q"},
208     {"Pineview M",                  "Intel(R) IGD"},
209     {"Pineview G",                  "Intel(R) IGD"},
210     {"IGD",                         "Intel(R) IGD"},
211     {"Q33",                         "Intel(R) Q33"},
212     {"G33",                         "Intel(R) G33"},
213     {"Q35",                         "Intel(R) Q35"},
214     {"945GME",                      "Intel(R) 945GME"},
215     {"945GM",                       "Mobile Intel(R) 945GM Express Chipset Family"},
216     {"945G",                        "Intel(R) 945G"},
217     {"915GM",                       "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family"},
218     {"E7221G",                      "Intel(R) E7221G"},
219     {"915G",                        "Intel(R) 82915G/GV/910GL Express Chipset Family"},
220     {"865G",                        "Intel(R) 82865G Graphics Controller"},
221     {"845G",                        "Intel(R) 845G"},
222     {"855GM",                       "Intel(R) 82852/82855 GM/GME Graphics Controller"},
223     {"830M",                        "Intel(R) 82830M Graphics Controller"},
224 };
225 
226 /* override VendorId, DeviceId and Description for unknown vendors */
227 void
d3d_match_vendor_id(D3DADAPTER_IDENTIFIER9 * drvid,unsigned fallback_ven,unsigned fallback_dev,const char * fallback_name)228 d3d_match_vendor_id( D3DADAPTER_IDENTIFIER9* drvid,
229         unsigned fallback_ven,
230         unsigned fallback_dev,
231         const char* fallback_name )
232 {
233     if (drvid->VendorId == HW_VENDOR_INTEL ||
234         drvid->VendorId == HW_VENDOR_VMWARE ||
235         drvid->VendorId == HW_VENDOR_AMD ||
236         drvid->VendorId == HW_VENDOR_NVIDIA)
237         return;
238 
239     DBG("unknown vendor 0x4%x, emulating 0x4%x\n", drvid->VendorId, fallback_ven);
240     drvid->VendorId = fallback_ven;
241     drvid->DeviceId = fallback_dev;
242     strncpy(drvid->Description, fallback_name, sizeof(drvid->Description));
243 }
244 
245 /* fill in driver name and version */
d3d_fill_driver_version(D3DADAPTER_IDENTIFIER9 * drvid)246 void d3d_fill_driver_version(D3DADAPTER_IDENTIFIER9* drvid) {
247     switch (drvid->VendorId) {
248     case HW_VENDOR_INTEL:
249         drvid->DriverVersionLowPart = 0x000A0682;
250         drvid->DriverVersionHighPart = 0x0006000F;
251         strncpy(drvid->Driver, "igdumd32.dll", sizeof(drvid->Driver));
252         break;
253     case HW_VENDOR_VMWARE:
254         drvid->DriverVersionLowPart = 0x0001046E;
255         drvid->DriverVersionHighPart = 0x0006000E;
256         strncpy(drvid->Driver, "vm3dum.dll", sizeof(drvid->Driver));
257         break;
258     case HW_VENDOR_AMD:
259         drvid->DriverVersionLowPart = 0x000A0500;
260         drvid->DriverVersionHighPart = 0x00060011;
261         strncpy(drvid->Driver, "atiumdag.dll", sizeof(drvid->Driver));
262         break;
263     case HW_VENDOR_NVIDIA:
264         drvid->DriverVersionLowPart = 0x000D0FD4;
265         drvid->DriverVersionHighPart = 0x00060012;
266         strncpy(drvid->Driver, "nvd3dum.dll", sizeof(drvid->Driver));
267         break;
268     default:
269         break;
270     }
271 }
272 
273 /* try to match the device name and override it with Windows like device names */
d3d_fill_cardname(D3DADAPTER_IDENTIFIER9 * drvid)274 void d3d_fill_cardname(D3DADAPTER_IDENTIFIER9* drvid) {
275     unsigned i;
276     switch (drvid->VendorId) {
277     case HW_VENDOR_INTEL:
278         for (i = 0; i < sizeof(cards_intel) / sizeof(cards_intel[0]); i++) {
279             if (strstr(drvid->Description, cards_intel[i].mesaname)) {
280                 strncpy(drvid->Description, cards_intel[i].d3d9name, sizeof(drvid->Description));
281                 return;
282             }
283         }
284         /* use a fall-back if nothing matches */
285         DBG("Unknown card name %s!\n", drvid->DeviceName);
286         strncpy(drvid->Description, cards_intel[0].d3d9name, sizeof(drvid->Description));
287         break;
288     case HW_VENDOR_VMWARE:
289         for (i = 0; i < sizeof(cards_vmware) / sizeof(cards_vmware[0]); i++) {
290             if (strstr(drvid->Description, cards_vmware[i].mesaname)) {
291                 strncpy(drvid->Description, cards_vmware[i].d3d9name, sizeof(drvid->Description));
292                 return;
293             }
294         }
295         /* use a fall-back if nothing matches */
296         DBG("Unknown card name %s!\n", drvid->DeviceName);
297         strncpy(drvid->Description, cards_vmware[0].d3d9name, sizeof(drvid->Description));
298         break;
299     case HW_VENDOR_AMD:
300         for (i = 0; i < sizeof(cards_amd) / sizeof(cards_amd[0]); i++) {
301             if (strstr(drvid->Description, cards_amd[i].mesaname)) {
302                 strncpy(drvid->Description, cards_amd[i].d3d9name, sizeof(drvid->Description));
303                 return;
304             }
305         }
306         /* use a fall-back if nothing matches */
307         DBG("Unknown card name %s!\n", drvid->DeviceName);
308         strncpy(drvid->Description, cards_amd[0].d3d9name, sizeof(drvid->Description));
309         break;
310     case HW_VENDOR_NVIDIA:
311         for (i = 0; i < sizeof(cards_nvidia) / sizeof(cards_nvidia[0]); i++) {
312             if (strstr(drvid->Description, cards_nvidia[i].mesaname)) {
313                 strncpy(drvid->Description, cards_nvidia[i].d3d9name, sizeof(drvid->Description));
314                 return;
315             }
316         }
317         /* use a fall-back if nothing matches */
318         DBG("Unknown card name %s!\n", drvid->DeviceName);
319         strncpy(drvid->Description, cards_nvidia[0].d3d9name, sizeof(drvid->Description));
320         break;
321     default:
322         break;
323     }
324 }
325