@@ -292,7 +292,7 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
292292 struct skl_module_iface * m_iface = & m_cfg -> module -> formats [fmt_idx ];
293293
294294 /* check if we already have blob */
295- if (m_cfg -> formats_config .caps_size > 0 )
295+ if (m_cfg -> formats_config [ SKL_PARAM_INIT ] .caps_size > 0 )
296296 return 0 ;
297297
298298 dev_dbg (skl -> dev , "Applying default cfg blob\n" );
@@ -328,8 +328,8 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
328328 cfg = skl_get_ep_blob (skl , m_cfg -> vbus_id , link_type ,
329329 s_fmt , ch , s_freq , dir , dev_type );
330330 if (cfg ) {
331- m_cfg -> formats_config .caps_size = cfg -> size ;
332- m_cfg -> formats_config .caps = (u32 * ) & cfg -> caps ;
331+ m_cfg -> formats_config [ SKL_PARAM_INIT ] .caps_size = cfg -> size ;
332+ m_cfg -> formats_config [ SKL_PARAM_INIT ] .caps = (u32 * )& cfg -> caps ;
333333 } else {
334334 dev_err (skl -> dev , "Blob NULL for id %x type %d dirn %d\n" ,
335335 m_cfg -> vbus_id , link_type , dir );
@@ -386,9 +386,9 @@ static int skl_tplg_set_module_params(struct snd_soc_dapm_widget *w,
386386 struct skl_algo_data * bc ;
387387 struct skl_specific_cfg * sp_cfg ;
388388
389- if (mconfig -> formats_config .caps_size > 0 &&
390- mconfig -> formats_config .set_params == SKL_PARAM_SET ) {
391- sp_cfg = & mconfig -> formats_config ;
389+ if (mconfig -> formats_config [ SKL_PARAM_SET ] .caps_size > 0 &&
390+ mconfig -> formats_config [ SKL_PARAM_SET ] .set_params == SKL_PARAM_SET ) {
391+ sp_cfg = & mconfig -> formats_config [ SKL_PARAM_SET ] ;
392392 ret = skl_set_module_params (skl , sp_cfg -> caps ,
393393 sp_cfg -> caps_size ,
394394 sp_cfg -> param_id , mconfig );
@@ -438,8 +438,10 @@ static int skl_tplg_set_module_init_data(struct snd_soc_dapm_widget *w)
438438 if (bc -> set_params != SKL_PARAM_INIT )
439439 continue ;
440440
441- mconfig -> formats_config .caps = (u32 * )bc -> params ;
442- mconfig -> formats_config .caps_size = bc -> size ;
441+ mconfig -> formats_config [SKL_PARAM_INIT ].caps =
442+ (u32 * )bc -> params ;
443+ mconfig -> formats_config [SKL_PARAM_INIT ].caps_size =
444+ bc -> size ;
443445
444446 break ;
445447 }
@@ -798,9 +800,10 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w,
798800 return 0 ;
799801 }
800802
801- if (mconfig -> formats_config .caps_size > 0 &&
802- mconfig -> formats_config .set_params == SKL_PARAM_BIND ) {
803- sp_cfg = & mconfig -> formats_config ;
803+ if (mconfig -> formats_config [SKL_PARAM_BIND ].caps_size > 0 &&
804+ mconfig -> formats_config [SKL_PARAM_BIND ].set_params ==
805+ SKL_PARAM_BIND ) {
806+ sp_cfg = & mconfig -> formats_config [SKL_PARAM_BIND ];
804807 ret = skl_set_module_params (skl , sp_cfg -> caps ,
805808 sp_cfg -> caps_size ,
806809 sp_cfg -> param_id , mconfig );
@@ -1496,7 +1499,8 @@ static int skl_tplg_mic_control_get(struct snd_kcontrol *kcontrol,
14961499static int skl_fill_mic_sel_params (struct skl_module_cfg * mconfig ,
14971500 struct skl_mic_sel_config * mic_cfg , struct device * dev )
14981501{
1499- struct skl_specific_cfg * sp_cfg = & mconfig -> formats_config ;
1502+ struct skl_specific_cfg * sp_cfg =
1503+ & mconfig -> formats_config [SKL_PARAM_INIT ];
15001504
15011505 sp_cfg -> caps_size = sizeof (struct skl_mic_sel_config );
15021506 sp_cfg -> set_params = SKL_PARAM_SET ;
@@ -1849,8 +1853,8 @@ static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai,
18491853 pipe_fmt -> freq , pipe -> direction ,
18501854 dev_type );
18511855 if (cfg ) {
1852- mconfig -> formats_config .caps_size = cfg -> size ;
1853- mconfig -> formats_config .caps = (u32 * ) & cfg -> caps ;
1856+ mconfig -> formats_config [ SKL_PARAM_INIT ] .caps_size = cfg -> size ;
1857+ mconfig -> formats_config [ SKL_PARAM_INIT ] .caps = (u32 * )& cfg -> caps ;
18541858 } else {
18551859 dev_err (dai -> dev , "Blob NULL for id:%d type:%d dirn:%d ch:%d, freq:%d, fmt:%d\n" ,
18561860 mconfig -> vbus_id , link_type , params -> stream ,
@@ -2567,19 +2571,26 @@ static int skl_tplg_get_token(struct device *dev,
25672571
25682572 break ;
25692573
2574+ case SKL_TKN_U32_FMT_CFG_IDX :
2575+ if (tkn_elem -> value > SKL_MAX_PARAMS_TYPES )
2576+ return - EINVAL ;
2577+
2578+ mconfig -> fmt_cfg_idx = tkn_elem -> value ;
2579+ break ;
2580+
25702581 case SKL_TKN_U32_CAPS_SIZE :
2571- mconfig -> formats_config .caps_size =
2582+ mconfig -> formats_config [ mconfig -> fmt_cfg_idx ] .caps_size =
25722583 tkn_elem -> value ;
25732584
25742585 break ;
25752586
25762587 case SKL_TKN_U32_CAPS_SET_PARAMS :
2577- mconfig -> formats_config .set_params =
2588+ mconfig -> formats_config [ mconfig -> fmt_cfg_idx ] .set_params =
25782589 tkn_elem -> value ;
25792590 break ;
25802591
25812592 case SKL_TKN_U32_CAPS_PARAMS_ID :
2582- mconfig -> formats_config .param_id =
2593+ mconfig -> formats_config [ mconfig -> fmt_cfg_idx ] .param_id =
25832594 tkn_elem -> value ;
25842595 break ;
25852596
@@ -2793,6 +2804,7 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w,
27932804 struct skl_dfw_v4_module * dfw =
27942805 (struct skl_dfw_v4_module * )tplg_w -> priv .data ;
27952806 int ret ;
2807+ int idx = mconfig -> fmt_cfg_idx ;
27962808
27972809 dev_dbg (dev , "Parsing Skylake v4 widget topology data\n" );
27982810
@@ -2826,7 +2838,7 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w,
28262838 mconfig -> dev_type = dfw -> dev_type ;
28272839 mconfig -> hw_conn_type = dfw -> hw_conn_type ;
28282840 mconfig -> time_slot = dfw -> time_slot ;
2829- mconfig -> formats_config .caps_size = dfw -> caps .caps_size ;
2841+ mconfig -> formats_config [ idx ] .caps_size = dfw -> caps .caps_size ;
28302842
28312843 mconfig -> m_in_pin = devm_kcalloc (dev ,
28322844 MAX_IN_QUEUE , sizeof (* mconfig -> m_in_pin ),
@@ -2847,21 +2859,39 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w,
28472859 dfw -> is_dynamic_out_pin ,
28482860 mconfig -> module -> max_output_pins );
28492861
2850- if (mconfig -> formats_config .caps_size ) {
2851- mconfig -> formats_config .set_params = dfw -> caps .set_params ;
2852- mconfig -> formats_config .param_id = dfw -> caps .param_id ;
2853- mconfig -> formats_config .caps =
2854- devm_kzalloc (dev , mconfig -> formats_config .caps_size ,
2862+ if (mconfig -> formats_config [ idx ] .caps_size ) {
2863+ mconfig -> formats_config [ idx ] .set_params = dfw -> caps .set_params ;
2864+ mconfig -> formats_config [ idx ] .param_id = dfw -> caps .param_id ;
2865+ mconfig -> formats_config [ idx ] .caps =
2866+ devm_kzalloc (dev , mconfig -> formats_config [ idx ] .caps_size ,
28552867 GFP_KERNEL );
2856- if (!mconfig -> formats_config .caps )
2868+ if (!mconfig -> formats_config [ idx ] .caps )
28572869 return - ENOMEM ;
2858- memcpy (mconfig -> formats_config .caps , dfw -> caps .caps ,
2870+ memcpy (mconfig -> formats_config [ idx ] .caps , dfw -> caps .caps ,
28592871 dfw -> caps .caps_size );
28602872 }
28612873
28622874 return 0 ;
28632875}
28642876
2877+ static int skl_tplg_get_caps_data (struct device * dev , char * data ,
2878+ struct skl_module_cfg * mconfig )
2879+ {
2880+ int idx = mconfig -> fmt_cfg_idx ;
2881+
2882+ if (mconfig -> formats_config [idx ].caps_size > 0 ) {
2883+ mconfig -> formats_config [idx ].caps =
2884+ devm_kzalloc (dev , mconfig -> formats_config [idx ].caps_size ,
2885+ GFP_KERNEL );
2886+ if (!mconfig -> formats_config [idx ].caps )
2887+ return - ENOMEM ;
2888+ memcpy (mconfig -> formats_config [idx ].caps , data ,
2889+ mconfig -> formats_config [idx ].caps_size );
2890+ }
2891+
2892+ return mconfig -> formats_config [idx ].caps_size ;
2893+ }
2894+
28652895/*
28662896 * Parse the private data for the token and corresponding value.
28672897 * The private data can have multiple data blocks. So, a data block
@@ -2922,18 +2952,14 @@ static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w,
29222952 if (block_type == SKL_TYPE_TUPLE ) {
29232953 ret = skl_tplg_get_tokens (dev , data ,
29242954 skl , mconfig , block_size );
2925-
2926- if (ret < 0 )
2927- return ret ;
2928-
2929- -- num_blocks ;
29302955 } else {
2931- if (mconfig -> formats_config .caps_size > 0 )
2932- memcpy (mconfig -> formats_config .caps , data ,
2933- mconfig -> formats_config .caps_size );
2934- -- num_blocks ;
2935- ret = mconfig -> formats_config .caps_size ;
2956+ ret = skl_tplg_get_caps_data (dev , data , mconfig );
29362957 }
2958+
2959+ if (ret < 0 )
2960+ return ret ;
2961+
2962+ -- num_blocks ;
29372963 off += ret ;
29382964 }
29392965
@@ -3024,6 +3050,9 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, int index,
30243050 */
30253051 mconfig -> id .module_id = -1 ;
30263052
3053+ /* To provide backward compatibility, set default as SKL_PARAM_INIT */
3054+ mconfig -> fmt_cfg_idx = SKL_PARAM_INIT ;
3055+
30273056 /* Parse private data for tuples */
30283057 ret = skl_tplg_get_pvt_data (tplg_w , skl , bus -> dev , mconfig );
30293058 if (ret < 0 )
0 commit comments