xf86-video-intel: 3 commits - src/intel_device.c tools/dri3info.c tools/Makefile.am

Chris Wilson ickle at kemper.freedesktop.org
Tue Feb 10 04:24:38 PST 2015


 src/intel_device.c |   12 +++++++++++-
 tools/Makefile.am  |    3 ++-
 tools/dri3info.c   |   38 +++++++++++++++++++++++++++++++-------
 3 files changed, 44 insertions(+), 9 deletions(-)

New commits:
commit d50eb8d57a3ecb4577b9e556d9e38bf80b408f77
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 10 12:22:59 2015 +0000

    intel: Fix checking for compatible render node
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_device.c b/src/intel_device.c
index 140e153..c835a5d 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -464,6 +464,7 @@ static char *find_render_node(int fd)
 #if defined(USE_RENDERNODE)
 	struct stat master, render;
 	char buf[128];
+	int i;
 
 	/* Are we a render-node ourselves? */
 	if (is_render_node(fd, &master))
@@ -472,8 +473,17 @@ static char *find_render_node(int fd)
 	sprintf(buf, "/dev/dri/renderD%d", (int)((master.st_rdev | 0x80) & 0xbf));
 	if (stat(buf, &render) == 0 &&
 	    master.st_mode == render.st_mode &&
-	    render.st_rdev == ((master.st_rdev | 0x80) & 0xbf))
+	    render.st_rdev == (master.st_rdev | 0x80))
 		return strdup(buf);
+
+	/* Misaligned card <-> renderD, do a full search */
+	for (i = 0; i < 16; i++) {
+		sprintf(buf, "/dev/dri/renderD%d", i + 128);
+		if (stat(buf, &render) == 0 &&
+		    master.st_mode == render.st_mode &&
+		    render.st_rdev == (master.st_rdev | 0x80))
+			return strdup(buf);
+	}
 #endif
 
 	return NULL;
commit 88db217705f6b59f75524a47a3e720d9ef0d37b3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 10 12:12:48 2015 +0000

    tools/dri3info: Match fd against render nodes
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/tools/dri3info.c b/tools/dri3info.c
index ca4e348..6587411 100644
--- a/tools/dri3info.c
+++ b/tools/dri3info.c
@@ -60,7 +60,7 @@ static void get_device_path(int fd, char *buf, int len)
 	if (fstat(fd, &remote))
 		goto out;
 
-	for (i = 0; i < 64; i++) {
+	for (i = 0; i < 16; i++) {
 		snprintf(buf, len, "/dev/dri/card%d", i);
 		if (stat(buf, &local))
 			continue;
@@ -68,10 +68,18 @@ static void get_device_path(int fd, char *buf, int len)
 		if (local.st_mode == remote.st_mode &&
 		    local.st_rdev == remote.st_rdev)
 			return;
+
+		snprintf(buf, len, "/dev/dri/renderD%d", i + 128);
+		if (stat(buf, &local))
+			continue;
+
+		if (local.st_mode == remote.st_mode &&
+		    local.st_rdev == remote.st_rdev)
+			return;
 	}
 
 out:
-	strncpy(buf, "unknown card", len);
+	strncpy(buf, "unknown path", len);
 }
 
 static void get_driver_name(int fd, char *name, int len)
commit 27ededdfc7a7727288f187aeebb06f6d118fd1c7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 10 12:10:56 2015 +0000

    tools/dri3info: Query the kernel driver name
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/tools/Makefile.am b/tools/Makefile.am
index 432ec2c..6c992f8 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -34,7 +34,8 @@ endif
 if X11_DRI3
 noinst_PROGRAMS = dri3info
 dri3info_SOURCES = dri3info.c
-dri3info_LDADD = $(X11_DRI3_LIBS)
+dri3info_CFLAGS = $(X11_DRI3_CFLAGS) $(DRI_CFLAGS)
+dri3info_LDADD = $(X11_DRI3_LIBS) $(DRI_LIBS)
 endif
 
 if BUILD_BACKLIGHT_HELPER
diff --git a/tools/dri3info.c b/tools/dri3info.c
index 0dcb495..ca4e348 100644
--- a/tools/dri3info.c
+++ b/tools/dri3info.c
@@ -31,6 +31,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <drm.h>
+#include <xf86drm.h>
 
 static int dri3_open(Display *dpy)
 {
@@ -50,7 +52,7 @@ static int dri3_open(Display *dpy)
 	return xcb_dri3_open_reply_fds(c, reply)[0];
 }
 
-static void match_device(int fd, char *buf, int len)
+static void get_device_path(int fd, char *buf, int len)
 {
 	struct stat remote, local;
 	int i;
@@ -72,11 +74,24 @@ out:
 	strncpy(buf, "unknown card", len);
 }
 
+static void get_driver_name(int fd, char *name, int len)
+{
+	drm_version_t version;
+
+	memset(name, 0, len);
+	memset(&version, 0, sizeof(version));
+	version.name_len = len;
+	version.name = name;
+
+	(void)drmIoctl(fd, DRM_IOCTL_VERSION, &version);
+}
+
 static void info(const char *dpyname)
 {
 	Display *dpy;
 	int device;
-	char device_name[1024];
+	char device_path[1024];
+	char driver_name[1024];
 
 	dpy = XOpenDisplay(dpyname);
 	if (dpy == NULL) {
@@ -92,10 +107,11 @@ static void info(const char *dpyname)
 		return;
 	}
 
-	match_device(device, device_name, sizeof(device_name));
+	get_device_path(device, device_path, sizeof(device_path));
+	get_driver_name(device, driver_name, sizeof(driver_name));
 
-	printf("Connected to DRI3 on display '%s', using fd %d: matches %s\n",
-	       DisplayString(dpy), device, device_name);
+	printf("Connected to DRI3 on display '%s', using fd %d: matches %s, driver %s\n",
+	       DisplayString(dpy), device, device_path, driver_name);
 
 	XCloseDisplay(dpy);
 	close(device);


More information about the xorg-commit mailing list