mt8186-mt6366-common.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // mt8186-mt6366-common.c
  4. // -- MT8186 MT6366 ALSA common driver
  5. //
  6. // Copyright (c) 2022 MediaTek Inc.
  7. // Author: Jiaxin Yu <[email protected]>
  8. //
  9. #include <sound/soc.h>
  10. #include "../../codecs/mt6358.h"
  11. #include "../common/mtk-afe-platform-driver.h"
  12. #include "mt8186-afe-common.h"
  13. #include "mt8186-mt6366-common.h"
  14. int mt8186_mt6366_init(struct snd_soc_pcm_runtime *rtd)
  15. {
  16. struct snd_soc_component *cmpnt_afe =
  17. snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
  18. struct snd_soc_component *cmpnt_codec =
  19. asoc_rtd_to_codec(rtd, 0)->component;
  20. struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt_afe);
  21. struct mt8186_afe_private *afe_priv = afe->platform_priv;
  22. struct snd_soc_dapm_context *dapm = &rtd->card->dapm;
  23. int ret;
  24. /* set mtkaif protocol */
  25. mt6358_set_mtkaif_protocol(cmpnt_codec,
  26. MT6358_MTKAIF_PROTOCOL_1);
  27. afe_priv->mtkaif_protocol = MT6358_MTKAIF_PROTOCOL_1;
  28. ret = snd_soc_dapm_sync(dapm);
  29. if (ret) {
  30. dev_err(rtd->dev, "failed to snd_soc_dapm_sync\n");
  31. return ret;
  32. }
  33. return 0;
  34. }
  35. EXPORT_SYMBOL_GPL(mt8186_mt6366_init);
  36. int mt8186_mt6366_card_set_be_link(struct snd_soc_card *card,
  37. struct snd_soc_dai_link *link,
  38. struct device_node *node,
  39. char *link_name)
  40. {
  41. int ret;
  42. if (node && strcmp(link->name, link_name) == 0) {
  43. ret = snd_soc_of_get_dai_link_codecs(card->dev, node, link);
  44. if (ret < 0)
  45. return dev_err_probe(card->dev, ret, "get dai link codecs fail\n");
  46. }
  47. return 0;
  48. }
  49. EXPORT_SYMBOL_GPL(mt8186_mt6366_card_set_be_link);