L4T Multimedia API Reference

31.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NvDrmRenderer Class Reference

Detailed Description

Helper class for rendering using LibDRM.

The renderer requires the fd of a buffer as an input. The caller must set the rendering rate, in terms of frames per second (FPS).

The caller specifies the width, height connector and crtc index. Based on connector and crtc index, the renderer finds a suitable encoder and configures the crtc mode.

Definition at line 66 of file NvDrmRenderer.h.

Inheritance diagram for NvDrmRenderer:
Collaboration diagram for NvDrmRenderer:

Public Member Functions

 ~NvDrmRenderer ()
 
int enqueBuffer (int fd)
 Enqueues a buffer fd for rendering. More...
 
int dequeBuffer ()
 Dequeues a previously rendered buffer. More...
 
int setFPS (float fps)
 Sets the rendering rate in terms of frames per second. 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 a framebuffer. 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 getCrtcCount ()
 Gets count of available crtcs. More...
 
int getEncoderCount ()
 Gets count of available encoders. More...
 
bool hdrSupported ()
 Checks if 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 ( )

Member Function Documentation

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 indicates that current stream has HDR metadata hence set HDR metadata.
Returns
Reference to the newly created renderer object else NULL in case of failure during initialization.
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 the bo_handle(s).
[out]fbA pointer to an NvDrmFB structure that contains the fb_id and the buffer mapping.
Returns
1 for success, 0 for failure.
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 last buffer can be used when the renderer is closed or after sending an EOS to the component.

Returns
fd of the previously rendered buffer.
virtual void NvElement::enableProfiling ( )
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.

Parameters
[in]enable1 or 0 to enable/disable the caps.
Returns
true for success and false for failure.
int NvDrmRenderer::enqueBuffer ( int  fd)

Enqueues a buffer fd for rendering.

This is a non-blocking call. This function waits until the rendering time of the next buffer. The rendering time is calculated based on the rendering time of the last buffer and the rendering rate fps.

Parameters
[in]fdFD of the exported buffer to render.
Returns
0 for success, -1 for failure
int NvDrmRenderer::getCrtcCount ( )

Gets count of available crtcs.

Returns
Count of available CRTCs.
int NvDrmRenderer::getEncoderCount ( )

Gets count of available encoders.

Returns
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.

Returns
Count of total planes available.
void NvElement::getProfilingData ( NvElementProfiler::NvElementProfilerData data)
inherited

Gets profiling data for the element.

Returns
A constant reference to the element's profiling data.
bool NvDrmRenderer::hdrSupported ( )

Checks if HDR mode is supported on the DRM renderer.

Returns
True if HDR supported else false.
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.

bool NvElement::isProfilingEnabled ( )
inherited

Checks whether profiling is enabled for the element.

Returns
Boolean value indicating if profiling is enabled.
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.
int NvDrmRenderer::removeFB ( uint32_t  fb_id)

Destroys a framebuffer.

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

Parameters
fb_idThe ID of the framebuffer to destroy.
Returns
0 if destruction is successful, or -ENOENT if the framebuffer is not found.
int NvDrmRenderer::setFPS ( float  fps)

Sets the rendering rate in terms of frames per second.

Warning
fps of zero is not allowed
Parameters
[in]fpsRender rate in terms of frames per second
Returns
0 for success, -1 for failure
int NvDrmRenderer::setHDRMetadataSmpte2086 ( struct drm_tegra_hdr_metadata_smpte_2086  )

Sets the HDR metadata retrieved from the decoder.

Returns
0 is successful else -1.
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

const char* NvElement::comp_name
protectedinherited

Specifies the name of the component, for debugging.

Definition at line 122 of file NvElement.h.

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

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: