hwcontext_drm.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. uint64_t format_modifier;
  58. } AVDRMObjectDescriptor;
  59. /**
  60. * DRM plane descriptor.
  61. *
  62. * Describes a single plane of a layer, which is contained within
  63. * a single object.
  64. */
  65. typedef struct AVDRMPlaneDescriptor {
  66. /**
  67. * Index of the object containing this plane in the objects
  68. * array of the enclosing frame descriptor.
  69. */
  70. int object_index;
  71. /**
  72. * Offset within that object of this plane.
  73. */
  74. ptrdiff_t offset;
  75. /**
  76. * Pitch (linesize) of this plane.
  77. */
  78. ptrdiff_t pitch;
  79. } AVDRMPlaneDescriptor;
  80. /**
  81. * DRM layer descriptor.
  82. *
  83. * Describes a single layer within a frame. This has the structure
  84. * defined by its format, and will contain one or more planes.
  85. */
  86. typedef struct AVDRMLayerDescriptor {
  87. /**
  88. * Format of the layer (DRM_FORMAT_*).
  89. */
  90. uint32_t format;
  91. /**
  92. * Number of planes in the layer.
  93. *
  94. * This must match the number of planes required by format.
  95. */
  96. int nb_planes;
  97. /**
  98. * Array of planes in this layer.
  99. */
  100. AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES];
  101. } AVDRMLayerDescriptor;
  102. /**
  103. * DRM frame descriptor.
  104. *
  105. * This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames.
  106. * It is also used by user-allocated frame pools - allocating in
  107. * AVHWFramesContext.pool must return AVBufferRefs which contain
  108. * an object of this type.
  109. *
  110. * The fields of this structure should be set such it can be
  111. * imported directly by EGL using the EGL_EXT_image_dma_buf_import
  112. * and EGL_EXT_image_dma_buf_import_modifiers extensions.
  113. * (Note that the exact layout of a particular format may vary between
  114. * platforms - we only specify that the same platform should be able
  115. * to import it.)
  116. *
  117. * The total number of planes must not exceed AV_DRM_MAX_PLANES, and
  118. * the order of the planes by increasing layer index followed by
  119. * increasing plane index must be the same as the order which would
  120. * be used for the data pointers in the equivalent software format.
  121. */
  122. typedef struct AVDRMFrameDescriptor {
  123. /**
  124. * Number of DRM objects making up this frame.
  125. */
  126. int nb_objects;
  127. /**
  128. * Array of objects making up the frame.
  129. */
  130. AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES];
  131. /**
  132. * Number of layers in the frame.
  133. */
  134. int nb_layers;
  135. /**
  136. * Array of layers in the frame.
  137. */
  138. AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES];
  139. } AVDRMFrameDescriptor;
  140. /**
  141. * DRM device.
  142. *
  143. * Allocated as AVHWDeviceContext.hwctx.
  144. */
  145. typedef struct AVDRMDeviceContext {
  146. /**
  147. * File descriptor of DRM device.
  148. *
  149. * This is used as the device to create frames on, and may also be
  150. * used in some derivation and mapping operations.
  151. *
  152. * If no device is required, set to -1.
  153. */
  154. int fd;
  155. } AVDRMDeviceContext;
  156. #endif /* AVUTIL_HWCONTEXT_DRM_H */