diff options
author | Vijendar Mukunda <Vijendar.Mukunda@amd.com> | 2024-08-01 14:44:25 +0530 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-08-01 12:44:00 +0100 |
commit | 4776d0c9088634677749e42ae8b36b4da46226db (patch) | |
tree | 6311f7e7b6cc3a630b934fbbbdf4c2a9fed14cb5 /sound/soc/sdw_utils | |
parent | 941d6933eb31b13d09a7293bc92d9d494513a372 (diff) |
ASoC: intel/sdw_utils: move dmic codec helper function
Move generic dmic codec helper function implementation to
sdw_utils folder so that this function can be used by other platform
machine drivers.
Link: https://github.com/thesofproject/linux/pull/5068
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://patch.msgid.link/20240801091446.10457-11-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sdw_utils')
-rw-r--r-- | sound/soc/sdw_utils/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/sdw_utils/soc_sdw_dmic.c | 45 |
2 files changed, 46 insertions, 1 deletions
diff --git a/sound/soc/sdw_utils/Makefile b/sound/soc/sdw_utils/Makefile index 29b2852be287..de8aff8744d8 100644 --- a/sound/soc/sdw_utils/Makefile +++ b/sound/soc/sdw_utils/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -snd-soc-sdw-utils-y := soc_sdw_utils.o +snd-soc-sdw-utils-y := soc_sdw_utils.o soc_sdw_dmic.o obj-$(CONFIG_SND_SOC_SDW_UTILS) += snd-soc-sdw-utils.o diff --git a/sound/soc/sdw_utils/soc_sdw_dmic.c b/sound/soc/sdw_utils/soc_sdw_dmic.c new file mode 100644 index 000000000000..fc2aae985084 --- /dev/null +++ b/sound/soc/sdw_utils/soc_sdw_dmic.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-only +// This file incorporates work covered by the following copyright notice: +// Copyright (c) 2020 Intel Corporation +// Copyright (c) 2024 Advanced Micro Devices, Inc. + +/* + * soc_sdw_dmic - Helpers to handle dmic from generic machine driver + */ + +#include <sound/soc.h> +#include <sound/soc-acpi.h> +#include <sound/soc-dapm.h> +#include <sound/soc_sdw_utils.h> + +static const struct snd_soc_dapm_widget dmic_widgets[] = { + SND_SOC_DAPM_MIC("SoC DMIC", NULL), +}; + +static const struct snd_soc_dapm_route dmic_map[] = { + /* digital mics */ + {"DMic", NULL, "SoC DMIC"}, +}; + +int asoc_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card = rtd->card; + int ret; + + ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, + ARRAY_SIZE(dmic_widgets)); + if (ret) { + dev_err(card->dev, "DMic widget addition failed: %d\n", ret); + /* Don't need to add routes if widget addition failed */ + return ret; + } + + ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, + ARRAY_SIZE(dmic_map)); + + if (ret) + dev_err(card->dev, "DMic map addition failed: %d\n", ret); + + return ret; +} +EXPORT_SYMBOL_NS(asoc_sdw_dmic_init, SND_SOC_SDW_UTILS); |