msm_common.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _MSM_COMMON_H_
  7. #define _MSM_COMMON_H_
  8. #include <sound/soc.h>
  9. #include <sound/pcm.h>
  10. //#ifdef CONFIG_COMMON_AMP_CIRRUS
  11. #if 1
  12. #define CLK_SRC_SCLK 0
  13. #define CLK_SRC_LRCLK 1
  14. #define CLK_SRC_PDM 2
  15. #define CLK_SRC_SELF 3
  16. #define CLK_SRC_MCLK 4
  17. #define CLK_SRC_SWIRE 5
  18. #define CLK_SRC_DAI 0
  19. #define CLK_SRC_CODEC 1
  20. #define CS35L43_MONO 0x31
  21. #define CS35L43_STEREO 0x32
  22. #define CS35L43_QUAD 0x34
  23. #define CS35L45_MONO 0x51
  24. #define CS35L45_STEREO 0x52
  25. #define CS35L45_QUAD 0x54
  26. #endif
  27. enum {
  28. MI2S = 0,
  29. TDM,
  30. AUXPCM,
  31. };
  32. enum {
  33. PRI_MI2S_TDM_AUXPCM = 0,
  34. SEC_MI2S_TDM_AUXPCM,
  35. TER_MI2S_TDM_AUXPCM,
  36. QUAT_MI2S_TDM_AUXPCM,
  37. QUIN_MI2S_TDM_AUXPCM,
  38. SEN_MI2S_TDM_AUXPCM,
  39. SEP_MI2S_TDM_AUXPCM,
  40. MI2S_TDM_AUXPCM_MAX,
  41. };
  42. typedef enum snd_card_status_t {
  43. SND_CARD_STATUS_OFFLINE = 0,
  44. SND_CARD_STATUS_ONLINE = 1,
  45. } snd_card_status_t;
  46. struct msm_common_pdata {
  47. uint8_t *aud_dev_state;
  48. struct kobject aud_dev_kobj;
  49. struct mutex aud_dev_lock;
  50. uint32_t num_aud_devs;
  51. struct device_node *mi2s_gpio_p[MI2S_TDM_AUXPCM_MAX];
  52. struct mutex lock[MI2S_TDM_AUXPCM_MAX];
  53. u32 tdm_max_slots; /* Max TDM slots used */
  54. atomic_t mi2s_gpio_ref_cnt[MI2S_TDM_AUXPCM_MAX];
  55. atomic_t lpass_intf_clk_ref_cnt[MI2S_TDM_AUXPCM_MAX];
  56. atomic_t lpass_audio_hw_vote_ref_cnt;
  57. struct clk *lpass_audio_hw_vote;
  58. uint32_t is_audio_hw_vote_required[MI2S_TDM_AUXPCM_MAX];
  59. uint32_t tdm_clk_attribute[MI2S_TDM_AUXPCM_MAX];
  60. uint32_t mi2s_clk_attribute[MI2S_TDM_AUXPCM_MAX];
  61. };
  62. int snd_card_notify_user(snd_card_status_t card_status);
  63. int snd_card_set_card_status(snd_card_status_t card_status);
  64. struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card);
  65. void msm_common_set_pdata(struct snd_soc_card *card,
  66. struct msm_common_pdata *pdata);
  67. int snd_card_sysfs_init(void);
  68. int msm_common_snd_hw_params(struct snd_pcm_substream *substream,
  69. struct snd_pcm_hw_params *params);
  70. int msm_common_snd_startup(struct snd_pcm_substream *substream);
  71. void msm_common_snd_shutdown(struct snd_pcm_substream *substream);
  72. int msm_common_snd_init(struct platform_device *pdev,
  73. struct snd_soc_card *card);
  74. void msm_common_snd_deinit(struct msm_common_pdata *pdata);
  75. int msm_common_dai_link_init(struct snd_soc_pcm_runtime *rtd);
  76. #endif