[Mesa-dev] [PATCH 1/6] gbm: Support non-PCI devices
Lucas Stach
l.stach at pengutronix.de
Wed Nov 6 08:22:51 PST 2013
From: Thierry Reding <thierry.reding at avionic-design.de>
When probing non-PCI DRM devices, such as those found in a lot of SoCs,
GBM errors out because it expects the device to have an associated PCI
ID which can be used to lookup the driver name in a table.
This patch removes this restriction by using the driver name from the
drmVersion structure as a fallback if a device doesn't have an
associated PCI ID.
Signed-off-by: Thierry Reding <thierry.reding at avionic-design.de>
Tested-by: Rob Clark <robclark at freedesktop.org>
---
src/gbm/backends/dri/driver_name.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/gbm/backends/dri/driver_name.c b/src/gbm/backends/dri/driver_name.c
index 2ed209fa438b..be74023d6c3a 100644
--- a/src/gbm/backends/dri/driver_name.c
+++ b/src/gbm/backends/dri/driver_name.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <libudev.h>
+#include <xf86drm.h>
#include "gbm_driint.h"
#define DRIVER_MAP_DRI2_ONLY
@@ -43,6 +44,7 @@ dri_fd_get_driver_name(int fd)
const char *pci_id;
char *driver = NULL;
int vendor_id, chip_id, i, j;
+ drmVersionPtr version;
udev = udev_new();
device = _gbm_udev_device_new_from_fd(udev, fd);
@@ -56,9 +58,22 @@ dri_fd_get_driver_name(int fd)
}
pci_id = udev_device_get_property_value(parent, "PCI_ID");
- if (pci_id == NULL ||
- sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
- fprintf(stderr, "gbm: malformed or no PCI ID");
+ if (pci_id == NULL) {
+ version = drmGetVersion(fd);
+ if (!version) {
+ fprintf(stderr, "gbm: cannot get DRM module version\n");
+ goto out;
+ }
+
+ driver = strndup(version->name, version->name_len);
+ _gbm_log("using driver %s for %d\n", driver, fd);
+
+ drmFreeVersion(version);
+ goto out;
+ }
+
+ if (sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
+ fprintf(stderr, "gbm: malformed PCI ID");
goto out;
}
--
1.8.4.rc3
More information about the mesa-dev
mailing list