Skip to content

Commit cda4db6

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 7da3551 commit cda4db6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

video/out/opengl/hwdec_drmprime_drm.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,28 @@ 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+
115+
// Disabling video plane is needed on some devices when using the
116+
// primary plane for video. Primary buffer can't be active with no
117+
// framebuffer associated. So we need this function to commit it
118+
// right away as mpv will free all framebuffers on playback end.
119+
drmModeAtomicReqPtr request = drmModeAtomicAlloc();
120+
if (request) {
121+
drm_object_set_property(request, p->ctx->video_plane, "FB_ID", 0);
122+
drm_object_set_property(request, p->ctx->video_plane, "CRTC_ID", 0);
123+
124+
int ret = drmModeAtomicCommit(p->ctx->fd, request,
125+
DRM_MODE_ATOMIC_NONBLOCK, NULL);
126+
127+
if (ret)
128+
MP_ERR(hw, "Failed to commit disable plane request (code %d)", ret);
129+
drmModeAtomicFree(request);
130+
}
131+
}
132+
111133
static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
112134
struct mp_rect *src, struct mp_rect *dst, bool newframe)
113135
{
@@ -178,6 +200,8 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
178200
}
179201
}
180202
} else {
203+
disable_video_plane(hw);
204+
181205
while (p->old_frame.fb.fb_id)
182206
set_current_frame(hw, NULL);
183207
}
@@ -194,6 +218,7 @@ static void uninit(struct ra_hwdec *hw)
194218
{
195219
struct priv *p = hw->priv;
196220

221+
disable_video_plane(hw);
197222
set_current_frame(hw, NULL);
198223

199224
if (p->ctx) {
@@ -244,6 +269,7 @@ static int init(struct ra_hwdec *hw)
244269
goto err;
245270
}
246271

272+
disable_video_plane(hw);
247273
return 0;
248274

249275
err:

0 commit comments

Comments
 (0)