Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,10 @@ static int mux_prepare(struct processing_module *mod,
{
struct comp_dev *dev = mod->dev;
struct comp_data *cd = module_get_private_data(mod);
struct sof_mux_config *config;
size_t blob_size;
int ret;

comp_dbg(dev, "mux_prepare()");

config = comp_get_data_blob(cd->model_handler, &blob_size, NULL);
if (blob_size > MUX_BLOB_MAX_SIZE) {
comp_err(dev, "illegal blob size %zu", blob_size);
return -EINVAL;
}

memcpy_s(&cd->config, MUX_BLOB_MAX_SIZE, config, blob_size);

ret = mux_params(mod);
if (ret < 0)
return ret;
Expand Down
4 changes: 4 additions & 0 deletions src/audio/mux/mux.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ void sys_comp_module_demux_interface_init(void);
#endif /* UNIT_TEST */

#define MUX_BLOB_STREAMS_SIZE (MUX_MAX_STREAMS * sizeof(struct mux_stream_data))
#ifdef CONFIG_IPC_MAJOR_4
#define MUX_BLOB_MAX_SIZE (sizeof(struct mux_data))
#else
#define MUX_BLOB_MAX_SIZE (sizeof(struct sof_mux_config) + MUX_BLOB_STREAMS_SIZE)
#endif

extern const struct sof_uuid demux_uuid;
extern struct tr_ctx mux_tr;
Expand Down
13 changes: 13 additions & 0 deletions src/audio/mux/mux_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <sof/audio/module_adapter/module/generic.h>
#include <sof/audio/component.h>
#include <sof/audio/data_blob.h>
#include <module/module/base.h>
#include <sof/trace/trace.h>
#include <rtos/string_macro.h>
Expand Down Expand Up @@ -98,6 +99,18 @@ static int mux_set_values(struct processing_module *mod)

int mux_params(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);
struct sof_mux_config *config;
size_t blob_size;

config = comp_get_data_blob(cd->model_handler, &blob_size, NULL);
if (blob_size > MUX_BLOB_MAX_SIZE) {
comp_err(mod->dev, "illegal blob size %zu", blob_size);
return -EINVAL;
}

memcpy_s(&cd->config, MUX_BLOB_MAX_SIZE, config, blob_size);

return mux_set_values(mod);
}
#endif /* CONFIG_COMP_MUX */
42 changes: 26 additions & 16 deletions src/audio/mux/mux_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sof/audio/audio_stream.h>
#include <sof/audio/component.h>
#include <sof/audio/buffer.h>
#include <sof/audio/data_blob.h>
#include <sof/trace/trace.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
Expand All @@ -31,7 +32,7 @@ SOF_DEFINE_REG_UUID(demux);

DECLARE_TR_CTX(demux_tr, SOF_UUID(demux_uuid), LOG_LEVEL_INFO);

static int build_config(struct processing_module *mod)
static int build_config(struct processing_module *mod, struct mux_data *cfg)
{
struct comp_dev *dev = mod->dev;
struct comp_data *cd = module_get_private_data(mod);
Expand All @@ -45,12 +46,12 @@ static int build_config(struct processing_module *mod)
memset(cd->config.streams[i].mask, 0, sizeof(cd->config.streams[i].mask));

/* Setting masks for streams */
for (i = 0; i < cd->md.base_cfg.audio_fmt.channels_count; i++) {
for (i = 0; i < cfg->base_cfg.audio_fmt.channels_count; i++) {
cd->config.streams[0].mask[i] = mask;
mask <<= 1;
}

for (i = 0; i < cd->md.reference_format.channels_count; i++) {
for (i = 0; i < cfg->reference_format.channels_count; i++) {
cd->config.streams[1].mask[i] = mask;
mask <<= 1;
}
Expand All @@ -67,7 +68,7 @@ static int build_config(struct processing_module *mod)
* set up param then verify param. BTW for IPC3 path, the param is sent by
* host driver.
*/
static void set_mux_params(struct processing_module *mod)
static void set_mux_params(struct processing_module *mod, struct mux_data *cfg)
{
struct sof_ipc_stream_params *params = mod->stream_params;
struct comp_data *cd = module_get_private_data(mod);
Expand All @@ -76,12 +77,12 @@ static void set_mux_params(struct processing_module *mod)
int j;

params->direction = dev->direction;
params->channels = cd->md.base_cfg.audio_fmt.channels_count;
params->rate = cd->md.base_cfg.audio_fmt.sampling_frequency;
params->sample_container_bytes = cd->md.base_cfg.audio_fmt.depth / 8;
params->sample_valid_bytes = cd->md.base_cfg.audio_fmt.valid_bit_depth / 8;
params->buffer_fmt = cd->md.base_cfg.audio_fmt.interleaving_style;
params->buffer.size = cd->md.base_cfg.ibs;
params->channels = cfg->base_cfg.audio_fmt.channels_count;
params->rate = cfg->base_cfg.audio_fmt.sampling_frequency;
params->sample_container_bytes = cfg->base_cfg.audio_fmt.depth / 8;
params->sample_valid_bytes = cfg->base_cfg.audio_fmt.valid_bit_depth / 8;
params->buffer_fmt = cfg->base_cfg.audio_fmt.interleaving_style;
params->buffer.size = cfg->base_cfg.ibs;
params->no_stream_position = 1;

/* There are two input pins and one output pin in the mux.
Expand All @@ -95,7 +96,7 @@ static void set_mux_params(struct processing_module *mod)
sink = comp_dev_get_first_data_consumer(dev);

if (!audio_buffer_hw_params_configured(&sink->audio_buffer)) {
ipc4_update_buffer_format(sink, &cd->md.output_format);
ipc4_update_buffer_format(sink, &cfg->output_format);
params->frame_fmt = audio_stream_get_frm_fmt(&sink->stream);
}
}
Expand All @@ -105,12 +106,12 @@ static void set_mux_params(struct processing_module *mod)
struct ipc4_audio_format *audio_fmt;

comp_dev_for_each_producer(dev, source) {
j = buf_get_id(source);
j = IPC4_SINK_QUEUE_ID(buf_get_id(source));
Copy link
Collaborator

Choose a reason for hiding this comment

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

just to check - it does have to be IPC4_SINK_QUEUE_ID(), not IPC4_SRC_QUEUE_ID()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, Its easy to make mistake around sink/src macros but based on the latest fixes this is the correct approach
#10298

cd->config.streams[j].pipeline_id = buffer_pipeline_id(source);
if (j == BASE_CFG_QUEUED_ID)
audio_fmt = &cd->md.base_cfg.audio_fmt;
audio_fmt = &cfg->base_cfg.audio_fmt;
else
audio_fmt = &cd->md.reference_format;
audio_fmt = &cfg->reference_format;

ipc4_update_buffer_format(source, audio_fmt);
}
Expand All @@ -121,13 +122,22 @@ static void set_mux_params(struct processing_module *mod)

int mux_params(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);
struct mux_data *cfg;
size_t blob_size;
int ret;

ret = build_config(mod);
cfg = comp_get_data_blob(cd->model_handler, &blob_size, NULL);
if (!cfg || blob_size > MUX_BLOB_MAX_SIZE) {
comp_err(mod->dev, "illegal blob size %zu", blob_size);
return -EINVAL;
}

ret = build_config(mod, cfg);
if (ret < 0)
return ret;

set_mux_params(mod);
set_mux_params(mod, cfg);

return ret;
}
Expand Down
Loading