Skip to content

Commit fb1d34b

Browse files
softwareckikv2019i
authored andcommitted
ipc4: module: interface: module_adapter: Add support for Config Get/Set ipc
Add support for Config Get and Config Set ipc commands. Handle them through the get_attribute and set_attribute methods of the component with the COMP_ATTR_IPC4_CONFIG parameter. Add the set_config_param and get_config_param functions to the module interface. Extend the functionality of module adapter to call the above functions to handle ipc request. Increase the version of module api due to modification of module_interface structure. Using Module Config Get / Set command, host driver may send a parameter that fits into the header (a very short one), packed along with parameter id. Larger parameters require fragmentation and a series of Large Config Set commands. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent cca4d87 commit fb1d34b

7 files changed

Lines changed: 125 additions & 3 deletions

File tree

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,17 @@ EXPORT_SYMBOL(module_get_large_config);
171171
int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
172172
{
173173
struct processing_module *mod = comp_mod(dev);
174+
const struct module_interface *const interface = mod->dev->drv->adapter_ops;
174175

175176
switch (type) {
176177
case COMP_ATTR_BASE_CONFIG:
177178
memcpy_s(value, sizeof(struct ipc4_base_module_cfg),
178179
&mod->priv.cfg.base_cfg, sizeof(mod->priv.cfg.base_cfg));
179180
break;
181+
case COMP_ATTR_IPC4_CONFIG:
182+
if (interface->get_config_param)
183+
return interface->get_config_param(mod, (uint32_t *)value);
184+
return -ENOEXEC;
180185
default:
181186
return -EINVAL;
182187
}
@@ -185,6 +190,24 @@ int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *valu
185190
}
186191
EXPORT_SYMBOL(module_adapter_get_attribute);
187192

193+
int module_adapter_set_attribute(struct comp_dev *dev, uint32_t type, void *value)
194+
{
195+
struct processing_module *mod = comp_mod(dev);
196+
const struct module_interface *const interface = mod->dev->drv->adapter_ops;
197+
198+
switch (type) {
199+
case COMP_ATTR_IPC4_CONFIG:
200+
if (interface->set_config_param)
201+
return interface->set_config_param(mod, *(uint32_t *)value);
202+
return -ENOEXEC;
203+
default:
204+
return -EINVAL;
205+
}
206+
207+
return 0;
208+
}
209+
EXPORT_SYMBOL(module_adapter_set_attribute);
210+
188211
static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev)
189212
{
190213
struct processing_module *mod = comp_mod(dev);

src/include/module/module/api_ver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#define SOF_MODULE_API_MAJOR_VERSION 5
2323
#define SOF_MODULE_API_MIDDLE_VERSION 0
24-
#define SOF_MODULE_API_MINOR_VERSION 0
24+
#define SOF_MODULE_API_MINOR_VERSION 1
2525

2626
#define SOF_MODULE_API_CURRENT_VERSION MODULE_API_VERSION_ENCODE(SOF_MODULE_API_MAJOR_VERSION, \
2727
SOF_MODULE_API_MIDDLE_VERSION, SOF_MODULE_API_MINOR_VERSION)

src/include/module/module/interface.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ struct processing_module;
6666
struct sof_source;
6767
struct sof_sink;
6868

69+
/*
70+
* This structure may be used by modules to carry short 16bit parameters.
71+
*/
72+
union config_param_id_data {
73+
uint32_t dw;
74+
struct {
75+
uint32_t data16 : 16; /* Input/Output small config data */
76+
uint32_t id : 14; /* input parameter ID */
77+
uint32_t _rsvd : 2;
78+
} f;
79+
};
80+
6981
/**
7082
* \struct module_interface
7183
* \brief 3rd party processing module interface
@@ -170,6 +182,30 @@ struct module_interface {
170182
struct output_stream_buffer *output_buffers,
171183
int num_output_buffers);
172184

185+
/**
186+
* (optional) Set module configuration parameter
187+
*
188+
* Using Module Config Set command, host driver may send a parameter
189+
* that fits into the header (a very short one), packed along with parameter id.
190+
*
191+
* param_id_data specifies both ID of the parameter, defined by the module
192+
* and value of the parameter.
193+
* It is up to the module how to distribute bits to ID and value of the parameter.
194+
*/
195+
int (*set_config_param)(struct processing_module *mod, uint32_t param_id_data);
196+
197+
/**
198+
* (optional) Get module configuration parameter
199+
*
200+
* Using Module Config Get command, host driver may send a parameter
201+
* that fits into the header (a very short one), packed along with parameter id.
202+
*
203+
* param_id_data specifies both ID of the parameter, defined by the module
204+
* and value of the parameter.
205+
* It is up to the module how to distribute bits to ID and value of the parameter.
206+
*/
207+
int (*get_config_param)(struct processing_module *mod, uint32_t *param_id_data);
208+
173209
/**
174210
* (optional) Set module configuration for the given configuration ID
175211
*

src/include/sof/audio/component.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ enum {
119119
#define COMP_ATTR_COPY_DIR 2 /**< Comp copy direction */
120120
#define COMP_ATTR_VDMA_INDEX 3 /**< Comp index of the virtual DMA at the gateway. */
121121
#define COMP_ATTR_BASE_CONFIG 4 /**< Component base config */
122+
#define COMP_ATTR_IPC4_CONFIG 5 /**< Component ipc4 set/get config */
122123
/** @}*/
123124

