The module directory contains the concrete module_interface implementations that bridge the core SOF Component API with various audio processing algorithms. These adapters translate the generic initialization, parameter configuration, and process loop calls into the specific operational sequences required by different module frameworks.
The directory primarily houses three distinct module adapters:
- Generic Core Adapter (
generic.c) - Modules (IADK/Shim) Adapter (
modules.c) - Cadence DSP Codec Adapter (
cadence.c,cadence_ipc4.c)
The Generic adapter provides the default runtime container for typical native SOF processing modules (e.g., volume, eq, src).
It implements the full struct module_interface contract:
- Memory Management: It intercepts memory allocation mappings using
mod_balloc_alignand tracks memory requests in a module-specific resource pool (module_resource). When the module goes out of scope, the framework garbage-collects any leaked allocations automatically viamod_free_all(). - Configuration Handling: Manages large blob configuration messages across multiple IPC fragments (
module_set_configuration). It allocates memory forruntime_paramsuntil the blob is fully assembled, then triggers the underlying algorithm with the completed struct. - State Machine Enforcement: It wraps
process_audio_streamandprocess_raw_datacalls to verify the module is in eitherMODULE_IDLEorMODULE_PROCESSINGstates before execution.
The modules.c base is an extension adapter designed specifically to run Intel Audio Development Kit (IADK) 3rd party algorithms.
Unlike the generic modules, the IADK modules are object-oriented C++ architectures linked into a separate library (module_adapter/iadk). This file acts as the primary C entry point wrapper.
- It utilizes the
iadk_wrapper_*C-bridge functions to invoke methods on the C++intel_adsp::ProcessingModuleInterfaceclasses. - It exposes the standard
DECLARE_MODULE_ADAPTER(processing_module_adapter_interface)that is bound to the SOF pipeline.
This is a highly specialized adapter used for integrating Xtensa Audio (XA) codecs from Cadence (e.g., MP3, AAC, Vorbis, SBC, DAB).
The cadence.c implementation maps the standard SOF pipeline controls into the Cadence memory buffer management and synchronous execution models.
graph TD
subgraph SOF Initialization
INIT["cadence_codec_init"]
CONFIG["cadence_configure_codec_params"]
RESOLVE["cadence_codec_resolve_api"]
end
subgraph Cadence Library Init XA API
MEMTABS["cadence_codec_init_memory_tables"]
GETSIZE["XA_API_CMD_GET_MEM_INFO_SIZE"]
SETPTR["XA_API_CMD_SET_MEM_PTR"]
end
subgraph Data Processing Loop
PROC["cadence_codec_process_data"]
FILL["XA_API_CMD_SET_INPUT_BYTES"]
EXEC["XA_API_CMD_EXECUTE"]
GETOUT["XA_API_CMD_GET_OUTPUT_BYTES"]
end
INIT --> RESOLVE
RESOLVE --> CONFIG
CONFIG --> MEMTABS
MEMTABS -. Iterates Memory Types .-> GETSIZE
GETSIZE -. Assigns Buffers .-> SETPTR
SETPTR ==>|Pipeline Trigger| PROC
PROC --> FILL
FILL --> EXEC
EXEC --> GETOUT
Unlike standard modules that directly read from a sof_source API, Cadence codecs require their memory isolated exclusively into exact predefined chunks categorized by "type". cadence_codec_init_memory_tables iterates through the codec's hardware definition to construct these memory areas:
XA_MEMTYPE_INPUTXA_MEMTYPE_OUTPUTXA_MEMTYPE_SCRATCHXA_MEMTYPE_PERSIST
The SOF adapter allocates tracking structures via mod_alloc_align for each of these mandatory regions prior to audio playback.
During cadence_codec_process(), the adapter:
- Performs
source_get_dataand mechanically copies audio bytes into the isolatedXA_MEMTYPE_INPUTbuffer. - Invokes the Xtensa Audio codec API (
XA_API_CMD_EXECUTE). - Reads the produced byte count and copies them back out from
XA_MEMTYPE_OUTPUTinto thesof_sink.