summaryrefslogtreecommitdiffstats
path: root/video/out/drm_common.c
diff options
context:
space:
mode:
authorLionel CHAZALLON <LongChair@hotmail.com>2017-10-23 08:51:49 -0700
committerwm4 <wm4@nowhere>2017-10-23 21:07:24 +0200
commitcfcee4cfe70536faeb9f2aaa87257d067e902b70 (patch)
treeb6dfc61144a7394974657b5dfdfc34d9fcf1576a /video/out/drm_common.c
parent762b8cc30007480f06d338ac77d6e91cc04cd320 (diff)
downloadmpv-cfcee4cfe70536faeb9f2aaa87257d067e902b70.tar.bz2
mpv-cfcee4cfe70536faeb9f2aaa87257d067e902b70.tar.xz
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.
Diffstat (limited to 'video/out/drm_common.c')
-rw-r--r--video/out/drm_common.c23
1 files changed, 22 insertions, 1 deletions
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);
}