14#ifndef __SOF_AUDIO_PIPELINE_H__
15#define __SOF_AUDIO_PIPELINE_H__
23#include <ipc/topology.h>
44#define PPL_STATUS_PATH_STOP 1
50#define PPL_STATUS_PATH_TERMINATE 2
53#define PPL_STATUS_SCHEDULED 2
58#define PPL_CONN_DIR_COMP_TO_BUFFER 0
59#define PPL_CONN_DIR_BUFFER_TO_COMP 1
65#define PPL_DIR_DOWNSTREAM 0
66#define PPL_DIR_UPSTREAM 1
92#ifdef CONFIG_IPC_MAJOR_4
152#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
153 int32_t kcps[CONFIG_CORE_COUNT];
172#define pipeline_task_get(t) container_of(t, struct pipeline_task, task)
235#ifdef CONFIG_SOF_USERSPACE_LL
240void pipeline_posn_grant_access(
struct k_thread *thread);
276#if CONFIG_IPC_MAJOR_4
454 uint32_t core, uint32_t
period,
455 uint32_t period_mips, uint32_t frames_per_sched,
456 uint32_t time_domain);
static bool pipeline_is_this_cpu(struct pipeline *p)
Checks if pipeline is scheduled on the current core.
Definition pipeline.h:393
static bool pipeline_is_same_sched_comp(struct pipeline *current, struct pipeline *previous)
Checks if two pipelines share the same scheduling component.
Definition pipeline.h:372
int pipeline_comp_ll_task_init(struct pipeline *p)
Initializes a low-latency (LL) task for a pipeline.
int pipeline_reset(struct pipeline *p, struct comp_dev *host_cd)
Resets the pipeline and frees runtime resources.
int pipeline_prepare(struct pipeline *p, struct comp_dev *cd)
Prepares pipeline for audio processing.
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.
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.
static uint32_t pipeline_id(struct pipeline *p)
Retrieves pipeline ID from pipeline structure.
Definition pipeline.h:291
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.
void pipeline_xrun(struct pipeline *p, struct comp_dev *dev, int32_t bytes)
Notifies host and pipeline that an XRUN condition occurred.
int pipeline_free(struct pipeline *p)
Frees a pipeline and its associated resources.
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.
int pipeline_params(struct pipeline *p, struct comp_dev *cd, struct sof_ipc_pcm_params *params)
Sets pipeline runtime audio stream parameters.
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.
struct comp_dev * pipeline_get_dai_comp_latency(uint32_t pipeline_id, uint32_t *latency)
Walks pipeline graph to find DAI component and latency.
int pipeline_copy(struct pipeline *p)
Copy and process stream data along a pipeline.
void pipeline_posn_init(struct sof *sof)
Initializes pipeline position structure.
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.
int pipeline_trigger(struct pipeline *p, struct comp_dev *host, int cmd)
Trigger pipeline in IPC context.
int pipeline_xrun_set_limit(struct pipeline *p, uint32_t xrun_limit_usecs)
Sets tolerance limit for pipeline XRUN handling.
int pipeline_xrun_recover(struct pipeline *p)
Recovers the pipeline from an XRUN condition.
void pipeline_set_eos(struct pipeline *p, bool eos)
Sets End Of Stream state for all devices in the pipeline.
int pipeline_trigger_run(struct pipeline *p, struct comp_dev *host, int cmd)
Trigger pipeline in either IPC or pipeline task context.
int pipeline_xrun_handle_trigger(struct pipeline *p, int cmd)
Performs XRUN recovery trigger handling.
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_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.
void pipeline_disconnect(struct comp_dev *comp, struct comp_buffer *buffer, int dir)
Disconnect components and buffers in a pipeline.
void pipeline_schedule_copy(struct pipeline *p, uint64_t start)
Schedules a pipeline copy operation to run after a delay.
int pipeline_connect(struct comp_dev *comp, struct comp_buffer *buffer, int dir)
Connect components in a pipeline.
static bool pipeline_is_timer_driven(struct pipeline *p)
Checks if pipeline is scheduled with timer.
Definition pipeline.h:383
@ SOF_TIME_DOMAIN_TIMER
Timer interrupt.
Definition topology.h:285
Sound Open Firmware global runtime context.
RTOS spinlock primitives and initialization.
User-space ABI log levels and binary trace packet header definitions.
Audio component interconnect buffer connecting two pipeline components.
Definition buffer.h:150
Audio component base device "class" used by all other component types.
Definition component.h:587
uint32_t period
Component processing period in microseconds.
Definition component.h:596
For storing IPC payload data during pipeline creation.
Definition pipeline.h:167
const struct ipc4_pipeline_ext_obj_mem_data * mem_data
IPC4 pipeline external memory descriptor.
Definition pipeline.h:168
Memory allocation parameters for pipeline execution context.
Definition pipeline.h:86
Module and pipeline allocation context aggregating a Zephyr heap and optional virtual region.
Definition alloc.h:251
Generic pipeline data used by pipeline_comp_* functions.
Definition pipeline.h:145
struct comp_dev * start
Starting component device.
Definition pipeline.h:146
struct sof_ipc_pcm_params * params
Stream PCM parameters.
Definition pipeline.h:147
uint32_t delay_ms
Delay in milliseconds between pre and main trigger phases.
Definition pipeline.h:151
struct pipeline * p
Target pipeline.
Definition pipeline.h:149
struct sof_ipc_stream_posn * posn
Stream position structure.
Definition pipeline.h:148
int cmd
Command code.
Definition pipeline.h:150
Task type registered by pipelines.
Definition pipeline.h:158
bool registrable
Should task be registered on IRQ.
Definition pipeline.h:160
struct comp_dev * sched_comp
Pipeline scheduling component.
Definition pipeline.h:161
Pipeline traversal walk context for graph exploration and operations.
Definition pipeline.h:123
void * comp_data
Component callback user data.
Definition pipeline.h:127
struct list_item pipelines
Pipelines to be scheduled after trigger walk.
Definition pipeline.h:132
bool skip_incomplete
Skip incompletely initialized components.
Definition pipeline.h:139
void(* buff_func)(struct comp_buffer *buffer, void *data)
Callback function invoked for each buffer in walk.
Definition pipeline.h:129
int(* comp_func)(struct comp_dev *cd, struct comp_buffer *buffer, struct pipeline_walk_context *ctx, int dir)
Callback function invoked for each component in walk.
Definition pipeline.h:125
struct comp_buffer * incoming
Incoming buffer context.
Definition pipeline.h:131
void * buff_data
Buffer callback user data.
Definition pipeline.h:130
Audio pipeline structure representing a stream graph and execution context.
Definition pipeline.h:72
uint32_t priority
Priority level 0 (low) to 10 (max)
Definition pipeline.h:79
uint32_t comp_id
Component ID for pipeline.
Definition pipeline.h:74
struct pipeline::@135 trigger
Pipeline trigger control structure.
struct task * trigger_task
IPC4 pipeline trigger task.
Definition pipeline.h:93
uint32_t time_domain
Scheduling time domain.
Definition pipeline.h:83
uint32_t posn_offset
Position update array offset.
Definition pipeline.h:109
uint32_t core
Core we run on.
Definition pipeline.h:77
struct tr_ctx tctx
Trace settings.
Definition pipeline.h:89
struct mod_alloc_ctx * alloc
Alloc context used for allocating this pipeline.
Definition pipeline.h:73
struct comp_dev * sched_comp
Component that drives scheduling in this pipe.
Definition pipeline.h:100
uint32_t pipeline_id
Pipeline ID.
Definition pipeline.h:75
int cmd
Trigger command.
Definition pipeline.h:112
int32_t xrun_bytes
Last xrun length in bytes.
Definition pipeline.h:87
uint32_t period
Execution period in microseconds.
Definition pipeline.h:78
struct comp_dev * sink_comp
Sink component for this pipe.
Definition pipeline.h:104
struct comp_dev * host
Associated host component device.
Definition pipeline.h:113
struct task * pipe_task
IPC3 pipeline processing task or IPC4 pipeline copy task.
Definition pipeline.h:95
unsigned int delay
Period count delay.
Definition pipeline.h:114
struct list_item list
List item in walk context.
Definition pipeline.h:106
uint32_t xrun_limit_usecs
Report xruns greater than limit.
Definition pipeline.h:82
struct pipeline * sched_prev
Pipeline scheduled before this.
Definition pipeline.h:97
uint32_t period_mips
Worst case instruction count per period.
Definition pipeline.h:80
bool aborted
STOP or PAUSE failed, stay active.
Definition pipeline.h:115
struct ipc_msg * msg
IPC message pointer for position updates.
Definition pipeline.h:110
struct comp_dev * source_comp
Source component for this pipe.
Definition pipeline.h:102
uint32_t sched_id
Scheduling component ID.
Definition pipeline.h:76
uint32_t status
Pipeline status flags.
Definition pipeline.h:88
bool pending
Trigger scheduled but not executed yet.
Definition pipeline.h:116
uint32_t frames_per_sched
Output frames of pipeline, 0 is variable.
Definition pipeline.h:81
uint32_t attributes
Pipeline attributes from IPC extension message.
Definition pipeline.h:84
struct pipeline * sched_next
Pipeline scheduled after this.
Definition pipeline.h:96
General firmware context.
Definition sof.h:50
Core task structure managed by SOF schedulers.
Definition task.h:81
Core task descriptor, task operations, and task execution state machine.