q6afe-v2.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __Q6AFE_V2_H__
  6. #define __Q6AFE_V2_H__
  7. #include <dsp/apr_audio-v2.h>
  8. #include <dsp/rtac.h>
  9. #define IN 0x000
  10. #define OUT 0x001
  11. #define MSM_AFE_MONO 0
  12. #define MSM_AFE_CH_STEREO 1
  13. #define MSM_AFE_MONO_RIGHT 1
  14. #define MSM_AFE_MONO_LEFT 2
  15. #define MSM_AFE_STEREO 3
  16. #define MSM_AFE_4CHANNELS 4
  17. #define MSM_AFE_6CHANNELS 6
  18. #define MSM_AFE_8CHANNELS 8
  19. #define MSM_AFE_10CHANNELS 10
  20. #define MSM_AFE_12CHANNELS 12
  21. #define MSM_AFE_14CHANNELS 14
  22. #define MSM_AFE_16CHANNELS 16
  23. #define MSM_AFE_I2S_FORMAT_LPCM 0
  24. #define MSM_AFE_I2S_FORMAT_COMPR 1
  25. #define MSM_AFE_I2S_FORMAT_IEC60958_LPCM 2
  26. #define MSM_AFE_I2S_FORMAT_IEC60958_COMPR 3
  27. #define MSM_AFE_PORT_TYPE_RX 0
  28. #define MSM_AFE_PORT_TYPE_TX 1
  29. #define RT_PROXY_DAI_001_RX 0xE0
  30. #define RT_PROXY_DAI_001_TX 0xF0
  31. #define RT_PROXY_DAI_002_RX 0xF1
  32. #define RT_PROXY_DAI_002_TX 0xE1
  33. #define RT_PROXY_DAI_003_TX 0xF2
  34. #define VIRTUAL_ID_TO_PORTID(val) ((val & 0xF) | 0x2000)
  35. #define AFE_CLK_VERSION_V1 1
  36. #define AFE_CLK_VERSION_V2 2
  37. #define AFE_API_VERSION_SUPPORT_SPV3 2
  38. #define AFE_API_VERSION_V3 3
  39. /* for VAD and Island mode */
  40. #define AFE_API_VERSION_V4 4
  41. /* for VAD enable */
  42. #define AFE_API_VERSION_V6 6
  43. /* for Speaker Protection V4 */
  44. #define AFE_API_VERSION_V9 9
  45. typedef int (*routing_cb)(int port);
  46. enum {
  47. /* IDX 0->4 */
  48. IDX_PRIMARY_I2S_RX,
  49. IDX_PRIMARY_I2S_TX,
  50. IDX_AFE_PORT_ID_PRIMARY_PCM_RX,
  51. IDX_AFE_PORT_ID_PRIMARY_PCM_TX,
  52. IDX_SECONDARY_I2S_RX,
  53. /* IDX 5->9 */
  54. IDX_SECONDARY_I2S_TX,
  55. IDX_MI2S_RX,
  56. IDX_MI2S_TX,
  57. IDX_HDMI_RX,
  58. IDX_RSVD_2,
  59. /* IDX 10->14 */
  60. IDX_RSVD_3,
  61. IDX_DIGI_MIC_TX,
  62. IDX_VOICE_RECORD_RX,
  63. IDX_VOICE_RECORD_TX,
  64. IDX_VOICE_PLAYBACK_TX,
  65. /* IDX 15->19 */
  66. IDX_SLIMBUS_0_RX,
  67. IDX_SLIMBUS_0_TX,
  68. IDX_SLIMBUS_1_RX,
  69. IDX_SLIMBUS_1_TX,
  70. IDX_SLIMBUS_2_RX,
  71. /* IDX 20->24 */
  72. IDX_SLIMBUS_2_TX,
  73. IDX_SLIMBUS_3_RX,
  74. IDX_SLIMBUS_3_TX,
  75. IDX_SLIMBUS_4_RX,
  76. IDX_SLIMBUS_4_TX,
  77. /* IDX 25->29 */
  78. IDX_SLIMBUS_5_RX,
  79. IDX_SLIMBUS_5_TX,
  80. IDX_INT_BT_SCO_RX,
  81. IDX_INT_BT_SCO_TX,
  82. IDX_INT_BT_A2DP_RX,
  83. /* IDX 30->34 */
  84. IDX_INT_FM_RX,
  85. IDX_INT_FM_TX,
  86. IDX_RT_PROXY_PORT_001_RX,
  87. IDX_RT_PROXY_PORT_001_TX,
  88. IDX_AFE_PORT_ID_QUATERNARY_MI2S_RX,
  89. /* IDX 35->39 */
  90. IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX,
  91. IDX_AFE_PORT_ID_SECONDARY_MI2S_RX,
  92. IDX_AFE_PORT_ID_SECONDARY_MI2S_TX,
  93. IDX_AFE_PORT_ID_TERTIARY_MI2S_RX,
  94. IDX_AFE_PORT_ID_TERTIARY_MI2S_TX,
  95. /* IDX 40->44 */
  96. IDX_AFE_PORT_ID_PRIMARY_MI2S_RX,
  97. IDX_AFE_PORT_ID_PRIMARY_MI2S_TX,
  98. IDX_AFE_PORT_ID_SECONDARY_PCM_RX,
  99. IDX_AFE_PORT_ID_SECONDARY_PCM_TX,
  100. IDX_VOICE2_PLAYBACK_TX,
  101. /* IDX 45->49 */
  102. IDX_SLIMBUS_6_RX,
  103. IDX_SLIMBUS_6_TX,
  104. IDX_PRIMARY_SPDIF_RX,
  105. IDX_GLOBAL_CFG,
  106. IDX_AUDIO_PORT_ID_I2S_RX,
  107. /* IDX 50->54 */
  108. IDX_AFE_PORT_ID_SECONDARY_MI2S_RX_SD1,
  109. IDX_AFE_PORT_ID_QUINARY_MI2S_RX,
  110. IDX_AFE_PORT_ID_QUINARY_MI2S_TX,
  111. IDX_AFE_PORT_ID_SENARY_MI2S_RX,
  112. IDX_AFE_PORT_ID_SENARY_MI2S_TX,
  113. /* IDX 55->118 */
  114. IDX_AFE_PORT_ID_PRIMARY_TDM_RX_0,
  115. IDX_AFE_PORT_ID_PRIMARY_TDM_TX_0,
  116. IDX_AFE_PORT_ID_PRIMARY_TDM_RX_1,
  117. IDX_AFE_PORT_ID_PRIMARY_TDM_TX_1,
  118. IDX_AFE_PORT_ID_PRIMARY_TDM_RX_2,
  119. IDX_AFE_PORT_ID_PRIMARY_TDM_TX_2,
  120. IDX_AFE_PORT_ID_PRIMARY_TDM_RX_3,
  121. IDX_AFE_PORT_ID_PRIMARY_TDM_TX_3,
  122. IDX_AFE_PORT_ID_PRIMARY_TDM_RX_4,
  123. IDX_AFE_PORT_ID_PRIMARY_TDM_TX_4,
  124. IDX_AFE_PORT_ID_PRIMARY_TDM_RX_5,
  125. IDX_AFE_PORT_ID_PRIMARY_TDM_TX_5,
  126. IDX_AFE_PORT_ID_PRIMARY_TDM_RX_6,
  127. IDX_AFE_PORT_ID_PRIMARY_TDM_TX_6,
  128. IDX_AFE_PORT_ID_PRIMARY_TDM_RX_7,
  129. IDX_AFE_PORT_ID_PRIMARY_TDM_TX_7,
  130. IDX_AFE_PORT_ID_SECONDARY_TDM_RX_0,
  131. IDX_AFE_PORT_ID_SECONDARY_TDM_TX_0,
  132. IDX_AFE_PORT_ID_SECONDARY_TDM_RX_1,
  133. IDX_AFE_PORT_ID_SECONDARY_TDM_TX_1,
  134. IDX_AFE_PORT_ID_SECONDARY_TDM_RX_2,
  135. IDX_AFE_PORT_ID_SECONDARY_TDM_TX_2,
  136. IDX_AFE_PORT_ID_SECONDARY_TDM_RX_3,
  137. IDX_AFE_PORT_ID_SECONDARY_TDM_TX_3,
  138. IDX_AFE_PORT_ID_SECONDARY_TDM_RX_4,
  139. IDX_AFE_PORT_ID_SECONDARY_TDM_TX_4,
  140. IDX_AFE_PORT_ID_SECONDARY_TDM_RX_5,
  141. IDX_AFE_PORT_ID_SECONDARY_TDM_TX_5,
  142. IDX_AFE_PORT_ID_SECONDARY_TDM_RX_6,
  143. IDX_AFE_PORT_ID_SECONDARY_TDM_TX_6,
  144. IDX_AFE_PORT_ID_SECONDARY_TDM_RX_7,
  145. IDX_AFE_PORT_ID_SECONDARY_TDM_TX_7,
  146. IDX_AFE_PORT_ID_TERTIARY_TDM_RX_0,
  147. IDX_AFE_PORT_ID_TERTIARY_TDM_TX_0,
  148. IDX_AFE_PORT_ID_TERTIARY_TDM_RX_1,
  149. IDX_AFE_PORT_ID_TERTIARY_TDM_TX_1,
  150. IDX_AFE_PORT_ID_TERTIARY_TDM_RX_2,
  151. IDX_AFE_PORT_ID_TERTIARY_TDM_TX_2,
  152. IDX_AFE_PORT_ID_TERTIARY_TDM_RX_3,
  153. IDX_AFE_PORT_ID_TERTIARY_TDM_TX_3,
  154. IDX_AFE_PORT_ID_TERTIARY_TDM_RX_4,
  155. IDX_AFE_PORT_ID_TERTIARY_TDM_TX_4,
  156. IDX_AFE_PORT_ID_TERTIARY_TDM_RX_5,
  157. IDX_AFE_PORT_ID_TERTIARY_TDM_TX_5,
  158. IDX_AFE_PORT_ID_TERTIARY_TDM_RX_6,
  159. IDX_AFE_PORT_ID_TERTIARY_TDM_TX_6,
  160. IDX_AFE_PORT_ID_TERTIARY_TDM_RX_7,
  161. IDX_AFE_PORT_ID_TERTIARY_TDM_TX_7,
  162. IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_0,
  163. IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_0,
  164. IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  165. IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  166. IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  167. IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  168. IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  169. IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  170. IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  171. IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  172. IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  173. IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  174. IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  175. IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  176. IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  177. IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  178. /* IDX 119->122 */
  179. IDX_SLIMBUS_7_RX,
  180. IDX_SLIMBUS_7_TX,
  181. IDX_SLIMBUS_8_RX,
  182. IDX_SLIMBUS_8_TX,
  183. /* IDX 123-> 124 */
  184. IDX_AFE_PORT_ID_USB_RX,
  185. IDX_AFE_PORT_ID_USB_TX,
  186. /* IDX 125 */
  187. IDX_DISPLAY_PORT_RX,
  188. /* IDX 126-> 129 */
  189. IDX_AFE_PORT_ID_TERTIARY_PCM_RX,
  190. IDX_AFE_PORT_ID_TERTIARY_PCM_TX,
  191. IDX_AFE_PORT_ID_QUATERNARY_PCM_RX,
  192. IDX_AFE_PORT_ID_QUATERNARY_PCM_TX,
  193. /* IDX 130-> 143 */
  194. IDX_AFE_PORT_ID_INT0_MI2S_RX,
  195. IDX_AFE_PORT_ID_INT0_MI2S_TX,
  196. IDX_AFE_PORT_ID_INT1_MI2S_RX,
  197. IDX_AFE_PORT_ID_INT1_MI2S_TX,
  198. IDX_AFE_PORT_ID_INT2_MI2S_RX,
  199. IDX_AFE_PORT_ID_INT2_MI2S_TX,
  200. IDX_AFE_PORT_ID_INT3_MI2S_RX,
  201. IDX_AFE_PORT_ID_INT3_MI2S_TX,
  202. IDX_AFE_PORT_ID_INT4_MI2S_RX,
  203. IDX_AFE_PORT_ID_INT4_MI2S_TX,
  204. IDX_AFE_PORT_ID_INT5_MI2S_RX,
  205. IDX_AFE_PORT_ID_INT5_MI2S_TX,
  206. IDX_AFE_PORT_ID_INT6_MI2S_RX,
  207. IDX_AFE_PORT_ID_INT6_MI2S_TX,
  208. /* IDX 144-> 161 */
  209. IDX_AFE_PORT_ID_QUINARY_PCM_RX,
  210. IDX_AFE_PORT_ID_QUINARY_PCM_TX,
  211. IDX_AFE_PORT_ID_QUINARY_TDM_RX_0,
  212. IDX_AFE_PORT_ID_QUINARY_TDM_TX_0,
  213. IDX_AFE_PORT_ID_QUINARY_TDM_RX_1,
  214. IDX_AFE_PORT_ID_QUINARY_TDM_TX_1,
  215. IDX_AFE_PORT_ID_QUINARY_TDM_RX_2,
  216. IDX_AFE_PORT_ID_QUINARY_TDM_TX_2,
  217. IDX_AFE_PORT_ID_QUINARY_TDM_RX_3,
  218. IDX_AFE_PORT_ID_QUINARY_TDM_TX_3,
  219. IDX_AFE_PORT_ID_QUINARY_TDM_RX_4,
  220. IDX_AFE_PORT_ID_QUINARY_TDM_TX_4,
  221. IDX_AFE_PORT_ID_QUINARY_TDM_RX_5,
  222. IDX_AFE_PORT_ID_QUINARY_TDM_TX_5,
  223. IDX_AFE_PORT_ID_QUINARY_TDM_RX_6,
  224. IDX_AFE_PORT_ID_QUINARY_TDM_TX_6,
  225. IDX_AFE_PORT_ID_QUINARY_TDM_RX_7,
  226. IDX_AFE_PORT_ID_QUINARY_TDM_TX_7,
  227. /* IDX 162 to 183 */
  228. IDX_AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  229. IDX_AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  230. IDX_AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  231. IDX_AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  232. IDX_AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  233. IDX_AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  234. IDX_AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  235. IDX_AFE_PORT_ID_VA_CODEC_DMA_TX_2,
  236. IDX_AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  237. IDX_AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  238. IDX_AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  239. IDX_AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  240. IDX_AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  241. IDX_AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  242. IDX_AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  243. IDX_AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  244. IDX_AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  245. IDX_AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  246. IDX_AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  247. IDX_AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  248. IDX_AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  249. IDX_AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  250. /* IDX 184 to 186 */
  251. IDX_SECONDARY_SPDIF_RX,
  252. IDX_PRIMARY_SPDIF_TX,
  253. IDX_SECONDARY_SPDIF_TX,
  254. /* IDX 187 to 188 */
  255. IDX_SLIMBUS_9_RX,
  256. IDX_SLIMBUS_9_TX,
  257. /* IDX 189 -> 191 */
  258. IDX_AFE_PORT_ID_SENARY_PCM_RX,
  259. IDX_AFE_PORT_ID_SENARY_PCM_TX,
  260. IDX_AFE_LOOPBACK_TX,
  261. /* IDX 192-> 207 */
  262. IDX_AFE_PORT_ID_SENARY_TDM_RX_0,
  263. IDX_AFE_PORT_ID_SENARY_TDM_TX_0,
  264. IDX_AFE_PORT_ID_SENARY_TDM_RX_1,
  265. IDX_AFE_PORT_ID_SENARY_TDM_TX_1,
  266. IDX_AFE_PORT_ID_SENARY_TDM_RX_2,
  267. IDX_AFE_PORT_ID_SENARY_TDM_TX_2,
  268. IDX_AFE_PORT_ID_SENARY_TDM_RX_3,
  269. IDX_AFE_PORT_ID_SENARY_TDM_TX_3,
  270. IDX_AFE_PORT_ID_SENARY_TDM_RX_4,
  271. IDX_AFE_PORT_ID_SENARY_TDM_TX_4,
  272. IDX_AFE_PORT_ID_SENARY_TDM_RX_5,
  273. IDX_AFE_PORT_ID_SENARY_TDM_TX_5,
  274. IDX_AFE_PORT_ID_SENARY_TDM_RX_6,
  275. IDX_AFE_PORT_ID_SENARY_TDM_TX_6,
  276. IDX_AFE_PORT_ID_SENARY_TDM_RX_7,
  277. IDX_AFE_PORT_ID_SENARY_TDM_TX_7,
  278. /* IDX 208-> 209 */
  279. IDX_AFE_PORT_ID_PRIMARY_META_MI2S_RX,
  280. IDX_AFE_PORT_ID_SECONDARY_META_MI2S_RX,
  281. /* IDX 210-> 211 */
  282. IDX_RT_PROXY_PORT_002_RX,
  283. IDX_RT_PROXY_PORT_002_TX,
  284. AFE_MAX_PORTS
  285. };
  286. enum afe_mad_type {
  287. MAD_HW_NONE = 0x00,
  288. MAD_HW_AUDIO = 0x01,
  289. MAD_HW_BEACON = 0x02,
  290. MAD_HW_ULTRASOUND = 0x04,
  291. MAD_SW_AUDIO = 0x05,
  292. };
  293. enum afe_cal_mode {
  294. AFE_CAL_MODE_DEFAULT = 0x00,
  295. AFE_CAL_MODE_NONE,
  296. };
  297. enum afe_vad_cfg_type {
  298. AFE_VAD_ENABLE = 0x00,
  299. AFE_VAD_PREROLL,
  300. };
  301. struct vad_config {
  302. u32 is_enable;
  303. u32 pre_roll;
  304. };
  305. struct afe_audio_buffer {
  306. dma_addr_t phys;
  307. void *data;
  308. uint32_t used;
  309. uint32_t size;/* size of buffer */
  310. uint32_t actual_size; /* actual number of bytes read by DSP */
  311. struct dma_buf *dma_buf;
  312. };
  313. struct afe_audio_port_data {
  314. struct afe_audio_buffer *buf;
  315. uint32_t max_buf_cnt;
  316. uint32_t dsp_buf;
  317. uint32_t cpu_buf;
  318. struct list_head mem_map_handle;
  319. uint32_t tmp_hdl;
  320. /* read or write locks */
  321. struct mutex lock;
  322. spinlock_t dsp_lock;
  323. };
  324. struct afe_audio_client {
  325. atomic_t cmd_state;
  326. /* Relative or absolute TS */
  327. uint32_t time_flag;
  328. void *priv;
  329. uint64_t time_stamp;
  330. struct mutex cmd_lock;
  331. /* idx:1 out port, 0: in port*/
  332. struct afe_audio_port_data port[2];
  333. wait_queue_head_t cmd_wait;
  334. uint32_t mem_map_handle;
  335. };
  336. struct aanc_data {
  337. bool aanc_active;
  338. uint16_t aanc_rx_port;
  339. uint16_t aanc_tx_port;
  340. uint32_t aanc_rx_port_sample_rate;
  341. uint32_t aanc_tx_port_sample_rate;
  342. int level;
  343. };
  344. int afe_open(u16 port_id, union afe_port_config *afe_config, int rate);
  345. int afe_close(int port_id);
  346. int afe_loopback(u16 enable, u16 rx_port, u16 tx_port);
  347. int afe_sidetone_enable(u16 tx_port_id, u16 rx_port_id, bool enable);
  348. int afe_set_display_stream(u16 rx_port_id, u32 stream_idx, u32 ctl_idx);
  349. int afe_loopback_gain(u16 port_id, u16 volume);
  350. int afe_validate_port(u16 port_id);
  351. int afe_get_port_index(u16 port_id);
  352. int afe_get_topology(int port_id);
  353. int afe_start_pseudo_port(u16 port_id);
  354. int afe_stop_pseudo_port(u16 port_id);
  355. uint32_t afe_req_mmap_handle(struct afe_audio_client *ac);
  356. int afe_memory_map(phys_addr_t dma_addr_p, u32 dma_buf_sz,
  357. struct afe_audio_client *ac);
  358. int afe_cmd_memory_map(phys_addr_t dma_addr_p, u32 dma_buf_sz);
  359. int afe_cmd_memory_map_nowait(int port_id, phys_addr_t dma_addr_p,
  360. u32 dma_buf_sz);
  361. int afe_cmd_memory_unmap(u32 dma_addr_p);
  362. int afe_cmd_memory_unmap_nowait(u32 dma_addr_p);
  363. void afe_set_dtmf_gen_rx_portid(u16 rx_port_id, int set);
  364. int afe_dtmf_generate_rx(int64_t duration_in_ms,
  365. uint16_t high_freq,
  366. uint16_t low_freq, uint16_t gain);
  367. int afe_register_get_events(u16 port_id,
  368. void (*cb)(uint32_t opcode,
  369. uint32_t token, uint32_t *payload, void *priv),
  370. void *private_data);
  371. int afe_unregister_get_events(u16 port_id);
  372. int afe_rt_proxy_port_write(phys_addr_t buf_addr_p,
  373. u32 mem_map_handle, int bytes);
  374. int afe_rt_proxy_port_read(phys_addr_t buf_addr_p,
  375. u32 mem_map_handle, int bytes, int id);
  376. void afe_set_cal_mode(u16 port_id, enum afe_cal_mode afe_cal_mode);
  377. void afe_set_vad_cfg(u32 vad_enable, u32 preroll_config,
  378. u32 port_id);
  379. void afe_set_island_mode_cfg(u16 port_id, u32 enable_flag);
  380. void afe_get_island_mode_cfg(u16 port_id, u32 *enable_flag);
  381. int afe_port_start(u16 port_id, union afe_port_config *afe_config,
  382. u32 rate);
  383. int afe_set_tws_channel_mode(u32 foramt, u16 port_id, u32 channel_mode);
  384. int afe_port_start_v2(u16 port_id, union afe_port_config *afe_config,
  385. u32 rate, u16 afe_in_channels, u16 afe_in_bit_width,
  386. struct afe_enc_config *enc_config,
  387. struct afe_dec_config *dec_config);
  388. int afe_spk_prot_feed_back_cfg(int src_port, int dst_port,
  389. int l_ch, int r_ch, u32 enable);
  390. int afe_spk_prot_get_calib_data(struct afe_spkr_prot_get_vi_calib *calib);
  391. int afe_port_stop_nowait(int port_id);
  392. int afe_apply_gain(u16 port_id, u16 gain);
  393. int afe_q6_interface_prepare(void);
  394. int afe_get_port_type(u16 port_id);
  395. int q6afe_audio_client_buf_alloc_contiguous(unsigned int dir,
  396. struct afe_audio_client *ac,
  397. unsigned int bufsz,
  398. unsigned int bufcnt);
  399. struct afe_audio_client *q6afe_audio_client_alloc(void *priv);
  400. int q6afe_audio_client_buf_free_contiguous(unsigned int dir,
  401. struct afe_audio_client *ac);
  402. void q6afe_audio_client_free(struct afe_audio_client *ac);
  403. /* if port_id is virtual, convert to physical..
  404. * if port_id is already physical, return physical
  405. */
  406. int afe_convert_virtual_to_portid(u16 port_id);
  407. int afe_pseudo_port_start_nowait(u16 port_id);
  408. int afe_pseudo_port_stop_nowait(u16 port_id);
  409. int afe_set_lpass_clock(u16 port_id, struct afe_clk_cfg *cfg);
  410. int afe_set_lpass_clock_v2(u16 port_id, struct afe_clk_set *cfg);
  411. int afe_set_lpass_clk_cfg(int index, struct afe_clk_set *cfg);
  412. int afe_set_digital_codec_core_clock(u16 port_id,
  413. struct afe_digital_clk_cfg *cfg);
  414. int afe_set_lpass_internal_digital_codec_clock(u16 port_id,
  415. struct afe_digital_clk_cfg *cfg);
  416. int afe_enable_lpass_core_shared_clock(u16 port_id, u32 enable);
  417. int q6afe_check_osr_clk_freq(u32 freq);
  418. int afe_send_spdif_clk_cfg(struct afe_param_id_spdif_clk_cfg *cfg,
  419. u16 port_id);
  420. int afe_send_spdif_ch_status_cfg(struct afe_param_id_spdif_ch_status_cfg
  421. *ch_status_cfg, u16 port_id);
  422. int afe_spdif_port_start(u16 port_id, struct afe_spdif_port_config *spdif_port,
  423. u32 rate);
  424. int afe_spdif_reg_event_cfg(u16 port_id, u16 reg_flag,
  425. void (*cb)(uint32_t opcode,
  426. uint32_t token, uint32_t *payload, void *priv),
  427. void *private_data);
  428. int afe_turn_onoff_hw_mad(u16 mad_type, u16 mad_enable);
  429. int afe_port_set_mad_type(u16 port_id, enum afe_mad_type mad_type);
  430. enum afe_mad_type afe_port_get_mad_type(u16 port_id);
  431. int afe_set_config(enum afe_config_type config_type, void *config_data,
  432. int arg);
  433. void afe_clear_config(enum afe_config_type config);
  434. bool afe_has_config(enum afe_config_type config);
  435. void afe_set_aanc_info(struct aanc_data *aanc_info);
  436. int afe_set_aanc_noise_level(int val);
  437. int afe_port_group_set_param(u16 group_id,
  438. union afe_port_group_config *afe_group_config);
  439. int afe_port_group_enable(u16 group_id,
  440. union afe_port_group_config *afe_group_config, u16 enable,
  441. struct afe_param_id_tdm_lane_cfg *lane_cfg);
  442. int afe_unmap_rtac_block(uint32_t *mem_map_handle);
  443. int afe_map_rtac_block(struct rtac_cal_block_data *cal_block);
  444. int afe_send_slot_mapping_cfg(
  445. struct afe_param_id_slot_mapping_cfg *slot_mapping_cfg,
  446. u16 port_id);
  447. int afe_send_custom_tdm_header_cfg(
  448. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header_cfg,
  449. u16 port_id);
  450. int afe_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port,
  451. u32 rate, u16 num_groups);
  452. void afe_set_routing_callback(routing_cb cb);
  453. int afe_get_av_dev_drift(struct afe_param_id_dev_timing_stats *timing_stats,
  454. u16 port);
  455. int afe_get_sp_rx_tmax_xmax_logging_data(
  456. struct afe_sp_rx_tmax_xmax_logging_param *xt_logging,
  457. u16 port_id);
  458. int afe_cal_init_hwdep(void *card);
  459. int afe_send_port_island_mode(u16 port_id);
  460. int afe_send_port_vad_cfg_params(u16 port_id);
  461. int afe_send_cmd_wakeup_register(void *handle, bool enable);
  462. void afe_register_wakeup_irq_callback(
  463. void (*afe_cb_wakeup_irq)(void *handle));
  464. int afe_get_doa_tracking_mon(u16 port_id,
  465. struct doa_tracking_mon_param *doa_tracking_data);
  466. enum {
  467. AFE_LPASS_CORE_HW_BLOCK_ID_NONE,
  468. AFE_LPASS_CORE_HW_RSVD,
  469. AFE_LPASS_CORE_HW_BLOCK_ID_AVTIMER,
  470. AFE_LPASS_CORE_HW_MACRO_BLOCK,
  471. AFE_LPASS_CORE_HW_DCODEC_BLOCK,
  472. AFE_LPASS_CORE_HW_VOTE_MAX
  473. };
  474. /* Handles audio-video timer (avtimer) and BTSC vote requests from clients.
  475. */
  476. #define AFE_CMD_REMOTE_LPASS_CORE_HW_VOTE_REQUEST 0x000100f4
  477. struct afe_cmd_remote_lpass_core_hw_vote_request {
  478. struct apr_hdr hdr;
  479. uint32_t hw_block_id;
  480. /* ID of the hardware block. */
  481. char client_name[8];
  482. /* Name of the client. */
  483. } __packed;
  484. #define AFE_CMD_RSP_REMOTE_LPASS_CORE_HW_VOTE_REQUEST 0x000100f5
  485. struct afe_cmd_rsp_remote_lpass_core_hw_vote_request {
  486. uint32_t client_handle;
  487. /**< Handle of the client. */
  488. } __packed;
  489. #define AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST 0x000100f6
  490. struct afe_cmd_remote_lpass_core_hw_devote_request {
  491. struct apr_hdr hdr;
  492. uint32_t hw_block_id;
  493. /**< ID of the hardware block.*/
  494. uint32_t client_handle;
  495. /**< Handle of the client.*/
  496. } __packed;
  497. int afe_vote_lpass_core_hw(uint32_t hw_block_id, char *client_name,
  498. uint32_t *client_handle);
  499. int afe_unvote_lpass_core_hw(uint32_t hw_block_id, uint32_t client_handle);
  500. int afe_get_spk_initial_cal(void);
  501. void afe_get_spk_r0(int *spk_r0);
  502. void afe_get_spk_t0(int *spk_t0);
  503. int afe_get_spk_v_vali_flag(void);
  504. void afe_get_spk_v_vali_sts(int *spk_v_vali_sts);
  505. void afe_set_spk_initial_cal(int initial_cal);
  506. void afe_set_spk_v_vali_flag(int v_vali_flag);
  507. #endif /* __Q6AFE_V2_H__ */