1 // SPDX-License-Identifier: GPL-2.0-only
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 <sound/soc-dapm.h>
11 #include "sof_sdw_common.h"
12
13 static const struct snd_soc_dapm_widget dmic_widgets[] = {
14 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
15 };
16
17 static const struct snd_soc_dapm_route dmic_map[] = {
18 /* digital mics */
19 {"DMic", NULL, "SoC DMIC"},
20 };
21
sof_sdw_dmic_init(struct snd_soc_pcm_runtime * rtd)22 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd)
23 {
24 struct snd_soc_card *card = rtd->card;
25 int ret;
26
27 ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
28 ARRAY_SIZE(dmic_widgets));
29 if (ret) {
30 dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
31 /* Don't need to add routes if widget addition failed */
32 return ret;
33 }
34
35 ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
36 ARRAY_SIZE(dmic_map));
37
38 if (ret)
39 dev_err(card->dev, "DMic map addition failed: %d\n", ret);
40
41 return ret;
42 }
43
44