Skip to content

Commit d7d6b73

Browse files
committed
updates.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 9eb49af commit d7d6b73

File tree

5 files changed

+107
-64
lines changed

5 files changed

+107
-64
lines changed

src/audio/copier/copier.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,9 +1053,11 @@ static uint64_t copier_get_processed_data(struct comp_dev *dev, uint32_t stream_
10531053
switch (dev->ipc_config.type) {
10541054
case SOF_COMP_HOST:
10551055
source = dev->direction == SOF_IPC_STREAM_PLAYBACK;
1056-
/* only support host, not support ipcgtw/qemugtw case */
1056+
/* support host and qemugtw gateway cases */
10571057
if (!cd->ipc_gtw && !cd->qemu_gtw && source == input)
10581058
ret = cd->hd->total_data_processed;
1059+
else if (cd->qemu_gtw && source == input)
1060+
ret = input ? cd->input_total_data_processed : cd->output_total_data_processed;
10591061
break;
10601062
case SOF_COMP_DAI:
10611063
source = dev->direction == SOF_IPC_STREAM_CAPTURE;

src/audio/copier/copier_qemugtw.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ int copier_qemugtw_process(struct comp_dev *dev)
159159
qemugtw_generate_signal(qemugtw_data, buf, data_size);
160160
buffer_stream_writeback(buf, data_size);
161161
comp_update_buffer_produce(buf, data_size);
162+
struct processing_module *mod = comp_mod(dev);
163+
struct copier_data *cd = module_get_private_data(mod);
164+
cd->input_total_data_processed += data_size;
162165
}
163166
} else { /* DSP -> GTW, consume and validate */
164167
process_bytes = audio_stream_period_bytes(&buf->stream, dev->frames);
@@ -167,6 +170,9 @@ int copier_qemugtw_process(struct comp_dev *dev)
167170
buffer_stream_invalidate(buf, data_size);
168171
qemugtw_validate_signal(qemugtw_data, buf, data_size);
169172
comp_update_buffer_consume(buf, data_size);
173+
struct processing_module *mod = comp_mod(dev);
174+
struct copier_data *cd = module_get_private_data(mod);
175+
cd->output_total_data_processed += data_size;
170176
}
171177
}
172178

zephyr/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ endif()
2323
if(CONFIG_SOF_BOOT_TEST_STANDALONE AND CONFIG_SOF_USERSPACE_LL)
2424
zephyr_library_sources(userspace/test_ll_task.c)
2525
zephyr_library_sources(userspace/test_ipc4_pipeline.c)
26+
zephyr_library_sources(audio/test_copier.c)
27+
zephyr_library_sources(audio/test_src.c)
2628
endif()

zephyr/test/userspace/test_ipc4_pipeline.c

Lines changed: 75 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -259,29 +259,28 @@ static void *ipc4_pipeline_setup(void)
259259
struct sof *sof = sof_get();
260260
printk("DEBUG: Entering ipc4_pipeline_setup\n");
261261

262-
volatile void *refs[] = {
263-
sys_comp_module_src_interface_init,
264-
sys_comp_module_copier_interface_init,
265-
sys_comp_module_volume_interface_init,
266-
sys_comp_module_mixin_interface_init,
267-
sys_comp_module_mixout_interface_init,
262+
sys_comp_init(sof);
263+
264+
sys_comp_module_src_interface_init();
265+
sys_comp_module_copier_interface_init();
266+
sys_comp_module_volume_interface_init();
267+
sys_comp_module_mixin_interface_init();
268+
sys_comp_module_mixout_interface_init();
268269
#if defined(CONFIG_COMP_EQ_IIR)
269-
sys_comp_module_eq_iir_interface_init,
270+
sys_comp_module_eq_iir_interface_init();
270271
#endif
271272
#if defined(CONFIG_COMP_EQ_FIR)
272-
sys_comp_module_eq_fir_interface_init,
273+
sys_comp_module_eq_fir_interface_init();
273274
#endif
274275
#if defined(CONFIG_COMP_DRC)
275-
sys_comp_module_drc_interface_init,
276+
sys_comp_module_drc_interface_init();
276277
#endif
277278
#if defined(CONFIG_COMP_ARIA)
278-
sys_comp_module_aria_interface_init,
279+
sys_comp_module_aria_interface_init();
279280
#endif
280281
#if defined(CONFIG_COMP_MFCC)
281-
sys_comp_module_mfcc_interface_init,
282+
sys_comp_module_mfcc_interface_init();
282283
#endif
283-
};
284-
(void)refs;
285284

286285
/* SOF_BOOT_TEST_STANDALONE skips IPC init. We must allocate it manually for testing. */
287286
if (!sof->ipc) {
@@ -477,6 +476,8 @@ struct test_pipeline_state {
477476
struct comp_dev *sched_comp;
478477
struct comp_buffer *source_buf; /* Mock source buffer for edge */
479478
struct comp_buffer *sink_buf; /* Mock sink buffer for edge */
479+
uint64_t accumulated_bytes[MAX_PIPELINE_MODULES];
480+
void *last_wptr[MAX_PIPELINE_MODULES];
480481
};
481482

482483
/**
@@ -577,15 +578,33 @@ static void print_module_buffers(struct test_pipeline_state *p_state)
577578
{
578579
for (uint32_t i = 0; i < p_state->num_modules; i++) {
579580
struct comp_dev *mod = p_state->modules[i];
580-
uint64_t bytes_copied = comp_get_total_data_processed(mod, 0, true);
581+
uint64_t bytes_copied = 0;
581582
uint32_t frames_copied = 0;
582583
struct list_item *clist;
583584
uint32_t frame_bytes = 0;
584585

585586
if (!list_is_empty(&mod->bsink_list)) {
586587
struct comp_buffer *buf = list_first_item(&mod->bsink_list, struct comp_buffer, source_list);
587588
frame_bytes = audio_stream_frame_bytes(&buf->stream);
589+
590+
void *current_wptr = audio_stream_get_wptr(&buf->stream);
591+
void *last_wptr = p_state->last_wptr[i];
592+
uint32_t buffer_size = audio_stream_get_size(&buf->stream);
593+
594+
if (last_wptr && current_wptr != last_wptr) {
595+
uint32_t diff;
596+
if (current_wptr >= last_wptr)
597+
diff = (char *)current_wptr - (char *)last_wptr;
598+
else
599+
diff = buffer_size - ((char *)last_wptr - (char *)current_wptr);
600+
601+
p_state->accumulated_bytes[i] += diff;
602+
}
603+
p_state->last_wptr[i] = current_wptr;
604+
bytes_copied = p_state->accumulated_bytes[i];
588605
} else if (!list_is_empty(&mod->bsource_list)) {
606+
/* If it's a gateway that only has a source but no sink, query its internal counter */
607+
bytes_copied = comp_get_total_data_processed(mod, 0, false);
589608
struct comp_buffer *buf = list_first_item(&mod->bsource_list, struct comp_buffer, sink_list);
590609
frame_bytes = audio_stream_frame_bytes(&buf->stream);
591610
}
@@ -658,7 +677,8 @@ static int test_pipeline_build(struct test_pipeline_state *state,
658677
};
659678
};
660679

661-
zassert_not_null(drv, "Driver for module %zu not found", i);
680+
zassert_not_null(drv, "Driver for module %zu (comp_id 0x%x) not found",
681+
i, defs[i].comp_id);
662682

663683
struct comp_ipc_config cfg = {
664684
.id = defs[i].comp_id,
@@ -1394,34 +1414,33 @@ static void multiple_pipelines_thread(void *p1, void *p2, void *p3)
13941414
#endif
13951415

13961416
#if defined(CONFIG_COMP_MFCC)
1397-
struct sof_mfcc_config mfcc_cfg;
1398-
struct ipc4_base_module_cfg mfcc_base;
1399-
memcpy(&mfcc_base, &mfcc_cfg, sizeof(mfcc_base));
1400-
memset(&mfcc_cfg, 0, sizeof(mfcc_cfg));
1417+
struct sof_mfcc_config mfcc_init;
1418+
memset(&mfcc_init, 0, sizeof(mfcc_init));
14011419

14021420
/* MFCC implicitly overlays the base configuration over its `size` + `reserved` fields */
1403-
mfcc_base = base_cfg;
1404-
mfcc_base.cpc = sizeof(struct sof_mfcc_config); /* cpc aliases to config->size */
1405-
1406-
mfcc_cfg.sample_frequency = 48000;
1407-
mfcc_cfg.channel = 0;
1408-
mfcc_cfg.frame_length = 400;
1409-
mfcc_cfg.frame_shift = 160;
1410-
mfcc_cfg.num_mel_bins = 23;
1411-
mfcc_cfg.num_ceps = 13;
1412-
mfcc_cfg.dct = MFCC_DCT_II;
1413-
mfcc_cfg.window = MFCC_BLACKMAN_WINDOW;
1414-
mfcc_cfg.blackman_coef = MFCC_BLACKMAN_A0;
1415-
mfcc_cfg.cepstral_lifter = 22 << 9;
1416-
mfcc_cfg.round_to_power_of_two = true;
1417-
mfcc_cfg.snip_edges = true;
1421+
memcpy(&mfcc_init, &base_cfg, sizeof(base_cfg));
1422+
/* We set cpc (aliasing config->size) so MFCC parses the entire incoming configuration payload */
1423+
mfcc_init.size = sizeof(struct sof_mfcc_config);
1424+
1425+
mfcc_init.sample_frequency = 48000;
1426+
mfcc_init.channel = 0;
1427+
mfcc_init.frame_length = 400;
1428+
mfcc_init.frame_shift = 160;
1429+
mfcc_init.num_mel_bins = 23;
1430+
mfcc_init.num_ceps = 13;
1431+
mfcc_init.dct = MFCC_DCT_II;
1432+
mfcc_init.window = MFCC_BLACKMAN_WINDOW;
1433+
mfcc_init.blackman_coef = MFCC_BLACKMAN_A0;
1434+
mfcc_init.cepstral_lifter = 22 << 9;
1435+
mfcc_init.round_to_power_of_two = true;
1436+
mfcc_init.snip_edges = true;
14181437

14191438
struct test_module_def p3_defs[] = {
14201439
{ .uuid = &COPIER_UUID, .comp_id = IPC4_COMP_ID(13, 0), .pipeline_id = 12,
14211440
.init_data = &c_cfg, .init_data_size = sizeof(c_cfg), .is_pipeline_source = true, .is_sched_comp = true,
14221441
.num_sinks = 1, .sinks = { { .sink_comp_id = IPC4_COMP_ID(14, 0) } } },
14231442
{ .uuid = &MFCC_UUID, .comp_id = IPC4_COMP_ID(14, 0), .pipeline_id = 12,
1424-
.init_data = &mfcc_base, .init_data_size = sizeof(mfcc_base),
1443+
.init_data = &mfcc_init, .init_data_size = sizeof(mfcc_init),
14251444
.num_sinks = 1, .sinks = { { .sink_comp_id = IPC4_COMP_ID(15, 0) } } },
14261445
{ .uuid = &COPIER_UUID, .comp_id = IPC4_COMP_ID(15, 0), .pipeline_id = 12,
14271446
.init_data = &c_out_cfg, .init_data_size = sizeof(c_out_cfg), .is_pipeline_sink = true }
@@ -1619,26 +1638,26 @@ static void all_modules_ll_pipeline_thread(void *p1, void *p2, void *p3)
16191638
#endif
16201639

16211640
#if defined(CONFIG_COMP_MFCC)
1622-
struct sof_mfcc_config mfcc_cfg;
1623-
struct ipc4_base_module_cfg mfcc_base;
1624-
memcpy(&mfcc_base, &mfcc_cfg, sizeof(mfcc_base));
1625-
memset(&mfcc_cfg, 0, sizeof(mfcc_cfg));
1626-
1627-
mfcc_base = base_cfg;
1628-
mfcc_base.cpc = sizeof(struct sof_mfcc_config);
1629-
1630-
mfcc_cfg.sample_frequency = 48000;
1631-
mfcc_cfg.channel = 0;
1632-
mfcc_cfg.frame_length = 400;
1633-
mfcc_cfg.frame_shift = 160;
1634-
mfcc_cfg.num_mel_bins = 23;
1635-
mfcc_cfg.num_ceps = 13;
1636-
mfcc_cfg.dct = MFCC_DCT_II;
1637-
mfcc_cfg.window = MFCC_BLACKMAN_WINDOW;
1638-
mfcc_cfg.blackman_coef = MFCC_BLACKMAN_A0;
1639-
mfcc_cfg.cepstral_lifter = 22 << 9;
1640-
mfcc_cfg.round_to_power_of_two = true;
1641-
mfcc_cfg.snip_edges = true;
1641+
struct sof_mfcc_config mfcc_init;
1642+
memset(&mfcc_init, 0, sizeof(mfcc_init));
1643+
1644+
/* MFCC implicitly overlays the base configuration over its `size` + `reserved` fields */
1645+
memcpy(&mfcc_init, &base_cfg, sizeof(base_cfg));
1646+
/* We set cpc (aliasing config->size) so MFCC parses the entire incoming configuration payload */
1647+
mfcc_init.size = sizeof(struct sof_mfcc_config);
1648+
1649+
mfcc_init.sample_frequency = 48000;
1650+
mfcc_init.channel = 0;
1651+
mfcc_init.frame_length = 400;
1652+
mfcc_init.frame_shift = 160;
1653+
mfcc_init.num_mel_bins = 23;
1654+
mfcc_init.num_ceps = 13;
1655+
mfcc_init.dct = MFCC_DCT_II;
1656+
mfcc_init.window = MFCC_BLACKMAN_WINDOW;
1657+
mfcc_init.blackman_coef = MFCC_BLACKMAN_A0;
1658+
mfcc_init.cepstral_lifter = 22 << 9;
1659+
mfcc_init.round_to_power_of_two = true;
1660+
mfcc_init.snip_edges = true;
16421661
#endif
16431662

16441663
struct test_module_info modules_to_test[] = {
@@ -1655,7 +1674,7 @@ static void all_modules_ll_pipeline_thread(void *p1, void *p2, void *p3)
16551674
{ &ARIA_UUID, &aria_cfg, sizeof(aria_cfg), "ARIA" },
16561675
#endif
16571676
#if defined(CONFIG_COMP_MFCC)
1658-
{ &MFCC_UUID, &mfcc_cfg, sizeof(mfcc_cfg), "MFCC" },
1677+
{ &MFCC_UUID, &mfcc_init, sizeof(mfcc_init), "MFCC" },
16591678
#endif
16601679
// Skip testing Volume standalone since test struct isn't fully defined yet
16611680
};

zephyr/test/userspace/test_ll_task.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
#include <sof/boot_test.h>
1111
#include <sof/lib/mailbox.h>
1212
#include <sof/lib/uuid.h>
13-
#include <sof/schedule/schedule.h>
1413
#include <sof/schedule/ll_schedule.h>
1514
#include <sof/schedule/ll_schedule_domain.h>
15+
#include <sof/audio/component.h>
16+
#include <sof/audio/component_ext.h>
17+
#include <sof/schedule/ll_schedule_domain.h>
1618
#include <sof/audio/pipeline.h>
1719
#include <rtos/task.h>
1820
#include <rtos/userspace_helper.h>
@@ -46,7 +48,7 @@ static enum task_state task_callback(void *arg)
4648
return SOF_TASK_STATE_RESCHEDULE;
4749
}
4850

49-
static void __attribute__((unused)) ll_task_test(void)
51+
static void ll_task_test(void)
5052
{
5153
struct task *task;
5254
int priority = 0;
@@ -88,11 +90,7 @@ static void __attribute__((unused)) ll_task_test(void)
8890

8991
ZTEST(userspace_ll, ll_task_test)
9092
{
91-
#ifndef CONFIG_QEMU_TARGET
9293
ll_task_test();
93-
#else
94-
ztest_test_skip();
95-
#endif
9694
}
9795

9896
static void pipeline_check(void)
@@ -129,6 +127,22 @@ ZTEST(userspace_ll, pipeline_check)
129127
pipeline_check();
130128
}
131129

132-
ZTEST_SUITE(userspace_ll, NULL, NULL, NULL, NULL, NULL);
130+
static struct dma_info dummy_dma_info = {
131+
.dma_array = NULL,
132+
.num_dmas = 0,
133+
};
134+
135+
static void *userspace_ll_setup(void)
136+
{
137+
struct sof *sof = sof_get();
138+
139+
k_mem_domain_add_partition(zephyr_ll_mem_domain(), &userspace_ll_part);
140+
sof->dma_info = &dummy_dma_info;
141+
sof->platform_timer_domain = zephyr_domain_init(19200000);
142+
scheduler_init_ll(sof->platform_timer_domain);
143+
return NULL;
144+
}
145+
146+
ZTEST_SUITE(userspace_ll, NULL, userspace_ll_setup, NULL, NULL, NULL);
133147

134148

0 commit comments

Comments
 (0)