Commit 2e3bc947 authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: Intel: sof_sdw: use .controls/.widgets to add controls/widgets

sof_sdw_rtd_init() will add the controls and widgets if we set them in
the codec_info. Move the additions from .rtd_init callback to
sof_sdw_rtd_init().
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20240509163418.67746-17-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 70d470f0
...@@ -515,6 +515,50 @@ static struct snd_soc_dai_link_component platform_component[] = { ...@@ -515,6 +515,50 @@ static struct snd_soc_dai_link_component platform_component[] = {
} }
}; };
static const struct snd_soc_dapm_widget generic_dmic_widgets[] = {
SND_SOC_DAPM_MIC("DMIC", NULL),
};
static const struct snd_soc_dapm_widget generic_jack_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
};
static const struct snd_kcontrol_new generic_jack_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
};
static const struct snd_soc_dapm_widget generic_spk_widgets[] = {
SND_SOC_DAPM_SPK("Speaker", NULL),
};
static const struct snd_kcontrol_new generic_spk_controls[] = {
SOC_DAPM_PIN_SWITCH("Speaker"),
};
static const struct snd_soc_dapm_widget maxim_widgets[] = {
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};
static const struct snd_kcontrol_new maxim_controls[] = {
SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"),
};
static const struct snd_soc_dapm_widget rt700_widgets[] = {
SND_SOC_DAPM_HP("Headphones", NULL),
SND_SOC_DAPM_MIC("AMIC", NULL),
SND_SOC_DAPM_SPK("Speaker", NULL),
};
static const struct snd_kcontrol_new rt700_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphones"),
SOC_DAPM_PIN_SWITCH("AMIC"),
SOC_DAPM_PIN_SWITCH("Speaker"),
};
struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd,
const char * const dai_name[], const char * const dai_name[],
int num_dais) int num_dais)
...@@ -681,6 +725,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -681,6 +725,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID}, .dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.rtd_init = rt700_rtd_init, .rtd_init = rt700_rtd_init,
.controls = rt700_controls,
.num_controls = ARRAY_SIZE(rt700_controls),
.widgets = rt700_widgets,
.num_widgets = ARRAY_SIZE(rt700_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -697,6 +745,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -697,6 +745,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_sdca_jack_init, .init = sof_sdw_rt_sdca_jack_init,
.exit = sof_sdw_rt_sdca_jack_exit, .exit = sof_sdw_rt_sdca_jack_exit,
.rtd_init = rt_sdca_jack_rtd_init, .rtd_init = rt_sdca_jack_rtd_init,
.controls = generic_jack_controls,
.num_controls = ARRAY_SIZE(generic_jack_controls),
.widgets = generic_jack_widgets,
.num_widgets = ARRAY_SIZE(generic_jack_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -713,6 +765,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -713,6 +765,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt711_init, .init = sof_sdw_rt711_init,
.exit = sof_sdw_rt711_exit, .exit = sof_sdw_rt711_exit,
.rtd_init = rt711_rtd_init, .rtd_init = rt711_rtd_init,
.controls = generic_jack_controls,
.num_controls = ARRAY_SIZE(generic_jack_controls),
.widgets = generic_jack_widgets,
.num_widgets = ARRAY_SIZE(generic_jack_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -729,6 +785,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -729,6 +785,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_sdca_jack_init, .init = sof_sdw_rt_sdca_jack_init,
.exit = sof_sdw_rt_sdca_jack_exit, .exit = sof_sdw_rt_sdca_jack_exit,
.rtd_init = rt_sdca_jack_rtd_init, .rtd_init = rt_sdca_jack_rtd_init,
.controls = generic_jack_controls,
.num_controls = ARRAY_SIZE(generic_jack_controls),
.widgets = generic_jack_widgets,
.num_widgets = ARRAY_SIZE(generic_jack_widgets),
}, },
{ {
.direction = {true, false}, .direction = {true, false},
...@@ -738,6 +798,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -738,6 +798,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_amp_init, .init = sof_sdw_rt_amp_init,
.exit = sof_sdw_rt_amp_exit, .exit = sof_sdw_rt_amp_exit,
.rtd_init = rt712_spk_rtd_init, .rtd_init = rt712_spk_rtd_init,
.controls = generic_spk_controls,
.num_controls = ARRAY_SIZE(generic_spk_controls),
.widgets = generic_spk_widgets,
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
}, },
}, },
.dai_num = 2, .dai_num = 2,
...@@ -768,6 +832,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -768,6 +832,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_sdca_jack_init, .init = sof_sdw_rt_sdca_jack_init,
.exit = sof_sdw_rt_sdca_jack_exit, .exit = sof_sdw_rt_sdca_jack_exit,
.rtd_init = rt_sdca_jack_rtd_init, .rtd_init = rt_sdca_jack_rtd_init,
.controls = generic_jack_controls,
.num_controls = ARRAY_SIZE(generic_jack_controls),
.widgets = generic_jack_widgets,
.num_widgets = ARRAY_SIZE(generic_jack_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -798,6 +866,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -798,6 +866,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_amp_init, .init = sof_sdw_rt_amp_init,
.exit = sof_sdw_rt_amp_exit, .exit = sof_sdw_rt_amp_exit,
.rtd_init = rt_amp_spk_rtd_init, .rtd_init = rt_amp_spk_rtd_init,
.controls = generic_spk_controls,
.num_controls = ARRAY_SIZE(generic_spk_controls),
.widgets = generic_spk_widgets,
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -814,6 +886,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -814,6 +886,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_amp_init, .init = sof_sdw_rt_amp_init,
.exit = sof_sdw_rt_amp_exit, .exit = sof_sdw_rt_amp_exit,
.rtd_init = rt_amp_spk_rtd_init, .rtd_init = rt_amp_spk_rtd_init,
.controls = generic_spk_controls,
.num_controls = ARRAY_SIZE(generic_spk_controls),
.widgets = generic_spk_widgets,
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -829,6 +905,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -829,6 +905,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_amp_init, .init = sof_sdw_rt_amp_init,
.exit = sof_sdw_rt_amp_exit, .exit = sof_sdw_rt_amp_exit,
.rtd_init = rt_amp_spk_rtd_init, .rtd_init = rt_amp_spk_rtd_init,
.controls = generic_spk_controls,
.num_controls = ARRAY_SIZE(generic_spk_controls),
.widgets = generic_spk_widgets,
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -905,6 +985,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -905,6 +985,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_sdca_jack_init, .init = sof_sdw_rt_sdca_jack_init,
.exit = sof_sdw_rt_sdca_jack_exit, .exit = sof_sdw_rt_sdca_jack_exit,
.rtd_init = rt_sdca_jack_rtd_init, .rtd_init = rt_sdca_jack_rtd_init,
.controls = generic_jack_controls,
.num_controls = ARRAY_SIZE(generic_jack_controls),
.widgets = generic_jack_widgets,
.num_widgets = ARRAY_SIZE(generic_jack_widgets),
}, },
{ {
.direction = {true, false}, .direction = {true, false},
...@@ -915,6 +999,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -915,6 +999,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.init = sof_sdw_rt_amp_init, .init = sof_sdw_rt_amp_init,
.exit = sof_sdw_rt_amp_exit, .exit = sof_sdw_rt_amp_exit,
.rtd_init = rt722_spk_rtd_init, .rtd_init = rt722_spk_rtd_init,
.controls = generic_spk_controls,
.num_controls = ARRAY_SIZE(generic_spk_controls),
.widgets = generic_spk_widgets,
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
}, },
{ {
.direction = {false, true}, .direction = {false, true},
...@@ -936,6 +1024,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -936,6 +1024,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID}, .dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID},
.init = sof_sdw_maxim_init, .init = sof_sdw_maxim_init,
.rtd_init = maxim_spk_rtd_init, .rtd_init = maxim_spk_rtd_init,
.controls = maxim_controls,
.num_controls = ARRAY_SIZE(maxim_controls),
.widgets = maxim_widgets,
.num_widgets = ARRAY_SIZE(maxim_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -950,6 +1042,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -950,6 +1042,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_UNUSED_DAI_ID}, .dailink = {SDW_AMP_OUT_DAI_ID, SDW_UNUSED_DAI_ID},
.init = sof_sdw_maxim_init, .init = sof_sdw_maxim_init,
.rtd_init = maxim_spk_rtd_init, .rtd_init = maxim_spk_rtd_init,
.controls = maxim_controls,
.num_controls = ARRAY_SIZE(maxim_controls),
.widgets = maxim_widgets,
.num_widgets = ARRAY_SIZE(maxim_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -963,6 +1059,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -963,6 +1059,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID}, .dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.rtd_init = rt5682_rtd_init, .rtd_init = rt5682_rtd_init,
.controls = generic_jack_controls,
.num_controls = ARRAY_SIZE(generic_jack_controls),
.widgets = generic_jack_widgets,
.num_widgets = ARRAY_SIZE(generic_jack_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -977,6 +1077,8 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -977,6 +1077,8 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID}, .dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID},
.init = sof_sdw_cs_amp_init, .init = sof_sdw_cs_amp_init,
.rtd_init = cs_spk_rtd_init, .rtd_init = cs_spk_rtd_init,
.widgets = generic_spk_widgets,
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -990,6 +1092,10 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -990,6 +1092,10 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID}, .dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.rtd_init = cs42l42_rtd_init, .rtd_init = cs42l42_rtd_init,
.controls = generic_jack_controls,
.num_controls = ARRAY_SIZE(generic_jack_controls),
.widgets = generic_jack_widgets,
.num_widgets = ARRAY_SIZE(generic_jack_widgets),
}, },
}, },
.dai_num = 1, .dai_num = 1,
...@@ -1006,6 +1112,8 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -1006,6 +1112,8 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_UNUSED_DAI_ID}, .dailink = {SDW_JACK_OUT_DAI_ID, SDW_UNUSED_DAI_ID},
.rtd_init = cs42l43_hs_rtd_init, .rtd_init = cs42l43_hs_rtd_init,
.widgets = generic_jack_widgets,
.num_widgets = ARRAY_SIZE(generic_jack_widgets),
}, },
{ {
.direction = {false, true}, .direction = {false, true},
...@@ -1013,6 +1121,8 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -1013,6 +1121,8 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_type = SOF_SDW_DAI_TYPE_MIC, .dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID}, .dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.rtd_init = cs42l43_dmic_rtd_init, .rtd_init = cs42l43_dmic_rtd_init,
.widgets = generic_dmic_widgets,
.num_widgets = ARRAY_SIZE(generic_dmic_widgets),
}, },
{ {
.direction = {false, true}, .direction = {false, true},
...@@ -1027,6 +1137,8 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -1027,6 +1137,8 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_UNUSED_DAI_ID}, .dailink = {SDW_AMP_OUT_DAI_ID, SDW_UNUSED_DAI_ID},
.init = sof_sdw_cs42l43_spk_init, .init = sof_sdw_cs42l43_spk_init,
.rtd_init = cs42l43_spk_rtd_init, .rtd_init = cs42l43_spk_rtd_init,
.widgets = generic_spk_widgets,
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
.quirk = SOF_CODEC_SPKR | SOF_SIDECAR_AMPS, .quirk = SOF_CODEC_SPKR | SOF_SIDECAR_AMPS,
}, },
}, },
......
...@@ -17,11 +17,6 @@ ...@@ -17,11 +17,6 @@
#include <sound/jack.h> #include <sound/jack.h>
#include "sof_sdw_common.h" #include "sof_sdw_common.h"
static const struct snd_soc_dapm_widget generic_jack_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
};
static const struct snd_soc_dapm_route cs42l42_map[] = { static const struct snd_soc_dapm_route cs42l42_map[] = {
/* HP jack connectors - unknown if we have jack detection */ /* HP jack connectors - unknown if we have jack detection */
{"Headphone", NULL, "cs42l42 HP"}, {"Headphone", NULL, "cs42l42 HP"},
...@@ -30,11 +25,6 @@ static const struct snd_soc_dapm_route cs42l42_map[] = { ...@@ -30,11 +25,6 @@ static const struct snd_soc_dapm_route cs42l42_map[] = {
{"cs42l42 HS", NULL, "Headset Mic"}, {"cs42l42 HS", NULL, "Headset Mic"},
}; };
static const struct snd_kcontrol_new generic_jack_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
};
static struct snd_soc_jack_pin cs42l42_jack_pins[] = { static struct snd_soc_jack_pin cs42l42_jack_pins[] = {
{ {
.pin = "Headphone", .pin = "Headphone",
...@@ -70,20 +60,6 @@ int cs42l42_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -70,20 +60,6 @@ int cs42l42_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_add_card_controls(card, generic_jack_controls,
ARRAY_SIZE(generic_jack_controls));
if (ret) {
dev_err(card->dev, "cs42l42 control addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, generic_jack_widgets,
ARRAY_SIZE(generic_jack_widgets));
if (ret) {
dev_err(card->dev, "cs42l42 widgets addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, cs42l42_map, ret = snd_soc_dapm_add_routes(&card->dapm, cs42l42_map,
ARRAY_SIZE(cs42l42_map)); ARRAY_SIZE(cs42l42_map));
......
...@@ -18,11 +18,6 @@ ...@@ -18,11 +18,6 @@
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include "sof_sdw_common.h" #include "sof_sdw_common.h"
static const struct snd_soc_dapm_widget generic_jack_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
};
static const struct snd_soc_dapm_route cs42l43_hs_map[] = { static const struct snd_soc_dapm_route cs42l43_hs_map[] = {
{ "Headphone", NULL, "cs42l43 AMP3_OUT" }, { "Headphone", NULL, "cs42l43 AMP3_OUT" },
{ "Headphone", NULL, "cs42l43 AMP4_OUT" }, { "Headphone", NULL, "cs42l43 AMP4_OUT" },
...@@ -30,10 +25,6 @@ static const struct snd_soc_dapm_route cs42l43_hs_map[] = { ...@@ -30,10 +25,6 @@ static const struct snd_soc_dapm_route cs42l43_hs_map[] = {
{ "cs42l43 ADC1_IN1_N", NULL, "Headset Mic" }, { "cs42l43 ADC1_IN1_N", NULL, "Headset Mic" },
}; };
static const struct snd_soc_dapm_widget generic_spk_widgets[] = {
SND_SOC_DAPM_SPK("Speaker", NULL),
};
static const struct snd_soc_dapm_route cs42l43_spk_map[] = { static const struct snd_soc_dapm_route cs42l43_spk_map[] = {
{ "Speaker", NULL, "cs42l43 AMP1_OUT_P", }, { "Speaker", NULL, "cs42l43 AMP1_OUT_P", },
{ "Speaker", NULL, "cs42l43 AMP1_OUT_N", }, { "Speaker", NULL, "cs42l43 AMP1_OUT_N", },
...@@ -41,10 +32,6 @@ static const struct snd_soc_dapm_route cs42l43_spk_map[] = { ...@@ -41,10 +32,6 @@ static const struct snd_soc_dapm_route cs42l43_spk_map[] = {
{ "Speaker", NULL, "cs42l43 AMP2_OUT_N", }, { "Speaker", NULL, "cs42l43 AMP2_OUT_N", },
}; };
static const struct snd_soc_dapm_widget generic_dmic_widgets[] = {
SND_SOC_DAPM_MIC("DMIC", NULL),
};
static const struct snd_soc_dapm_route cs42l43_dmic_map[] = { static const struct snd_soc_dapm_route cs42l43_dmic_map[] = {
{ "cs42l43 PDM1_DIN", NULL, "DMIC" }, { "cs42l43 PDM1_DIN", NULL, "DMIC" },
{ "cs42l43 PDM2_DIN", NULL, "DMIC" }, { "cs42l43 PDM2_DIN", NULL, "DMIC" },
...@@ -74,13 +61,6 @@ int cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -74,13 +61,6 @@ int cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_dapm_new_controls(&card->dapm, generic_jack_widgets,
ARRAY_SIZE(generic_jack_widgets));
if (ret) {
dev_err(card->dev, "cs42l43 hs widgets addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, cs42l43_hs_map, ret = snd_soc_dapm_add_routes(&card->dapm, cs42l43_hs_map,
ARRAY_SIZE(cs42l43_hs_map)); ARRAY_SIZE(cs42l43_hs_map));
if (ret) { if (ret) {
...@@ -133,13 +113,6 @@ int cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -133,13 +113,6 @@ int cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
return -ENOMEM; return -ENOMEM;
} }
ret = snd_soc_dapm_new_controls(&card->dapm, generic_spk_widgets,
ARRAY_SIZE(generic_spk_widgets));
if (ret) {
dev_err(card->dev, "cs42l43 speaker widgets addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, cs42l43_spk_map, ret = snd_soc_dapm_add_routes(&card->dapm, cs42l43_spk_map,
ARRAY_SIZE(cs42l43_spk_map)); ARRAY_SIZE(cs42l43_spk_map));
if (ret) if (ret)
...@@ -172,13 +145,6 @@ int cs42l43_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -172,13 +145,6 @@ int cs42l43_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_dapm_new_controls(&card->dapm, generic_dmic_widgets,
ARRAY_SIZE(generic_dmic_widgets));
if (ret) {
dev_err(card->dev, "cs42l43 dmic widgets addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, cs42l43_dmic_map, ret = snd_soc_dapm_add_routes(&card->dapm, cs42l43_dmic_map,
ARRAY_SIZE(cs42l43_dmic_map)); ARRAY_SIZE(cs42l43_dmic_map));
if (ret) if (ret)
......
...@@ -14,10 +14,6 @@ ...@@ -14,10 +14,6 @@
#define CODEC_NAME_SIZE 8 #define CODEC_NAME_SIZE 8
static const struct snd_soc_dapm_widget generic_spk_widgets[] = {
SND_SOC_DAPM_SPK("Speaker", NULL),
};
int cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) int cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
{ {
const char *dai_name = rtd->dai_link->codecs->dai_name; const char *dai_name = rtd->dai_link->codecs->dai_name;
...@@ -35,13 +31,6 @@ int cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -35,13 +31,6 @@ int cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_dapm_new_controls(&card->dapm, generic_spk_widgets,
ARRAY_SIZE(generic_spk_widgets));
if (ret) {
dev_err(card->dev, "widgets addition failed: %d\n", ret);
return ret;
}
for_each_rtd_codec_dais(rtd, i, codec_dai) { for_each_rtd_codec_dais(rtd, i, codec_dai) {
if (!strstr(codec_dai->name, "cs35l56")) if (!strstr(codec_dai->name, "cs35l56"))
continue; continue;
......
...@@ -16,16 +16,6 @@ static int maxim_part_id; ...@@ -16,16 +16,6 @@ static int maxim_part_id;
#define SOF_SDW_PART_ID_MAX98363 0x8363 #define SOF_SDW_PART_ID_MAX98363 0x8363
#define SOF_SDW_PART_ID_MAX98373 0x8373 #define SOF_SDW_PART_ID_MAX98373 0x8373
static const struct snd_soc_dapm_widget maxim_widgets[] = {
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};
static const struct snd_kcontrol_new maxim_controls[] = {
SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"),
};
static const struct snd_soc_dapm_route max_98373_dapm_routes[] = { static const struct snd_soc_dapm_route max_98373_dapm_routes[] = {
{ "Left Spk", NULL, "Left BE_OUT" }, { "Left Spk", NULL, "Left BE_OUT" },
{ "Right Spk", NULL, "Right BE_OUT" }, { "Right Spk", NULL, "Right BE_OUT" },
...@@ -45,20 +35,6 @@ int maxim_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -45,20 +35,6 @@ int maxim_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
dev_dbg(card->dev, "soundwire maxim card components assigned : %s\n", dev_dbg(card->dev, "soundwire maxim card components assigned : %s\n",
card->components); card->components);
ret = snd_soc_add_card_controls(card, maxim_controls,
ARRAY_SIZE(maxim_controls));
if (ret) {
dev_err(card->dev, "mx%04x ctrls addition failed: %d\n", maxim_part_id, ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, maxim_widgets,
ARRAY_SIZE(maxim_widgets));
if (ret) {
dev_err(card->dev, "mx%04x widgets addition failed: %d\n", maxim_part_id, ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, max_98373_dapm_routes, 2); ret = snd_soc_dapm_add_routes(&card->dapm, max_98373_dapm_routes, 2);
if (ret) if (ret)
dev_err(rtd->dev, "failed to add first SPK map: %d\n", ret); dev_err(rtd->dev, "failed to add first SPK map: %d\n", ret);
......
...@@ -17,11 +17,6 @@ ...@@ -17,11 +17,6 @@
#include <sound/jack.h> #include <sound/jack.h>
#include "sof_sdw_common.h" #include "sof_sdw_common.h"
static const struct snd_soc_dapm_widget generic_jack_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
};
static const struct snd_soc_dapm_route rt5682_map[] = { static const struct snd_soc_dapm_route rt5682_map[] = {
/*Headphones*/ /*Headphones*/
{ "Headphone", NULL, "rt5682 HPOL" }, { "Headphone", NULL, "rt5682 HPOL" },
...@@ -29,11 +24,6 @@ static const struct snd_soc_dapm_route rt5682_map[] = { ...@@ -29,11 +24,6 @@ static const struct snd_soc_dapm_route rt5682_map[] = {
{ "rt5682 IN1P", NULL, "Headset Mic" }, { "rt5682 IN1P", NULL, "Headset Mic" },
}; };
static const struct snd_kcontrol_new generic_jack_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
};
static struct snd_soc_jack_pin rt5682_jack_pins[] = { static struct snd_soc_jack_pin rt5682_jack_pins[] = {
{ {
.pin = "Headphone", .pin = "Headphone",
...@@ -69,20 +59,6 @@ int rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -69,20 +59,6 @@ int rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_add_card_controls(card, generic_jack_controls,
ARRAY_SIZE(generic_jack_controls));
if (ret) {
dev_err(card->dev, "rt5682 control addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, generic_jack_widgets,
ARRAY_SIZE(generic_jack_widgets));
if (ret) {
dev_err(card->dev, "rt5682 widgets addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, rt5682_map, ret = snd_soc_dapm_add_routes(&card->dapm, rt5682_map,
ARRAY_SIZE(rt5682_map)); ARRAY_SIZE(rt5682_map));
......
...@@ -15,12 +15,6 @@ ...@@ -15,12 +15,6 @@
#include <sound/jack.h> #include <sound/jack.h>
#include "sof_sdw_common.h" #include "sof_sdw_common.h"
static const struct snd_soc_dapm_widget rt700_widgets[] = {
SND_SOC_DAPM_HP("Headphones", NULL),
SND_SOC_DAPM_MIC("AMIC", NULL),
SND_SOC_DAPM_SPK("Speaker", NULL),
};
static const struct snd_soc_dapm_route rt700_map[] = { static const struct snd_soc_dapm_route rt700_map[] = {
/* Headphones */ /* Headphones */
{ "Headphones", NULL, "rt700 HP" }, { "Headphones", NULL, "rt700 HP" },
...@@ -28,12 +22,6 @@ static const struct snd_soc_dapm_route rt700_map[] = { ...@@ -28,12 +22,6 @@ static const struct snd_soc_dapm_route rt700_map[] = {
{ "rt700 MIC2", NULL, "AMIC" }, { "rt700 MIC2", NULL, "AMIC" },
}; };
static const struct snd_kcontrol_new rt700_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphones"),
SOC_DAPM_PIN_SWITCH("AMIC"),
SOC_DAPM_PIN_SWITCH("Speaker"),
};
static struct snd_soc_jack_pin rt700_jack_pins[] = { static struct snd_soc_jack_pin rt700_jack_pins[] = {
{ {
.pin = "Headphones", .pin = "Headphones",
...@@ -69,20 +57,6 @@ int rt700_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -69,20 +57,6 @@ int rt700_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_add_card_controls(card, rt700_controls,
ARRAY_SIZE(rt700_controls));
if (ret) {
dev_err(card->dev, "rt700 controls addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, rt700_widgets,
ARRAY_SIZE(rt700_widgets));
if (ret) {
dev_err(card->dev, "rt700 widgets addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, rt700_map, ret = snd_soc_dapm_add_routes(&card->dapm, rt700_map,
ARRAY_SIZE(rt700_map)); ARRAY_SIZE(rt700_map));
......
...@@ -42,22 +42,12 @@ static int rt711_add_codec_device_props(struct device *sdw_dev) ...@@ -42,22 +42,12 @@ static int rt711_add_codec_device_props(struct device *sdw_dev)
return ret; return ret;
} }
static const struct snd_soc_dapm_widget generic_jack_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
};
static const struct snd_soc_dapm_route rt711_map[] = { static const struct snd_soc_dapm_route rt711_map[] = {
/* Headphones */ /* Headphones */
{ "Headphone", NULL, "rt711 HP" }, { "Headphone", NULL, "rt711 HP" },
{ "rt711 MIC2", NULL, "Headset Mic" }, { "rt711 MIC2", NULL, "Headset Mic" },
}; };
static const struct snd_kcontrol_new generic_jack_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
};
static struct snd_soc_jack_pin rt711_jack_pins[] = { static struct snd_soc_jack_pin rt711_jack_pins[] = {
{ {
.pin = "Headphone", .pin = "Headphone",
...@@ -93,20 +83,6 @@ int rt711_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -93,20 +83,6 @@ int rt711_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_add_card_controls(card, generic_jack_controls,
ARRAY_SIZE(generic_jack_controls));
if (ret) {
dev_err(card->dev, "rt711 controls addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, generic_jack_widgets,
ARRAY_SIZE(generic_jack_widgets));
if (ret) {
dev_err(card->dev, "rt711 widgets addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, rt711_map, ret = snd_soc_dapm_add_routes(&card->dapm, rt711_map,
ARRAY_SIZE(rt711_map)); ARRAY_SIZE(rt711_map));
......
...@@ -15,10 +15,6 @@ ...@@ -15,10 +15,6 @@
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include "sof_sdw_common.h" #include "sof_sdw_common.h"
static const struct snd_soc_dapm_widget generic_spk_widgets[] = {
SND_SOC_DAPM_SPK("Speaker", NULL),
};
/* /*
* dapm routes for rt712 spk will be registered dynamically according * dapm routes for rt712 spk will be registered dynamically according
* to the number of rt712 spk used. The first two entries will be registered * to the number of rt712 spk used. The first two entries will be registered
...@@ -30,10 +26,6 @@ static const struct snd_soc_dapm_route rt712_spk_map[] = { ...@@ -30,10 +26,6 @@ static const struct snd_soc_dapm_route rt712_spk_map[] = {
{ "Speaker", NULL, "rt712 SPOR" }, { "Speaker", NULL, "rt712 SPOR" },
}; };
static const struct snd_kcontrol_new generic_spk_controls[] = {
SOC_DAPM_PIN_SWITCH("Speaker"),
};
int rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) int rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_card *card = rtd->card; struct snd_soc_card *card = rtd->card;
...@@ -45,20 +37,6 @@ int rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -45,20 +37,6 @@ int rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_add_card_controls(card, generic_spk_controls,
ARRAY_SIZE(generic_spk_controls));
if (ret) {
dev_err(card->dev, "rt712 spk controls addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, generic_spk_widgets,
ARRAY_SIZE(generic_spk_widgets));
if (ret) {
dev_err(card->dev, "rt712 spk widgets addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, rt712_spk_map, ARRAY_SIZE(rt712_spk_map)); ret = snd_soc_dapm_add_routes(&card->dapm, rt712_spk_map, ARRAY_SIZE(rt712_spk_map));
if (ret) if (ret)
dev_err(rtd->dev, "failed to add SPK map: %d\n", ret); dev_err(rtd->dev, "failed to add SPK map: %d\n", ret);
......
...@@ -15,18 +15,10 @@ ...@@ -15,18 +15,10 @@
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include "sof_sdw_common.h" #include "sof_sdw_common.h"
static const struct snd_soc_dapm_widget generic_spk_widgets[] = {
SND_SOC_DAPM_SPK("Speaker", NULL),
};
static const struct snd_soc_dapm_route rt722_spk_map[] = { static const struct snd_soc_dapm_route rt722_spk_map[] = {
{ "Speaker", NULL, "rt722 SPK" }, { "Speaker", NULL, "rt722 SPK" },
}; };
static const struct snd_kcontrol_new generic_spk_controls[] = {
SOC_DAPM_PIN_SWITCH("Speaker"),
};
int rt722_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) int rt722_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_card *card = rtd->card; struct snd_soc_card *card = rtd->card;
...@@ -38,20 +30,6 @@ int rt722_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -38,20 +30,6 @@ int rt722_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_add_card_controls(card, generic_spk_controls,
ARRAY_SIZE(generic_spk_controls));
if (ret) {
dev_err(card->dev, "failed to add rt722 spk controls: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, generic_spk_widgets,
ARRAY_SIZE(generic_spk_widgets));
if (ret) {
dev_err(card->dev, "failed to add rt722 spk widgets: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, rt722_spk_map, ARRAY_SIZE(rt722_spk_map)); ret = snd_soc_dapm_add_routes(&card->dapm, rt722_spk_map, ARRAY_SIZE(rt722_spk_map));
if (ret) if (ret)
dev_err(rtd->dev, "failed to add rt722 spk map: %d\n", ret); dev_err(rtd->dev, "failed to add rt722 spk map: %d\n", ret);
......
...@@ -131,14 +131,6 @@ static int rt_amp_add_device_props(struct device *sdw_dev) ...@@ -131,14 +131,6 @@ static int rt_amp_add_device_props(struct device *sdw_dev)
return ret; return ret;
} }
static const struct snd_soc_dapm_widget generic_spk_widgets[] = {
SND_SOC_DAPM_SPK("Speaker", NULL),
};
static const struct snd_kcontrol_new generic_spk_controls[] = {
SOC_DAPM_PIN_SWITCH("Speaker"),
};
/* /*
* dapm routes for rt1308/rt1316/rt1318 will be registered dynamically * dapm routes for rt1308/rt1316/rt1318 will be registered dynamically
* according to the number of rt1308/rt1316/rt1318 used. The first two * according to the number of rt1308/rt1316/rt1318 used. The first two
...@@ -202,20 +194,6 @@ int rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -202,20 +194,6 @@ int rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (!card->components) if (!card->components)
return -ENOMEM; return -ENOMEM;
ret = snd_soc_add_card_controls(card, generic_spk_controls,
ARRAY_SIZE(generic_spk_controls));
if (ret) {
dev_err(card->dev, "%s controls addition failed: %d\n", codec_name, ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, generic_spk_widgets,
ARRAY_SIZE(generic_spk_widgets));
if (ret) {
dev_err(card->dev, "%s widgets addition failed: %d\n", codec_name, ret);
return ret;
}
for_each_rtd_codec_dais(rtd, i, dai) { for_each_rtd_codec_dais(rtd, i, dai) {
if (strstr(dai->component->name_prefix, "-1")) if (strstr(dai->component->name_prefix, "-1"))
ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map, 2); ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map, 2);
......
...@@ -43,11 +43,6 @@ static int rt_sdca_jack_add_codec_device_props(struct device *sdw_dev) ...@@ -43,11 +43,6 @@ static int rt_sdca_jack_add_codec_device_props(struct device *sdw_dev)
return ret; return ret;
} }
static const struct snd_soc_dapm_widget generic_jack_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
};
static const struct snd_soc_dapm_route rt711_sdca_map[] = { static const struct snd_soc_dapm_route rt711_sdca_map[] = {
{ "Headphone", NULL, "rt711 HP" }, { "Headphone", NULL, "rt711 HP" },
{ "rt711 MIC2", NULL, "Headset Mic" }, { "rt711 MIC2", NULL, "Headset Mic" },
...@@ -68,11 +63,6 @@ static const struct snd_soc_dapm_route rt722_sdca_map[] = { ...@@ -68,11 +63,6 @@ static const struct snd_soc_dapm_route rt722_sdca_map[] = {
{ "rt722 MIC2", NULL, "Headset Mic" }, { "rt722 MIC2", NULL, "Headset Mic" },
}; };
static const struct snd_kcontrol_new generic_jack_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
};
static struct snd_soc_jack_pin rt_sdca_jack_pins[] = { static struct snd_soc_jack_pin rt_sdca_jack_pins[] = {
{ {
.pin = "Headphone", .pin = "Headphone",
...@@ -129,20 +119,6 @@ int rt_sdca_jack_rtd_init(struct snd_soc_pcm_runtime *rtd) ...@@ -129,20 +119,6 @@ int rt_sdca_jack_rtd_init(struct snd_soc_pcm_runtime *rtd)
} }
} }
ret = snd_soc_add_card_controls(card, generic_jack_controls,
ARRAY_SIZE(generic_jack_controls));
if (ret) {
dev_err(card->dev, "rt sdca jack controls addition failed: %d\n", ret);
return ret;
}
ret = snd_soc_dapm_new_controls(&card->dapm, generic_jack_widgets,
ARRAY_SIZE(generic_jack_widgets));
if (ret) {
dev_err(card->dev, "rt sdca jack widgets addition failed: %d\n", ret);
return ret;
}
if (strstr(component->name_prefix, "rt711")) { if (strstr(component->name_prefix, "rt711")) {
ret = snd_soc_dapm_add_routes(&card->dapm, rt711_sdca_map, ret = snd_soc_dapm_add_routes(&card->dapm, rt711_sdca_map,
ARRAY_SIZE(rt711_sdca_map)); ARRAY_SIZE(rt711_sdca_map));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment