13#ifndef __SOF_AUDIO_MODULE_GENERIC__
14#define __SOF_AUDIO_MODULE_GENERIC__
31#define IS_PROCESSING_MODE_AUDIO_STREAM(mod) ((mod)->proc_type == MODULE_PROCESS_TYPE_STREAM)
32#define IS_PROCESSING_MODE_RAW_DATA(mod) ((mod)->proc_type == MODULE_PROCESS_TYPE_RAW)
33#define IS_PROCESSING_MODE_SINK_SOURCE(mod) ((mod)->proc_type == MODULE_PROCESS_TYPE_SOURCE_SINK)
37#elif CONFIG_IPC_MAJOR_3
38#define IPC_MOD_CMD(v) .cmd = v,
43#define SET_MODULE_ADAPTER_TCTX(tr)
45#define SET_MODULE_ADAPTER_TCTX(tr) .tctx = &(tr),
58#define DECLARE_MODULE_ADAPTER(adapter, uuid, tr) \
59static const struct comp_driver comp_##adapter##_module = { \
60 .type = SOF_COMP_MODULE_ADAPTER, \
61 .uid = SOF_RT_UUID(uuid), \
62 SET_MODULE_ADAPTER_TCTX(tr) \
64 .create = module_adapter_new, \
65 .prepare = module_adapter_prepare, \
66 .params = module_adapter_params, \
67 .copy = module_adapter_copy, \
68 IPC_MOD_CMD(module_adapter_cmd) \
69 .trigger = module_adapter_trigger, \
70 .reset = module_adapter_reset, \
71 .free = module_adapter_free, \
72 .set_large_config = module_set_large_config,\
73 .get_large_config = module_get_large_config,\
74 .get_attribute = module_adapter_get_attribute,\
75 .set_attribute = module_adapter_set_attribute,\
76 .bind = module_adapter_bind,\
77 .unbind = module_adapter_unbind,\
78 .get_total_data_processed = module_adapter_get_total_data_processed,\
79 .dai_get_hw_params = module_adapter_get_hw_params,\
80 .position = module_adapter_position,\
81 .dai_ts_config = module_adapter_ts_config_op,\
82 .dai_ts_start = module_adapter_ts_start_op,\
83 .dai_ts_stop = module_adapter_ts_stop_op,\
84 .dai_ts_get = module_adapter_ts_get_op,\
86 .adapter_ops = &(adapter), \
89static struct comp_driver_info comp_module_##adapter##_info = { \
90 .drv = &comp_##adapter##_module, \
93UT_STATIC void sys_comp_module_##adapter##_init(void) \
95 comp_register(&comp_module_##adapter##_info); \
98DECLARE_MODULE(sys_comp_module_##adapter##_init)
185#define SOF_MODULE_API_PRIVATE
206#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
209void *z_impl_mod_balloc_align(
struct processing_module *mod,
size_t size,
size_t alignment);
210#define mod_balloc_align z_impl_mod_balloc_align
239#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
256void *z_impl_mod_alloc_ext(
struct processing_module *mod, uint32_t flags,
size_t size,
260#define mod_alloc_ext z_impl_mod_alloc_ext
261#define mod_free z_impl_mod_free
262#define mod_free_all z_impl_mod_free_all
312 memset(ret, 0, size);
337 memset(msg, 0,
sizeof(*msg));
358 uint32_t
header, uint32_t size)
382#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
386__syscall
struct comp_data_blob_handler *mod_data_blob_handler_new(
struct processing_module *mod);
394 const uint8_t *fragment,
size_t fragment_size);
396struct comp_data_blob_handler *z_impl_mod_data_blob_handler_new(
struct processing_module *mod);
399 const uint8_t *fragment,
size_t fragment_size);
400#define mod_data_blob_handler_new z_impl_mod_data_blob_handler_new
401#define mod_data_blob_set z_impl_mod_data_blob_set
403void mod_data_blob_handler_free(
struct processing_module *mod,
struct comp_data_blob_handler *dbh);
406#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
407__syscall
const void *mod_fast_get(
struct processing_module *mod,
const void *
const dram_ptr,
410const void *z_impl_mod_fast_get(
struct processing_module *mod,
const void *
const dram_ptr,
412#define mod_fast_get z_impl_mod_fast_get
417 struct sof_source **sources,
int num_of_sources,
418 struct sof_sink **sinks,
int num_of_sinks);
429 for (i = 0; i < num_of_sources; i++)
433 for (i = 0; i < num_of_sinks; i++)
463 struct sof_source **sources,
int num_of_sources,
464 struct sof_sink **sinks,
int num_of_sinks);
468 int num_output_buffers);
474 const uint8_t *fragment,
size_t fragment_size, uint8_t *response,
475 size_t response_size);
481struct userspace_context;
484 void *mod_priv,
struct userspace_context *user_ctx,
496#if CONFIG_IPC_MAJOR_3
511 bool last_block, uint32_t data_offset,
const char *
data)
518 bool last_block, uint32_t *data_offset,
char *
data)
537 uint32_t stream_no,
bool input)
544 int num_input_buffers,
546 int num_output_buffers)
549 output_buffers, num_output_buffers);
554 bool last_block, uint32_t data_offset,
const char *
data);
556 bool last_block, uint32_t *data_offset,
char *
data);
562 uint32_t stream_no,
bool input);
566 int num_input_buffers,
568 int num_output_buffers)
573 output_buffers, num_output_buffers);
584#if CONFIG_ZEPHYR_NATIVE_DRIVERS
594#if CONFIG_IPC_MAJOR_4
638 return mod->dev->period;
641#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
642#include <zephyr/syscalls/generic.h>
Base definitions and structures for loadable audio modules.
Component API definition.
void * mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t size, size_t alignment)
Allocate memory for a module with explicit flags and alignment.
size_t module_adapter_heap_usage(struct processing_module *mod, size_t *hwm)
int module_adapter_ts_get_op(struct comp_dev *dev, struct timestamp_data *tsd)
static int module_adapter_unbind(struct comp_dev *dev, const struct bind_info *unbind_data)
Definition generic.h:530
int module_adapter_prepare(struct comp_dev *dev)
static int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
Definition generic.h:498
int module_adapter_ts_start_op(struct comp_dev *dev)
module_state
Module-specific states.
Definition generic.h:104
@ MODULE_INITIALIZED
Module initialized or reset.
Definition generic.h:106
@ MODULE_PROCESSING
Module is processing samples now.
Definition generic.h:108
@ MODULE_DISABLED
Module isn't initialized yet or has been freed.
Definition generic.h:105
@ MODULE_IDLE
Module is idle now.
Definition generic.h:107
int module_process_legacy(struct processing_module *mod, struct input_stream_buffer *input_buffers, int num_input_buffers, struct output_stream_buffer *output_buffers, int num_output_buffers)
int module_adapter_copy(struct comp_dev *dev)
int module_adapter_ts_stop_op(struct comp_dev *dev)
static uint32_t module_get_lpt(struct processing_module *mod)
Get a Longest Processing Time estimation for the module, in us It is either.
Definition generic.h:635
int module_unbind(struct processing_module *mod, const struct bind_info *unbind_data)
int module_adapter_set_state(struct processing_module *mod, struct comp_dev *dev, int cmd)
int module_prepare(struct processing_module *mod, struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks)
int module_free(struct processing_module *mod)
int module_adapter_get_hw_params(struct comp_dev *dev, struct sof_ipc_stream_params *params, int dir)
int module_set_configuration(struct processing_module *mod, uint32_t config_id, enum module_cfg_fragment_position pos, size_t data_offset_size, const uint8_t *fragment, size_t fragment_size, uint8_t *response, size_t response_size)
void mod_free_all(struct processing_module *mod)
Free all heap resources currently tracked for a module.
void module_adapter_free(struct comp_dev *dev)
void mod_resource_init(struct processing_module *mod)
Initialize module resource management locks and containers.
mod_resource_type
Definition generic.h:142
@ MOD_RES_BLOB_HANDLER
Definition generic.h:145
@ MOD_RES_UNINITIALIZED
Definition generic.h:143
@ MOD_RES_FAST_GET
Definition generic.h:146
@ MOD_RES_HEAP
Definition generic.h:144
int module_adapter_sink_src_prepare(struct comp_dev *dev)
static struct ipc_msg * mod_ipc_msg_w_ext_init(struct processing_module *mod, uint32_t header, uint32_t extension, uint32_t size)
Initialize a new IPC message using the module allocator.
Definition generic.h:325
int module_adapter_cmd(struct comp_dev *dev, int cmd, void *data, int max_data_size)
static uint64_t module_adapter_get_total_data_processed(struct comp_dev *dev, uint32_t stream_no, bool input)
Definition generic.h:536
struct comp_dev * module_adapter_new_ext(const struct comp_driver *drv, const struct comp_ipc_config *config, const void *spec, void *mod_priv, struct userspace_context *user_ctx, const struct module_interface *ops)
int module_adapter_ts_config_op(struct comp_dev *dev)
int module_init(struct processing_module *mod)
static struct ipc_msg * mod_ipc_msg_init(struct processing_module *mod, uint32_t header, uint32_t size)
Definition generic.h:357
int module_ext_init_decode(const struct comp_driver *drv, struct module_ext_init_data *ext_data, struct ipc_config_process *spec)
struct comp_dev * module_adapter_new(const struct comp_driver *drv, const struct comp_ipc_config *config, const void *spec)
int module_adapter_init_data(struct comp_dev *dev, struct module_config *dst, const struct comp_ipc_config *config, const void *spec)
void module_adapter_reset_data(struct module_config *dst)
int module_process_sink_src(struct processing_module *mod, struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks)
static void * mod_balloc(struct processing_module *mod, size_t size)
Allocate stream buffer memory for module with natural alignment.
Definition generic.h:285
void module_adapter_check_data(struct processing_module *mod, struct comp_dev *dev, struct comp_buffer *sink)
static int module_process_endpoint(struct processing_module *mod, struct input_stream_buffer *input_buffers, int num_input_buffers, struct output_stream_buffer *output_buffers, int num_output_buffers)
Definition generic.h:542
int module_reset(struct processing_module *mod)
static void * mod_alloc(struct processing_module *mod, size_t size)
Allocate memory block for module with default natural alignment.
Definition generic.h:296
int module_adapter_trigger(struct comp_dev *dev, int cmd)
void * mod_balloc_align(struct processing_module *mod, size_t size, size_t alignment)
Allocate aligned stream buffer memory for a processing module.
static void * mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment)
Allocate aligned memory block for module with user privileges.
Definition generic.h:274
int mod_free(struct processing_module *mod, const void *ptr)
Free a memory block previously allocated for a module.
int module_bind(struct processing_module *mod, const struct bind_info *bind_data)
void module_adapter_set_params(struct processing_module *mod, struct sof_ipc_stream_params *params)
static void * mod_zalloc(struct processing_module *mod, size_t size)
Allocate zero-initialized memory block for module.
Definition generic.h:307
static int module_adapter_set_attribute(struct comp_dev *dev, uint32_t type, void *value)
Definition generic.h:504
static bool generic_module_is_ready_to_process(struct processing_module *mod, struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks)
Definition generic.h:421
int module_adapter_reset(struct comp_dev *dev)
int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *params)
static int module_adapter_bind(struct comp_dev *dev, const struct bind_info *bind_data)
Definition generic.h:524
static int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block, bool last_block, uint32_t *data_offset, char *data)
Definition generic.h:517
void mod_heap_info(struct processing_module *mod, size_t *size, uintptr_t *start)
Query module memory heap boundary and size.
void module_update_buffer_position(struct input_stream_buffer *input_buffers, struct output_stream_buffer *output_buffers, uint32_t frames)
static bool module_is_ready_to_process(struct processing_module *mod, struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks)
Definition generic.h:441
int module_adapter_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn)
static int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block, bool last_block, uint32_t data_offset, const char *data)
Definition generic.h:510
int module_load_config(struct comp_dev *dev, const void *cfg, size_t size)
static void mod_ipc_msg_free(struct processing_module *mod, struct ipc_msg *msg)
Free an IPC message allocated with mod_ipc_msg_init() or mod_ipc_msg_w_ext_init().
Definition generic.h:369
uint32_t module_get_deadline(struct processing_module *mod)
Get a deadline based on current LFT reported by all sinks it returns a value >= UINT32_MAX / 2 in cas...
#define COMP_PROCESSING_DOMAIN_LL
Low latency processing domain.
Definition component.h:553
#define SOF_MEM_FLAG_USER
Base allocation flag denoting memory allocated for user-space threads and module execution.
Definition alloc.h:69
#define SOF_MEM_FLAG_COHERENT
Allocate uncached / coherent memory address.
Definition alloc.h:53
module_cfg_fragment_position
Fragment position in config MODULE_CFG_FRAGMENT_FIRST: first fragment of the large configuration MODU...
Definition interface.h:29
static void list_init(struct list_item *list)
Definition list.h:25
static size_t sink_get_min_free_space(struct sof_sink *sink)
Definition sink_api.h:334
static size_t sink_get_free_size(struct sof_sink *sink)
Public functions.
Definition sink_api.h:162
static size_t source_get_data_available(struct sof_source *source)
Public functions.
Definition source_api.h:159
static size_t source_get_min_available(struct sof_source *source)
Definition source_api.h:305
void ipc_msg_list_remove(struct ipc_msg *msg)
Remove an IPC message from the send queue.
RTOS mutex primitives and synchronization wrappers.
Audio sink API helpers and stream configuration.
Audio source API helpers and stream configuration.
Component module binding metadata and endpoint references.
Definition component.h:287
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
const struct comp_driver * drv
Component driver.
Definition component.h:608
struct processing_module * mod
Module adapter reference.
Definition component.h:610
Audio component base driver "class".
Definition component.h:528
Audio component base configuration from IPC at creation.
Definition component.h:560
Definition ipc-config.h:139
uint32_t tx_size
Definition msg.h:37
uint32_t extension
Definition msg.h:36
struct list_item list
Definition msg.h:39
uint32_t header
Definition msg.h:35
void * tx_data
Definition msg.h:38
Module and pipeline allocation context aggregating a Zephyr heap and optional virtual region.
Definition alloc.h:251
Module config container, used for both config types.
Definition base.h:50
Container for found ext init object pointers This struct contains pointers that point to IPC payload ...
Definition base.h:40
3rd party processing module interface
Definition interface.h:102
int(* process_audio_stream)(struct processing_module *mod, struct input_stream_buffer *input_buffers, int num_input_buffers, struct output_stream_buffer *output_buffers, int num_output_buffers)
process_audio_stream (depreciated)
Definition interface.h:172
bool(* is_ready_to_process)(struct processing_module *mod, struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks)
(optional) return true if the module is ready to process This procedure should check if the module is...
Definition interface.h:132
Module TLV parameters container - used for both config types.
Definition generic.h:119
uint32_t size
The size of whole parameter - id + size + data.
Definition generic.h:125
int32_t data[]
A pointer to memory where config is stored.
Definition generic.h:126
uint32_t id
Specifies the unique id of a parameter.
Definition generic.h:124
Processing data shared between particular module & module_adapter.
Definition generic.h:167
uint32_t consumed
Specified how much data the module consumed in its last task.
Definition generic.h:172
uint32_t avail
Specifies how much data is available for module to process.
Definition generic.h:170
uint32_t produced
Specifies how much data the module produced in its last task.
Definition generic.h:171
uint32_t init_done
Specifies if the module initialization is finished.
Definition generic.h:173
uint32_t out_buff_size
Specifies the size of module output buffer.
Definition generic.h:169
void * in_buff
A pointer to module input buffer.
Definition generic.h:176
void * out_buff
A pointer to module output buffer.
Definition generic.h:177
bool eos_notification_sent
EOS notification is sent to host.
Definition generic.h:175
bool eos_reached
End of stream processing is reached.
Definition generic.h:174
uint32_t in_buff_size
Specifies the size of module input buffer.
Definition generic.h:168
module memory container - used for every memory allocated by module
Definition generic.h:153
struct comp_data_blob_handler * bhp
Blob handler ptr.
Definition generic.h:156
size_t size
Size of allocated heap memory, 0 if not from heap.
Definition generic.h:159
const void * sram_ptr
SRAM ptr from fast_get()
Definition generic.h:157
enum mod_resource_type type
Resource type.
Definition generic.h:160
void * ptr
Pointer to heap allocated memory.
Definition generic.h:155
module resources block - used for module allocation records The allocations are recorded so that they...
Definition generic.h:135
struct mod_alloc_ctx * alloc
Definition generic.h:139
size_t heap_usage
Definition generic.h:137
size_t heap_high_water_mark
Definition generic.h:138
struct objpool_head objpool
Definition generic.h:136
Output stream buffer.
Definition interface.h:66
internals of sink API.
Definition sink_api.h:141
internals of source API.
Definition source_api.h:137