mirror of https://github.com/thesofproject/sof.git
pipeline2.0: change module prepare API to use sink/src.c
Module prepare is an operation that needs to set up sink and source according to needs. Therefore it must have access to sink/source handlers This commit adds handlers to API. In case the module uses legacy audio stream sink/source pointers will be NULLs and number of sinks/sources will be zero Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
This commit is contained in:
parent
002d4a3f66
commit
fa77edf9a4
|
@ -564,7 +564,9 @@ static void eq_fir_set_alignment(struct audio_stream __sparse_cache *source,
|
|||
audio_stream_init_alignment_constants(byte_align, frame_align_req, sink);
|
||||
}
|
||||
|
||||
static int eq_fir_prepare(struct processing_module *mod)
|
||||
static int eq_fir_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct comp_data *cd = module_get_private_data(mod);
|
||||
struct comp_buffer *sourceb, *sinkb;
|
||||
|
|
|
@ -879,7 +879,9 @@ static void eq_iir_set_passthrough_func(struct comp_data *cd,
|
|||
#endif
|
||||
}
|
||||
|
||||
static int eq_iir_prepare(struct processing_module *mod)
|
||||
static int eq_iir_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct comp_data *cd = module_get_private_data(mod);
|
||||
struct comp_buffer *sourceb, *sinkb;
|
||||
|
|
|
@ -186,7 +186,9 @@ static void mfcc_set_alignment(struct audio_stream *source, struct audio_stream
|
|||
audio_stream_init_alignment_constants(byte_align, frame_align_req, sink);
|
||||
}
|
||||
|
||||
static int mfcc_prepare(struct processing_module *mod)
|
||||
static int mfcc_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct mfcc_comp_data *cd = module_get_private_data(mod);
|
||||
struct comp_buffer *sourceb;
|
||||
|
|
|
@ -217,7 +217,9 @@ static inline void mixer_set_frame_alignment(struct audio_stream __sparse_cache
|
|||
audio_stream_init_alignment_constants(byte_align, frame_align_req, source);
|
||||
}
|
||||
|
||||
static int mixer_prepare(struct processing_module *mod)
|
||||
static int mixer_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct mixer_data *md = module_get_private_data(mod);
|
||||
struct comp_buffer __sparse_cache *sink_c;
|
||||
|
|
|
@ -686,7 +686,9 @@ static int mixin_params(struct processing_module *mod)
|
|||
* We should also make sure that we propagate the prepare call to downstream
|
||||
* if downstream is not currently active.
|
||||
*/
|
||||
static int mixin_prepare(struct processing_module *mod)
|
||||
static int mixin_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct mixin_data *md = module_get_private_data(mod);
|
||||
struct comp_dev *dev = mod->dev;
|
||||
|
@ -805,7 +807,9 @@ static int mixout_params(struct processing_module *mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mixout_prepare(struct processing_module *mod)
|
||||
static int mixout_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct module_source_info __sparse_cache *mod_source_info;
|
||||
struct comp_dev *dev = mod->dev;
|
||||
|
|
|
@ -501,7 +501,9 @@ static int cadence_codec_init_process(struct processing_module *mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cadence_codec_prepare(struct processing_module *mod)
|
||||
static int cadence_codec_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
int ret = 0, mem_tabs_size;
|
||||
struct comp_dev *dev = mod->dev;
|
||||
|
|
|
@ -183,7 +183,9 @@ static int dts_codec_init(struct processing_module *mod)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int dts_codec_prepare(struct processing_module *mod)
|
||||
static int dts_codec_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
int ret;
|
||||
struct comp_dev *dev = mod->dev;
|
||||
|
|
|
@ -192,7 +192,9 @@ static int validate_config(struct module_config *cfg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int module_prepare(struct processing_module *mod)
|
||||
int module_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
int ret;
|
||||
struct module_data *md = &mod->priv;
|
||||
|
@ -205,7 +207,7 @@ int module_prepare(struct processing_module *mod)
|
|||
if (mod->priv.state < MODULE_INITIALIZED)
|
||||
return -EPERM;
|
||||
|
||||
ret = md->ops->prepare(mod);
|
||||
ret = md->ops->prepare(mod, sources, num_of_sources, sinks, num_of_sinks);
|
||||
if (ret) {
|
||||
comp_err(dev, "module_prepare() error %d: module specific prepare failed, comp_id %d",
|
||||
ret, dev_comp_id(dev));
|
||||
|
|
|
@ -117,7 +117,9 @@ static int iadk_modules_init(struct processing_module *mod)
|
|||
* configuration. Its internal structure is proprietary to the module implementation.
|
||||
* There is one assumption - all IADK modules utilize IPC4 protocol.
|
||||
*/
|
||||
static int iadk_modules_prepare(struct processing_module *mod)
|
||||
static int iadk_modules_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct comp_dev *dev = mod->dev;
|
||||
int ret = 0;
|
||||
|
|
|
@ -20,7 +20,9 @@ static int passthrough_codec_init(struct processing_module *mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int passthrough_codec_prepare(struct processing_module *mod)
|
||||
static int passthrough_codec_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct comp_dev *dev = mod->dev;
|
||||
struct module_data *codec = &mod->priv;
|
||||
|
|
|
@ -1242,7 +1242,9 @@ static void volume_set_alignment(struct audio_stream __sparse_cache *source,
|
|||
* Volume component is usually first and last in pipelines so it makes sense
|
||||
* to also do some type of conversion here.
|
||||
*/
|
||||
static int volume_prepare(struct processing_module *mod)
|
||||
static int volume_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct vol_data *cd = module_get_private_data(mod);
|
||||
struct module_data *md = &mod->priv;
|
||||
|
|
|
@ -688,7 +688,9 @@ static int waves_codec_init(struct processing_module *mod)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int waves_codec_prepare(struct processing_module *mod)
|
||||
static int waves_codec_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct comp_dev *dev = mod->dev;
|
||||
int ret;
|
||||
|
|
|
@ -165,6 +165,55 @@ err:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int module_adapter_sink_src_prepare(struct comp_dev *dev)
|
||||
{
|
||||
struct comp_buffer __sparse_cache *source_buffers_c[PLATFORM_MAX_STREAMS];
|
||||
struct comp_buffer __sparse_cache *sinks_buffers_c[PLATFORM_MAX_STREAMS];
|
||||
struct sof_sink __sparse_cache *audio_sink[PLATFORM_MAX_STREAMS];
|
||||
struct sof_source __sparse_cache *audio_src[PLATFORM_MAX_STREAMS];
|
||||
struct processing_module *mod = comp_get_drvdata(dev);
|
||||
struct list_item *blist;
|
||||
uint32_t num_of_sources = 0;
|
||||
uint32_t num_of_sinks = 0;
|
||||
int ret;
|
||||
|
||||
/* acquire all sink and source buffers, get handlers to sink/source API */
|
||||
list_for_item(blist, &dev->bsink_list) {
|
||||
struct comp_buffer *sink_buffer_uc;
|
||||
|
||||
sink_buffer_uc = container_of(blist, struct comp_buffer, source_list);
|
||||
sinks_buffers_c[num_of_sinks] = buffer_acquire(sink_buffer_uc);
|
||||
audio_sink[num_of_sinks] =
|
||||
audio_stream_get_sink(&sinks_buffers_c[num_of_sinks]->stream);
|
||||
sink_reset_num_of_processed_bytes(audio_sink[num_of_sinks]);
|
||||
num_of_sinks++;
|
||||
}
|
||||
|
||||
list_for_item(blist, &dev->bsource_list) {
|
||||
struct comp_buffer *source_buffer_uc;
|
||||
|
||||
source_buffer_uc = container_of(blist, struct comp_buffer, sink_list);
|
||||
source_buffers_c[num_of_sources] = buffer_acquire(source_buffer_uc);
|
||||
audio_src[num_of_sources] =
|
||||
audio_stream_get_source(&source_buffers_c[num_of_sources]->stream);
|
||||
source_reset_num_of_processed_bytes(audio_src[num_of_sources]);
|
||||
num_of_sources++;
|
||||
}
|
||||
|
||||
/* Prepare module */
|
||||
ret = module_prepare(mod, audio_src, num_of_sources, audio_sink, num_of_sinks);
|
||||
|
||||
/* release all source buffers in reverse order */
|
||||
for (int i = num_of_sources - 1; i >= 0; i--)
|
||||
buffer_release(source_buffers_c[i]);
|
||||
|
||||
/* release all sink buffers in reverse order */
|
||||
for (int i = num_of_sinks - 1; i >= 0 ; i--)
|
||||
buffer_release(sinks_buffers_c[i]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Prepare the module
|
||||
* \param[in] dev - component device pointer.
|
||||
|
@ -189,7 +238,11 @@ int module_adapter_prepare(struct comp_dev *dev)
|
|||
comp_dbg(dev, "module_adapter_prepare() start");
|
||||
|
||||
/* Prepare module */
|
||||
ret = module_prepare(mod);
|
||||
if (IS_PROCESSING_MODE_SINK_SOURCE(mod))
|
||||
ret = module_adapter_sink_src_prepare(dev);
|
||||
else
|
||||
ret = module_prepare(mod, NULL, 0, NULL, 0);
|
||||
|
||||
if (ret) {
|
||||
if (ret != PPL_STATUS_PATH_STOP)
|
||||
comp_err(dev, "module_adapter_prepare() error %x: module prepare failed",
|
||||
|
|
|
@ -617,7 +617,9 @@ static int mux_reset(struct processing_module *mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mux_prepare(struct processing_module *mod)
|
||||
static int mux_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct comp_dev *dev = mod->dev;
|
||||
struct comp_data *cd = module_get_private_data(mod);
|
||||
|
|
|
@ -890,7 +890,9 @@ static int selector_process(struct processing_module *mod,
|
|||
* \param[in,out] mod Selector base module device.
|
||||
* \return Error code.
|
||||
*/
|
||||
static int selector_prepare(struct processing_module *mod)
|
||||
static int selector_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct comp_data *cd = module_get_private_data(mod);
|
||||
struct module_data *md = &mod->priv;
|
||||
|
|
|
@ -725,7 +725,9 @@ static void tdfb_set_alignment(struct audio_stream __sparse_cache *source,
|
|||
audio_stream_init_alignment_constants(byte_align, frame_align_req, sink);
|
||||
}
|
||||
|
||||
static int tdfb_prepare(struct processing_module *mod)
|
||||
static int tdfb_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct tdfb_comp_data *cd = module_get_private_data(mod);
|
||||
struct comp_buffer *sourceb, *sinkb;
|
||||
|
|
|
@ -399,7 +399,9 @@ err:
|
|||
}
|
||||
|
||||
/* just stubs for now. Remove these after making these ops optional in the module adapter */
|
||||
static int up_down_mixer_prepare(struct processing_module *mod)
|
||||
static int up_down_mixer_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct up_down_mixer_data *cd = module_get_private_data(mod);
|
||||
struct comp_dev *dev = mod->dev;
|
||||
|
|
|
@ -219,7 +219,9 @@ int module_init(struct processing_module *mod, struct module_interface *interfac
|
|||
void *module_allocate_memory(struct processing_module *mod, uint32_t size, uint32_t alignment);
|
||||
int module_free_memory(struct processing_module *mod, void *ptr);
|
||||
void module_free_all_memory(struct processing_module *mod);
|
||||
int module_prepare(struct processing_module *mod);
|
||||
int module_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks);
|
||||
int module_process_sink_src(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks);
|
||||
|
|
|
@ -82,7 +82,9 @@ struct module_interface {
|
|||
* Module specific prepare procedure, called as part of module_adapter
|
||||
* component preparation in .prepare()
|
||||
*/
|
||||
int (*prepare)(struct processing_module *mod);
|
||||
int (*prepare)(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks);
|
||||
|
||||
/**
|
||||
* Module specific processing procedure
|
||||
|
|
|
@ -364,7 +364,9 @@ static int smart_amp_reset(struct processing_module *mod)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int smart_amp_prepare(struct processing_module *mod)
|
||||
static int smart_amp_prepare(struct processing_module *mod,
|
||||
struct sof_source __sparse_cache **sources, int num_of_sources,
|
||||
struct sof_sink __sparse_cache **sinks, int num_of_sinks)
|
||||
{
|
||||
struct smart_amp_data *sad = module_get_private_data(mod);
|
||||
struct comp_dev *dev = mod->dev;
|
||||
|
|
|
@ -171,7 +171,7 @@ static int setup(void **state)
|
|||
mod->stream_params->channels = params->channels;
|
||||
mod->period_bytes = get_frame_bytes(params->source_format, params->channels) * 48000 / 1000;
|
||||
|
||||
ret = module_prepare(mod);
|
||||
ret = module_prepare(mod, NULL, 0, NULL, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ static int setup(void **state)
|
|||
mod->stream_params->channels = params->channels;
|
||||
mod->period_bytes = get_frame_bytes(params->source_format, params->channels) * 48000 / 1000;
|
||||
|
||||
ret = module_prepare(mod);
|
||||
ret = module_prepare(mod, NULL, 0, NULL, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
Loading…
Reference in New Issue