summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLongChair <longchair@hotmail.com>2018-04-08 09:03:20 +0200
committerJan Ekström <jeebjp@gmail.com>2018-05-01 20:48:02 +0300
commitba3d90d9edbb379d23591da5b63c25be41664924 (patch)
treeb19e8e3252cecb729398fd5e6664e487ba94c04d
parent1ccc56eff0242123ba448638f4cc534fb69e3024 (diff)
downloadmpv-ba3d90d9edbb379d23591da5b63c25be41664924.tar.bz2
mpv-ba3d90d9edbb379d23591da5b63c25be41664924.tar.xz
drm/atomic: disable video plane when unused.
This patch will make sure that the video plane is hidden when unused. When using high resolution modes, typically UHD, and embedding mpv, having the video plane sitting in the back when you don't play any video is eating a lot of memory bandwidth for compositing. That patch makes sure that the video layer is just disabled before and after playback.
-rw-r--r--video/out/opengl/hwdec_drmprime_drm.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/video/out/opengl/hwdec_drmprime_drm.c b/video/out/opengl/hwdec_drmprime_drm.c
index 2e1859f6bb..24753067d6 100644
--- a/video/out/opengl/hwdec_drmprime_drm.c
+++ b/video/out/opengl/hwdec_drmprime_drm.c
@@ -108,6 +108,30 @@ static void scale_dst_rect(struct ra_hwdec *hw, int source_w, int source_h ,stru
dst->y1 += offset_y;
}
+static void disable_video_plane(struct ra_hwdec *hw)
+{
+ struct priv *p = hw->priv;
+ if (!p->ctx)
+ return;
+
+ // Disabling video plane is needed on some devices when using the
+ // primary plane for video. Primary buffer can't be active with no
+ // framebuffer associated. So we need this function to commit it
+ // right away as mpv will free all framebuffers on playback end.
+ drmModeAtomicReqPtr request = drmModeAtomicAlloc();
+ if (request) {
+ drm_object_set_property(request, p->ctx->video_plane, "FB_ID", 0);
+ drm_object_set_property(request, p->ctx->video_plane, "CRTC_ID", 0);
+
+ int ret = drmModeAtomicCommit(p->ctx->fd, request,
+ DRM_MODE_ATOMIC_NONBLOCK, NULL);
+
+ if (ret)
+ MP_ERR(hw, "Failed to commit disable plane request (code %d)", ret);
+ drmModeAtomicFree(request);
+ }
+}
+
static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
struct mp_rect *src, struct mp_rect *dst, bool newframe)
{
@@ -183,6 +207,8 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
}
}
} else {
+ disable_video_plane(hw);
+
while (p->old_frame.fb.fb_id)
set_current_frame(hw, NULL);
}
@@ -199,6 +225,7 @@ static void uninit(struct ra_hwdec *hw)
{
struct priv *p = hw->priv;
+ disable_video_plane(hw);
set_current_frame(hw, NULL);
if (p->ctx) {
@@ -249,6 +276,7 @@ static int init(struct ra_hwdec *hw)
goto err;
}
+ disable_video_plane(hw);
return 0;
err: