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