From c151fae054d12ef9b392f5b6dcc1bafe894005b0 Mon Sep 17 00:00:00 2001 From: Anton Kindestam Date: Sat, 2 Jun 2018 12:54:05 +0200 Subject: drm_atomic: Add general primary/overlay plane option Add general primary/overlay plane option to drm-osd-plane-id and drm-video-plane-id, so that the user can just request any usable primary or overlay plane for either of these two options. This should be somewhat more user-friendly (especially as neither of these two options currently have a useful help function), as usually you would only be interested in the type of the plane, and not exactly which plane gets picked. --- video/out/drm_atomic.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'video/out/drm_atomic.c') diff --git a/video/out/drm_atomic.c b/video/out/drm_atomic.c index f530d91b66..fea8ffa88e 100644 --- a/video/out/drm_atomic.c +++ b/video/out/drm_atomic.c @@ -138,7 +138,8 @@ void drm_object_print_info(struct mp_log *log, struct drm_object *object) } struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, int crtc_id, - int connector_id, int osd_plane_id, int video_plane_id) + int connector_id, + int osd_plane_idx, int video_plane_idx) { drmModePlaneRes *plane_res = NULL; drmModeRes *res = NULL; @@ -228,12 +229,12 @@ struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, if ((!overlay_id) && (value == DRM_PLANE_TYPE_OVERLAY)) overlay_id = plane_id; - if (layercount == osd_plane_id) { + if (layercount == osd_plane_idx) { ctx->osd_plane = plane; continue; } - if (layercount == video_plane_id) { + if (layercount == video_plane_idx) { ctx->video_plane = plane; continue; } @@ -244,26 +245,31 @@ struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, } } - // default OSD plane to primary if unspecified + // OSD plane was specified as either of the special options: any primary plane or any overlay plane if (!ctx->osd_plane) { - if (primary_id) { - mp_verbose(log, "Using default plane %d for OSD\n", primary_id); - ctx->osd_plane = drm_object_create(log, ctx->fd, primary_id, DRM_MODE_OBJECT_PLANE); + const int osd_plane_id = (osd_plane_idx == DRM_OPTS_OVERLAY_PLANE) ? overlay_id : primary_id; + const char *plane_type = (osd_plane_idx == DRM_OPTS_OVERLAY_PLANE) ? "overlay" : "primary"; + if (osd_plane_id) { + mp_verbose(log, "Using %s plane %d for OSD\n", plane_type, osd_plane_id); + ctx->osd_plane = drm_object_create(log, ctx->fd, osd_plane_id, DRM_MODE_OBJECT_PLANE); } else { - mp_err(log, "Failed to find OSD plane with id=%d\n", osd_plane_id); + mp_err(log, "Failed to find OSD plane with idx=%d\n", osd_plane_idx); goto fail; } } else { mp_verbose(log, "Found OSD plane with ID %d\n", ctx->osd_plane->id); } - // default video plane to overlay if unspecified + // video plane was specified as either of the special options: any primary plane or any overlay plane if (!ctx->video_plane) { - if (overlay_id) { - 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); + const int video_plane_id = (video_plane_idx == DRM_OPTS_PRIMARY_PLANE) ? primary_id : overlay_id; + const char *plane_type = (video_plane_idx == DRM_OPTS_PRIMARY_PLANE) ? "primary" : "overlay"; + + if (video_plane_id) { + mp_verbose(log, "Using %s plane %d for video\n", plane_type, video_plane_id); + ctx->video_plane = drm_object_create(log, ctx->fd, video_plane_id, DRM_MODE_OBJECT_PLANE); } else { - mp_verbose(log, "Failed to find video plane with id=%d. drmprime-drm hwdec interop will not work\n", video_plane_id); + mp_verbose(log, "Failed to find video plane with idx=%d. drmprime-drm hwdec interop will not work\n", video_plane_idx); } } else { mp_verbose(log, "Found video plane with ID %d\n", ctx->video_plane->id); -- cgit v1.2.3