msm_common.h 2.4 KB

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