Skip to content

Commit 575f556

Browse files
ranj063macchian
authored andcommitted
module_adapter: Add set/get_large_config ops
Define the set_large_config and get_large_config ops for the module adapter component. These are mandatory ops needed to make the module adapter compatible with IPC4. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent ffe7c12 commit 575f556

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

src/audio/module_adapter/module_adapter.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,3 +733,87 @@ void module_adapter_free(struct comp_dev *dev)
733733
rfree(mod);
734734
rfree(dev);
735735
}
736+
737+
#if CONFIG_IPC_MAJOR_4
738+
int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
739+
bool last_block, uint32_t data_offset_size, char *data)
740+
{
741+
struct processing_module *mod = comp_get_drvdata(dev);
742+
struct module_data *md = &mod->priv;
743+
enum module_cfg_fragment_position pos;
744+
size_t fragment_size;
745+
746+
/* set fragment position */
747+
if (first_block) {
748+
if (last_block)
749+
pos = MODULE_CFG_FRAGMENT_SINGLE;
750+
else
751+
pos = MODULE_CFG_FRAGMENT_FIRST;
752+
} else {
753+
if (!last_block)
754+
pos = MODULE_CFG_FRAGMENT_MIDDLE;
755+
else
756+
pos = MODULE_CFG_FRAGMENT_LAST;
757+
}
758+
759+
switch (pos) {
760+
case MODULE_CFG_FRAGMENT_SINGLE:
761+
fragment_size = data_offset_size;
762+
break;
763+
case MODULE_CFG_FRAGMENT_MIDDLE:
764+
case MODULE_CFG_FRAGMENT_FIRST:
765+
fragment_size = SOF_IPC_MSG_MAX_SIZE;
766+
break;
767+
case MODULE_CFG_FRAGMENT_LAST:
768+
fragment_size = md->new_cfg_size - data_offset_size;
769+
break;
770+
default:
771+
comp_err(dev, "module_set_large_config(): invalid fragment position");
772+
return -EINVAL;
773+
}
774+
775+
if (md->ops->set_configuration)
776+
return md->ops->set_configuration(mod, param_id, pos, data_offset_size,
777+
(const uint8_t *)data,
778+
fragment_size, NULL, 0);
779+
return 0;
780+
}
781+
782+
int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
783+
bool last_block, uint32_t *data_offset_size, char *data)
784+
{
785+
struct processing_module *mod = comp_get_drvdata(dev);
786+
struct module_data *md = &mod->priv;
787+
size_t fragment_size;
788+
789+
/* set fragment size */
790+
if (first_block) {
791+
if (last_block)
792+
fragment_size = md->cfg.size;
793+
else
794+
fragment_size = SOF_IPC_MSG_MAX_SIZE;
795+
} else {
796+
if (!last_block)
797+
fragment_size = SOF_IPC_MSG_MAX_SIZE;
798+
else
799+
fragment_size = md->cfg.size - *data_offset_size;
800+
}
801+
802+
if (md->ops->get_configuration)
803+
return md->ops->get_configuration(mod, param_id, data_offset_size,
804+
(uint8_t *)data, fragment_size);
805+
return 0;
806+
}
807+
#else
808+
int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
809+
bool last_block, uint32_t data_offset, char *data)
810+
{
811+
return 0;
812+
}
813+
814+
int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
815+
bool last_block, uint32_t *data_offset, char *data)
816+
{
817+
return 0;
818+
}
819+
#endif

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ static const struct comp_driver comp_module_adapter = { \
4949
.trigger = module_adapter_trigger, \
5050
.reset = module_adapter_reset, \
5151
.free = module_adapter_free, \
52+
.set_large_config = module_set_large_config,\
53+
.get_large_config = module_get_large_config,\
5254
}, \
5355
}; \
5456
\
@@ -323,5 +325,9 @@ int module_adapter_cmd(struct comp_dev *dev, int cmd, void *data, int max_data_s
323325
int module_adapter_trigger(struct comp_dev *dev, int cmd);
324326
void module_adapter_free(struct comp_dev *dev);
325327
int module_adapter_reset(struct comp_dev *dev);
328+
int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
329+
bool last_block, uint32_t data_offset, char *data);
330+
int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
331+
bool last_block, uint32_t *data_offset, char *data);
326332

327333
#endif /* __SOF_AUDIO_MODULE_GENERIC__ */

0 commit comments

Comments
 (0)