drm-node
Header: kmsroots/drm-node.h
Table of contents (click to go)
Macros
Enums
Unions
Structs
Functions
Function Pointers
API Documentation
kmr_drm_node
-
struct kmr_drm_node
-
int kmsfd;
-
struct kmr_session *session;
kmsfd- A valid file descriptor to an open DRI device node
Only included if libseat is used
session- Stores address of
structkmr_session. Used whenopening and releasing a device.
-
int kmsfd;
kmr_drm_node_create_info
-
struct kmr_drm_node_create_info
-
const char *kmsNode;
-
struct kmr_session *session;
kmsNode- Path to character device associated with GPU. If set to NULL. List ofavailable kmsnode’s will be queried and one will be automaticallychoosen for you.
Only included if libseat is used
session- Address of
structkmr_session. Which members areused to communicate with systemd-logind via D-Bus systemd-logindinterface. Needed bykmr_drm_node_create()to acquire and takencontrol of a device without the need of being root.
-
const char *kmsNode;
kmr_drm_node_create
-
struct kmr_drm_node *kmr_drm_node_create(struct kmr_drm_node_create_info *nodeInfo);
Function opens a DRI device node. If a systemd-logind session available one can take control of a device node. Returned fd is exposed to all planes (overlay, primary, and cursor) and has access to the aspect ratio information in modes in userspace. In order to drive KMS, we need to be ‘master’. Function fails if we aren’t DRM-Master more info here: DRM-Master and DRM-Auth. So, if a graphical session is already active on the current VT this function will fail.
- Parameters:
- nodeInfoPointer to a
structkmr_drm_node_create_infoused to pass a DRI/KMSdevice file that we may want to use and to store information aboutthe current seatd/sytemd-logind D-bus session. - Returns:
- on success: Pointer to a
structkmr_drm_nodeon failure: NULL
kmr_drm_node_destroy
-
void kmr_drm_node_destroy(struct kmr_drm_node *node);
Frees any allocated memory and closes FD’s (if open) created after
kmr_drm_node_create()call.- Parameters:
- nodePointer to a valid
structkmr_drm_node
/* Free'd members with fd's closed */ struct kmr_drm_node { int kmsfd; }
kmr_drm_node_device_capabilites
-
struct kmr_drm_node_device_capabilites
-
bool CAP_ADDFB2_MODIFIERS;
-
bool CAP_TIMESTAMP_MONOTONIC;
-
bool CAP_CRTC_IN_VBLANK_EVENT;
-
bool CAP_DUMB_BUFFER;
More information can be found at drm uapi
CAP_ADDFB2_MODIFIERS- If set to
true, the driver supports supplying modifiersin theDRM_IOCTL_MODE_ADDFB2ioctl. CAP_TIMESTAMP_MONOTONIC- If set to
false, the kernel will report timestamps withCLOCK_REALTIMEinstructdrm_event_vblank. If set totrue, the kernel willreport timestamps withCLOCK_MONOTONIC. See clock_gettime(2)for the definition of these clocks. CAP_CRTC_IN_VBLANK_EVENT- If set to
true, the kernel supports reporting the CRTC ID indrm_event_vblank.crtc_idfor theDRM_EVENT_VBLANKandDRM_EVENT_FLIP_COMPLETEevents. CAP_DUMB_BUFFER- If set to
true, the driver supports creating dumb buffers viatheDRM_IOCTL_MODE_CREATE_DUMBioctl.
-
bool CAP_ADDFB2_MODIFIERS;
kmr_drm_node_get_device_capabilities
-
struct kmr_drm_node_device_capabilites kmr_drm_node_get_device_capabilities(int kmsfd);
Function takes in a DRM device fd and populates the
structkmr_drm_node_device_capabilitesto give details on what capabilites the particular kms device supports. Function is called bykmr_drm_node_create(), but is exposed to the application developer for their own use.- Parameters:
- kmsfdNumber associated with open KMS device node.
- Returns:
kmr_drm_node_display_object_props_data
kmr_drm_node_display_object_props
-
struct kmr_drm_node_display_object_props
-
uint32_t id;
-
struct kmr_drm_node_display_object_props_data *propsData;
-
uint8_t propsDataCount;
id- Driver assigned ID of the KMS object.
propsData- Stores array of data about the properties of a KMS objectused during KMS atomic operations.
propsDataCount- Array size of
propsData.
-
uint32_t id;
kmr_drm_node_display_mode_data
-
struct kmr_drm_node_display_mode_data
-
id- Stores the highest mode (resolution + refresh) property id.When we perform an atomic commit, the driver expects a CRTCproperty named
"MODE_ID", which points to the id given to oneof connected display resolution & refresh rate. At the moment thehighest mode is choosen. modeInfo- Stores the highest mode data (display resolution + refresh)associated with display.
kmr_drm_node_display
-
struct kmr_drm_node_display
-
int kmsfd;
-
uint16_t width;
-
uint16_t height;
-
clockid_t presClock;
-
struct kmr_drm_node_display_mode_data modeData;
-
struct kmr_drm_node_display_object_props connector;
-
struct kmr_drm_node_display_object_props crtc;
-
struct kmr_drm_node_display_object_props plane;
More information can be found at drm-kms
kmsfd- Pollable file descriptor to an open KMS (GPU) device file.
width- Highest mode (display resolution) width for
connectorattached to display. height- Highest mode (display resolution) width for
connectorattached to display. presClock- Presentation clock stores the type of clock to utilize for fps tracking. Clock willeither be set to CLOCK_MONOTONIC or CLOCK_REALTIME depending upon theSystem/DRM device capabilities. CLOCK_MONOTONIC will return the elapsed timefrom system boot, can only increase, and can’t be manually modified. WhileCLOCK_REALTIME will return the real time system clock as set by the user.This clock can however be modified.
modeData- Stores highest mode (display resolution & refresh) along with the modeid propertyused during KMS atomic operations.
connecter- Anything that can transfer pixels in some form. (i.e HDMI). Connectors canbe hotplugged and unplugged at runtime. Stores connector properties usedduring KMS atomic modesetting and page-flips.
crtc- Represents a part of the chip that contains a pointer to a scanout buffer.Stores crtc properties used during KMS atomic modesetting and page-flips.
plane- A plane represents an image source that can be blended with or overlayed on top ofa CRTC during the scanout process. Planes are associated with a frame buffer to cropa portion of the image memory (source) and optionally scale it to a destination size.The result is then blended with or overlayed on top of a CRTC. Stores primary planeproperties used during KMS atomic modesetting and page-flips.
-
int kmsfd;
kmr_drm_node_display_create_info
kmr_drm_node_display_create
-
struct kmr_drm_node_display *kmr_drm_node_display_create(struct kmr_drm_node_display_create_info *displayInfo);
Function takes in a pointer to a
structkmr_drm_node_display_create_infoand produces one connector->encoder->CRTC->plane display output chain. Populating the members ofstructkmr_drm_node_displaywhose information will be later used in modesetting.- Parameters:
- displayInfoPointer to a
structkmr_drm_node_display_create_infousedto determine what operation will happen in the function - Returns:
- on success: Pointer to a
structkmr_drm_node_displayon failure: NULL
kmr_drm_node_display_destroy
-
void kmr_drm_node_display_destroy(struct kmr_drm_node_display *display);
Frees any allocated memory and closes FD’s (if open) created after
kmr_drm_node_display_create()call.- Parameters:
- displayPointer to a valid
structkmr_drm_node_display
/* Free'd members with fd's closed */ struct kmr_drm_node_display { struct kmr_drm_node_display_object_props connector.propsData; struct kmr_drm_node_display_object_props crtc.propsData; struct kmr_drm_node_display_object_props plane.propsData; }
kmr_drm_node_display_mode_info
kmr_drm_node_display_mode_set
-
int kmr_drm_node_display_mode_set(struct kmr_drm_node_display_mode_info *displayModeInfo);
Sets the display connected to
display->connecterscreen resolution and refresh to the highest possible value.- Parameters:
- displayModeInfoPointer to a
structkmr_drm_node_display_mode_infoused toset highest display mode. - Returns:
- on success: 0on failure: -1
kmr_drm_node_display_mode_reset
-
int kmr_drm_node_display_mode_reset(struct kmr_drm_node_display_mode_info *displayModeInfo);
Clears the current display mode setting
- Parameters:
- displayModeInfoPointer to a
structkmr_drm_node_display_mode_infoused toset highest display mode. - Returns:
- on success: 0on failure: -1
kmr_drm_node_renderer_impl
-
void kmr_drm_node_renderer_impl(volatile bool*, uint8_t*, int*, void*);
typedef void (*kmr_drm_node_renderer_impl)(volatile bool*, uint8_t*, int*, void*);
Function pointer used by
structkmr_drm_node_atomic_request_create_infoused to pass the address of an external function you want to run Given that the arguments of the function are:- volatile bool *
- A pointer to a boolean determining if the renderer is running.Used to exit rendering operations.
- uint8_t *
- A pointer to an unsigned 8 bit integer determining current bufferGBM/DUMP buffer being used.
- int *
- A pointer to an integer storing KMS framebuffer ID associated withthe GBM(GEM DMA Buf) or DUMP buffer. Used by the implementationduring atomic modesetting operations.
- void *
- A pointer to any arbitrary data the custom renderer may want passduring rendering operations.
kmr_drm_node_atomic_request
-
struct kmr_drm_node_atomic_request
-
atomicRequest- Pointer to a KMS atomic request instance
rendererInfo- Used by the implementation to free data. DO NOT MODIFY.
kmr_drm_node_atomic_request_create_info
-
struct kmr_drm_node_atomic_request_create_info
-
int kmsfd;
-
struct kmr_drm_node_display *display;
-
kmr_drm_node_renderer_impl renderer;
-
volatile bool *rendererRunning;
-
uint8_t *rendererCurrentBuffer;
-
int *rendererFbId;
-
void *rendererData;
kmsfd- File descriptor to an open KMS device node.
display- Pointer to a struct containing all plane->crtc->connector data used duringKMS atomic mode setting.
renderer- Function pointer that allows custom external renderers to be executed by the apiupon
kmsfdpolled events. rendererRunning- Pointer to a boolean that determines if a given renderer is running and in needof stopping.
rendererCurrentBuffer- Pointer to an integer used by the api to update the current displayable buffer.
rendererFbId- Pointer to an integer used as the value of the
"FB_ID"property for a planerelated to the CRTC during the atomic modeset operation. rendererData- Pointer to an optional address. This address may be the address of a struct.Reference/Address passed depends on external renderer function.
-
int kmsfd;
kmr_drm_node_atomic_request_create
-
struct kmr_drm_node_atomic_request *kmr_drm_node_atomic_request_create(struct kmr_drm_node_atomic_request_create_info *atomicInfo);
Function creates a KMS atomic request instance. Sets the interface that allows callers of API to setup custom renderer implementation. Performs the initial modeset operation. After all the application needs to do is wait for page-flip events to happen.
- Parameters:
- atomicInfoPointer to a
structkmr_drm_node_atomic_request_create_infoused to setexternal renderer and arguments of the external renderer. - Returns:
- on success: pointer to a
structkmr_drm_node_atomic_requeston failure: NULL
kmr_drm_node_atomic_request_destroy
-
void kmr_drm_node_atomic_request_destroy(struct kmr_drm_node_atomic_request *atomic);
Frees any allocated memory and closes FD’s (if open) created after
kmr_drm_node_atomic_request_create()call.- Parameters:
- atomicPointer to a valid
structkmr_drm_node_atomic_request/* Free'd members */ struct kmr_drm_node_atomic_request { drmModeAtomicReq *atomicRequest; void *rendererInfo; }
kmr_drm_node_handle_drm_event_info
kmr_drm_node_handle_drm_event
-
int kmr_drm_node_handle_drm_event(struct kmr_drm_node_handle_drm_event_info *eventInfo);
Function calls drmHandleEvent(3) which processes outstanding DRM events on the DRM file-descriptor. This function should be called after the DRM file-descriptor has polled readable.
- Parameters:
- eventInfoPointer to a
structkmr_drm_node_handle_drm_event_info - Returns:
- on success: 0om failure: -1