[PATCH xf86-video-ati 1/6] Use render node for DRI3 if available

Michel Dänzer michel at daenzer.net
Tue Feb 16 08:29:04 UTC 2016


From: Jammy Zhou <Jammy.Zhou at amd.com>

Signed-off-by: Jammy Zhou <Jammy.Zhou at amd.com>
(ported from amdgpu commit ea558e645786b08d75307716036045170e97b43e)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 configure.ac       |  2 +-
 src/radeon_dri3.c  | 37 ++++++++++++++++++++++++++++++++++---
 src/radeon_probe.h |  1 +
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0a95420..f2bf57c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,7 +71,7 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto)
 XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
 
 # Checks for libraries.
-PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.58])
+PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.60])
 PKG_CHECK_MODULES(LIBDRM_RADEON, [libdrm_radeon])
 
 # Obtain compiler/linker options for the driver dependencies
diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c
index 1415a0d..de97f39 100644
--- a/src/radeon_dri3.c
+++ b/src/radeon_dri3.c
@@ -39,9 +39,7 @@
 #include <fcntl.h>
 #include <errno.h>
 
-
-static int
-radeon_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out)
+static int open_master_node(ScreenPtr screen, int *out)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	RADEONInfoPtr info = RADEONPTR(scrn);
@@ -86,6 +84,36 @@ radeon_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out)
 	return Success;
 }
 
+static int open_render_node(ScreenPtr screen, int *out)
+{
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
+	int fd;
+
+	fd = open(pRADEONEnt->render_node, O_RDWR | O_CLOEXEC);
+	if (fd < 0)
+		return BadAlloc;
+
+	*out = fd;
+	return Success;
+}
+
+static int
+radeon_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out)
+{
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
+	int ret = BadAlloc;
+
+	if (pRADEONEnt->render_node)
+		ret = open_render_node(screen, out);
+
+	if (ret != Success)
+		ret = open_master_node(screen, out);
+
+	return ret;
+}
+
 static PixmapPtr radeon_dri3_pixmap_from_fd(ScreenPtr screen,
 					    int fd,
 					    CARD16 width,
@@ -190,6 +218,9 @@ Bool
 radeon_dri3_screen_init(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
+
+	pRADEONEnt->render_node = drmGetRenderDeviceNameFromFd(pRADEONEnt->fd);
 
 	if (!dri3_screen_init(screen, &radeon_dri3_screen_info)) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
diff --git a/src/radeon_probe.h b/src/radeon_probe.h
index 258c7be..36e2ff6 100644
--- a/src/radeon_probe.h
+++ b/src/radeon_probe.h
@@ -142,6 +142,7 @@ typedef struct
 #ifdef XSERVER_PLATFORM_BUS
     struct xf86_platform_device *platform_dev;
 #endif
+    char *render_node;
 } RADEONEntRec, *RADEONEntPtr;
 
 extern const OptionInfoRec *RADEONOptionsWeak(void);
-- 
2.7.0



More information about the xorg-driver-ati mailing list