22#include <libavutil/frame.h>
23#include <libavutil/hwcontext_drm.h>
26#include <drm_fourcc.h>
28#include <xf86drmMode.h>
49 for (
int i = 0;
i < 4;
i++) {
62 : m_width(
src->m_width),
63 m_height(
src->m_height),
64 m_pixFmt(
src->m_pixFmt),
65 m_rectOnScreen(
src->GetScreenRect()),
67 m_numPlanes(
src->m_numPlanes),
68 m_numObjects(
src->m_numObjects)
76 for (
int i = 0;
i <
src->m_numPlanes;
i++) {
88 if (!
src->m_pPlane[0]) {
94 LOGERROR(
"drmbuffer: %s (clone): cannot map buffer size %d prime_fd %d (%d): %m",
118 LOGDEBUG2(
L_GRAB,
"drmbuffer: %s (clone): Cloned plane %d address %p pitch %d offset %d handle %d size %d",
139 m_drmDeviceFd(
fdDrm),
143 for (
int i = 0;
i < 4;
i++) {
227 {
DRM_FORMAT_NV12,
"NV12", 2, { { 8, 1, 1 }, { 16, 2, 2 } }, },
228 {
DRM_FORMAT_YUV420,
"YU12", 3, { { 8, 1, 1 }, { 8, 2, 2 }, {8, 2, 2 } }, },
232#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
289 for (
int object = 0;
object <
primedata->nb_objects;
object++) {
291 LOGFATAL(
"drmbuffer: %s: PRIMEDATA Failed to retrieve the Prime Handle %i size %zu (%d): %m",
__FUNCTION__,
305 int object =
layer->planes[
plane].object_index;
312 if (
primedata->objects[
object].format_modifier)
455 if (
buf->IsDirty() && !
buf->IsPresentationPending())
cDrmBuffer * FindUninitilized(void)
Find a clean drm buffer from the buffer pool.
cDrmBuffer * FindByDmaBufHandle(int)
Find a drm buffer from the buffer pool by a given prime handle.
cDrmBuffer * FindNoPresentationPending(void)
Find a dirty drm buffer from the buffer pool which presentation has finished.
void DestroyAllExcept(cDrmBuffer *)
Destroy all drm buffers except the given one.
bool m_dirty
true, if the buffer is dirty (it was written to)
cDrmBuffer(void)
Create a new drm buffer.
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
void Setup(int, uint32_t, uint32_t, uint32_t, AVDRMFrameDescriptor *, bool)
Setup the buffer.
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
void FillBlack(void)
Color the buffer black.
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
void PresentationFinished(void)
The presentation of this buffer has finished.
bool m_presentationPending
true, if buffer presentation is pending
uint8_t * m_pPlane[4]
array of the plane data
void Destroy(void)
Clear and destroy the buffer object and its parameters.
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
const struct format_info * FindFormat(uint32_t format)
Find infos for the given pixel format.
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