Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / 111_armel-drv-fallbacks.patch
diff --git a/debian/patches/111_armel-drv-fallbacks.patch b/debian/patches/111_armel-drv-fallbacks.patch
new file mode 100644 (file)
index 0000000..bc76c4e
--- /dev/null
@@ -0,0 +1,86 @@
+diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
+index 55412b4..d4a95d2 100644
+--- a/hw/xfree86/common/xf86AutoConfig.c
++++ b/hw/xfree86/common/xf86AutoConfig.c
+@@ -45,6 +45,12 @@
+ #include "xf86sbusBus.h"
+ #endif
++#if defined(__arm__) && defined(__linux__)
++#include "loaderProcs.h"
++#include <sys/types.h>          /* For opendir in test_sysfs_device */
++#include <dirent.h>             /* For opendir in test_sysfs_device */
++#endif
++
+ #ifdef sun
+ #include <sys/visual_io.h>
+ #include <ctype.h>
+@@ -200,6 +206,27 @@ xf86AutoConfig(void)
+     return ret == CONFIG_OK;
+ }
++#if defined(__arm__) && defined(__linux__)
++static int
++test_sysfs_device(char *device_name, char *driver_name)
++{
++    DIR *dir = opendir("/sys/devices/platform");
++    struct dirent *current_dir;
++    int len = strlen(device_name);
++
++    while (current_dir = readdir(dir)) {
++        if (strlen(current_dir->d_name) >= len &&
++            strncmp(device_name, current_dir->d_name, len) == 0)
++            break;
++    }
++    closedir(dir);
++    if (!current_dir)
++        return 0;
++
++    return 1;
++}
++#endif                          /* defined(__arm__) && defined(__linux__) */
++
+ static void
+ listPossibleVideoDrivers(char *matches[], int nmatches)
+ {
+@@ -287,6 +314,21 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
+ #endif
+     }
++#if defined(__linux__) && defined(__arm__)
++    if (i < (nmatches - 1)) {
++        if (test_sysfs_device("mxc_gpu", "imx"))
++            matches[i++] = xnfstrdup("imx");
++        else if (test_sysfs_device("dovefb", "dovefb"))
++            matches[i++] = xnfstrdup("dovefb");
++        else if (test_sysfs_device("omapdrm", "omap"))
++            matches[i++] = xnfstrdup("omap");
++        else if (test_sysfs_device("omapfb", "omapfb"))
++            matches[i++] = xnfstrdup("omapfb");
++        else if (test_sysfs_device("omap", "pvr"))
++            matches[i++] = xnfstrdup("pvr");
++    }
++#endif                          /* defined(__linux__) && defined(__arm__) */
++
+ #if defined(__linux__)
+     matches[i++] = xnfstrdup("modesetting");
+ #endif
+diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
+index 24b9473..0061c25 100644
+--- a/hw/xfree86/common/xf86platformBus.c
++++ b/hw/xfree86/common/xf86platformBus.c
+@@ -362,6 +362,14 @@ xf86platformProbeDev(DriverPtr drvp)
+                     if (xf86IsPrimaryPlatform(&xf86_platform_devices[j]))
+                         break;
+                 }
++                else {
++                    /* there's no way to handle real platform devices at this point,
++                     * as there's no valid busID to be used, so try to move forward
++                     * in case there's only one platform device, and see if the
++                     * driver's probe succeeds or not at least once */
++                    if ((xf86_num_platform_devices == 1) && (!foundScreen))
++                        break;
++                }
+             }
+         }