diff options
author | Anton Kindestam <antonki@kth.se> | 2018-06-28 15:06:41 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-07-09 02:33:35 +0300 |
commit | 351c083487050c88adb0e3d60f2174850f869018 (patch) | |
tree | 79664f12e0815e590470d07873c724d42608ec1e /video/out/opengl/context_drm_egl.c | |
parent | 7beee68f8d8617557990a5f860d9d1f99c4ba009 (diff) | |
download | mpv-351c083487050c88adb0e3d60f2174850f869018.tar.bz2 mpv-351c083487050c88adb0e3d60f2174850f869018.tar.xz |
hwdec_vaegl: Fix VAAPI EGL interop used with gpu-context=drm
Add another parameter to mpv_opengl_drm_params to hold the FD to the
render node, so that the fd can be passed to hwdec_vaegl.
The render node is opened in context_drm_egl and inferred from the
primary device fd using drmGetRenderDeviceNameFromFd.
Diffstat (limited to 'video/out/opengl/context_drm_egl.c')
-rw-r--r-- | video/out/opengl/context_drm_egl.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c index 52774d8170..72eb2e3b98 100644 --- a/video/out/opengl/context_drm_egl.c +++ b/video/out/opengl/context_drm_egl.c @@ -513,6 +513,8 @@ static void drm_egl_uninit(struct ra_ctx *ctx) p->egl.context = EGL_NO_CONTEXT; eglDestroyContext(p->egl.display, p->egl.context); + close(p->drm_params.render_fd); + if (p->kms) { kms_destroy(p->kms); p->kms = 0; @@ -664,6 +666,20 @@ static bool drm_egl_init(struct ra_ctx *ctx) p->drm_params.connector_id = p->kms->connector->connector_id; if (p->kms->atomic_context) p->drm_params.atomic_request_ptr = &p->kms->atomic_context->request; + char *rendernode_path = drmGetRenderDeviceNameFromFd(p->kms->fd); + if (rendernode_path) { + MP_VERBOSE(ctx, "Opening render node \"%s\"\n", rendernode_path); + p->drm_params.render_fd = open(rendernode_path, O_RDWR | O_CLOEXEC); + if (p->drm_params.render_fd < 0) { + MP_WARN(ctx, "Cannot open render node \"%s\": %s. VAAPI hwdec will be disabled\n", + rendernode_path, mp_strerror(errno)); + } + free(rendernode_path); + } else { + p->drm_params.render_fd = -1; + MP_VERBOSE(ctx, "Could not find path to render node. VAAPI hwdec will be disabled\n"); + } + struct ra_gl_ctx_params params = { .swap_buffers = drm_egl_swap_buffers, .external_swapchain = p->kms->atomic_context ? &drm_atomic_swapchain : |