Skip to content

Convert copier to use the module interface - #7890

Merged
lgirdwood merged 12 commits into
thesofproject:mainfrom
ranj063:pr7740_2
Jul 13, 2023
Merged

lgirdwood merged 12 commits into
thesofproject:mainfrom
ranj063:pr7740_2

Conversation

@ranj063

@ranj063 ranj063 commented Jul 4, 2023

Copy link
Copy Markdown
Collaborator

Includes patches from #7740

Comment thread src/audio/module_adapter/module_adapter.c Outdated
@ranj063
ranj063 force-pushed the pr7740_2 branch 2 times, most recently from 0e3f502 to 35fbe85 Compare July 5, 2023 01:44
Comment thread src/include/sof/audio/module_adapter/module/module_interface.h Outdated

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just minor comments.

Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/module_adapter/module_adapter.c Outdated
@ranj063
ranj063 force-pushed the pr7740_2 branch 4 times, most recently from 69de002 to 187b02d Compare July 6, 2023 00:19

@RanderWang RanderWang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ranj063
ranj063 force-pushed the pr7740_2 branch 7 times, most recently from 54f27cd to ab2291e Compare July 7, 2023 19:53
ranj063 added 2 commits July 7, 2023 12:53
Add the bind/unbind ops that can be optionally implemented by modules to
perform module-specific actions when other modules are bound/unbound
from them.

These are particularly useful for modules such as the mixers, smart_amp,
copier that can have multiple input/output pins.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Introduce a new struct module_endpoint_ops which contains all the ops
that are relevant for endpoint devices (host copier and DAI copier) and
add a new field for setting the endpoint_ops.

These will be needed when the copier component is converted to use the
module adapter interface.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
@ranj063
ranj063 marked this pull request as ready for review July 9, 2023 18:52
@ranj063

ranj063 commented Jul 9, 2023

Copy link
Copy Markdown
Collaborator Author

SOFCI TEST

Comment thread src/audio/module_adapter/module/generic.c Outdated
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier_host.c Outdated
Comment thread src/audio/module_adapter/module_adapter.c
Comment thread src/audio/module_adapter/module_adapter.c
Comment thread src/audio/module_adapter/module/volume/volume.c Outdated
Comment thread src/audio/module_adapter/module/generic.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I understand correctly, this call to buffer_set_params() is now practically dropped, was it not needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it isnt dropped, it is handled by ipc4_update_buffer_format() now

ranj063 added 10 commits July 10, 2023 16:51
Add the dai endpoint ops to the module adapter in preparation for
converting the copier module to use the module interface.
Also, modify the module_adapter ops to handle the HOST/DAI components
are a special case.

In the case of module_adapter_prepare(), there's no need to compute the
period_bytes for the HOST/DAI because these are computed by the copier
module prepare op. In the case of copy, HOST/DAI components are handled
separately as well as these components deal with the DMA buffers.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
The state check is redundant as the state will always be >=
MODULE_INITIALIZED if the module exists.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
For IPC4, the component device state machine is handled by the
comp_set_state() calls in the module adapter ops already. So, the module
state checks are redundant. But, keep the state checks for IPC3 so as to
not break the existing codec implementations for IPC3.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Define the module interface ops and the endpoint ops for the copier
module to convert it to use the module interface.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
It will be needed by other modules.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Update the pipeline params based on the base config.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
It will be needed by other modules as well.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Fix the function name in the comment.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
The input stream params may not be updated by the source module. So
update the stream params from the config. Also, update the source/sink
ibuffer formats based on the base config audio format.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Use the helper functions to update the stream params and the source/sink
buffer formats.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
buffer_release(sink_c);

return ret;
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous code only have sink buffer update, does not have source buffer update, just want to avoid some parameter missing caused issues? do we need add source update to each module?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the volume component, the source buffer and sink buffer formats are exactly the same. So yes we should update both buffers. And should we do it for each module individually? Probably not, something we should work on unifying for all modules in IPC4 in a follow up PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, any audio processing module, like iir, fir they also need assume source and sink buffer have same format, right?

@lyakh lyakh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments / questions only

Comment thread src/audio/copier/copier.c
if (ret < 0)
return ret;

comp_info(dev, "copier_prepare()");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep it comp_dbg()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to info on purpose @lyakh mainly because prepare is a one time thing and it is useful to see which components are done getting pepared during trigger


#if CONFIG_IPC_MAJOR_4
ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params);
ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, mod->stream_params);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my understanding: why is this needed? Is this fixing a bug?

@ranj063 ranj063 Jul 12, 2023 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now that the copier is not using the comp_driver, its params wont get called until prepare. So the params will not propagated if we wont do this and components that do not use the module adapter yet will fail

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that mean that that before this commit copier.c is broken, which breaks bisection? Should this commit be merged with 6bcaf89 which comes before it?

Comment thread src/audio/asrc/asrc.c
/* update the source/sink buffer formats. Sink rate will be modified below */
ipc4_update_buffer_format(source_c, &cd->ipc_config.base.audio_fmt);
ipc4_update_buffer_format(sink_c, &cd->ipc_config.base.audio_fmt);
#endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here - what's the effect of these changes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same explanation, copier doesnt set the source/sink buffer until prepare. So asrc_params( will fail without it

@lgirdwood

Copy link
Copy Markdown
Member

SOFCI TEST

@lgirdwood

Copy link
Copy Markdown
Member

@ranj063 pls merge after CAVS CI finishes, I've restarted it as it was pending for 1 day.

@ranj063

ranj063 commented Jul 12, 2023

Copy link
Copy Markdown
Collaborator Author

@ranj063 pls merge after CAVS CI finishes, I've restarted it as it was pending for 1 day.

@lgirdwood even though it shows as pending, if you click on the link, you can see the results. I have notified @fredoh9 @marc-hb about the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants