libs: drm: find render node in hybrid system

Originally the drm backend only tried to open the first render node
found. But in hybrid system this first render node might not support
VA-API (propietary Nvidia driver, for example).

This patch tries all the available nodes until a finding one with a
VA-API supported driver.

https://bugzilla.gnome.org/show_bug.cgi?id=774811

Original-patch-by: Stirling Westrup <swestrup@gmail.com> and
                   Reza Razavi <reza@userful.com>
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-12-06 17:33:42 +01:00
parent ad8da84062
commit 7aeefb0990

View file

@ -58,6 +58,22 @@ typedef enum
static DRMDeviceType g_drm_device_type;
static GMutex g_drm_device_type_lock;
static gboolean
supports_vaapi (int fd)
{
gboolean ret;
VADisplay va_dpy;
int major, minor;
va_dpy = vaGetDisplayDRM (fd);
if (!va_dpy)
return FALSE;
ret = (vaInitialize (va_dpy, &major, &minor) == VA_STATUS_SUCCESS);
vaTerminate (va_dpy);
return ret;
}
/* Get default device path. Actually, the first match in the DRM subsystem */
static const gchar *
get_default_device_path (GstVaapiDisplay * display)
@ -109,9 +125,11 @@ get_default_device_path (GstVaapiDisplay * display)
continue;
}
if (supports_vaapi (fd))
priv->device_path_default = g_strdup (devpath);
close (fd);
udev_device_unref (device);
if (priv->device_path_default)
break;
}