@@ -486,6 +486,15 @@ static int get_token_u16(void *elem, void *object, u32 offset, u32 size)
486486 return 0 ;
487487}
488488
489+ static int get_token_u8 (void * elem , void * object , u32 offset , u32 size )
490+ {
491+ struct snd_soc_tplg_vendor_value_elem * velem = elem ;
492+ u8 * val = (u8 * )object + offset ;
493+
494+ * val = (u8 )velem -> value ;
495+ return 0 ;
496+ }
497+
489498static int get_token_comp_format (void * elem , void * object , u32 offset , u32 size )
490499{
491500 struct snd_soc_tplg_vendor_string_elem * velem = elem ;
@@ -614,6 +623,22 @@ static const struct sof_topology_token stream_tokens[] = {
614623 offsetof(struct snd_sof_pcm , stream [1 ].d0i3_compatible ), 0 },
615624};
616625
626+ /* Mux data */
627+ static const struct sof_topology_token mux_tokens [] = {
628+ {SOF_TKN_MUX_NUM_CHANNELS , SND_SOC_TPLG_TUPLE_TYPE_WORD , get_token_u32 ,
629+ offsetof(struct sof_mux_config , num_channels ), 0 },
630+ {SOF_TKN_MUX_NUM_STREAMS , SND_SOC_TPLG_TUPLE_TYPE_WORD , get_token_u32 ,
631+ offsetof(struct sof_mux_config , num_streams ), 0 },
632+ };
633+
634+ /* Mux stream data */
635+ static const struct sof_topology_token mux_stream_tokens [] = {
636+ {SOF_TKN_MUX_STREAM_PIPELINE_ID , SND_SOC_TPLG_TUPLE_TYPE_WORD , get_token_u32 ,
637+ offsetof(struct mux_stream_data , pipeline_id ), 0 },
638+ {SOF_TKN_MUX_STREAM_CHANNELS , SND_SOC_TPLG_TUPLE_TYPE_WORD , get_token_u8 ,
639+ offsetof(struct mux_stream_data , num_channels ), 0 },
640+ };
641+
617642/* Generic components */
618643static const struct sof_topology_token comp_tokens [] = {
619644 {SOF_TKN_COMP_PERIOD_SINK_COUNT ,
@@ -2017,6 +2042,60 @@ static int sof_get_control_data(struct snd_soc_component *scomp,
20172042 return 0 ;
20182043}
20192044
2045+ /*
2046+ * Sof mux/demux component
2047+ */
2048+ static int sof_process_load_mux (struct snd_soc_component * scomp ,
2049+ struct sof_ipc_comp_process * process ,
2050+ struct snd_soc_tplg_private * private )
2051+ {
2052+ struct sof_mux_config * mc = (struct sof_mux_config * )& process -> data ;
2053+ struct mux_stream_data * msd = (struct mux_stream_data * )
2054+ ((u8 * )process -> data + sizeof (struct sof_mux_config ));
2055+ struct snd_soc_tplg_vendor_array * varray ;
2056+ int pos = 0 ;
2057+ int ret ;
2058+ int i ;
2059+
2060+ /* parse mux config array */
2061+ ret = sof_parse_tokens (scomp , mc , mux_tokens ,
2062+ ARRAY_SIZE (mux_tokens ), private -> array ,
2063+ le32_to_cpu (private -> size ));
2064+ if (ret < 0 ) {
2065+ dev_err (scomp -> dev , "error: parse mux tokens failed %d\n" ,
2066+ private -> size );
2067+ return ret ;
2068+ }
2069+
2070+ /* parse mux stream config arrays */
2071+ for (i = 0 ; i < mc -> num_streams ; i ++ ) {
2072+ varray = (struct snd_soc_tplg_vendor_array * )
2073+ ((u8 * )private -> array + pos );
2074+ ret = sof_parse_tokens (scomp , msd , mux_stream_tokens ,
2075+ ARRAY_SIZE (mux_stream_tokens ),
2076+ varray ,
2077+ le32_to_cpu (private -> size ) - pos );
2078+ if (ret < 0 ) {
2079+ dev_err (scomp -> dev , "error: mux stream tokens %d\n" ,
2080+ private -> size );
2081+ return ret ;
2082+ }
2083+
2084+ /* track position for multiple same type arrays */
2085+ pos += ret ;
2086+ msd ++ ;
2087+ }
2088+
2089+ /* get the channel byte masks after stream arrays */
2090+ msd -= mc -> num_streams ;
2091+ for (i = 0 ; i < mc -> num_streams ; i ++ ) {
2092+ memcpy (& msd -> mask [0 ], (u8 * )private -> array + pos + i * 8 , 8 );
2093+ msd ++ ;
2094+ }
2095+
2096+ return ret ;
2097+ }
2098+
20202099static int sof_process_load (struct snd_soc_component * scomp , int index ,
20212100 struct snd_sof_widget * swidget ,
20222101 struct snd_soc_tplg_dapm_widget * tw ,
@@ -2092,6 +2171,30 @@ static int sof_process_load(struct snd_soc_component *scomp, int index,
20922171
20932172 sof_dbg_comp_config (scomp , & process -> config );
20942173
2174+ /* possible tuplet and data parsing for process components */
2175+ switch (type ) {
2176+ case SOF_COMP_EQ_FIR :
2177+ /* fallthrough */
2178+ case SOF_COMP_EQ_IIR :
2179+ /* fallthrough */
2180+ case SOF_COMP_KEYWORD_DETECT :
2181+ /* fallthrough */
2182+ case SOF_COMP_KPB :
2183+ /* fallthrough */
2184+ case SOF_COMP_SELECTOR :
2185+ break ;
2186+ case SOF_COMP_MUX :
2187+ case SOF_COMP_DEMUX :
2188+ offset = sof_process_load_mux (scomp , process , private );
2189+ break ;
2190+ }
2191+
2192+ if (offset < 0 ) {
2193+ dev_err (scomp -> dev , "error: parse process tokens failed %d\n" ,
2194+ le32_to_cpu (private -> size ));
2195+ goto err ;
2196+ }
2197+
20952198 /*
20962199 * found private data in control, so copy it.
20972200 * get possible component controls - get size of all pdata,
0 commit comments