1

ASoC: Intel: sof_sdw: use single rtd_init for rt_amps

2 amps can be in the same or different dai links. To handle this, the
existing code implements different spk_init functions to add dapm routes
for different amps. However, sof_sdw.c doesn't support non-aggregated
amp any more since it used pre-defined BE id.
With that assumption, combine the spk_init functions together.
This is a preparation of putting different types amps in a single dai
link.

Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20240208165545.93811-10-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Bard Liao 2024-02-08 10:55:30 -06:00 committed by Mark Brown
parent 1ad55ee7b5
commit 9f3763b362
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -185,12 +185,14 @@ static const struct snd_soc_dapm_route *get_codec_name_and_route(struct snd_soc_
return rt1318_map;
}
static int first_spk_init(struct snd_soc_pcm_runtime *rtd)
static int rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
const struct snd_soc_dapm_route *rt_amp_map;
char codec_name[CODEC_NAME_SIZE];
struct snd_soc_dai *dai;
int ret;
int i;
rt_amp_map = get_codec_name_and_route(rtd, codec_name);
@ -214,38 +216,14 @@ static int first_spk_init(struct snd_soc_pcm_runtime *rtd)
return ret;
}
for_each_rtd_codec_dais(rtd, i, dai) {
if (strstr(dai->component->name_prefix, "-1"))
ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map, 2);
if (ret)
dev_err(rtd->dev, "failed to add first SPK map: %d\n", ret);
return ret;
}
static int second_spk_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
const struct snd_soc_dapm_route *rt_amp_map;
char codec_name[CODEC_NAME_SIZE];
int ret;
rt_amp_map = get_codec_name_and_route(rtd, codec_name);
else if (strstr(dai->component->name_prefix, "-2"))
ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map + 2, 2);
if (ret)
dev_err(rtd->dev, "failed to add second SPK map: %d\n", ret);
return ret;
}
static int all_spk_init(struct snd_soc_pcm_runtime *rtd)
{
int ret;
ret = first_spk_init(rtd);
if (ret)
return ret;
return second_spk_init(rtd);
}
static int rt1308_i2s_hw_params(struct snd_pcm_substream *substream,
@ -317,8 +295,7 @@ int sof_sdw_rt_amp_init(struct snd_soc_card *card,
return 0;
info->amp_num++;
if (info->amp_num == 1)
dai_links->init = first_spk_init;
dai_links->init = rt_amp_spk_rtd_init;
if (info->amp_num == 2) {
sdw_dev1 = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[0].name);
@ -342,17 +319,6 @@ int sof_sdw_rt_amp_init(struct snd_soc_card *card,
return ret;
}
ctx->amp_dev2 = sdw_dev2;
/*
* if two amps 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->init)
dai_links->init = all_spk_init;
else
dai_links->init = second_spk_init;
}
return 0;