Helper class for rendering using LibDRM.
The renderer requires the file descriptor of a buffer as input. The caller must set the rendering rate in frames per second (FPS).
The caller specifies the width, height, connector, and CRTC index. Based on the connector and CRTC index, the renderer finds a suitable encoder and configures the CRTC mode.
Definition at line 67 of file NvDrmRenderer.h.
Public Member Functions | |
~NvDrmRenderer () | |
int | enqueBuffer (int fd) |
Enqueues a buffer file descriptor for rendering. More... | |
int | dequeBuffer () |
Dequeues a previously rendered buffer. More... | |
int | setFPS (float fps) |
Sets the rendering rate. More... | |
bool | enableUniversalPlanes (int enable) |
Enables/disables DRM universal planes client caps, such as DRM_CLIENT_CAP_UNIVERSAL_PLANES . More... | |
uint32_t | createDumbFB (uint32_t width, uint32_t height, uint32_t drm_format, NvDrmFB *fb) |
Allocates a framebuffer of size (w, h). More... | |
int | removeFB (uint32_t fb_id) |
Destroys (frees) a framebuffer previously allocated by createDumbFB(). More... | |
int | drmUtilCloseGemBo (int fd, uint32_t bo_handle) |
Close GEM (Graphics Execution Manager) handles. More... | |
int | setPlane (uint32_t pl_index, uint32_t fb_id, uint32_t crtc_x, uint32_t crtc_y, uint32_t crtc_w, uint32_t crtc_h, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h) |
Changes a plane's framebuffer and position. More... | |
int | getPlaneCount () |
Gets total number of planes available. More... | |
int | getPlaneIndex (uint32_t crtc_index, int32_t *plane_index) |
Gets the plane indexes supported by the given crtc index. More... | |
int | getCrtcCount () |
Gets count of available CRTCs. More... | |
int | getEncoderCount () |
Gets count of available encoders. More... | |
bool | hdrSupported () |
Checks whether HDR mode is supported on the DRM renderer. More... | |
int | setHDRMetadataSmpte2086 (struct drm_tegra_hdr_metadata_smpte_2086) |
Sets the HDR metadata retrieved from the decoder. More... | |
virtual int | isInError () |
Indicates whether the element encountered an error during its operation. More... | |
void | getProfilingData (NvElementProfiler::NvElementProfilerData &data) |
Gets profiling data for the element. More... | |
void | printProfilingStats (std::ostream &out_stream=std::cout) |
Prints profiling data for the element to an output stream. More... | |
virtual void | enableProfiling () |
Enables profiling for the element. More... | |
bool | isProfilingEnabled () |
Checks whether profiling is enabled for the element. More... | |
Static Public Member Functions | |
static NvDrmRenderer * | createDrmRenderer (const char *name, uint32_t width, uint32_t height, uint32_t w_x, uint32_t w_y, uint32_t connector, uint32_t crtc, struct drm_tegra_hdr_metadata_smpte_2086 metadata, bool streamHDR) |
Creates a new DRM based renderer named name. More... | |
Protected Attributes | |
int | is_in_error |
Indicates if an error was encountered during the operation of the element. More... | |
const char * | comp_name |
Specifies the name of the component, for debugging. More... | |
NvElementProfiler | profiler |
Profiler for the element. More... | |
NvDrmRenderer::~NvDrmRenderer | ( | ) |
|
static |
Creates a new DRM based renderer named name.
[in] | name | Unique name to identity the element instance. |
[in] | width | Width of the window in pixels. |
[in] | height | Height of the window in pixels. |
[in] | w_x | x offset of window location. |
[in] | w_y | y offset of window location. |
[in] | connector | Index of connector to use. |
[in] | crtc | Index of CRTC to use. |
[in] | metadata | Contains HDR metadata. |
[in] | streamHDR | Flag indicating that current stream has HDR metadata, and hence metadata is set. |
uint32_t NvDrmRenderer::createDumbFB | ( | uint32_t | width, |
uint32_t | height, | ||
uint32_t | drm_format, | ||
NvDrmFB * | fb | ||
) |
Allocates a framebuffer of size (w, h).
[in] | width | Framebuffer width in pixels. |
[in] | height | Framebuffer height in pixels. |
[in] | drm_format | DRM format of _NvDrmBO::bo_handle in *fb. |
[out] | fb | A pointer to an NvDrmFB structure that contains the fb_id and the buffer mapping. |
int NvDrmRenderer::dequeBuffer | ( | ) |
Dequeues a previously rendered buffer.
This is blocking function that waits until a free buffer is available. The renderer retains one buffer, which must not be overwritten by any other component. This buffer can be used when the renderer is closed or after sending an EOS to the component.
int NvDrmRenderer::drmUtilCloseGemBo | ( | int | fd, |
uint32_t | bo_handle | ||
) |
Close GEM (Graphics Execution Manager) handles.
fd | FD of the buffer. |
bo_handle | the gem-handle to be closed. |
|
virtualinherited |
Enables profiling for the element.
Reimplemented in NvV4l2Element.
bool NvDrmRenderer::enableUniversalPlanes | ( | int | enable | ) |
Enables/disables DRM universal planes client caps, such as DRM_CLIENT_CAP_UNIVERSAL_PLANES
.
[in] | enable | 1 to enable the caps, or 0 to disable. |
int NvDrmRenderer::enqueBuffer | ( | int | fd | ) |
Enqueues a buffer file descriptor for rendering.
This is a non-blocking call. The function waits for the estimated rendering time of the next buffer. The estimated rendering time is calculated based on the rendering time of the last buffer and the rendering rate.
[in] | fd | File descriptor of the exported buffer to render. |
int NvDrmRenderer::getCrtcCount | ( | ) |
Gets count of available CRTCs.
int NvDrmRenderer::getEncoderCount | ( | ) |
Gets count of available encoders.
int NvDrmRenderer::getPlaneCount | ( | ) |
Gets total number of planes available.
By default, the count returned includes only "Overlay" type (regular) planes—not "Primary" and "Cursor" planes. If DRM_CLIENT_CAP_UNIVERSAL_PLANES
has been enabled with enableUniversalPlanes(), the count returned includes "Primary" and "Cursor" planes as well.
int NvDrmRenderer::getPlaneIndex | ( | uint32_t | crtc_index, |
int32_t * | plane_index | ||
) |
Gets the plane indexes supported by the given crtc index.
[in] | crtc_index | Index of crtc for which the plane indexes to be found. |
[in,out] | plane_index | Pointer to an array which contains plane indexes. This array should be allocated by the caller for the size of plane count returned by getPlaneCount() API. |
|
inherited |
Gets profiling data for the element.
bool NvDrmRenderer::hdrSupported | ( | ) |
Checks whether HDR mode is supported on the DRM renderer.
|
inlinevirtualinherited |
Indicates whether the element encountered an error during its operation.
Reimplemented in NvV4l2Element.
Definition at line 72 of file NvElement.h.
References NvElement::is_in_error.
|
inherited |
Checks whether profiling is enabled for the element.
|
inherited |
Prints profiling data for the element to an output stream.
[in] | out_stream | Output stream of type std::ostream to print the data to. It takes the default value std::cout if not specified. |
int NvDrmRenderer::removeFB | ( | uint32_t | fb_id | ) |
Destroys (frees) a framebuffer previously allocated by createDumbFB().
fb_id | ID of the framebuffer to be destroyed. |
-ENOENT
if the framebuffer is not found. int NvDrmRenderer::setFPS | ( | float | fps | ) |
Sets the rendering rate.
[in] | fps | Rendering rate in frames per second. |
int NvDrmRenderer::setHDRMetadataSmpte2086 | ( | struct drm_tegra_hdr_metadata_smpte_2086 | ) |
Sets the HDR metadata retrieved from the decoder.
int NvDrmRenderer::setPlane | ( | uint32_t | pl_index, |
uint32_t | fb_id, | ||
uint32_t | crtc_x, | ||
uint32_t | crtc_y, | ||
uint32_t | crtc_w, | ||
uint32_t | crtc_h, | ||
uint32_t | src_x, | ||
uint32_t | src_y, | ||
uint32_t | src_w, | ||
uint32_t | src_h | ||
) |
Changes a plane's framebuffer and position.
-ERANGE
when given this value.)setPlane
() operations are synced to vblank and are blocking.pl_index | Plane index of the plane to be changed. |
fb_id | Framebuffer ID of the framebuffer to display on the plane, or -1 to leave the framebuffer unchanged. |
crtc_x | Offset from left of active display region to show plane. |
crtc_y | Offset from top of active display region to show plane. |
crtc_w | Width of output rectangle on display. |
crtc_h | Height of output rectangle on display. |
src_x | Clip offset from left of source framebuffer (Q16.16 fixed point). |
src_y | Clip offset from top of source framebuffer (Q16.16 fixed point). |
src_w | Width of source rectangle (Q16.16 fixed point). |
src_h | Height of source rectangle (Q16.16 fixed point). |
0 | if successful. |
-EINVAL | if pl_index is invalid. |
-errno | otherwise. |
|
protectedinherited |
Specifies the name of the component, for debugging.
Definition at line 122 of file NvElement.h.
|
protectedinherited |
Indicates if an error was encountered during the operation of the element.
Definition at line 120 of file NvElement.h.
Referenced by NvElement::isInError().
|
protectedinherited |
Profiler for the element.
Definition at line 124 of file NvElement.h.