1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 module ffmpeg.libavutil.hwcontext_drm;
20 
21 extern (C):
22 import ffmpeg; @nogc nothrow:
23 
24 /**
25  * @file
26  * API-specific header for AV_HWDEVICE_TYPE_DRM.
27  *
28  * Internal frame allocation is not currently supported - all frames
29  * must be allocated by the user.  Thus AVHWFramesContext is always
30  * NULL, though this may change if support for frame allocation is
31  * added in future.
32  */
33 
34 enum
35 {
36     /**
37      * The maximum number of layers/planes in a DRM frame.
38      */
39     AV_DRM_MAX_PLANES = 4
40 }
41 
42 /**
43  * DRM object descriptor.
44  *
45  * Describes a single DRM object, addressing it as a PRIME file
46  * descriptor.
47  */
48 struct AVDRMObjectDescriptor
49 {
50     /**
51      * DRM PRIME fd for the object.
52      */
53     int fd;
54     /**
55      * Total size of the object.
56      *
57      * (This includes any parts not which do not contain image data.)
58      */
59     size_t size;
60     /**
61      * Format modifier applied to the object (DRM_FORMAT_MOD_*).
62      *
63      * If the format modifier is unknown then this should be set to
64      * DRM_FORMAT_MOD_INVALID.
65      */
66     ulong format_modifier;
67 }
68 
69 /**
70  * DRM plane descriptor.
71  *
72  * Describes a single plane of a layer, which is contained within
73  * a single object.
74  */
75 struct AVDRMPlaneDescriptor
76 {
77     /**
78      * Index of the object containing this plane in the objects
79      * array of the enclosing frame descriptor.
80      */
81     int object_index;
82     /**
83      * Offset within that object of this plane.
84      */
85     ptrdiff_t offset;
86     /**
87      * Pitch (linesize) of this plane.
88      */
89     ptrdiff_t pitch;
90 }
91 
92 /**
93  * DRM layer descriptor.
94  *
95  * Describes a single layer within a frame.  This has the structure
96  * defined by its format, and will contain one or more planes.
97  */
98 struct AVDRMLayerDescriptor
99 {
100     /**
101      * Format of the layer (DRM_FORMAT_*).
102      */
103     uint format;
104     /**
105      * Number of planes in the layer.
106      *
107      * This must match the number of planes required by format.
108      */
109     int nb_planes;
110     /**
111      * Array of planes in this layer.
112      */
113     AVDRMPlaneDescriptor[AV_DRM_MAX_PLANES] planes;
114 }
115 
116 /**
117  * DRM frame descriptor.
118  *
119  * This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames.
120  * It is also used by user-allocated frame pools - allocating in
121  * AVHWFramesContext.pool must return AVBufferRefs which contain
122  * an object of this type.
123  *
124  * The fields of this structure should be set such it can be
125  * imported directly by EGL using the EGL_EXT_image_dma_buf_import
126  * and EGL_EXT_image_dma_buf_import_modifiers extensions.
127  * (Note that the exact layout of a particular format may vary between
128  * platforms - we only specify that the same platform should be able
129  * to import it.)
130  *
131  * The total number of planes must not exceed AV_DRM_MAX_PLANES, and
132  * the order of the planes by increasing layer index followed by
133  * increasing plane index must be the same as the order which would
134  * be used for the data pointers in the equivalent software format.
135  */
136 struct AVDRMFrameDescriptor
137 {
138     /**
139      * Number of DRM objects making up this frame.
140      */
141     int nb_objects;
142     /**
143      * Array of objects making up the frame.
144      */
145     AVDRMObjectDescriptor[AV_DRM_MAX_PLANES] objects;
146     /**
147      * Number of layers in the frame.
148      */
149     int nb_layers;
150     /**
151      * Array of layers in the frame.
152      */
153     AVDRMLayerDescriptor[AV_DRM_MAX_PLANES] layers;
154 }
155 
156 /**
157  * DRM device.
158  *
159  * Allocated as AVHWDeviceContext.hwctx.
160  */
161 struct AVDRMDeviceContext
162 {
163     /**
164      * File descriptor of DRM device.
165      *
166      * This is used as the device to create frames on, and may also be
167      * used in some derivation and mapping operations.
168      *
169      * If no device is required, set to -1.
170      */
171     int fd;
172 }
173 
174 /* AVUTIL_HWCONTEXT_DRM_H */