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