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