soc_sdw_dmic.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. // This file incorporates work covered by the following copyright notice:
  3. // Copyright (c) 2020 Intel Corporation
  4. // Copyright (c) 2024 Advanced Micro Devices, Inc.
  5. /*
  6. * soc_sdw_dmic - Helpers to handle dmic from generic machine driver
  7. */
  8. #include <sound/soc.h>
  9. #include <sound/soc-acpi.h>
  10. #include <sound/soc-dapm.h>
  11. #include <sound/soc_sdw_utils.h>
  12. static const struct snd_soc_dapm_widget dmic_widgets[] = {
  13. SND_SOC_DAPM_MIC("SoC DMIC", NULL),
  14. };
  15. static const struct snd_soc_dapm_route dmic_map[] = {
  16. /* digital mics */
  17. {"DMic", NULL, "SoC DMIC"},
  18. };
  19. int asoc_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd)
  20. {
  21. struct snd_soc_card *card = rtd->card;
  22. int ret;
  23. ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
  24. ARRAY_SIZE(dmic_widgets));
  25. if (ret) {
  26. dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
  27. /* Don't need to add routes if widget addition failed */
  28. return ret;
  29. }
  30. ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
  31. ARRAY_SIZE(dmic_map));
  32. if (ret)
  33. dev_err(card->dev, "DMic map addition failed: %d\n", ret);
  34. return ret;
  35. }
  36. EXPORT_SYMBOL_NS(asoc_sdw_dmic_init, SND_SOC_SDW_UTILS);