Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / 111_armel-drv-fallbacks.patch
1 diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
2 index 55412b4..d4a95d2 100644
3 --- a/hw/xfree86/common/xf86AutoConfig.c
4 +++ b/hw/xfree86/common/xf86AutoConfig.c
5 @@ -45,6 +45,12 @@
6 #include "xf86sbusBus.h"
7 #endif
8
9 +#if defined(__arm__) && defined(__linux__)
10 +#include "loaderProcs.h"
11 +#include <sys/types.h> /* For opendir in test_sysfs_device */
12 +#include <dirent.h> /* For opendir in test_sysfs_device */
13 +#endif
14 +
15 #ifdef sun
16 #include <sys/visual_io.h>
17 #include <ctype.h>
18 @@ -200,6 +206,27 @@ xf86AutoConfig(void)
19 return ret == CONFIG_OK;
20 }
21
22 +#if defined(__arm__) && defined(__linux__)
23 +static int
24 +test_sysfs_device(char *device_name, char *driver_name)
25 +{
26 + DIR *dir = opendir("/sys/devices/platform");
27 + struct dirent *current_dir;
28 + int len = strlen(device_name);
29 +
30 + while (current_dir = readdir(dir)) {
31 + if (strlen(current_dir->d_name) >= len &&
32 + strncmp(device_name, current_dir->d_name, len) == 0)
33 + break;
34 + }
35 + closedir(dir);
36 + if (!current_dir)
37 + return 0;
38 +
39 + return 1;
40 +}
41 +#endif /* defined(__arm__) && defined(__linux__) */
42 +
43 static void
44 listPossibleVideoDrivers(char *matches[], int nmatches)
45 {
46 @@ -287,6 +314,21 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
47 #endif
48 }
49
50 +#if defined(__linux__) && defined(__arm__)
51 + if (i < (nmatches - 1)) {
52 + if (test_sysfs_device("mxc_gpu", "imx"))
53 + matches[i++] = xnfstrdup("imx");
54 + else if (test_sysfs_device("dovefb", "dovefb"))
55 + matches[i++] = xnfstrdup("dovefb");
56 + else if (test_sysfs_device("omapdrm", "omap"))
57 + matches[i++] = xnfstrdup("omap");
58 + else if (test_sysfs_device("omapfb", "omapfb"))
59 + matches[i++] = xnfstrdup("omapfb");
60 + else if (test_sysfs_device("omap", "pvr"))
61 + matches[i++] = xnfstrdup("pvr");
62 + }
63 +#endif /* defined(__linux__) && defined(__arm__) */
64 +
65 #if defined(__linux__)
66 matches[i++] = xnfstrdup("modesetting");
67 #endif
68 diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
69 index 24b9473..0061c25 100644
70 --- a/hw/xfree86/common/xf86platformBus.c
71 +++ b/hw/xfree86/common/xf86platformBus.c
72 @@ -362,6 +362,14 @@ xf86platformProbeDev(DriverPtr drvp)
73 if (xf86IsPrimaryPlatform(&xf86_platform_devices[j]))
74 break;
75 }
76 + else {
77 + /* there's no way to handle real platform devices at this point,
78 + * as there's no valid busID to be used, so try to move forward
79 + * in case there's only one platform device, and see if the
80 + * driver's probe succeeds or not at least once */
81 + if ((xf86_num_platform_devices == 1) && (!foundScreen))
82 + break;
83 + }
84 }
85 }
86