Sound Open Firmware
Loading...
Searching...
No Matches
Pipeline Graph & Lifecycle Infrastructure

Directed Acyclic Graph (DAG) pipeline creation, scheduling binding, traversal, and lifecycle management. More...

Files

file  pipeline.h
 Audio pipeline management, graph scheduling, and execution control.
 

Data Structures

struct  pipeline
 Audio pipeline structure representing a stream graph and execution context. More...
 
struct  pipeline_walk_context
 Pipeline traversal walk context for graph exploration and operations. More...
 
struct  pipeline_data
 Generic pipeline data used by pipeline_comp_* functions. More...
 
struct  pipeline_task
 Task type registered by pipelines. More...
 
struct  create_pipeline_params
 For storing IPC payload data during pipeline creation. More...
 

Macros

#define PPL_STATUS_PATH_STOP   1
 Pipeline status to stop execution of current path, but to keep the pipeline alive, when processing COMP_TRIGGER_STOP or COMP_TRIGGER_PAUSE.
 
#define PPL_STATUS_PATH_TERMINATE   2
 Pipeline status to stop execution of current path, and to terminate the pipeline, when processing COMP_TRIGGER_STOP or COMP_TRIGGER_PAUSE.
 
#define PPL_STATUS_SCHEDULED   2
 Pipeline scheduled in another thread other than IPC thread.
 
#define pipeline_task_get(t)   container_of(t, struct pipeline_task, task)
 Retrieves the enclosing pipeline_task structure from a task pointer.
 

Functions

struct pipeline * pipeline_new (struct k_heap *heap, uint32_t pipeline_id, uint32_t priority, uint32_t comp_id, struct create_pipeline_params *pparams)
 Creates a new pipeline.
 
int pipeline_free (struct pipeline *p)
 Frees a pipeline and its associated resources.
 
int pipeline_connect (struct comp_dev *comp, struct comp_buffer *buffer, int dir)
 Connect components in a pipeline.
 
void pipeline_disconnect (struct comp_dev *comp, struct comp_buffer *buffer, int dir)
 Disconnect components and buffers in a pipeline.
 
int pipeline_complete (struct pipeline *p, struct comp_dev *source, struct comp_dev *sink)
 Completes a pipeline setup by verifying connectivity between source and sink.
 
void pipeline_posn_init (struct sof *sof)
 Initializes pipeline position structure.
 
int pipeline_reset (struct pipeline *p, struct comp_dev *host_cd)
 Resets the pipeline and frees runtime resources.
 
void pipeline_set_eos (struct pipeline *p, bool eos)
 Sets End Of Stream state for all devices in the pipeline.
 
int pipeline_for_each_comp (struct comp_dev *current, struct pipeline_walk_context *ctx, int dir)
 Walks the pipeline graph for each component.
 
struct comp_dev * pipeline_get_dai_comp (uint32_t pipeline_id, int dir)
 Walks pipeline graph to find DAI component.
 
struct comp_dev * pipeline_get_dai_comp_latency (uint32_t pipeline_id, uint32_t *latency)
 Walks pipeline graph to find DAI component and latency.
 
static uint32_t pipeline_id (struct pipeline *p)
 Retrieves pipeline ID from pipeline structure.
 
int pipeline_params (struct pipeline *p, struct comp_dev *cd, struct sof_ipc_pcm_params *params)
 Sets pipeline runtime audio stream parameters.
 
int pipeline_prepare (struct pipeline *p, struct comp_dev *cd)
 Prepares pipeline for audio processing.
 
int pipeline_trigger (struct pipeline *p, struct comp_dev *host, int cmd)
 Trigger pipeline in IPC context.
 
int pipeline_trigger_run (struct pipeline *p, struct comp_dev *host, int cmd)
 Trigger pipeline in either IPC or pipeline task context.
 
int pipeline_copy (struct pipeline *p)
 Copy and process stream data along a pipeline.
 
void pipeline_get_timestamp (struct pipeline *p, struct comp_dev *host_dev, struct sof_ipc_stream_posn *posn)
 Get pipeline timestamps from host to DAI.
 
static bool pipeline_is_same_sched_comp (struct pipeline *current, struct pipeline *previous)
 Checks if two pipelines share the same scheduling component.
 
static bool pipeline_is_timer_driven (struct pipeline *p)
 Checks if pipeline is scheduled with timer.
 
static bool pipeline_is_this_cpu (struct pipeline *p)
 Checks if pipeline is scheduled on the current core.
 
int pipeline_comp_ll_task_init (struct pipeline *p)
 Initializes a low-latency (LL) task for a pipeline.
 
void pipeline_comp_ll_task_free (struct pipeline *p)
 Frees the low-latency (LL) tasks owned by a pipeline.
 
int pipeline_comp_dp_task_init (struct comp_dev *comp)
 Initializes a data processing (DP) task for a component.
 
void pipeline_schedule_copy (struct pipeline *p, uint64_t start)
 Schedules a pipeline copy operation to run after a delay.
 
void pipeline_comp_trigger_sched_comp (struct pipeline *p, struct comp_dev *comp, struct pipeline_walk_context *ctx)
 Triggers pipeline's scheduling component.
 
void pipeline_schedule_triggered (struct pipeline_walk_context *ctx, int cmd)
 Schedules all triggered pipelines collected during traversal.
 
void pipeline_schedule_config (struct pipeline *p, uint32_t sched_id, uint32_t core, uint32_t period, uint32_t period_mips, uint32_t frames_per_sched, uint32_t time_domain)
 Configures pipeline scheduling parameters.
 
int pipeline_xrun_recover (struct pipeline *p)
 Recovers the pipeline from an XRUN condition.
 
int pipeline_xrun_handle_trigger (struct pipeline *p, int cmd)
 Performs XRUN recovery trigger handling.
 
void pipeline_xrun (struct pipeline *p, struct comp_dev *dev, int32_t bytes)
 Notifies host and pipeline that an XRUN condition occurred.
 
int pipeline_xrun_set_limit (struct pipeline *p, uint32_t xrun_limit_usecs)
 Sets tolerance limit for pipeline XRUN handling.
 
void pipeline_comp_copy_error_notify (const struct comp_dev *component, int error_code)
 Sends an IPC notification that an error occurred in a module's processing function.
 

Pipeline connection directions

#define PPL_CONN_DIR_COMP_TO_BUFFER   0
 Connection from component to buffer.
 
#define PPL_CONN_DIR_BUFFER_TO_COMP   1
 Connection from buffer to component.
 

Pipeline processing directions

#define PPL_DIR_DOWNSTREAM   0
 Downstream playback/processing direction.
 
#define PPL_DIR_UPSTREAM   1
 Upstream capture/processing direction.
 

Detailed Description

Directed Acyclic Graph (DAG) pipeline creation, scheduling binding, traversal, and lifecycle management.

Macro Definition Documentation

◆ pipeline_task_get

#define pipeline_task_get (   t)    container_of(t, struct pipeline_task, task)

Retrieves the enclosing pipeline_task structure from a task pointer.

◆ PPL_CONN_DIR_BUFFER_TO_COMP

#define PPL_CONN_DIR_BUFFER_TO_COMP   1

Connection from buffer to component.

◆ PPL_CONN_DIR_COMP_TO_BUFFER

#define PPL_CONN_DIR_COMP_TO_BUFFER   0

Connection from component to buffer.

◆ PPL_DIR_DOWNSTREAM

#define PPL_DIR_DOWNSTREAM   0

Downstream playback/processing direction.

◆ PPL_DIR_UPSTREAM

#define PPL_DIR_UPSTREAM   1

Upstream capture/processing direction.

◆ PPL_STATUS_PATH_STOP

#define PPL_STATUS_PATH_STOP   1

Pipeline status to stop execution of current path, but to keep the pipeline alive, when processing COMP_TRIGGER_STOP or COMP_TRIGGER_PAUSE.

