FFmpeg  5.1.3
hwcontext_drm.h
Go to the documentation of this file.
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 
30 enum {
31  /**
32  * The maximum number of layers/planes in a DRM frame.
33  */
35 };
36 
37 /**
38  * DRM object descriptor.
39  *
40  * Describes a single DRM object, addressing it as a PRIME file
41  * descriptor.
42  */
43 typedef struct AVDRMObjectDescriptor {
44  /**
45  * DRM PRIME fd for the object.
46  */
47  int fd;
48  /**
49  * DRM PRIME mapped virtual ptr for above fd.
50  *
51  * The content of this buffer must be readonly when acting decoder's out buffer.
52  */
53  void *ptr;
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  uint64_t format_modifier;
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 typedef struct AVDRMPlaneDescriptor {
76  /**
77  * Index of the object containing this plane in the objects
78  * array of the enclosing frame descriptor.
79  */
81  /**
82  * Offset within that object of this plane.
83  */
84  ptrdiff_t offset;
85  /**
86  * Pitch (linesize) of this plane.
87  */
88  ptrdiff_t pitch;
90 
91 /**
92  * DRM layer descriptor.
93  *
94  * Describes a single layer within a frame. This has the structure
95  * defined by its format, and will contain one or more planes.
96  */
97 typedef struct AVDRMLayerDescriptor {
98  /**
99  * Format of the layer (DRM_FORMAT_*).
100  */
101  uint32_t format;
102  /**
103  * Number of planes in the layer.
104  *
105  * This must match the number of planes required by format.
106  */
108  /**
109  * Array of planes in this layer.
110  */
113 
114 /**
115  * DRM frame descriptor.
116  *
117  * This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames.
118  * It is also used by user-allocated frame pools - allocating in
119  * AVHWFramesContext.pool must return AVBufferRefs which contain
120  * an object of this type.
121  *
122  * The fields of this structure should be set such it can be
123  * imported directly by EGL using the EGL_EXT_image_dma_buf_import
124  * and EGL_EXT_image_dma_buf_import_modifiers extensions.
125  * (Note that the exact layout of a particular format may vary between
126  * platforms - we only specify that the same platform should be able
127  * to import it.)
128  *
129  * The total number of planes must not exceed AV_DRM_MAX_PLANES, and
130  * the order of the planes by increasing layer index followed by
131  * increasing plane index must be the same as the order which would
132  * be used for the data pointers in the equivalent software format.
133  */
134 typedef struct AVDRMFrameDescriptor {
135  /**
136  * Number of DRM objects making up this frame.
137  */
139  /**
140  * Array of objects making up the frame.
141  */
143  /**
144  * Number of layers in the frame.
145  *
146  * Set by users if need more than 1.
147  */
149  /**
150  * Array of layers in the frame.
151  * NOTE: total planes of layers must not be more than AV_NUM_DATA_POINTERS.
152  */
155 
156 /**
157  * DRM device.
158  *
159  * Allocated as AVHWDeviceContext.hwctx.
160  */
161 typedef struct AVDRMDeviceContext {
162  /**
163  * File descriptor of DRM device.
164  *
165  * This is used as the device to create frames on, and may also be
166  * used in some derivation and mapping operations.
167  *
168  * If no device is required, set to -1.
169  */
170  int fd;
172 
173 #endif /* AVUTIL_HWCONTEXT_DRM_H */
AVDRMPlaneDescriptor
DRM plane descriptor.
Definition: hwcontext_drm.h:75
AVDRMFrameDescriptor::nb_layers
int nb_layers
Number of layers in the frame.
Definition: hwcontext_drm.h:148
AVDRMFrameDescriptor
DRM frame descriptor.
Definition: hwcontext_drm.h:134
AVDRMDeviceContext::fd
int fd
File descriptor of DRM device.
Definition: hwcontext_drm.h:170
AVDRMLayerDescriptor::nb_planes
int nb_planes
Number of planes in the layer.
Definition: hwcontext_drm.h:107
AVDRMLayerDescriptor::planes
AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES]
Array of planes in this layer.
Definition: hwcontext_drm.h:111
AVDRMPlaneDescriptor::offset
ptrdiff_t offset
Offset within that object of this plane.
Definition: hwcontext_drm.h:84
AVDRMLayerDescriptor
DRM layer descriptor.
Definition: hwcontext_drm.h:97
AVDRMObjectDescriptor
DRM object descriptor.
Definition: hwcontext_drm.h:43
AVDRMObjectDescriptor::fd
int fd
DRM PRIME fd for the object.
Definition: hwcontext_drm.h:47
AVDRMFrameDescriptor::layers
AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES]
Array of layers in the frame.
Definition: hwcontext_drm.h:153
AVDRMObjectDescriptor::ptr
void * ptr
DRM PRIME mapped virtual ptr for above fd.
Definition: hwcontext_drm.h:53
AVDRMObjectDescriptor::size
size_t size
Total size of the object.
Definition: hwcontext_drm.h:59
AVDRMFrameDescriptor::objects
AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES]
Array of objects making up the frame.
Definition: hwcontext_drm.h:142
AVDRMObjectDescriptor::format_modifier
uint64_t format_modifier
Format modifier applied to the object (DRM_FORMAT_MOD_*).
Definition: hwcontext_drm.h:66
AVDRMPlaneDescriptor::object_index
int object_index
Index of the object containing this plane in the objects array of the enclosing frame descriptor.
Definition: hwcontext_drm.h:80
AVDRMLayerDescriptor::format
uint32_t format
Format of the layer (DRM_FORMAT_*).
Definition: hwcontext_drm.h:101
AV_DRM_MAX_PLANES
@ AV_DRM_MAX_PLANES
The maximum number of layers/planes in a DRM frame.
Definition: hwcontext_drm.h:34
AVDRMPlaneDescriptor::pitch
ptrdiff_t pitch
Pitch (linesize) of this plane.
Definition: hwcontext_drm.h:88
AVDRMDeviceContext
DRM device.
Definition: hwcontext_drm.h:161
AVDRMFrameDescriptor::nb_objects
int nb_objects
Number of DRM objects making up this frame.
Definition: hwcontext_drm.h:138