diff options
Diffstat (limited to 'sound/soc/intel/boards/sof_sdw.c')
-rw-r--r-- | sound/soc/intel/boards/sof_sdw.c | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index a64dc563b47e..e1c1a8ba78e6 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0-only // Copyright (c) 2020 Intel Corporation /* @@ -411,25 +411,36 @@ static int create_codec_dai_name(struct device *dev, static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, - bool playback) + bool playback, int group_id) { int i; - for (i = 0; i < link->num_adr; i++) { - unsigned int part_id; - int codec_index; - - part_id = SDW_PART_ID(link->adr_d[i].adr); - codec_index = find_codec_info_part(part_id); + do { + /* + * Initialize the codec. If codec is part of an aggregated + * group (group_id>0), initialize all codecs belonging to + * same group. + */ + for (i = 0; i < link->num_adr; i++) { + unsigned int part_id; + int codec_index; - if (codec_index < 0) - return codec_index; + part_id = SDW_PART_ID(link->adr_d[i].adr); + codec_index = find_codec_info_part(part_id); - if (codec_info_list[codec_index].init) - codec_info_list[codec_index].init(link, dai_links, - &codec_info_list[codec_index], - playback); - } + if (codec_index < 0) + return codec_index; + /* The group_id is > 0 iff the codec is aggregated */ + if (link->adr_d[i].endpoints->group_id != group_id) + continue; + if (codec_info_list[codec_index].init) + codec_info_list[codec_index].init(link, + dai_links, + &codec_info_list[codec_index], + playback); + } + link++; + } while (link->mask && group_id); return 0; } @@ -623,7 +634,7 @@ static int create_sdw_dailink(struct device *dev, int *be_index, NULL, &sdw_ops); ret = set_codec_init_func(link, dai_links + (*be_index)++, - playback); + playback, group_id); if (ret < 0) { dev_err(dev, "failed to init codec %d", codec_index); return ret; @@ -652,9 +663,7 @@ static int sof_card_dai_links_create(struct device *dev, struct snd_soc_card *card) { int ssp_num, sdw_be_num = 0, hdmi_num = 0, dmic_num; -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) struct snd_soc_dai_link_component *idisp_components; -#endif struct snd_soc_dai_link_component *ssp_components; struct snd_soc_acpi_mach_params *mach_params; const struct snd_soc_acpi_link_adr *adr_link; @@ -675,10 +684,8 @@ static int sof_card_dai_links_create(struct device *dev, for (i = 0; i < ARRAY_SIZE(codec_info_list); i++) codec_info_list[i].amp_num = 0; -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) hdmi_num = sof_sdw_quirk & SOF_SDW_TGL_HDMI ? SOF_TGL_HDMI_COUNT : SOF_PRE_TGL_HDMI_COUNT; -#endif ssp_mask = SOF_SSP_GET_PORT(sof_sdw_quirk); /* @@ -838,7 +845,6 @@ DMIC: INC_ID(be_id, cpu_id, link_id); } -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) /* HDMI */ if (hdmi_num > 0) { idisp_components = devm_kcalloc(dev, hdmi_num, @@ -875,7 +881,6 @@ DMIC: sof_sdw_hdmi_init, NULL); INC_ID(be_id, cpu_id, link_id); } -#endif card->dai_link = links; card->num_links = num_links; @@ -898,6 +903,7 @@ static int mc_probe(struct platform_device *pdev) struct snd_soc_card *card = &card_sof_sdw; struct snd_soc_acpi_mach *mach; struct mc_private *ctx; + int amp_num = 0, i; int ret; dev_dbg(&pdev->dev, "Entry %s\n", __func__); @@ -908,9 +914,7 @@ static int mc_probe(struct platform_device *pdev) dmi_check_system(sof_sdw_quirk_table); -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) INIT_LIST_HEAD(&ctx->hdmi_pcm_list); -#endif card->dev = &pdev->dev; @@ -924,9 +928,18 @@ static int mc_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(card, ctx); + /* + * the default amp_num is zero for each codec and + * amp_num will only be increased for active amp + * codecs on used platform + */ + for (i = 0; i < ARRAY_SIZE(codec_info_list); i++) + amp_num += codec_info_list[i].amp_num; + card->components = devm_kasprintf(card->dev, GFP_KERNEL, - "cfg-spk:%d", - (sof_sdw_quirk & SOF_SDW_FOUR_SPK) ? 4 : 2); + "cfg-spk:%d cfg-amp:%d", + (sof_sdw_quirk & SOF_SDW_FOUR_SPK) + ? 4 : 2, amp_num); if (!card->components) return -ENOMEM; |