Jetson Linux API Reference

32.7.5 Release
NvDrmRenderer Class Reference

Detailed Description

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.

Inheritance diagram for NvDrmRenderer:
Collaboration diagram for NvDrmRenderer:

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 NvDrmRenderercreateDrmRenderer (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...
 

Constructor & Destructor Documentation

◆ ~NvDrmRenderer()

NvDrmRenderer::~NvDrmRenderer ( )

Member Function Documentation

◆ createDrmRenderer()

static NvDrmRenderer* 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 
)
static

Creates a new DRM based renderer named name.

Parameters
[in]nameUnique name to identity the element instance.
[in]widthWidth of the window in pixels.
[in]heightHeight of the window in pixels.
[in]w_xx offset of window location.
[in]w_yy offset of window location.
[in]connectorIndex of connector to use.
[in]crtcIndex of CRTC to use.
[in]metadataContains HDR metadata.
[in]streamHDRFlag indicating that current stream has HDR metadata, and hence metadata is set.
Returns
Reference to the newly created renderer object if successful, or NULL if initialization failed.

◆ createDumbFB()

uint32_t NvDrmRenderer::createDumbFB ( uint32_t  width,
uint32_t  height,
uint32_t  drm_format,
NvDrmFB fb 
)

Allocates a framebuffer of size (w, h).

Postcondition
If the call is successful, the application must remove (free) the framebuffer by calling removeFB().
Parameters
[in]widthFramebuffer width in pixels.
[in]heightFramebuffer height in pixels.
[in]drm_formatDRM format of _NvDrmBO::bo_handle in *fb.
[out]fbA pointer to an NvDrmFB structure that contains the fb_id and the buffer mapping.
Returns
1 if successful, or 0 otherwise.

◆ dequeBuffer()

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.

Returns
File descriptor of the previously rendered buffer.

◆ drmUtilCloseGemBo()

int NvDrmRenderer::drmUtilCloseGemBo ( int  fd,
uint32_t  bo_handle 
)

Close GEM (Graphics Execution Manager) handles.

Parameters
fdFD of the buffer.
bo_handlethe gem-handle to be closed.
Returns
1 for success, 0 for failure.

◆ enableProfiling()

virtual void NvElement::enableProfiling ( )
virtualinherited

Enables profiling for the element.

Reimplemented in NvV4l2Element.

◆ enableUniversalPlanes()

bool NvDrmRenderer::enableUniversalPlanes ( int  enable)

Enables/disables DRM universal planes client caps, such as DRM_CLIENT_CAP_UNIVERSAL_PLANES.

Parameters
[in]enable1 to enable the caps, or 0 to disable.
Returns
true if successful, or false otherwise.

◆ enqueBuffer()

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.

Parameters
[in]fdFile descriptor of the exported buffer to render.
Returns
0 if successful, or -1 otherwise.

◆ getCrtcCount()

int NvDrmRenderer::getCrtcCount ( )

Gets count of available CRTCs.

Returns
Count of available CRTCs.

◆ getEncoderCount()

int NvDrmRenderer::getEncoderCount ( )

Gets count of available encoders.

Returns
Count of available encoders.

◆ getPlaneCount()

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.

Returns
Count of total planes available.

◆ getPlaneIndex()

int NvDrmRenderer::getPlaneIndex ( uint32_t  crtc_index,
int32_t *  plane_index 
)

Gets the plane indexes supported by the given crtc index.

Parameters
[in]crtc_indexIndex of crtc for which the plane indexes to be found.
[in,out]plane_indexPointer 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.
Returns
Count of the indexes written in the given array.

◆ getProfilingData()

void NvElement::getProfilingData ( NvElementProfiler::NvElementProfilerData data)
inherited

Gets profiling data for the element.

Returns
A constant reference to the element's profiling data.

◆ hdrSupported()

bool NvDrmRenderer::hdrSupported ( )

Checks whether HDR mode is supported on the DRM renderer.

Returns
True if HDR mode is supported, or false otherwise.

◆ isInError()

virtual int NvElement::isInError ( )
inlinevirtualinherited

Indicates whether the element encountered an error during its operation.

Returns
0 if no error was encountered, a non-zero value if an error was encountered.

Reimplemented in NvV4l2Element.

Definition at line 72 of file NvElement.h.

References NvElement::is_in_error.

◆ isProfilingEnabled()

bool NvElement::isProfilingEnabled ( )
inherited

Checks whether profiling is enabled for the element.

Returns
Boolean value indicating if profiling is enabled.

◆ printProfilingStats()

void NvElement::printProfilingStats ( std::ostream &  out_stream = std::cout)
inherited

Prints profiling data for the element to an output stream.

Parameters
[in]out_streamOutput stream of type std::ostream to print the data to. It takes the default value std::cout if not specified.

◆ removeFB()

int NvDrmRenderer::removeFB ( uint32_t  fb_id)

Destroys (frees) a framebuffer previously allocated by createDumbFB().

Parameters
fb_idID of the framebuffer to be destroyed.
Returns
0 if the framebuffer is successfully destroyed, or -ENOENT if the framebuffer is not found.

◆ setFPS()

int NvDrmRenderer::setFPS ( float  fps)

Sets the rendering rate.

Warning
fps may not be set to zero.
Parameters
[in]fpsRendering rate in frames per second.
Returns
0 if successful, or -1 otherwise.

◆ setHDRMetadataSmpte2086()

int NvDrmRenderer::setHDRMetadataSmpte2086 ( struct drm_tegra_hdr_metadata_smpte_2086  )

Sets the HDR metadata retrieved from the decoder.

Returns
0 if successful, or -1 otherwise.

◆ setPlane()

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.

Note
The crtc_... and src_... parameters accept the special input value -1, which indicates that the hardware offset value is not to be changed. (Kernel-based DRM drivers return the error code -ERANGE when given this value.)
All setPlane() operations are synced to vblank and are blocking.
Parameters
pl_indexPlane index of the plane to be changed.
fb_idFramebuffer ID of the framebuffer to display on the plane, or -1 to leave the framebuffer unchanged.
crtc_xOffset from left of active display region to show plane.
crtc_yOffset from top of active display region to show plane.
crtc_wWidth of output rectangle on display.
crtc_hHeight of output rectangle on display.
src_xClip offset from left of source framebuffer (Q16.16 fixed point).
src_yClip offset from top of source framebuffer (Q16.16 fixed point).
src_wWidth of source rectangle (Q16.16 fixed point).
src_hHeight of source rectangle (Q16.16 fixed point).
Return values
0if successful.
-EINVALif pl_index is invalid.
-errnootherwise.

Field Documentation

◆ comp_name

const char* NvElement::comp_name
protectedinherited

Specifies the name of the component, for debugging.

Definition at line 122 of file NvElement.h.

◆ is_in_error

int NvElement::is_in_error
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().

◆ profiler

NvElementProfiler NvElement::profiler
protectedinherited

Profiler for the element.

Definition at line 124 of file NvElement.h.


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