Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / 226_fall_back_to_autoconfiguration.patch
diff --git a/debian/patches/226_fall_back_to_autoconfiguration.patch b/debian/patches/226_fall_back_to_autoconfiguration.patch
new file mode 100644 (file)
index 0000000..70fa7e5
--- /dev/null
@@ -0,0 +1,78 @@
+--- a/hw/xfree86/common/xf86Globals.c
++++ b/hw/xfree86/common/xf86Globals.c
+@@ -161,6 +161,7 @@
+ int xf86NumInputDrivers = 0;
+ int xf86NumScreens = 0;
+ int xf86NumGPUScreens = 0;
++Bool xf86AttemptedFallback = FALSE;
+ const char *xf86VisualNames[] = {
+     "StaticGray",
+--- a/hw/xfree86/common/xf86Init.c
++++ b/hw/xfree86/common/xf86Init.c
+@@ -481,20 +481,34 @@
+             free(optionlist);
+         }
++ Fallback:
+         /* Load all driver modules specified in the config file */
+         /* If there aren't any specified in the config file, autoconfig them */
+         /* FIXME: Does not handle multiple active screen sections, but I'm not
+          * sure if we really want to handle that case*/
+         configured_device = xf86ConfigLayout.screens->screen->device;
+-        if ((!configured_device) || (!configured_device->driver)) {
++        if (xf86AttemptedFallback) {
++            configured_device->driver = NULL;
++            if (!autoConfigDevice(configured_device)) {
++                xf86Msg(X_ERROR, "Auto configuration on fallback failed\n");
++                return;
++            }
++        }
++        else if ((!configured_device) || (!configured_device->driver)) {
+             if (!autoConfigDevice(configured_device)) {
+                 xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
+                 return;
+             }
+         }
+         if ((modulelist = xf86DriverlistFromConfig())) {
+-            xf86LoadModules(modulelist, NULL);
+-            free(modulelist);
++            if (!xf86LoadModules(modulelist, NULL) && !xf86AttemptedFallback) {
++                free(modulelist);
++                xf86AttemptedFallback = TRUE;
++                goto Fallback;
++            }
++            else {
++                free(modulelist);
++            }
+         }
+         /* Load all input driver modules specified in the config file. */
+@@ -554,8 +568,15 @@
+         else
+             xf86Info.dontVTSwitch = TRUE;
+-        if (xf86BusConfig() == FALSE)
+-            return;
++        if (xf86BusConfig() == FALSE) {
++            if (!xf86AttemptedFallback) {
++                xf86AttemptedFallback = TRUE;
++                goto Fallback;
++            }
++            else {
++                return;
++            }
++        }
+         xf86PostProbe();
+--- a/hw/xfree86/common/xf86Priv.h
++++ b/hw/xfree86/common/xf86Priv.h
+@@ -89,6 +89,7 @@
+ extern _X_EXPORT Bool xf86Resetting;
+ extern _X_EXPORT Bool xf86Initialising;
+ extern _X_EXPORT int xf86NumScreens;
++extern _X_EXPORT Bool xf86AttemptedFallback;
+ extern _X_EXPORT const char *xf86VisualNames[];
+ extern _X_EXPORT int xf86Verbose;       /* verbosity level */
+ extern _X_EXPORT int xf86LogVerbose;    /* log file verbosity level */