From 4f74e6f35f53b3803e0147f9ec0ff95a98b9bf37 Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Tue, 10 Dec 2024 14:48:54 +0100 Subject: [PATCH] debug: tester loadable module framework Tester module is a framework for a runtime testing that need a special internal code i.e. provide an extra load to CPU by running additional thread, etc. The idea is to allow testing of special cases using a standard "production" build. The module should be compiled as a loadable module only, as it is not needed in any real production case. In order to keep only one testing module (in meaning of a SOF module with separate UUID), a framework is introduced, where a test to be executed is selected by IPC parameter Signed-off-by: Marcin Szkudlinski --- app/boards/intel_adsp_ace15_mtpm.conf | 1 + app/boards/intel_adsp_ace20_lnl.conf | 1 + app/boards/intel_adsp_ace30_ptl.conf | 1 + app/configs/mtl/modules.conf | 1 + src/Kconfig | 2 + src/audio/sink_source_utils.c | 5 +- src/debug/CMakeLists.txt | 4 + src/debug/tester/CMakeLists.txt | 2 + src/debug/tester/Kconfig | 8 + src/debug/tester/llext/CMakeLists.txt | 7 + src/debug/tester/llext/llext.toml.h | 6 + src/debug/tester/tester.c | 244 ++++++++++++++++++++++++++ src/debug/tester/tester.h | 97 ++++++++++ src/debug/tester/tester.toml | 74 ++++++++ src/debug/tester/tester_dummy_test.c | 58 ++++++ src/debug/tester/tester_dummy_test.h | 18 ++ src/include/sof/audio/component.h | 1 + tools/rimage/config/mtl.toml.h | 4 + uuid-registry.txt | 1 + zephyr/CMakeLists.txt | 12 ++ 20 files changed, 544 insertions(+), 3 deletions(-) create mode 100644 src/debug/tester/CMakeLists.txt create mode 100644 src/debug/tester/Kconfig create mode 100644 src/debug/tester/llext/CMakeLists.txt create mode 100644 src/debug/tester/llext/llext.toml.h create mode 100644 src/debug/tester/tester.c create mode 100644 src/debug/tester/tester.h create mode 100644 src/debug/tester/tester.toml create mode 100644 src/debug/tester/tester_dummy_test.c create mode 100644 src/debug/tester/tester_dummy_test.h diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 9044699a1519..7b07a5e36c87 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -11,6 +11,7 @@ CONFIG_COMP_CHAIN_DMA=y CONFIG_COMP_CROSSOVER=y CONFIG_COMP_DRC=y CONFIG_COMP_KPB=y +CONFIG_COMP_TESTER=m CONFIG_COMP_SRC_IPC4_FULL_MATRIX=y CONFIG_COMP_SRC_LITE=y CONFIG_COMP_MFCC=y diff --git a/app/boards/intel_adsp_ace20_lnl.conf b/app/boards/intel_adsp_ace20_lnl.conf index 022a3a9a40b6..1c293feb77f2 100644 --- a/app/boards/intel_adsp_ace20_lnl.conf +++ b/app/boards/intel_adsp_ace20_lnl.conf @@ -10,6 +10,7 @@ CONFIG_COMP_ARIA=y CONFIG_COMP_CHAIN_DMA=y CONFIG_COMP_DRC=m CONFIG_COMP_KPB=y +CONFIG_COMP_TESTER=m CONFIG_COMP_SRC_IPC4_FULL_MATRIX=y CONFIG_COMP_UP_DOWN_MIXER=y CONFIG_COMP_VOLUME_WINDOWS_FADE=y diff --git a/app/boards/intel_adsp_ace30_ptl.conf b/app/boards/intel_adsp_ace30_ptl.conf index 62106d05e02e..12ce0970f921 100644 --- a/app/boards/intel_adsp_ace30_ptl.conf +++ b/app/boards/intel_adsp_ace30_ptl.conf @@ -12,6 +12,7 @@ CONFIG_COMP_ARIA=y CONFIG_COMP_CHAIN_DMA=y CONFIG_COMP_DRC=y CONFIG_COMP_KPB=y +CONFIG_COMP_TESTER=m CONFIG_COMP_SRC_IPC4_FULL_MATRIX=y CONFIG_COMP_UP_DOWN_MIXER=y CONFIG_COMP_VOLUME_WINDOWS_FADE=y diff --git a/app/configs/mtl/modules.conf b/app/configs/mtl/modules.conf index fbef3ae182c7..36ad94c263ab 100644 --- a/app/configs/mtl/modules.conf +++ b/app/configs/mtl/modules.conf @@ -20,3 +20,4 @@ CONFIG_COMP_CROSSOVER=m CONFIG_COMP_MULTIBAND_DRC=m CONFIG_COMP_GOOGLE_CTC_AUDIO_PROCESSING=m CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING=m +CONFIG_COMP_TESTER=m diff --git a/src/Kconfig b/src/Kconfig index 378cd533b0b7..46f30b287450 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -25,3 +25,5 @@ rsource "library_manager/Kconfig" rsource "debug/telemetry/Kconfig" rsource "debug/debug_stream/Kconfig" + +rsource "debug/tester/Kconfig" diff --git a/src/audio/sink_source_utils.c b/src/audio/sink_source_utils.c index fcbef17f94f9..1fb86df386c2 100644 --- a/src/audio/sink_source_utils.c +++ b/src/audio/sink_source_utils.c @@ -72,6 +72,7 @@ int source_to_sink_copy(struct sof_source *source, sink_commit_buffer(sink, INT_MAX); return 0; } +EXPORT_SYMBOL(source_to_sink_copy); int sink_fill_with_silence(struct sof_sink *sink, size_t size) { @@ -107,6 +108,7 @@ int sink_fill_with_silence(struct sof_sink *sink, size_t size) sink_commit_buffer(sink, INT_MAX); return 0; } +EXPORT_SYMBOL(sink_fill_with_silence); int source_drop_data(struct sof_source *source, size_t size) { @@ -130,7 +132,4 @@ int source_drop_data(struct sof_source *source, size_t size) source_release_data(source, INT_MAX); return 0; } - -EXPORT_SYMBOL(sink_fill_with_silence); -EXPORT_SYMBOL(source_to_sink_copy); EXPORT_SYMBOL(source_drop_data); diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index 394895f58c9e..60521cfa2cb0 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -4,4 +4,8 @@ if(CONFIG_GDB_DEBUG) add_subdirectory(gdb) endif() +if(CONFIG_COMP_TESTER) + add_subdirectory(tester) +endif() + add_local_sources(sof panic.c) diff --git a/src/debug/tester/CMakeLists.txt b/src/debug/tester/CMakeLists.txt new file mode 100644 index 000000000000..a38b971ca72f --- /dev/null +++ b/src/debug/tester/CMakeLists.txt @@ -0,0 +1,2 @@ +add_local_sources(tester.c) +add_local_sources(tester_dummy_test.c) diff --git a/src/debug/tester/Kconfig b/src/debug/tester/Kconfig new file mode 100644 index 000000000000..f635157a7295 --- /dev/null +++ b/src/debug/tester/Kconfig @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause + +config COMP_TESTER + tristate "tester module" + default n + depends on IPC_MAJOR_4 + help + Select for loadable module for testing diff --git a/src/debug/tester/llext/CMakeLists.txt b/src/debug/tester/llext/CMakeLists.txt new file mode 100644 index 000000000000..a629ef98ca7b --- /dev/null +++ b/src/debug/tester/llext/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (c) 2024 Intel Corporation. +# SPDX-License-Identifier: Apache-2.0 + +sof_llext_build("tester" + SOURCES ../tester.c + ../tester_dummy_test.c +) diff --git a/src/debug/tester/llext/llext.toml.h b/src/debug/tester/llext/llext.toml.h new file mode 100644 index 000000000000..764d6e743506 --- /dev/null +++ b/src/debug/tester/llext/llext.toml.h @@ -0,0 +1,6 @@ +#include +#define LOAD_TYPE "2" +#include "../tester.toml" + +[module] +count = __COUNTER__ diff --git a/src/debug/tester/tester.c b/src/debug/tester/tester.c new file mode 100644 index 000000000000..d697572edddc --- /dev/null +++ b/src/debug/tester/tester.c @@ -0,0 +1,244 @@ +//SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2025 Intel Corporation. All rights reserved. +// +// Author: Marcin Szkudlinski + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tester.h" +#include "tester_dummy_test.h" + +/** + * Tester module is a framework for a runtime testing that need a special internal code + * i.e. provide an extra load to CPU by running additional thread, etc. + * + * The idea is to allow testing of special cases using a standard "production" build. + * The module should be compiled as a loadable module only, as it is not needed + * in any real production case. + * + * In order to keep only one testing module (in meaning of + * a SOF module with separate UUID), a framework is introduced, + * where a test to be executed is selected by IPC parameter + */ + +LOG_MODULE_REGISTER(tester, CONFIG_SOF_LOG_LEVEL); + +SOF_DEFINE_REG_UUID(tester); + +DECLARE_TR_CTX(tester_tr, SOF_UUID(tester_uuid), LOG_LEVEL_INFO); + +struct tester_init_config { + struct ipc4_base_module_cfg ipc4_cfg; + int32_t test_type; +} __attribute__((packed, aligned(4))); + +static int tester_init(struct processing_module *mod) +{ + struct module_data *md = &mod->priv; + struct comp_dev *dev = mod->dev; + struct module_config *cfg = &md->cfg; + size_t bs = cfg->size; + struct tester_module_data *cd = NULL; + int ret = 0; + + if (bs != sizeof(struct tester_init_config)) { + comp_err(dev, "tester_init(): Invalid config"); + return -EINVAL; + } + + /* allocate ctx for test module in shared memory - to allow all non-standard operations + * without problems with cache + */ + cd = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*cd)); + if (!cd) { + comp_err(dev, "Out of memory"); + return -ENOMEM; + } + + struct tester_init_config *init_cfg = (struct tester_init_config *)cfg->init_data; + + cd->test_case_type = init_cfg->test_type; + switch (cd->test_case_type) { + case TESTER_MODULE_CASE_DUMMY_TEST: + cd->tester_case_interface = &tester_interface_dummy_test; + break; + + default: + comp_err(dev, "Invalid config, unknown test type"); + return -EINVAL; + } + + module_set_private_data(mod, cd); + + if (cd->tester_case_interface->init) + ret = cd->tester_case_interface->init(mod, &cd->test_case_ctx); + + return ret; +} + +static int tester_prepare(struct processing_module *mod, + struct sof_source **sources, int num_of_sources, + struct sof_sink **sinks, int num_of_sinks) +{ + struct tester_module_data *cd = module_get_private_data(mod); + int ret = 0; + + if (cd->tester_case_interface->prepare) + ret = cd->tester_case_interface->prepare(cd->test_case_ctx, mod, + sources, num_of_sources, + sinks, num_of_sinks); + + return ret; +} + +int tester_set_configuration(struct processing_module *mod, + uint32_t config_id, + enum module_cfg_fragment_position pos, uint32_t data_offset_size, + const uint8_t *fragment, size_t fragment_size, uint8_t *response, + size_t response_size) +{ + struct tester_module_data *cd = module_get_private_data(mod); + int ret = 0; + + if (cd->tester_case_interface->set_configuration) + ret = cd->tester_case_interface->set_configuration( + cd->test_case_ctx, mod, config_id, pos, data_offset_size, + fragment, fragment_size, response, response_size); + + return ret; +} + +static int tester_process(struct processing_module *mod, + struct sof_source **sources, int num_of_sources, + struct sof_sink **sinks, int num_of_sinks) +{ + struct tester_module_data *cd = module_get_private_data(mod); + int ret = 0; + bool do_copy = true; + + if (cd->tester_case_interface->process) + ret = cd->tester_case_interface->process(cd->test_case_ctx, mod, + sources, num_of_sources, + sinks, num_of_sinks, &do_copy); + + if (!ret) { + size_t sink_free = sink_get_free_size(sinks[0]); + size_t source_avail = source_get_data_available(sources[0]); + size_t to_copy = MIN(sink_free, source_avail); + + if (do_copy) { + /* copy data from input to output */ + source_to_sink_copy(sources[0], sinks[0], true, to_copy); + } else { + /* drop data and generate silence */ + source_drop_data(sources[0], to_copy); + sink_fill_with_silence(sinks[0], to_copy); + } + } + + return ret; +} + +static int tester_reset(struct processing_module *mod) +{ + struct tester_module_data *cd = module_get_private_data(mod); + int ret = 0; + + if (cd->tester_case_interface->reset) + ret = cd->tester_case_interface->reset(cd->test_case_ctx, mod); + + return ret; +} + +static int tester_free(struct processing_module *mod) +{ + struct tester_module_data *cd = module_get_private_data(mod); + int ret = 0; + + if (cd->tester_case_interface->free) + ret = cd->tester_case_interface->free(cd->test_case_ctx, mod); + + rfree(cd); + return ret; +} + +static int tester_bind(struct processing_module *mod, void *data) +{ + struct tester_module_data *cd = module_get_private_data(mod); + int ret = 0; + + if (cd->tester_case_interface->bind) + ret = cd->tester_case_interface->bind(cd->test_case_ctx, mod, data); + + return ret; +} + +static int tester_unbind(struct processing_module *mod, void *data) +{ + struct tester_module_data *cd = module_get_private_data(mod); + int ret = 0; + + if (cd->tester_case_interface->unbind) + ret = cd->tester_case_interface->unbind(cd->test_case_ctx, mod, data); + + return ret; +} + +static int tester_trigger(struct processing_module *mod, int cmd) +{ + struct comp_dev *dev = mod->dev; + struct tester_module_data *cd = module_get_private_data(mod); + int ret = 0; + + if (cd->tester_case_interface->trigger) + ret = cd->tester_case_interface->trigger(cd->test_case_ctx, mod, cmd); + + if (!ret) + ret = module_adapter_set_state(mod, mod->dev, cmd); + + return ret; +} + +static const struct module_interface tester_interface = { + .init = tester_init, + .prepare = tester_prepare, + .set_configuration = tester_set_configuration, + .process = tester_process, + .reset = tester_reset, + .free = tester_free, + .bind = tester_bind, + .unbind = tester_unbind, + .trigger = tester_trigger +}; + +DECLARE_MODULE_ADAPTER(tester_interface, tester_uuid, tester_tr); +SOF_MODULE_INIT(tester, sys_comp_module_tester_interface_init); + +#if CONFIG_COMP_TESTER_MODULE +/* modular: llext dynamic link */ + +#include +#include +#include + +/* 08aeb4ff-7f68-4c71-86c3c842b4262898 */ +#define UUID_TESTER 0xff, 0xb4, 0xae, 0x08, 0x68, 0x7f, 0x71, 0x4c, \ + 0x86, 0xc3, 0xc8, 0x42, 0xb4, 0x26, 0x28, 0x98 + +SOF_LLEXT_MOD_ENTRY(tester, &tester_interface); + +static const struct sof_man_module_manifest mod_manifest __section(".module") __used = + SOF_LLEXT_MODULE_MANIFEST("TESTER", tester_llext_entry, 1, UUID_TESTER, 40); + +SOF_LLEXT_BUILDINFO; + +#endif diff --git a/src/debug/tester/tester.h b/src/debug/tester/tester.h new file mode 100644 index 000000000000..99796aa94c0a --- /dev/null +++ b/src/debug/tester/tester.h @@ -0,0 +1,97 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2025 Intel Corporation. + * + * Author: Marcin Szkudlinski + */ + +#ifndef COMP_TESTER +#define COMP_TESTER + +#include +#include +#include +#include + +#define TESTER_MODULE_CASE_NO_TEST 0 +#define TESTER_MODULE_CASE_DUMMY_TEST 1 + +/** + * API of a test case + * it is mostly a replica of module interface, with some additional parameters and functions + * + * all methods are optional + */ +struct tester_test_case_interface { + /** + * test initialization procedure, + * called in module init method + * It should allocate all required structures and return pointer to context + * in ctx param + */ + int (*init)(struct processing_module *mod, void **ctx); + + /** + * copy of module prepare method, with additional ctx param + */ + int (*prepare)(void *ctx, struct processing_module *mod, + struct sof_source **sources, int num_of_sources, + struct sof_sink **sinks, int num_of_sinks); + + /** + * copy of module set_configuration method, with additional ctx param + */ + int (*set_configuration)(void *ctx, struct processing_module *mod, + uint32_t config_id, + enum module_cfg_fragment_position pos, uint32_t data_offset_size, + const uint8_t *fragment, size_t fragment_size, uint8_t *response, + size_t response_size); + + /** + * copy of module process method, with additional + * - ctx param + * - do_copy return flag. If is set to true, the tester base will do copy all samples + * from source to sink. + * May be used to indicate if the test has failed without any messages, just by stopping + * data stream + */ + int (*process)(void *ctx, struct processing_module *mod, + struct sof_source **sources, int num_of_sources, + struct sof_sink **sinks, int num_of_sinks, + bool *do_copy); + + /** + * copy of module reset method, with additional ctx param + */ + int (*reset)(void *ctx, struct processing_module *mod); + + /** + * copy of module free method, with additional ctx param + * must free all data allocated during test + */ + int (*free)(void *ctx, struct processing_module *mod); + + /** + * copy of module bind method, with additional ctx param + */ + int (*bind)(void *ctx, struct processing_module *mod, void *data); + + /** + * copy of module unbind method, with additional ctx param + */ + int (*unbind)(void *ctx, struct processing_module *mod, void *data); + + /** + * copy of module trigger method, with additional ctx param + */ + int (*trigger)(void *ctx, struct processing_module *mod, int cmd); + +}; + +struct tester_module_data { + const struct tester_test_case_interface *tester_case_interface; + uint32_t test_case_type; + void *test_case_ctx; +}; + +#endif /* COMP_TESTER */ diff --git a/src/debug/tester/tester.toml b/src/debug/tester/tester.toml new file mode 100644 index 000000000000..57bf76ad41c7 --- /dev/null +++ b/src/debug/tester/tester.toml @@ -0,0 +1,74 @@ +#ifndef LOAD_TYPE +#define LOAD_TYPE "0" +#endif + + [[module.entry]] + name = "TESTER" + uuid = "08AEB4FF-7F68-4C71-86C3-C842B4262898" + affinity_mask = "0x1" + REM #instance_count = "10" + domain_types = "0" + load_type = LOAD_TYPE + module_type = "7" + auto_start = "0" + sched_caps = [1, 0x00008000] + + REM # pin = [dir, type, sample rate, size, container, channel-cfg] + pin = [0, 0, 0xffff, 0xc, 0x8, 0x05ff, + 1, 0, 0xf6c9, 0xc, 0x8, 0x05ff] + + REM # mod_cfg [PAR_0 PAR_1 PAR_2 PAR_3 IS_BYTES CPS IBS OBS MOD_FLAGS CPC OBLS] +#if CONFIG_METEORLAKE + mod_cfg = [1, 0, 0, 0, 12832, 15976000, 128, 512, 0, 15976, 0, + 2, 0, 0, 0, 12832, 15340000, 64, 256, 0, 15340, 0, + 3, 0, 0, 0, 12832, 21880000, 96, 512, 0, 21880, 0, + 4, 0, 0, 0, 12832, 19968000, 48, 256, 0, 19968, 0, + 5, 0, 0, 0, 12832, 18236000, 64, 256, 0, 18236, 0, + 6, 0, 0, 0, 12832, 15244000, 32, 256, 0, 15244, 0, + 7, 0, 0, 0, 12832, 56028000, 1536, 512, 0, 56028, 0, + 8, 0, 0, 0, 12832, 46740000, 768, 256, 0, 46740, 0, + 9, 0, 0, 0, 12832, 24656000, 768, 512, 0, 24656, 0, + 10, 0, 0, 0, 12832, 23516000, 384, 256, 0, 23516, 0, + 11, 0, 0, 0, 12832, 29368000, 384, 488, 0, 29368, 0, + 12, 0, 0, 0, 12832, 27164000, 192, 244, 0, 27164, 0, + 13, 0, 0, 0, 12832, 15892000, 384, 384, 0, 15892, 0, + 14, 0, 0, 0, 12832, 19916000, 192, 512, 0, 19916, 0, + 15, 0, 0, 0, 12832, 19176000, 96, 256, 0, 19176, 0, + 16, 0, 0, 0, 12832, 12676000, 192, 192, 0, 12676, 0, + 17, 0, 0, 0, 12832, 16280000, 384, 320, 0, 16280, 0, + 18, 0, 0, 0, 12832, 13076000, 192, 160, 0, 13076, 0, + 19, 0, 0, 0, 12832, 11440000, 384, 256, 0, 11440, 0, + 20, 0, 0, 0, 12832, 10996000, 192, 128, 0, 10996, 0, + 21, 0, 0, 0, 12832, 11428000, 384, 192, 0, 11428, 0, + 22, 0, 0, 0, 12832, 10740000, 192, 96, 0, 10740, 0, + 23, 0, 0, 0, 12832, 29936000, 360, 512, 0, 29936, 0, + 24, 0, 0, 0, 12832, 27696000, 180, 256, 0, 27696, 0, + 25, 0, 0, 0, 12832, 18368000, 256, 512, 0, 18368, 0, + 26, 0, 0, 0, 12832, 15204000, 128, 256, 0, 15204, 0] +#elif defined(CONFIG_LUNARLAKE) || defined(CONFIG_PANTHERLAKE) + mod_cfg = [0, 0, 0, 0, 12832, 1365500, 0, 0, 0, 1365, 0, + 1, 0, 0, 0, 12832, 2302300, 0, 0, 0, 2302, 0, + 2, 0, 0, 0, 12832, 3218200, 0, 0, 0, 3218, 0, + 3, 0, 0, 0, 12832, 4169700, 0, 0, 0, 4169, 0, + 4, 0, 0, 0, 12832, 5095100, 0, 0, 0, 5095, 0, + 5, 0, 0, 0, 12832, 6014800, 0, 0, 0, 6014, 0, + 6, 0, 0, 0, 12832, 6963500, 0, 0, 0, 6963, 0, + 7, 0, 0, 0, 12832, 7791000, 0, 0, 0, 7791, 0, + 8, 0, 0, 0, 12832, 8843000, 0, 0, 0, 8843, 0, + 9, 0, 0, 0, 12832, 9755100, 0, 0, 0, 9755, 0, + 10, 0, 0, 0, 12832, 10726500, 0, 0, 0, 10726, 0, + 11, 0, 0, 0, 12832, 11624100, 0, 0, 0, 11624, 0, + 12, 0, 0, 0, 12832, 12518700, 0, 0, 0, 12518, 0, + 13, 0, 0, 0, 12832, 13555000, 0, 0, 0, 13555, 0, + 14, 0, 0, 0, 12832, 14144500, 0, 0, 0, 14144, 0, + 15, 0, 0, 0, 12832, 15809800, 0, 0, 0, 15809, 0, + 16, 0, 0, 0, 12832, 16749000, 0, 0, 0, 16749, 0, + 17, 0, 0, 0, 12832, 18433500, 0, 0, 0, 18433, 0, + 18, 0, 0, 0, 12832, 19425900, 0, 0, 0, 19425, 0, + 19, 0, 0, 0, 12832, 20396900, 0, 0, 0, 20396, 0, + 20, 0, 0, 0, 12832, 20881000, 0, 0, 0, 20881, 0, + 21, 0, 0, 0, 12832, 23431000, 0, 0, 0, 23431, 0, + 22, 0, 0, 0, 12832, 30471000, 0, 0, 0, 30471, 0] +#endif + + index = __COUNTER__ diff --git a/src/debug/tester/tester_dummy_test.c b/src/debug/tester/tester_dummy_test.c new file mode 100644 index 000000000000..138314e5a1df --- /dev/null +++ b/src/debug/tester/tester_dummy_test.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2025 Intel Corporation. All rights reserved. +// +// Author: Marcin Szkudlinski + +#include "tester_dummy_test.h" +#include +#include + +/* + * This is a dummy test case + * The test case will copy every 2nd frame of data + * by setting do_copy flag to true/false + */ + +struct tester_module_dummy_test_data { + bool do_copy_data; +}; + +static int dummy_test_case_init(struct processing_module *mod, void **ctx) +{ + struct tester_module_dummy_test_data *data = + rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*data)); + + if (!data) + return -ENOMEM; + + data->do_copy_data = false; + *ctx = data; + return 0; +} + +int dummy_test_case_process(void *ctx, struct processing_module *mod, + struct sof_source **sources, int num_of_sources, + struct sof_sink **sinks, int num_of_sinks, + bool *do_copy) +{ + struct tester_module_dummy_test_data *data = ctx; + + /* copy every second cycle */ + *do_copy = data->do_copy_data; + data->do_copy_data = !data->do_copy_data; + + return 0; +} + +int dummy_test_free(void *ctx, struct processing_module *mod) +{ + rfree(ctx); + return 0; +} + +const struct tester_test_case_interface tester_interface_dummy_test = { + .init = dummy_test_case_init, + .process = dummy_test_case_process, + .free = dummy_test_free +}; diff --git a/src/debug/tester/tester_dummy_test.h b/src/debug/tester/tester_dummy_test.h new file mode 100644 index 000000000000..55a53266d243 --- /dev/null +++ b/src/debug/tester/tester_dummy_test.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2025 Intel Corporation. + * + * Author: Marcin Szkudlinski + */ + +#ifndef TESTER_DUMMY_TEST +#define TESTER_DUMMY_TEST + +#include +#include + +#include "tester.h" + +extern const struct tester_test_case_interface tester_interface_dummy_test; + +#endif /* TESTER_DUMMY_TEST */ diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 03f37ac884ad..40ce1158bd2d 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -831,6 +831,7 @@ void sys_comp_module_selector_interface_init(void); void sys_comp_module_src_interface_init(void); void sys_comp_module_tdfb_interface_init(void); void sys_comp_module_volume_interface_init(void); +void sys_comp_module_tester_interface_init(void); #elif CONFIG_LIBRARY /* In case of shared libs components are initialised in dlopen */ diff --git a/tools/rimage/config/mtl.toml.h b/tools/rimage/config/mtl.toml.h index 90b468efba18..9b44cbcfb67f 100644 --- a/tools/rimage/config/mtl.toml.h +++ b/tools/rimage/config/mtl.toml.h @@ -38,6 +38,10 @@ index = __COUNTER__ +#if defined(CONFIG_COMP_TESTER) || defined(LLEXT_FORCE_ALL_MODULAR) +#include +#endif + #if defined(CONFIG_COMP_MIXIN_MIXOUT) || defined(LLEXT_FORCE_ALL_MODULAR) #include