mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 19:25:18 +00:00
kmssink: Add modifier to gst_kms_allocator_dmabuf_import
Use the new drmModeAddFB2WithModifiers() API for binding the non-linear BO. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5174>
This commit is contained in:
parent
7010efc8ed
commit
9df377efc1
3 changed files with 28 additions and 11 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
|
#include <drm_fourcc.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -348,7 +349,7 @@ gst_kms_allocator_new (int fd)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_kms_allocator_add_fb (GstKMSAllocator * alloc, GstKMSMemory * kmsmem,
|
gst_kms_allocator_add_fb (GstKMSAllocator * alloc, GstKMSMemory * kmsmem,
|
||||||
gsize in_offsets[GST_VIDEO_MAX_PLANES], GstVideoInfo * vinfo,
|
gsize in_offsets[GST_VIDEO_MAX_PLANES], GstVideoInfo * vinfo,
|
||||||
guint32 bo_handles[4])
|
guint64 modifier, guint32 bo_handles[4])
|
||||||
{
|
{
|
||||||
gint i, ret;
|
gint i, ret;
|
||||||
gint num_planes = GST_VIDEO_INFO_N_PLANES (vinfo);
|
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],
|
GST_DEBUG_OBJECT (alloc, "bo handles: %d, %d, %d, %d", bo_handles[0],
|
||||||
bo_handles[1], bo_handles[2], bo_handles[3]);
|
bo_handles[1], bo_handles[2], bo_handles[3]);
|
||||||
|
|
||||||
|
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,
|
ret = drmModeAddFB2 (alloc->priv->fd, w, h, fmt, bo_handles, pitches,
|
||||||
offsets, &kmsmem->fb_id, 0);
|
offsets, &kmsmem->fb_id, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
GST_ERROR_OBJECT (alloc, "Failed to bind to framebuffer: %s (%d)",
|
GST_ERROR_OBJECT (alloc, "Failed to bind to framebuffer: %s (%d)",
|
||||||
g_strerror (errno), errno);
|
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);
|
bo_handle[i] = gst_drm_dumb_memory_get_handle (kmsmem->bo);
|
||||||
|
|
||||||
if (!gst_kms_allocator_add_fb (alloc, kmsmem, vinfo->offset, vinfo,
|
if (!gst_kms_allocator_add_fb (alloc, kmsmem, vinfo->offset, vinfo,
|
||||||
bo_handle))
|
DRM_FORMAT_MOD_LINEAR, bo_handle))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
return mem;
|
return mem;
|
||||||
|
@ -422,7 +436,8 @@ fail:
|
||||||
|
|
||||||
GstKMSMemory *
|
GstKMSMemory *
|
||||||
gst_kms_allocator_dmabuf_import (GstAllocator * allocator, gint * prime_fds,
|
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;
|
GstKMSAllocator *alloc;
|
||||||
GstKMSMemory *kmsmem;
|
GstKMSMemory *kmsmem;
|
||||||
|
@ -445,7 +460,8 @@ gst_kms_allocator_dmabuf_import (GstAllocator * allocator, gint * prime_fds,
|
||||||
goto import_fd_failed;
|
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;
|
goto failed;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -85,7 +85,8 @@ GstKMSMemory* gst_kms_allocator_dmabuf_import (GstAllocator *allocator,
|
||||||
gint *prime_fds,
|
gint *prime_fds,
|
||||||
gint n_planes,
|
gint n_planes,
|
||||||
gsize offsets[GST_VIDEO_MAX_PLANES],
|
gsize offsets[GST_VIDEO_MAX_PLANES],
|
||||||
GstVideoInfo *vinfo);
|
GstVideoInfo *vinfo,
|
||||||
|
guint64 modifier);
|
||||||
|
|
||||||
GstMemory* gst_kms_allocator_dmabuf_export (GstAllocator *allocator,
|
GstMemory* gst_kms_allocator_dmabuf_export (GstAllocator *allocator,
|
||||||
GstMemory *kmsmem);
|
GstMemory *kmsmem);
|
||||||
|
|
|
@ -1728,7 +1728,7 @@ gst_kms_sink_import_dmabuf (GstKMSSink * self, GstBuffer * inbuf,
|
||||||
prime_fds[1], prime_fds[2], prime_fds[3]);
|
prime_fds[1], prime_fds[2], prime_fds[3]);
|
||||||
|
|
||||||
kmsmem = gst_kms_allocator_dmabuf_import (self->allocator,
|
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)
|
if (!kmsmem)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue