vdr-plugin-softhddevice-drm-gles 1.6.4-d0291bb
cDrmDevice Class Reference

DRM Device. More...

#include <drmdevice.h>

Public Member Functions

 cDrmDevice (cVideoRender *, const char *, const char *)
 Create a drm device.
 
 ~cDrmDevice (void)
 
int Init (void)
 Initiate the drm device.
 
int Fd (void)
 
void Close (void)
 Close the drm file handle.
 
uint32_t ConnectorId (void)
 
uint64_t DisplayWidth (void)
 
uint64_t DisplayHeight (void)
 
uint32_t CrtcId (void)
 
int UseZpos (void)
 
uint64_t ZposOverlay (void)
 
uint64_t ZposPrimary (void)
 
cDrmPlaneOsdPlane (void)
 
cDrmPlaneVideoPlane (void)
 
cDrmPlanePipPlane (void)
 
bool HasPipPlane (void)
 
EGLSurface EglSurface (void)
 
EGLDisplay EglDisplay (void)
 
EGLContext EglContext (void)
 
int GlInitiated (void)
 
struct gbm_surfaceGbmSurface (void)
 
cDrmBufferGetBufFromBo (struct gbm_bo *)
 Get a drm buffer from a gbm buffer object.
 
void SaveCrtc (void)
 Save information of a CRTC.
 
void RestoreCrtc (void)
 Restore information of a CRTC.
 
int HandleEvent (void)
 Poll for a drm event.
 
void InitEvent (void)
 Init the event context.
 
bool CanHandleHdr (void)
 
drmModeAtomicReqPtr ModeAtomicAlloc (void)
 
int ModeAtomicCommit (drmModeAtomicReqPtr req, uint32_t flags, void *user_data)
 
void ModeAtomicFree (drmModeAtomicReqPtr req)
 
int SetConnectorCrtcId (drmModeAtomicReqPtr)
 
int SetConnectorHdrOutputMetadata (drmModeAtomicReqPtr, uint32_t)
 
int SetConnectorColorspace (drmModeAtomicReqPtr, uint32_t)
 
int SetVideoPlaneColorEncoding (drmModeAtomicReqPtr, uint32_t)
 
int SetVideoPlaneColorRange (drmModeAtomicReqPtr, uint32_t)
 
int GetVideoPlaneColorRange (uint64_t *)
 
int SetCrtcModeId (drmModeAtomicReqPtr, uint32_t)
 
int SetCrtcActive (drmModeAtomicReqPtr, uint32_t)
 
int CreateModeBlob (uint32_t *)
 
int DestroyModeBlob (uint32_t)
 
int CreateHdrBlob (struct hdr_output_metadata *, size_t, uint32_t *)
 
int SetConnectorHdrBlobProperty (uint32_t)
 
int DestroyHdrBlob (uint32_t)
 

Private Member Functions

int CreatePropertyBlob (uint32_t *)
 Wrapper to create a property blob.
 
int GetPropertyValue (uint32_t, uint32_t, const char *, uint64_t *)
 Get a drm property value.
 
uint32_t GetPropertyID (uint32_t, uint32_t, const char *)
 Get a property ID.
 
int SetPropertyRequest (drmModeAtomicReqPtr, uint32_t, uint32_t, const char *, uint64_t)
 Add a drm property to an atomic modeset request.
 
int32_t FindCrtcForConnector (const drmModeRes *, const drmModeConnector *)
 Find the CRTC_ID for the given connector.
 
int InitEGL (void)
 Init EGL context.
 
EGLConfig GetEGLConfig (void)
 Get a suitable EGLConfig.
 
int InitGbm (int, int, uint32_t, uint64_t)
 Init gbm device and surface.
 

Private Attributes

cVideoRenderm_pRender
 pointer to cVideoRender object
 
int m_fdDrm = -1
 drm file descriptor
 
uint32_t m_connectorId
 connector id
 
drmModeModeInfo m_drmModeInfo
 mode info
 
uint32_t m_crtcId
 current crtc ID
 
uint32_t m_crtcIndex
 current crtc index
 
uint32_t m_hdrMetadata = 0
 property id of HDR_OUTPUT_METADATA
 
drmModeCrtcm_drmModeCrtcSaved
 saved CRTC infos
 
drmEventContext m_drmEventCtx
 drm event context
 
const charm_userDrmDevice = nullptr
 user requested drm device
 
int m_userReqDisplayWidth = 0
 user requested display width
 
int m_userReqDisplayHeight
 user requested display height
 
uint32_t m_userReqDisplayRefreshRate
 user requested display refresh rate
 
bool m_useZpos = false
 is set, if drm hardware can use zpos
 
uint64_t m_zposOverlay = 0
 zpos of overlay plane
 
uint64_t m_zposPrimary = 0
 zpos of primary plane
 
cDrmPlane m_videoPlane
 the video drm plane
 
cDrmPlane m_osdPlane
 the osd drm plane
 
uint64_t m_zposPip = 0
 zpos of pip plane
 
cDrmPlane m_pipPlane
 the pip drm plane
 
struct gbm_devicem_pGbmDevice
 pointer to the gbm device
 
struct gbm_surfacem_pGbmSurface
 pointer to the gbm surface
 
EGLSurface m_eglSurface
 EGL surface.
 
EGLDisplay m_eglDisplay
 EGL display.
 
EGLContext m_eglContext
 EGL context.
 
bool m_glInitiated
 true, if OpenGL/ES context is initiated
 

Detailed Description

DRM Device.

Definition at line 43 of file drmdevice.h.

Constructor & Destructor Documentation

◆ cDrmDevice()

cDrmDevice::cDrmDevice ( cVideoRender render,
const char resolution,
const char device 
)

Create a drm device.

Parameters
renderpointer to cVideoRender object
resolutiondisplay resolution string set by user

Definition at line 47 of file drmdevice.cpp.

References m_userReqDisplayHeight, m_userReqDisplayRefreshRate, and m_userReqDisplayWidth.

◆ ~cDrmDevice()

cDrmDevice::~cDrmDevice ( void  )

Definition at line 55 of file drmdevice.cpp.

References L_DRM, and LOGDEBUG2.

Member Function Documentation

◆ CanHandleHdr()

bool cDrmDevice::CanHandleHdr ( void  )
inline

Definition at line 82 of file drmdevice.h.

References m_hdrMetadata.

Referenced by cVideoRender::CanHandleHdr().

◆ Close()

void cDrmDevice::Close ( void  )

Close the drm file handle.

Definition at line 949 of file drmdevice.cpp.

References L_DRM, LOGDEBUG2, and m_fdDrm.

Referenced by cVideoRender::Exit().

◆ ConnectorId()

uint32_t cDrmDevice::ConnectorId ( void  )
inline

Definition at line 53 of file drmdevice.h.

References m_connectorId.

Referenced by cVideoRender::SetColorSpace().

◆ CreateHdrBlob()

int cDrmDevice::CreateHdrBlob ( struct hdr_output_metadata data,
size_t  size,
uint32_t blobID 
)

Definition at line 1203 of file drmdevice.cpp.

References L_DRM, LOGDEBUG2, and m_fdDrm.

Referenced by cVideoRender::SetHdrBlob().

◆ CreateModeBlob()

int cDrmDevice::CreateModeBlob ( uint32_t modeID)

◆ CreatePropertyBlob()

int cDrmDevice::CreatePropertyBlob ( uint32_t modeID)
private

Wrapper to create a property blob.

Creates a property blob for the drm mode which was found during Init()

Parameters
[out]modeIDid of the blob
Return values
0on success
-errnoon error
Todo:
According to drm logs, this blob must be destroyed by calling drmModeDestroyPropertyBlob which is probably missing

Definition at line 971 of file drmdevice.cpp.

References m_drmModeInfo, and m_fdDrm.

◆ CrtcId()

uint32_t cDrmDevice::CrtcId ( void  )
inline

◆ DestroyHdrBlob()

int cDrmDevice::DestroyHdrBlob ( uint32_t  blobID)

Definition at line 1222 of file drmdevice.cpp.

References m_fdDrm.

Referenced by cVideoRender::SetHdrBlob().

◆ DestroyModeBlob()

int cDrmDevice::DestroyModeBlob ( uint32_t  modeID)

Definition at line 1198 of file drmdevice.cpp.

References m_fdDrm.

Referenced by cVideoRender::RestoreColorSpace(), and cVideoRender::SetColorSpace().

◆ DisplayHeight()

uint64_t cDrmDevice::DisplayHeight ( void  )
inline

◆ DisplayWidth()

uint64_t cDrmDevice::DisplayWidth ( void  )
inline

◆ EglContext()

EGLContext cDrmDevice::EglContext ( void  )
inline

Definition at line 71 of file drmdevice.h.

References m_eglContext.

Referenced by cVideoRender::EglContext().

◆ EglDisplay()

EGLDisplay cDrmDevice::EglDisplay ( void  )
inline

Definition at line 70 of file drmdevice.h.

References m_eglDisplay.

Referenced by cVideoRender::EglDisplay(), cVideoRender::OsdClear(), and cVideoRender::OsdDrawARGB().

◆ EglSurface()

EGLSurface cDrmDevice::EglSurface ( void  )
inline

Definition at line 69 of file drmdevice.h.

References m_eglSurface.

Referenced by cVideoRender::EglSurface(), cVideoRender::OsdClear(), and cVideoRender::OsdDrawARGB().

◆ Fd()

int cDrmDevice::Fd ( void  )
inline

Definition at line 49 of file drmdevice.h.

References m_fdDrm.

Referenced by cVideoRender::Init(), and cVideoRender::PushFrame().

◆ FindCrtcForConnector()

int32_t cDrmDevice::FindCrtcForConnector ( const drmModeRes resources,
const drmModeConnector connector 
)
private

Find the CRTC_ID for the given connector.

Parameters
resourcesdrm resources
connectordrm connector
Returns
CRTC_ID

Definition at line 926 of file drmdevice.cpp.

References FindCrtcForEncoder(), and m_fdDrm.

Referenced by Init().

◆ GbmSurface()

struct gbm_surface * cDrmDevice::GbmSurface ( void  )
inline

Definition at line 73 of file drmdevice.h.

References m_pGbmSurface.

Referenced by cVideoRender::OsdClear(), and cVideoRender::OsdDrawARGB().

◆ GetBufFromBo()

cDrmBuffer * cDrmDevice::GetBufFromBo ( struct gbm_bo bo)

Get a drm buffer from a gbm buffer object.

Parameters
bogbm buffer object
Returns
a drm buffer corresponding to the gbm buffer object

Definition at line 813 of file drmdevice.cpp.

References drm_fb_destroy_callback(), L_DRM, LOGDEBUG2, LOGFATAL, and m_fdDrm.

Referenced by cVideoRender::OsdClear(), and cVideoRender::OsdDrawARGB().

◆ GetPropertyID()

uint32_t cDrmDevice::GetPropertyID ( uint32_t  objectID,
uint32_t  objectType,
const char propName 
)
private

Get a property ID.

Parameters
objectIDdrm object ID
objectTypedrm object type
propNamedrm property name
Returns
the value if found, 0 otherwise

Definition at line 1074 of file drmdevice.cpp.

References L_DRM, LOGDEBUG2, and m_fdDrm.

Referenced by Init().

◆ GetPropertyValue()

int cDrmDevice::GetPropertyValue ( uint32_t  objectID,
uint32_t  objectType,
const char propName,
uint64_t value 
)
private

Get a drm property value.

Parameters
objectIDdrm object ID
objectTypedrm object type
propNamedrm property name
[out]valuevalue for the requested property
Return values
0value was found
-1value was not found

Definition at line 1029 of file drmdevice.cpp.

References L_DRM, LOGDEBUG2, and m_fdDrm.

Referenced by GetVideoPlaneColorRange(), and Init().

◆ GetVideoPlaneColorRange()

int cDrmDevice::GetVideoPlaneColorRange ( uint64_t value)

Definition at line 1178 of file drmdevice.cpp.

References cDrmPlane::GetId(), GetPropertyValue(), and m_videoPlane.

Referenced by cVideoRender::SetHdrBlob().

◆ GlInitiated()

int cDrmDevice::GlInitiated ( void  )
inline

Definition at line 72 of file drmdevice.h.

References m_glInitiated.

Referenced by cVideoRender::GlInitiated().

◆ HandleEvent()

int cDrmDevice::HandleEvent ( void  )

Poll for a drm event.

Return values
0if successful
-1on error

Definition at line 1136 of file drmdevice.cpp.

References m_drmEventCtx, and m_fdDrm.

Referenced by cVideoRender::DrmHandleEvent(), and cVideoRender::PageFlip().

◆ HasPipPlane()

bool cDrmDevice::HasPipPlane ( void  )
inline

Definition at line 66 of file drmdevice.h.

References cDrmPlane::GetId(), and m_pipPlane.

Referenced by cVideoRender::Init().

◆ Init()

◆ InitEGL()

int cDrmDevice::InitEGL ( void  )
private

Init EGL context.

Return values
0on success
-1on error

Definition at line 719 of file drmdevice.cpp.

References context_attribute_list, EGL_CHECK, get_platform_display, get_platform_surface, GetEGLConfig(), L_OPENGL, LOGDEBUG2, LOGERROR, LOGINFO, m_eglContext, m_eglDisplay, m_eglSurface, m_glInitiated, m_pGbmDevice, and m_pGbmSurface.

Referenced by Init().

◆ InitEvent()

void cDrmDevice::InitEvent ( void  )

Init the event context.

Definition at line 1144 of file drmdevice.cpp.

References m_drmEventCtx.

Referenced by cVideoRender::Init().

◆ InitGbm()

int cDrmDevice::InitGbm ( int  w,
int  h,
uint32_t  format,
uint64_t  modifier 
)
private

Init gbm device and surface.

Parameters
wgbm surface width
hgbm surface height
formatgbm pixel format
modifiergbm buffer modifier
Return values
0on success
-1on error

Definition at line 632 of file drmdevice.cpp.

References LOGERROR, m_fdDrm, m_pGbmDevice, and m_pGbmSurface.

Referenced by Init().

◆ ModeAtomicAlloc()

drmModeAtomicReqPtr cDrmDevice::ModeAtomicAlloc ( void  )
inline

◆ ModeAtomicCommit()

int cDrmDevice::ModeAtomicCommit ( drmModeAtomicReqPtr  req,
uint32_t  flags,
void user_data 
)
inline

◆ ModeAtomicFree()

void cDrmDevice::ModeAtomicFree ( drmModeAtomicReqPtr  req)
inline

◆ OsdPlane()

cDrmPlane * cDrmDevice::OsdPlane ( void  )
inline

◆ PipPlane()

cDrmPlane * cDrmDevice::PipPlane ( void  )
inline

Definition at line 65 of file drmdevice.h.

References m_pipPlane.

Referenced by cVideoRender::CommitBuffer(), and cVideoRender::SetPipBuffer().

◆ RestoreCrtc()

void cDrmDevice::RestoreCrtc ( void  )

Restore information of a CRTC.

Definition at line 1121 of file drmdevice.cpp.

References m_connectorId, m_drmModeCrtcSaved, and m_fdDrm.

Referenced by cVideoRender::Exit().

◆ SaveCrtc()

void cDrmDevice::SaveCrtc ( void  )

Save information of a CRTC.

Definition at line 1113 of file drmdevice.cpp.

References m_crtcId, m_drmModeCrtcSaved, and m_fdDrm.

Referenced by cVideoRender::Init().

◆ SetConnectorColorspace()

int cDrmDevice::SetConnectorColorspace ( drmModeAtomicReqPtr  modeReq,
uint32_t  id 
)

◆ SetConnectorCrtcId()

int cDrmDevice::SetConnectorCrtcId ( drmModeAtomicReqPtr  modeReq)

◆ SetConnectorHdrBlobProperty()

int cDrmDevice::SetConnectorHdrBlobProperty ( uint32_t  blobID)

Definition at line 1212 of file drmdevice.cpp.

References L_DRM, LOGDEBUG2, m_connectorId, m_fdDrm, and m_hdrMetadata.

Referenced by cVideoRender::SetHdrBlob().

◆ SetConnectorHdrOutputMetadata()

int cDrmDevice::SetConnectorHdrOutputMetadata ( drmModeAtomicReqPtr  modeReq,
uint32_t  id 
)

Definition at line 1158 of file drmdevice.cpp.

References m_connectorId, and SetPropertyRequest().

Referenced by cVideoRender::RestoreColorSpace().

◆ SetCrtcActive()

int cDrmDevice::SetCrtcActive ( drmModeAtomicReqPtr  modeReq,
uint32_t  id 
)

◆ SetCrtcModeId()

int cDrmDevice::SetCrtcModeId ( drmModeAtomicReqPtr  modeReq,
uint32_t  id 
)

◆ SetPropertyRequest()

int cDrmDevice::SetPropertyRequest ( drmModeAtomicReqPtr  ModeReq,
uint32_t  objectID,
uint32_t  objectType,
const char propName,
uint64_t  value 
)
private

Add a drm property to an atomic modeset request.

Parameters
ModeReqatomic request object
objectIDdrm object id
objectTypedrm object type
propNamename of the drm property to be set
valuethe value, the drm property should get
Returns
negative value on errors, otherwise the number of properties in the atomic request

Definition at line 987 of file drmdevice.cpp.

References L_DRM, LOGDEBUG2, and m_fdDrm.

Referenced by SetConnectorColorspace(), SetConnectorCrtcId(), SetConnectorHdrOutputMetadata(), SetCrtcActive(), SetCrtcModeId(), SetVideoPlaneColorEncoding(), and SetVideoPlaneColorRange().

◆ SetVideoPlaneColorEncoding()

int cDrmDevice::SetVideoPlaneColorEncoding ( drmModeAtomicReqPtr  modeReq,
uint32_t  id 
)

◆ SetVideoPlaneColorRange()

int cDrmDevice::SetVideoPlaneColorRange ( drmModeAtomicReqPtr  modeReq,
uint32_t  id 
)

◆ UseZpos()

int cDrmDevice::UseZpos ( void  )
inline

Definition at line 59 of file drmdevice.h.

References m_useZpos.

Referenced by cVideoRender::Init(), and cVideoRender::SetOsdBuffer().

◆ VideoPlane()

◆ ZposOverlay()

uint64_t cDrmDevice::ZposOverlay ( void  )
inline

Definition at line 60 of file drmdevice.h.

References m_zposOverlay.

Referenced by cVideoRender::Init(), and cVideoRender::SetOsdBuffer().

◆ ZposPrimary()

uint64_t cDrmDevice::ZposPrimary ( void  )
inline

Definition at line 61 of file drmdevice.h.

References m_zposPrimary.

Referenced by cVideoRender::Init(), and cVideoRender::SetOsdBuffer().

Member Data Documentation

◆ m_connectorId

uint32_t cDrmDevice::m_connectorId
private

◆ m_crtcId

uint32_t cDrmDevice::m_crtcId
private

current crtc ID

Definition at line 108 of file drmdevice.h.

Referenced by CrtcId(), Init(), SaveCrtc(), SetConnectorCrtcId(), SetCrtcActive(), and SetCrtcModeId().

◆ m_crtcIndex

uint32_t cDrmDevice::m_crtcIndex
private

current crtc index

Definition at line 109 of file drmdevice.h.

Referenced by Init().

◆ m_drmEventCtx

drmEventContext cDrmDevice::m_drmEventCtx
private

drm event context

Definition at line 112 of file drmdevice.h.

Referenced by HandleEvent(), and InitEvent().

◆ m_drmModeCrtcSaved

drmModeCrtc* cDrmDevice::m_drmModeCrtcSaved
private

saved CRTC infos

Definition at line 111 of file drmdevice.h.

Referenced by RestoreCrtc(), and SaveCrtc().

◆ m_drmModeInfo

drmModeModeInfo cDrmDevice::m_drmModeInfo
private

mode info

Definition at line 107 of file drmdevice.h.

Referenced by CreateModeBlob(), CreatePropertyBlob(), DisplayHeight(), DisplayWidth(), and Init().

◆ m_eglContext

EGLContext cDrmDevice::m_eglContext
private

EGL context.

Definition at line 139 of file drmdevice.h.

Referenced by EglContext(), and InitEGL().

◆ m_eglDisplay

EGLDisplay cDrmDevice::m_eglDisplay
private

EGL display.

Definition at line 138 of file drmdevice.h.

Referenced by EglDisplay(), GetEGLConfig(), and InitEGL().

◆ m_eglSurface

EGLSurface cDrmDevice::m_eglSurface
private

EGL surface.

Definition at line 137 of file drmdevice.h.

Referenced by EglSurface(), and InitEGL().

◆ m_fdDrm

◆ m_glInitiated

bool cDrmDevice::m_glInitiated
private

true, if OpenGL/ES context is initiated

Definition at line 140 of file drmdevice.h.

Referenced by GlInitiated(), and InitEGL().

◆ m_hdrMetadata

uint32_t cDrmDevice::m_hdrMetadata = 0
private

property id of HDR_OUTPUT_METADATA

Definition at line 110 of file drmdevice.h.

Referenced by CanHandleHdr(), Init(), and SetConnectorHdrBlobProperty().

◆ m_osdPlane

cDrmPlane cDrmDevice::m_osdPlane
private

the osd drm plane

Definition at line 123 of file drmdevice.h.

Referenced by Init(), and OsdPlane().

◆ m_pGbmDevice

struct gbm_device* cDrmDevice::m_pGbmDevice
private

pointer to the gbm device

Definition at line 134 of file drmdevice.h.

Referenced by InitEGL(), and InitGbm().

◆ m_pGbmSurface

struct gbm_surface* cDrmDevice::m_pGbmSurface
private

pointer to the gbm surface

Definition at line 135 of file drmdevice.h.

Referenced by GbmSurface(), InitEGL(), and InitGbm().

◆ m_pipPlane

cDrmPlane cDrmDevice::m_pipPlane
private

the pip drm plane

Definition at line 125 of file drmdevice.h.

Referenced by HasPipPlane(), Init(), and PipPlane().

◆ m_pRender

cVideoRender* cDrmDevice::m_pRender
private

pointer to cVideoRender object

Definition at line 103 of file drmdevice.h.

Referenced by Init().

◆ m_userDrmDevice

const char* cDrmDevice::m_userDrmDevice = nullptr
private

user requested drm device

Definition at line 114 of file drmdevice.h.

Referenced by Init().

◆ m_userReqDisplayHeight

int cDrmDevice::m_userReqDisplayHeight
private

user requested display height

Definition at line 116 of file drmdevice.h.

Referenced by cDrmDevice(), and Init().

◆ m_userReqDisplayRefreshRate

uint32_t cDrmDevice::m_userReqDisplayRefreshRate
private

user requested display refresh rate

Definition at line 117 of file drmdevice.h.

Referenced by cDrmDevice(), and Init().

◆ m_userReqDisplayWidth

int cDrmDevice::m_userReqDisplayWidth = 0
private

user requested display width

Definition at line 115 of file drmdevice.h.

Referenced by cDrmDevice(), and Init().

◆ m_useZpos

bool cDrmDevice::m_useZpos = false
private

is set, if drm hardware can use zpos

Definition at line 119 of file drmdevice.h.

Referenced by Init(), and UseZpos().

◆ m_videoPlane

cDrmPlane cDrmDevice::m_videoPlane
private

the video drm plane

Definition at line 122 of file drmdevice.h.

Referenced by GetVideoPlaneColorRange(), Init(), SetVideoPlaneColorEncoding(), SetVideoPlaneColorRange(), and VideoPlane().

◆ m_zposOverlay

uint64_t cDrmDevice::m_zposOverlay = 0
private

zpos of overlay plane

Definition at line 120 of file drmdevice.h.

Referenced by Init(), and ZposOverlay().

◆ m_zposPip

uint64_t cDrmDevice::m_zposPip = 0
private

zpos of pip plane

Definition at line 124 of file drmdevice.h.

Referenced by Init().

◆ m_zposPrimary

uint64_t cDrmDevice::m_zposPrimary = 0
private

zpos of primary plane

Definition at line 121 of file drmdevice.h.

Referenced by Init(), and ZposPrimary().


The documentation for this class was generated from the following files: