Skip to content

Commit e8fd631

Browse files
committed
zephyr: test: userspace: add ipc4_create_pipeline_check
Add a test that sends SOF_IPC4_GLB_CREATE_PIPELINE message via ipc_cmd() interface. This test can be used to test SOF when built with CONFIG_SOF_USERSPACE_LL. Handling of audio pipeline IPC messages (like CREATE_PIPELINE) will be routed to a user-space IPC thread. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 71fbedd commit e8fd631

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

zephyr/test/userspace/test_ll_task.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <ipc4/module.h>
2525
#include <ipc4/gateway.h>
2626
#include <ipc4/header.h>
27+
#include <ipc4/pipeline.h>
2728
#include <ipc4/base_fw_vendor.h>
2829
#include <module/ipc4/base-config.h>
2930
#include <rimage/sof/user/manifest.h>
@@ -148,6 +149,83 @@ ZTEST(userspace_ll, pipeline_check)
148149
pipeline_check();
149150
}
150151

152+
/**
153+
* Test creating a pipeline via IPC4 GLB_CREATE_PIPELINE message.
154+
*
155+
* Unlike pipeline_check() which calls pipeline_new() directly,
156+
* this test constructs an ipc4_pipeline_create message and sends
157+
* it through ipc_cmd(), exercising the full IPC4 command dispatch
158+
* path: ipc_cmd() -> ipc4_process_glb_message() ->
159+
* ipc_user_forward_cmd() (userspace) or ipc4_new_pipeline().
160+
*/
161+
static void ipc4_create_pipeline_check(void)
162+
{
163+
struct ipc4_pipeline_create pipe_desc = {0};
164+
struct ipc *ipc = ipc_get();
165+
struct ipc_cmd_hdr *hdr;
166+
struct ipc_comp_dev *ipc_pipe;
167+
uint32_t pipeline_id = 10;
168+
uint32_t priority = 3;
169+
int ret;
170+
171+
/* Construct IPC4 CREATE_PIPELINE message */
172+
pipe_desc.primary.r.type = SOF_IPC4_GLB_CREATE_PIPELINE;
173+
pipe_desc.primary.r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
174+
pipe_desc.primary.r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
175+
pipe_desc.primary.r.instance_id = pipeline_id;
176+
pipe_desc.primary.r.ppl_priority = priority;
177+
pipe_desc.primary.r.ppl_mem_size = 0;
178+
179+
pipe_desc.extension.r.core_id = 0;
180+
pipe_desc.extension.r.lp = 0;
181+
pipe_desc.extension.r.payload = 0;
182+
183+
/*
184+
* Populate handler.c's internal IPC message buffer.
185+
* ipc_compact_read_msg() returns a pointer to the static
186+
* msg_data.msg_in used by ipc_cmd() via ipc4_get_message_request().
187+
* Overwriting through this pointer sets up the message for dispatch.
188+
*/
189+
hdr = ipc_compact_read_msg();
190+
hdr->pri = pipe_desc.primary.dat;
191+
hdr->ext = pipe_desc.extension.dat;
192+
193+
/* Send through the full IPC command dispatch path */
194+
ipc_cmd(hdr);
195+
196+
LOG_INF("ipc_cmd() returned for pipeline id=%u", pipeline_id);
197+
198+
/* Verify pipeline is registered in IPC component list */
199+
ipc_pipe = ipc_get_pipeline_by_id(ipc, pipeline_id);
200+
zassert_not_null(ipc_pipe, "pipeline not found in IPC comp list");
201+
zassert_equal(ipc_pipe->type, COMP_TYPE_PIPELINE, "wrong comp type");
202+
zassert_equal(ipc_pipe->id, pipeline_id, "pipeline id mismatch");
203+
zassert_not_null(ipc_pipe->pipeline, "pipeline struct is NULL");
204+
zassert_equal(ipc_pipe->pipeline->pipeline_id, pipeline_id,
205+
"pipeline->pipeline_id mismatch");
206+
zassert_equal(ipc_pipe->pipeline->priority, priority,
207+
"pipeline priority mismatch");
208+
zassert_equal(ipc_pipe->pipeline->time_domain, SOF_TIME_DOMAIN_TIMER,
209+
"time_domain not set");
210+
211+
LOG_INF("pipeline verified in IPC comp list");
212+
213+
/* Clean up through IPC free path */
214+
ret = ipc_pipeline_free(ipc, pipeline_id);
215+
zassert_equal(ret, 0, "ipc_pipeline_free failed: %%d", ret);
216+
217+
/* Verify pipeline is removed from IPC component list */
218+
ipc_pipe = ipc_get_pipeline_by_id(ipc, pipeline_id);
219+
zassert_is_null(ipc_pipe, "pipeline still in IPC comp list after free");
220+
221+
LOG_INF("ipc4 create pipeline test complete");
222+
}
223+
224+
ZTEST(userspace_ll, ipc4_create_pipeline_check)
225+
{
226+
ipc4_create_pipeline_check();
227+
}
228+
151229
/* Copier UUID: 9ba00c83-ca12-4a83-943c-1fa2e82f9dda */
152230
static const uint8_t copier_uuid[16] = {
153231
0x83, 0x0c, 0xa0, 0x9b, 0x12, 0xca, 0x83, 0x4a,

0 commit comments

Comments
 (0)