◆ PPL_STATUS_PATH_TERMINATE

#define PPL_STATUS_PATH_TERMINATE   2

Pipeline status to stop execution of current path, and to terminate the pipeline, when processing COMP_TRIGGER_STOP or COMP_TRIGGER_PAUSE.

◆ PPL_STATUS_SCHEDULED

#define PPL_STATUS_SCHEDULED   2

Pipeline scheduled in another thread other than IPC thread.

Function Documentation

◆ pipeline_comp_copy_error_notify()

void pipeline_comp_copy_error_notify ( const struct comp_dev *  component,
int  error_code 
)

Sends an IPC notification that an error occurred in a module's processing function.

Parameters
[in]componentComponent device in which the error occurred.
[in]error_codeError code to report.

◆ pipeline_comp_dp_task_init()

int pipeline_comp_dp_task_init ( struct comp_dev *  comp)

Initializes a data processing (DP) task for a component.

Parameters
[in,out]compComponent device for which the task is created.
Returns
0 on success, or negative error code on failure.

◆ pipeline_comp_ll_task_free()

void pipeline_comp_ll_task_free ( struct pipeline *  p)

Frees the low-latency (LL) tasks owned by a pipeline.

Parameters
[in,out]pTarget pipeline.

◆ pipeline_comp_ll_task_init()

int pipeline_comp_ll_task_init ( struct pipeline *  p)

Initializes a low-latency (LL) task for a pipeline.

Parameters
[in,out]pTarget pipeline.
Returns
0 on success, or negative error code on failure.

◆ pipeline_comp_trigger_sched_comp()

void pipeline_comp_trigger_sched_comp ( struct pipeline *  p,
struct comp_dev *  comp,
struct pipeline_walk_context *  ctx 
)

Triggers pipeline's scheduling component.

Parameters
[in,out]pTarget pipeline.
[in,out]compPipeline component device.
[in,out]ctxPipeline graph walk context.

◆ pipeline_complete()

int pipeline_complete ( struct pipeline *  p,
struct comp_dev *  source,
struct comp_dev *  sink 
)

Completes a pipeline setup by verifying connectivity between source and sink.

Parameters
[in,out]pPipeline to complete.
[in,out]sourcePipeline source component device.
[in,out]sinkPipeline sink component device.
Returns
0 on success, or negative error code on failure.

◆ pipeline_connect()

int pipeline_connect ( struct comp_dev *  comp,
struct comp_buffer *  buffer,
int  dir 
)

Connect components in a pipeline.

Parameters
[in,out]compConnecting component device.
[in,out]bufferConnecting buffer.
[in]dirConnection direction (PPL_CONN_DIR_*).
Returns
0 on success, or negative error code on failure.

◆ pipeline_copy()

int pipeline_copy ( struct pipeline *  p)

Copy and process stream data along a pipeline.

Parameters
[in,out]pTarget pipeline.
Returns
0 on success, or negative error code on failure.

◆ pipeline_disconnect()

void pipeline_disconnect ( struct comp_dev *  comp,
struct comp_buffer *  buffer,
int  dir 
)

Disconnect components and buffers in a pipeline.

Parameters
[in,out]compConnecting component device.
[in,out]bufferConnecting buffer.
[in]dirConnection direction (PPL_CONN_DIR_*).

◆ pipeline_for_each_comp()

int pipeline_for_each_comp ( struct comp_dev *  current,
struct pipeline_walk_context *  ctx,
int  dir 
)

Walks the pipeline graph for each component.

Parameters
[in,out]currentCurrent pipeline component to start traversal from.
[in,out]ctxPipeline graph walk context.
[in]dirWalk direction (PPL_DIR_*).
Returns
0 on success, or negative error code on failure.

◆ pipeline_free()

int pipeline_free ( struct pipeline *  p)

Frees a pipeline and its associated resources.

Parameters
[in,out]pPipeline to free.
Returns
0 on success, or negative error code on failure.

◆ pipeline_get_dai_comp()

struct comp_dev * pipeline_get_dai_comp ( uint32_t  pipeline_id,
int  dir 
)

Walks pipeline graph to find DAI component.

Parameters
[in]pipeline_idStart pipeline ID.
[in]dirDirection of traversal (PPL_DIR_*).
Returns
Pointer to DAI component device, or NULL if not found.

◆ pipeline_get_dai_comp_latency()

struct comp_dev * pipeline_get_dai_comp_latency ( uint32_t  pipeline_id,
uint32_t *  latency 
)

Walks pipeline graph to find DAI component and latency.

Parameters
[in]pipeline_idStart pipeline ID.
[out]latencyReceives latency to DAI as a count of buffered processing blocks (input_data/ibs - output_data/obs).
Returns
Pointer to DAI component device, or NULL if not found.

◆ pipeline_get_timestamp()

void pipeline_get_timestamp ( struct pipeline *  p,
struct comp_dev *  host_dev,
struct sof_ipc_stream_posn *  posn 
)

Get pipeline timestamps from host to DAI.

Parameters
[in]pTarget pipeline.
[in]host_devHost DMA component device.
[in,out]posnPipeline stream position structure to populate.

◆ pipeline_id()

static uint32_t pipeline_id ( struct pipeline *  p)
inlinestatic

Retrieves pipeline ID from pipeline structure.

Parameters
[in]pTarget pipeline.
Returns
Pipeline ID.

◆ pipeline_is_same_sched_comp()

static bool pipeline_is_same_sched_comp ( struct pipeline *  current,
struct pipeline *  previous 
)
inlinestatic

Checks if two pipelines share the same scheduling component.

Parameters
[in]currentFirst pipeline.
[in]previousSecond pipeline.
Returns
True if both pipelines are scheduled together, false otherwise.

◆ pipeline_is_this_cpu()

static bool pipeline_is_this_cpu ( struct pipeline *  p)
inlinestatic

Checks if pipeline is scheduled on the current core.

Parameters
[in]pTarget pipeline.
Returns
True if pipeline core ID matches current core ID, false otherwise.

◆ pipeline_is_timer_driven()

static bool pipeline_is_timer_driven ( struct pipeline *  p)
inlinestatic

Checks if pipeline is scheduled with timer.

Parameters
[in]pTarget pipeline.
Returns
True if pipeline uses timer-based scheduling, false otherwise.

◆ pipeline_new()

struct pipeline * pipeline_new ( struct k_heap *  heap,
uint32_t  pipeline_id,
uint32_t  priority,
uint32_t  comp_id,
struct create_pipeline_params *  pparams 
)

Creates a new pipeline.

Parameters
[in,out]heapHeap to allocate the pipeline on, or NULL for default.
[in]pipeline_idPipeline ID number.
[in]priorityPipeline scheduling priority.
[in]comp_idPipeline component ID number.
[in]pparamsPipeline parameters from IPC payload, may be NULL.
Returns
Pointer to new pipeline on success, or NULL on failure.

◆ pipeline_params()

int pipeline_params ( struct pipeline *  p,
struct comp_dev *  cd,
struct sof_ipc_pcm_params *  params 
)

Sets pipeline runtime audio stream parameters.

Parameters
[in,out]pPipeline to configure.
[in,out]cdPipeline component device.
[in]paramsStream PCM parameters.
Returns
0 on success, or negative error code on failure.

◆ pipeline_posn_init()

void pipeline_posn_init ( struct sof *  sof)

Initializes pipeline position structure.

Parameters
[in,out]sofPointer to global SOF system context.

◆ pipeline_prepare()

int pipeline_prepare ( struct pipeline *  p,
struct comp_dev *  cd 
)

Prepares pipeline for audio processing.

Parameters
[in,out]pPipeline to prepare.
[in,out]cdPipeline component device.
Returns
0 on success, or negative error code on failure.

◆ pipeline_reset()

int pipeline_reset ( struct pipeline *  p,
struct comp_dev *  host_cd 
)

