Sound Open Firmware
Loading...
Searching...
No Matches
base.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Copyright(c) 2020 - 2023 Intel Corporation. All rights reserved.
4 *
5 * Author: Marcin Rajwa <marcin.rajwa@linux.intel.com>
6 * Adrian Warecki <adrian.warecki@intel.com>
7 */
8
15#ifndef __MODULE_MODULE_BASE__
16#define __MODULE_MODULE_BASE__
17
18#include <stdint.h>
19#include <stddef.h>
20#include <stdbool.h>
21
22#include "interface.h"
23#include "../ipc4/base-config.h"
24
25#ifdef SOF_MODULE_API_PRIVATE
26#include <sof/list.h>
27#endif
28
29#define module_get_private_data(mod) ((mod)->priv.private)
30#define module_set_private_data(mod, data) ((mod)->priv.private = data)
31
45
51 size_t size;
52 bool avail;
53 void *data;
54 const void *init_data;
55#if CONFIG_IPC_MAJOR_4
62#endif
63};
64
65/*
66 * A structure containing a module's private data, intended for its exclusive use.
67 *
68 * This structure should contain only fields that are used be a module.
69 * All other fields, used exclusively by SOF must be moved to another structure!
70 */
72 void *private;
75 /*
76 * Fields below can only be accessed by the SOF and must be moved to a new structure.
77 * Below #ifdef is a temporary solution used until work on separating a common interface
78 * for loadable modules is completed.
79 */
80#ifdef SOF_MODULE_API_PRIVATE
81 enum module_state state;
82 size_t new_cfg_size;
83 void *runtime_params;
84 struct module_resources resources;
85 struct module_processing_data mpd;
86#endif /* SOF_MODULE_PRIVATE */
87};
88
94
95struct userspace_context;
96struct k_mem_domain;
97
98/*
99 * A pointer to this structure is passed to module API functions (from struct module_interface).
100 * This structure should contain only fields that should be available to a module.
101 * All other fields, used exclusively by SOF must be moved to another structure!
102 */
105 uint32_t period_bytes;
107 /*
108 * Fields below can only be accessed by the SOF and must be moved to a new structure.
109 * Below #ifdef is a temporary solution used until work on separating a common interface
110 * for loadable modules is completed.
111 */
112#ifdef SOF_MODULE_API_PRIVATE
114 /* list of sink buffers to save produced output, to be used in Raw data
115 * processing mode
116 */
117 struct list_item raw_data_buffers_list;
118
119 /*
120 * This is a temporary change in order to support the trace messages in the modules. This
121 * will be removed once the trace API is updated.
122 */
123 struct comp_dev *dev;
124 uint32_t deep_buff_bytes;
125 uint32_t output_buffer_size;
127 /* number of sinks / sources and (when in use) input_buffers / input_buffers */
128 uint32_t num_of_sources;
129 uint32_t num_of_sinks;
130
131 /* sink and source handlers for the module */
132 struct sof_sink *sinks[CONFIG_MODULE_MAX_CONNECTIONS];
133 struct sof_source *sources[CONFIG_MODULE_MAX_CONNECTIONS];
134
135 /* this is used in case of raw data or audio_stream mode
136 * number of buffers described by fields:
137 * input_buffers - num_of_sources
138 * output_buffers - num_of_sinks
139 */
140 struct input_stream_buffer *input_buffers;
141 struct output_stream_buffer *output_buffers;
142 struct comp_buffer *source_comp_buffer;
143 struct comp_buffer *sink_comp_buffer;
145 /* module-specific flags for comp_verify_params() */
146 uint32_t verify_params_flags;
147
148 /* indicates that this DP module did not yet reach its first deadline and
149 * no data should be passed yet to next LL module
150 *
151 * why: lets assume DP with 10ms period (a.k.a a deadline). It starts and finishes
152 * Earlier, i.e. in 2ms providing 10ms of data. LL starts consuming data in 1ms chunks and
153 * will drain 10ms buffer in 10ms, expecting a new portion of data on 11th ms
154 * BUT - the DP module deadline is still 10ms, regardless if it had finished earlier
155 * and it is completely fine that processing in next cycle takes full 10ms - as long as it
156 * fits into the deadline.
157 * It may lead to underruns:
158 *
159 * LL1 (1ms) ---> DP (10ms) -->LL2 (1ms)
160 *
161 * ticks 0..9 -> LL1 is producing 1ms data portions, DP is waiting, LL2 is waiting
162 * tick 10 - DP has enough data to run, it starts processing
163 * tick 12 - DP finishes earlier, LL2 starts consuming, LL1 is producing data
164 * ticks 13-19 LL1 is producing data, LL2 is consuming data (both in 1ms chunks)
165 * tick 20 - DP starts processing a new portion of 10ms data, having 10ms to finish
166 * !!!! but LL2 has already consumed 8ms !!!!
167 * tick 22 - LL2 is consuming the last 1ms data chunk
168 * tick 23 - DP is still processing, LL2 has no data to process
169 * !!! UNDERRUN !!!!
170 * tick 19 - DP finishes properly in a deadline time
171 *
172 * Solution: even if DP finishes before its deadline, the data must be held till
173 * deadline time, so LL2 may start processing no earlier than tick 20
174 */
175 bool dp_startup_delay;
176
177#if CONFIG_IPC_MAJOR_3
178 /* flag to indicate module does not pause */
179 bool no_pause;
180#endif
181
182 /*
183 * flag to indicate that the sink buffer writeback should be skipped. It will be handled
184 * in the module's process callback
185 */
186 bool skip_sink_buffer_writeback;
187
188 /*
189 * flag to indicate that the source buffer invalidate should be skipped. It will be handled
190 * in the module's process callback
191 */
192 bool skip_src_buffer_invalidate;
193
194 /*
195 * True for module with one source component buffer and one sink component buffer
196 * to enable reduction of module processing overhead. False if component uses
197 * multiple buffers.
198 */
199 bool stream_copy_single_to_single;
200
201 /* total processed data after stream started */
202 uint64_t total_data_consumed;
203 uint64_t total_data_produced;
204
205 /* max source/sinks supported by the module */
206 uint32_t max_sources;
207 uint32_t max_sinks;
208
209 enum module_processing_type proc_type;
210#if CONFIG_USERSPACE
211 struct userspace_context *user_ctx;
212 struct k_mem_domain *mdom;
213#endif /* CONFIG_USERSPACE */
214
215 /* total size of a fragmented runtime-params (get/set) transfer, kept
216 * per instance so concurrent transfers to different components do not
217 * corrupt each other's reassembly state. Appended here to avoid shifting
218 * the offsets of the fields above.
219 */
220 uint32_t runtime_params_size;
221#endif /* SOF_MODULE_PRIVATE */
222};
223
224#endif /* __MODULE_MODULE_BASE__ */
module_processing_type
Definition base.h:89
@ MODULE_PROCESS_TYPE_SOURCE_SINK
Definition base.h:90
@ MODULE_PROCESS_TYPE_STREAM
Definition base.h:91
@ MODULE_PROCESS_TYPE_RAW
Definition base.h:92
module_state
Module-specific states.
Definition generic.h:104
Dynamic module interface, lifecycle callbacks, and buffer contracts.
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
Input stream buffer.
Definition interface.h:53
Base module configuration parameters provided upon module instantiation.
Definition base-config.h:160
Input pin format specification for multi-pin modules.
Definition base-config.h:172
Memory requirements for Data Processing (DP) module threads.
Definition module.h:108
Output pin format specification for multi-pin modules.
Definition base-config.h:182
Definition list.h:16
Module config container, used for both config types.
Definition base.h:50
struct ipc4_output_pin_format * output_pins
Definition base.h:60
struct module_ext_init_data * ext_data
IPC payload pointers, NULL after init()
Definition base.h:61
const void * init_data
Initial IPC configuration.
Definition base.h:54
void * data
tlv config, a pointer to memory where config is stored.
Definition base.h:53
size_t size
Specifies the size of whole config.
Definition base.h:51
uint8_t nb_output_pins
Definition base.h:58
struct ipc4_input_pin_format * input_pins
Definition base.h:59
bool avail
Marks config as available to use.
Definition base.h:52
uint8_t nb_input_pins
Definition base.h:57
struct ipc4_base_module_cfg base_cfg
Definition base.h:56
Definition base.h:71
struct module_config cfg
module configuration data
Definition base.h:73
Container for found ext init object pointers This struct contains pointers that point to IPC payload ...
Definition base.h:40
size_t module_data_size
Definition base.h:43
const struct ipc4_module_init_ext_obj_dp_data * dp_data
Definition base.h:41
const void * module_data
Definition base.h:42
Processing data shared between particular module & module_adapter.
Definition generic.h:167
module resources block - used for module allocation records The allocations are recorded so that they...
Definition generic.h:135
Output stream buffer.
Definition interface.h:66
Definition base.h:103
uint32_t period_bytes
Definition base.h:105
struct module_data priv
module private data
Definition base.h:104
Definition stream.h:71
internals of sink API.
Definition sink_api.h:141
internals of source API.
Definition source_api.h:137
Definition stream.h:20