29#include <EGL/eglext.h>
32#include <drm_fourcc.h>
34#include <xf86drmMode.h>
107#define MAX_DRM_DEVICES 64
246 for (
i = 0, width = 0;
i <
connector->count_modes;
i++) {
266 LOGERROR(
"drmdevice: %s: No monitor mode found! Probably no monitor connected, giving up!",
__FUNCTION__);
311 LOGINFO(
"DRM Setup: Using Monitor Mode %dx%d@%.2fHz, m_crtcId %d crtc_idx %d",
363 for (
k = 0;
k <
plane->count_formats;
k++) {
366 switch (
plane->formats[
k]) {
459 LOGWARNING(
"drmdevice: %s: No suitable plane for Picture-in-Picture found. PIP will be disabled.",
__FUNCTION__);
512 strcat(
str_zpos,
"hardcode them to 0 and 1, because they are equal");
540 LOGINFO(
"DRM setup - CRTC: %i video_plane: %i (%s %" PRIu64 ") osd_plane: %i (%s %" PRIu64 ") pip_plane: %i (%s %" PRIu64 ") m_useZpos: %d",
553 LOGINFO(
"DRM setup - CRTC: %i video_plane: %i (%s %" PRIu64 ") osd_plane: %i (%s %" PRIu64 ") m_useZpos: %d (pip disbled)",
728 LOGINFO(
"DRM Setup: EGL context initialized");
790 buf->SetNumPlanes(num_planes);
791 for (
int i = 0;
i < num_planes;
i++) {
799 buf->SetNumObjects(1);
800 buf->SetObjectIndex(0, 0);
819 buf->SetNumPlanes(1);
827 buf->SetNumObjects(1);
828 buf->SetObjectIndex(0, 0);
833 buf->PrimeHandle(),
buf->Pitch(),
buf->Offset(), &
id, 0);
1173 LOGDEBUG2(
L_DRM,
"drmdevice: %s: failed to set hdr property blob: blob id %d connector_id %d, m_hdrMetadata %d ret %d",
bool m_glInitiated
true, if OpenGL/ES context is initiated
uint32_t m_userReqDisplayRefreshRate
user requested display refresh rate
int m_userReqDisplayHeight
user requested display height
drmModeModeInfo m_drmModeInfo
mode info
uint32_t m_hdrMetadata
property id of HDR_OUTPUT_METADATA
cDrmPlane m_videoPlane
the video drm plane
struct gbm_surface * m_pGbmSurface
pointer to the gbm surface
EGLContext m_eglContext
EGL context.
EGLSurface m_eglSurface
EGL surface.
int m_userReqDisplayWidth
user requested display width
cDrmPlane m_pipPlane
the pip drm plane
drmModeCrtc * m_drmModeCrtcSaved
saved CRTC infos
int m_fdDrm
drm file descriptor
uint64_t m_zposPip
zpos of pip plane
EGLDisplay m_eglDisplay
EGL display.
uint32_t m_connectorId
connector id
uint32_t m_crtcId
current crtc ID
uint32_t m_crtcIndex
current crtc index
cVideoRender * m_pRender
pointer to cVideoRender object
uint64_t m_zposPrimary
zpos of primary plane
drmEventContext m_drmEventCtx
drm event context
bool m_useZpos
is set, if drm hardware can use zpos
struct gbm_device * m_pGbmDevice
pointer to the gbm device
cDrmPlane m_osdPlane
the osd drm plane
uint64_t m_zposOverlay
zpos of overlay plane
void SetZpos(uint64_t zpos)
void SetType(uint64_t type)
bool OglOsdDisabled(void)
int SetConnectorHdrOutputMetadata(drmModeAtomicReqPtr, uint32_t)
cDrmBuffer * GetBufFromBo(struct gbm_bo *)
Get a drm buffer from a gbm buffer object.
int GetPropertyValue(uint32_t, uint32_t, const char *, uint64_t *)
Get a drm property value.
int SetConnectorColorspace(drmModeAtomicReqPtr, uint32_t)
int InitEGL(void)
Init EGL context.
int CreateModeBlob(uint32_t *)
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display
int CreatePropertyBlob(uint32_t *)
Wrapper to create a property blob.
static void drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
Callback function to destroy a drm buffer which stays in the gbm_bo's user data.
static int TestCaps(int fd)
Test drm capabilities.
EGLConfig GetEGLConfig(void)
Get a suitable EGLConfig.
static int FindDrmDevice(drmModeRes **resources)
Find and open a suitable device with the wanted capabilities.
int GetVideoPlaneColorRange(uint64_t *)
int DestroyHdrBlob(uint32_t)
uint32_t GetPropertyID(uint32_t, uint32_t, const char *)
Get a property ID.
cDrmDevice(cVideoRender *, const char *)
Create a drm device.
int SetVideoPlaneColorEncoding(drmModeAtomicReqPtr, uint32_t)
static int32_t FindCrtcForEncoder(const drmModeRes *resources, const drmModeEncoder *encoder)
Find the CRTC_ID for the given encoder.
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC get_platform_surface
int SetPropertyRequest(drmModeAtomicReqPtr, uint32_t, uint32_t, const char *, uint64_t)
Add a drm property to an atomic modeset request.
int SetCrtcModeId(drmModeAtomicReqPtr, uint32_t)
int32_t FindCrtcForConnector(const drmModeRes *, const drmModeConnector *)
Find the CRTC_ID for the given connector.
int HandleEvent(void)
Poll for a drm event.
static int get_resources(int fd, drmModeRes **resources)
int DestroyModeBlob(uint32_t)
int HasZpos(int)
Check, if the plane is able to set the zpos property.
int CreateHdrBlob(struct hdr_output_metadata *, size_t, uint32_t *)
void FillProperties(int)
Fill the plane properties.
int SetConnectorHdrBlobProperty(uint32_t)
void SaveCrtc(void)
Save information of a CRTC.
static const EGLint context_attribute_list[]
void RestoreCrtc(void)
Restore information of a CRTC.
void Close(void)
Close the drm file handle.
int SetConnectorCrtcId(drmModeAtomicReqPtr)
int InitGbm(int, int, uint32_t, uint64_t)
Init gbm device and surface.
int SetCrtcActive(drmModeAtomicReqPtr, uint32_t)
int Init(void)
Initiate the drm device.
static drmModeConnector * FindDrmConnector(int fd, drmModeRes *resources)
Find a suitable connector, preferably a connected one.
__attribute__((weak)) union gbm_bo_handle gbm_bo_get_handle_for_plane(struct gbm_bo *bo
int SetVideoPlaneColorRange(drmModeAtomicReqPtr, uint32_t)
void InitEvent(void)
Init the event context.
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
#define LOGERROR
log to LOG_ERR
#define LOGWARNING
log to LOG_WARN
#define LOGINFO
log to LOG_INFO
#define LOGFATAL
log to LOG_ERR and abort
#define EGL_CHECK(stmt)
eglCheckError macro
@ L_OPENGL
opengl osd logs
void SetScreenSize(int, int, double)
Wrapper to set the screen size in the device.
Video Renderer (Display) Header File.