22#include <libavutil/frame.h>
23#include <libavutil/hwcontext_drm.h>
26#include <drm_fourcc.h>
28#include <xf86drmMode.h>
54 for (
int i = 0;
i < 4;
i++) {
67 : m_width(
src->m_width),
68 m_height(
src->m_height),
69 m_pixFmt(
src->m_pixFmt),
70 m_rectOnScreen(
src->GetScreenRect()),
72 m_numPlanes(
src->m_numPlanes),
73 m_numObjects(
src->m_numObjects)
81 for (
int i = 0;
i <
src->m_numPlanes;
i++) {
93 if (!
src->m_pPlane[0]) {
99 LOGERROR(
"drmbuffer: %s (clone): cannot map buffer size %d prime_fd %d (%d): %m",
123 LOGDEBUG2(
L_GRAB,
"drmbuffer: %s (clone): Cloned plane %d address %p pitch %d offset %d handle %d size %d",
144 m_drmDeviceFd(
fdDrm),
148 for (
int i = 0;
i < 4;
i++) {
232 {
DRM_FORMAT_NV12,
"NV12", 2, { { 8, 1, 1 }, { 16, 2, 2 } }, },
233 {
DRM_FORMAT_YUV420,
"YU12", 3, { { 8, 1, 1 }, { 8, 2, 2 }, {8, 2, 2 } }, },
237#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
294 for (
int object = 0;
object <
primedata->nb_objects;
object++) {
296 LOGFATAL(
"drmbuffer: %s: PRIMEDATA Failed to retrieve the Prime Handle %i size %zu (%d): %m",
__FUNCTION__,
310 int object =
layer->planes[
plane].object_index;
317 if (
primedata->objects[
object].format_modifier)
460 if (
buf->IsDirty() && !
buf->IsPresentationPending())
bool m_dirty
true, if the buffer is dirty (it was written to)
bool m_destroyAfterUse
true, if buffer should be destroyed after use
int m_objIdx[4]
index of the objects
bool m_closeHandleOnDestroy
true, if DMA-BUF handle should be closed on destroy
int m_numObjects
number of prime objects in the buffer
uint32_t m_fbId
framebuffer id
uint32_t m_width
buffer width
uint32_t m_offset[4]
array of the plane offset
uint32_t m_pitch[4]
array of the plane pitch
AVFrame * frame
associated AVFrame
uint32_t m_objectPrimeHandle[4]
primedata objects prime handles (count is numObjects, index is objIdx)
int m_dmaBufHandle[4]
DMA-BUF file descriptor.
uint32_t m_pixFmt
buffer pixel format
int m_drmDeviceFd
drm device file descriptor
uint32_t m_height
buffer height
bool m_presentationPending
true, if buffer presentation is pending
uint8_t * m_pPlane[4]
array of the plane data
uint32_t m_size[4]
array of the plane size
uint32_t m_planePrimeHandle[4]
array of the plane handles
int m_numPlanes
number of planes in the buffer
std::vector< std::unique_ptr< cDrmBuffer > > buffer
cDrmBuffer(void)
Create a new drm buffer.
cDrmBuffer * FindUninitilized(void)
Find a clean drm buffer from the buffer pool.
void Setup(int, uint32_t, uint32_t, uint32_t, AVDRMFrameDescriptor *, bool)
Setup the buffer.
cDrmBuffer * FindByDmaBufHandle(int)
Find a drm buffer from the buffer pool by a given prime handle.
void FillBlack(void)
Color the buffer black.
cDrmBuffer * FindNoPresentationPending(void)
Find a dirty drm buffer from the buffer pool which presentation has finished.
const struct format_info * FindFormat(uint32_t format)
Find infos for the given pixel format.
void DestroyAllExcept(cDrmBuffer *)
Destroy all drm buffers except the given one.
void PresentationFinished(void)
The presentation of this buffer has finished.
void Destroy(void)
Clear and destroy the buffer object and its parameters.
static const struct format_info format_info_array[]
Holds the infos of a pixel format.
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
#define LOGERROR
log to LOG_ERR
#define LOGFATAL
log to LOG_ERR and abort