2
0

hwcontext_drm.h 4.6 KB

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