summaryrefslogtreecommitdiff
path: root/src/radeon_dri3.c
diff options
context:
space:
mode:
authorJammy Zhou <Jammy.Zhou@amd.com>2016-12-19 17:27:19 +0900
committerMichel Dänzer <michel.daenzer@amd.com>2016-12-19 17:27:19 +0900
commit720dd07e79b5f5cbbf3ef8bd92300578c485d583 (patch)
tree2275d985d3b5aa55f8582166240e14779db75cae /src/radeon_dri3.c
parent92fc387a6256ce3c95d62142735783ea07162c54 (diff)
Use render node for DRI3 if available
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> (ported from amdgpu commit ea558e645786b08d75307716036045170e97b43e) Reviewed-by: Alex Deucher <alexander.deucher@amd.com> [ Second attempt, let's see if there's any fallout this time... ]
Diffstat (limited to 'src/radeon_dri3.c')
-rw-r--r--src/radeon_dri3.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c
index c5670246..fa24abae 100644
--- a/src/radeon_dri3.c
+++ b/src/radeon_dri3.c
@@ -40,9 +40,7 @@
#include <errno.h>
#include <libgen.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);
@@ -87,6 +85,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;
+}
+
#if DRI3_SCREEN_INFO_VERSION >= 1 && XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(1,18,99,1,0)
static int
@@ -228,6 +256,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,