soc_sdw_rt712_sdca.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. // This file incorporates work covered by the following copyright notice:
  3. // Copyright (c) 2023 Intel Corporation
  4. // Copyright (c) 2024 Advanced Micro Devices, Inc.
  5. /*
  6. * soc_sdw_rt712_sdca - Helpers to handle RT712-SDCA from generic machine driver
  7. */
  8. #include <linux/device.h>
  9. #include <linux/errno.h>
  10. #include <linux/soundwire/sdw.h>
  11. #include <linux/soundwire/sdw_type.h>
  12. #include <sound/control.h>
  13. #include <sound/soc.h>
  14. #include <sound/soc-acpi.h>
  15. #include <sound/soc-dapm.h>
  16. #include <sound/soc_sdw_utils.h>
  17. /*
  18. * dapm routes for rt712 spk will be registered dynamically according
  19. * to the number of rt712 spk used. The first two entries will be registered
  20. * for one codec case, and the last two entries are also registered
  21. * if two rt712s are used.
  22. */
  23. static const struct snd_soc_dapm_route rt712_spk_map[] = {
  24. { "Speaker", NULL, "rt712 SPOL" },
  25. { "Speaker", NULL, "rt712 SPOR" },
  26. };
  27. int asoc_sdw_rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
  28. {
  29. struct snd_soc_card *card = rtd->card;
  30. int ret;
  31. card->components = devm_kasprintf(card->dev, GFP_KERNEL,
  32. "%s spk:rt712",
  33. card->components);
  34. if (!card->components)
  35. return -ENOMEM;
  36. ret = snd_soc_dapm_add_routes(&card->dapm, rt712_spk_map, ARRAY_SIZE(rt712_spk_map));
  37. if (ret)
  38. dev_err(rtd->dev, "failed to add SPK map: %d\n", ret);
  39. return ret;
  40. }
  41. EXPORT_SYMBOL_NS(asoc_sdw_rt712_spk_rtd_init, SND_SOC_SDW_UTILS);