From ab148aa550faf8cfcb71a6ad20af35adb4cefdf6 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 30 Mar 2020 11:23:48 +0800 Subject: [PATCH 1/3] ASoC: intel: sof_sdw_rt1308: amp_num should be += num_codecs The amp_num represents the number of amps. A dai link may have more than one amp. So amp_num should += the number of amps in the dai link. Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_sdw_rt1308.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/sof_sdw_rt1308.c b/sound/soc/intel/boards/sof_sdw_rt1308.c index 321768e54d08a0..9385bcab9fd83a 100644 --- a/sound/soc/intel/boards/sof_sdw_rt1308.c +++ b/sound/soc/intel/boards/sof_sdw_rt1308.c @@ -130,7 +130,7 @@ int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link, struct sof_sdw_codec_info *info, bool playback) { - info->amp_num++; + info->amp_num += dai_links->num_codecs; if (info->amp_num == 1) dai_links->init = first_spk_init; From ce6352b90771c6b5a64aa7efb77dc4aa80e3cd3e Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 30 Mar 2020 11:28:37 +0800 Subject: [PATCH 2/3] ASoC: intel: sof_sdw_rt1308: Use dai_links->num_codecs to test which spk_init should be use It is more readable to test dai_links->num_codecs than dai_links->init. Also, sof_sdw_rt1308_init() will be called once if two rt1308s are aggregated. Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_sdw_rt1308.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw_rt1308.c b/sound/soc/intel/boards/sof_sdw_rt1308.c index 9385bcab9fd83a..00f689c457803f 100644 --- a/sound/soc/intel/boards/sof_sdw_rt1308.c +++ b/sound/soc/intel/boards/sof_sdw_rt1308.c @@ -136,12 +136,11 @@ int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link, if (info->amp_num == 2) { /* - * if two 1308s are in one dai link, the init function - * in this dai link will be first set for the first speaker, - * and it should be reset to initialize all speakers when - * the second speaker is found. + * if dai_links->num_codecs = 2, it implies that 2 rt1308s + * are in the same dai link. Otherwise they will be in 2 + * dai links. */ - if (dai_links->init) + if (dai_links->num_codecs == 2) dai_links->init = all_spk_init; else dai_links->init = second_spk_init; From 16d51317f1862f97c733f80ee2f61d8349a9adb9 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 30 Mar 2020 15:36:54 +0800 Subject: [PATCH 3/3] ASoC: intel: sof_sdw: No need to call codec init one by one in the same dailink The only reason that we do that is to calculate how many rt1308s do we have. However, we can get the number by dailinks->num_codecs. Now, we increase rt1308 amp_num by += num_codecs. So we can do codec init in each dailink now. Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_sdw.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index a64dc563b47e1b..28f4f328cecbfe 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -409,27 +409,23 @@ static int create_codec_dai_name(struct device *dev, return 0; } -static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link, +static int set_dailink_init_func(const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, bool playback) { - int i; - - for (i = 0; i < link->num_adr; i++) { - unsigned int part_id; - int codec_index; + 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); + part_id = SDW_PART_ID(link->adr_d[0].adr); + codec_index = find_codec_info_part(part_id); - if (codec_index < 0) - return codec_index; + if (codec_index < 0) + return codec_index; - if (codec_info_list[codec_index].init) - codec_info_list[codec_index].init(link, dai_links, - &codec_info_list[codec_index], - playback); - } + if (codec_info_list[codec_index].init) + codec_info_list[codec_index].init(link, dai_links, + &codec_info_list[codec_index], + playback); return 0; } @@ -622,8 +618,8 @@ static int create_sdw_dailink(struct device *dev, int *be_index, codecs, codec_num, NULL, &sdw_ops); - ret = set_codec_init_func(link, dai_links + (*be_index)++, - playback); + ret = set_dailink_init_func(link, dai_links + (*be_index)++, + playback); if (ret < 0) { dev_err(dev, "failed to init codec %d", codec_index); return ret;