wcd9320.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* Copyright (c) 2012-2013, 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 WCD9320_H
  13. #define WCD9320_H
  14. #include <sound/soc.h>
  15. #include <sound/jack.h>
  16. #include <sound/apr_audio-v2.h>
  17. #include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h>
  18. #include "wcd9xxx-mbhc.h"
  19. #include "wcd9xxx-resmgr.h"
  20. #include "wcd9xxx-common.h"
  21. #define TAIKO_NUM_REGISTERS 0x400
  22. #define TAIKO_MAX_REGISTER (TAIKO_NUM_REGISTERS-1)
  23. #define TAIKO_CACHE_SIZE TAIKO_NUM_REGISTERS
  24. #define TAIKO_REG_VAL(reg, val) {reg, 0, val}
  25. #define TAIKO_MCLK_ID 0
  26. #define TAIKO_REGISTER_START_OFFSET 0x800
  27. #define TAIKO_SB_PGD_PORT_RX_BASE 0x40
  28. #define TAIKO_SB_PGD_PORT_TX_BASE 0x50
  29. extern const u8 taiko_reg_readable[TAIKO_CACHE_SIZE];
  30. extern const u8 taiko_reset_reg_defaults[TAIKO_CACHE_SIZE];
  31. struct taiko_codec_dai_data {
  32. u32 rate;
  33. u32 *ch_num;
  34. u32 ch_act;
  35. u32 ch_tot;
  36. };
  37. enum taiko_pid_current {
  38. TAIKO_PID_MIC_2P5_UA,
  39. TAIKO_PID_MIC_5_UA,
  40. TAIKO_PID_MIC_10_UA,
  41. TAIKO_PID_MIC_20_UA,
  42. };
  43. enum taiko_mbhc_analog_pwr_cfg {
  44. TAIKO_ANALOG_PWR_COLLAPSED = 0,
  45. TAIKO_ANALOG_PWR_ON,
  46. TAIKO_NUM_ANALOG_PWR_CONFIGS,
  47. };
  48. /* Number of input and output Slimbus port */
  49. enum {
  50. TAIKO_RX1 = 0,
  51. TAIKO_RX2,
  52. TAIKO_RX3,
  53. TAIKO_RX4,
  54. TAIKO_RX5,
  55. TAIKO_RX6,
  56. TAIKO_RX7,
  57. TAIKO_RX8,
  58. TAIKO_RX9,
  59. TAIKO_RX10,
  60. TAIKO_RX11,
  61. TAIKO_RX12,
  62. TAIKO_RX13,
  63. TAIKO_RX_MAX,
  64. };
  65. enum {
  66. TAIKO_TX1 = 0,
  67. TAIKO_TX2,
  68. TAIKO_TX3,
  69. TAIKO_TX4,
  70. TAIKO_TX5,
  71. TAIKO_TX6,
  72. TAIKO_TX7,
  73. TAIKO_TX8,
  74. TAIKO_TX9,
  75. TAIKO_TX10,
  76. TAIKO_TX11,
  77. TAIKO_TX12,
  78. TAIKO_TX13,
  79. TAIKO_TX14,
  80. TAIKO_TX15,
  81. TAIKO_TX16,
  82. TAIKO_TX_MAX,
  83. };
  84. struct mad_audio_header {
  85. u32 reserved[3];
  86. u32 num_reg_cfg;
  87. };
  88. struct mad_microphone_info {
  89. uint8_t input_microphone;
  90. uint8_t cycle_time;
  91. uint8_t settle_time;
  92. uint8_t padding;
  93. } __packed;
  94. struct mad_micbias_info {
  95. uint8_t micbias;
  96. uint8_t k_factor;
  97. uint8_t external_bypass_capacitor;
  98. uint8_t internal_biasing;
  99. uint8_t cfilter;
  100. uint8_t padding[3];
  101. } __packed;
  102. struct mad_rms_audio_beacon_info {
  103. uint8_t rms_omit_samples;
  104. uint8_t rms_comp_time;
  105. uint8_t detection_mechanism;
  106. uint8_t rms_diff_threshold;
  107. uint8_t rms_threshold_lsb;
  108. uint8_t rms_threshold_msb;
  109. uint8_t padding[2];
  110. uint8_t iir_coefficients[36];
  111. } __packed;
  112. struct mad_rms_ultrasound_info {
  113. uint8_t rms_comp_time;
  114. uint8_t detection_mechanism;
  115. uint8_t rms_diff_threshold;
  116. uint8_t rms_threshold_lsb;
  117. uint8_t rms_threshold_msb;
  118. uint8_t padding[3];
  119. uint8_t iir_coefficients[36];
  120. } __packed;
  121. struct mad_audio_cal {
  122. uint32_t version;
  123. struct mad_microphone_info microphone_info;
  124. struct mad_micbias_info micbias_info;
  125. struct mad_rms_audio_beacon_info audio_info;
  126. struct mad_rms_audio_beacon_info beacon_info;
  127. struct mad_rms_ultrasound_info ultrasound_info;
  128. } __packed;
  129. extern int taiko_mclk_enable(struct snd_soc_codec *codec, int mclk_enable,
  130. bool dapm);
  131. extern int taiko_hs_detect(struct snd_soc_codec *codec,
  132. struct wcd9xxx_mbhc_config *mbhc_cfg);
  133. extern void taiko_hs_detect_exit(struct snd_soc_codec *codec);
  134. extern void *taiko_get_afe_config(struct snd_soc_codec *codec,
  135. enum afe_config_type config_type);
  136. extern void taiko_event_register(
  137. int (*machine_event_cb)(struct snd_soc_codec *codec,
  138. enum wcd9xxx_codec_event),
  139. struct snd_soc_codec *codec);
  140. #endif