sdm660-common.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef __MSM_COMMON
  13. #define __MSM_COMMON
  14. #include <sound/soc.h>
  15. #include <dsp/q6afe-v2.h>
  16. #include "codecs/wcd-mbhc-v2.h"
  17. #define DEFAULT_MCLK_RATE 9600000
  18. #define NATIVE_MCLK_RATE 11289600
  19. #define SAMPLING_RATE_8KHZ 8000
  20. #define SAMPLING_RATE_11P025KHZ 11025
  21. #define SAMPLING_RATE_16KHZ 16000
  22. #define SAMPLING_RATE_22P05KHZ 22050
  23. #define SAMPLING_RATE_32KHZ 32000
  24. #define SAMPLING_RATE_44P1KHZ 44100
  25. #define SAMPLING_RATE_48KHZ 48000
  26. #define SAMPLING_RATE_88P2KHZ 88200
  27. #define SAMPLING_RATE_96KHZ 96000
  28. #define SAMPLING_RATE_176P4KHZ 176400
  29. #define SAMPLING_RATE_192KHZ 192000
  30. #define SAMPLING_RATE_352P8KHZ 352800
  31. #define SAMPLING_RATE_384KHZ 384000
  32. #define TDM_CHANNEL_MAX 8
  33. #define TDM_SLOT_OFFSET_MAX 8
  34. enum {
  35. TDM_0 = 0,
  36. TDM_1,
  37. TDM_2,
  38. TDM_3,
  39. TDM_4,
  40. TDM_5,
  41. TDM_6,
  42. TDM_7,
  43. TDM_PORT_MAX,
  44. };
  45. enum {
  46. TDM_PRI = 0,
  47. TDM_SEC,
  48. TDM_TERT,
  49. TDM_QUAT,
  50. TDM_QUIN,
  51. TDM_INTERFACE_MAX,
  52. };
  53. struct tdm_port {
  54. u32 mode;
  55. u32 channel;
  56. };
  57. enum {
  58. PRIM_MI2S = 0,
  59. SEC_MI2S,
  60. TERT_MI2S,
  61. QUAT_MI2S,
  62. QUIN_MI2S,
  63. MI2S_MAX,
  64. };
  65. enum {
  66. DIG_CDC,
  67. ANA_CDC,
  68. CODECS_MAX,
  69. };
  70. extern const struct snd_kcontrol_new msm_common_snd_controls[];
  71. extern bool codec_reg_done;
  72. struct sdm660_codec {
  73. void* (*get_afe_config_fn)(struct snd_soc_codec *codec,
  74. enum afe_config_type config_type);
  75. };
  76. enum {
  77. INT_SND_CARD,
  78. EXT_SND_CARD_TASHA,
  79. EXT_SND_CARD_TAVIL,
  80. };
  81. struct msm_asoc_mach_data {
  82. int us_euro_gpio; /* used by gpio driver API */
  83. int usbc_en2_gpio; /* used by gpio driver API */
  84. int hph_en1_gpio;
  85. int hph_en0_gpio;
  86. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  87. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  88. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  89. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  90. struct device_node *pdm_gpio_p; /* used by pinctrl API */
  91. struct device_node *comp_gpio_p; /* used by pinctrl API */
  92. struct device_node *dmic_gpio_p; /* used by pinctrl API */
  93. struct device_node *ext_spk_gpio_p; /* used by pinctrl API */
  94. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  95. struct snd_soc_codec *codec;
  96. struct sdm660_codec sdm660_codec_fn;
  97. struct snd_info_entry *codec_root;
  98. int spk_ext_pa_gpio;
  99. int mclk_freq;
  100. bool native_clk_set;
  101. int lb_mode;
  102. int snd_card_val;
  103. u8 micbias1_cap_mode;
  104. u8 micbias2_cap_mode;
  105. atomic_t int_mclk0_rsc_ref;
  106. atomic_t int_mclk0_enabled;
  107. struct mutex cdc_int_mclk0_mutex;
  108. struct delayed_work disable_int_mclk0_work;
  109. struct afe_clk_set digital_cdc_core_clk;
  110. };
  111. int msm_common_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  112. struct snd_pcm_hw_params *params);
  113. int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream);
  114. void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream);
  115. int msm_mi2s_snd_startup(struct snd_pcm_substream *substream);
  116. void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream);
  117. int msm_common_snd_controls_size(void);
  118. void msm_set_codec_reg_done(bool done);
  119. #endif