19514001df3da82c1274d54732836bf3d19305be
[deb_xorg-server.git] / debian / patches / 226_fall_back_to_autoconfiguration.patch
1 --- a/hw/xfree86/common/xf86Globals.c
2 +++ b/hw/xfree86/common/xf86Globals.c
3 @@ -162,6 +162,7 @@ InputDriverPtr *xf86InputDriverList = NU
4 int xf86NumInputDrivers = 0;
5 int xf86NumScreens = 0;
6 int xf86NumGPUScreens = 0;
7 +Bool xf86AttemptedFallback = FALSE;
8
9 const char *xf86VisualNames[] = {
10 "StaticGray",
11 --- a/hw/xfree86/common/xf86Init.c
12 +++ b/hw/xfree86/common/xf86Init.c
13 @@ -482,20 +482,34 @@ InitOutput(ScreenInfo * pScreenInfo, int
14 free(optionlist);
15 }
16
17 + Fallback:
18 /* Load all driver modules specified in the config file */
19 /* If there aren't any specified in the config file, autoconfig them */
20 /* FIXME: Does not handle multiple active screen sections, but I'm not
21 * sure if we really want to handle that case*/
22 configured_device = xf86ConfigLayout.screens->screen->device;
23 - if ((!configured_device) || (!configured_device->driver)) {
24 + if (xf86AttemptedFallback) {
25 + configured_device->driver = NULL;
26 + if (!autoConfigDevice(configured_device)) {
27 + xf86Msg(X_ERROR, "Auto configuration on fallback failed\n");
28 + return;
29 + }
30 + }
31 + else if ((!configured_device) || (!configured_device->driver)) {
32 if (!autoConfigDevice(configured_device)) {
33 xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
34 return;
35 }
36 }
37 if ((modulelist = xf86DriverlistFromConfig())) {
38 - xf86LoadModules(modulelist, NULL);
39 - free(modulelist);
40 + if (!xf86LoadModules(modulelist, NULL) && !xf86AttemptedFallback) {
41 + free(modulelist);
42 + xf86AttemptedFallback = TRUE;
43 + goto Fallback;
44 + }
45 + else {
46 + free(modulelist);
47 + }
48 }
49
50 /* Load all input driver modules specified in the config file. */
51 @@ -557,8 +571,15 @@ InitOutput(ScreenInfo * pScreenInfo, int
52 if (want_hw_access)
53 xorgHWAccess = xf86EnableIO();
54
55 - if (xf86BusConfig() == FALSE)
56 - return;
57 + if (xf86BusConfig() == FALSE) {
58 + if (!xf86AttemptedFallback) {
59 + xf86AttemptedFallback = TRUE;
60 + goto Fallback;
61 + }
62 + else {
63 + return;
64 + }
65 + }
66
67 xf86PostProbe();
68
69 --- a/hw/xfree86/common/xf86Priv.h
70 +++ b/hw/xfree86/common/xf86Priv.h
71 @@ -89,6 +89,7 @@ extern _X_EXPORT int xf86NumDrivers;
72 extern _X_EXPORT Bool xf86Resetting;
73 extern _X_EXPORT Bool xf86Initialising;
74 extern _X_EXPORT int xf86NumScreens;
75 +extern _X_EXPORT Bool xf86AttemptedFallback;
76 extern _X_EXPORT const char *xf86VisualNames[];
77 extern _X_EXPORT int xf86Verbose; /* verbosity level */
78 extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */