wcd934x.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef WCD934X_H
  14. #define WCD934X_H
  15. #include <dsp/apr_audio-v2.h>
  16. #include "wcd934x-dsp-cntl.h"
  17. #include "../wcd9xxx-slimslave.h"
  18. #include "../wcd9xxx-common-v2.h"
  19. #include "../wcd-mbhc-v2.h"
  20. #define WCD934X_REGISTER_START_OFFSET 0x800
  21. #define WCD934X_SB_PGD_PORT_RX_BASE 0x40
  22. #define WCD934X_SB_PGD_PORT_TX_BASE 0x50
  23. #define WCD934X_RX_PORT_START_NUMBER 16
  24. #define WCD934X_DMIC_CLK_DIV_2 0x0
  25. #define WCD934X_DMIC_CLK_DIV_3 0x1
  26. #define WCD934X_DMIC_CLK_DIV_4 0x2
  27. #define WCD934X_DMIC_CLK_DIV_6 0x3
  28. #define WCD934X_DMIC_CLK_DIV_8 0x4
  29. #define WCD934X_DMIC_CLK_DIV_16 0x5
  30. #define WCD934X_DMIC_CLK_DRIVE_DEFAULT 0x02
  31. #define WCD934X_ANC_DMIC_X2_FULL_RATE 1
  32. #define WCD934X_ANC_DMIC_X2_HALF_RATE 0
  33. #define TAVIL_MAX_MICBIAS 4
  34. #define TAVIL_NUM_INTERPOLATORS 9
  35. #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
  36. /* Convert from vout ctl to micbias voltage in mV */
  37. #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
  38. /* Feature masks to distinguish codec version */
  39. #define DSD_DISABLED_MASK 0
  40. #define SLNQ_DISABLED_MASK 1
  41. #define DSD_DISABLED (1 << DSD_DISABLED_MASK)
  42. #define SLNQ_DISABLED (1 << SLNQ_DISABLED_MASK)
  43. /* Number of input and output Slimbus port */
  44. enum {
  45. WCD934X_RX0 = 0,
  46. WCD934X_RX1,
  47. WCD934X_RX2,
  48. WCD934X_RX3,
  49. WCD934X_RX4,
  50. WCD934X_RX5,
  51. WCD934X_RX6,
  52. WCD934X_RX7,
  53. WCD934X_RX_MAX,
  54. };
  55. enum {
  56. WCD934X_TX0 = 0,
  57. WCD934X_TX1,
  58. WCD934X_TX2,
  59. WCD934X_TX3,
  60. WCD934X_TX4,
  61. WCD934X_TX5,
  62. WCD934X_TX6,
  63. WCD934X_TX7,
  64. WCD934X_TX8,
  65. WCD934X_TX9,
  66. WCD934X_TX10,
  67. WCD934X_TX11,
  68. WCD934X_TX12,
  69. WCD934X_TX13,
  70. WCD934X_TX14,
  71. WCD934X_TX15,
  72. WCD934X_TX_MAX,
  73. };
  74. enum {
  75. INTERP_EAR = 0,
  76. INTERP_HPHL,
  77. INTERP_HPHR,
  78. INTERP_LO1,
  79. INTERP_LO2,
  80. INTERP_LO3_NA, /* LO3 not avalible in Tavil*/
  81. INTERP_LO4_NA,
  82. INTERP_SPKR1,
  83. INTERP_SPKR2,
  84. INTERP_MAX,
  85. };
  86. /*
  87. * Selects compander and smart boost settings
  88. * for a given speaker mode
  89. */
  90. enum {
  91. WCD934X_SPKR_MODE_DEFAULT,
  92. WCD934X_SPKR_MODE_1, /* COMP Gain = 12dB, Smartboost Max = 5.5V */
  93. };
  94. /*
  95. * Rx path gain offsets
  96. */
  97. enum {
  98. WCD934X_RX_GAIN_OFFSET_M1P5_DB,
  99. WCD934X_RX_GAIN_OFFSET_0_DB,
  100. };
  101. /*
  102. * Dai data structure holds the
  103. * dai specific info like rate,
  104. * channel number etc.
  105. */
  106. struct tavil_codec_dai_data {
  107. u32 rate;
  108. u32 *ch_num;
  109. u32 ch_act;
  110. u32 ch_tot;
  111. };
  112. /*
  113. * Structure used to update codec
  114. * register defaults after reset
  115. */
  116. struct tavil_reg_mask_val {
  117. u16 reg;
  118. u8 mask;
  119. u8 val;
  120. };
  121. extern void *tavil_get_afe_config(struct snd_soc_codec *codec,
  122. enum afe_config_type config_type);
  123. extern int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable);
  124. extern int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable);
  125. extern int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode);
  126. extern int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
  127. extern struct wcd_dsp_cntl *tavil_get_wcd_dsp_cntl(struct device *dev);
  128. extern int wcd934x_get_micb_vout_ctl_val(u32 micb_mv);
  129. extern int tavil_micbias_control(struct snd_soc_codec *codec,
  130. int micb_num,
  131. int req, bool is_dapm);
  132. extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  133. int req_volt,
  134. int micb_num);
  135. extern struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec);
  136. extern int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec,
  137. int event, int intp_idx);
  138. extern struct tavil_dsd_config *tavil_get_dsd_config(
  139. struct snd_soc_codec *codec);
  140. extern int tavil_codec_info_create_codec_entry(
  141. struct snd_info_entry *codec_root,
  142. struct snd_soc_codec *codec);
  143. #endif