Skip to content

Commit d9f0c6b

Browse files
committed
module: Move system_agent_start parameters into system_agent_params struct
Replace multiple arguments passed to system_agent_start and native_system_agent_start with a single pointer to system_agent_params. This improves readability and simplifies function signature. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent e2386cc commit d9f0c6b

5 files changed

Lines changed: 39 additions & 31 deletions

File tree

src/audio/module_adapter/iadk/system_agent.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <iadk_module_adapter.h>
2222
#include <system_agent.h>
2323
#include <sof/audio/module_adapter/library/native_system_service.h>
24+
#include <sof/audio/module_adapter/library/native_system_agent.h>
2425

2526
using namespace intel_adsp;
2627
using namespace intel_adsp::system;
@@ -124,16 +125,17 @@ int SystemAgent::CheckIn(ProcessingModuleFactoryInterface& module_factory,
124125
typedef int (*create_instance_f)(uint32_t module_id, uint32_t instance_id, uint32_t core_id,
125126
void *mod_cfg, void *parent_ppl, void **mod_ptr);
126127

127-
int system_agent_start(uintptr_t entry_point, uint32_t module_id, uint32_t instance_id,
128-
uint32_t core_id, uint32_t log_handle, void* mod_cfg,
128+
int system_agent_start(const struct system_agent_params *params,
129129
const void **adapter)
130130
{
131131
uint32_t ret;
132-
SystemAgent system_agent(module_id, instance_id, core_id, log_handle);
132+
SystemAgent system_agent(params->module_id, params->instance_id, params->core_id,
133+
params->log_handle);
133134
void* system_agent_p = reinterpret_cast<void*>(&system_agent);
134135

135-
create_instance_f ci = (create_instance_f)(entry_point);
136-
ret = ci(module_id, instance_id, core_id, mod_cfg, NULL, &system_agent_p);
136+
create_instance_f ci = (create_instance_f)(params->entry_point);
137+
ret = ci(params->module_id, params->instance_id, params->core_id, params->mod_cfg, NULL,
138+
&system_agent_p);
137139

138140
IadkModuleAdapter* module_adapter = reinterpret_cast<IadkModuleAdapter*>(system_agent_p);
139141
*adapter = module_adapter;

src/audio/module_adapter/library/native_system_agent.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@ typedef void* (*native_create_instance_f)(void *mod_cfg, void *parent_ppl,
1919

2020
struct native_system_agent native_sys_agent;
2121

22-
int native_system_agent_start(uintptr_t entry_point, uint32_t module_id, uint32_t instance_id,
23-
uint32_t core_id, uint32_t log_handle, void *mod_cfg,
22+
int native_system_agent_start(const struct system_agent_params *params,
2423
const void **iface)
2524
{
26-
native_sys_agent.module_id = module_id;
27-
native_sys_agent.instance_id = instance_id;
28-
native_sys_agent.core_id = core_id;
29-
native_sys_agent.log_handle = log_handle;
25+
native_sys_agent.module_id = params->module_id;
26+
native_sys_agent.instance_id = params->instance_id;
27+
native_sys_agent.core_id = params->core_id;
28+
native_sys_agent.log_handle = params->log_handle;
3029
const void *ret;
3130

3231
void *system_agent_p = &native_sys_agent;
3332

34-
native_create_instance_f ci = (native_create_instance_f)entry_point;
33+
native_create_instance_f ci = (native_create_instance_f)params->entry_point;
3534

36-
ret = ci(mod_cfg, NULL, &system_agent_p);
35+
ret = ci(params->mod_cfg, NULL, &system_agent_p);
3736
if (!ret)
3837
return -EINVAL;
3938

src/include/sof/audio/module_adapter/iadk/system_agent.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ extern "C" {
107107
* method (the variant with 7 parameters) via a parameter that initially contained the address to
108108
* the agent system. The system_agent_start function returns it in the variable adapter.
109109
*/
110-
int system_agent_start(uintptr_t entry_point, uint32_t module_id, uint32_t instance_id,
111-
uint32_t core_id, uint32_t log_handle, void *mod_cfg, const void **adapter);
110+
struct system_agent_params;
111+
112+
int system_agent_start(const struct system_agent_params *params, const void **adapter);
112113
#ifdef __cplusplus
113114
}
114115
#endif

src/include/sof/audio/module_adapter/library/native_system_agent.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@
1111
#include <sof/audio/module_adapter/module/module_interface.h>
1212
#include <native_system_service.h>
1313

14-
typedef int (*system_agent_start_fn)(uintptr_t entry_point, uint32_t module_id,
15-
uint32_t instance_id, uint32_t core_id, uint32_t log_handle,
16-
void *mod_cfg, const void **adapter);
14+
struct system_agent_params {
15+
uintptr_t entry_point; /* The module entry point function address. */
16+
uint32_t module_id; /* The identifier for the module. */
17+
uint32_t instance_id; /* The instance identifier of the module. */
18+
uint32_t core_id; /* Core on which the module will run. */
19+
uint32_t log_handle; /* The handle for logging purposes. */
20+
void *mod_cfg; /* Pointer to the module configuration data. */
21+
};
22+
23+
typedef int (*system_agent_start_fn)(const struct system_agent_params *params,
24+
const void **adapter);
1725

1826
struct native_system_agent {
1927
struct system_service system_service;
@@ -29,18 +37,12 @@ struct native_system_agent {
2937
*
3038
* This function initializes and starts the native system agent with the provided parameters.
3139
*
32-
* @param[in] entry_point - The module entry point function address.
33-
* @param[in] module_id - The identifier for the module.
34-
* @param[in] instance_id - The instance identifier of the module.
35-
* @param[in] core_id - Core on which the module will run.
36-
* @param[in] log_handle - The handle for logging purposes.
37-
* @param[in] mod_cfg - Pointer to the module configuration data.
40+
* @param[in] params - Pointer to the system agent parameter structure
3841
* @param[out] iface - Pointer to the module interface.
3942
*
4043
* @return Returns 0 on success or an error code on failure.
4144
*/
42-
int native_system_agent_start(uintptr_t entry_point, uint32_t module_id, uint32_t instance_id,
43-
uint32_t core_id, uint32_t log_handle, void *mod_cfg,
45+
int native_system_agent_start(const struct system_agent_params *params,
4446
const void **iface);
4547

4648
#endif /* __NATIVE_SYSTEM_AGENT_H__ */

src/library_manager/lib_manager.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,18 +501,22 @@ static int lib_manager_start_agent(const struct comp_driver *drv, const uint32_t
501501
const system_agent_start_fn agent,
502502
const void **agent_interface)
503503
{
504-
const uint32_t module_id = IPC4_MOD_ID(component_id);
505-
const uint32_t instance_id = IPC4_INST_ID(component_id);
506-
const uint32_t log_handle = (uint32_t)drv->tctx;
504+
struct system_agent_params agent_params;
507505
byte_array_t mod_cfg;
508506
int ret;
509507

510508
mod_cfg.data = (uint8_t *)args->data;
511509
/* Intel modules expects DW size here */
512510
mod_cfg.size = args->size >> 2;
513511

514-
ret = agent(module_entry_point, module_id, instance_id, 0, log_handle, &mod_cfg,
515-
agent_interface);
512+
agent_params.entry_point = module_entry_point;
513+
agent_params.module_id = IPC4_MOD_ID(component_id);
514+
agent_params.instance_id = IPC4_INST_ID(component_id);
515+
agent_params.core_id = 0;
516+
agent_params.log_handle = (uint32_t)drv->tctx;
517+
agent_params.mod_cfg = &mod_cfg;
518+
519+
ret = agent(&agent_params, agent_interface);
516520
if (ret)
517521
tr_err(&lib_manager_tr, "System agent start failed %d!", ret);
518522

0 commit comments

Comments
 (0)