Skip to content

Commit 6f02c08

Browse files
committed
Merge series "ASoC: Intel: Skylake: Fix and support complex" from Cezary Rojewski <[email protected]>:
Existing skylake-driver supports very basic scenarios with limited range of modules and their control. Attached changes first fix code as several advanced configurations are 'mentioned' throughout the files but are not actually functional. Follow up are changes adding missing support for said configurations. Cezary Rojewski (5): ASoC: Intel: kbl_da7219_max98927: Fix format selection for max98373 ASoC: Intel: Skylake: Leave data as is when invoking TLV IPCs ASoC: Intel: Skylake: Fix module resource and format selection ASoC: Intel: Skylake: Fix module configuration for KPB and MIXER ASoC: Intel: Skylake: Select first entry for singular pipe config arrays Gustaw Lewandowski (2): ASoC: Intel: Skylake: Fix passing loadable flag for module ASoC: Intel: Skylake: Simplify m_state for loadable modules Kareem Shaik (1): ASoC: Intel: Skylake: Support multiple format configs Pawel Harlozinski (1): ASoC: Intel: Skylake: Properly configure modules with generic extension Piotr Maziarz (1): ASoC: Intel: Skylake: Select proper format for NHLT blob Szymon Mielczarek (1): ASoC: Intel: Skylake: Support modules with generic extension include/uapi/sound/snd_sst_tokens.h | 6 +- sound/soc/intel/boards/kbl_da7219_max98927.c | 55 +------ sound/soc/intel/skylake/skl-messages.c | 155 ++++++++++++------- sound/soc/intel/skylake/skl-pcm.c | 25 ++- sound/soc/intel/skylake/skl-topology.c | 155 +++++++++++-------- sound/soc/intel/skylake/skl-topology.h | 26 +++- 6 files changed, 231 insertions(+), 191 deletions(-) -- 2.25.1
2 parents d019403 + b947d2b commit 6f02c08

File tree

6 files changed

+231
-191
lines changed

6 files changed

+231
-191
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/boards/kbl_da7219_max98927.c

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
199199
}
200200
if (!strcmp(codec_dai->component->name, MAX98373_DEV0_NAME)) {
201201
ret = snd_soc_dai_set_tdm_slot(codec_dai,
202-
0x03, 3, 8, 24);
202+
0x30, 3, 8, 16);
203203
if (ret < 0) {
204204
dev_err(runtime->dev,
205205
"DEV0 TDM slot err:%d\n", ret);
@@ -208,10 +208,10 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
208208
}
209209
if (!strcmp(codec_dai->component->name, MAX98373_DEV1_NAME)) {
210210
ret = snd_soc_dai_set_tdm_slot(codec_dai,
211-
0x0C, 3, 8, 24);
211+
0xC0, 3, 8, 16);
212212
if (ret < 0) {
213213
dev_err(runtime->dev,
214-
"DEV0 TDM slot err:%d\n", ret);
214+
"DEV1 TDM slot err:%d\n", ret);
215215
return ret;
216216
}
217217
}
@@ -311,24 +311,6 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
311311
* The above 2 loops are mutually exclusive based on the stream direction,
312312
* thus rtd_dpcm variable will never be overwritten
313313
*/
314-
/*
315-
* Topology for kblda7219m98373 & kblmax98373 supports only S24_LE,
316-
* where as kblda7219m98927 & kblmax98927 supports S16_LE by default.
317-
* Skipping the port wise FE and BE configuration for kblda7219m98373 &
318-
* kblmax98373 as the topology (FE & BE) supports S24_LE only.
319-
*/
320-
321-
if (!strcmp(rtd->card->name, "kblda7219m98373") ||
322-
!strcmp(rtd->card->name, "kblmax98373")) {
323-
/* The ADSP will convert the FE rate to 48k, stereo */
324-
rate->min = rate->max = 48000;
325-
chan->min = chan->max = DUAL_CHANNEL;
326-
327-
/* set SSP to 24 bit */
328-
snd_mask_none(fmt);
329-
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
330-
return 0;
331-
}
332314

333315
/*
334316
* The ADSP will convert the FE rate to 48k, stereo, 24 bit
@@ -479,31 +461,20 @@ static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
479461
static int kbl_fe_startup(struct snd_pcm_substream *substream)
480462
{
481463
struct snd_pcm_runtime *runtime = substream->runtime;
482-
struct snd_soc_pcm_runtime *soc_rt = asoc_substream_to_rtd(substream);
483464

484465
/*
485466
* On this platform for PCM device we support,
486467
* 48Khz
487468
* stereo
469+
* 16 bit audio
488470
*/
489471

490472
runtime->hw.channels_max = DUAL_CHANNEL;
491473
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
492474
&constraints_channels);
493-
/*
494-
* Setup S24_LE (32 bit container and 24 bit valid data) for
495-
* kblda7219m98373 & kblmax98373. For kblda7219m98927 &
496-
* kblmax98927 keeping it as 16/16 due to topology FW dependency.
497-
*/
498-
if (!strcmp(soc_rt->card->name, "kblda7219m98373") ||
499-
!strcmp(soc_rt->card->name, "kblmax98373")) {
500-
runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_LE;
501-
snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
502-
503-
} else {
504-
runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
505-
snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
506-
}
475+
476+
runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
477+
snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
507478

508479
snd_pcm_hw_constraint_list(runtime, 0,
509480
SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
@@ -536,23 +507,11 @@ static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
536507
static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
537508
{
538509
struct snd_pcm_runtime *runtime = substream->runtime;
539-
struct snd_soc_pcm_runtime *soc_rt = asoc_substream_to_rtd(substream);
540510

541511
runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
542512
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
543513
&constraints_channels_quad);
544514

545-
/*
546-
* Topology for kblda7219m98373 & kblmax98373 supports only S24_LE.
547-
* The DMIC also configured for S24_LE. Forcing the DMIC format to
548-
* S24_LE due to the topology FW dependency.
549-
*/
550-
if (!strcmp(soc_rt->card->name, "kblda7219m98373") ||
551-
!strcmp(soc_rt->card->name, "kblmax98373")) {
552-
runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_LE;
553-
snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
554-
}
555-
556515
return snd_pcm_hw_constraint_list(substream->runtime, 0,
557516
SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
558517
}

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

Lines changed: 98 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -472,22 +472,91 @@ static void skl_set_base_module_format(struct skl_dev *skl,
472472
base_cfg->is_pages = res->is_pages;
473473
}
474474

475+
static void fill_pin_params(struct skl_audio_data_format *pin_fmt,
476+
struct skl_module_fmt *format)
477+
{
478+
pin_fmt->number_of_channels = format->channels;
479+
pin_fmt->s_freq = format->s_freq;
480+
pin_fmt->bit_depth = format->bit_depth;
481+
pin_fmt->valid_bit_depth = format->valid_bit_depth;
482+
pin_fmt->ch_cfg = format->ch_cfg;
483+
pin_fmt->sample_type = format->sample_type;
484+
pin_fmt->channel_map = format->ch_map;
485+
pin_fmt->interleaving = format->interleaving_style;
486+
}
487+
488+
/*
489+
* Any module configuration begins with a base module configuration but
490+
* can be followed by a generic extension containing audio format for all
491+
* module's pins that are in use.
492+
*/
493+
static void skl_set_base_ext_module_format(struct skl_dev *skl,
494+
struct skl_module_cfg *mconfig,
495+
struct skl_base_cfg_ext *base_cfg_ext)
496+
{
497+
struct skl_module *module = mconfig->module;
498+
struct skl_module_pin_resources *pin_res;
499+
struct skl_module_iface *fmt = &module->formats[mconfig->fmt_idx];
500+
struct skl_module_res *res = &module->resources[mconfig->res_idx];
501+
struct skl_module_fmt *format;
502+
struct skl_pin_format *pin_fmt;
503+
char *params;
504+
int i;
505+
506+
base_cfg_ext->nr_input_pins = res->nr_input_pins;
507+
base_cfg_ext->nr_output_pins = res->nr_output_pins;
508+
base_cfg_ext->priv_param_length =
509+
mconfig->formats_config[SKL_PARAM_INIT].caps_size;
510+
511+
for (i = 0; i < res->nr_input_pins; i++) {
512+
pin_res = &res->input[i];
513+
pin_fmt = &base_cfg_ext->pins_fmt[i];
514+
515+
pin_fmt->pin_idx = pin_res->pin_index;
516+
pin_fmt->buf_size = pin_res->buf_size;
517+
518+
format = &fmt->inputs[pin_res->pin_index].fmt;
519+
fill_pin_params(&pin_fmt->audio_fmt, format);
520+
}
521+
522+
for (i = 0; i < res->nr_output_pins; i++) {
523+
pin_res = &res->output[i];
524+
pin_fmt = &base_cfg_ext->pins_fmt[res->nr_input_pins + i];
525+
526+
pin_fmt->pin_idx = pin_res->pin_index;
527+
pin_fmt->buf_size = pin_res->buf_size;
528+
529+
format = &fmt->outputs[pin_res->pin_index].fmt;
530+
fill_pin_params(&pin_fmt->audio_fmt, format);
531+
}
532+
533+
if (!base_cfg_ext->priv_param_length)
534+
return;
535+
536+
params = (char *)base_cfg_ext + sizeof(struct skl_base_cfg_ext);
537+
params += (base_cfg_ext->nr_input_pins + base_cfg_ext->nr_output_pins) *
538+
sizeof(struct skl_pin_format);
539+
540+
memcpy(params, mconfig->formats_config[SKL_PARAM_INIT].caps,
541+
mconfig->formats_config[SKL_PARAM_INIT].caps_size);
542+
}
543+
475544
/*
476545
* Copies copier capabilities into copier module and updates copier module
477546
* config size.
478547
*/
479548
static void skl_copy_copier_caps(struct skl_module_cfg *mconfig,
480549
struct skl_cpr_cfg *cpr_mconfig)
481550
{
482-
if (mconfig->formats_config.caps_size == 0)
551+
if (mconfig->formats_config[SKL_PARAM_INIT].caps_size == 0)
483552
return;
484553

485554
memcpy(cpr_mconfig->gtw_cfg.config_data,
486-
mconfig->formats_config.caps,
487-
mconfig->formats_config.caps_size);
555+
mconfig->formats_config[SKL_PARAM_INIT].caps,
556+
mconfig->formats_config[SKL_PARAM_INIT].caps_size);
488557

489558
cpr_mconfig->gtw_cfg.config_length =
490-
(mconfig->formats_config.caps_size) / 4;
559+
(mconfig->formats_config[SKL_PARAM_INIT].caps_size) / 4;
491560
}
492561

493562
#define SKL_NON_GATEWAY_CPR_NODE_ID 0xFFFFFFFF
@@ -737,28 +806,6 @@ static void skl_set_copier_format(struct skl_dev *skl,
737806
skl_setup_cpr_gateway_cfg(skl, mconfig, cpr_mconfig);
738807
}
739808

740-
/*
741-
* Algo module are DSP pre processing modules. Algo module take base module
742-
* configuration and params
743-
*/
744-
745-
static void skl_set_algo_format(struct skl_dev *skl,
746-
struct skl_module_cfg *mconfig,
747-
struct skl_algo_cfg *algo_mcfg)
748-
{
749-
struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)algo_mcfg;
750-
751-
skl_set_base_module_format(skl, mconfig, base_cfg);
752-
753-
if (mconfig->formats_config.caps_size == 0)
754-
return;
755-
756-
memcpy(algo_mcfg->params,
757-
mconfig->formats_config.caps,
758-
mconfig->formats_config.caps_size);
759-
760-
}
761-
762809
/*
763810
* Mic select module allows selecting one or many input channels, thus
764811
* acting as a demux.
@@ -781,12 +828,14 @@ static void skl_set_base_outfmt_format(struct skl_dev *skl,
781828
static u16 skl_get_module_param_size(struct skl_dev *skl,
782829
struct skl_module_cfg *mconfig)
783830
{
831+
struct skl_module_res *res;
832+
struct skl_module *module = mconfig->module;
784833
u16 param_size;
785834

786835
switch (mconfig->m_type) {
787836
case SKL_MODULE_TYPE_COPIER:
788837
param_size = sizeof(struct skl_cpr_cfg);
789-
param_size += mconfig->formats_config.caps_size;
838+
param_size += mconfig->formats_config[SKL_PARAM_INIT].caps_size;
790839
return param_size;
791840

792841
case SKL_MODULE_TYPE_SRCINT:
@@ -795,22 +844,24 @@ static u16 skl_get_module_param_size(struct skl_dev *skl,
795844
case SKL_MODULE_TYPE_UPDWMIX:
796845
return sizeof(struct skl_up_down_mixer_cfg);
797846

798-
case SKL_MODULE_TYPE_ALGO:
799-
param_size = sizeof(struct skl_base_cfg);
800-
param_size += mconfig->formats_config.caps_size;
801-
return param_size;
802-
803847
case SKL_MODULE_TYPE_BASE_OUTFMT:
804848
case SKL_MODULE_TYPE_MIC_SELECT:
805-
case SKL_MODULE_TYPE_KPB:
806849
return sizeof(struct skl_base_outfmt_cfg);
807850

808-
default:
809-
/*
810-
* return only base cfg when no specific module type is
811-
* specified
812-
*/
851+
case SKL_MODULE_TYPE_MIXER:
852+
case SKL_MODULE_TYPE_KPB:
813853
return sizeof(struct skl_base_cfg);
854+
855+
case SKL_MODULE_TYPE_ALGO:
856+
default:
857+
res = &module->resources[mconfig->res_idx];
858+
859+
param_size = sizeof(struct skl_base_cfg) + sizeof(struct skl_base_cfg_ext);
860+
param_size += (res->nr_input_pins + res->nr_output_pins) *
861+
sizeof(struct skl_pin_format);
862+
param_size += mconfig->formats_config[SKL_PARAM_INIT].caps_size;
863+
864+
return param_size;
814865
}
815866

816867
return 0;
@@ -851,20 +902,23 @@ static int skl_set_module_format(struct skl_dev *skl,
851902
skl_set_updown_mixer_format(skl, module_config, *param_data);
852903
break;
853904

854-
case SKL_MODULE_TYPE_ALGO:
855-
skl_set_algo_format(skl, module_config, *param_data);
856-
break;
857-
858905
case SKL_MODULE_TYPE_BASE_OUTFMT:
859906
case SKL_MODULE_TYPE_MIC_SELECT:
860-
case SKL_MODULE_TYPE_KPB:
861907
skl_set_base_outfmt_format(skl, module_config, *param_data);
862908
break;
863909

864-
default:
910+
case SKL_MODULE_TYPE_MIXER:
911+
case SKL_MODULE_TYPE_KPB:
865912
skl_set_base_module_format(skl, module_config, *param_data);
866913
break;
867914

915+
case SKL_MODULE_TYPE_ALGO:
916+
default:
917+
skl_set_base_module_format(skl, module_config, *param_data);
918+
skl_set_base_ext_module_format(skl, module_config,
919+
*param_data +
920+
sizeof(struct skl_base_cfg));
921+
break;
868922
}
869923

870924
dev_dbg(skl->dev, "Module type=%d id=%d config size: %d bytes\n",
@@ -1085,19 +1139,6 @@ int skl_unbind_modules(struct skl_dev *skl,
10851139
return ret;
10861140
}
10871141

1088-
static void fill_pin_params(struct skl_audio_data_format *pin_fmt,
1089-
struct skl_module_fmt *format)
1090-
{
1091-
pin_fmt->number_of_channels = format->channels;
1092-
pin_fmt->s_freq = format->s_freq;
1093-
pin_fmt->bit_depth = format->bit_depth;
1094-
pin_fmt->valid_bit_depth = format->valid_bit_depth;
1095-
pin_fmt->ch_cfg = format->ch_cfg;
1096-
pin_fmt->sample_type = format->sample_type;
1097-
pin_fmt->channel_map = format->ch_map;
1098-
pin_fmt->interleaving = format->interleaving_style;
1099-
}
1100-
11011142
#define CPR_SINK_FMT_PARAM_ID 2
11021143

11031144
/*

0 commit comments

Comments
 (0)