WIP FPC-III support
[linux/fpc-iii.git] / sound / soc / intel / boards / sof_sdw_dmic.c
blob19df0f7a1d85aff7ad75252e782d6f69bf9f35a3
1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2020 Intel Corporation
4 /*
5 * sof_sdw_dmic - Helpers to handle dmic from generic machine driver
6 */
8 #include <sound/soc.h>
9 #include <sound/soc-acpi.h>
10 #include <sound/soc-dapm.h>
11 #include "sof_sdw_common.h"
13 static const struct snd_soc_dapm_widget dmic_widgets[] = {
14 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
17 static const struct snd_soc_dapm_route dmic_map[] = {
18 /* digital mics */
19 {"DMic", NULL, "SoC DMIC"},
22 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd)
24 struct snd_soc_card *card = rtd->card;
25 int ret;
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;
35 ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
36 ARRAY_SIZE(dmic_map));
38 if (ret)
39 dev_err(card->dev, "DMic map addition failed: %d\n", ret);
41 return ret;