|
Sound Open Firmware
|
Unified interface contracts, lifecycle callbacks, and streaming endpoints for built-in audio components and dynamic LLEXT processing modules (Volume, Mixer, EQ, DRC, SRC, etc.). More...
Files | |
| file | audio_stream.h |
| Circular audio buffer calculation and wrap utilities for processing modules. | |
| file | format.h |
| Audio sample format conversion and size calculation helpers for modules. | |
| file | sink_api.h |
| Sink audio endpoint API for module output buffers. | |
| file | source_api.h |
| Source audio endpoint API for module input buffers. | |
| file | base.h |
| Base definitions and structures for loadable audio modules. | |
| file | interface.h |
| Dynamic module interface, lifecycle callbacks, and buffer contracts. | |
| file | llext.h |
| LLEXT manifest macros and declarations for loadable ELF extensions. | |
| file | system_service.h |
| System services provided by the base firmware to loadable modules. | |
| file | sink_api.h |
| Audio sink API helpers and stream configuration. | |
| file | source_api.h |
| Audio source API helpers and stream configuration. | |
Data Structures | |
| struct | sof_audio_stream_params |
| set of parameters describing audio stream this structure is shared between audio_stream.h and sink/source interface TODO: compressed formats More... | |
| struct | cir_buf_source |
| Read-only view of source data in a circular buffer. More... | |
| struct | cir_buf_sink |
| Writable view of sink data in a circular buffer. More... | |
| struct | sof_uuid |
| UUID (Universally Unique IDentifier) structure. More... | |
| struct | sof_uuid_entry |
| Connects UUID with component description. More... | |
Macros | |
| #define | UUID_SIZE 16 |
| UUID is 16 bytes long. | |
| #define | UUID_NAME_MAX_LEN 32 |
| UUID name string max length in bytes, including null termination. | |
| #define | _UUID_INIT(va, vb, vc, d0, d1, d2, d3, d4, d5, d6, d7) { va, vb, vc, { d0, d1, d2, d3, d4, d5, d6, d7 } } |
| #define | _UUID(uuid_name) (&_##uuid_name) |
| #define | _RT_UUID(uuid_name) (&uuid_name) |
| #define | _DEF_UUID(entity_name, uuid_name, initializer) |
| #define | SOF_DEFINE_UUID(entity_name, uuid_name, va, vb, vc, vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7) |
| Declares runtime UUID (aaaaaaaa-bbbb-cccc-d0d1-d2d3d4d5d6d7) and name. | |
| #define | SOF_REG_UUID(name) _UUIDREG_##name |
| Get UUID value sourced from the fixed SOF registry. | |
| #define | SOF_DEFINE_REG_UUID(name) _DEF_UUID(#name, name##_uuid, SOF_REG_UUID(name)) |
| Defines UUID sourced from the fixed SOF registry. | |
| #define | SOF_UUID(uuid_name) _UUID(uuid_name) |
| Creates local unique 32-bit representation of UUID structure. | |
| #define | SOF_RT_UUID(uuid_name) _RT_UUID(uuid_name) |
| Dereference unique 32-bit representation of UUID structure in runtime. | |
Enumerations | |
| enum | sof_audio_buffer_state { AUDIOBUF_STATE_INITIAL , AUDIOBUF_STATE_READY , AUDIOBUF_STATE_END_OF_STREAM , AUDIOBUF_STATE_END_OF_STREAM_FLUSH } |
| Define states of an audio stream buffer connecting two components. More... | |
Functions | |
| static size_t | circ_buf_frames_without_wrap (const void *began, const void *end, size_t sample_bytes, size_t channels) |
| Number of whole frames available before a circular buffer wraps. | |
| static size_t | cir_buf_samples_to_wrap_s16 (const int16_t *ptr, const int16_t *buf_start, size_t buf_samples) |
| Calculates numbers of s16 samples to buffer wrap. | |
| static size_t | cir_buf_samples_to_wrap_s32 (const int32_t *ptr, const int32_t *buf_start, size_t buf_samples) |
| Calculates numbers of s32 samples to buffer wrap. | |
| static size_t | cir_buf_samples_without_wrap_s16 (const void *ptr, const void *buf_end) |
| Calculates numbers of s16 samples to buffer wrap when reading a circular buffer forward from current pointer towards the buffer end. | |
| static size_t | cir_buf_samples_without_wrap_s32 (const void *ptr, const void *buf_end) |
| Calculates numbers of s32 samples to buffer wrap when reading a circular buffer forward from current pointer towards the buffer end. | |
| static size_t | cir_buf_bytes_without_wrap (const void *ptr, const void *buf_end) |
| Calculates number of bytes to buffer wrap when reading a circular buffer forward from current pointer towards the buffer end. | |
| static void * | cir_buf_wrap (const void *ptr, const void *buf_addr, const void *buf_end) |
| Verifies the pointer and performs rollover when reaching the end of the circular buffer. | |
| static const void * | source_cir_buf_wrap (const void *ptr, const void *buf_addr, const void *buf_end) |
| Verifies a read pointer and performs rollover when reaching the end of the circular buffer. | |
| static size_t | cir_buf_bytes_without_wrap_rewind (const void *ptr, const void *buf_start) |
| Calculates number of bytes to buffer wrap when reading a circular buffer backwards from current pointer towards the buffer start. | |
| static const void * | source_cir_buf_rewind_wrap (const void *ptr, const void *buf_start, const void *buf_end) |
| Verifies the pointer and performs rollover when reading a read-only circular buffer backwards past its start address. | |
| void | sink_init (struct sof_sink *sink, const struct sink_ops *ops, struct sof_audio_stream_params *audio_stream_params) |
| Initialize sink API structure before any operation. | |
| size_t | sink_get_num_of_processed_bytes (struct sof_sink *sink) |
| Get total number of bytes processed by the sink (committed by sink_commit_buffer()). | |
| void | sink_reset_num_of_processed_bytes (struct sof_sink *sink) |
| Reset counter of total processed bytes to zero. | |
| bool | sink_get_overrun (struct sof_sink *sink) |
| Check if buffer overrun is permitted on sink stream. | |
| void | sink_set_min_free_space (struct sof_sink *sink, size_t min_free_space) |
| Set minimum free space required in sink buffer. | |
| void | source_init (struct sof_source *source, const struct source_ops *ops, struct sof_audio_stream_params *audio_stream_params) |
| Initialize source API structure before any operation. | |
| size_t | source_get_num_of_processed_bytes (struct sof_source *source) |
| Get total number of bytes processed by the source (freed by source_release_data()). | |
| void | source_reset_num_of_processed_bytes (struct sof_source *source) |
| Reset counter of total processed bytes to zero. | |
| bool | source_get_underrun (struct sof_source *source) |
| Check if buffer underrun is permitted on source stream. | |
| uint32_t | source_get_id (struct sof_source *source) |
| Get unique stream identifier for source. | |
| int | source_set_frm_fmt (struct sof_source *source, enum sof_ipc_frame frm_fmt) |
| Set audio frame format for source. | |
| int | source_set_valid_fmt (struct sof_source *source, enum sof_ipc_frame valid_sample_fmt) |
| Set valid sample format for source. | |
| int | source_set_rate (struct sof_source *source, unsigned int rate) |
| Set sample rate for source. | |
| int | source_set_channels (struct sof_source *source, unsigned int channels) |
| Set channel count for source. | |
| int | source_set_underrun (struct sof_source *source, bool underrun_permitted) |
| Configure whether underrun is permitted on source. | |
| int | source_set_buffer_fmt (struct sof_source *source, uint32_t buffer_fmt) |
| Set buffer format for source. | |
| void | source_set_min_available (struct sof_source *source, size_t min_available) |
| Set minimum available data requirement in bytes. | |
| int | source_set_params (struct sof_source *source, struct sof_ipc_stream_params *params, bool force_update) |
| Configure initial set of audio parameters. | |
| int | source_set_alignment_constants (struct sof_source *source, const uint32_t byte_align, const uint32_t frame_align_req) |
| Set byte and frame alignment constants for source stream. | |
Unified interface contracts, lifecycle callbacks, and streaming endpoints for built-in audio components and dynamic LLEXT processing modules (Volume, Mixer, EQ, DRC, SRC, etc.).
UUID API specification.
| #define _DEF_UUID | ( | entity_name, | |
| uuid_name, | |||
| initializer | |||
| ) |
| #define _RT_UUID | ( | uuid_name | ) | (&uuid_name) |
| #define _UUID | ( | uuid_name | ) | (&_##uuid_name) |
| #define _UUID_INIT | ( | va, | |
| vb, | |||
| vc, | |||
| d0, | |||
| d1, | |||
| d2, | |||
| d3, | |||
| d4, | |||
| d5, | |||
| d6, | |||
| d7 | |||
| ) | { va, vb, vc, { d0, d1, d2, d3, d4, d5, d6, d7 } } |
| #define SOF_DEFINE_REG_UUID | ( | name | ) | _DEF_UUID(#name, name##_uuid, SOF_REG_UUID(name)) |
Defines UUID sourced from the fixed SOF registry.
As for SOF_DEFINE_UUID(), but the ID value is sourced by name from the uuid-registry.txt file distributed with the source tree. The string name field will be identical with the name passed (which is passed as a symbol!), runtime symbol (e.g. the "uuid_name" argument to SOF_DEFINE_UUID()) will be the same, postfixed with a "_uuid".
| name | Name of the UUID, must match an entry in uuid-registry.txt |
| #define SOF_DEFINE_UUID | ( | entity_name, | |
| uuid_name, | |||
| va, | |||
| vb, | |||
| vc, | |||
| vd0, | |||
| vd1, | |||
| vd2, | |||
| vd3, | |||
| vd4, | |||
| vd5, | |||
| vd6, | |||
| vd7 | |||
| ) |
Declares runtime UUID (aaaaaaaa-bbbb-cccc-d0d1-d2d3d4d5d6d7) and name.
UUID value from variables declared with this macro are accessible in runtime code - to dereference use SOF_RT_UUID()
| entity_name | Name of the object pinted by the software tools. |
| uuid_name | Uuid symbol name used with SOF_UUID() and SOF_RT_UUID(). |
| va | aaaaaaaa value. |
| vb | bbbb value. |
| vc | cccc value. |
| vd0 | d0 value (note how d0 and d1 are grouped in formatted uuid) |
| vd1 | d1 value. |
| vd2 | d2 value. |
| vd3 | d3 value. |
| vd4 | d4 value. |
| vd5 | d5 value. |
| vd6 | d6 value. |
| vd7 | d7 value. |
| #define SOF_REG_UUID | ( | name | ) | _UUIDREG_##name |
Get UUID value sourced from the fixed SOF registry.
The ID value is sourced by name from the uuid-registry.txt file distributed with the source tree.
| name | Name of the UUID, must match an entry in uuid-registry.txt |
| #define SOF_RT_UUID | ( | uuid_name | ) | _RT_UUID(uuid_name) |
Dereference unique 32-bit representation of UUID structure in runtime.
| uuid_name | UUID symbol name declared with DECLARE_SOF_RT_UUID(). |
| #define SOF_UUID | ( | uuid_name | ) | _UUID(uuid_name) |
Creates local unique 32-bit representation of UUID structure.
In Zephyr builds, this has the same address as the result of SOF_RT_UUID, but has type of "struct sof_uuid *" and not "struct sof_uid_record *"
| uuid_name | UUID symbol name declared with DECLARE_SOF_UUID() or DECLARE_SOF_RT_UUID(). |
| #define UUID_NAME_MAX_LEN 32 |
UUID name string max length in bytes, including null termination.
| #define UUID_SIZE 16 |
UUID is 16 bytes long.
Define states of an audio stream buffer connecting two components.
This enum represents the lifecycle of an audio stream, including its initialization, readiness, and end-of-stream handling. It is used to track and manage the state transitions of the stream during audio processing.
| Enumerator | |
|---|---|
| AUDIOBUF_STATE_INITIAL | |
| AUDIOBUF_STATE_READY | |
| AUDIOBUF_STATE_END_OF_STREAM | |
| AUDIOBUF_STATE_END_OF_STREAM_FLUSH | |
|
inlinestatic |
Calculates number of bytes to buffer wrap when reading a circular buffer forward from current pointer towards the buffer end.
| ptr | Read or write pointer of circular buffer. |
| buf_end | End address of circular buffer. |
|
inlinestatic |
Calculates number of bytes to buffer wrap when reading a circular buffer backwards from current pointer towards the buffer start.
| ptr | Read or write pointer of circular buffer. |
| buf_start | Start address of circular buffer. |
|
inlinestatic |
Calculates numbers of s16 samples to buffer wrap.
| ptr | Read or write pointer of circular buffer. |
| buf_start | Start address of circular buffer. |
| buf_samples | Total size of circular buffer in samples. |
|
inlinestatic |
Calculates numbers of s32 samples to buffer wrap.
| ptr | Read or write pointer of circular buffer. |
| buf_start | Start address of circular buffer. |
| buf_samples | Total size of circular buffer in samples. |
|
inlinestatic |
Calculates numbers of s16 samples to buffer wrap when reading a circular buffer forward from current pointer towards the buffer end.
| ptr | Read or write pointer of circular buffer. |
| buf_end | End address of circular buffer. |
|
inlinestatic |
Calculates numbers of s32 samples to buffer wrap when reading a circular buffer forward from current pointer towards the buffer end.
| ptr | Read or write pointer of circular buffer. |
| buf_end | End address of circular buffer. |
|
inlinestatic |
Verifies the pointer and performs rollover when reaching the end of the circular buffer.
| ptr | Read pointer that may have moved past the buffer end. |
| buf_addr | Start address of the circular buffer. |
| buf_end | End address of the circular buffer. |
|
inlinestatic |
Number of whole frames available before a circular buffer wraps.
Computes (end - began) / channels expressed in frames. The pointer distance is evaluated in bytes so the helper works for any sample width.
| began | current position in the circular buffer |
| end | one past the last sample of the circular buffer |
| sample_bytes | size of a single sample in bytes (2 for s16, 4 for s32) |
| channels | number of channels, i.e. samples per frame |
| size_t sink_get_num_of_processed_bytes | ( | struct sof_sink * | sink | ) |
Get total number of bytes processed by the sink (committed by sink_commit_buffer()).
| [in] | sink | Pointer to sink structure. |
| bool sink_get_overrun | ( | struct sof_sink * | sink | ) |
Check if buffer overrun is permitted on sink stream.
| [in] | sink | Pointer to sink structure. |
| void sink_init | ( | struct sof_sink * | sink, |
| const struct sink_ops * | ops, | ||
| struct sof_audio_stream_params * | audio_stream_params | ||
| ) |
Initialize sink API structure before any operation.
NOTE: audio_stream_params must be accessible by the caller core, and the implementation must ensure coherent access to the parameters (e.g. for a cross-core shared queue, it must be located in non-cached memory).
| [in,out] | sink | Pointer to sink structure. |
| [in] | ops | Pointer to API operations vtable. |
| [in] | audio_stream_params | Pointer to structure with audio parameters. |
| void sink_reset_num_of_processed_bytes | ( | struct sof_sink * | sink | ) |
Reset counter of total processed bytes to zero.
| [in,out] | sink | Pointer to sink structure. |
| void sink_set_min_free_space | ( | struct sof_sink * | sink, |
| size_t | min_free_space | ||
| ) |
Set minimum free space required in sink buffer.
| [in,out] | sink | Pointer to sink structure. |
| [in] | min_free_space | Minimum free space in bytes. |
|
inlinestatic |
Verifies the pointer and performs rollover when reading a read-only circular buffer backwards past its start address.
| ptr | Pointer that may have moved below the buffer start. |
| buf_start | Start address of the circular buffer. |
| buf_end | End address of the circular buffer. |
|
inlinestatic |
Verifies a read pointer and performs rollover when reaching the end of the circular buffer.
| ptr | Read pointer that may have moved past the buffer end. |
| buf_addr | Start address of the circular buffer. |
| buf_end | End address of the circular buffer. |
| uint32_t source_get_id | ( | struct sof_source * | source | ) |
Get unique stream identifier for source.
| [in] | source | Pointer to source structure. |
| size_t source_get_num_of_processed_bytes | ( | struct sof_source * | source | ) |
Get total number of bytes processed by the source (freed by source_release_data()).
| [in] | source | Pointer to source structure. |
| bool source_get_underrun | ( | struct sof_source * | source | ) |
Check if buffer underrun is permitted on source stream.
| [in] | source | Pointer to source structure. |
| void source_init | ( | struct sof_source * | source, |
| const struct source_ops * | ops, | ||
| struct sof_audio_stream_params * | audio_stream_params | ||
| ) |
Initialize source API structure before any operation.
NOTE: audio_stream_params must be accessible by the caller core, and the implementation must ensure coherent access to the parameters (e.g. for a cross-core shared queue, it must be located in non-cached memory).
| [in,out] | source | Pointer to source structure. |
| [in] | ops | Pointer to API operations vtable. |
| [in] | audio_stream_params | Pointer to structure with audio parameters. |
| void source_reset_num_of_processed_bytes | ( | struct sof_source * | source | ) |
Reset counter of total processed bytes to zero.
| [in,out] | source | Pointer to source structure. |
| int source_set_alignment_constants | ( | struct sof_source * | source, |
| const uint32_t | byte_align, | ||
| const uint32_t | frame_align_req | ||
| ) |
Set byte and frame alignment constants for source stream.
Sets frame_align_shift and frame_align of stream according to byte_align and frame_align_req requirements. Once the channel number and frame size are determined, the frame_align and frame_align_shift are determined too. These features are used by audio_stream_get_avail_frames_aligned() to calculate available frames.
| [in,out] | source | Pointer to source structure. |
| [in] | byte_align | Processing byte alignment requirement. |
| [in] | frame_align_req | Processing frames alignment requirement. |
| int source_set_buffer_fmt | ( | struct sof_source * | source, |
| uint32_t | buffer_fmt | ||
| ) |
Set buffer format for source.
| [in,out] | source | Pointer to source structure. |
| [in] | buffer_fmt | Buffer format identifier. |
| int source_set_channels | ( | struct sof_source * | source, |
| unsigned int | channels | ||
| ) |
Set channel count for source.
| [in,out] | source | Pointer to source structure. |
| [in] | channels | Number of audio channels. |
| int source_set_frm_fmt | ( | struct sof_source * | source, |
| enum sof_ipc_frame | frm_fmt | ||
| ) |
Set audio frame format for source.
| [in,out] | source | Pointer to source structure. |
| [in] | frm_fmt | Audio frame format. |
| void source_set_min_available | ( | struct sof_source * | source, |
| size_t | min_available | ||
| ) |
Set minimum available data requirement in bytes.
| [in,out] | source | Pointer to source structure. |
| [in] | min_available | Minimum available bytes. |
| int source_set_params | ( | struct sof_source * | source, |
| struct sof_ipc_stream_params * | params, | ||
| bool | force_update | ||
| ) |
Configure initial set of audio parameters.
| [in,out] | source | Pointer to source structure. |
| [in] | params | Audio stream parameters. |
| [in] | force_update | True to force parameters override. |
| int source_set_rate | ( | struct sof_source * | source, |
| unsigned int | rate | ||
| ) |
Set sample rate for source.
| [in,out] | source | Pointer to source structure. |
| [in] | rate | Sample rate in Hz. |
| int source_set_underrun | ( | struct sof_source * | source, |
| bool | underrun_permitted | ||
| ) |
Configure whether underrun is permitted on source.
| [in,out] | source | Pointer to source structure. |
| [in] | underrun_permitted | True if underrun is permitted, false otherwise. |
| int source_set_valid_fmt | ( | struct sof_source * | source, |
| enum sof_ipc_frame | valid_sample_fmt | ||
| ) |
Set valid sample format for source.
| [in,out] | source | Pointer to source structure. |
| [in] | valid_sample_fmt | Valid sample format. |