Skip to content

Commit fc6d5ed

Browse files
committed
component: module_adapter: Move module_interface pointer to comp_driver
Moved pointer to module_interface from struct module_data to comp_driver structure. The change is aimed at clearing the module_data structure of fields intended for exclusive use by sof. All modules are eventually use module interface so this pointer will be in comp_driver anyway. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent 83f69f1 commit fc6d5ed

File tree

10 files changed

+150
-128
lines changed

10 files changed

+150
-128
lines changed

src/audio/asrc/asrc_ipc4.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ int asrc_dai_configure_timestamp(struct comp_data *cd)
2828
return -ENODEV;
2929

3030
struct processing_module *mod = comp_get_drvdata(cd->dai_dev);
31-
struct module_data *md = &mod->priv;
31+
const struct comp_driver *const drv = mod->dev->drv;
3232

33-
return md->ops->endpoint_ops->dai_ts_config(cd->dai_dev);
33+
return drv->adapter_ops->endpoint_ops->dai_ts_config(cd->dai_dev);
3434
}
3535

3636
int asrc_dai_start_timestamp(struct comp_data *cd)
@@ -39,9 +39,9 @@ int asrc_dai_start_timestamp(struct comp_data *cd)
3939
return -ENODEV;
4040

4141
struct processing_module *mod = comp_get_drvdata(cd->dai_dev);
42-
struct module_data *md = &mod->priv;
42+
const struct comp_driver *const drv = mod->dev->drv;
4343

44-
return md->ops->endpoint_ops->dai_ts_start(cd->dai_dev);
44+
return drv->adapter_ops->endpoint_ops->dai_ts_start(cd->dai_dev);
4545
}
4646

4747
int asrc_dai_stop_timestamp(struct comp_data *cd)
@@ -50,9 +50,9 @@ int asrc_dai_stop_timestamp(struct comp_data *cd)
5050
return -ENODEV;
5151

5252
struct processing_module *mod = comp_get_drvdata(cd->dai_dev);
53-
struct module_data *md = &mod->priv;
53+
const struct comp_driver *const drv = mod->dev->drv;
5454

55-
return md->ops->endpoint_ops->dai_ts_stop(cd->dai_dev);
55+
return drv->adapter_ops->endpoint_ops->dai_ts_stop(cd->dai_dev);
5656
}
5757

5858
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
@@ -65,9 +65,9 @@ int asrc_dai_get_timestamp(struct comp_data *cd, struct timestamp_data *tsd)
6565
return -ENODEV;
6666

6767
struct processing_module *mod = comp_get_drvdata(cd->dai_dev);
68-
struct module_data *md = &mod->priv;
68+
const struct comp_driver *const drv = mod->dev->drv;
6969

70-
return md->ops->endpoint_ops->dai_ts_get(cd->dai_dev, tsd);
70+
return drv->adapter_ops->endpoint_ops->dai_ts_get(cd->dai_dev, tsd);
7171
}
7272

7373
void asrc_update_buffer_format(struct comp_buffer *buf_c, struct comp_data *cd)

src/audio/module_adapter/module/generic.c

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ int module_load_config(struct comp_dev *dev, const void *cfg, size_t size)
7575
return ret;
7676
}
7777

78-
int module_init(struct processing_module *mod, const struct module_interface *interface)
78+
int module_init(struct processing_module *mod)
7979
{
8080
int ret;
8181
struct module_data *md = &mod->priv;
8282
struct comp_dev *dev = mod->dev;
83+
const struct module_interface *const interface = dev->drv->adapter_ops;
8384

8485
comp_dbg(dev, "module_init() start");
8586

@@ -90,7 +91,7 @@ int module_init(struct processing_module *mod, const struct module_interface *in
9091
return -EPERM;
9192
#endif
9293
if (!interface) {
93-
comp_err(dev, "module_init(): could not find module interface for comp id %d",
94+
comp_err(dev, "module_init(): module interface not defined for comp id %d",
9495
dev_comp_id(dev));
9596
return -EIO;
9697
}
@@ -104,13 +105,11 @@ int module_init(struct processing_module *mod, const struct module_interface *in
104105
return -EIO;
105106
}
106107

107-
/* Assign interface */
108-
md->ops = interface;
109108
/* Init memory list */
110109
list_init(&md->memory.mem_list);
111110

112111
/* Now we can proceed with module specific initialization */
113-
ret = md->ops->init(mod);
112+
ret = interface->init(mod);
114113
if (ret) {
115114
comp_err(dev, "module_init() error %d: module specific init failed, comp id %d",
116115
ret, dev_comp_id(dev));
@@ -201,6 +200,7 @@ int module_prepare(struct processing_module *mod,
201200
int ret = 0;
202201
struct module_data *md = &mod->priv;
203202
struct comp_dev *dev = mod->dev;
203+
const struct comp_driver *const drv = dev->drv;
204204

205205
comp_dbg(dev, "module_prepare() start");
206206

@@ -210,8 +210,8 @@ int module_prepare(struct processing_module *mod,
210210
if (mod->priv.state < MODULE_INITIALIZED)
211211
return -EPERM;
212212
#endif
213-
if (md->ops->prepare) {
214-
ret = md->ops->prepare(mod, sources, num_of_sources, sinks, num_of_sinks);
213+
if (drv->adapter_ops->prepare) {
214+
ret = drv->adapter_ops->prepare(mod, sources, num_of_sources, sinks, num_of_sinks);
215215
if (ret) {
216216
comp_err(dev, "module_prepare() error %d: module specific prepare failed, comp_id %d",
217217
ret, dev_comp_id(dev));
@@ -242,13 +242,14 @@ int module_process_legacy(struct processing_module *mod,
242242
int num_output_buffers)
243243
{
244244
struct comp_dev *dev = mod->dev;
245+
const struct comp_driver *const drv = dev->drv;
245246
int ret;
246247

247-
struct module_data *md = &mod->priv;
248-
249248
comp_dbg(dev, "module_process_legacy() start");
250249

251250
#if CONFIG_IPC_MAJOR_3
251+
struct module_data *md = &mod->priv;
252+
252253
if (md->state != MODULE_IDLE) {
253254
comp_err(dev, "module_process(): wrong state of comp_id %x, state %d",
254255
dev_comp_id(dev), md->state);
@@ -259,11 +260,11 @@ int module_process_legacy(struct processing_module *mod,
259260
md->state = MODULE_PROCESSING;
260261
#endif
261262
if (IS_PROCESSING_MODE_AUDIO_STREAM(mod))
262-
ret = md->ops->process_audio_stream(mod, input_buffers, num_input_buffers,
263-
output_buffers, num_output_buffers);
263+
ret = drv->adapter_ops->process_audio_stream(mod, input_buffers, num_input_buffers,
264+
output_buffers, num_output_buffers);
264265
else if (IS_PROCESSING_MODE_RAW_DATA(mod))
265-
ret = md->ops->process_raw_data(mod, input_buffers, num_input_buffers,
266-
output_buffers, num_output_buffers);
266+
ret = drv->adapter_ops->process_raw_data(mod, input_buffers, num_input_buffers,
267+
output_buffers, num_output_buffers);
267268
else
268269
ret = -EOPNOTSUPP;
269270

@@ -288,13 +289,13 @@ int module_process_sink_src(struct processing_module *mod,
288289

289290
{
290291
struct comp_dev *dev = mod->dev;
292+
const struct comp_driver *const drv = dev->drv;
291293
int ret;
292294

293-
struct module_data *md = &mod->priv;
294-
295295
comp_dbg(dev, "module_process sink src() start");
296296

297297
#if CONFIG_IPC_MAJOR_3
298+
struct module_data *md = &mod->priv;
298299
if (md->state != MODULE_IDLE) {
299300
comp_err(dev, "module_process(): wrong state of comp_id %x, state %d",
300301
dev_comp_id(dev), md->state);
@@ -304,8 +305,8 @@ int module_process_sink_src(struct processing_module *mod,
304305
/* set state to processing */
305306
md->state = MODULE_PROCESSING;
306307
#endif
307-
assert(md->ops->process);
308-
ret = md->ops->process(mod, sources, num_of_sources, sinks, num_of_sinks);
308+
assert(drv->adapter_ops->process);
309+
ret = drv->adapter_ops->process(mod, sources, num_of_sources, sinks, num_of_sinks);
309310

310311
if (ret && ret != -ENOSPC && ret != -ENODATA) {
311312
comp_err(dev, "module_process() error %d: for comp %d",
@@ -325,15 +326,16 @@ int module_process_sink_src(struct processing_module *mod,
325326
int module_reset(struct processing_module *mod)
326327
{
327328
int ret;
329+
const struct comp_driver *const drv = mod->dev->drv;
328330
struct module_data *md = &mod->priv;
329331

330332
#if CONFIG_IPC_MAJOR_3
331333
/* if the module was never prepared, no need to reset */
332334
if (md->state < MODULE_IDLE)
333335
return 0;
334336
#endif
335-
if (md->ops->reset) {
336-
ret = md->ops->reset(mod);
337+
if (drv->adapter_ops) {
338+
ret = drv->adapter_ops->reset(mod);
337339
if (ret) {
338340
if (ret != PPL_STATUS_PATH_STOP)
339341
comp_err(mod->dev,
@@ -375,11 +377,12 @@ void module_free_all_memory(struct processing_module *mod)
375377

376378
int module_free(struct processing_module *mod)
377379
{
378-
int ret = 0;
380+
const struct comp_driver *const drv = mod->dev->drv;
379381
struct module_data *md = &mod->priv;
382+
int ret = 0;
380383

381-
if (md->ops->free) {
382-
ret = md->ops->free(mod);
384+
if (drv->adapter_ops->free) {
385+
ret = drv->adapter_ops->free(mod);
383386
if (ret)
384387
comp_warn(mod->dev, "module_free(): error: %d for %d",
385388
ret, dev_comp_id(mod->dev));
@@ -508,19 +511,19 @@ int module_set_configuration(struct processing_module *mod,
508511

509512
int module_bind(struct processing_module *mod, void *data)
510513
{
511-
struct module_data *md = &mod->priv;
514+
const struct comp_driver *const drv = mod->dev->drv;
512515

513-
if (md->ops->bind)
514-
return md->ops->bind(mod, data);
516+
if (drv->adapter_ops->bind)
517+
return drv->adapter_ops->bind(mod, data);
515518
return 0;
516519
}
517520

518521
int module_unbind(struct processing_module *mod, void *data)
519522
{
520-
struct module_data *md = &mod->priv;
523+
const struct comp_driver *const drv = mod->dev->drv;
521524

522-
if (md->ops->unbind)
523-
return md->ops->unbind(mod, data);
525+
if (drv->adapter_ops->unbind)
526+
return drv->adapter_ops->unbind(mod, data);
524527
return 0;
525528
}
526529

0 commit comments

Comments
 (0)