Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools: Testbench: Add IPC4 support #9483

Merged
merged 18 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3292b73
platform: library: Add missing include task.h to ll_schedule
singalsu Feb 20, 2024
be9f075
Lib: Dai-legacy: Add chmap and channel_copy members to struct dai_data
singalsu Sep 10, 2024
21b5571
IPC4: Add missing header include to alh.h
singalsu Sep 10, 2024
7bf5d3d
IPC: IPC4: Skip ipc_wait_for_compound_msg() for CONFIG_LIBRARY
singalsu Feb 19, 2024
bbd3865
IPC: IPC4: Initialize IPC reply to zero ipc_cmd()
singalsu Sep 16, 2024
634d192
IPC: IPC4: Remove unused function process_dma_index()
singalsu Sep 17, 2024
77616b6
IPC: IPC4: Add File and dcblock to UUID map
singalsu Sep 17, 2024
3c3ebc4
Audio: Component: Add module headers to component.h for testbench
singalsu Sep 17, 2024
3645e6d
Audio: Crossover: Fix IPC4 testbench build
singalsu Apr 10, 2024
fe6b8d8
Audio: TDFB: Fix flexible array members in control notification
singalsu Sep 18, 2024
ea2fdda
Audio: Volume: Remove two unused variables from peakvolume
singalsu Sep 18, 2024
e3f13a8
Tools: Testbench: Rename files with IPC3
singalsu Sep 17, 2024
c7b090a
Tools: Testbench: Clean up header files
singalsu Sep 17, 2024
8129566
Tools: Testbench: Cleanup and move common and IPC3 specific functions
singalsu Sep 17, 2024
8db545f
Tools: Testbench: Error if filename is empty in file component
singalsu Sep 24, 2024
5b3f6ec
Tools: Testbench: Add IPC4 support
singalsu Sep 17, 2024
088893e
Tools: Testbench: Rename common_test C source files to utils
singalsu Sep 19, 2024
2a0284f
Tools: Testbench: Add README.md text
singalsu Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/arch/host/configs/library_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONFIG_COMP_VOLUME_LINEAR_RAMP=y
CONFIG_COMP_VOLUME_WINDOWS_FADE=y
CONFIG_DEBUG_MEMORY_USAGE_SCAN=n
CONFIG_IPC_MAJOR_3=y
CONFIG_IPC_MAJOR_4=n
CONFIG_LIBRARY=y
CONFIG_LIBRARY_STATIC=y
CONFIG_MATH_IIR_DF2T=y
Expand Down
2 changes: 1 addition & 1 deletion src/audio/crossover/crossover_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int crossover_get_sink_id(struct comp_data *cd, uint32_t pipeline_id, uint32_t i
* kernel know that the base_cfg_ext needs to be appended to the IPC payload. The
* Extension is needed to know the output pin indices.
*/
int crossover_init_output_pins(struct processing_module *mod)
static int crossover_init_output_pins(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;
Expand Down
41 changes: 21 additions & 20 deletions src/audio/tdfb/tdfb_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
#include "tdfb.h"
#include "tdfb_comp.h"

struct tdfb_notification_payload {
struct sof_ipc4_notify_module_data module_data;
struct sof_ipc4_control_msg_payload control_msg;
struct sof_ipc4_ctrl_value_chan control_value; /* One channel value */
};

LOG_MODULE_DECLARE(tdfb, CONFIG_SOF_LOG_LEVEL);

static struct ipc_msg *tdfb_notification_init(struct processing_module *mod,
Expand All @@ -44,8 +38,9 @@ static struct ipc_msg *tdfb_notification_init(struct processing_module *mod,
struct comp_ipc_config *ipc_config = &dev->ipc_config;
union ipc4_notification_header *primary =
(union ipc4_notification_header *)&msg_proto.header;
struct sof_ipc4_notify_module_data *msg_module_data;
struct sof_ipc4_control_msg_payload *msg_payload;
struct ipc_msg *msg;
struct tdfb_notification_payload *payload;

/* Clear header, extension, and other ipc_msg members */
memset_s(&msg_proto, sizeof(msg_proto), 0, sizeof(msg_proto));
Expand All @@ -54,32 +49,38 @@ static struct ipc_msg *tdfb_notification_init(struct processing_module *mod,
primary->r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
primary->r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
msg = ipc_msg_w_ext_init(msg_proto.header, msg_proto.extension,
sizeof(struct tdfb_notification_payload));
sizeof(struct sof_ipc4_notify_module_data) +
sizeof(struct sof_ipc4_control_msg_payload) +
sizeof(struct sof_ipc4_ctrl_value_chan));
if (!msg)
return NULL;

payload = (struct tdfb_notification_payload *)msg->tx_data;
payload->module_data.instance_id = IPC4_INST_ID(ipc_config->id);
payload->module_data.module_id = IPC4_MOD_ID(ipc_config->id);
payload->module_data.event_id = SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL |
msg_module_data = (struct sof_ipc4_notify_module_data *)msg->tx_data;
msg_module_data->instance_id = IPC4_INST_ID(ipc_config->id);
msg_module_data->module_id = IPC4_MOD_ID(ipc_config->id);
msg_module_data->event_id = SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL |
control_type_param_id;
payload->module_data.event_data_size = sizeof(struct sof_ipc4_control_msg_payload) +
msg_module_data->event_data_size = sizeof(struct sof_ipc4_control_msg_payload) +
sizeof(struct sof_ipc4_ctrl_value_chan);
payload->control_msg.id = control_id;
payload->control_msg.num_elems = 1;
payload->control_value.channel = 0;

msg_payload = (struct sof_ipc4_control_msg_payload *)msg_module_data->event_data;
lgirdwood marked this conversation as resolved.
Show resolved Hide resolved
msg_payload->id = control_id;
msg_payload->num_elems = 1;
msg_payload->chanv[0].channel = 0;

comp_dbg(dev, "instance_id = 0x%08x, module_id = 0x%08x",
payload->module_data.instance_id, payload->module_data.module_id);
msg_module_data->instance_id, msg_module_data->module_id);
return msg;
}

static void tdfb_send_notification(struct ipc_msg *msg, uint32_t val)
{
struct tdfb_notification_payload *ipc_payload;
struct sof_ipc4_notify_module_data *msg_module_data;
struct sof_ipc4_control_msg_payload *msg_payload;

ipc_payload = (struct tdfb_notification_payload *)msg->tx_data;
ipc_payload->control_value.value = val;
msg_module_data = (struct sof_ipc4_notify_module_data *)msg->tx_data;
msg_payload = (struct sof_ipc4_control_msg_payload *)msg_module_data->event_data;
msg_payload->chanv[0].value = val;
ipc_msg_send(msg, NULL, false);
}

Expand Down
2 changes: 0 additions & 2 deletions src/audio/volume/volume_hifi4_with_peakvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ static void vol_s16_to_s16(struct processing_module *mod, struct input_stream_bu
+ bsource->consumed);
ae_f16x4 *out = (ae_f16x4 *)audio_stream_wrap(sink, (char *)audio_stream_get_wptr(sink)
+ bsink->size);
ae_f16 *in1;
ae_f16 *out1;
const int channels_count = audio_stream_get_channels(sink);
const int inc = sizeof(ae_f32x2);
int samples = channels_count * frames;
Expand Down
1 change: 1 addition & 0 deletions src/include/ipc4/alh.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <ipc4/gateway.h>

#define IPC4_ALH_MAX_NUMBER_OF_GTW 16
Expand Down
5 changes: 5 additions & 0 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -802,22 +802,27 @@ void sys_comp_host_init(void);
void sys_comp_kpb_init(void);
void sys_comp_selector_init(void);

void sys_comp_module_copier_interface_init(void);
void sys_comp_module_crossover_interface_init(void);
void sys_comp_module_dcblock_interface_init(void);
void sys_comp_module_demux_interface_init(void);
void sys_comp_module_drc_interface_init(void);
void sys_comp_module_dts_interface_init(void);
void sys_comp_module_eq_fir_interface_init(void);
void sys_comp_module_eq_iir_interface_init(void);
void sys_comp_module_gain_interface_init(void);
void sys_comp_module_google_rtc_audio_processing_interface_init(void);
void sys_comp_module_google_ctc_audio_processing_interface_init(void);
void sys_comp_module_igo_nr_interface_init(void);
void sys_comp_module_mfcc_interface_init(void);
void sys_comp_module_mixer_interface_init(void);
void sys_comp_module_mixin_interface_init(void);
void sys_comp_module_mixout_interface_init(void);
void sys_comp_module_multiband_drc_interface_init(void);
void sys_comp_module_mux_interface_init(void);
void sys_comp_module_asrc_interface_init(void);
void sys_comp_module_rtnr_interface_init(void);
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);
Expand Down
9 changes: 9 additions & 0 deletions src/include/sof/lib/dai-legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ struct llp_slot_info {
uint32_t reg_offset;
};

typedef int (*channel_copy_func)(const struct audio_stream *src, unsigned int src_channel,
struct audio_stream *dst, unsigned int dst_channel,
unsigned int frames);

/**
* \brief DAI runtime data
*/
Expand All @@ -181,6 +185,11 @@ struct dai_data {
int xrun; /* true if we are doing xrun recovery */

pcm_converter_func process; /* processing function */
uint32_t chmap;
channel_copy_func channel_copy; /* channel copy func used by multi-endpoint
* gateway to mux/demux stream from/to multiple
* DMA buffers
*/

uint32_t period_bytes; /* number of bytes per one period */
uint64_t total_data_processed;
Expand Down
14 changes: 13 additions & 1 deletion src/ipc/ipc4/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,17 @@ static void ipc_compound_msg_done(uint32_t msg_id, int error)
}
}

