[PATCH libdrm] Revert "Add device enumeration interface (v4)"

Emil Velikov emil.l.velikov at gmail.com
Sat May 30 08:30:54 PDT 2015


This reverts commit fde4969176822fe54197b6baa78f8b0ef900baba.

The commit adds an API that does not seem flexible enough to be used in
current open-source projects. Additionally it adds a hidden dependency
of libudev, which when used in mesa caused grief when combined with
Steam('s runtime).

Let's revert this for now and add a tweaked API later on that can be
used in mesa/xserver.

Cc: Frank Min <frank.min at amd.com>
Cc: Christian König <christian.koenig at amd.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: Jammy Zhou <Jammy.Zhou at amd.com>
---
 Makefile.am |   7 ++---
 xf86drm.c   | 100 ------------------------------------------------------------
 xf86drm.h   |  19 ------------
 3 files changed, 2 insertions(+), 124 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index ffd334a..13df80c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -95,15 +95,12 @@ SUBDIRS = \
 libdrm_la_LTLIBRARIES = libdrm.la
 libdrm_ladir = $(libdir)
 libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
-libdrm_la_LIBADD = \
-		@CLOCK_LIB@ \
-		@LIBUDEV_LIBS@
+libdrm_la_LIBADD = @CLOCK_LIB@
 
 libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
-	$(VALGRIND_CFLAGS) \
-	$(LIBUDEV_CFLAGS)
+	$(VALGRIND_CFLAGS)
 
 libdrm_la_SOURCES = $(LIBDRM_FILES)
 
diff --git a/xf86drm.c b/xf86drm.c
index 49da9c7..2c17d11 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -63,7 +63,6 @@
 
 #include "xf86drm.h"
 #include "libdrm_macros.h"
-#include "libudev.h"
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 #define DRM_MAJOR 145
@@ -2816,102 +2815,3 @@ char *drmGetRenderDeviceNameFromFd(int fd)
 {
 	return drmGetMinorNameForFD(fd, DRM_NODE_RENDER);
 }
-
-/**
-* Enumerate the GPU devices on the system
-*
-* \param devs device array set to return the device information
-* (if NULL, the number of device is returned)
-* \param vendor the vendor ID for GPU devices to list
-* (optional, if not specified, all GPU devices are returned)
-*
-* \return the number of GPU devices
-*/
-int drmGetPciDevices(drmPciDevicePtr devSet, uint16_t vendorId)
-{
-	struct udev *udev = NULL;
-	struct udev_enumerate *udev_enumerate;
-	struct udev_list_entry *list_entry;
-	struct udev_device *device;
-	int drmDevCount = 0;
-	int vendor = 0;
-	int devid = 0;
-	int subvendor = 0;
-	int subdevid = 0;
-	int revid = 0xff;
-	int domain = 0;
-	int bus = 0;
-	int dev = 0;
-	int func = 0;
-	char config[64] = {0};
-	char node[128] = {'\0'};
-	char slot[] = "0000:00:00.0";
-	const char *info = NULL;
-	int fd = 0;
-	int ret = 0;
-
-	udev = udev_new();
-	if (udev == NULL) {
-		fprintf(stderr, "no context\n");
-		return -EINVAL;
-	}
-	udev_enumerate = udev_enumerate_new(udev);
-	if (udev_enumerate == NULL)
-		return -EINVAL;
-	udev_enumerate_add_match_subsystem(udev_enumerate, "drm");
-	udev_enumerate_add_match_property(udev_enumerate, "DEVTYPE", "drm_minor");
-
-	udev_enumerate_scan_devices(udev_enumerate);
-
-	udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(udev_enumerate)) {
-		device = udev_device_new_from_syspath(udev_enumerate_get_udev(udev_enumerate),
-						      udev_list_entry_get_name(list_entry));
-		if (device != NULL) {
-			info = udev_device_get_property_value(device, "MINOR");
-			if (!strcmp(info, "0")) {
-			strcpy(node, udev_device_get_syspath(device));
-			info = strstr(node, "/drm");
-			strncpy(slot, info - strlen(slot), strlen(slot));
-			if (sscanf(slot, "%4x:%2x:%2x.%1x", &domain, &bus, &dev, &func) != 4) {
-				domain = 0;
-				bus = 0;
-				dev = 0;
-				func = 0;
-			}
-			strcpy(node + strlen(node), "/device/config");
-
-			fd = open(node, O_RDONLY);
-			if (fd >= 0) {
-				ret = read(fd, config, 64);
-				if (ret == 64) {
-					vendor = config[0] + (config[1] << 8);
-					devid = config[2] + (config[3] << 8);
-					revid = config[8];
-					subdevid = config[44] + (config[45] << 8);
-				}
-				close(fd);
-			}
-
-			if((vendorId == 0) || (vendorId == vendor)) {
-				if(devSet != NULL) {
-					devSet[drmDevCount].domain = domain;
-					devSet[drmDevCount].bus = bus;
-					devSet[drmDevCount].dev = dev;
-					devSet[drmDevCount].func = func;
-					devSet[drmDevCount].vendor_id = vendor;
-					devSet[drmDevCount].device_id = devid;
-					devSet[drmDevCount].subdevice_id = subdevid;
-					devSet[drmDevCount].subvendor_id = subvendor;
-					devSet[drmDevCount].revision_id = revid;
-				}
-				drmDevCount++;
-			}
-		}
-		}
-		udev_device_unref(device);
-	}
-	udev_enumerate_unref(udev_enumerate);
-	udev_unref(udev);
-
-	return drmDevCount;
-}
diff --git a/xf86drm.h b/xf86drm.h
index 2610934..40c55c9 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -342,24 +342,6 @@ typedef struct _drmSetVersion {
 	int drm_dd_minor;
 } drmSetVersion, *drmSetVersionPtr;
 
-/**
- * Structure to a general pci gpu device
- *
- * \sa drmGetDevices()
- *
-*/
-typedef struct _drmPciDevice {
-		uint16_t domain;
-		uint8_t bus;
-		uint8_t dev;
-		uint8_t func;
-		uint16_t vendor_id;
-		uint16_t device_id;
-		uint16_t subvendor_id;
-		uint16_t subdevice_id;
-		uint8_t revision_id;
-} drmPciDevice, *drmPciDevicePtr;
-
 #define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
 
 #define DRM_LOCK_HELD  0x80000000U /**< Hardware lock is held */
@@ -570,7 +552,6 @@ do {	register unsigned int __old __asm("o0");		\
 /* General user-level programmer's API: unprivileged */
 extern int           drmAvailable(void);
 extern int           drmOpen(const char *name, const char *busid);
-extern int           drmGetPciDevices(drmPciDevicePtr devSet, uint16_t vendorId);
 
 #define DRM_NODE_PRIMARY 0
 #define DRM_NODE_CONTROL 1
-- 
2.3.5



More information about the dri-devel mailing list