Skip to content

Commit b5932dd

Browse files
committed
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.
1 parent a9b09cc commit b5932dd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

video/out/opengl/hwdec_drmprime_drm.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ static void scale_dst_rect(struct ra_hwdec *hw, int source_w, int source_h ,stru
108108
dst->y1 += offset_y;
109109
}
110110

111+
static void disable_video_plane(struct ra_hwdec *hw)
112+
{
113+
struct priv *p = hw->priv;
114+
if (!p->ctx)
115+
return;
116+
117+
// Disabling video plane is needed on some devices when using the
118+
// primary plane for video. Primary buffer can't be active with no
119+
// framebuffer associated. So we need this function to commit it
120+
// right away as mpv will free all framebuffers on playback end.
121+
drmModeAtomicReqPtr request = drmModeAtomicAlloc();
122+
if (request) {
123+
drm_object_set_property(request, p->ctx->video_plane, "FB_ID", 0);
124+
drm_object_set_property(request, p->ctx->video_plane, "CRTC_ID", 0);
125+
126+
int ret = drmModeAtomicCommit(p->ctx->fd, request,
127+
DRM_MODE_ATOMIC_NONBLOCK, NULL);
128+
129+
if (ret)
130+
MP_ERR(hw, "Failed to commit disable plane request (code %d)", ret);
131+
drmModeAtomicFree(request);
132+
}
133+
}
134+
111135
static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
112136
struct mp_rect *src, struct mp_rect *dst, bool newframe)
113137
{
@@ -178,6 +202,8 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
178202
}
179203
}
180204
} else {
205+
disable_video_plane(hw);
206+
181207
while (p->old_frame.fb.fb_id)
182208
set_current_frame(hw, NULL);
183209
}
@@ -194,6 +220,7 @@ static void uninit(struct ra_hwdec *hw)
194220
{
195221
struct priv *p = hw->priv;
196222

223+
disable_video_plane(hw);
197224
set_current_frame(hw, NULL);
198225

199226
if (p->ctx) {
@@ -244,6 +271,7 @@ static int init(struct ra_hwdec *hw)
244271
goto err;
245272
}
246273

274+
disable_video_plane(hw);
247275
return 0;
248276

249277
err:

0 commit comments

Comments
 (0)