Skip to content
Snippets Groups Projects
Commit 14ba7d2d authored by Thomas Guillem's avatar Thomas Guillem
Browse files

gl: vaapi: add DRM support

Favor DRM and use X11/WAYLAND if it's not available.

Fixes #18445
parent 040316e9
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,10 @@ OPENGL_COMMONLIBS += $(LIBVA_X11_LIBS) $(X_LIBS) $(X_PRE_LIBS) -lX11
OPENGL_COMMONCFLAGS += -DHAVE_VA_X11
endif
endif
if HAVE_VAAPI_DRM
OPENGL_COMMONLIBS += $(LIBVA_DRM_LIBS)
OPENGL_COMMONCFLAGS += -DHAVE_VA_DRM
endif
endif
endif
......
......@@ -41,6 +41,12 @@
# include <vlc_xlib.h>
#endif
#ifdef HAVE_VA_DRM
# include <va/va_drm.h>
# include <vlc_fs.h>
# include <fcntl.h>
#endif
#if defined(USE_OPENGL_ES2)
# include <GLES2/gl2ext.h>
#endif
......@@ -354,6 +360,13 @@ x11_native_destroy_cb(VANativeDisplay native)
XCloseDisplay(native);
}
#endif
#ifdef HAVE_VA_DRM
static void
drm_native_destroy_cb(VANativeDisplay native)
{
vlc_close((intptr_t) native);
}
#endif
int
opengl_tex_converter_vaapi_init(opengl_tex_converter_t *tc)
......@@ -370,6 +383,28 @@ opengl_tex_converter_vaapi_init(opengl_tex_converter_t *tc)
if (eglexts == NULL || !HasExtension(eglexts, "EGL_EXT_image_dma_buf_import"))
return VLC_EGENERIC;
#ifdef HAVE_VA_DRM
static const char const *drm_device_paths[] = {
"/dev/dri/renderD128",
"/dev/dri/card0"
};
for (int i = 0; ARRAY_SIZE(drm_device_paths); i++)
{
int drm_fd = vlc_open(drm_device_paths[i], O_RDWR);
if (drm_fd == -1)
continue;
VADisplay dpy = vaGetDisplayDRM(drm_fd);
if (dpy)
return tc_vaegl_init(tc, dpy, (VANativeDisplay) (intptr_t) drm_fd,
drm_native_destroy_cb);
vlc_close(drm_fd);
}
/* Fallback to X11 or WAYLAND */
#endif
switch (tc->gl->surface->type)
{
#ifdef HAVE_VA_X11
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment