1 /* GStreamer 2 * 3 * Copyright (C) 2016 Igalia 4 * 5 * Authors: 6 * Víctor Manuel Jáquez Leal <vjaquez@igalia.com> 7 * Javier Martin <javiermartin@by.com.es> 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Library General Public 11 * License as published by the Free Software Foundation; either 12 * version 2 of the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Library General Public License for more details. 18 * 19 * You should have received a copy of the GNU Library General Public 20 * License along with this library; if not, write to the 21 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 22 * Boston, MA 02110-1301, USA. 23 * 24 */ 25 26 #ifndef __GST_KMS_ALLOCATOR_H__ 27 #define __GST_KMS_ALLOCATOR_H__ 28 29 #include <gst/gst.h> 30 #include <gst/video/video.h> 31 32 G_BEGIN_DECLS 33 34 #define GST_TYPE_KMS_ALLOCATOR \ 35 (gst_kms_allocator_get_type()) 36 #define GST_IS_KMS_ALLOCATOR(obj) \ 37 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_KMS_ALLOCATOR)) 38 #define GST_IS_KMS_ALLOCATOR_CLASS(klass) \ 39 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_KMS_ALLOCATOR)) 40 #define GST_KMS_ALLOCATOR_GET_CLASS(obj) \ 41 (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_KMS_ALLOCATOR, GstKMSAllocatorClass)) 42 #define GST_KMS_ALLOCATOR(obj) \ 43 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_KMS_ALLOCATOR, GstKMSAllocator)) 44 #define GST_KMS_ALLOCATOR_CLASS(klass) \ 45 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_KMS_ALLOCATOR, GstKMSAllocatorClass)) 46 47 typedef struct _GstKMSAllocator GstKMSAllocator; 48 typedef struct _GstKMSAllocatorClass GstKMSAllocatorClass; 49 typedef struct _GstKMSAllocatorPrivate GstKMSAllocatorPrivate; 50 typedef struct _GstKMSMemory GstKMSMemory; 51 52 struct kms_bo; 53 54 struct _GstKMSMemory 55 { 56 GstMemory parent; 57 58 guint32 fb_id; 59 guint32 gem_handle[GST_VIDEO_MAX_PLANES]; 60 struct kms_bo *bo; 61 }; 62 63 struct _GstKMSAllocator 64 { 65 GstAllocator parent; 66 GstKMSAllocatorPrivate *priv; 67 }; 68 69 struct _GstKMSAllocatorClass { 70 GstAllocatorClass parent_class; 71 }; 72 73 GType gst_kms_allocator_get_type (void) G_GNUC_CONST; 74 75 gboolean gst_is_kms_memory (GstMemory *mem); 76 guint32 gst_kms_memory_get_fb_id (GstMemory *mem); 77 78 GstAllocator* gst_kms_allocator_new (gint fd); 79 80 GstMemory* gst_kms_allocator_bo_alloc (GstAllocator *allocator, 81 GstVideoInfo *vinfo); 82 83 GstKMSMemory* gst_kms_allocator_dmabuf_import (GstAllocator *allocator, 84 gint *prime_fds, 85 gint n_planes, 86 gsize offsets[GST_VIDEO_MAX_PLANES], 87 GstVideoInfo *vinfo); 88 89 GstMemory* gst_kms_allocator_dmabuf_export (GstAllocator *allocator, 90 GstMemory *kmsmem); 91 92 GstMemory * gst_kms_allocator_get_cached (GstMemory * mem); 93 94 void gst_kms_allocator_clear_cache (GstAllocator * allocator); 95 96 void gst_kms_allocator_cache (GstAllocator * allocator, 97 GstMemory * mem, 98 GstMemory * kmsmem); 99 100 G_END_DECLS 101 102 103 #endif /* __GST_KMS_ALLOCATOR_H__ */ 104