From cfcee4cfe70536faeb9f2aaa87257d067e902b70 Mon Sep 17 00:00:00 2001 From: Lionel CHAZALLON Date: Mon, 23 Oct 2017 08:51:49 -0700 Subject: Add DRM_PRIME Format Handling and Display for RockChip MPP decoders This commit allows to use the AV_PIX_FMT_DRM_PRIME newly introduced format in ffmpeg that allows decoders to provide an AVDRMFrameDescriptor struct. That struct holds dmabuf fds and information allowing zerocopy rendering using KMS / DRM Atomic. This has been tested on RockChip ROCK64 device. --- video/out/drm_common.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'video/out/drm_common.c') diff --git a/video/out/drm_common.c b/video/out/drm_common.c index aea4afaa09..c1f374118a 100644 --- a/video/out/drm_common.c +++ b/video/out/drm_common.c @@ -222,7 +222,7 @@ static void parse_connector_spec(struct mp_log *log, struct kms *kms_create(struct mp_log *log, const char *connector_spec, - int mode_id) + int mode_id, int overlay_id) { int card_no = -1; char *connector_name = NULL; @@ -260,6 +260,23 @@ struct kms *kms_create(struct mp_log *log, const char *connector_spec, if (!setup_mode(kms, mode_id)) goto err; + // Universal planes allows accessing all the planes (including primary) + if (drmSetClientCap(kms->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) { + mp_err(log, "Failed to set Universal planes capability\n"); + } + + if (drmSetClientCap(kms->fd, DRM_CLIENT_CAP_ATOMIC, 1)) { + mp_verbose(log, "No DRM Atomic support found\n"); + } else { + mp_verbose(log, "DRM Atomic support found\n"); + kms->atomic_context = drm_atomic_create_context(kms->log, kms->fd, kms->crtc_id, overlay_id); + if (!kms->atomic_context) { + mp_err(log, "Failed to create DRM atomic context\n"); + goto err; + } + } + + drmModeFreeResources(res); return kms; @@ -284,6 +301,10 @@ void kms_destroy(struct kms *kms) drmModeFreeEncoder(kms->encoder); kms->encoder = NULL; } + if (kms->atomic_context) { + drm_atomic_destroy_context(kms->atomic_context); + } + close(kms->fd); talloc_free(kms); } -- cgit v1.2.3