Skip to content

Commit

Permalink
drm/atomic: disable video plane when unused.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LongChair committed Apr 7, 2018
1 parent 7da3551 commit cda4db6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions video/out/opengl/hwdec_drmprime_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,28 @@ 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;

// 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)
{
Expand Down Expand Up @@ -178,6 +200,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);
}
Expand All @@ -194,6 +218,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) {
Expand Down Expand Up @@ -244,6 +269,7 @@ static int init(struct ra_hwdec *hw)
goto err;
}

disable_video_plane(hw);
return 0;

err:
Expand Down

0 comments on commit cda4db6

Please sign in to comment.