NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release

Detailed Description

The 2D stream API offers a stream-like interface for handling synchronization with NvMedia 2D. The user can push fences to be waited on and tasks to be executed to the stream, and request a fence to be signaled at any point of the stream. The stream will wait on the fences and execute the tasks in the order they are pushed. The fences requested will be signaled when all of the preceding fence waits and tasks have completed. The benefit of using the 2D Stream API is that it decouples the synchronization from processing of individual tasks, allowing for more flexible usage.

Typedefs

typedef struct NvMedia2DStream NvMedia2DStream
 An object representing a stream. More...
 

Functions

NvMediaStatus NvMedia2DStreamCreate (NvMedia2DStream **const stream, NvMedia2D *const ctx, NvSciSyncObj const syncObj)
 Create a new stream. More...
 
NvMediaStatus NvMedia2DStreamDestroy (NvMedia2DStream *const stream)
 Destroy a stream. More...
 
NvMediaStatus NvMedia2DStreamPushFenceWait (NvMedia2DStream *const stream, NvSciSyncFence const *const syncFence)
 Push a fence wait to the stream. More...
 
NvMediaStatus NvMedia2DStreamPushTask (NvMedia2DStream *const stream, NvMedia2DComposeParameters const taskParams, NvMedia2DComposeResult *const taskResult)
 Push a task to the stream. More...
 
NvMediaStatus NvMedia2DStreamRequestFence (NvMedia2DStream *const stream, NvSciSyncFence *const syncFence)
 Request a fence from the stream. More...
 

Typedef Documentation

◆ NvMedia2DStream

An object representing a stream.


Usage considerations

  • Maturity: GA

Definition at line 49 of file nvmedia_2d_stream.h.

Function Documentation

◆ NvMedia2DStreamCreate()

NvMediaStatus NvMedia2DStreamCreate ( NvMedia2DStream **const  stream,
NvMedia2D *const  ctx,
NvSciSyncObj const  syncObj 
)

Create a new stream.

Parameters
[out]streamThe stream.
[in]ctxThe NvMedia2D context to use for the stream. The tasks pushed to the stream will be executed using this context. The caller must ensure the context lifetime extends beyond the lifetime of the stream.
[in]syncObjThe sync object to associate with the stream. The fences returned by NvMedia2DStreamRequestFence() will be associated with this sync object. This function registers the sync object with the NvMedia2D context as NVMEDIA_EOF_PRESYNCOBJ.
Returns
An NvMediaStatus return code.
Return values
NVMEDIA_STATUS_OKStream created successfully.
NVMEDIA_STATUS_BAD_PARAMETERstream or ctx is NULL, or there was an error registering syncObj.
NVMEDIA_STATUS_INSUFFICIENT_BUFFERINGMaximum number of registered objects has been reached in the NvMedia2D context.
NVMEDIA_STATUS_INVALID_STATEThe function was called in incorrect system state.
NVMEDIA_STATUS_OUT_OF_MEMORYMemory allocation failed.
NVMEDIA_STATUS_ERRORAn internal failure occurred when trying to create the stream.
Precondition
  • ctx must be valid NvMedia2D handle created with NvMedia2DCreate().
  • syncObj must be valid NvSciSyncObj handle.


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes, with the following conditions:
      • Each thread uses different NvMedia2DStream handle
      • Each thread uses different NvMedia2D handle
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: No
  • Maturity: Experimental

◆ NvMedia2DStreamDestroy()

NvMediaStatus NvMedia2DStreamDestroy ( NvMedia2DStream *const  stream)

Destroy a stream.

Unregisters the associated sync object and clears any fences pushed to the stream but not consumed yet.

Parameters
[in]streamThe stream.
Returns
An NvMediaStatus return code.
Return values
NVMEDIA_STATUS_OKStream destroyed successfully.
NVMEDIA_STATUS_BAD_PARAMETERstream is NULL.
NVMEDIA_STATUS_INVALID_STATEThe function was called in incorrect system state.
NVMEDIA_STATUS_PENDINGTasks pushed to the stream are still pending.
NVMEDIA_STATUS_ERRORAn internal failure occurred when trying to destroy the stream.
Precondition


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes, with the following conditions:
      • Each thread uses NvMedia2DStream handle created with different NvMedia2D handle
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: Yes
    • Operational: No
    • Reinit/Deinit Preparation: Yes
  • Maturity: Experimental

◆ NvMedia2DStreamPushFenceWait()

NvMediaStatus NvMedia2DStreamPushFenceWait ( NvMedia2DStream *const  stream,
NvSciSyncFence const *const  syncFence 
)

Push a fence wait to the stream.

After a call to this function:

Pushing a cleared fence to the stream is a valid no-op.

Maximum number of (non-cleared) fence waits that can be pushed to the stream without pushing a task or requesting a fence in between is 15.

Parameters
[in]streamThe stream.
[in]syncFenceThe fence to wait on.
Returns
An NvMediaStatus return code.
Return values
NVMEDIA_STATUS_OKFence wait pushed successfully.
NVMEDIA_STATUS_BAD_PARAMETERstream is NULL, or syncFence is NULL or not valid.
NVMEDIA_STATUS_INSUFFICIENT_BUFFERINGMaximum number of fence waits has been reached.
NVMEDIA_STATUS_ERRORAn internal failure occurred when trying to push the fence wait.
Precondition


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes, with the following conditions:
      • Each thread uses NvMedia2DStream handle created with different NvMedia2D handle
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: No
    • Operational: Yes
    • Reinit/Deinit Preparation: No
  • Maturity: Experimental

◆ NvMedia2DStreamPushTask()

NvMediaStatus NvMedia2DStreamPushTask ( NvMedia2DStream *const  stream,
NvMedia2DComposeParameters const  taskParams,
NvMedia2DComposeResult *const  taskResult 
)

Push a task to the stream.

The task will be executed after any fence waits and tasks pushed to the stream previously have completed.

Parameters
[in]streamThe stream.
[in]taskParamsThe task parameters. Must not have any pre-fences set with NvMedia2DInsertPreNvSciSyncFence() or EOF sync object set with NvMedia2DSetNvSciSyncObjforEOF(). This function consumes the task parameters, so the caller must not use the parameters after this function returns.
[out]taskResultThe task result. Optional, can be NULL.
Returns
An NvMediaStatus return code.
Return values
NVMEDIA_STATUS_OKTask pushed successfully.
NVMEDIA_STATUS_BAD_PARAMETERstream is NULL, or taskParams is invalid.
NVMEDIA_STATUS_INSUFFICIENT_BUFFERINGFailed to add fence waits for the task.
NVMEDIA_STATUS_NOT_SUPPORTEDRequested task is not supported on this platform.
NVMEDIA_STATUS_TIMED_OUTToo many tasks are already pending for the NvMedia2D context associated with the stream.
NVMEDIA_STATUS_ERRORAn internal failure occurred when trying to push the task.
Precondition


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes, with the following conditions:
      • Each thread uses NvMedia2DStream handle created with different NvMedia2D handle
      • Each thread uses different NvMedia2DComposeResult
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: No
    • Operational: Yes
    • Reinit/Deinit Preparation: No
  • Maturity: Experimental

◆ NvMedia2DStreamRequestFence()

NvMediaStatus NvMedia2DStreamRequestFence ( NvMedia2DStream *const  stream,
NvSciSyncFence *const  syncFence 
)

Request a fence from the stream.

The fence will be signaled after any fence waits and tasks pushed to the stream previously have completed.

Parameters
[in]streamThe stream.
[out]syncFenceThe fence to be signaled. Cleared by this function before being populated with the new fence value.
Returns
An NvMediaStatus return code.
Return values
NVMEDIA_STATUS_OKFence requested successfully.
NVMEDIA_STATUS_BAD_PARAMETERstream or syncFence is NULL.
NVMEDIA_STATUS_INSUFFICIENT_BUFFERINGNo free compose parameters instance is available in the NvMedia2D context associated with the stream.
NVMEDIA_STATUS_TIMED_OUTToo many tasks are already pending for the NvMedia2D context associated with the stream.
NVMEDIA_STATUS_ERRORAn internal failure occurred when trying to request the fence.
Precondition


Usage considerations

  • Allowed context for the API call
    • Interrupt handler: No
    • Signal handler: No
    • Thread-safe: Yes, with the following conditions:
      • Each thread uses NvMedia2DStream handle created with different NvMedia2D handle
      • Each thread uses different NvSciSyncFence
    • Re-entrant: No
    • Async/Sync: Sync
  • Required privileges: None
  • Allowed execution state
    • Initialization: No
    • Operational: Yes
    • Reinit/Deinit Preparation: No
  • Maturity: Experimental