Sound Open Firmware
Loading...
Searching...
No Matches
component.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
4 *
5 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6 * Keyon Jie <yang.jie@linux.intel.com>
7 */
8
15
16#ifndef __SOF_AUDIO_COMPONENT_H__
17#define __SOF_AUDIO_COMPONENT_H__
18
19#include <sof/audio/buffer.h>
20#include <sof/audio/format.h>
21#include <sof/audio/pipeline.h>
23#include <rtos/idc.h>
24#include <rtos/mutex.h>
26#include <sof/lib/dai.h>
27#include <sof/lib/uuid.h>
29#include <ipc/control.h>
30#include <sof/ipc/topology.h>
31#include <kernel/abi.h>
32
33#include <limits.h>
34
35struct comp_dev;
37struct dai_hw_params;
38struct timestamp_data;
39struct dai_ts_data;
40
44
45/* NOTE: Keep the component state diagram up to date:
46 * sof-docs/developer_guides/firmware/components/images/comp-dev-states.pu
47 */
48
52#define COMP_STATE_NOT_EXIST 0
53#define COMP_STATE_INIT 1
54#define COMP_STATE_READY 2
55#define COMP_STATE_SUSPEND 3
56#define COMP_STATE_PREPARE 4
57#define COMP_STATE_PAUSED 5
58#define COMP_STATE_ACTIVE 6
59#define COMP_STATE_PRE_ACTIVE 7
61
73enum {
86};
88
96#define COMP_CMD_SET_VALUE 100
97#define COMP_CMD_GET_VALUE 101
98#define COMP_CMD_SET_DATA 102
99#define COMP_CMD_GET_DATA 103
101
105#define COMP_CMD_IPC_MMAP_RPOS 200
106#define COMP_CMD_IPC_MMAP_PPOS 201
107
108#define COMP_CMD_IPC_MMAP_VOL(chan) (216 + chan)
110
114#define COMP_STATUS_STATE_ALREADY_SET 1
116
120#define COMP_ATTR_COPY_TYPE 0
121#define COMP_ATTR_HOST_BUFFER 1
122#define COMP_ATTR_COPY_DIR 2
123#define COMP_ATTR_VDMA_INDEX 3
124#define COMP_ATTR_BASE_CONFIG 4
125#define COMP_ATTR_IPC4_CONFIG 5
127
131
133#define trace_comp_drv_get_tr_ctx(drv_p) ((drv_p)->tctx)
134
136#define trace_comp_drv_get_id(drv_p) (-1)
137
139#define trace_comp_drv_get_subid(drv_p) (-1)
140
142#define trace_comp_get_tr_ctx(comp_p) (&(comp_p)->tctx)
143
145#define trace_comp_get_id(comp_p) ((comp_p)->ipc_config.pipeline_id)
146
148#define trace_comp_get_subid(comp_p) ((comp_p)->ipc_config.id)
149
150#if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG)
151/* class (driver) level (no device object) tracing */
152#define comp_cl_err(drv_p, __e, ...) LOG_ERR(__e, ##__VA_ARGS__)
153
154#define comp_cl_warn(drv_p, __e, ...) LOG_WRN(__e, ##__VA_ARGS__)
155
156#define comp_cl_info(drv_p, __e, ...) LOG_INF(__e, ##__VA_ARGS__)
157
158#define comp_cl_dbg(drv_p, __e, ...) LOG_DBG(__e, ##__VA_ARGS__)
159
160/* device level tracing */
161
162#if CONFIG_IPC_MAJOR_4
163#define __COMP_FMT "comp:%u %#x "
164#else
165#define __COMP_FMT "comp:%u.%u "
166#endif
167
168#define comp_err(comp_p, __e, ...) LOG_ERR(__COMP_FMT __e, trace_comp_get_id(comp_p), \
169 trace_comp_get_subid(comp_p), ##__VA_ARGS__)
170
171#define comp_warn(comp_p, __e, ...) LOG_WRN(__COMP_FMT __e, trace_comp_get_id(comp_p), \
172 trace_comp_get_subid(comp_p), ##__VA_ARGS__)
173
174#define comp_info(comp_p, __e, ...) LOG_INF(__COMP_FMT __e, trace_comp_get_id(comp_p), \
175 trace_comp_get_subid(comp_p), ##__VA_ARGS__)
176
177#define comp_dbg(comp_p, __e, ...) LOG_DBG(__COMP_FMT __e, trace_comp_get_id(comp_p), \
178 trace_comp_get_subid(comp_p), ##__VA_ARGS__)
179
180#else
181/* class (driver) level (no device object) tracing */
182
184#define comp_cl_err(drv_p, __e, ...) \
185 trace_dev_err(trace_comp_drv_get_tr_ctx, \
186 trace_comp_drv_get_id, \
187 trace_comp_drv_get_subid, \
188 drv_p, \
189 __e, ##__VA_ARGS__)
190
192#define comp_cl_warn(drv_p, __e, ...) \
193 trace_dev_warn(trace_comp_drv_get_tr_ctx, \
194 trace_comp_drv_get_id, \
195 trace_comp_drv_get_subid, \
196 drv_p, \
197 __e, ##__VA_ARGS__)
198
200#define comp_cl_info(drv_p, __e, ...) \
201 trace_dev_info(trace_comp_drv_get_tr_ctx, \
202 trace_comp_drv_get_id, \
203 trace_comp_drv_get_subid, \
204 drv_p, \
205 __e, ##__VA_ARGS__)
206
208#define comp_cl_dbg(drv_p, __e, ...) \
209 trace_dev_dbg(trace_comp_drv_get_tr_ctx, \
210 trace_comp_drv_get_id, \
211 trace_comp_drv_get_subid, \
212 drv_p, \
213 __e, ##__VA_ARGS__)
214
215/* device tracing */
216
218#define comp_err(comp_p, __e, ...) \
219 trace_dev_err(trace_comp_get_tr_ctx, trace_comp_get_id, \
220 trace_comp_get_subid, comp_p, __e, ##__VA_ARGS__)
221
223#define comp_warn(comp_p, __e, ...) \
224 trace_dev_warn(trace_comp_get_tr_ctx, trace_comp_get_id, \
225 trace_comp_get_subid, comp_p, __e, ##__VA_ARGS__)
226
228#define comp_info(comp_p, __e, ...) \
229 trace_dev_info(trace_comp_get_tr_ctx, trace_comp_get_id, \
230 trace_comp_get_subid, comp_p, __e, ##__VA_ARGS__)
231
233#define comp_dbg(comp_p, __e, ...) \
234 trace_dev_dbg(trace_comp_get_tr_ctx, trace_comp_get_id, \
235 trace_comp_get_subid, comp_p, __e, ##__VA_ARGS__)
236
237#endif /* #if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG) */
238
239#define comp_perf_info(pcd, comp_p) \
240 comp_info(comp_p, "perf comp_copy peak plat %u cpu %u", \
241 (uint32_t)((pcd)->plat_delta_peak), \
242 (uint32_t)((pcd)->cpu_delta_peak))
243
244#define comp_perf_avg_info(pcd, comp_p) \
245 comp_info(comp_p, "perf comp_copy samples %u period %u cpu avg %u peak %u %u",\
246 (uint32_t)((comp_p)->frames), \
247 (uint32_t)((comp_p)->period), \
248 (uint32_t)((pcd)->cpu_delta_sum), \
249 (uint32_t)((pcd)->cpu_delta_peak), \
250 (uint32_t)((pcd)->peak_mcps_period_cnt))
251
253
260
273
274struct comp_driver;
275struct comp_ipc_config;
276union ipc_config_specific;
277struct ipc4_module_bind_unbind;
278
283
284struct bind_info {
285 /* pointer to IPC4 bind/unbind data */
286 const struct ipc4_module_bind_unbind *ipc4_data;
287
288 /* type of binding
289 * bind call will be called twice for every component, first when binding a data source,
290 * than when binding data sink.
291 *
292 * bind_type is indicating type of binding
293 */
295
296 /* pointers to sink or source API of the data provider/consumer
297 * that is being bound to the module
298 *
299 * if bind_type == COMP_BIND_TYPE_SOURCE, the pointer points to source being bound/unbound
300 * if bind_type == COMP_BIND_TYPE_SINK, the pointer points to sink being bound/unbound
301 *
302 * NOTE! As in pipeline2.0 there may be a binding between modules,
303 * without a buffer in between, it cannot be a pointer to any buffer type, module should
304 * use sink/source API
305 */
306 union {
307 struct sof_source *source;
308 struct sof_sink *sink;
309 };
310};
311
319struct comp_ops {
334 struct comp_dev *(*create)(const struct comp_driver *drv,
335 const struct comp_ipc_config *ipc_config,
336 const void *spec);
337
346 void (*free)(struct comp_dev *dev);
347
358 int (*params)(struct comp_dev *dev,
360
371 int (*dai_get_hw_params)(struct comp_dev *dev,
372 struct sof_ipc_stream_params *params, int dir);
373
382 int (*dai_config)(struct dai_data *dd, struct comp_dev *dev,
383 struct ipc_config_dai *dai_config, const void *dai_spec_config);
384
385#if CONFIG_IPC_MAJOR_3 || CONFIG_LIBRARY
394 int (*cmd)(struct comp_dev *dev, int cmd, void *data,
395 int max_data_size);
396#endif
397
405 int (*trigger)(struct comp_dev *dev, int cmd);
406
415 int (*prepare)(struct comp_dev *dev);
416
425 int (*reset)(struct comp_dev *dev);
426
434 int (*copy)(struct comp_dev *dev);
435
443 int (*position)(struct comp_dev *dev,
444 struct sof_ipc_stream_posn *posn);
445
455 int (*get_attribute)(struct comp_dev *dev, uint32_t type,
456 void *value);
457
467 int (*set_attribute)(struct comp_dev *dev, uint32_t type,
468 void *value);
469
477 int (*dai_ts_config)(struct comp_dev *dev);
478
486 int (*dai_ts_start)(struct comp_dev *dev);
487
495 int (*dai_ts_stop)(struct comp_dev *dev);
496
505#if CONFIG_ZEPHYR_NATIVE_DRIVERS
506 int (*dai_ts_get)(struct comp_dev *dev, struct dai_ts_data *tsd);
507#else
508 int (*dai_ts_get)(struct comp_dev *dev,
509 struct timestamp_data *tsd);
510#endif
511
519 int (*bind)(struct comp_dev *dev, const struct bind_info *bind_data);
520
528 int (*unbind)(struct comp_dev *dev, const struct bind_info *unbind_data);
529
544 int (*get_large_config)(struct comp_dev *dev, uint32_t param_id,
545 bool first_block,
546 bool last_block,
547 uint32_t *data_offset,
548 char *data);
549
565 int (*set_large_config)(struct comp_dev *dev, uint32_t param_id,
566 bool first_block,
567 bool last_block,
568 uint32_t data_offset,
569 const char *data);
570
580 uint64_t (*get_total_data_processed)(struct comp_dev *dev, uint32_t stream_no, bool input);
581};
582
588 uint32_t type;
589 const struct sof_uuid *uid;
590 struct tr_ctx *tctx;
591 struct comp_ops ops;
592 const struct module_interface *adapter_ops;
596 struct k_heap *user_heap;
598};
599
602 const struct comp_driver *drv;
603 const struct module_interface **adapter_ops;
605};
606
607#define COMP_PROCESSING_DOMAIN_LL 0
608#define COMP_PROCESSING_DOMAIN_DP 1
609
614 uint32_t core;
615 uint32_t id;
616 uint32_t pipeline_id;
617 uint32_t proc_domain;
619 uint32_t periods_sink;
620 uint32_t periods_source;
621 uint32_t frame_fmt;
622 uint32_t xrun_action;
623#if CONFIG_IPC_MAJOR_4
624 bool ipc_extended_init;
625 uint32_t ipc_config_size;
626#endif
627};
628
630 /* maximum measured cpc on run-time.
631 *
632 * if current measured cpc exceeds peak_of_measured_cpc_ then
633 * ResoruceEvent(BUDGET_VIOLATION) notification must be send.
634 * Otherwise there is no new information for host to care about
635 */
637 /* Pointer to performance data structure. */
638 struct perf_data_item_comp *perf_data_item;
639};
640
645struct comp_dev {
646
647 /* runtime */
648 uint16_t state;
649 uint32_t frames;
651
652 struct task *task;
657 uint32_t size;
658 uint32_t period;
664 uint32_t priority;
669 struct tr_ctx tctx;
670
671 /* common runtime configuration for downstream/upstream */
672 uint32_t direction;
674
675 const struct comp_driver *drv;
676
677 struct processing_module *mod;
680
681 /* lists */
684
685 /* performance data*/
687 /* Input Buffer Size for pin 0, add array for other pins if needed */
688 size_t ibs;
689 /* Output Buffers Size for pin 0, add array for other pins if needed */
690 size_t obs;
691 /* max dsp cycles per chunk */
692 size_t cpc;
693 /* size of 1ms for input format in bytes */
694 size_t ll_chunk_size : 16;
695
696 /* private data - core does not touch this */
697 void *priv_data;
698
699#if CONFIG_PERFORMANCE_COUNTERS_COMPONENT
700 struct perf_cnt_data pcd;
701#endif
702
703#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
704 int32_t kcps_inc[CONFIG_CORE_COUNT];
705#endif
706};
707
712static inline struct comp_buffer *comp_dev_get_first_data_producer(struct comp_dev *component)
713{
714 return list_is_empty(&component->bsource_list) ? NULL :
716}
717
723static inline struct comp_buffer *comp_dev_get_next_data_producer(struct comp_dev *component,
724 struct comp_buffer *producer)
725{
726 return producer->sink_list.next == &component->bsource_list ? NULL :
727 list_item(producer->sink_list.next, struct comp_buffer, sink_list);
728}
729
730static inline struct comp_buffer *comp_dev_get_next_data_producer_safe(struct comp_dev *component,
731 struct comp_buffer *producer)
732{
733 return producer ? comp_dev_get_next_data_producer(component, producer) : NULL;
734}
735
740static inline struct comp_buffer *comp_dev_get_first_data_consumer(struct comp_dev *component)
741{
742 return list_is_empty(&component->bsink_list) ? NULL :
744}
745
751static inline struct comp_buffer *comp_dev_get_next_data_consumer(struct comp_dev *component,
752 struct comp_buffer *consumer)
753{
754 return consumer->source_list.next == &component->bsink_list ? NULL :
756}
757
758static inline struct comp_buffer *comp_dev_get_next_data_consumer_safe(struct comp_dev *component,
759 struct comp_buffer *consumer)
760{
761 return consumer ? comp_dev_get_next_data_consumer(component, consumer) : NULL;
762}
763
764/*
765 * a macro for easy iteration through component's list of producers
766 */
767#define comp_dev_for_each_producer(_dev, _producer) \
768 for (_producer = comp_dev_get_first_data_producer(_dev); \
769 _producer != NULL; \
770 _producer = comp_dev_get_next_data_producer(_dev, _producer))
771
772/*
773 * a macro for easy iteration through component's list of producers
774 * allowing deletion of a buffer during iteration
775 *
776 * additional "safe storage" pointer to struct comp_buffer must be provided
777 */
778#define comp_dev_for_each_producer_safe(_dev, _producer, _next_producer) \
779 for (_producer = comp_dev_get_first_data_producer(_dev), \
780 _next_producer = comp_dev_get_next_data_producer_safe(_dev, _producer); \
781 _producer != NULL; \
782 _producer = _next_producer, \
783 _next_producer = comp_dev_get_next_data_producer_safe(_dev, _producer))
784
785/*
786 * a macro for easy iteration through component's list of consumers
787 */
788#define comp_dev_for_each_consumer(_dev, _consumer) \
789 for (_consumer = comp_dev_get_first_data_consumer(_dev); \
790 _consumer != NULL; \
791 _consumer = comp_dev_get_next_data_consumer(_dev, _consumer)) \
792
793/*
794 * a macro for easy iteration through component's list of consumers
795 * allowing deletion of a buffer during iteration
796 *
797 * additional "safe storage" pointer to struct comp_buffer must be provided
798 */
799#define comp_dev_for_each_consumer_safe(_dev, _consumer, _next_consumer) \
800 for (_consumer = comp_dev_get_first_data_consumer(_dev), \
801 _next_consumer = comp_dev_get_next_data_consumer_safe(_dev, _consumer); \
802 _consumer != NULL; \
803 _consumer = _next_consumer, \
804 _next_consumer = comp_dev_get_next_data_consumer_safe(_dev, _consumer))
805
807
808/* Common helper function used internally by the component implementations
809 * begin here.
810 */
811
815
824
830static inline uint32_t dev_comp_id(const struct comp_dev *dev)
831{
832 return dev->ipc_config.id;
833}
834
840static inline uint32_t dev_comp_pipe_id(const struct comp_dev *dev)
841{
842 return dev->ipc_config.pipeline_id;
843}
844
850static inline enum sof_comp_type dev_comp_type(const struct comp_dev *dev)
851{
852 return dev->ipc_config.type;
853}
854
861static inline void comp_init(const struct comp_driver *drv,
862 struct comp_dev *dev, size_t bytes)
863{
864 dev->size = bytes;
865 dev->drv = drv;
866 dev->state = COMP_STATE_INIT;
867 list_init(&dev->bsink_list);
868 list_init(&dev->bsource_list);
869#ifndef __ZEPHYR__
870 memcpy_s(&dev->tctx, sizeof(dev->tctx),
871 trace_comp_drv_get_tr_ctx(dev->drv), sizeof(struct tr_ctx));
872#endif
873}
874
881static inline struct comp_dev *comp_alloc(const struct comp_driver *drv, size_t bytes)
882{
883 /*
884 * Use uncached address everywhere to access components to rule out
885 * multi-core failures. TODO: verify if cached alias may be used in some cases
886 */
887 struct comp_dev *dev = sof_heap_alloc(drv->user_heap,
889 bytes, 0);
890
891 if (!dev)
892 return NULL;
893
894 memset(dev, 0, sizeof(*dev));
895 comp_init(drv, dev, bytes);
896
897 return dev;
898}
899
908static inline void comp_free_device(struct comp_dev *dev)
909{
910 sof_heap_free(dev->drv->user_heap, dev);
911}
912
917static inline struct processing_module *comp_mod(const struct comp_dev *dev)
918{
919 return dev->mod;
920}
921
927#define comp_set_drvdata(c, data) \
928 (c->priv_data = data)
929
935#define comp_get_drvdata(c) \
936 (c->priv_data)
937
938#if defined UNIT_TEST || defined __ZEPHYR__ || CONFIG_LIBRARY_STATIC
939#define DECLARE_MODULE(init)
940
941/* declared modules */
942void sys_comp_dai_init(void);
943void sys_comp_host_init(void);
944void sys_comp_kpb_init(void);
945void sys_comp_selector_init(void);
946
947/* Start of modules in alphabetical order */
948void sys_comp_module_aria_interface_init(void);
949void sys_comp_module_asrc_interface_init(void);
950void sys_comp_module_copier_interface_init(void);
951void sys_comp_module_crossover_interface_init(void);
952void sys_comp_module_dcblock_interface_init(void);
953void sys_comp_module_demux_interface_init(void);
954void sys_comp_module_dolby_dax_audio_processing_interface_init(void);
955void sys_comp_module_drc_interface_init(void);
956void sys_comp_module_dts_interface_init(void);
957void sys_comp_module_eq_fir_interface_init(void);
958void sys_comp_module_eq_iir_interface_init(void);
959void sys_comp_module_gain_interface_init(void);
960void sys_comp_module_google_rtc_audio_processing_interface_init(void);
961void sys_comp_module_google_ctc_audio_processing_interface_init(void);
962void sys_comp_module_igo_nr_interface_init(void);
963void sys_comp_module_level_multiplier_interface_init(void);
964void sys_comp_module_mfcc_interface_init(void);
965void sys_comp_module_mixer_interface_init(void);
966void sys_comp_module_mixin_interface_init(void);
967void sys_comp_module_mixout_interface_init(void);
968void sys_comp_module_multiband_drc_interface_init(void);
969void sys_comp_module_mux_interface_init(void);
970void sys_comp_module_nxp_eap_interface_init(void);
971void sys_comp_module_phase_vocoder_interface_init(void);
972void sys_comp_module_rtnr_interface_init(void);
973void sys_comp_module_selector_interface_init(void);
974void sys_comp_module_sound_dose_interface_init(void);
975void sys_comp_module_src_interface_init(void);
976void sys_comp_module_src_lite_interface_init(void);
977void sys_comp_module_stft_process_interface_init(void);
978void sys_comp_module_tdfb_interface_init(void);
979void sys_comp_module_tone_interface_init(void);
980void sys_comp_module_template_interface_init(void);
981void sys_comp_module_tester_interface_init(void);
982void sys_comp_module_volume_interface_init(void);
983/* End of modules in alphabetical order */
984
985#elif CONFIG_LIBRARY
986/* In case of shared libs components are initialised in dlopen */
987#define DECLARE_MODULE(init) __attribute__((constructor)) \
988 static void _module_##init(void) { init(); }
989#else
993#define DECLARE_MODULE(init) __attribute__((__used__)) \
994 __section(".initcall") static void(*f##init)(void) = init
995#endif
996
1000
1007
1013
1021int comp_set_adapter_ops(const struct comp_driver *drv, const struct module_interface *ops);
1022
1024
1044int comp_set_state(struct comp_dev *dev, int cmd);
1045
1046/* \brief Set component period frames */
1047static inline void component_set_nearest_period_frames(struct comp_dev *current,
1048 uint32_t rate)
1049{
1050 uint64_t frames;
1051
1052 /* Sample rate is in Hz and period in microseconds.
1053 * As we don't have floats use scale divider 1000000.
1054 * Also integer round up the result.
1055 * dma buffer size should align with 32bytes which can't be
1056 * compatible with current 45K adjustment. 48K is a suitable
1057 * adjustment.
1058 */
1059
1060 switch (rate) {
1061 case 44100:
1062 rate = 48000;
1063 break;
1064 case 88200:
1065 rate = 96000;
1066 break;
1067 case 176400:
1068 rate = 192000;
1069 break;
1070 default:
1071 break;
1072 }
1073
1074 frames = SOF_DIV_ROUND_UP((uint64_t)rate * current->period, 1000000);
1075
1076 assert(frames <= UINT_MAX);
1077 current->frames = (uint32_t)frames;
1078}
1079
1083
1090static inline void comp_underrun(struct comp_dev *dev,
1091 struct comp_buffer *source,
1092 uint32_t copy_bytes)
1093{
1094 LOG_MODULE_DECLARE(component, CONFIG_SOF_LOG_LEVEL);
1095
1096 int32_t bytes = (int32_t)audio_stream_get_avail_bytes(&source->stream) -
1097 copy_bytes;
1098
1099 comp_err(dev, "comp_underrun(): dev->comp.id = %u, source->avail = %u, copy_bytes = %u",
1100 dev_comp_id(dev),
1102 copy_bytes);
1103
1104 pipeline_xrun(dev->pipeline, dev, bytes);
1105}
1106
1113static inline void comp_overrun(struct comp_dev *dev, struct comp_buffer *sink,
1114 uint32_t copy_bytes)
1115{
1116 LOG_MODULE_DECLARE(component, CONFIG_SOF_LOG_LEVEL);
1117
1118 int32_t bytes = (int32_t)copy_bytes -
1120
1121 comp_err(dev, "comp_overrun(): sink->free = %u, copy_bytes = %u",
1122 audio_stream_get_free_bytes(&sink->stream), copy_bytes);
1123
1124 pipeline_xrun(dev->pipeline, dev, bytes);
1125}
1126
1128
1139 struct comp_buffer *sink,
1140 struct comp_copy_limits *cl);
1141
1152 const struct comp_buffer *sink,
1153 struct comp_copy_limits *cl);
1154
1163static inline int comp_get_state(const struct comp_dev *dev)
1164{
1165 if (!dev)
1166 return COMP_STATE_NOT_EXIST;
1167 return dev->state;
1168}
1169
1178static inline int comp_buffer_get_source_state(const struct comp_buffer *buffer)
1179{
1181}
1182
1191static inline int comp_buffer_get_sink_state(const struct comp_buffer *buffer)
1192{
1194}
1195
1209int comp_verify_params(struct comp_dev *dev, uint32_t flag,
1210 struct sof_ipc_stream_params *params);
1211
1213
1220
1227
1235bool comp_update_performance_data(struct comp_dev *dev, uint32_t cycles_used);
1236
1237static inline int user_get_buffer_memory_region(const struct comp_driver *drv)
1238{
1239#if CONFIG_SOF_USERSPACE_USE_DRIVER_HEAP
1241#else
1242 return SOF_MEM_FLAG_USER;
1243#endif
1244}
1245#endif /* __SOF_AUDIO_COMPONENT_H__ */
ABI definitions.
static struct comp_dev * comp_buffer_get_source_component(const struct comp_buffer *buffer)
Definition buffer.h:165
static struct comp_dev * comp_buffer_get_sink_component(const struct comp_buffer *buffer)
Definition buffer.h:173
#define SOF_DIV_ROUND_UP(val, div)
Definition common.h:107
void comp_update_ibs_obs_cpc(struct comp_dev *dev)
Update ibs, obs, cpc, ll chunk size for component.
void comp_init_performance_data(struct comp_dev *dev)
If component has assigned slot in performance measurement window, initialize its fields.
static int user_get_buffer_memory_region(const struct comp_driver *drv)
Definition component.h:1237
bool comp_update_performance_data(struct comp_dev *dev, uint32_t cycles_used)
Update performance data entry for component.
IPC control commands.
uint32_t data[]
Definition debug_stream_slot.h:2
#define SOF_MEM_FLAG_USER_SHARED_BUFFER
Allocate shared user memory address.
Definition alloc.h:47
void * sof_heap_alloc(struct k_heap *heap, uint32_t flags, size_t bytes, size_t alignment)
#define SOF_MEM_FLAG_USER
Allocate user memory address.
Definition alloc.h:45
#define SOF_MEM_FLAG_COHERENT
Allocate uncached address.
Definition alloc.h:37
void sof_heap_free(struct k_heap *heap, void *addr)
static uint32_t audio_stream_get_free_bytes(const struct audio_stream *stream)
Calculates free space in bytes, handling overrun_permitted behaviour.
Definition audio_stream.h:480
static uint32_t audio_stream_get_avail_bytes(const struct audio_stream *stream)
Calculates available data in bytes, handling underrun_permitted behaviour.
Definition audio_stream.h:436
#define comp_err(comp_p, __e,...)
Trace error message from component device.
Definition component.h:218
#define COMP_STATE_NOT_EXIST
Component does not exist.
Definition component.h:52
static struct comp_buffer * comp_dev_get_next_data_producer_safe(struct comp_dev *component, struct comp_buffer *producer)
Definition component.h:730
bind_type
Definition component.h:279
static struct comp_buffer * comp_dev_get_next_data_consumer(struct comp_dev *component, struct comp_buffer *consumer)
Get a pointer to the next comp_buffer object receiving data from the component The function will retu...
Definition component.h:751
#define trace_comp_drv_get_tr_ctx(drv_p)
Retrieves trace context from the component driver.
Definition component.h:133
static struct comp_buffer * comp_dev_get_next_data_consumer_safe(struct comp_dev *component, struct comp_buffer *consumer)
Definition component.h:758
comp_copy_type
Type of next dma copy mode, changed on runtime.
Definition component.h:267
comp_endpoint_type
Type of endpoint this component is connected to in a pipeline.
Definition component.h:255
static struct comp_buffer * comp_dev_get_first_data_consumer(struct comp_dev *component)
Get a pointer to the first comp_buffer object receiving data from the component The function will ret...
Definition component.h:740
static struct comp_buffer * comp_dev_get_first_data_producer(struct comp_dev *component)
Get a pointer to the first comp_buffer object providing data to the component The function will retur...
Definition component.h:712
#define COMP_STATE_INIT
Component being initialised.
Definition component.h:53
static struct comp_buffer * comp_dev_get_next_data_producer(struct comp_dev *component, struct comp_buffer *producer)
Get a pointer to the next comp_buffer object providing data to the component The function will return...
Definition component.h:723
@ COMP_TRIGGER_STOP
Stop component stream.
Definition component.h:74
@ COMP_TRIGGER_XRUN
XRUN component.
Definition component.h:80
@ COMP_TRIGGER_PAUSE
Pause the component stream.
Definition component.h:76
@ COMP_TRIGGER_RESET
Reset component.
Definition component.h:78
@ COMP_TRIGGER_PREPARE
Prepare component.
Definition component.h:79
@ COMP_TRIGGER_START
Start component stream.
Definition component.h:75
@ COMP_TRIGGER_PRE_START
Prepare to start component stream.
Definition component.h:81
@ COMP_TRIGGER_POST_STOP
Finalize stop component stream.
Definition component.h:83
@ COMP_TRIGGER_POST_PAUSE
Finalize pause component stream.
Definition component.h:84
@ COMP_TRIGGER_NO_ACTION
No action required.
Definition component.h:85
@ COMP_TRIGGER_RELEASE
Release paused component stream.
Definition component.h:77
@ COMP_TRIGGER_PRE_RELEASE
Prepare to release paused component stream.
Definition component.h:82
@ COMP_BIND_TYPE_SINK
Definition component.h:281
@ COMP_BIND_TYPE_SOURCE
Definition component.h:280
@ COMP_COPY_BLOCKING
Blocking.
Definition component.h:270
@ COMP_COPY_NORMAL
Normal.
Definition component.h:269
@ COMP_COPY_ONE_SHOT
One-shot.
Definition component.h:271
@ COMP_COPY_INVALID
Invalid.
Definition component.h:268
@ COMP_ENDPOINT_HOST
Connected to host dma.
Definition component.h:256
@ COMP_ENDPOINT_DAI
Connected to dai dma.
Definition component.h:257
@ COMP_ENDPOINT_NODE
No dma connection.
Definition component.h:258
int comp_register(struct comp_driver_info *drv)
Registers the component driver on the list of available components.
static enum sof_comp_type dev_comp_type(const struct comp_dev *dev)
Retrieves component type from device.
Definition component.h:850
static struct processing_module * comp_mod(const struct comp_dev *dev)
Module adapter associated with a component.
Definition component.h:917
static void comp_init(const struct comp_driver *drv, struct comp_dev *dev, size_t bytes)
Initialize common part of a component device.
Definition component.h:861
void comp_unregister(struct comp_driver_info *drv)
Unregisters the component driver from the list of available components.
static void comp_free_device(struct comp_dev *dev)
Frees memory allocated for component device.
Definition component.h:908
int comp_verify_params(struct comp_dev *dev, uint32_t flag, struct sof_ipc_stream_params *params)
Warning: duplicate declaration in topology.h.
static uint32_t dev_comp_pipe_id(const struct comp_dev *dev)
Retrieves Component pipeline id from device.
Definition component.h:840
static uint32_t dev_comp_id(const struct comp_dev *dev)
Retrieves Component id from device.
Definition component.h:830
static struct comp_dev * comp_alloc(const struct comp_driver *drv, size_t bytes)
Allocates memory for the component device and initializes common part.
Definition component.h:881
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 req...
static void comp_overrun(struct comp_dev *dev, struct comp_buffer *sink, uint32_t copy_bytes)
Called by component device when overrun is detected.
Definition component.h:1113
int comp_set_state(struct comp_dev *dev, int cmd)
Component state set.
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.
Definition component.h:1090
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
Definition component.h:1191
static void component_set_nearest_period_frames(struct comp_dev *current, uint32_t rate)
Definition component.h:1047
int comp_set_adapter_ops(const struct comp_driver *drv, const struct module_interface *ops)
Set adapter ops for a dynamically created driver.
static int comp_get_state(const struct comp_dev *dev)
Get component state.
Definition component.h:1163
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 tran...
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
Definition component.h:1178
IDC header file.
sof_comp_type
Definition topology.h:27
#define list_is_empty(item)
Definition list.h:73
static void list_init(struct list_item *list)
Definition list.h:25
#define list_item(item, type, member)
Definition list.h:80
#define list_first_item(list, type, member)
Definition list.h:84
#define assert(x)
Definition panic.h:19
void pipeline_xrun(struct pipeline *p, struct comp_dev *dev, int32_t bytes)
notify host that we have XRUN.
#define LOG_MODULE_DECLARE(ctx, level)
Definition trace.h:163
static int memcpy_s(void *dest, size_t dest_size, const void *src, size_t count)
Definition string.h:38
Definition component.h:284
const struct ipc4_module_bind_unbind * ipc4_data
Definition component.h:286
enum bind_type bind_type
Definition component.h:294
struct sof_source * source
Definition component.h:307
Definition buffer.h:130
struct list_item source_list
Definition buffer.h:146
struct list_item sink_list
Definition buffer.h:147
struct audio_stream stream
Definition buffer.h:134
Struct for use with comp_get_copy_limits() function.
Definition component.h:817
int frames
Definition component.h:818
int sink_frame_bytes
Definition component.h:822
int source_frame_bytes
Definition component.h:821
int sink_bytes
Definition component.h:820
int source_bytes
Definition component.h:819
Audio component base device "class".
Definition component.h:645
uint32_t priority
component's processing priority
Definition component.h:664
struct comp_ipc_config ipc_config
Component IPC configuration.
Definition component.h:668
size_t cpc
Definition component.h:692
struct comp_perf_data perf_data
Definition component.h:686
struct list_item bsink_list
list of sink buffers
Definition component.h:683
bool is_shared
indicates whether component is shared across cores
Definition component.h:665
size_t ll_chunk_size
Definition component.h:694
uint16_t state
COMP_STATE_.
Definition component.h:648
size_t obs
Definition component.h:690
uint32_t size
component's allocated size
Definition component.h:657
void * priv_data
private data
Definition component.h:697
uint32_t direction
enum sof_ipc_stream_direction
Definition component.h:672
struct task * task
component's processing task used 1) for components running on different core than the rest of the pip...
Definition component.h:652
const struct comp_driver * drv
driver
Definition component.h:675
struct processing_module * mod
self->mod->dev == self, NULL if component is not using module adapter
Definition component.h:677
bool direction_set
flag indicating that the direction has been set
Definition component.h:673
struct list_item bsource_list
list of source buffers
Definition component.h:682
struct pipeline * pipeline
pipeline we belong to
Definition component.h:650
struct tr_ctx tctx
trace settings
Definition component.h:669
size_t ibs
Definition component.h:688
uint32_t frames
number of frames we copy to sink
Definition component.h:649
uint32_t period
component's processing period for LL modules is set to LL pipeline's period for DP module its meaning...
Definition component.h:658
Holds constant pointer to component driver.
Definition component.h:601
struct list_item list
list of component drivers
Definition component.h:604
const struct module_interface ** adapter_ops
pointer for updating ops
Definition component.h:603
const struct comp_driver * drv
pointer to component driver
Definition component.h:602
Audio component base driver "class".
Definition component.h:587
const struct module_interface * adapter_ops
module specific operations.
Definition component.h:592
struct comp_ops ops
component operations
Definition component.h:591
struct tr_ctx * tctx
Pointer to trace context.
Definition component.h:590
const struct sof_uuid * uid
Address to UUID value.
Definition component.h:589
uint32_t type
SOF_COMP_ for driver.
Definition component.h:588
struct k_heap * user_heap
Userspace heap.
Definition component.h:596
struct sof_uuid uid_cp
UUID copy for LLEXT modules.
Definition component.h:597
Audio component base configuration from IPC at creation.
Definition component.h:613
uint32_t frame_fmt
SOF_IPC_FRAME_.
Definition component.h:621
uint32_t proc_domain
processing domain - LL or DP
Definition component.h:617
uint32_t id
component id
Definition component.h:615
uint32_t periods_source
0 means variable
Definition component.h:620
uint32_t periods_sink
0 means variable
Definition component.h:619
uint32_t xrun_action
action we should take on XRUN
Definition component.h:622
enum sof_comp_type type
component type
Definition component.h:618
uint32_t core
core we run on
Definition component.h:614
uint32_t pipeline_id
component pipeline id
Definition component.h:616
Audio component operations.
Definition component.h:319
int(* set_attribute)(struct comp_dev *dev, uint32_t type, void *value)
Sets attribute in component.
Definition component.h:467
int(* get_attribute)(struct comp_dev *dev, uint32_t type, void *value)
Gets attribute in component.
Definition component.h:455
int(* prepare)(struct comp_dev *dev)
Prepares component after params are set.
Definition component.h:415
int(* reset)(struct comp_dev *dev)
Resets component.
Definition component.h:425
int(* dai_ts_get)(struct comp_dev *dev, struct timestamp_data *tsd)
Gets timestamp.
Definition component.h:508
int(* params)(struct comp_dev *dev, struct sof_ipc_stream_params *params)
Sets component audio stream parameters.
Definition component.h:358
int(* bind)(struct comp_dev *dev, const struct bind_info *bind_data)
Bind, atomic - used to notify component of bind event.
Definition component.h:519
int(* dai_ts_stop)(struct comp_dev *dev)
Stops timestamping.
Definition component.h:495
int(* dai_get_hw_params)(struct comp_dev *dev, struct sof_ipc_stream_params *params, int dir)
Fetches hardware stream parameters.
Definition component.h:371
int(* position)(struct comp_dev *dev, struct sof_ipc_stream_posn *posn)
Retrieves component rendering position.
Definition component.h:443
uint64_t(* get_total_data_processed)(struct comp_dev *dev, uint32_t stream_no, bool input)
Returns total data processed in number bytes.
Definition component.h:580
int(* copy)(struct comp_dev *dev)
Copy and process stream data from source to sink buffers.
Definition component.h:434
int(* dai_ts_start)(struct comp_dev *dev)
Starts timestamping.
Definition component.h:486
int(* set_large_config)(struct comp_dev *dev, uint32_t param_id, bool first_block, bool last_block, uint32_t data_offset, const char *data)
Set config in component.
Definition component.h:565
int(* dai_ts_config)(struct comp_dev *dev)
Configures timestamping in attached DAI.
Definition component.h:477
int(* dai_config)(struct dai_data *dd, struct comp_dev *dev, struct ipc_config_dai *dai_config, const void *dai_spec_config)
Configures attached DAI.
Definition component.h:382
int(* trigger)(struct comp_dev *dev, int cmd)
Trigger, atomic - used to start/stop/pause stream operations.
Definition component.h:405
int(* get_large_config)(struct comp_dev *dev, uint32_t param_id, bool first_block, bool last_block, uint32_t *data_offset, char *data)
Gets config in component.
Definition component.h:544
int(* unbind)(struct comp_dev *dev, const struct bind_info *unbind_data)
Unbind, atomic - used to notify component of unbind event.
Definition component.h:528
void(* free)(struct comp_dev *dev)
Called to delete the specified component device.
Definition component.h:346
Definition component.h:629
struct perf_data_item_comp * perf_data_item
Definition component.h:638
size_t peak_of_measured_cpc
Definition component.h:636
DAI runtime data.
Definition dai-zephyr.h:119
Definition ipc-config.h:65
struct list_item * next
Definition list.h:17
Definition perf_cnt.h:19
Definition stream.h:71
Definition stream.h:134
UUID (Universally Unique IDentifier) structure.
Definition uuid.h:60
Definition trace.h:135
char value[]
Definition tlv.h:2
uint32_t type
Definition tlv.h:0