diff --git a/subprojects/gst-plugins-bad/sys/kms/gstkmsallocator.c b/subprojects/gst-plugins-bad/sys/kms/gstkmsallocator.c index 84359b0782..44d9b24dd1 100644 --- a/subprojects/gst-plugins-bad/sys/kms/gstkmsallocator.c +++ b/subprojects/gst-plugins-bad/sys/kms/gstkmsallocator.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -348,7 +349,7 @@ gst_kms_allocator_new (int fd) static gboolean gst_kms_allocator_add_fb (GstKMSAllocator * alloc, GstKMSMemory * kmsmem, gsize in_offsets[GST_VIDEO_MAX_PLANES], GstVideoInfo * vinfo, - guint32 bo_handles[4]) + guint64 modifier, guint32 bo_handles[4]) { gint i, ret; gint num_planes = GST_VIDEO_INFO_N_PLANES (vinfo); @@ -371,8 +372,21 @@ gst_kms_allocator_add_fb (GstKMSAllocator * alloc, GstKMSMemory * kmsmem, GST_DEBUG_OBJECT (alloc, "bo handles: %d, %d, %d, %d", bo_handles[0], bo_handles[1], bo_handles[2], bo_handles[3]); - ret = drmModeAddFB2 (alloc->priv->fd, w, h, fmt, bo_handles, pitches, - offsets, &kmsmem->fb_id, 0); + if (modifier != DRM_FORMAT_MOD_LINEAR) { + guint64 modifiers[4]; + + for (i = 0; i < num_planes; i++) + modifiers[i] = modifier; + for (; i < 4; i++) + modifiers[i] = DRM_FORMAT_MOD_LINEAR; + + ret = drmModeAddFB2WithModifiers (alloc->priv->fd, w, h, fmt, bo_handles, + pitches, offsets, modifiers, &kmsmem->fb_id, DRM_MODE_FB_MODIFIERS); + } else { + ret = drmModeAddFB2 (alloc->priv->fd, w, h, fmt, bo_handles, pitches, + offsets, &kmsmem->fb_id, 0); + } + if (ret) { GST_ERROR_OBJECT (alloc, "Failed to bind to framebuffer: %s (%d)", g_strerror (errno), errno); @@ -409,7 +423,7 @@ gst_kms_allocator_bo_alloc (GstAllocator * allocator, GstVideoInfo * vinfo) bo_handle[i] = gst_drm_dumb_memory_get_handle (kmsmem->bo); if (!gst_kms_allocator_add_fb (alloc, kmsmem, vinfo->offset, vinfo, - bo_handle)) + DRM_FORMAT_MOD_LINEAR, bo_handle)) goto fail; return mem; @@ -422,7 +436,8 @@ fail: GstKMSMemory * gst_kms_allocator_dmabuf_import (GstAllocator * allocator, gint * prime_fds, - gint n_planes, gsize offsets[GST_VIDEO_MAX_PLANES], GstVideoInfo * vinfo) + gint n_planes, gsize offsets[GST_VIDEO_MAX_PLANES], + GstVideoInfo * vinfo, guint64 modifier) { GstKMSAllocator *alloc; GstKMSMemory *kmsmem; @@ -445,7 +460,8 @@ gst_kms_allocator_dmabuf_import (GstAllocator * allocator, gint * prime_fds, goto import_fd_failed; } - if (!gst_kms_allocator_add_fb (alloc, kmsmem, offsets, vinfo, gem_handle)) + if (!gst_kms_allocator_add_fb (alloc, kmsmem, offsets, vinfo, + modifier, gem_handle)) goto failed; done: diff --git a/subprojects/gst-plugins-bad/sys/kms/gstkmsallocator.h b/subprojects/gst-plugins-bad/sys/kms/gstkmsallocator.h index 258efbaba9..88a0e1546e 100644 --- a/subprojects/gst-plugins-bad/sys/kms/gstkmsallocator.h +++ b/subprojects/gst-plugins-bad/sys/kms/gstkmsallocator.h @@ -82,10 +82,11 @@ GstMemory* gst_kms_allocator_bo_alloc (GstAllocator *allocator, GstVideoInfo *vinfo); GstKMSMemory* gst_kms_allocator_dmabuf_import (GstAllocator *allocator, - gint *prime_fds, - gint n_planes, - gsize offsets[GST_VIDEO_MAX_PLANES], - GstVideoInfo *vinfo); + gint *prime_fds, + gint n_planes, + gsize offsets[GST_VIDEO_MAX_PLANES], + GstVideoInfo *vinfo, + guint64 modifier); GstMemory* gst_kms_allocator_dmabuf_export (GstAllocator *allocator, GstMemory *kmsmem); diff --git a/subprojects/gst-plugins-bad/sys/kms/gstkmssink.c b/subprojects/gst-plugins-bad/sys/kms/gstkmssink.c index 6a23f42b23..3ef25246c2 100644 --- a/subprojects/gst-plugins-bad/sys/kms/gstkmssink.c +++ b/subprojects/gst-plugins-bad/sys/kms/gstkmssink.c @@ -1728,7 +1728,7 @@ gst_kms_sink_import_dmabuf (GstKMSSink * self, GstBuffer * inbuf, prime_fds[1], prime_fds[2], prime_fds[3]); kmsmem = gst_kms_allocator_dmabuf_import (self->allocator, - prime_fds, n_planes, mems_skip, &self->vinfo); + prime_fds, n_planes, mems_skip, &self->vinfo, 0); if (!kmsmem) return FALSE;