From 0856fd1b79d50ef521e346ee49353362f397c5ac Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 25 Jul 2013 11:44:37 +1000 Subject: [PATCH] gallium/vl: add prime support This will go and fetch the correct path to open from the X server at least. libvdpau also needs a simiiar fix. Signed-off-by: Dave Airlie --- src/gallium/auxiliary/vl/vl_winsys_dri.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c index 88e17fe..7aec3fe 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -32,8 +32,10 @@ #include #include +#include #include #include +#include #include "pipe/p_screen.h" #include "pipe/p_context.h" @@ -305,6 +307,7 @@ vl_screen_create(Display *display, int screen) xcb_generic_error_t *error = NULL; char *device_name; int fd, device_name_length; + unsigned int driverType; drm_magic_t magic; @@ -332,7 +335,22 @@ vl_screen_create(Display *display, int screen) s = xcb_setup_roots_iterator(xcb_get_setup(scrn->conn)); while (screen--) xcb_screen_next(&s); - connect_cookie = xcb_dri2_connect_unchecked(scrn->conn, s.data->root, XCB_DRI2_DRIVER_TYPE_DRI); + driverType = XCB_DRI2_DRIVER_TYPE_DRI; +#ifdef DRI2DriverPrimeShift + { + char *prime = getenv("DRI_PRIME"); + if (prime) { + unsigned int primeid; + errno = 0; + primeid = strtoul(prime, NULL, 0); + if (errno == 0) + driverType |= + ((primeid & DRI2DriverPrimeMask) << DRI2DriverPrimeShift); + } + } +#endif + + connect_cookie = xcb_dri2_connect_unchecked(scrn->conn, s.data->root, driverType); connect = xcb_dri2_connect_reply(scrn->conn, connect_cookie, NULL); if (connect == NULL || connect->driver_name_length + connect->device_name_length == 0) goto free_screen; -- 1.8.3.1