124125
/** \name Trace macros

src/include/sof/audio/module_adapter/module/generic.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static const struct comp_driver comp_##adapter##_module = { \
6161
.set_large_config = module_set_large_config,\
6262
.get_large_config = module_get_large_config,\
6363
.get_attribute = module_adapter_get_attribute,\
64+
.set_attribute = module_adapter_set_attribute,\
6465
.bind = module_adapter_bind,\
6566
.unbind = module_adapter_unbind,\
6667
.get_total_data_processed = module_adapter_get_total_data_processed,\
@@ -224,6 +225,12 @@ int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *valu
224225
return -EINVAL;
225226
}
226227

228+
static inline
229+
int module_adapter_set_attribute(struct comp_dev *dev, uint32_t type, void *value)
230+
{
231+
return -EINVAL;
232+
}
233+
227234
static inline
228235
int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
229236
bool last_block, uint32_t data_offset, const char *data)
@@ -273,6 +280,7 @@ int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_
273280
int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
274281
bool last_block, uint32_t *data_offset, char *data);
275282
int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *value);
283+
int module_adapter_set_attribute(struct comp_dev *dev, uint32_t type, void *value);
276284
int module_adapter_bind(struct comp_dev *dev, void *data);
277285
int module_adapter_unbind(struct comp_dev *dev, void *data);
278286
uint64_t module_adapter_get_total_data_processed(struct comp_dev *dev,

src/ipc/ipc4/handler.c

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,58 @@ __cold static int ipc4_unbind_module_instance(struct ipc4_message_request *ipc4)
968968
return ipc_comp_disconnect(ipc, (ipc_pipe_comp_connect *)&bu);
969969
}
970970

971+
static int ipc4_set_get_config_module_instance(struct ipc4_message_request *ipc4, bool set)
972+
{
973+
struct ipc4_module_config *config = (struct ipc4_module_config *)ipc4;
974+
int (*function)(struct comp_dev *dev, uint32_t type, void *value);
975+
const struct comp_driver *drv;
976+
struct comp_dev *dev = NULL;
977+
int ret;
978+
979+
tr_dbg(&ipc_tr, "ipc4_set_get_config_module_instance %x : %x, set %d",
980+
(uint32_t)config->primary.r.module_id, (uint32_t)config->primary.r.instance_id,
981+
!!set);
982+
983+
/* get component dev for non-basefw since there is no component dev for basefw */
984+
if (config->primary.r.module_id) {
985+
uint32_t comp_id;
986+
987+
comp_id = IPC4_COMP_ID(config->primary.r.module_id, config->primary.r.instance_id);
988+
dev = ipc4_get_comp_dev(comp_id);
989+
if (!dev)
990+
return IPC4_MOD_INVALID_ID;
991+
992+
drv = dev->drv;
993+
994+
/* Pass IPC to target core */
995+
if (!cpu_is_me(dev->ipc_config.core))
996+
return ipc4_process_on_core(dev->ipc_config.core, false);
997+
} else {
998+
drv = ipc4_get_comp_drv(config->primary.r.module_id);
999+
}
1000+
1001+
if (!drv)
1002+
return IPC4_MOD_INVALID_ID;
1003+
1004+
function = set ? drv->ops.set_attribute : drv->ops.get_attribute;
1005+
if (!function)
1006+
return IPC4_INVALID_REQUEST;
1007+
1008+
ret = function(dev, COMP_ATTR_IPC4_CONFIG, &config->extension.dat);
1009+
if (ret < 0) {
1010+
ipc_cmd_err(&ipc_tr, "ipc4_set_get_config_module_instance %x : %x failed %d, set %u, param %x",
1011+
(uint32_t)config->primary.r.module_id,
1012+
(uint32_t)config->primary.r.instance_id, ret, !!set,
1013+
(uint32_t)config->extension.dat);
1014+
ret = IPC4_INVALID_CONFIG_PARAM_ID;
1015+
}
1016+
1017+
if (!set)
1018+
msg_reply.extension = config->extension.dat;
1019+
1020+
return ret;
1021+
}
1022+
9711023
__cold static int ipc4_get_vendor_config_module_instance(struct comp_dev *dev,
9721024
const struct comp_driver *drv,
9731025
bool init_block,
@@ -1463,9 +1515,10 @@ __cold static int ipc4_process_module_message(struct ipc4_message_request *ipc4)
14631515
ret = ipc4_init_module_instance(ipc4);
14641516
break;
14651517
case SOF_IPC4_MOD_CONFIG_GET:
1518+
ret = ipc4_set_get_config_module_instance(ipc4, false);
1519+
break;
14661520
case SOF_IPC4_MOD_CONFIG_SET:
1467-
ret = IPC4_UNAVAILABLE;
1468-
tr_info(&ipc_tr, "unsupported module CONFIG_GET");
1521+
ret = ipc4_set_get_config_module_instance(ipc4, true);
14691522
break;
14701523
case SOF_IPC4_MOD_LARGE_CONFIG_GET:
14711524
ret = ipc4_get_large_config_module_instance(ipc4);

src/library_manager/lib_manager.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ static void lib_manager_prepare_module_adapter(struct comp_driver *drv, const st
572572
drv->ops.set_large_config = module_set_large_config;
573573
drv->ops.get_large_config = module_get_large_config;
574574
drv->ops.get_attribute = module_adapter_get_attribute;
575+
drv->ops.set_attribute = module_adapter_set_attribute;
575576
drv->ops.bind = module_adapter_bind;
576577
drv->ops.unbind = module_adapter_unbind;
577578
drv->ops.get_total_data_processed = module_adapter_get_total_data_processed;

0 commit comments

Comments
 (0)