]> git.sesse.net Git - ffmpeg/blob - libavutil/hwcontext_drm.h
Merge commit '8965e2af921ec5926b26d5ae466ee4104bb5262b'
[ffmpeg] / libavutil / hwcontext_drm.h
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 #ifndef AVUTIL_HWCONTEXT_DRM_H
20 #define AVUTIL_HWCONTEXT_DRM_H
21
22 #include <stddef.h>
23 #include <stdint.h>
24
25 /**
26  * @file
27  * API-specific header for AV_HWDEVICE_TYPE_DRM.
28  *
29  * Internal frame allocation is not currently supported - all frames
30  * must be allocated by the user.  Thus AVHWFramesContext is always
31  * NULL, though this may change if support for frame allocation is
32  * added in future.
33  */
34
35 enum {
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 typedef struct AVDRMObjectDescriptor {
49     /**
50      * DRM PRIME fd for the object.
51      */
52     int fd;
53     /**
54      * Total size of the object.
55      *
56      * (This includes any parts not which do not contain image data.)
57      */
58     size_t size;
59     /**
60      * Format modifier applied to the object (DRM_FORMAT_MOD_*).
61      */
62     uint64_t format_modifier;
63 } AVDRMObjectDescriptor;
64
65 /**
66  * DRM plane descriptor.
67  *
68  * Describes a single plane of a layer, which is contained within
69  * a single object.
70  */
71 typedef struct AVDRMPlaneDescriptor {
72     /**
73      * Index of the object containing this plane in the objects
74      * array of the enclosing frame descriptor.
75      */
76     int object_index;
77     /**
78      * Offset within that object of this plane.
79      */
80     ptrdiff_t offset;
81     /**
82      * Pitch (linesize) of this plane.
83      */
84     ptrdiff_t pitch;
85 } AVDRMPlaneDescriptor;
86
87 /**
88  * DRM layer descriptor.
89  *
90  * Describes a single layer within a frame.  This has the structure
91  * defined by its format, and will contain one or more planes.
92  */
93 typedef struct AVDRMLayerDescriptor {
94     /**
95      * Format of the layer (DRM_FORMAT_*).
96      */
97     uint32_t format;
98     /**
99      * Number of planes in the layer.
100      *
101      * This must match the number of planes required by format.
102      */
103     int nb_planes;
104     /**
105      * Array of planes in this layer.
106      */
107     AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES];
108 } AVDRMLayerDescriptor;
109
110 /**
111  * DRM frame descriptor.
112  *
113  * This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames.
114  * It is also used by user-allocated frame pools - allocating in
115  * AVHWFramesContext.pool must return AVBufferRefs which contain
116  * an object of this type.
117  *
118  * The fields of this structure should be set such it can be
119  * imported directly by EGL using the EGL_EXT_image_dma_buf_import
120  * and EGL_EXT_image_dma_buf_import_modifiers extensions.
121  * (Note that the exact layout of a particular format may vary between
122  * platforms - we only specify that the same platform should be able
123  * to import it.)
124  *
125  * The total number of planes must not exceed AV_DRM_MAX_PLANES, and
126  * the order of the planes by increasing layer index followed by
127  * increasing plane index must be the same as the order which would
128  * be used for the data pointers in the equivalent software format.
129  */
130 typedef struct AVDRMFrameDescriptor {
131     /**
132      * Number of DRM objects making up this frame.
133      */
134     int nb_objects;
135     /**
136      * Array of objects making up the frame.
137      */
138     AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES];
139     /**
140      * Number of layers in the frame.
141      */
142     int nb_layers;
143     /**
144      * Array of layers in the frame.
145      */
146     AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES];
147 } AVDRMFrameDescriptor;
148
149 /**
150  * DRM device.
151  *
152  * Allocated as AVHWDeviceContext.hwctx.
153  */
154 typedef struct AVDRMDeviceContext {
155     /**
156      * File descriptor of DRM device.
157      *
158      * This is used as the device to create frames on, and may also be
159      * used in some derivation and mapping operations.
160      *
161      * If no device is required, set to -1.
162      */
163     int fd;
164 } AVDRMDeviceContext;
165
166 #endif /* AVUTIL_HWCONTEXT_DRM_H */