From ed94f8dc00dd75bf5d88bdf73b9d69a579c0f8ef Mon Sep 17 00:00:00 2001 From: LongChair Date: Sun, 29 Apr 2018 17:46:23 +0200 Subject: drm/atomic: refactor planes names We are currently using primary / overlay planes drm objects, assuming that primary plane is osd and overlay plane is video. This commit is doing two things : - replace the primary / overlay planes members with osd and video planes member without the assumption - Add two more options to determine which one of the primary / overlay is associated to osd / video. - It will default osd to overlay and video to primary if unspecified --- video/out/drm_atomic.c | 73 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 24 deletions(-) (limited to 'video/out/drm_atomic.c') diff --git a/video/out/drm_atomic.c b/video/out/drm_atomic.c index fb63c2b277..84c46beb82 100644 --- a/video/out/drm_atomic.c +++ b/video/out/drm_atomic.c @@ -137,8 +137,8 @@ void drm_object_print_info(struct mp_log *log, struct drm_object *object) (long long)object->props->prop_values[i]); } -struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, - int crtc_id, int connector_id, int overlay_id) +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) { drmModePlane *drmplane = NULL; drmModePlaneRes *plane_res = NULL; @@ -146,7 +146,10 @@ struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, struct drm_object *plane = NULL; struct drm_atomic_context *ctx; int crtc_index = -1; - int layercount = 0; + int layercount = -1; + int primary_id = 0; + int overlay_id = 0; + uint64_t value; res = drmModeGetResources(fd); @@ -206,20 +209,26 @@ struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, mp_err(log, "Unable to retrieve type property from plane %d\n", j); goto fail; } else { - if ((value == DRM_PLANE_TYPE_OVERLAY) && - (layercount == overlay_id)) { - ctx->overlay_plane = plane; - } - else if (value == DRM_PLANE_TYPE_PRIMARY) { - ctx->primary_plane = plane; + layercount++; + + if ((!primary_id) && (value == DRM_PLANE_TYPE_PRIMARY)) + primary_id = drmplane->plane_id; + + if ((!overlay_id) && (value == DRM_PLANE_TYPE_OVERLAY)) + overlay_id = drmplane->plane_id; + + if (layercount == osd_plane_id) { + ctx->osd_plane = plane; + continue; } - else { - drm_object_free(plane); - plane = NULL; + + if (layercount == video_plane_id) { + ctx->video_plane = plane; + continue; } - if (value == DRM_PLANE_TYPE_OVERLAY) - layercount++; + drm_object_free(plane); + plane = NULL; } } else { mp_err(log, "Failed to create Plane object from plane ID %d\n", @@ -231,18 +240,34 @@ struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, drmplane = NULL; } - if (!ctx->primary_plane) { - mp_err(log, "Failed to find primary plane\n"); - goto fail; + // default OSD plane to primary if unspecified + 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); + } else { + mp_err(log, "Failed to find OSD plane with id=%d\n", osd_plane_id); + goto fail; + } + } else { + mp_verbose(log, "Found OSD plane with ID %d\n", ctx->osd_plane->id); } - if (!ctx->overlay_plane) { - mp_err(log, "Failed to find overlay plane with id=%d\n", overlay_id); - goto fail; + // default video plane to overlay if unspecified + 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); + } else { + mp_err(log, "Failed to find video plane with id=%d\n", video_plane_id); + goto fail; + } + } else { + mp_verbose(log, "Found video plane with ID %d\n", ctx->video_plane->id); } - mp_verbose(log, "Found Primary plane with ID %d, overlay with ID %d\n", - ctx->primary_plane->id, ctx->overlay_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); @@ -265,7 +290,7 @@ void drm_atomic_destroy_context(struct drm_atomic_context *ctx) { drm_object_free(ctx->crtc); drm_object_free(ctx->connector); - drm_object_free(ctx->primary_plane); - drm_object_free(ctx->overlay_plane); + drm_object_free(ctx->osd_plane); + drm_object_free(ctx->video_plane); talloc_free(ctx); } -- cgit v1.2.3