From 810acf32d6cf0dfbad66c602689ef1218fc0a6e3 Mon Sep 17 00:00:00 2001 From: Anton Kindestam Date: Sun, 1 Jul 2018 09:12:52 +0200 Subject: drm_atomic: Allow to create atomic context w/o drmprime video plane This is to improve the experience when running with default settings on a driver that doesn't have any overlay planes (or indeed only one plane), but still supports DRM atomic. Since the drmprime video plane is set to pick an overlay plane by default it would fail on these drivers due to not being able to create any atomic context. Users with such cards had to specify --drm-video-plane-id manually to some bogus value (it's not used after all). The "video" plane is only ever used by the drmprime-drm hwdec interop, which is not used at all in the typical usecase where everything is actually rendered on to the "OSD" plane using EGL, so having an atomic context without the "video" plane should be fine most of the time. --- video/out/drm_atomic.c | 13 +++++++------ video/out/opengl/hwdec_drmprime_drm.c | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'video/out') diff --git a/video/out/drm_atomic.c b/video/out/drm_atomic.c index 5c6b3bbe21..f530d91b66 100644 --- a/video/out/drm_atomic.c +++ b/video/out/drm_atomic.c @@ -263,21 +263,16 @@ struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, mp_verbose(log, "Using default plane %d for video\n", overlay_id); ctx->video_plane = drm_object_create(log, ctx->fd, overlay_id, DRM_MODE_OBJECT_PLANE); } else { - mp_err(log, "Failed to find video plane with id=%d\n", video_plane_id); - goto fail; + mp_verbose(log, "Failed to find video plane with id=%d. drmprime-drm hwdec interop will not work\n", video_plane_id); } } else { mp_verbose(log, "Found video plane with ID %d\n", ctx->video_plane->id); } - mp_verbose(log, "Found Video plane with ID %d, OSD with ID %d\n", - ctx->video_plane->id, ctx->osd_plane->id); - drmModeFreePlaneResources(plane_res); drmModeFreeResources(res); return ctx; - fail: if (res) drmModeFreeResources(res); @@ -301,6 +296,9 @@ void drm_atomic_destroy_context(struct drm_atomic_context *ctx) static bool drm_atomic_save_plane_state(struct drm_object *plane, struct drm_atomic_plane_state *plane_state) { + if (!plane) + return true; + bool ret = true; if (0 > drm_object_get_property(plane, "FB_ID", &plane_state->fb_id)) @@ -333,6 +331,9 @@ static bool drm_atomic_restore_plane_state(drmModeAtomicReq *request, struct drm_object *plane, const struct drm_atomic_plane_state *plane_state) { + if (!plane) + return true; + bool ret = true; if (0 > drm_object_set_property(request, plane, "FB_ID", plane_state->fb_id)) diff --git a/video/out/opengl/hwdec_drmprime_drm.c b/video/out/opengl/hwdec_drmprime_drm.c index 5e09c5a215..d4543b0f47 100644 --- a/video/out/opengl/hwdec_drmprime_drm.c +++ b/video/out/opengl/hwdec_drmprime_drm.c @@ -257,6 +257,10 @@ static int init(struct ra_hwdec *hw) mp_err(p->log, "Failed to retrieve DRM atomic context.\n"); goto err; } + if (!p->ctx->video_plane) { + mp_warn(p->log, "No video plane. You might need to specify it manually using --drm-video-plane-id\n"); + goto err; + } } else { mp_verbose(p->log, "Failed to retrieve DRM fd from native display.\n"); goto err; -- cgit v1.2.3