Resets the pipeline and frees runtime resources.

Parameters
[in,out]pPipeline to reset.
[in,out]host_cdHost DMA component device.
Returns
0 on success, or negative error code on failure.

◆ pipeline_schedule_config()

void pipeline_schedule_config ( struct pipeline *  p,
uint32_t  sched_id,
uint32_t  core,
uint32_t  period,
uint32_t  period_mips,
uint32_t  frames_per_sched,
uint32_t  time_domain 
)

Configures pipeline scheduling parameters.

Parameters
[in,out]pTarget pipeline.
[in]sched_idScheduling component ID.
[in]coreDSP core the pipeline runs on.
[in]periodPipeline scheduling period in microseconds.
[in]period_mipsPipeline worst-case MCPS per period.
[in]frames_per_schedPipeline frames processed per schedule.
[in]time_domainPipeline scheduling time domain.

◆ pipeline_schedule_copy()

void pipeline_schedule_copy ( struct pipeline *  p,
uint64_t  start 
)

Schedules a pipeline copy operation to run after a delay.

Parameters
[in,out]pTarget pipeline.
[in]startPipeline start time in microseconds.

◆ pipeline_schedule_triggered()

void pipeline_schedule_triggered ( struct pipeline_walk_context *  ctx,
int  cmd 
)

Schedules all triggered pipelines collected during traversal.

Parameters
[in,out]ctxPipeline graph walk context.
[in]cmdTrigger command (COMP_TRIGGER_*).

◆ pipeline_set_eos()

void pipeline_set_eos ( struct pipeline *  p,
bool  eos 
)

Sets End Of Stream state for all devices in the pipeline.

Parameters
[in,out]pTarget pipeline.
[in]eosEnd Of Stream flag state.

◆ pipeline_trigger()

int pipeline_trigger ( struct pipeline *  p,
struct comp_dev *  host,
int  cmd 
)

Trigger pipeline in IPC context.

Parameters
[in,out]pTarget pipeline.
[in,out]hostHost DMA component device.
[in]cmdPipeline trigger command (COMP_TRIGGER_*).
Returns
0 on success, or negative error code on failure.

◆ pipeline_trigger_run()

int pipeline_trigger_run ( struct pipeline *  p,
struct comp_dev *  host,
int  cmd 
)

Trigger pipeline in either IPC or pipeline task context.

Parameters
[in,out]pTarget pipeline.
[in,out]hostHost DMA component device.
[in]cmdPipeline trigger command (COMP_TRIGGER_*).
Returns
0 on success, or negative error code on failure.

◆ pipeline_xrun()

void pipeline_xrun ( struct pipeline *  p,
struct comp_dev *  dev,
int32_t  bytes 
)

Notifies host and pipeline that an XRUN condition occurred.

Parameters
[in,out]pTarget pipeline.
[in,out]devPipeline component device where XRUN occurred.
[in]bytesNumber of overrun or underrun bytes.

◆ pipeline_xrun_handle_trigger()

int pipeline_xrun_handle_trigger ( struct pipeline *  p,
int  cmd 
)

Performs XRUN recovery trigger handling.

Parameters
[in,out]pTarget pipeline.
[in]cmdTrigger command (COMP_TRIGGER_*).
Returns
0 on success, or negative error code on failure.

◆ pipeline_xrun_recover()

int pipeline_xrun_recover ( struct pipeline *  p)

Recovers the pipeline from an XRUN condition.

Parameters
[in,out]pTarget pipeline.
Returns
0 on success, or negative error code on failure.

◆ pipeline_xrun_set_limit()

int pipeline_xrun_set_limit ( struct pipeline *  p,
uint32_t  xrun_limit_usecs 
)

Sets tolerance limit for pipeline XRUN handling.

Parameters
[in,out]pTarget pipeline.
[in]xrun_limit_usecsLimit in microseconds that pipeline will tolerate before reporting.
Returns
0 on success, or negative error code on failure.