Audio Component Infrastructure API#

The Audio Component Infrastructure API provides the foundational driver model, lifecycle state machine, copy execution interface, and Inter-Domain Communication (IDC) binding protocol for all audio processing nodes within SOF.

Component Architecture & Driver Model#

Audio processing components implement the standardized operations vtable (struct comp_ops), allowing the pipeline engine to manage disparate processing nodes (codecs, volume controls, equalizers, mixers, and hardware DAIs) through a uniform interface:

+-------------------------------------------------------------------------+
|                        struct comp_dev (Instance)                       |
|  - id, type, state, core, is_shared, period, frames                      |
|  - bsink_list, bsource_list (connected comp_buffer lists)               |
|  - drvdata (private component algorithm context)                        |
+------------------------------------+------------------------------------+
                                     | Points to
                                     v
+-------------------------------------------------------------------------+
|                       struct comp_driver (Driver)                       |
|  - type, uid, tplg_type, ops                                            |
+------------------------------------+------------------------------------+
                                     | Contains
                                     v
+-------------------------------------------------------------------------+
|                        struct comp_ops (VTable)                         |
|  - new() / free()             : Lifecycle allocation & cleanup          |
|  - params() / dai_hw_params() : Stream format negotiation               |
|  - prepare() / reset()        : Buffer allocation & resource reset      |
|  - trigger()                  : START, STOP, PAUSE, RELEASE transitions |
|  - copy()                     : Audio block processing algorithm loop   |
|  - bind() / unbind()          : Multi-module IPC graph interconnection  |
|  - get_attribute() / set()    : Runtime dynamic module parameters       |
+-------------------------------------------------------------------------+

Component Lifecycle & State Machine#

Every component instance transitions through deterministic execution states in response to pipeline trigger commands:

           +-----------------------+
           |    COMP_STATE_INIT    | <--- comp_new()
           +-----------+-----------+
                       | params()
                       v
           +-----------------------+
+--------> |    COMP_STATE_READY   | <---------------------------+
|          +-----------+-----------+                             |
|                      | prepare()                               |
|                      v                                         |
|          +-----------------------+                             |
|          |   COMP_STATE_PREPARE  |                             |
|          +-----------+-----------+                             |
|                      | START / PRE_START                       |
|                      v                                         |
|          +-----------------------+                             |
|          |   COMP_STATE_ACTIVE   | <-------+                   |
|          +-----+-----------+-----+         |                   |
|                |           |               | RELEASE           |
|          PAUSE |           | STOP          |                   |
|                v           v               |                   |
|   +------------------+   +-------------------+                 |
|   | COMP_STATE_PAUSED|   | COMP_STATE_PREPARE|                 |
|   +--------+---------+   +---------+---------+                 |
|            |                       |                           |
|            +-----------------------+                           |
|                        | RESET                                 |
|                        v                                       |
+------------------------+---------------------------------------+

Multi-Core IDC & IPC4 Module Binding#

When components communicate across DSP core boundaries or connect dynamically in IPC4 firmware, binding information is propagated via struct bind_info and Inter-Domain Communication (IDC) messages:

  • Local Core Binding: Direct buffer attachment between source and sink components.

  • Remote Core Binding: Uses comp_ipc4_bind_remote() to establish cross-core shared buffers or lockless ring buffer streaming channels.

C API Reference#

group Audio Component Infrastructure & Driver Model

Component driver interface, operations vtable, hardware abstraction, IPC binding, and state machines.

Standard Component Stream Commands

TODO: use IPC versions after 1.1

Most component stream commands match one-to-one IPC stream trigger commands. However we add two PRE_ and two POST_ commands to the set. They are issued internally without matching IPC commands. A single START IPC command is translated into a sequence of PRE_START and START component commands, etc. POST_* commands aren’t used so far.

Values:

enumerator COMP_TRIGGER_STOP#

Stop component stream.

enumerator COMP_TRIGGER_START#

Start component stream.

enumerator COMP_TRIGGER_PAUSE#

Pause the component stream.

enumerator COMP_TRIGGER_RELEASE#

Release paused component stream.

enumerator COMP_TRIGGER_RESET#

Reset component.

enumerator COMP_TRIGGER_PREPARE#

Prepare component.

enumerator COMP_TRIGGER_XRUN#

XRUN component.

enumerator COMP_TRIGGER_PRE_START#

Prepare to start component stream.

enumerator COMP_TRIGGER_PRE_RELEASE#

Prepare to release paused component stream.

enumerator COMP_TRIGGER_POST_STOP#

Finalize stop component stream.

enumerator COMP_TRIGGER_POST_PAUSE#

Finalize pause component stream.

enumerator COMP_TRIGGER_NO_ACTION#

No action required.

Component registration

int comp_register(struct comp_driver_info *drv)#

Registers the component driver on the list of available components.

Parameters:
  • drv – [inout] Component driver to be registered.

Returns:

0 if succeeded, error code otherwise.

void comp_unregister(struct comp_driver_info *drv)#

Unregisters the component driver from the list of available components.

Parameters:
  • drv – [inout] Component driver to be unregistered.

int comp_set_adapter_ops(const struct comp_driver *drv, const struct module_interface *ops)#

Set adapter ops for a dynamically created driver.

Parameters:
  • drv – [inout] Component driver to update.

  • ops – [in] Module interface operations.

Returns:

0 or a negative error code.

const struct comp_driver *comp_driver_find(const struct sof_uuid *uuid, uint32_t type)#

Look up a registered SOF component driver by UUID or driver type.

Scans the global SOF component driver registry to match either a specific 128-bit UUID (for audio processing modules) or a generic driver type (for host or DAI endpoints).

Parameters:
  • uuid – Component UUID to match, or NULL to match by type.

  • type – SOF component driver type (SOF_COMP_HOST, SOF_COMP_DAI, etc.).

Returns:

Pointer to matched comp_driver, or NULL if not registered.

XRUN handling.

static inline void comp_underrun(struct comp_dev *dev, struct comp_buffer *source, uint32_t copy_bytes)#

Called by the component device when underrun is detected.

Parameters:
  • dev – [inout] Component device.

  • source – [in] Source buffer.

  • copy_bytes – [in] Requested size of data in bytes.

static inline void comp_overrun(struct comp_dev *dev, struct comp_buffer *sink, uint32_t copy_bytes)#

Called by component device when overrun is detected.

Parameters:
  • dev – [inout] Component device.

  • sink – [in] Sink buffer.

  • copy_bytes – [in] Requested size of free space in bytes.

Audio Component States

COMP_STATE_NOT_EXIST#

Component does not exist.

COMP_STATE_INIT#

Component being initialised.

COMP_STATE_READY#

Component inactive, but ready.

COMP_STATE_SUSPEND#

Component suspended.

COMP_STATE_PREPARE#

Component prepared.

COMP_STATE_PAUSED#

Component paused.

COMP_STATE_ACTIVE#

Component active.

COMP_STATE_PRE_ACTIVE#

Component after early initialisation.

Standard Component Control Commands

“Value” commands are standard ones, known to the driver while “Data” commands are opaque blobs transferred by the driver.

TODO: see also: ref to ipc data structures for commands.

COMP_CMD_SET_VALUE#

Set value to component.

COMP_CMD_GET_VALUE#

Get value from component.

COMP_CMD_SET_DATA#

Set data to component.

COMP_CMD_GET_DATA#

Get data from component.

MMAP IPC status

COMP_CMD_IPC_MMAP_RPOS#

Host read position.

COMP_CMD_IPC_MMAP_PPOS#

DAI presentation position.

COMP_CMD_IPC_MMAP_VOL(chan)#

Volume.

Component status

COMP_STATUS_STATE_ALREADY_SET#

Comp set state status.

Component attribute types

COMP_ATTR_COPY_TYPE#

Comp copy type attribute.

COMP_ATTR_HOST_BUFFER#

Comp host buffer attribute.

COMP_ATTR_COPY_DIR#

Comp copy direction.

COMP_ATTR_VDMA_INDEX#

Comp index of the virtual DMA at the gateway.

COMP_ATTR_BASE_CONFIG#

Component base config.

COMP_ATTR_IPC4_CONFIG#

Component ipc4 set/get config.

Trace macros

trace_comp_drv_get_id(drv_p)#

Retrieves id (-1 = undefined) from the component driver.

trace_comp_drv_get_subid(drv_p)#

Retrieves subid (-1 = undefined) from the component driver.

trace_comp_get_id(comp_p)#

Retrieves id (pipe id) from the component device.

trace_comp_get_subid(comp_p)#

Retrieves subid (comp id) from the component device.

trace_comp_drv_get_tr_ctx(drv_p)#

Retrieves trace context from the component driver.

trace_comp_get_tr_ctx(comp_p)#

Retrieves trace context from the component device.

comp_cl_err(drv_p, __e, ...)#

Trace error message from component driver (no comp instance).

comp_cl_warn(drv_p, __e, ...)#

Trace warning message from component driver (no comp instance).

comp_cl_info(drv_p, __e, ...)#

Trace info message from component driver (no comp instance).

comp_cl_dbg(drv_p, __e, ...)#

Trace debug message from component driver (no comp instance).

comp_err(comp_p, __e, ...)#

Trace error message from component device.

comp_warn(comp_p, __e, ...)#

Trace warning message from component device.

comp_info(comp_p, __e, ...)#

Trace info message from component device.

comp_dbg(comp_p, __e, ...)#

Trace debug message from component device.

comp_perf_info(pcd, comp_p)#
comp_perf_avg_info(pcd, comp_p)#

Component processing domains

COMP_PROCESSING_DOMAIN_LL#

Low latency processing domain.

COMP_PROCESSING_DOMAIN_DP#

Data processing / worker thread domain.

Defines

SOF_DRV_UID_NAME(drv)#
comp_dev_for_each_producer(_dev, _producer)#

Macro to iterate through component’s list of producer buffers.

Parameters:
  • _dev – [in] Target component device.

  • _producer – [out] Buffer pointer iterator variable.

comp_dev_for_each_producer_safe(_dev, _producer, _next_producer)#

Safe macro to iterate through component’s producer buffers allowing buffer deletion.

Parameters:
  • _dev – [in] Target component device.

  • _producer – [out] Buffer pointer iterator variable.

  • _next_producer – [out] Storage pointer for next buffer.

comp_dev_for_each_consumer(_dev, _consumer)#

Macro to iterate through component’s list of consumer buffers.

Parameters:
  • _dev – [in] Target component device.

  • _consumer – [out] Buffer pointer iterator variable.

comp_dev_for_each_consumer_safe(_dev, _consumer, _next_consumer)#

Safe macro to iterate through component’s consumer buffers allowing buffer deletion.

Parameters:
  • _dev – [in] Target component device.

  • _consumer – [out] Buffer pointer iterator variable.

  • _next_consumer – [out] Storage pointer for next buffer.

comp_set_drvdata(c, data)#

Assigns private data to component device.

Parameters:
  • c – [inout] Component device.

  • data – [in] Private data pointer.

comp_get_drvdata(c)#

Retrieves driver private data from component device.

Parameters:
  • c – [in] Component device.

Returns:

Private data pointer.

DECLARE_MODULE(init)#
comp_buffer_list(comp, dir)#

Retrieves the component device buffer list based on direction.

Parameters:
  • comp – [in] Component device pointer.

  • dir – [in] Direction (PPL_DIR_DOWNSTREAM or PPL_DIR_UPSTREAM).

Returns:

Pointer to sink list or source list.

Enums

enum comp_endpoint_type#

Type of endpoint this component is connected to in a pipeline.

Values:

enumerator COMP_ENDPOINT_HOST#

Connected to host dma.

enumerator COMP_ENDPOINT_DAI#

Connected to dai dma.

enumerator COMP_ENDPOINT_NODE#

No dma connection.

enum comp_copy_type#

Type of next dma copy mode, changed on runtime.

Supported by host as COMP_ATTR_COPY_TYPE parameter to comp_set_attribute().

Values:

enumerator COMP_COPY_INVALID#

Invalid.

enumerator COMP_COPY_NORMAL#

Normal.

enumerator COMP_COPY_BLOCKING#

Blocking.

enumerator COMP_COPY_ONE_SHOT#

One-shot.

enum bind_type#

Component module binding endpoint type.

Values:

enumerator COMP_BIND_TYPE_SOURCE#

Bind to a data source.

enumerator COMP_BIND_TYPE_SINK#

Bind to a data sink.

Functions

static inline struct comp_buffer *comp_dev_get_first_data_producer(struct comp_dev *component)#

Get a pointer to the first comp_buffer object providing data to the component.

Parameters:
  • component – [in] Target component device.

Returns:

Pointer to first producer comp_buffer, or NULL if none.

static inline struct comp_buffer *comp_dev_get_next_data_producer(struct comp_dev *component, struct comp_buffer *producer)#

Get a pointer to the next comp_buffer object providing data to the component.

Parameters:
  • component – [in] Target component device.

  • producer – [in] Current producer buffer.

Returns:

Pointer to next producer comp_buffer, or NULL if none.

static inline struct comp_buffer *comp_dev_get_next_data_producer_safe(struct comp_dev *component, struct comp_buffer *producer)#

Safely get a pointer to the next comp_buffer object providing data to the component.

Parameters:
  • component – [in] Target component device.

  • producer – [in] Current producer buffer, or NULL.

Returns:

Pointer to next producer comp_buffer, or NULL if none.

static inline struct comp_buffer *comp_dev_get_first_data_consumer(struct comp_dev *component)#

Get a pointer to the first comp_buffer object receiving data from the component.

Parameters:
  • component – [in] Target component device.

Returns:

Pointer to first consumer comp_buffer, or NULL if none.

static inline struct comp_buffer *comp_dev_get_next_data_consumer(struct comp_dev *component, struct comp_buffer *consumer)#

Get a pointer to the next comp_buffer object receiving data from the component.

Parameters:
  • component – [in] Target component device.

  • consumer – [in] Current consumer buffer.

Returns:

Pointer to next consumer comp_buffer, or NULL if none.

static inline struct comp_buffer *comp_dev_get_next_data_consumer_safe(struct comp_dev *component, struct comp_buffer *consumer)#

Safely get a pointer to the next comp_buffer object receiving data from the component.

Parameters:
  • component – [in] Target component device.

  • consumer – [in] Current consumer buffer, or NULL.

Returns:

Pointer to next consumer comp_buffer, or NULL if none.

static inline uint32_t dev_comp_id(const struct comp_dev *dev)#

Retrieves Component ID from device.

Parameters:
  • dev – [in] Component device.

Returns:

Component ID.

static inline uint32_t dev_comp_pipe_id(const struct comp_dev *dev)#

Retrieves Component pipeline ID from device.

Parameters:
  • dev – [in] Component device.

Returns:

Component pipeline ID.

static inline enum sof_comp_type dev_comp_type(const struct comp_dev *dev)#

Retrieves component type from device.

Parameters:
  • dev – [in] Component device.

Returns:

Component type (enum sof_comp_type).

static inline void comp_init(const struct comp_driver *drv, struct comp_dev *dev, size_t bytes)#

Initialize common part of a component device.

Parameters:
  • drv – [in] Parent component driver.

  • dev – [inout] Component device.

  • bytes – [in] Size of the component device in bytes.

static inline struct comp_dev *comp_alloc(const struct comp_driver *drv, size_t bytes)#

Allocates memory for the component device and initializes common part.

Parameters:
  • drv – [in] Parent component driver.

  • bytes – [in] Size of the component device in bytes.

Returns:

Pointer to the allocated component device, or NULL on failure.

static inline void comp_free_device(struct comp_dev *dev)#

Frees memory allocated for component device.

This is a counterpart to comp_alloc() and not to be confused with comp_free().

Parameters:
  • dev – [inout] Pointer to the component device to free.

static inline struct processing_module *comp_mod(const struct comp_dev *dev)#

Module adapter associated with a component.

Parameters:
  • dev – [in] Component device.

Returns:

Pointer to associated processing module, or NULL if none.

void sys_comp_dai_init(void)#
void sys_comp_host_init(void)#
void sys_comp_kpb_init(void)#
void sys_comp_selector_init(void)#
void sys_comp_module_aria_interface_init(void)#
void sys_comp_module_asrc_interface_init(void)#
void sys_comp_module_copier_interface_init(void)#
void sys_comp_module_crossover_interface_init(void)#
void sys_comp_module_dcblock_interface_init(void)#
void sys_comp_module_demux_interface_init(void)#
void sys_comp_module_dolby_dax_audio_processing_interface_init(void)#
void sys_comp_module_drc_interface_init(void)#
void sys_comp_module_dts_interface_init(void)#
void sys_comp_module_eq_fir_interface_init(void)#
void sys_comp_module_eq_iir_interface_init(void)#
void sys_comp_module_gain_interface_init(void)#
void sys_comp_module_google_rtc_audio_processing_interface_init(void)#
void sys_comp_module_google_ctc_audio_processing_interface_init(void)#
void sys_comp_module_igo_nr_interface_init(void)#
void sys_comp_module_level_multiplier_interface_init(void)#
void sys_comp_module_mfcc_interface_init(void)#
void sys_comp_module_mixer_interface_init(void)#
void sys_comp_module_mixin_interface_init(void)#
void sys_comp_module_mixout_interface_init(void)#
void sys_comp_module_multiband_drc_interface_init(void)#
void sys_comp_module_mux_interface_init(void)#
void sys_comp_module_nxp_eap_interface_init(void)#
void sys_comp_module_phase_vocoder_interface_init(void)#
void sys_comp_module_rtnr_interface_init(void)#
void sys_comp_module_selector_interface_init(void)#
void sys_comp_module_sound_dose_interface_init(void)#
void sys_comp_module_src_interface_init(void)#
void sys_comp_module_src_lite_interface_init(void)#
void sys_comp_module_stft_process_interface_init(void)#
void sys_comp_module_tdfb_interface_init(void)#
void sys_comp_module_tone_interface_init(void)#
void sys_comp_module_template_interface_init(void)#
void sys_comp_module_tester_interface_init(void)#
void sys_comp_module_volume_interface_init(void)#
int comp_set_state(struct comp_dev *dev, int cmd)#

Component state transition handling.

This function should be called by a component implementation at the beginning of its state transition to verify whether the trigger is valid in the current state and abort the transition otherwise.

Typically the COMP_STATE_READY as the initial state is set directly by the component’s implementation of _new().

COMP_TRIGGER_PREPARE is called from the component’s prepare().

COMP_TRIGGER_START/STOP is called from trigger().

COMP_TRIGGER_RESET is called from reset().

Parameters:
  • dev – [inout] Component device.

  • cmd – [in] Command, one of COMP_TRIGGER_…

Returns:

0 if succeeded, error code otherwise.

static inline void component_set_nearest_period_frames(struct comp_dev *current, uint32_t rate)#

Set component period frames based on sample rate and period.

Parameters:
  • current – [inout] Target component device.

  • rate – [in] Sample rate in Hz.

void comp_get_copy_limits(struct comp_buffer *source, struct comp_buffer *sink, struct comp_copy_limits *cl)#

Computes source to sink copy operation boundaries including maximum number of frames that can be transferred.

Parameters:
  • source – [in] Source buffer.

  • sink – [in] Sink buffer.

  • cl – [out] Current copy limits.

void comp_get_copy_limits_frame_aligned(const struct comp_buffer *source, const struct comp_buffer *sink, struct comp_copy_limits *cl)#

Computes source to sink copy operation boundaries including maximum number of frames aligned with requirement that can be transferred.

Parameters:
  • source – [in] Buffer of source.

  • sink – [in] Buffer of sink.

  • cl – [out] Current copy limits.

static inline int comp_get_state(const struct comp_dev *dev)#

Get component state.

Parameters:
  • dev – [in] Component from which user wants to read status.

Return values:

COMP_STATE_NOT_EXIST – If there’s no connected component.

Returns:

State of the component (COMP_STATE_*).

static inline int comp_buffer_get_source_state(const struct comp_buffer *buffer)#

Provide state of a component connected to a buffer as a data provider.

Parameters:
  • buffer – [in] Interconnect buffer to be checked.

Return values:

COMP_STATE_NOT_EXIST – If there’s no connected component.

Returns:

State of the component.

static inline int comp_buffer_get_sink_state(const struct comp_buffer *buffer)#

Provide state of a component connected to a buffer as a data consumer.

Parameters:
  • buffer – [in] Interconnect buffer to be checked.

Return values:

COMP_STATE_NOT_EXIST – If there’s no connected component.

Returns:

State of the component.

int comp_verify_params(struct comp_dev *dev, uint32_t flag, struct sof_ipc_stream_params *params)#

Verify and set component audio parameters.

Called by component in params() function in order to set and update some of downstream (playback) or upstream (capture) buffer parameters with PCM parameters.

Parameters:
  • dev – [inout] Component device.

  • flag – [in] Specifies which parameter should not be updated.

  • params – [inout] PCM stream parameters.

Returns:

0 on success, negative error code on failure.

void comp_update_ibs_obs_cpc(struct comp_dev *dev)#

Update IBS, OBS, CPC, LL chunk size for component.

Parameters:
  • dev – [inout] Component to update.

void comp_init_performance_data(struct comp_dev *dev)#

Initialize performance data fields if component has assigned slot in measurement window.

Parameters:
  • dev – [inout] Component to init.

bool comp_update_performance_data(struct comp_dev *dev, uint32_t cycles_used)#

Update performance data entry for component and check for budget violation.

Parameters:
  • dev – [inout] Component to update.

  • cycles_used – [in] Execution time.

Returns:

True if budget violation occurred, false otherwise.

static inline int user_get_buffer_memory_region(const struct comp_driver *drv)#

Get memory region flag for component buffer allocations.

Parameters:
  • drv – [in] Component driver pointer.

Returns:

Memory flag (SOF_MEM_FLAG_*).

struct comp_dev *comp_new(struct sof_ipc_comp *comp)#

Instantiate a new component device from IPC3 descriptor.

Parameters:
  • comp – [in] IPC3 component descriptor.

Returns:

Pointer to new component device, or NULL on failure.

static inline void comp_free(struct comp_dev *dev)#

Free component device via driver ops.

Parameters:
  • dev – [inout] Component device to free.

static inline int comp_params_remote(struct comp_dev *dev, struct sof_ipc_stream_params *params)#

Parameter initialization for component on remote core.

Parameters:
  • dev – [inout] Component device.

  • params – [in] Stream parameters to be set.

Returns:

0 if succeeded, error code otherwise.

static inline int comp_params(struct comp_dev *dev, struct sof_ipc_stream_params *params)#

Configure audio stream parameters for component device.

Parameters:
  • dev – [inout] Component device.

  • params – [inout] Audio (PCM) stream parameters to configure.

Returns:

0 on success, negative error code on failure.

static inline int comp_dai_get_hw_params(struct comp_dev *dev, struct sof_ipc_stream_params *params, int dir)#

Retrieve DAI hardware parameters from component device.

Parameters:
  • dev – [in] Component device.

  • params – [out] Stream parameters to populate.

  • dir – [in] Stream direction (enum sof_ipc_stream_direction).

Returns:

0 on success, negative error code on failure.

static inline int comp_cmd(struct comp_dev *dev, int cmd, void *data, int max_data_size)#

Dispatch IPC3 command to component device.

Parameters:
  • dev – [inout] Component device.

  • cmd – [in] Command code.

  • data – [inout] Command data buffer.

  • max_data_size – [in] Maximum acceptable size of returned data.

Returns:

0 on success, negative error code on failure.

static inline int comp_trigger_remote(struct comp_dev *dev, int cmd)#

Run trigger command on remote core for target component.

Parameters:
  • dev – [inout] Component device.

  • cmd – [in] Trigger command (COMP_TRIGGER_*).

Returns:

0 on success, negative error code on failure.

static inline int comp_trigger_local(struct comp_dev *dev, int cmd)#

Run trigger command locally on current core for target component.

Parameters:
  • dev – [inout] Component device.

  • cmd – [in] Trigger command (COMP_TRIGGER_*).

Returns:

0 on success, negative error code on failure.

static inline int comp_trigger(struct comp_dev *dev, int cmd)#

Dispatch trigger command to component (local or remote).

Parameters:
  • dev – [inout] Component device.

  • cmd – [in] Trigger command (COMP_TRIGGER_*).

Returns:

0 on success, negative error code on failure.

static inline int comp_prepare_remote(struct comp_dev *dev)#

Run prepare command on remote core for target component.

Parameters:
  • dev – [inout] Component device.

Returns:

0 on success, negative error code on failure.

static inline int comp_prepare(struct comp_dev *dev)#

Prepare component device for streaming (local or remote).

Parameters:
  • dev – [inout] Component device.

Returns:

0 on success, negative error code on failure.

int comp_copy(struct comp_dev *dev)#

Process and copy audio data through component.

Parameters:
  • dev – [inout] Component device.

Returns:

Number of copied frames, or negative error code on failure.

static inline int comp_ipc4_get_attribute_remote(struct comp_dev *dev, uint32_t type, void *value)#

Retrieve component attribute from a remote core (IPC4).

Parameters:
  • dev – [inout] Component device.

  • type – [in] Attribute type (COMP_ATTR_*).

  • value – [out] Pointer to buffer where attribute value is copied.

Returns:

0 on success, negative error code on failure.

static inline int comp_get_attribute(struct comp_dev *dev, uint32_t type, void *value)#

Get component attribute.

Parameters:
  • dev – [inout] Component device.

  • type – [in] Attribute type (COMP_ATTR_*).

  • value – [out] Pointer to buffer where attribute value is returned.

Returns:

0 on success, negative error code on failure.

static inline int comp_set_attribute(struct comp_dev *dev, uint32_t type, void *value)#

Set component attribute.

Parameters:
  • dev – [inout] Component device.

  • type – [in] Attribute type (COMP_ATTR_*).

  • value – [in] Pointer to attribute value to set.

Returns:

0 on success, negative error code on failure.

static inline int comp_reset_remote(struct comp_dev *dev)#

Run reset command on remote core for target component.

Parameters:
  • dev – [inout] Component device.

Returns:

0 on success, negative error code on failure.

static inline int comp_reset(struct comp_dev *dev)#

Reset component and free runtime resources (local or remote).

Parameters:
  • dev – [inout] Component device.

Returns:

0 on success, negative error code on failure.

static inline int comp_dai_config(struct comp_dev *dev, struct ipc_config_dai *config, const void *spec_config)#

Configure DAI component.

Parameters:
  • dev – [inout] Component device.

  • config – [in] IPC DAI configuration.

  • spec_config – [in] Spec-specific configuration data.

Returns:

0 on success, negative error code on failure.

static inline int comp_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn)#

Retrieve stream position from component.

Parameters:
  • dev – [inout] Component device.

  • posn – [out] Stream position structure to populate.

Returns:

0 on success, negative error code on failure.

void sys_comp_init(struct sof *sof)#

Allocates and initializes audio component list.

To be called once at boot time.

Parameters:
  • sof – [inout] SOF global system context.

static inline int comp_is_single_pipeline(struct comp_dev *current, struct comp_dev *previous)#

Checks if two component devices belong to the same parent pipeline.

Parameters:
  • current – [in] Component device.

  • previous – [in] Another component device.

Returns:

1 if children of the same pipeline, 0 otherwise.

static inline int comp_is_active(struct comp_dev *current)#

Checks if component device is active.

Parameters:
  • current – [in] Component device.

Returns:

1 if active, 0 otherwise.

static inline int comp_get_requested_state(int cmd)#

Returns component state based on requested command.

Parameters:
  • cmd – [in] Request command (COMP_TRIGGER_*).

Returns:

Component state (COMP_STATE_*).

static inline int comp_get_endpoint_type(struct comp_dev *dev)#

Returns endpoint type of given component.

Parameters:
  • dev – [in] Component device.

Returns:

Endpoint type, one of comp_endpoint_type (COMP_ENDPOINT_*).

static inline bool comp_is_scheduling_source(struct comp_dev *dev)#

Called to check whether component schedules its pipeline.

Parameters:
  • dev – [in] Component device.

Returns:

True if this is scheduling component, false otherwise.

static inline void comp_make_shared(struct comp_dev *dev)#

Called to mark component as shared between cores.

Parameters:
  • dev – [inout] Component device.

static inline struct comp_driver_list *comp_drivers_get(void)#

Get the global component driver list.

Returns:

Pointer to the component driver list.

static inline int comp_ipc4_bind_remote(struct comp_dev *dev, const struct bind_info *bind_data)#

Send bind message to component on remote core (IPC4).

Parameters:
  • dev – [inout] Component device.

  • bind_data – [in] Binding information.

Returns:

0 on success, negative error code on failure.

static inline int comp_bind(struct comp_dev *dev, const struct bind_info *bind_data)#

Bind component to downstream/upstream component or buffer.

Parameters:
  • dev – [inout] Component device.

  • bind_data – [in] Binding information.

Returns:

0 on success, negative error code on failure.

static inline int comp_ipc4_unbind_remote(struct comp_dev *dev, const struct bind_info *unbind_data)#

Send unbind message to component on remote core (IPC4).

Parameters:
  • dev – [inout] Component device.

  • unbind_data – [in] Unbinding information.

Returns:

0 on success, negative error code on failure.

static inline int comp_unbind(struct comp_dev *dev, const struct bind_info *unbind_data)#

Unbind component from downstream/upstream component or buffer.

Parameters:
  • dev – [inout] Component device.

  • unbind_data – [in] Unbinding information.

Returns:

0 on success, negative error code on failure.

static inline uint64_t comp_get_total_data_processed(struct comp_dev *dev, uint32_t stream_no, bool input)#

Retrieve total data processed by component.

Parameters:
  • dev – [in] Component device.

  • stream_no – [in] Stream index.

  • input – [in] True for input data, false for output data.

Returns:

Total processed data in bytes.

static inline bool comp_same_dir(struct comp_dev *comp, enum sof_ipc_stream_direction dir)#

Returns true if the component’s pipeline matches the specified direction.

Parameters:
  • comp – [in] Component device.

  • dir – [in] Stream direction (SOF_IPC_STREAM_PLAYBACK or SOF_IPC_STREAM_CAPTURE).

Returns:

True if matching direction, false otherwise.

struct bind_info#
#include <src/include/sof/audio/component.h>

Component module binding metadata and endpoint references.

Public Members

const struct ipc4_module_bind_unbind *ipc4_data#

Pointer to IPC4 bind/unbind data.

enum bind_type bind_type#

Type of binding (source or sink).

struct sof_source *source#

Source interface pointer when bind_type == COMP_BIND_TYPE_SOURCE.

struct sof_sink *sink#

Sink interface pointer when bind_type == COMP_BIND_TYPE_SINK.

union bind_info
struct comp_ops#
#include <src/include/sof/audio/component.h>

Audio component operations table.

All component operations must return 0 for success, negative values for errors and 1 to stop the pipeline walk operation unless specified otherwise in the operation documentation.

Public Members

struct comp_dev *(*create)(const struct comp_driver *drv, const struct comp_ipc_config *ipc_config, const void *spec)#

Creates a new component device.

Param drv:

[in] Parent component driver.

Param ipc_config:

[in] Component parameters.

Param spec:

[in] Pointer to initialization data.

Return:

Pointer to the new component device, or NULL on failure.

void (*free)(struct comp_dev *dev)#

Called to delete the specified component device.

Param dev:

[inout] Component device to be deleted.

int (*params)(struct comp_dev *dev, struct sof_ipc_stream_params *params)#

Sets component audio stream parameters.

Param dev:

[inout] Component device.

Param params:

[inout] Audio (PCM) stream parameters to be set.

Return:

0 on success, negative error code on failure.

int (*dai_get_hw_params)(struct comp_dev *dev, struct sof_ipc_stream_params *params, int dir)#

Fetches hardware stream parameters.

Param dev:

[in] Component device.

Param params:

[out] Receives copy of stream parameters retrieved from DAI HW settings.

Param dir:

[in] Stream direction (enum sof_ipc_stream_direction).

Return:

0 on success, negative error code on failure.

int (*dai_config)(struct dai_data *dd, struct comp_dev *dev, struct ipc_config_dai *dai_config, const void *dai_spec_config)#

Configures attached DAI.

Param dd:

[inout] DAI data context.

Param dev:

[inout] Component device.

Param dai_config:

[in] DAI configuration.

Param dai_spec_config:

[in] DAI specific configuration data.

Return:

0 on success, negative error code on failure.

int (*cmd)(struct comp_dev *dev, int cmd, void *data, int max_data_size)#

Used to pass standard and bespoke commands (with optional data).

Param dev:

[inout] Component device.

Param cmd:

[in] Command.

Param data:

[inout] Command data.

Param max_data_size:

[in] Max size of returned data acceptable by caller for ‘get’ commands.

Return:

0 on success, negative error code on failure.

int (*trigger)(struct comp_dev *dev, int cmd)#

Trigger, atomic - used to start/stop/pause stream operations.

Param dev:

[inout] Component device.

Param cmd:

[in] Command, one of COMP_TRIGGER_…

Return:

0 on success, negative error code on failure.

int (*prepare)(struct comp_dev *dev)#

Prepares component after params are set.

Param dev:

[inout] Component device.

Return:

0 on success, negative error code on failure.

int (*reset)(struct comp_dev *dev)#

Resets component.

Param dev:

[inout] Component device.

Return:

0 on success, negative error code on failure.

int (*copy)(struct comp_dev *dev)#

Copy and process stream data from source to sink buffers.

Param dev:

[inout] Component device.

Return:

Number of copied frames, or negative error code on failure.

int (*position)(struct comp_dev *dev, struct sof_ipc_stream_posn *posn)#

Retrieves component rendering position.

Param dev:

[in] Component device.

Param posn:

[out] Receives reported position.

Return:

0 on success, negative error code on failure.

int (*get_attribute)(struct comp_dev *dev, uint32_t type, void *value)#

Gets attribute in component.

Param dev:

[in] Component device.

Param type:

[in] Attribute type.

Param value:

[out] Attribute value buffer.

Return:

0 if succeeded, error code otherwise.

int (*set_attribute)(struct comp_dev *dev, uint32_t type, void *value)#

Sets attribute in component.

Param dev:

[inout] Component device.

Param type:

[in] Attribute type.

Param value:

[in] Attribute value.

Return:

0 if succeeded, error code otherwise.

int (*dai_ts_config)(struct comp_dev *dev)#

Configures timestamping in attached DAI.

Param dev:

[inout] Component device.

Return:

0 on success, negative error code on failure.

int (*dai_ts_start)(struct comp_dev *dev)#

Starts timestamping.

Param dev:

[inout] Component device.

Return:

0 on success, negative error code on failure.

int (*dai_ts_stop)(struct comp_dev *dev)#

Stops timestamping.

Param dev:

[inout] Component device.

Return:

0 on success, negative error code on failure.

int (*dai_ts_get)(struct comp_dev *dev, struct timestamp_data *tsd)#

Gets timestamp.

Param dev:

[in] Component device.

Param tsd:

[out] Receives timestamp data.

Return:

0 on success, negative error code on failure.

int (*bind)(struct comp_dev *dev, const struct bind_info *bind_data)#

Bind, atomic - used to notify component of bind event.

Param dev:

[inout] Component device.

Param bind_data:

[in] Bind info.

Return:

0 on success, negative error code on failure.

int (*unbind)(struct comp_dev *dev, const struct bind_info *unbind_data)#

Unbind, atomic - used to notify component of unbind event.

Param dev:

[inout] Component device.

Param unbind_data:

[in] Unbind info.

Return:

0 on success, negative error code on failure.

int (*get_large_config)(struct comp_dev *dev, uint32_t param_id, bool first_block, bool last_block, uint32_t *data_offset, char *data)#

Gets large config in component.

Param dev:

[inout] Component device.

Param param_id:

[in] Parameter ID for each component.

Param first_block:

[in] First block of large block.

Param last_block:

[in] Last block of large block.

Param data_offset:

[inout] Block offset filled by callee.

Param data:

[out] Block data buffer.

Return:

0 if succeeded, error code otherwise.

int (*set_large_config)(struct comp_dev *dev, uint32_t param_id, bool first_block, bool last_block, uint32_t data_offset, const char *data)#

Set large config in component.

Param dev:

[inout] Component device.

Param param_id:

[in] Parameter ID for each component.

Param first_block:

[in] First block of large block.

Param last_block:

[in] Last block of large block.

Param data_offset:

[in] Block offset in large block.

Param data:

[in] Block data payload.

Return:

0 if succeeded, error code otherwise.

uint64_t (*get_total_data_processed)(struct comp_dev *dev, uint32_t stream_no, bool input)#

Returns total data processed in number of bytes.

Param dev:

[in] Component device.

Param stream_no:

[in] Index of input/output stream.

Param input:

[in] Selects between input (true) or output (false) stream direction.

Return:

Total data processed if succeeded, 0 otherwise.

struct comp_driver#
#include <src/include/sof/audio/component.h>

Audio component base driver “class”.

  • used by all other component types.

Public Members

uint32_t type#

SOF_COMP_ for driver.

const struct sof_uuid *uid#

Address to UUID value.

struct tr_ctx *tctx#

Pointer to trace context.

struct comp_ops ops#

component operations

const struct module_interface *adapter_ops#

module specific operations.

Intended to replace the ops field. Currently used by module_adapter.

struct k_heap *user_heap#

Userspace heap.

struct sof_uuid uid_cp#

UUID copy for LLEXT modules.

struct comp_driver_info#
#include <src/include/sof/audio/component.h>

Holds constant pointer to component driver.

Public Members

const struct comp_driver *drv#

pointer to component driver

const struct module_interface **adapter_ops#

pointer for updating ops

struct list_item list#

list of component drivers

struct comp_ipc_config#
#include <src/include/sof/audio/component.h>

Audio component base configuration from IPC at creation.

Public Members

uint32_t core#

Core we run on.

uint32_t id#

Component ID.

uint32_t pipeline_id#

Component pipeline ID.

uint32_t proc_domain#

Processing domain (COMP_PROCESSING_DOMAIN_*).

enum sof_comp_type type#

Component type (SOF_COMP_*).

uint32_t periods_sink#

Sink periods (0 means variable).

uint32_t periods_source#

Source periods (0 means variable).

uint32_t frame_fmt#

Frame format (SOF_IPC_FRAME_*).

uint32_t xrun_action#

Action to take on XRUN.

bool ipc_extended_init#

True if extended init is included in IPC payload.

uint32_t ipc_config_size#

Size of config received by IPC.

struct comp_perf_data#
#include <src/include/sof/audio/component.h>

Component performance measurement tracking data.

Public Members

size_t peak_of_measured_cpc#

Maximum measured CPC at runtime.

struct perf_data_item_comp *perf_data_item#

Pointer to performance data item.

struct comp_dev#
#include <src/include/sof/audio/component.h>

Audio component base device “class” used by all other component types.

Public Members

uint16_t state#

Component state (COMP_STATE_*).

uint32_t frames#

Number of frames copied to sink.

bool expect_eos#

End of stream expected flag.

struct pipeline *pipeline#

Parent pipeline reference.

struct task *task#

Component processing task (cross-core or DP).

uint32_t size#

Component allocated size in bytes.

uint32_t period#

Component processing period in microseconds.

uint32_t priority#

Component processing priority.

bool is_shared#

True if component is shared across cores.

struct comp_ipc_config ipc_config#

Component IPC configuration.

struct tr_ctx tctx#

Trace settings.

uint32_t direction#

Stream direction (enum sof_ipc_stream_direction).

bool direction_set#

Flag indicating that direction has been set.

const struct comp_driver *drv#

Component driver.

struct processing_module *mod#

Module adapter reference.

struct list_item bsource_list#

List of source buffers.

struct list_item bsink_list#

List of sink buffers.

struct comp_perf_data perf_data#

Performance data.

size_t ibs#

Input Buffer Size for pin 0.

size_t obs#

Output Buffer Size for pin 0.

size_t cpc#

Max DSP cycles per chunk.

size_t ll_chunk_size#

Size of 1ms input format chunk in bytes.

void *priv_data#

Driver private data.

struct comp_copy_limits#
#include <src/include/sof/audio/component.h>

Struct for use with comp_get_copy_limits() function.

Public Members

int frames#

Number of frames that can be copied.

int source_bytes#

Available bytes in source.

int sink_bytes#

Free bytes in sink.

int source_frame_bytes#

Frame size in bytes in source.

int sink_frame_bytes#

Frame size in bytes in sink.

struct comp_driver_list#
#include <src/include/sof/audio/component_ext.h>

Holds list of registered components’ drivers.

Public Members

struct list_item list#

list of component drivers

struct get_attribute_remote_payload#
#include <src/include/sof/audio/component_ext.h>

Remote payload for component get_attribute IPC4 message.

Public Members

uint32_t type#

Attribute type (COMP_ATTR_*).

void *value#

Pointer to attribute value storage.