Skip to content

Commit a4ad42d

Browse files
kareemshaik80broonie
authored andcommitted
ASoC: Intel: Skylake: Support multiple format configs
A module can have two kinds of set params, as per topology requirements. For example, one pre-init and one post-init. But currently, there is support for just one type, as the format_config. This patch extends the format_configs to 4, so as to be able to support pre-init, post-init and post-bind type of set params, for the same module, simultaneously. Signed-off-by: Kareem Shaik <[email protected]> Signed-off-by: Gustaw Lewandowski <[email protected]> Signed-off-by: Cezary Rojewski <[email protected]> Tested-by: Lukasz Majczak <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e4e95d8 commit a4ad42d

File tree

4 files changed

+82
-47
lines changed

4 files changed

+82
-47
lines changed

include/uapi/sound/snd_sst_tokens.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@
233233
*
234234
* %SKL_TKN_U32_ASTATE_CLK_SRC: Clock source for A-State entry
235235
*
236+
* %SKL_TKN_U32_FMT_CFG_IDX: Format config index
237+
*
236238
* module_id and loadable flags dont have tokens as these values will be
237239
* read from the DSP FW manifest
238240
*
@@ -324,7 +326,9 @@ enum SKL_TKNS {
324326
SKL_TKN_U32_ASTATE_COUNT,
325327
SKL_TKN_U32_ASTATE_KCPS,
326328
SKL_TKN_U32_ASTATE_CLK_SRC,
327-
SKL_TKN_MAX = SKL_TKN_U32_ASTATE_CLK_SRC,
329+
330+
SKL_TKN_U32_FMT_CFG_IDX = 96,
331+
SKL_TKN_MAX = SKL_TKN_U32_FMT_CFG_IDX,
328332
};
329333

330334
#endif

sound/soc/intel/skylake/skl-messages.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,15 @@ static void skl_set_base_module_format(struct skl_dev *skl,
479479
static void skl_copy_copier_caps(struct skl_module_cfg *mconfig,
480480
struct skl_cpr_cfg *cpr_mconfig)
481481
{
482-
if (mconfig->formats_config.caps_size == 0)
482+
if (mconfig->formats_config[SKL_PARAM_INIT].caps_size == 0)
483483
return;
484484

485485
memcpy(cpr_mconfig->gtw_cfg.config_data,
486-
mconfig->formats_config.caps,
487-
mconfig->formats_config.caps_size);
486+
mconfig->formats_config[SKL_PARAM_INIT].caps,
487+
mconfig->formats_config[SKL_PARAM_INIT].caps_size);
488488

489489
cpr_mconfig->gtw_cfg.config_length =
490-
(mconfig->formats_config.caps_size) / 4;
490+
(mconfig->formats_config[SKL_PARAM_INIT].caps_size) / 4;
491491
}
492492

493493
#define SKL_NON_GATEWAY_CPR_NODE_ID 0xFFFFFFFF
@@ -749,13 +749,12 @@ static void skl_set_algo_format(struct skl_dev *skl,
749749
struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)algo_mcfg;
750750

751751
skl_set_base_module_format(skl, mconfig, base_cfg);
752-
753-
if (mconfig->formats_config.caps_size == 0)
752+
if (mconfig->formats_config[SKL_PARAM_INIT].caps_size == 0)
754753
return;
755754

756755
memcpy(algo_mcfg->params,
757-
mconfig->formats_config.caps,
758-
mconfig->formats_config.caps_size);
756+
mconfig->formats_config[SKL_PARAM_INIT].caps,
757+
mconfig->formats_config[SKL_PARAM_INIT].caps_size);
759758

760759
}
761760

@@ -786,7 +785,7 @@ static u16 skl_get_module_param_size(struct skl_dev *skl,
786785
switch (mconfig->m_type) {
787786
case SKL_MODULE_TYPE_COPIER:
788787
param_size = sizeof(struct skl_cpr_cfg);
789-
param_size += mconfig->formats_config.caps_size;
788+
param_size += mconfig->formats_config[SKL_PARAM_INIT].caps_size;
790789
return param_size;
791790

792791
case SKL_MODULE_TYPE_SRCINT:
@@ -797,7 +796,7 @@ static u16 skl_get_module_param_size(struct skl_dev *skl,
797796

798797
case SKL_MODULE_TYPE_ALGO:
799798
param_size = sizeof(struct skl_base_cfg);
800-
param_size += mconfig->formats_config.caps_size;
799+
param_size += mconfig->formats_config[SKL_PARAM_INIT].caps_size;
801800
return param_size;
802801

803802
case SKL_MODULE_TYPE_BASE_OUTFMT:

sound/soc/intel/skylake/skl-topology.c

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -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,
14961499
static 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)

sound/soc/intel/skylake/skl-topology.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ enum skl_s_freq {
8181
SKL_FS_INVALID
8282
};
8383

84+
#define SKL_MAX_PARAMS_TYPES 4
85+
8486
enum skl_widget_type {
8587
SKL_WIDGET_VMIXER = 1,
8688
SKL_WIDGET_MIXER = 2,
@@ -371,6 +373,7 @@ struct skl_module_cfg {
371373
struct skl_module *module;
372374
int res_idx;
373375
int fmt_idx;
376+
int fmt_cfg_idx;
374377
u8 domain;
375378
bool homogenous_inputs;
376379
bool homogenous_outputs;
@@ -401,7 +404,7 @@ struct skl_module_cfg {
401404
enum skl_hw_conn_type hw_conn_type;
402405
enum skl_module_state m_state;
403406
struct skl_pipe *pipe;
404-
struct skl_specific_cfg formats_config;
407+
struct skl_specific_cfg formats_config[SKL_MAX_PARAMS_TYPES];
405408
struct skl_pipe_mcfg mod_cfg[SKL_MAX_MODULES_IN_PIPE];
406409
};
407410

0 commit comments

Comments
 (0)