Sound Open Firmware
Loading...
Searching...
No Matches
Component's Common Helpers

Data Structures

struct  comp_copy_limits
 Struct for use with comp_get_copy_limits() function. More...

Macros

#define comp_set_drvdata(c, data)
 Assigns private data to component device.
#define comp_get_drvdata(c)
 Retrieves driver private data from component device.
#define DECLARE_MODULE(init)
 Usage at the end of an independent module file: DECLARE_MODULE(sys_*_init);.

Functions

static uint32_t dev_comp_id (const struct comp_dev *dev)
 Retrieves Component id from device.
static uint32_t dev_comp_pipe_id (const struct comp_dev *dev)
 Retrieves Component pipeline id from device.
static enum sof_comp_type dev_comp_type (const struct comp_dev *dev)
 Retrieves component type from device.
static void comp_init (const struct comp_driver *drv, struct comp_dev *dev, size_t bytes)
 Initialize common part of a component device.
static struct comp_dev * comp_alloc (const struct comp_driver *drv, size_t bytes)
 Allocates memory for the component device and initializes common part.
static void comp_free_device (struct comp_dev *dev)
 Frees memory allocated for component device.
static struct processing_module * comp_mod (const struct comp_dev *dev)
 Module adapter associated with a component.
int comp_set_state (struct comp_dev *dev, int cmd)
 Component state set.
