|
1 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
|
2 # Use subject to license terms. |
|
3 # |
|
4 # Permission is hereby granted, free of charge, to any person obtaining a |
|
5 # copy of this software and associated documentation files (the |
|
6 # "Software"), to deal in the Software without restriction, including |
|
7 # without limitation the rights to use, copy, modify, merge, publish, |
|
8 # distribute, and/or sell copies of the Software, and to permit persons |
|
9 # to whom the Software is furnished to do so, provided that the above |
|
10 # copyright notice(s) and this permission notice appear in all copies of |
|
11 # the Software and that both the above copyright notice(s) and this |
|
12 # permission notice appear in supporting documentation. |
|
13 # |
|
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
|
17 # OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
|
18 # HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL |
|
19 # INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING |
|
20 # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
|
21 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
|
22 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
23 # |
|
24 # Except as contained in this notice, the name of a copyright holder |
|
25 # shall not be used in advertising or otherwise to promote the sale, use |
|
26 # or other dealings in this Software without prior written authorization |
|
27 # of the copyright holder. |
|
28 |
|
29 diff -urp -x '*~' -x '*.orig' hw/xfree86/common/xf86AutoConfig.c hw/xfree86/common/xf86AutoConfig.c |
|
30 --- hw/xfree86/common/xf86AutoConfig.c 2008-05-07 18:53:54.780461000 -0700 |
|
31 +++ hw/xfree86/common/xf86AutoConfig.c 2008-05-07 18:54:39.872308000 -0700 |
|
32 @@ -40,6 +40,11 @@ |
|
33 #include "xf86Priv.h" |
|
34 #include "xf86_OSlib.h" |
|
35 |
|
36 +#ifdef sun |
|
37 +# include <sys/visual_io.h> |
|
38 +# include <ctype.h> |
|
39 +#endif |
|
40 + |
|
41 /* Sections for the default built-in configuration. */ |
|
42 |
|
43 #define BUILTIN_MODULE_SECTION \ |
|
44 @@ -99,7 +104,7 @@ |
|
45 |
|
46 static const char **builtinConfig = NULL; |
|
47 static int builtinLines = 0; |
|
48 -static const char *deviceList[] = { |
|
49 +static const char *fallbackDeviceList[] = { |
|
50 #if defined(sun) && defined(__sparc) |
|
51 "wsfb", |
|
52 #else |
|
53 @@ -160,70 +165,123 @@ AppendToConfig(const char *s) |
|
54 AppendToList(s, &builtinConfig, &builtinLines); |
|
55 } |
|
56 |
|
57 -static const char * |
|
58 -videoPtrToDriverName(pciVideoPtr info) |
|
59 +static void |
|
60 +videoPtrToDriverName(pciVideoPtr info, const char *driverList[]) |
|
61 { |
|
62 /* |
|
63 * things not handled yet: |
|
64 * amd/cyrix/nsc |
|
65 * xgi |
|
66 */ |
|
67 - |
|
68 switch (info->vendor) |
|
69 { |
|
70 - case 0x1142: return "apm"; |
|
71 - case 0xedd8: return "ark"; |
|
72 - case 0x1a03: return "ast"; |
|
73 - case 0x1002: return "ati"; |
|
74 - case 0x102c: return "chips"; |
|
75 - case 0x1013: return "cirrus"; |
|
76 + case 0x1142: driverList[0] = "apm"; break; |
|
77 + case 0xedd8: driverList[0] = "ark"; break; |
|
78 + case 0x1a03: driverList[0] = "ast"; break; |
|
79 + case 0x1002: |
|
80 + driverList[0] = "ati"; |
|
81 + driverList[1] = "radeonhd"; |
|
82 + break; |
|
83 + case 0x102c: driverList[0] = "chips"; break; |
|
84 + case 0x1013: driverList[0] = "cirrus"; break; |
|
85 case 0x8086: |
|
86 - if ((info->chipType == 0x00d1) || (info->chipType == 0x7800)) |
|
87 - return "i740"; |
|
88 - else return "i810"; |
|
89 - case 0x102b: return "mga"; |
|
90 - case 0x10c8: return "neomagic"; |
|
91 - case 0x105d: return "i128"; |
|
92 - case 0x10de: case 0x12d2: return "nv"; |
|
93 - case 0x1163: return "rendition"; |
|
94 + if ((info->chipType == 0x00d1) || (info->chipType == 0x7800)) { |
|
95 + driverList[0] = "i740"; |
|
96 + } else { |
|
97 + driverList[0] = "intel"; |
|
98 + driverList[1] = "i810"; |
|
99 + } |
|
100 + break; |
|
101 + case 0x102b: driverList[0] = "mga"; break; |
|
102 + case 0x10c8: driverList[0] = "neomagic"; break; |
|
103 + case 0x105d: driverList[0] = "i128"; break; |
|
104 + case 0x10de: case 0x12d2: driverList[0] = "nv"; break; |
|
105 + case 0x1163: driverList[0] = "rendition";break; |
|
106 case 0x5333: |
|
107 switch (info->chipType) |
|
108 { |
|
109 case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811: |
|
110 case 0x8812: case 0x8814: case 0x8901: |
|
111 - return "s3"; |
|
112 + driverList[0] = "s3"; |
|
113 + break; |
|
114 case 0x5631: case 0x883d: case 0x8a01: case 0x8a10: |
|
115 case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13: |
|
116 - return "s3virge"; |
|
117 + driverList[0] = "s3virge"; |
|
118 + break; |
|
119 default: |
|
120 - return "savage"; |
|
121 + driverList[0] = "savage"; |
|
122 + break; |
|
123 } |
|
124 - case 0x1039: return "sis"; |
|
125 - case 0x126f: return "siliconmotion"; |
|
126 + break; |
|
127 + case 0x1039: driverList[0] = "sis"; break; |
|
128 + case 0x126f: driverList[0] = "siliconmotion"; break; |
|
129 case 0x121a: |
|
130 if (info->chipType < 0x0003) |
|
131 - return "voodoo"; |
|
132 + driverList[0] = "voodoo"; |
|
133 else |
|
134 - return "tdfx"; |
|
135 - case 0x3d3d: return "glint"; |
|
136 - case 0x1023: return "trident"; |
|
137 - case 0x100c: return "tseng"; |
|
138 - case 0x1106: return "via"; |
|
139 - case 0x15ad: return "vmware"; |
|
140 + driverList[0] = "tdfx"; |
|
141 + break; |
|
142 + case 0x3d3d: driverList[0] = "glint"; break; |
|
143 + case 0x1023: driverList[0] = "trident"; break; |
|
144 + case 0x100c: driverList[0] = "tseng"; break; |
|
145 + case 0x1106: |
|
146 + driverList[0] = "openchrome"; |
|
147 + driverList[1] = "via"; |
|
148 + break; |
|
149 + case 0x15ad: driverList[0] = "vmware"; break; |
|
150 default: break; |
|
151 } |
|
152 - return NULL; |
|
153 } |
|
154 |
|
155 Bool |
|
156 xf86AutoConfig(void) |
|
157 { |
|
158 - const char **p; |
|
159 + const char *detectedDeviceList[8] = { NULL, NULL, NULL, NULL, |
|
160 + NULL, NULL, NULL, NULL }; |
|
161 + const char **deviceLists[3] |
|
162 + = { detectedDeviceList, fallbackDeviceList, NULL }; |
|
163 + const char **p = detectedDeviceList; |
|
164 + const char ***d; |
|
165 char buf[1024]; |
|
166 pciVideoPtr *pciptr, info = NULL; |
|
167 - char *driver = NULL; |
|
168 ConfigStatus ret; |
|
169 +#ifdef sun |
|
170 + char *vendorName = NULL, *driverName = NULL; |
|
171 |
|
172 + /* Check for driver type based on /dev/fb type and if valid, replace |
|
173 + detectedDeviceList */ |
|
174 + if (xf86Info.consoleFd >= 0) { |
|
175 + struct vis_identifier visid; |
|
176 + const char *cp; |
|
177 + int ddi = 0; |
|
178 + |
|
179 + if (ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid) >= 0) { |
|
180 + xf86Msg(X_PROBED, "console driver: %s\n", visid.name); |
|
181 + |
|
182 + /* Special case from before the general case was set */ |
|
183 + if (strcmp(visid.name, "NVDAnvda") == 0) { |
|
184 + detectedDeviceList[ddi++] = "nvidia"; |
|
185 + } |
|
186 + |
|
187 + /* General case - split into vendor name & driver name */ |
|
188 + if (strcmp(visid.name, "SUNWtext") != 0) { |
|
189 + for (cp = visid.name; (*cp != '\0') && isupper(*cp); cp++) { |
|
190 + /* find end of all uppercase vendor section */ |
|
191 + } |
|
192 + if ((cp != visid.name) && (*cp != '\0')) { |
|
193 + vendorName = xnfstrdup(visid.name); |
|
194 + vendorName[cp - visid.name] = '\0'; |
|
195 + driverName = xnfstrdup(cp); |
|
196 + |
|
197 + detectedDeviceList[ddi++] = vendorName; |
|
198 + detectedDeviceList[ddi++] = driverName; |
|
199 + } |
|
200 + } |
|
201 + p = &detectedDeviceList[ddi]; |
|
202 + } |
|
203 + } |
|
204 +#endif |
|
205 + |
|
206 /* Find the primary device, and get some information about it. */ |
|
207 if (xf86PciVideoInfo) { |
|
208 for (pciptr = xf86PciVideoInfo; (info = *pciptr); pciptr++) { |
|
209 @@ -239,38 +297,29 @@ xf86AutoConfig(void) |
|
210 } |
|
211 |
|
212 if (info) |
|
213 - driver = videoPtrToDriverName(info); |
|
214 - |
|
215 + videoPtrToDriverName(info, p); |
|
216 + |
|
217 AppendToConfig(BUILTIN_MODULE_SECTION); |
|
218 AppendToConfig(BUILTIN_MONITOR_SECTION); |
|
219 - |
|
220 - if (driver) { |
|
221 - snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION_PRE, |
|
222 - driver, 0, driver); |
|
223 - AppendToConfig(buf); |
|
224 - ErrorF("New driver is \"%s\"\n", driver); |
|
225 - buf[0] = '\t'; |
|
226 - AppendToConfig(BUILTIN_DEVICE_SECTION_POST); |
|
227 - snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, |
|
228 - driver, 0, driver, 0); |
|
229 - AppendToConfig(buf); |
|
230 - } |
|
231 - |
|
232 - for (p = deviceList; *p; p++) { |
|
233 - snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p); |
|
234 - AppendToConfig(buf); |
|
235 - snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0); |
|
236 - AppendToConfig(buf); |
|
237 + |
|
238 + ErrorF("Drivers to try are:"); |
|
239 + for (d = deviceLists; *d ; d++) { |
|
240 + for (p = *d; *p; p++) { |
|
241 + ErrorF(" \"%s\"", *p); |
|
242 + snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p); |
|
243 + AppendToConfig(buf); |
|
244 + snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0); |
|
245 + AppendToConfig(buf); |
|
246 + } |
|
247 } |
|
248 + ErrorF("\n"); |
|
249 |
|
250 AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE); |
|
251 - if (driver) { |
|
252 - snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, driver, 0); |
|
253 - AppendToConfig(buf); |
|
254 - } |
|
255 - for (p = deviceList; *p; p++) { |
|
256 - snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0); |
|
257 - AppendToConfig(buf); |
|
258 + for (d = deviceLists; *d ; d++) { |
|
259 + for (p = *d; *p; p++) { |
|
260 + snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0); |
|
261 + AppendToConfig(buf); |
|
262 + } |
|
263 } |
|
264 AppendToConfig(BUILTIN_LAYOUT_SECTION_POST); |
|
265 |
|
266 @@ -287,6 +336,11 @@ xf86AutoConfig(void) |
|
267 ret = xf86HandleConfigFile(TRUE); |
|
268 FreeConfig(); |
|
269 |
|
270 +#ifdef sun |
|
271 + xfree(driverName); |
|
272 + xfree(vendorName); |
|
273 +#endif |
|
274 + |
|
275 if (ret != CONFIG_OK) |
|
276 xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n"); |
|
277 |