[vlc-commits] gl: vaapi: add DRM support
Thomas Guillem
git at videolan.org
Wed Jul 5 11:10:53 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jun 29 16:47:40 2017 +0200| [14ba7d2d7e96892bebff9f7b90cccbe4c7fa37b4] | committer: Thomas Guillem
gl: vaapi: add DRM support
Favor DRM and use X11/WAYLAND if it's not available.
Fixes #18445
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=14ba7d2d7e96892bebff9f7b90cccbe4c7fa37b4
---
modules/video_output/Makefile.am | 4 +++
modules/video_output/opengl/converter_vaapi.c | 35 +++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index e7cf70ab66..5b5efcfe1f 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -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
diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index 7c8129a48b..96d8f969c4 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -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
More information about the vlc-commits
mailing list