Skip to content

Commit ca200ed

Browse files
committed
audio: mux: fix IPC4 configuration handling for IPC3/IPC4 separation
This patch will fix IPC4 configuration. Move configuration blob handling from common mux_prepare() to IPC-specific mux_params() implementations to better separate IPC3 and IPC4 code paths. Changes: - Remove config blob retrieval and validation from mux_prepare() in mux.c - Move blob handling to mux_params() in mux_ipc3.c for IPC3 path - Update mux_ipc4.c to use blob handler for config blob instead of storing in comp_data->md - Define MUX_BLOB_MAX_SIZE conditionally based on IPC version: * IPC4: sizeof(struct mux_data) * IPC3: sizeof(struct sof_mux_config) + MUX_BLOB_STREAMS_SIZE Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent f9f71a9 commit ca200ed

File tree

4 files changed

+42
-25
lines changed

4 files changed

+42
-25
lines changed

src/audio/mux/mux.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,20 +390,10 @@ static int mux_prepare(struct processing_module *mod,
390390
{
391391
struct comp_dev *dev = mod->dev;
392392
struct comp_data *cd = module_get_private_data(mod);
393-
struct sof_mux_config *config;
394-
size_t blob_size;
395393
int ret;
396394

397395
comp_dbg(dev, "mux_prepare()");
398396

399-
config = comp_get_data_blob(cd->model_handler, &blob_size, NULL);
400-
if (blob_size > MUX_BLOB_MAX_SIZE) {
401-
comp_err(dev, "illegal blob size %zu", blob_size);
402-
return -EINVAL;
403-
}
404-
405-
memcpy_s(&cd->config, MUX_BLOB_MAX_SIZE, config, blob_size);
406-
407397
ret = mux_params(mod);
408398
if (ret < 0)
409399
return ret;

src/audio/mux/mux.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ void sys_comp_module_demux_interface_init(void);
213213
#endif /* UNIT_TEST */
214214

215215
#define MUX_BLOB_STREAMS_SIZE (MUX_MAX_STREAMS * sizeof(struct mux_stream_data))
216+
#ifdef CONFIG_IPC_MAJOR_4
217+
#define MUX_BLOB_MAX_SIZE (sizeof(struct mux_data))
218+
#else
216219
#define MUX_BLOB_MAX_SIZE (sizeof(struct sof_mux_config) + MUX_BLOB_STREAMS_SIZE)
220+
#endif
217221

218222
extern const struct sof_uuid demux_uuid;
219223
extern struct tr_ctx mux_tr;

src/audio/mux/mux_ipc3.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <sof/audio/module_adapter/module/generic.h>
1111
#include <sof/audio/component.h>
12+
#include <sof/audio/data_blob.h>
1213
#include <module/module/base.h>
1314
#include <sof/trace/trace.h>
1415
#include <rtos/string_macro.h>
@@ -98,6 +99,18 @@ static int mux_set_values(struct processing_module *mod)
9899

99100
int mux_params(struct processing_module *mod)
100101
{
102+
struct comp_data *cd = module_get_private_data(mod);
103+
struct sof_mux_config *config;
104+
size_t blob_size;
105+
106+
config = comp_get_data_blob(cd->model_handler, &blob_size, NULL);
107+
if (blob_size > MUX_BLOB_MAX_SIZE) {
108+
comp_err(mod->dev, "illegal blob size %zu", blob_size);
109+
return -EINVAL;
110+
}
111+
112+
memcpy_s(&cd->config, MUX_BLOB_MAX_SIZE, config, blob_size);
113+
101114
return mux_set_values(mod);
102115
}
103116
#endif /* CONFIG_COMP_MUX */

src/audio/mux/mux_ipc4.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <sof/audio/audio_stream.h>
1212
#include <sof/audio/component.h>
1313
#include <sof/audio/buffer.h>
14+
#include <sof/audio/data_blob.h>
1415
#include <sof/trace/trace.h>
1516
#include <sof/lib/uuid.h>
1617
#include <sof/list.h>
@@ -31,7 +32,7 @@ SOF_DEFINE_REG_UUID(demux);
3132

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

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

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

53-
for (i = 0; i < cd->md.reference_format.channels_count; i++) {
54+
for (i = 0; i < cfg->reference_format.channels_count; i++) {
5455
cd->config.streams[1].mask[i] = mask;
5556
mask <<= 1;
5657
}
@@ -67,7 +68,7 @@ static int build_config(struct processing_module *mod)
6768
* set up param then verify param. BTW for IPC3 path, the param is sent by
6869
* host driver.
6970
*/
70-
static void set_mux_params(struct processing_module *mod)
71+
static void set_mux_params(struct processing_module *mod, struct mux_data *cfg)
7172
{
7273
struct sof_ipc_stream_params *params = mod->stream_params;
7374
struct comp_data *cd = module_get_private_data(mod);
@@ -76,12 +77,12 @@ static void set_mux_params(struct processing_module *mod)
7677
int j;
7778

7879
params->direction = dev->direction;
79-
params->channels = cd->md.base_cfg.audio_fmt.channels_count;
80-
params->rate = cd->md.base_cfg.audio_fmt.sampling_frequency;
81-
params->sample_container_bytes = cd->md.base_cfg.audio_fmt.depth / 8;
82-
params->sample_valid_bytes = cd->md.base_cfg.audio_fmt.valid_bit_depth / 8;
83-
params->buffer_fmt = cd->md.base_cfg.audio_fmt.interleaving_style;
84-
params->buffer.size = cd->md.base_cfg.ibs;
80+
params->channels = cfg->base_cfg.audio_fmt.channels_count;
81+
params->rate = cfg->base_cfg.audio_fmt.sampling_frequency;
82+
params->sample_container_bytes = cfg->base_cfg.audio_fmt.depth / 8;
83+
params->sample_valid_bytes = cfg->base_cfg.audio_fmt.valid_bit_depth / 8;
84+
params->buffer_fmt = cfg->base_cfg.audio_fmt.interleaving_style;
85+
params->buffer.size = cfg->base_cfg.ibs;
8586
params->no_stream_position = 1;
8687

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

9798
if (!audio_buffer_hw_params_configured(&sink->audio_buffer)) {
98-
ipc4_update_buffer_format(sink, &cd->md.output_format);
99+
ipc4_update_buffer_format(sink, &cfg->output_format);
99100
params->frame_fmt = audio_stream_get_frm_fmt(&sink->stream);
100101
}
101102
}
@@ -108,9 +109,9 @@ static void set_mux_params(struct processing_module *mod)
108109
j = IPC4_SINK_QUEUE_ID(buf_get_id(source));
109110
cd->config.streams[j].pipeline_id = buffer_pipeline_id(source);
110111
if (j == BASE_CFG_QUEUED_ID)
111-
audio_fmt = &cd->md.base_cfg.audio_fmt;
112+
audio_fmt = &cfg->base_cfg.audio_fmt;
112113
else
113-
audio_fmt = &cd->md.reference_format;
114+
audio_fmt = &cfg->reference_format;
114115

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

122123
int mux_params(struct processing_module *mod)
123124
{
125+
struct comp_data *cd = module_get_private_data(mod);
126+
struct mux_data *cfg;
127+
size_t blob_size;
124128
int ret;
125129

126-
ret = build_config(mod);
130+
cfg = comp_get_data_blob(cd->model_handler, &blob_size, NULL);
131+
if (!cfg || blob_size > MUX_BLOB_MAX_SIZE) {
132+
comp_err(mod->dev, "illegal blob size %zu", blob_size);
133+
return -EINVAL;
134+
}
135+
136+
ret = build_config(mod, cfg);
127137
if (ret < 0)
128138
return ret;
129139

130-
set_mux_params(mod);
140+
set_mux_params(mod, cfg);
131141

132142
return ret;
133143
}

0 commit comments

Comments
 (0)