1 // SPDX-License-Identifier: GPL-2.0 2 // Copyright (c) 2020 Intel Corporation 3 4 /* 5 * sof_sdw_dmic - Helpers to handle dmic from generic machine driver 6 */ 7 8 #include <sound/soc.h> 9 #include <sound/soc-acpi.h> 10 #include "sof_sdw_common.h" 11 12 static const struct snd_soc_dapm_widget dmic_widgets[] = { 13 SND_SOC_DAPM_MIC("SoC DMIC", NULL), 14 }; 15 16 static const struct snd_soc_dapm_route dmic_map[] = { 17 /* digital mics */ 18 {"DMic", NULL, "SoC DMIC"}, 19 }; 20 21 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd) 22 { 23 struct snd_soc_card *card = rtd->card; 24 int ret; 25 26 ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, 27 ARRAY_SIZE(dmic_widgets)); 28 if (ret) { 29 dev_err(card->dev, "DMic widget addition failed: %d\n", ret); 30 /* Don't need to add routes if widget addition failed */ 31 return ret; 32 } 33 34 ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, 35 ARRAY_SIZE(dmic_map)); 36 37 if (ret) 38 dev_err(card->dev, "DMic map addition failed: %d\n", ret); 39 40 return ret; 41 } 42 43