From 001188d41c4f3b3fc770e2f2d5001d5e5e6aef3f Mon Sep 17 00:00:00 2001 From: Sameer Pujar Date: Sat, 7 Dec 2019 11:24:14 +0530 Subject: [PATCH] ASoC: tegra-alt: parse machine widgets from DT Machine DAPM widgets are currently defined in the driver and are used to connect to DAPM input/output widgets of external codecs. This routing map is exposed from DT. Since the machine driver is common to multiple platforms, all widgets defined in the driver are not always required. Instead of statically defining the widgets in the driver, these can be exposed from DT. Any platform DT can then add required number of widgets and can define a corresponding routing map. This patch removes the static array for DAPM widgets and instead helper function, snd_soc_of_parse_audio_simple_widgets(), is used to populate given DAPM widgets for the sound card. Bug 200503387 Change-Id: I8ff9f0d52e3c1cc10b6ab1682d05a7b7ef7e2684 Signed-off-by: Sameer Pujar Reviewed-on: https://git-master.nvidia.com/r/2257383 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Mohan Kumar D Reviewed-by: Jonathan Hunter Reviewed-by: Ravindra Lokhande Reviewed-by: mobile promotions Tested-by: mobile promotions --- .../tegra_machine_driver_mobile.c | 19 ------------------- .../tegra-alt/utils/tegra_asoc_dt_parser.c | 8 ++++++++ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c index 4d820c3c..68eaf4d4 100644 --- a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c +++ b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c @@ -81,23 +81,6 @@ static const int tegra_machine_srate_values[] = { 192000, }; -static const struct snd_soc_dapm_widget tegra_machine_dapm_widgets[] = { - SND_SOC_DAPM_SPK("x Int Spk", NULL), - SND_SOC_DAPM_HP("x Headphone Jack", NULL), - SND_SOC_DAPM_MIC("x Int Mic", NULL), - SND_SOC_DAPM_MIC("x Mic Jack", NULL), - - SND_SOC_DAPM_SPK("d1 Headphone", NULL), - SND_SOC_DAPM_SPK("d2 Headphone", NULL), - SND_SOC_DAPM_SPK("d3 Headphone", NULL), - - SND_SOC_DAPM_HP("x Headphone", NULL), - SND_SOC_DAPM_HP("y Headphone", NULL), - SND_SOC_DAPM_MIC("Int Mic", NULL), - SND_SOC_DAPM_MIC("x Mic", NULL), - SND_SOC_DAPM_MIC("y Mic", NULL), -}; - static int tegra_machine_codec_get_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -497,8 +480,6 @@ static struct snd_soc_card snd_soc_tegra_card = { .owner = THIS_MODULE, .controls = tegra_machine_controls, .num_controls = ARRAY_SIZE(tegra_machine_controls), - .dapm_widgets = tegra_machine_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tegra_machine_dapm_widgets), .suspend_pre = tegra_machine_suspend_pre, .fully_routed = true, }; diff --git a/sound/soc/tegra-alt/utils/tegra_asoc_dt_parser.c b/sound/soc/tegra-alt/utils/tegra_asoc_dt_parser.c index d64f2aff..fe8d41da 100644 --- a/sound/soc/tegra-alt/utils/tegra_asoc_dt_parser.c +++ b/sound/soc/tegra-alt/utils/tegra_asoc_dt_parser.c @@ -424,6 +424,14 @@ int parse_card_info(struct snd_soc_card *card, struct snd_soc_ops *pcm_ops, if (ret < 0) return ret; + /* parse machine DAPM widgets */ + if (of_property_read_bool(node, PREFIX "widgets")) { + ret = snd_soc_of_parse_audio_simple_widgets(card, + PREFIX "widgets"); + if (ret < 0) + return ret; + } + /* * Below property of routing map is required only when there * are DAPM input/output widgets available for external codec,