Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 21 additions & 9 deletions src/audio/module_adapter/module/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ int module_prepare(struct processing_module *mod,

#if CONFIG_SOF_USERSPACE_APPLICATION
if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
const union scheduler_dp_thread_ipc_param param = {
union scheduler_dp_thread_ipc_param param = {
.pipeline_state = {
.trigger_cmd = COMP_TRIGGER_PREPARE,
.state = SOF_IPC4_PIPELINE_STATE_RUNNING,
Expand Down Expand Up @@ -722,7 +722,7 @@ int module_reset(struct processing_module *mod)
if (ops->reset) {
#if CONFIG_SOF_USERSPACE_APPLICATION
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
const union scheduler_dp_thread_ipc_param param = {
union scheduler_dp_thread_ipc_param param = {
.pipeline_state.trigger_cmd = COMP_TRIGGER_STOP,
};
ret = scheduler_dp_thread_ipc(mod, SOF_IPC4_GLB_SET_PIPELINE_STATE, &param);
Expand Down Expand Up @@ -781,11 +781,23 @@ int module_free(struct processing_module *mod)
struct module_data *md = &mod->priv;
int ret = 0;

if (ops->free && (mod->dev->ipc_config.proc_domain != COMP_PROCESSING_DOMAIN_DP ||
!IS_ENABLED(CONFIG_SOF_USERSPACE_APPLICATION))) {
ret = ops->free(mod);
if (ret)
comp_warn(mod->dev, "error: %d", ret);
if (ops->free) {
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL ||
!IS_ENABLED(CONFIG_SOF_USERSPACE_APPLICATION)) {
ret = ops->free(mod);
if (ret)
comp_warn(mod->dev, "error: %d", ret);
#if CONFIG_SOF_USERSPACE_APPLICATION
} else {
/*
* Run DP module's .free() method in its thread context.
* Unlike with other IPCs we first run module's .free()
* in thread context, then cancel the thread, and then
* execute final clean up
*/
scheduler_dp_thread_ipc(mod, SOF_IPC4_MOD_DELETE_INSTANCE, NULL);
#endif
}
}

/* Free all memory shared by module_adapter & module */
Expand Down Expand Up @@ -939,7 +951,7 @@ int module_bind(struct processing_module *mod, const struct bind_info *bind_data
if (ops->bind) {
#if CONFIG_SOF_USERSPACE_APPLICATION
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
const union scheduler_dp_thread_ipc_param param = {
union scheduler_dp_thread_ipc_param param = {
.bind_data = bind_data,
};
ret = scheduler_dp_thread_ipc(mod, SOF_IPC4_MOD_BIND, &param);
Expand Down Expand Up @@ -972,7 +984,7 @@ int module_unbind(struct processing_module *mod, const struct bind_info *unbind_
if (ops->unbind) {
#if CONFIG_SOF_USERSPACE_APPLICATION
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
const union scheduler_dp_thread_ipc_param param = {
union scheduler_dp_thread_ipc_param param = {
.bind_data = unbind_data,
};
ret = scheduler_dp_thread_ipc(mod, SOF_IPC4_MOD_UNBIND, &param);
Expand Down
13 changes: 1 addition & 12 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ int module_adapter_trigger(struct comp_dev *dev, int cmd)
#if CONFIG_SOF_USERSPACE_APPLICATION
if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
/* Process DP module's trigger */
const union scheduler_dp_thread_ipc_param param = {
union scheduler_dp_thread_ipc_param param = {
.pipeline_state.trigger_cmd = cmd,
};
return scheduler_dp_thread_ipc(mod, SOF_IPC4_GLB_SET_PIPELINE_STATE,
Expand Down Expand Up @@ -1483,17 +1483,6 @@ void module_adapter_free(struct comp_dev *dev)

comp_dbg(dev, "start");

#if CONFIG_SOF_USERSPACE_APPLICATION
if (dev->task)
/*
* Run DP module's .free() method in its thread context.
* Unlike with other IPCs we first run module's .free() in
* thread context, then cancel the thread, and then execute
* final clean up
*/
scheduler_dp_thread_ipc(mod, SOF_IPC4_MOD_DELETE_INSTANCE, NULL);
#endif

ret = module_free(mod);
if (ret)
comp_err(dev, "failed with error: %d", ret);
Expand Down
52 changes: 45 additions & 7 deletions src/audio/module_adapter/module_adapter_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <sof/lib/mailbox.h>
#include <sof/platform.h>
#include <sof/ut.h>
#include <sof/schedule/dp_schedule.h>
#include <module/module/interface.h>
#include <rtos/interrupt.h>
#include <rtos/symbol.h>
#include <ipc4/base_fw.h>
Expand Down Expand Up @@ -263,10 +265,27 @@ int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_
return -EINVAL;
}

if (interface->set_configuration)
return interface->set_configuration(mod, param_id, pos, data_offset_size,
(const uint8_t *)data, fragment_size,
NULL, 0);
if (interface->set_configuration) {
#if CONFIG_SOF_USERSPACE_APPLICATION
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
union scheduler_dp_thread_ipc_param param = {
.set_config = {
.param_id = param_id,
.position = pos,
.data_offset_size = data_offset_size,
.data = data,
.fragment_size = fragment_size,
},
};

return scheduler_dp_thread_ipc(mod, SOF_IPC4_MOD_LARGE_CONFIG_SET, &param);
} else
#endif
return interface->set_configuration(mod, param_id, pos, data_offset_size,
(const uint8_t *)data, fragment_size,
NULL, 0);
}

return 0;
}

Expand Down Expand Up @@ -297,9 +316,28 @@ int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_
}
}

if (interface->get_configuration)
return interface->get_configuration(mod, param_id, data_offset_size,
(uint8_t *)data, fragment_size);
if (interface->get_configuration) {
#if CONFIG_SOF_USERSPACE_APPLICATION
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
union scheduler_dp_thread_ipc_param param = {
.get_config = {
.param_id = param_id,
.data_offset_size = *data_offset_size,
.data = data,
.fragment_size = fragment_size,
},
};

int ret = scheduler_dp_thread_ipc(mod, SOF_IPC4_MOD_LARGE_CONFIG_SET,
&param);
if (!ret)
*data_offset_size = param.get_config.data_offset_size;
} else
#endif
return interface->get_configuration(mod, param_id, data_offset_size,
(uint8_t *)data, fragment_size);
}

/*
* Return error if getter is not implemented. Otherwise, the host will suppose
* the GET_VALUE command is successful, but the received cdata is not filled.
Expand Down
13 changes: 0 additions & 13 deletions src/include/ipc4/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ int ipc4_user_module_load(const struct comp_driver *drv,
int ipc4_process_module_config(struct ipc4_message_request *ipc4,
bool set, uint32_t *reply_ext);

/**
* @brief Process MOD_LARGE_CONFIG_GET in any execution context.
* @param[in] ipc4 IPC4 message request.
* @param[out] reply_ext Receives extension value for reply.
* @param[out] reply_tx_size Receives TX data size for reply.
* @param[out] reply_tx_data Receives TX data pointer for reply.
* @return IPC4 status code (0 on success).
*/
int ipc4_process_large_config_get(struct ipc4_message_request *ipc4,
uint32_t *reply_ext,
uint32_t *reply_tx_size,
void **reply_tx_data);

/**
* @brief Process MOD_LARGE_CONFIG_SET in any execution context.
* @param[in] ipc4 IPC4 message request.
Expand Down
18 changes: 16 additions & 2 deletions src/include/sof/schedule/dp_schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <ipc4/base_fw.h>
#include <ipc4/module.h>
#include <ipc4/pipeline.h>
#include <module/module/interface.h>

struct processing_module;
struct module_ext_init_data;
Expand Down Expand Up @@ -129,15 +130,28 @@ union scheduler_dp_thread_ipc_param {
int n_sinks;
struct sof_sink **sinks;
} pipeline_state;
struct {
uint32_t param_id;
enum module_cfg_fragment_position position;
uint32_t data_offset_size;
size_t fragment_size;
const char *data;
} set_config;
struct {
uint32_t param_id;
uint32_t data_offset_size;
size_t fragment_size;
char *data;
} get_config;
};

#if CONFIG_ZEPHYR_DP_SCHEDULER
int scheduler_dp_thread_ipc(struct processing_module *pmod, unsigned int cmd,
const union scheduler_dp_thread_ipc_param *param);
union scheduler_dp_thread_ipc_param *param);
#else
static inline int scheduler_dp_thread_ipc(struct processing_module *pmod,
unsigned int cmd,
const union scheduler_dp_thread_ipc_param *param)
union scheduler_dp_thread_ipc_param *param)
{
return 0;
}
Expand Down
18 changes: 14 additions & 4 deletions src/ipc/ipc4/handler-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,10 +1091,11 @@ __cold static int ipc4_get_vendor_config_module_instance(struct comp_dev *dev,
return IPC4_SUCCESS;
}

__cold int ipc4_process_large_config_get(struct ipc4_message_request *ipc4,
uint32_t *reply_ext,
uint32_t *reply_tx_size,
void **reply_tx_data)
#ifdef CONFIG_SOF_USERSPACE_LL
__cold static int ipc4_process_large_config_get(struct ipc4_message_request *ipc4,
uint32_t *reply_ext,
uint32_t *reply_tx_size,
void **reply_tx_data)
{
struct ipc4_module_large_config_reply reply;
const struct ipc4_module_large_config *config =
Expand Down Expand Up @@ -1189,6 +1190,7 @@ __cold int ipc4_process_large_config_get(struct ipc4_message_request *ipc4,
*reply_tx_data = data;
return ret;
}
#endif

__cold static int ipc4_get_large_config_module_instance(struct ipc4_message_request *ipc4)
{
Expand Down Expand Up @@ -1683,6 +1685,13 @@ __cold int ipc4_user_process_module_message(struct ipc4_message_request *ipc4,
break;
case SOF_IPC4_MOD_BIND:
#ifdef CONFIG_SOF_USERSPACE_LL
/*
* bind and unbind can connect LL with DP. In that case it isn't
* immediately clear whether the handler should run in the DP
* thread context or in the LL IPC thread context. The LL IPC
* thread has access to DP modules, so we have to perform
* binding in the LL IPC thread context
*/
ret = ipc_user_forward_cmd(ipc4->primary.dat, ipc4->extension.dat,
ipc4_user_target_core_module(ipc4));
#else
Expand All @@ -1691,6 +1700,7 @@ __cold int ipc4_user_process_module_message(struct ipc4_message_request *ipc4,
break;
case SOF_IPC4_MOD_UNBIND:
#ifdef CONFIG_SOF_USERSPACE_LL
/* DP / LL: see comment above */
ret = ipc_user_forward_cmd(ipc4->primary.dat, ipc4->extension.dat,
ipc4_user_target_core_module(ipc4));
#else
Expand Down
1 change: 1 addition & 0 deletions src/schedule/zephyr_dp_schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct task_dp_pdata {
struct processing_module *mod; /* the module to be scheduled */
uint32_t ll_cycles_to_start; /* current number of LL cycles till delayed start */
#if CONFIG_SOF_USERSPACE_APPLICATION
uint8_t *ipc_config_data;
struct ipc4_flat *flat;
struct k_mem_partition mpart[SOF_DP_PART_TYPE_COUNT];
#endif
Expand Down
Loading
Loading