Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 // Copyright (c) 2020 Intel Corporation
0003 
0004 /*
0005  *  sof_sdw_dmic - Helpers to handle dmic from generic machine driver
0006  */
0007 
0008 #include <sound/soc.h>
0009 #include <sound/soc-acpi.h>
0010 #include <sound/soc-dapm.h>
0011 #include "sof_sdw_common.h"
0012 
0013 static const struct snd_soc_dapm_widget dmic_widgets[] = {
0014     SND_SOC_DAPM_MIC("SoC DMIC", NULL),
0015 };
0016 
0017 static const struct snd_soc_dapm_route dmic_map[] = {
0018     /* digital mics */
0019     {"DMic", NULL, "SoC DMIC"},
0020 };
0021 
0022 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd)
0023 {
0024     struct snd_soc_card *card = rtd->card;
0025     int ret;
0026 
0027     ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
0028                     ARRAY_SIZE(dmic_widgets));
0029     if (ret) {
0030         dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
0031         /* Don't need to add routes if widget addition failed */
0032         return ret;
0033     }
0034 
0035     ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
0036                       ARRAY_SIZE(dmic_map));
0037 
0038     if (ret)
0039         dev_err(card->dev, "DMic map addition failed: %d\n", ret);
0040 
0041     return ret;
0042 }
0043