ASoC: Intel: sof_sdw: add controls and dapm widgets in codec_info
Currently, we add card controls and dapm widgets one by one in the codec_info->dais->rtd_init callback. Duplicated controls and dapm widgets will be added if there are more than one types of amps in the dai link. Moving it to sof_sdw_rtd_init() and only add the controls/widgets of the first codec dai can avoid the duplications. Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.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/20240509163418.67746-16-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
01c266af92
commit
70d470f05f
@ -1248,6 +1248,7 @@ static const char *get_codec_name(struct device *dev,
|
||||
|
||||
static int sof_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct sof_sdw_codec_info *codec_info;
|
||||
struct snd_soc_dai *dai;
|
||||
int dai_index;
|
||||
@ -1267,6 +1268,36 @@ static int sof_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd)
|
||||
*/
|
||||
if (codec_info->dais[dai_index].rtd_init_done)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Add card controls and dapm widgets for the first codec dai.
|
||||
* The controls and widgets will be used for all codec dais.
|
||||
*/
|
||||
|
||||
if (i > 0)
|
||||
goto skip_add_controls_widgets;
|
||||
|
||||
if (codec_info->dais[dai_index].controls) {
|
||||
ret = snd_soc_add_card_controls(card, codec_info->dais[dai_index].controls,
|
||||
codec_info->dais[dai_index].num_controls);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "%#x controls addition failed: %d\n",
|
||||
codec_info->part_id, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (codec_info->dais[dai_index].widgets) {
|
||||
ret = snd_soc_dapm_new_controls(&card->dapm,
|
||||
codec_info->dais[dai_index].widgets,
|
||||
codec_info->dais[dai_index].num_widgets);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "%#x widgets addition failed: %d\n",
|
||||
codec_info->part_id, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
skip_add_controls_widgets:
|
||||
if (codec_info->dais[dai_index].rtd_init) {
|
||||
ret = codec_info->dais[dai_index].rtd_init(rtd);
|
||||
if (ret)
|
||||
|
@ -86,6 +86,10 @@ struct sof_sdw_dai_info {
|
||||
const char *dai_name;
|
||||
const int dai_type;
|
||||
const int dailink[2]; /* dailink id for each direction */
|
||||
const struct snd_kcontrol_new *controls;
|
||||
const int num_controls;
|
||||
const struct snd_soc_dapm_widget *widgets;
|
||||
const int num_widgets;
|
||||
int (*init)(struct snd_soc_card *card,
|
||||
struct snd_soc_dai_link *dai_links,
|
||||
struct sof_sdw_codec_info *info,
|
||||
|
Loading…
x
Reference in New Issue
Block a user