aif.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* Copyright (C) 2016 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _AIF_H_
  13. #define _AIF_H_
  14. #ifdef CT_ASM
  15. #error "You are trying to use in an assembly code the normal H description of 'aif'."
  16. #endif
  17. // =============================================================================
  18. // MACROS
  19. // =============================================================================
  20. // ============================================================================
  21. // AIF_SAMPLING_RATE_T
  22. // -----------------------------------------------------------------------------
  23. ///
  24. // =============================================================================
  25. typedef enum
  26. {
  27. AIF_8K = 0x00000000,
  28. AIF_11K025 = 0x00000001,
  29. AIF_12K = 0x00000002,
  30. AIF_16K = 0x00000003,
  31. AIF_22K05 = 0x00000004,
  32. AIF_24K = 0x00000005,
  33. AIF_32K = 0x00000006,
  34. AIF_44K1 = 0x00000007,
  35. AIF_48K = 0x00000008
  36. } AIF_SAMPLING_RATE_T;
  37. #define AIF_RX_FIFO_SIZE (8)
  38. #define AIF_TX_FIFO_SIZE (8)
  39. // =============================================================================
  40. // TYPES
  41. // =============================================================================
  42. // ============================================================================
  43. // AIF_T
  44. // -----------------------------------------------------------------------------
  45. ///
  46. // =============================================================================
  47. //#define REG_AIF1_BASE 0x0881A000
  48. //#define REG_AIF2_BASE 0x0881B000
  49. #define REG_AIF_BASE 0x5140A000
  50. typedef volatile struct
  51. {
  52. REG32 data; //0x00000000
  53. REG32 ctrl; //0x00000004
  54. REG32 serial_ctrl; //0x00000008
  55. REG32 tone; //0x0000000C
  56. REG32 side_tone; //0x00000010
  57. REG32 rx_load_pos; //0x00000014
  58. REG32 fm_record_ctrl; //0x00000018
  59. } HWP_AIF_T;
  60. //#define hwp_aif1 ((HWP_AIF_T*) REG_ACCESS_ADDRESS(REG_AIF1_BASE))
  61. //#define hwp_aif2 ((HWP_AIF_T*) REG_ACCESS_ADDRESS(REG_AIF2_BASE))
  62. #define hwp_aif ((HWP_AIF_T *)REG_ACCESS_ADDRESS(REG_AIF_BASE))
  63. //data
  64. #define AIF_DATA0(n) (((n)&0xFFFF) << 0)
  65. #define AIF_DATA1(n) (((n)&0xFFFF) << 16)
  66. //ctrl
  67. #define AIF_ENABLE (1 << 0)
  68. #define AIF_ENABLE_ENABLE (1 << 0)
  69. #define AIF_ENABLE_DISABLE (0 << 0)
  70. #define AIF_TX_OFF (1 << 4)
  71. #define AIF_TX_OFF_TX_ON (0 << 4)
  72. #define AIF_TX_OFF_TX_OFF (1 << 4)
  73. #define AIF_PARALLEL_OUT_SET (1 << 8)
  74. #define AIF_PARALLEL_OUT_SET_SERL (0 << 8)
  75. #define AIF_PARALLEL_OUT_SET_PARA (1 << 8)
  76. #define AIF_PARALLEL_OUT_CLR (1 << 9)
  77. #define AIF_PARALLEL_OUT_CLR_SERL (0 << 9)
  78. #define AIF_PARALLEL_OUT_CLR_PARA (1 << 9)
  79. #define AIF_PARALLEL_IN_SET (1 << 10)
  80. #define AIF_PARALLEL_IN_SET_SERL (0 << 10)
  81. #define AIF_PARALLEL_IN_SET_PARA (1 << 10)
  82. #define AIF_PARALLEL_IN_CLR (1 << 11)
  83. #define AIF_PARALLEL_IN_CLR_SERL (0 << 11)
  84. #define AIF_PARALLEL_IN_CLR_PARA (1 << 11)
  85. #define AIF_TX_STB_MODE (1 << 12)
  86. #define AIF_OUT_UNDERFLOW (1 << 16)
  87. #define AIF_IN_OVERFLOW (1 << 17)
  88. #define AIF_LOOP_BACK (1 << 31)
  89. #define AIF_LOOP_BACK_NORMAL (0 << 31)
  90. #define AIF_LOOP_BACK_LOOPBACK (1 << 31)
  91. //serial_ctrl
  92. #define AIF_SERIAL_MODE(n) (((n)&3) << 0)
  93. #define AIF_SERIAL_MODE_I2S_PCM (0 << 0)
  94. #define AIF_SERIAL_MODE_VOICE (1 << 0)
  95. #define AIF_SERIAL_MODE_DAI (2 << 0)
  96. #define AIF_I2S_IN_SEL(n) (((n)&3) << 2)
  97. #define AIF_I2S_IN_SEL_I2S_IN_0 (0 << 2)
  98. #define AIF_I2S_IN_SEL_I2S_IN_1 (1 << 2)
  99. #define AIF_I2S_IN_SEL_I2S_IN_2 (2 << 2)
  100. #define AIF_MASTER_MODE (1 << 4)
  101. #define AIF_MASTER_MODE_SLAVE (0 << 4)
  102. #define AIF_MASTER_MODE_MASTER (1 << 4)
  103. #define AIF_LSB (1 << 5)
  104. #define AIF_LSB_MSB (0 << 5)
  105. #define AIF_LSB_LSB (1 << 5)
  106. #define AIF_LRCK_POL (1 << 6)
  107. #define AIF_LRCK_POL_LEFT_H_RIGHT_L (0 << 6)
  108. #define AIF_LRCK_POL_LEFT_L_RIGHT_H (1 << 6)
  109. #define AIF_LR_JUSTIFIED (1 << 7)
  110. #define AIF_RX_DLY(n) (((n)&3) << 8)
  111. #define AIF_RX_DLY_ALIGN (0 << 8)
  112. #define AIF_RX_DLY_DLY_1 (1 << 8)
  113. #define AIF_RX_DLY_DLY_2 (2 << 8)
  114. #define AIF_RX_DLY_DLY_3 (3 << 8)
  115. #define AIF_TX_DLY (1 << 10)
  116. #define AIF_TX_DLY_ALIGN (0 << 10)
  117. #define AIF_TX_DLY_DLY_1 (1 << 10)
  118. #define AIF_TX_DLY_S (1 << 11)
  119. #define AIF_TX_DLY_S_NO_DLY (0 << 11)
  120. #define AIF_TX_DLY_S_DLY (1 << 11)
  121. #define AIF_TX_MODE(n) (((n)&3) << 12)
  122. #define AIF_TX_MODE_STEREO_STEREO (0 << 12)
  123. #define AIF_TX_MODE_MONO_STEREO_CHAN_L (1 << 12)
  124. #define AIF_TX_MODE_MONO_STEREO_DUPLI (2 << 12)
  125. #define AIF_TX_MODE_STEREO_TO_MONO (3 << 12)
  126. #define AIF_RX_MODE (1 << 14)
  127. #define AIF_RX_MODE_STEREO_STEREO (0 << 14)
  128. #define AIF_RX_MODE_STEREO_MONO_FROM_L (1 << 14)
  129. #define AIF_BCK_LRCK(n) (((n)&31) << 16)
  130. #define AIF_BCK_LRCK_BCK_LRCK_16 (0 << 16)
  131. #define AIF_BCK_LRCK_BCK_LRCK_17 (1 << 16)
  132. #define AIF_BCK_LRCK_BCK_LRCK_18 (2 << 16)
  133. #define AIF_BCK_LRCK_BCK_LRCK_19 (3 << 16)
  134. #define AIF_BCK_LRCK_BCK_LRCK_20 (4 << 16)
  135. #define AIF_BCK_LRCK_BCK_LRCK_21 (5 << 16)
  136. #define AIF_BCK_LRCK_BCK_LRCK_22 (6 << 16)
  137. #define AIF_BCK_LRCK_BCK_LRCK_23 (7 << 16)
  138. #define AIF_BCK_LRCK_BCK_LRCK_24 (8 << 16)
  139. #define AIF_BCK_LRCK_BCK_LRCK_25 (9 << 16)
  140. #define AIF_BCK_LRCK_BCK_LRCK_26 (10 << 16)
  141. #define AIF_BCK_LRCK_BCK_LRCK_27 (11 << 16)
  142. #define AIF_BCK_LRCK_BCK_LRCK_28 (12 << 16)
  143. #define AIF_BCK_LRCK_BCK_LRCK_29 (13 << 16)
  144. #define AIF_BCK_LRCK_BCK_LRCK_30 (14 << 16)
  145. #define AIF_BCK_LRCK_BCK_LRCK_31 (15 << 16)
  146. #define AIF_BCK_LRCK_BCK_LRCK_32 (16 << 16)
  147. #define AIF_BCK_LRCK_BCK_LRCK_33 (17 << 16)
  148. #define AIF_BCK_LRCK_BCK_LRCK_34 (18 << 16)
  149. #define AIF_BCK_LRCK_BCK_LRCK_35 (19 << 16)
  150. #define AIF_BCK_LRCK_BCK_LRCK_36 (20 << 16)
  151. #define AIF_BCK_LRCK_BCK_LRCK_37 (21 << 16)
  152. #define AIF_BCK_LRCK_BCK_LRCK_38 (22 << 16)
  153. #define AIF_BCK_LRCK_BCK_LRCK_39 (23 << 16)
  154. #define AIF_BCK_LRCK_BCK_LRCK_40 (24 << 16)
  155. #define AIF_BCK_LRCK_BCK_LRCK_41 (25 << 16)
  156. #define AIF_BCK_LRCK_BCK_LRCK_42 (26 << 16)
  157. #define AIF_BCK_LRCK_BCK_LRCK_43 (27 << 16)
  158. #define AIF_BCK_LRCK_BCK_LRCK_44 (28 << 16)
  159. #define AIF_BCK_LRCK_BCK_LRCK_45 (29 << 16)
  160. #define AIF_BCK_LRCK_BCK_LRCK_46 (30 << 16)
  161. #define AIF_BCK_LRCK_BCK_LRCK_47 (31 << 16)
  162. #define AIF_BCK_POL (1 << 24)
  163. #define AIF_BCK_POL_NORMAL (0 << 24)
  164. #define AIF_BCK_POL_INVERT (1 << 24)
  165. #define AIF_OUTPUT_HALF_CYCLE_DLY (1 << 25)
  166. #define AIF_OUTPUT_HALF_CYCLE_DLY_NO_DLY (0 << 25)
  167. #define AIF_OUTPUT_HALF_CYCLE_DLY_DLY (1 << 25)
  168. #define AIF_INPUT_HALF_CYCLE_DLY (1 << 26)
  169. #define AIF_INPUT_HALF_CYCLE_DLY_NO_DLY (0 << 26)
  170. #define AIF_INPUT_HALF_CYCLE_DLY_DLY (1 << 26)
  171. #define AIF_BCKOUT_GATE (1 << 28)
  172. #define AIF_BCKOUT_GATE_NO_GATE (0 << 28)
  173. #define AIF_BCKOUT_GATE_GATED (1 << 28)
  174. //tone
  175. #define AIF_ENABLE_H (1 << 0)
  176. #define AIF_ENABLE_H_DISABLE (0 << 0)
  177. #define AIF_ENABLE_H_ENABLE (1 << 0)
  178. #define AIF_TONE_SELECT (1 << 1)
  179. #define AIF_TONE_SELECT_DTMF (0 << 1)
  180. #define AIF_TONE_SELECT_COMFORT_TONE (1 << 1)
  181. #define AIF_DTMF_FREQ_COL(n) (((n)&3) << 4)
  182. #define AIF_DTMF_FREQ_COL_1209_HZ (0 << 4)
  183. #define AIF_DTMF_FREQ_COL_1336_HZ (1 << 4)
  184. #define AIF_DTMF_FREQ_COL_1477_HZ (2 << 4)
  185. #define AIF_DTMF_FREQ_COL_1633_HZ (3 << 4)
  186. #define AIF_DTMF_FREQ_ROW(n) (((n)&3) << 6)
  187. #define AIF_DTMF_FREQ_ROW_697_HZ (0 << 6)
  188. #define AIF_DTMF_FREQ_ROW_770_HZ (1 << 6)
  189. #define AIF_DTMF_FREQ_ROW_852_HZ (2 << 6)
  190. #define AIF_DTMF_FREQ_ROW_941_HZ (3 << 6)
  191. #define AIF_COMFORT_FREQ(n) (((n)&3) << 8)
  192. #define AIF_COMFORT_FREQ_425_HZ (0 << 8)
  193. #define AIF_COMFORT_FREQ_950_HZ (1 << 8)
  194. #define AIF_COMFORT_FREQ_1400_HZ (2 << 8)
  195. #define AIF_COMFORT_FREQ_1800_HZ (3 << 8)
  196. #define AIF_TONE_GAIN(n) (((n)&3) << 12)
  197. #define AIF_TONE_GAIN_0_DB (0 << 12)
  198. #define AIF_TONE_GAIN_M3_DB (1 << 12)
  199. #define AIF_TONE_GAIN_M9_DB (2 << 12)
  200. #define AIF_TONE_GAIN_M15_DB (3 << 12)
  201. //side_tone
  202. #define AIF_SIDE_TONE_GAIN(n) (((n)&15) << 0)
  203. //rx_load_pos
  204. #define AIF_RX_LOAD_POSITION(n) (((n)&15) << 0)
  205. //fm_record_ctrl
  206. #define AIF_RECORD_EN (1 << 0)
  207. #define AIF_LR_SWAP (1 << 4)
  208. #endif