Skip to content

Commit db32a33

Browse files
softwareckikv2019i
authored andcommitted
module_adapter: Separate module_adapter_new_ext function
Create a function module_adapter_new_ext that allows to assign a pointer to the private data of the module for which the adapter is being created. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent a500755 commit db32a33

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/audio/module_adapter/module_adapter.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,31 @@ LOG_MODULE_REGISTER(module_adapter, CONFIG_SOF_LOG_LEVEL);
3434
* \param[in] drv - component driver pointer.
3535
* \param[in] config - component ipc descriptor pointer.
3636
* \param[in] spec - passdowned data from driver.
37+
* \param[in] mod_priv - Pointer to private data for processing module.
3738
*
3839
* \return: a pointer to newly created module adapter component on success. NULL on error.
3940
*/
4041
struct comp_dev *module_adapter_new(const struct comp_driver *drv,
41-
const struct comp_ipc_config *config,
42-
const void *spec)
42+
const struct comp_ipc_config *config, const void *spec)
43+
{
44+
return module_adapter_new_ext(drv, config, spec, NULL);
45+
}
46+
47+
/*
48+
* \brief Create a module adapter component.
49+
* \param[in] drv - component driver pointer.
50+
* \param[in] config - component ipc descriptor pointer.
51+
* \param[in] spec - passdowned data from driver.
52+
* \param[in] mod_priv - Pointer to private data for processing module.
53+
*
54+
* \return: a pointer to newly created module adapter component on success. NULL on error.
55+
*
56+
* Note: Use the ext version if you need to set the module's private data before calling
57+
* the create method.
58+
*/
59+
struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv,
60+
const struct comp_ipc_config *config, const void *spec,
61+
void *mod_priv)
4362
{
4463
int ret;
4564
struct comp_dev *dev;
@@ -79,6 +98,7 @@ struct comp_dev *module_adapter_new(const struct comp_driver *drv,
7998

8099
dst = &mod->priv.cfg;
81100

101+
module_set_private_data(mod, mod_priv);
82102
mod->dev = dev;
83103
dev->mod = mod;
84104

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ int module_unbind(struct processing_module *mod, struct bind_info *unbind_data);
209209

210210
struct comp_dev *module_adapter_new(const struct comp_driver *drv,
211211
const struct comp_ipc_config *config, const void *spec);
212+
struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv,
213+
const struct comp_ipc_config *config, const void *spec,
214+
void *mod_priv);
212215
int module_adapter_prepare(struct comp_dev *dev);
213216
int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *params);
214217
int module_adapter_copy(struct comp_dev *dev);

0 commit comments

Comments
 (0)