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
3233DECLARE_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
122123int 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