#if CONFIG_LIBRARY
/* There is no parallel execution in testbench for scheduler and pipelines, so the result would
* be always IPC4_FAILURE. Therefore the compound messages handling is simplified. The pipeline
* triggers will require an explicit scheduler call to get the components to desired state.
*/
static int ipc_wait_for_compound_msg(void)
{
atomic_set(&msg_data.delayed_reply, 0);
return IPC4_SUCCESS;
}
#else
static int ipc_wait_for_compound_msg(void)
{
int try_count = 30;
Expand All @@ -550,6 +561,7 @@ static int ipc_wait_for_compound_msg(void)

return IPC4_SUCCESS;
}
#endif

const struct ipc4_pipeline_set_state_data *ipc4_get_pipeline_data_wrapper(void)
{
Expand Down Expand Up @@ -1603,7 +1615,7 @@ void ipc_cmd(struct ipc_cmd_hdr *_hdr)
/* FW sends an ipc message to host if request bit is clear */
if (in->primary.r.rsp == SOF_IPC4_MESSAGE_DIR_MSG_REQUEST) {
struct ipc *ipc = ipc_get();
struct ipc4_message_reply reply;
struct ipc4_message_reply reply = {{0}};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of stuff could have been in a separate PR btw.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can take it to separate if this review pass takes longer than few days.


/* Process flow and time stamp for IPC4 msg processed on secondary core :
* core 0 (primary core) core x (secondary core)
Expand Down
31 changes: 10 additions & 21 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,27 +755,6 @@ int ipc_comp_disconnect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
return IPC4_SUCCESS;
}

/* dma index may be for playback or capture. Current hw supports PLATFORM_MAX_DMA_CHAN playback
* channels and the rest are for capture. This function converts DMA ID to DMA channel.
*/
static inline int process_dma_index(uint32_t dma_id, uint32_t *dir, uint32_t *chan)
{
if (dma_id > DAI_NUM_HDA_OUT + DAI_NUM_HDA_IN) {
tr_err(&ipc_tr, "dma id %d is out of range", dma_id);
return IPC4_INVALID_NODE_ID;
}

if (dma_id >= PLATFORM_MAX_DMA_CHAN) {
*dir = SOF_IPC_STREAM_CAPTURE;
*chan = dma_id - PLATFORM_MAX_DMA_CHAN;
} else {
*dir = SOF_IPC_STREAM_PLAYBACK;
*chan = dma_id;
}

return IPC4_SUCCESS;
}

#if CONFIG_COMP_CHAIN_DMA
int ipc4_chain_manager_create(struct ipc4_chain_dma *cdma)
{
Expand Down Expand Up @@ -982,6 +961,16 @@ static const struct ipc4_module_uuid uuid_map[] = {
.d = { 0xa0, 0x8f, 0x97, 0xfc, 0xc4, 0x2e, 0xaa, 0xeb }}}, /* ALSA aplay */
{0x99, {.a = 0x66def9f0, .b = 0x39f2, .c = 0x11ed,
.d = { 0xf7, 0x89, 0xaf, 0x98, 0xa6, 0x44, 0x0c, 0xc4 }}}, /* ALSA arecord */
{0x9a, {.a = 0xbfc7488c, .b = 0x75aa, .c = 0x4ce8,
.d = { 0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2 }}}, /* file read aif */
{0x9b, {.a = 0xbfc7488c, .b = 0x75aa, .c = 0x4ce8,
.d = { 0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2 }}}, /* file write aif */
{0x9c, {.a = 0xbfc7488c, .b = 0x75aa, .c = 0x4ce8,
.d = { 0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2 }}}, /* file read dai */
{0x9d, {.a = 0xbfc7488c, .b = 0x75aa, .c = 0x4ce8,
.d = { 0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2 }}}, /* file write dai */
{0x9e, {.a = 0xb809efaf, .b = 0x5681, .c = 0x42b1,
.d = { 0x9e, 0xd6, 0x04, 0xbb, 0x01, 0x2d, 0xd3, 0x84 }}}, /* process: dcblock */
};

static const struct comp_driver *ipc4_library_get_drv(int module_id)
Expand Down
1 change: 1 addition & 0 deletions src/platform/library/include/platform/lib/ll_schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef __LIBRARY_INCLUDE_LIB_SCHEDULE_H__
#define __LIBRARY_INCLUDE_LIB_SCHEDULE_H__

#include <rtos/task.h>
#include <stdint.h>

struct task;
Expand Down
7 changes: 5 additions & 2 deletions tools/testbench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ set(default_asoc_h "/usr/include/alsa/sound/uapi/asoc.h")

add_executable(testbench
testbench.c
common_test.c
file.c
topology.c
utils.c
utils_ipc3.c
utils_ipc4.c
topology_ipc3.c
topology_ipc4.c
)

sof_append_relative_path_definitions(testbench)
Expand Down
Loading
Loading