diff options
author | Jonas Karlman <jonas@kwiboo.se> | 2019-01-24 22:11:10 +0100 |
---|---|---|
committer | wm4 <1387750+wm4@users.noreply.github.com> | 2019-09-27 13:08:27 +0200 |
commit | 16d2ddb5050ef56825875476a9a0b545f2462eee (patch) | |
tree | 1419a0c1adc2a2239b285791f5d7d09ea680b9f9 /video/out/opengl/hwdec_drmprime_drm.c | |
parent | c3687b9eaaaddf8dae075e903fd464b503229d07 (diff) | |
download | mpv-16d2ddb5050ef56825875476a9a0b545f2462eee.tar.bz2 mpv-16d2ddb5050ef56825875476a9a0b545f2462eee.tar.xz |
vo_gpu: hwdec_drmprime_drm: add hwdec ctx
This allows to use drm hwaccels that require a hwdevice.
Tested with v4l2request hwaccel and cedrus driver on an allwinner device
running mpv with --vo=gpu --gpu-context=drm --hwdec=drm.
Diffstat (limited to 'video/out/opengl/hwdec_drmprime_drm.c')
-rw-r--r-- | video/out/opengl/hwdec_drmprime_drm.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/video/out/opengl/hwdec_drmprime_drm.c b/video/out/opengl/hwdec_drmprime_drm.c index 7328fbb284..bc9f548019 100644 --- a/video/out/opengl/hwdec_drmprime_drm.c +++ b/video/out/opengl/hwdec_drmprime_drm.c @@ -23,6 +23,7 @@ #include <math.h> #include <stdbool.h> +#include <libavutil/hwcontext.h> #include <libavutil/hwcontext_drm.h> #include "common.h" @@ -44,6 +45,7 @@ struct drm_frame { struct priv { struct mp_log *log; + struct mp_hwdec_ctx hwctx; struct mp_image_params params; @@ -231,6 +233,9 @@ static void uninit(struct ra_hwdec *hw) disable_video_plane(hw); set_current_frame(hw, NULL); + hwdec_devices_remove(hw->devs, &p->hwctx); + av_buffer_unref(&p->hwctx.av_device_ref); + if (p->ctx) { drm_atomic_destroy_context(p->ctx); p->ctx = NULL; @@ -284,6 +289,15 @@ static int init(struct ra_hwdec *hw) } disable_video_plane(hw); + + p->hwctx = (struct mp_hwdec_ctx) { + .driver_name = hw->driver->name, + }; + if (!av_hwdevice_ctx_create(&p->hwctx.av_device_ref, AV_HWDEVICE_TYPE_DRM, + drmGetDeviceNameFromFd2(p->ctx->fd), NULL, 0)) { + hwdec_devices_add(hw->devs, &p->hwctx); + } + return 0; err: |