static void component_set_nearest_period_frames (struct comp_dev *current, uint32_t rate)
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 (data available in source vs.
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 (data available in source vs.
static int comp_get_state (const struct comp_dev *dev)
 Get component state.
static int comp_buffer_get_source_state (const struct comp_buffer *buffer)
 helper, provide state of a component connected to a buffer as a data provider
static int comp_buffer_get_sink_state (const struct comp_buffer *buffer)
 helper, provide state of a component connected to a buffer as a data consumer
int comp_verify_params (struct comp_dev *dev, uint32_t flag, struct sof_ipc_stream_params *params)
 Warning: duplicate declaration in topology.h.

Component registration

int comp_register (struct comp_driver_info *drv)
 Registers the component driver on the list of available components.
void comp_unregister (struct comp_driver_info *drv)
 Unregisters the component driver from the list of available components.
int comp_set_adapter_ops (const struct comp_driver *drv, const struct module_interface *ops)
 Set adapter ops for a dynamically created driver.

XRUN handling.

static void comp_underrun (struct comp_dev *dev, struct comp_buffer *source, uint32_t copy_bytes)
 Called by the component device when underrun is detected.
static void comp_overrun (struct comp_dev *dev, struct comp_buffer *sink, uint32_t copy_bytes)
 Called by component device when overrun is detected.

Detailed Description

Macro Definition Documentation

◆ comp_get_drvdata

#define comp_get_drvdata ( c)
Value:
(c->priv_data)

Retrieves driver private data from component device.

Parameters
cComponent device.
Returns
Private data.

◆ comp_set_drvdata

#define comp_set_drvdata ( c,
data )
Value:
(c->priv_data = data)
uint32_t data[]
Definition debug_stream_slot.h:2

Assigns private data to component device.

Parameters
cComponent device.
dataPrivate data.

◆ DECLARE_MODULE

#define DECLARE_MODULE ( init)
Value:
__attribute__((__used__)) \
__section(".initcall") static void(*f##init)(void) = init

Usage at the end of an independent module file: DECLARE_MODULE(sys_*_init);.

Function Documentation

◆ comp_alloc()

struct comp_dev * comp_alloc ( const struct comp_driver * drv,
size_t bytes )
inlinestatic

Allocates memory for the component device and initializes common part.

Parameters
drvParent component driver.
bytesSize of the component device in bytes.
Returns
Pointer to the component device.

◆ comp_buffer_get_sink_state()

int comp_buffer_get_sink_state ( const struct comp_buffer * buffer)
inlinestatic

helper, provide state of a component connected to a buffer as a data consumer

Parameters
buffera buffer to be checked
Return values
COMP_STATE_NOT_EXISTif there's no connected component
Returns
state of the component

◆ comp_buffer_get_source_state()

int comp_buffer_get_source_state ( const struct comp_buffer * buffer)
inlinestatic

helper, provide state of a component connected to a buffer as a data provider

Parameters
buffera buffer to be checked
Return values
COMP_STATE_NOT_EXISTif there's no connected component
Returns
state of the component

◆ comp_free_device()

void comp_free_device ( struct comp_dev * dev)
inlinestatic

Frees memory allocated for component device.

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

Parameters
devPointer to the component device.

◆ comp_get_copy_limits()

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 (data available in source vs.

free space available in sink).

Parameters
[in]sourceSource buffer.
[in]sinkSink buffer.
[out]clCurrent copy limits.

◆ comp_get_copy_limits_frame_aligned()

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 (data available in source vs.

free space available in sink).

Parameters
[in]sourceBuffer of source.
[in]sinkBuffer of sink.
[out]clCurrent copy limits.

◆ comp_get_state()

int comp_get_state ( const struct comp_dev * dev)
inlinestatic

Get component state.

Parameters
devComponent from which user wants to read status.
Return values
COMP_STATE_NOT_EXISTif there's no connected component
Returns
state of the component

◆ comp_init()

void comp_init ( const struct comp_driver * drv,
struct comp_dev * dev,
size_t bytes )
inlinestatic

Initialize common part of a component device.

Parameters
drvParent component driver.
devDevice.
bytesSize of the component device in bytes.

◆ comp_mod()

struct processing_module * comp_mod ( const struct comp_dev * dev)
inlinestatic

Module adapter associated with a component.

Parameters
devComponent device

◆ comp_overrun()

void comp_overrun ( struct comp_dev * dev,
struct comp_buffer * sink,
uint32_t copy_bytes )
inlinestatic

Called by component device when overrun is detected.

Parameters
devComponent device.
sinkSink buffer.
copy_bytesRequested size of free space to be available.

◆ comp_register()

int comp_register ( struct comp_driver_info * drv)

Registers the component driver on the list of available components.

Parameters
drvComponent driver to be registered.
Returns
0 if succeeded, error code otherwise.

◆ comp_set_adapter_ops()

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

Set adapter ops for a dynamically created driver.

Parameters
drvComponent driver to update.
opsModule interface operations.
Returns
0 or a negative error code

◆ comp_set_state()

int comp_set_state ( struct comp_dev * dev,
int cmd )

Component state set.

Parameters
devComponent device.
cmdCommand, one of COMP_TRIGGER_....
Returns
0 if succeeded, error code otherwise.

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

◆ comp_underrun()

void comp_underrun ( struct comp_dev * dev,
struct comp_buffer * source,
uint32_t copy_bytes )
inlinestatic

Called by the component device when underrun is detected.

Parameters
devComponent device.
sourceSource buffer.
copy_bytesRequested size of data to be available.

◆ comp_unregister()

void comp_unregister ( struct comp_driver_info * drv)

Unregisters the component driver from the list of available components.

Parameters
drvComponent driver to be unregistered.

◆ comp_verify_params()

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

Warning: duplicate declaration in topology.h.

Called by component in params() function in order to set and update some of downstream (playback) or upstream (capture) buffer parameters with pcm parameters. There is a possibility to specify which of parameters won't be overwritten (e.g. SRC component should not overwrite rate parameter, because it is able to change it).

Parameters
devComponent device
flagSpecifies which parameter should not be updated
paramspcm params

◆ component_set_nearest_period_frames()

void component_set_nearest_period_frames ( struct comp_dev * current,
uint32_t rate )
inlinestatic

◆ dev_comp_id()

uint32_t dev_comp_id ( const struct comp_dev * dev)
inlinestatic

Retrieves Component id from device.

Parameters
devDevice.
Returns
Component id.

◆ dev_comp_pipe_id()

uint32_t dev_comp_pipe_id ( const struct comp_dev * dev)
inlinestatic

Retrieves Component pipeline id from device.

Parameters
devDevice.
Returns
Component pipeline id.

◆ dev_comp_type()

enum sof_comp_type dev_comp_type ( const struct comp_dev * dev)
inlinestatic

Retrieves component type from device.

Parameters
devDevice.
Returns
Component type.