[PATCH xf86-video-intel] intel: Add support for server managed fds

Hans de Goede hdegoede at redhat.com
Wed Jan 15 06:34:53 PST 2014


Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/intel_device.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/intel_device.c b/src/intel_device.c
index 4d08a6e..4378e66 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -42,6 +42,7 @@
 #include <pciaccess.h>
 
 #include <xorg-server.h>
+#include <xorgVersion.h>
 #include <xf86.h>
 #include <xf86drm.h>
 #include <xf86drmMode.h>
@@ -273,19 +274,15 @@ static char *get_path(struct xf86_platform_device *dev)
 #endif
 
 
-#if defined(ODEV_ATTRIB_FD) && 0
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,0,0)
 static int get_fd(struct xf86_platform_device *dev)
 {
-	const char *str;
+	int fd = dev->attribs->fd;
 
-	if (dev == NULL)
-		return -1;
-
-	str = xf86_get_platform_device_attrib(dev, ODEV_ATTRIB_FD);
-	if (str == NULL)
-		return -1;
+	fd = fd_set_nonblock(fd);
+	fd = fd_set_cloexec(fd);
 
-	return atoi(str);
+	return fd;
 }
 
 #else
@@ -303,7 +300,7 @@ int intel_open_device(int entity_num,
 {
 	struct intel_device *dev;
 	char *local_path;
-	int fd;
+	int fd, init_master_count = 0;
 
 	if (intel_device_key == -1)
 		intel_device_key = xf86AllocateEntityPrivateIndex();
@@ -319,6 +316,8 @@ int intel_open_device(int entity_num,
 	fd = get_fd(platform);
 	if (fd == -1)
 		fd = __intel_open_device(pci, &local_path);
+	else
+		init_master_count = 1; /* Server fd is already master */
 	if (fd == -1)
 		goto err_path;
 
@@ -331,7 +330,7 @@ int intel_open_device(int entity_num,
 
 	dev->fd = fd;
 	dev->open_count = 0;
-	dev->master_count = 0;
+	dev->master_count = init_master_count;
 	dev->master_node = local_path;
 	dev->render_node = find_render_node(fd);
 	if (dev->render_node == NULL)
-- 
1.8.4.2



More information about the xorg-devel mailing list