aqt1000-internal.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* Copyright (c) 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 _AQT1000_INTERNAL_H
  13. #define _AQT1000_INTERNAL_H
  14. #include <linux/types.h>
  15. #include <linux/regmap.h>
  16. #include <sound/soc.h>
  17. #define AQT1000_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  18. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  19. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\
  20. SNDRV_PCM_RATE_384000)
  21. /* Fractional Rates */
  22. #define AQT1000_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\
  23. SNDRV_PCM_RATE_176400)
  24. #define AQT1000_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  25. SNDRV_PCM_FMTBIT_S24_LE)
  26. #define AQT1000_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  27. SNDRV_PCM_FMTBIT_S24_LE | \
  28. SNDRV_PCM_FMTBIT_S32_LE)
  29. #define AQT1000_FORMATS_S16_LE (SNDRV_PCM_FMTBIT_S16_LE)
  30. /* Macros for packing register writes into a U32 */
  31. #define AQT1000_PACKED_REG_SIZE sizeof(u32)
  32. #define AQT1000_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \
  33. do { \
  34. ((reg) = ((packed >> 16) & (0xffff))); \
  35. ((mask) = ((packed >> 8) & (0xff))); \
  36. ((val) = ((packed) & (0xff))); \
  37. } while (0)
  38. #define STRING(name) #name
  39. #define AQT_DAPM_ENUM(name, reg, offset, text) \
  40. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  41. static const struct snd_kcontrol_new name##_mux = \
  42. SOC_DAPM_ENUM(STRING(name), name##_enum)
  43. #define AQT_DAPM_ENUM_EXT(name, reg, offset, text, getname, putname) \
  44. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  45. static const struct snd_kcontrol_new name##_mux = \
  46. SOC_DAPM_ENUM_EXT(STRING(name), name##_enum, getname, putname)
  47. #define AQT_DAPM_MUX(name, shift, kctl) \
  48. SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, shift, 0, &kctl##_mux)
  49. #define AQT1000_INTERP_MUX_NUM_INPUTS 3
  50. #define AQT1000_RX_PATH_CTL_OFFSET 20
  51. #define BYTE_BIT_MASK(nr) (1 << ((nr) % BITS_PER_BYTE))
  52. #define AQT1000_REG_BITS 8
  53. #define AQT1000_MAX_VALID_ADC_MUX 3
  54. #define AQT1000_AMIC_PWR_LEVEL_LP 0
  55. #define AQT1000_AMIC_PWR_LEVEL_DEFAULT 1
  56. #define AQT1000_AMIC_PWR_LEVEL_HP 2
  57. #define AQT1000_AMIC_PWR_LVL_MASK 0x60
  58. #define AQT1000_AMIC_PWR_LVL_SHIFT 0x5
  59. #define AQT1000_DEC_PWR_LVL_MASK 0x06
  60. #define AQT1000_DEC_PWR_LVL_DF 0x00
  61. #define AQT1000_DEC_PWR_LVL_LP 0x02
  62. #define AQT1000_DEC_PWR_LVL_HP 0x04
  63. #define AQT1000_STRING_LEN 100
  64. #define AQT1000_CDC_SIDETONE_IIR_COEFF_MAX 5
  65. #define AQT1000_MAX_MICBIAS 1
  66. #define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
  67. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  68. #define CF_MIN_3DB_4HZ 0x0
  69. #define CF_MIN_3DB_75HZ 0x1
  70. #define CF_MIN_3DB_150HZ 0x2
  71. enum {
  72. AUDIO_NOMINAL,
  73. HPH_PA_DELAY,
  74. CLSH_Z_CONFIG,
  75. ANC_MIC_AMIC1,
  76. ANC_MIC_AMIC2,
  77. ANC_MIC_AMIC3,
  78. };
  79. enum {
  80. MIC_BIAS_1 = 1,
  81. };
  82. enum {
  83. MICB_PULLUP_ENABLE,
  84. MICB_PULLUP_DISABLE,
  85. MICB_ENABLE,
  86. MICB_DISABLE,
  87. };
  88. enum {
  89. INTn_1_INP_SEL_ZERO = 0,
  90. INTn_1_INP_SEL_DEC0,
  91. INTn_1_INP_SEL_DEC1,
  92. INTn_1_INP_SEL_IIR0,
  93. INTn_1_INP_SEL_IIR1,
  94. INTn_1_INP_SEL_RX0,
  95. INTn_1_INP_SEL_RX1,
  96. };
  97. enum {
  98. INTn_2_INP_SEL_ZERO = 0,
  99. INTn_2_INP_SEL_RX0,
  100. INTn_2_INP_SEL_RX1,
  101. INTn_2_INP_SEL_PROXIMITY,
  102. };
  103. /* Codec supports 2 IIR filters */
  104. enum {
  105. IIR0 = 0,
  106. IIR1,
  107. IIR_MAX,
  108. };
  109. enum {
  110. ASRC_IN_HPHL,
  111. ASRC_IN_HPHR,
  112. ASRC_INVALID,
  113. };
  114. enum {
  115. CONV_88P2K_TO_384K,
  116. CONV_96K_TO_352P8K,
  117. CONV_352P8K_TO_384K,
  118. CONV_384K_TO_352P8K,
  119. CONV_384K_TO_384K,
  120. CONV_96K_TO_384K,
  121. };
  122. enum aqt_notify_event {
  123. AQT_EVENT_INVALID,
  124. /* events for micbias ON and OFF */
  125. AQT_EVENT_PRE_MICBIAS_1_OFF,
  126. AQT_EVENT_POST_MICBIAS_1_OFF,
  127. AQT_EVENT_PRE_MICBIAS_1_ON,
  128. AQT_EVENT_POST_MICBIAS_1_ON,
  129. AQT_EVENT_PRE_DAPM_MICBIAS_1_OFF,
  130. AQT_EVENT_POST_DAPM_MICBIAS_1_OFF,
  131. AQT_EVENT_PRE_DAPM_MICBIAS_1_ON,
  132. AQT_EVENT_POST_DAPM_MICBIAS_1_ON,
  133. /* events for PA ON and OFF */
  134. AQT_EVENT_PRE_HPHL_PA_ON,
  135. AQT_EVENT_POST_HPHL_PA_OFF,
  136. AQT_EVENT_PRE_HPHR_PA_ON,
  137. AQT_EVENT_POST_HPHR_PA_OFF,
  138. AQT_EVENT_PRE_HPHL_PA_OFF,
  139. AQT_EVENT_PRE_HPHR_PA_OFF,
  140. AQT_EVENT_OCP_OFF,
  141. AQT_EVENT_OCP_ON,
  142. AQT_EVENT_LAST,
  143. };
  144. struct interp_sample_rate {
  145. int sample_rate;
  146. int rate_val;
  147. };
  148. extern struct regmap_config aqt1000_regmap_config;
  149. extern int aqt_register_codec(struct device *dev);
  150. #endif /* _AQT1000_INTERNAL_H */