audioreach.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __AUDIOREACH_H__
  3. #define __AUDIOREACH_H__
  4. #include <linux/types.h>
  5. #include <linux/soc/qcom/apr.h>
  6. #include <sound/soc.h>
  7. struct q6apm;
  8. struct q6apm_graph;
  9. /* Module IDs */
  10. #define MODULE_ID_WR_SHARED_MEM_EP 0x07001000
  11. #define MODULE_ID_RD_SHARED_MEM_EP 0x07001001
  12. #define MODULE_ID_GAIN 0x07001002
  13. #define MODULE_ID_PCM_CNV 0x07001003
  14. #define MODULE_ID_PCM_ENC 0x07001004
  15. #define MODULE_ID_PCM_DEC 0x07001005
  16. #define MODULE_ID_CODEC_DMA_SINK 0x07001023
  17. #define MODULE_ID_CODEC_DMA_SOURCE 0x07001024
  18. #define MODULE_ID_I2S_SINK 0x0700100A
  19. #define MODULE_ID_I2S_SOURCE 0x0700100B
  20. #define MODULE_ID_DATA_LOGGING 0x0700101A
  21. #define APM_CMD_GET_SPF_STATE 0x01001021
  22. #define APM_CMD_RSP_GET_SPF_STATE 0x02001007
  23. #define APM_MODULE_INSTANCE_ID 0x00000001
  24. #define PRM_MODULE_INSTANCE_ID 0x00000002
  25. #define AMDB_MODULE_INSTANCE_ID 0x00000003
  26. #define VCPM_MODULE_INSTANCE_ID 0x00000004
  27. #define AR_MODULE_INSTANCE_ID_START 0x00006000
  28. #define AR_MODULE_INSTANCE_ID_END 0x00007000
  29. #define AR_MODULE_DYNAMIC_INSTANCE_ID_START 0x00007000
  30. #define AR_MODULE_DYNAMIC_INSTANCE_ID_END 0x00008000
  31. #define AR_CONT_INSTANCE_ID_START 0x00005000
  32. #define AR_CONT_INSTANCE_ID_END 0x00006000
  33. #define AR_SG_INSTANCE_ID_START 0x00004000
  34. #define APM_CMD_GRAPH_OPEN 0x01001000
  35. #define APM_CMD_GRAPH_PREPARE 0x01001001
  36. #define APM_CMD_GRAPH_START 0x01001002
  37. #define APM_CMD_GRAPH_STOP 0x01001003
  38. #define APM_CMD_GRAPH_CLOSE 0x01001004
  39. #define APM_CMD_GRAPH_FLUSH 0x01001005
  40. #define APM_CMD_SET_CFG 0x01001006
  41. #define APM_CMD_GET_CFG 0x01001007
  42. #define APM_CMD_SHARED_MEM_MAP_REGIONS 0x0100100C
  43. #define APM_CMD_SHARED_MEM_UNMAP_REGIONS 0x0100100D
  44. #define APM_CMD_RSP_SHARED_MEM_MAP_REGIONS 0x02001001
  45. #define APM_CMD_RSP_GET_CFG 0x02001000
  46. #define APM_CMD_CLOSE_ALL 0x01001013
  47. #define APM_CMD_REGISTER_SHARED_CFG 0x0100100A
  48. #define APM_MEMORY_MAP_SHMEM8_4K_POOL 3
  49. struct apm_cmd_shared_mem_map_regions {
  50. uint16_t mem_pool_id;
  51. uint16_t num_regions;
  52. uint32_t property_flag;
  53. } __packed;
  54. struct apm_shared_map_region_payload {
  55. uint32_t shm_addr_lsw;
  56. uint32_t shm_addr_msw;
  57. uint32_t mem_size_bytes;
  58. } __packed;
  59. struct apm_cmd_shared_mem_unmap_regions {
  60. uint32_t mem_map_handle;
  61. } __packed;
  62. struct apm_cmd_rsp_shared_mem_map_regions {
  63. uint32_t mem_map_handle;
  64. } __packed;
  65. /* APM module */
  66. #define APM_PARAM_ID_SUB_GRAPH_LIST 0x08001005
  67. #define APM_PARAM_ID_MODULE_LIST 0x08001002
  68. struct apm_param_id_modules_list {
  69. uint32_t num_modules_list;
  70. } __packed;
  71. #define APM_PARAM_ID_MODULE_PROP 0x08001003
  72. struct apm_param_id_module_prop {
  73. uint32_t num_modules_prop_cfg;
  74. } __packed;
  75. struct apm_module_prop_cfg {
  76. uint32_t instance_id;
  77. uint32_t num_props;
  78. } __packed;
  79. #define APM_PARAM_ID_MODULE_CONN 0x08001004
  80. struct apm_param_id_module_conn {
  81. uint32_t num_connections;
  82. } __packed;
  83. struct apm_module_conn_obj {
  84. uint32_t src_mod_inst_id;
  85. uint32_t src_mod_op_port_id;
  86. uint32_t dst_mod_inst_id;
  87. uint32_t dst_mod_ip_port_id;
  88. } __packed;
  89. #define APM_PARAM_ID_GAIN 0x08001006
  90. struct param_id_gain_cfg {
  91. uint16_t gain;
  92. uint16_t reserved;
  93. } __packed;
  94. #define PARAM_ID_PCM_OUTPUT_FORMAT_CFG 0x08001008
  95. struct param_id_pcm_output_format_cfg {
  96. uint32_t data_format;
  97. uint32_t fmt_id;
  98. uint32_t payload_size;
  99. } __packed;
  100. struct payload_pcm_output_format_cfg {
  101. uint16_t bit_width;
  102. uint16_t alignment;
  103. uint16_t bits_per_sample;
  104. uint16_t q_factor;
  105. uint16_t endianness;
  106. uint16_t interleaved;
  107. uint16_t reserved;
  108. uint16_t num_channels;
  109. uint8_t channel_mapping[];
  110. } __packed;
  111. #define PARAM_ID_ENC_BITRATE 0x08001052
  112. struct param_id_enc_bitrate_param {
  113. uint32_t bitrate;
  114. } __packed;
  115. #define DATA_FORMAT_FIXED_POINT 1
  116. #define PCM_LSB_ALIGNED 1
  117. #define PCM_MSB_ALIGNED 2
  118. #define PCM_LITTLE_ENDIAN 1
  119. #define PCM_BIT_ENDIAN 2
  120. #define MEDIA_FMT_ID_PCM 0x09001000
  121. #define PCM_CHANNEL_L 1
  122. #define PCM_CHANNEL_R 2
  123. #define SAMPLE_RATE_48K 48000
  124. #define BIT_WIDTH_16 16
  125. #define APM_PARAM_ID_PROP_PORT_INFO 0x08001015
  126. struct apm_modules_prop_info {
  127. uint32_t max_ip_port;
  128. uint32_t max_op_port;
  129. } __packed;
  130. /* Shared memory module */
  131. #define DATA_CMD_WR_SH_MEM_EP_DATA_BUFFER 0x04001000
  132. #define WR_SH_MEM_EP_TIMESTAMP_VALID_FLAG BIT(31)
  133. #define WR_SH_MEM_EP_LAST_BUFFER_FLAG BIT(30)
  134. #define WR_SH_MEM_EP_TS_CONTINUE_FLAG BIT(29)
  135. #define WR_SH_MEM_EP_EOF_FLAG BIT(4)
  136. struct apm_data_cmd_wr_sh_mem_ep_data_buffer {
  137. uint32_t buf_addr_lsw;
  138. uint32_t buf_addr_msw;
  139. uint32_t mem_map_handle;
  140. uint32_t buf_size;
  141. uint32_t timestamp_lsw;
  142. uint32_t timestamp_msw;
  143. uint32_t flags;
  144. } __packed;
  145. #define DATA_CMD_WR_SH_MEM_EP_DATA_BUFFER_V2 0x0400100A
  146. struct apm_data_cmd_wr_sh_mem_ep_data_buffer_v2 {
  147. uint32_t buf_addr_lsw;
  148. uint32_t buf_addr_msw;
  149. uint32_t mem_map_handle;
  150. uint32_t buf_size;
  151. uint32_t timestamp_lsw;
  152. uint32_t timestamp_msw;
  153. uint32_t flags;
  154. uint32_t md_addr_lsw;
  155. uint32_t md_addr_msw;
  156. uint32_t md_map_handle;
  157. uint32_t md_buf_size;
  158. } __packed;
  159. #define DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE 0x05001000
  160. struct data_cmd_rsp_wr_sh_mem_ep_data_buffer_done {
  161. uint32_t buf_addr_lsw;
  162. uint32_t buf_addr_msw;
  163. uint32_t mem_map_handle;
  164. uint32_t status;
  165. } __packed;
  166. #define DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE_V2 0x05001004
  167. struct data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_v2 {
  168. uint32_t buf_addr_lsw;
  169. uint32_t buf_addr_msw;
  170. uint32_t mem_map_handle;
  171. uint32_t status;
  172. uint32_t md_buf_addr_lsw;
  173. uint32_t md_buf_addr_msw;
  174. uint32_t md_mem_map_handle;
  175. uint32_t md_status;
  176. } __packed;
  177. #define PARAM_ID_MEDIA_FORMAT 0x0800100C
  178. #define DATA_CMD_WR_SH_MEM_EP_MEDIA_FORMAT 0x04001001
  179. struct apm_media_format {
  180. uint32_t data_format;
  181. uint32_t fmt_id;
  182. uint32_t payload_size;
  183. } __packed;
  184. #define DATA_CMD_WR_SH_MEM_EP_EOS 0x04001002
  185. #define WR_SH_MEM_EP_EOS_POLICY_LAST 1
  186. #define WR_SH_MEM_EP_EOS_POLICY_EACH 2
  187. struct data_cmd_wr_sh_mem_ep_eos {
  188. uint32_t policy;
  189. } __packed;
  190. #define DATA_CMD_RD_SH_MEM_EP_DATA_BUFFER 0x04001003
  191. struct data_cmd_rd_sh_mem_ep_data_buffer {
  192. uint32_t buf_addr_lsw;
  193. uint32_t buf_addr_msw;
  194. uint32_t mem_map_handle;
  195. uint32_t buf_size;
  196. } __packed;
  197. #define DATA_CMD_RSP_RD_SH_MEM_EP_DATA_BUFFER 0x05001002
  198. struct data_cmd_rsp_rd_sh_mem_ep_data_buffer_done {
  199. uint32_t status;
  200. uint32_t buf_addr_lsw;
  201. uint32_t buf_addr_msw;
  202. uint32_t mem_map_handle;
  203. uint32_t data_size;
  204. uint32_t offset;
  205. uint32_t timestamp_lsw;
  206. uint32_t timestamp_msw;
  207. uint32_t flags;
  208. uint32_t num_frames;
  209. } __packed;
  210. #define DATA_CMD_RD_SH_MEM_EP_DATA_BUFFER_V2 0x0400100B
  211. struct data_cmd_rd_sh_mem_ep_data_buffer_v2 {
  212. uint32_t buf_addr_lsw;
  213. uint32_t buf_addr_msw;
  214. uint32_t mem_map_handle;
  215. uint32_t buf_size;
  216. uint32_t md_buf_addr_lsw;
  217. uint32_t md_buf_addr_msw;
  218. uint32_t md_mem_map_handle;
  219. uint32_t md_buf_size;
  220. } __packed;
  221. #define DATA_CMD_RSP_RD_SH_MEM_EP_DATA_BUFFER_V2 0x05001005
  222. struct data_cmd_rsp_rd_sh_mem_ep_data_buffer_done_v2 {
  223. uint32_t status;
  224. uint32_t buf_addr_lsw;
  225. uint32_t buf_addr_msw;
  226. uint32_t mem_map_handle;
  227. uint32_t data_size;
  228. uint32_t offset;
  229. uint32_t timestamp_lsw;
  230. uint32_t timestamp_msw;
  231. uint32_t flags;
  232. uint32_t num_frames;
  233. uint32_t md_status;
  234. uint32_t md_buf_addr_lsw;
  235. uint32_t md_buf_addr_msw;
  236. uint32_t md_mem_map_handle;
  237. uint32_t md_size;
  238. } __packed;
  239. #define PARAM_ID_RD_SH_MEM_CFG 0x08001007
  240. struct param_id_rd_sh_mem_cfg {
  241. uint32_t num_frames_per_buffer;
  242. uint32_t metadata_control_flags;
  243. } __packed;
  244. #define DATA_CMD_WR_SH_MEM_EP_EOS_RENDERED 0x05001001
  245. struct data_cmd_wr_sh_mem_ep_eos_rendered {
  246. uint32_t module_instance_id;
  247. uint32_t render_status;
  248. } __packed;
  249. #define MODULE_ID_WR_SHARED_MEM_EP 0x07001000
  250. struct apm_cmd_header {
  251. uint32_t payload_address_lsw;
  252. uint32_t payload_address_msw;
  253. uint32_t mem_map_handle;
  254. uint32_t payload_size;
  255. } __packed;
  256. #define APM_CMD_HDR_SIZE sizeof(struct apm_cmd_header)
  257. struct apm_module_param_data {
  258. uint32_t module_instance_id;
  259. uint32_t param_id;
  260. uint32_t param_size;
  261. uint32_t error_code;
  262. } __packed;
  263. #define APM_MODULE_PARAM_DATA_SIZE sizeof(struct apm_module_param_data)
  264. struct apm_module_param_shared_data {
  265. uint32_t param_id;
  266. uint32_t param_size;
  267. } __packed;
  268. struct apm_prop_data {
  269. uint32_t prop_id;
  270. uint32_t prop_size;
  271. } __packed;
  272. /* Sub-Graph Properties */
  273. #define APM_PARAM_ID_SUB_GRAPH_CONFIG 0x08001001
  274. struct apm_param_id_sub_graph_cfg {
  275. uint32_t num_sub_graphs;
  276. } __packed;
  277. struct apm_sub_graph_cfg {
  278. uint32_t sub_graph_id;
  279. uint32_t num_sub_graph_prop;
  280. } __packed;
  281. #define APM_SUB_GRAPH_PROP_ID_PERF_MODE 0x0800100E
  282. struct apm_sg_prop_id_perf_mode {
  283. uint32_t perf_mode;
  284. } __packed;
  285. #define APM_SG_PROP_ID_PERF_MODE_SIZE 4
  286. #define APM_SUB_GRAPH_PROP_ID_DIRECTION 0x0800100F
  287. struct apm_sg_prop_id_direction {
  288. uint32_t direction;
  289. } __packed;
  290. #define APM_SG_PROP_ID_DIR_SIZE 4
  291. #define APM_SUB_GRAPH_PROP_ID_SCENARIO_ID 0x08001010
  292. #define APM_SUB_GRAPH_SID_AUDIO_PLAYBACK 0x1
  293. #define APM_SUB_GRAPH_SID_AUDIO_RECORD 0x2
  294. #define APM_SUB_GRAPH_SID_AUDIO_VOICE_CALL 0x3
  295. struct apm_sg_prop_id_scenario_id {
  296. uint32_t scenario_id;
  297. } __packed;
  298. #define APM_SG_PROP_ID_SID_SIZE 4
  299. /* container api */
  300. #define APM_PARAM_ID_CONTAINER_CONFIG 0x08001000
  301. struct apm_param_id_container_cfg {
  302. uint32_t num_containers;
  303. } __packed;
  304. struct apm_container_cfg {
  305. uint32_t container_id;
  306. uint32_t num_prop;
  307. } __packed;
  308. struct apm_cont_capability {
  309. uint32_t capability_id;
  310. } __packed;
  311. #define APM_CONTAINER_PROP_ID_CAPABILITY_LIST 0x08001011
  312. #define APM_CONTAINER_PROP_ID_CAPABILITY_SIZE 8
  313. #define APM_PROP_ID_INVALID 0x0
  314. #define APM_CONTAINER_CAP_ID_PP 0x1
  315. #define APM_CONTAINER_CAP_ID_PP 0x1
  316. struct apm_cont_prop_id_cap_list {
  317. uint32_t num_capability_id;
  318. } __packed;
  319. #define APM_CONTAINER_PROP_ID_GRAPH_POS 0x08001012
  320. struct apm_cont_prop_id_graph_pos {
  321. uint32_t graph_pos;
  322. } __packed;
  323. #define APM_CONTAINER_PROP_ID_STACK_SIZE 0x08001013
  324. struct apm_cont_prop_id_stack_size {
  325. uint32_t stack_size;
  326. } __packed;
  327. #define APM_CONTAINER_PROP_ID_PROC_DOMAIN 0x08001014
  328. struct apm_cont_prop_id_domain {
  329. uint32_t proc_domain;
  330. } __packed;
  331. #define CONFIG_I2S_WS_SRC_EXTERNAL 0x0
  332. #define CONFIG_I2S_WS_SRC_INTERNAL 0x1
  333. #define PARAM_ID_I2S_INTF_CFG 0x08001019
  334. struct param_id_i2s_intf_cfg {
  335. uint32_t lpaif_type;
  336. uint32_t intf_idx;
  337. uint16_t sd_line_idx;
  338. uint16_t ws_src;
  339. } __packed;
  340. #define I2S_INTF_TYPE_PRIMARY 0
  341. #define I2S_INTF_TYPE_SECOINDARY 1
  342. #define I2S_INTF_TYPE_TERTINARY 2
  343. #define I2S_INTF_TYPE_QUATERNARY 3
  344. #define I2S_INTF_TYPE_QUINARY 4
  345. #define I2S_SD0 1
  346. #define I2S_SD1 2
  347. #define I2S_SD2 3
  348. #define I2S_SD3 4
  349. #define PORT_ID_I2S_INPUT 2
  350. #define PORT_ID_I2S_OUPUT 1
  351. #define I2S_STACK_SIZE 2048
  352. #define PARAM_ID_HW_EP_MF_CFG 0x08001017
  353. struct param_id_hw_ep_mf {
  354. uint32_t sample_rate;
  355. uint16_t bit_width;
  356. uint16_t num_channels;
  357. uint32_t data_format;
  358. } __packed;
  359. #define PARAM_ID_HW_EP_FRAME_SIZE_FACTOR 0x08001018
  360. struct param_id_fram_size_factor {
  361. uint32_t frame_size_factor;
  362. } __packed;
  363. #define APM_CONTAINER_PROP_ID_PARENT_CONTAINER_ID 0x080010CB
  364. struct apm_cont_prop_id_parent_container {
  365. uint32_t parent_container_id;
  366. } __packed;
  367. #define APM_CONTAINER_PROP_ID_HEAP_ID 0x08001174
  368. #define APM_CONT_HEAP_DEFAULT 0x1
  369. #define APM_CONT_HEAP_LOW_POWER 0x2
  370. struct apm_cont_prop_id_headp_id {
  371. uint32_t heap_id;
  372. } __packed;
  373. struct apm_modules_list {
  374. uint32_t sub_graph_id;
  375. uint32_t container_id;
  376. uint32_t num_modules;
  377. } __packed;
  378. struct apm_module_obj {
  379. uint32_t module_id;
  380. uint32_t instance_id;
  381. } __packed;
  382. #define APM_MODULE_PROP_ID_PORT_INFO 0x08001015
  383. #define APM_MODULE_PROP_ID_PORT_INFO_SZ 8
  384. struct apm_module_prop_id_port_info {
  385. uint32_t max_ip_port;
  386. uint32_t max_op_port;
  387. } __packed;
  388. #define DATA_LOGGING_MAX_INPUT_PORTS 0x1
  389. #define DATA_LOGGING_MAX_OUTPUT_PORTS 0x1
  390. #define DATA_LOGGING_STACK_SIZE 2048
  391. #define PARAM_ID_DATA_LOGGING_CONFIG 0x08001031
  392. struct data_logging_config {
  393. uint32_t log_code;
  394. uint32_t log_tap_point_id;
  395. uint32_t mode;
  396. } __packed;
  397. #define PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT 0x08001024
  398. struct param_id_mfc_media_format {
  399. uint32_t sample_rate;
  400. uint16_t bit_width;
  401. uint16_t num_channels;
  402. uint16_t channel_mapping[];
  403. } __packed;
  404. struct media_format {
  405. uint32_t data_format;
  406. uint32_t fmt_id;
  407. uint32_t payload_size;
  408. } __packed;
  409. struct payload_media_fmt_pcm {
  410. uint32_t sample_rate;
  411. uint16_t bit_width;
  412. uint16_t alignment;
  413. uint16_t bits_per_sample;
  414. uint16_t q_factor;
  415. uint16_t endianness;
  416. uint16_t num_channels;
  417. uint8_t channel_mapping[];
  418. } __packed;
  419. #define PARAM_ID_CODEC_DMA_INTF_CFG 0x08001063
  420. struct param_id_codec_dma_intf_cfg {
  421. /* 1 - RXTX
  422. * 2 - WSA
  423. * 3 - VA
  424. * 4 - AXI
  425. */
  426. uint32_t lpaif_type;
  427. /*
  428. * RX0 | TX0 = 1
  429. * RX1 | TX1 = 2
  430. * RX2 | TX2 = 3... so on
  431. */
  432. uint32_t intf_index;
  433. uint32_t active_channels_mask;
  434. } __packed;
  435. struct audio_hw_clk_cfg {
  436. uint32_t clock_id;
  437. uint32_t clock_freq;
  438. uint32_t clock_attri;
  439. uint32_t clock_root;
  440. } __packed;
  441. struct audio_hw_clk_rel_cfg {
  442. uint32_t clock_id;
  443. } __packed;
  444. #define PARAM_ID_HW_EP_POWER_MODE_CFG 0x8001176
  445. #define AR_HW_EP_POWER_MODE_0 0 /* default */
  446. #define AR_HW_EP_POWER_MODE_1 1 /* XO Shutdown allowed */
  447. #define AR_HW_EP_POWER_MODE_2 2 /* XO Shutdown not allowed */
  448. struct param_id_hw_ep_power_mode_cfg {
  449. uint32_t power_mode;
  450. } __packed;
  451. #define PARAM_ID_HW_EP_DMA_DATA_ALIGN 0x08001233
  452. #define AR_HW_EP_DMA_DATA_ALIGN_MSB 0
  453. #define AR_HW_EP_DMA_DATA_ALIGN_LSB 1
  454. #define AR_PCM_MAX_NUM_CHANNEL 8
  455. struct param_id_hw_ep_dma_data_align {
  456. uint32_t dma_data_align;
  457. } __packed;
  458. #define PARAM_ID_VOL_CTRL_MASTER_GAIN 0x08001035
  459. #define VOL_CTRL_DEFAULT_GAIN 0x2000
  460. struct param_id_vol_ctrl_master_gain {
  461. uint16_t master_gain;
  462. uint16_t reserved;
  463. } __packed;
  464. /* Graph */
  465. struct audioreach_connection {
  466. /* Connections */
  467. uint32_t src_mod_inst_id;
  468. uint32_t src_mod_op_port_id;
  469. uint32_t dst_mod_inst_id;
  470. uint32_t dst_mod_ip_port_id;
  471. struct list_head node;
  472. };
  473. struct audioreach_graph_info {
  474. int id;
  475. uint32_t num_sub_graphs;
  476. struct list_head sg_list;
  477. struct list_head connection_list;
  478. };
  479. struct audioreach_sub_graph {
  480. uint32_t sub_graph_id;
  481. uint32_t perf_mode;
  482. uint32_t direction;
  483. uint32_t scenario_id;
  484. struct list_head node;
  485. struct audioreach_graph_info *info;
  486. uint32_t num_containers;
  487. struct list_head container_list;
  488. };
  489. struct audioreach_container {
  490. uint32_t container_id;
  491. uint32_t capability_id;
  492. uint32_t graph_pos;
  493. uint32_t stack_size;
  494. uint32_t proc_domain;
  495. struct list_head node;
  496. uint32_t num_modules;
  497. struct list_head modules_list;
  498. struct audioreach_sub_graph *sub_graph;
  499. };
  500. struct audioreach_module {
  501. uint32_t module_id;
  502. uint32_t instance_id;
  503. uint32_t max_ip_port;
  504. uint32_t max_op_port;
  505. uint32_t in_port;
  506. uint32_t out_port;
  507. /* Connections */
  508. uint32_t src_mod_inst_id;
  509. uint32_t src_mod_op_port_id;
  510. uint32_t dst_mod_inst_id;
  511. uint32_t dst_mod_ip_port_id;
  512. /* Format specifics */
  513. uint32_t ch_fmt;
  514. uint32_t rate;
  515. uint32_t bit_depth;
  516. /* I2S module */
  517. uint32_t hw_interface_idx;
  518. uint32_t sd_line_idx;
  519. uint32_t ws_src;
  520. uint32_t frame_size_factor;
  521. uint32_t data_format;
  522. uint32_t hw_interface_type;
  523. /* PCM module specific */
  524. uint32_t interleave_type;
  525. /* GAIN/Vol Control Module */
  526. uint16_t gain;
  527. /* Logging */
  528. uint32_t log_code;
  529. uint32_t log_tap_point_id;
  530. uint32_t log_mode;
  531. /* bookkeeping */
  532. struct list_head node;
  533. struct audioreach_container *container;
  534. struct snd_soc_dapm_widget *widget;
  535. };
  536. struct audioreach_module_config {
  537. int direction;
  538. u32 sample_rate;
  539. u16 bit_width;
  540. u16 bits_per_sample;
  541. u16 data_format;
  542. u16 num_channels;
  543. u16 active_channels_mask;
  544. u32 sd_line_mask;
  545. int fmt;
  546. u8 channel_map[AR_PCM_MAX_NUM_CHANNEL];
  547. };
  548. /* Packet Allocation routines */
  549. void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t
  550. token);
  551. void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode,
  552. uint32_t token, uint32_t src_port,
  553. uint32_t dest_port);
  554. void *audioreach_alloc_apm_pkt(int pkt_size, uint32_t opcode, uint32_t token,
  555. uint32_t src_port);
  556. void *audioreach_alloc_pkt(int payload_size, uint32_t opcode,
  557. uint32_t token, uint32_t src_port,
  558. uint32_t dest_port);
  559. void *audioreach_alloc_graph_pkt(struct q6apm *apm,
  560. struct list_head *sg_list,
  561. int graph_id);
  562. /* Topology specific */
  563. int audioreach_tplg_init(struct snd_soc_component *component);
  564. /* Module specific */
  565. void audioreach_graph_free_buf(struct q6apm_graph *graph);
  566. int audioreach_map_memory_regions(struct q6apm_graph *graph,
  567. unsigned int dir, size_t period_sz,
  568. unsigned int periods,
  569. bool is_contiguous);
  570. int audioreach_send_cmd_sync(struct device *dev, gpr_device_t *gdev, struct gpr_ibasic_rsp_result_t *result,
  571. struct mutex *cmd_lock, gpr_port_t *port, wait_queue_head_t *cmd_wait,
  572. struct gpr_pkt *pkt, uint32_t rsp_opcode);
  573. int audioreach_graph_send_cmd_sync(struct q6apm_graph *graph, struct gpr_pkt *pkt,
  574. uint32_t rsp_opcode);
  575. int audioreach_set_media_format(struct q6apm_graph *graph,
  576. struct audioreach_module *module,
  577. struct audioreach_module_config *cfg);
  578. int audioreach_shared_memory_send_eos(struct q6apm_graph *graph);
  579. int audioreach_gain_set_vol_ctrl(struct q6apm *apm,
  580. struct audioreach_module *module, int vol);
  581. struct audioreach_module *audioreach_get_container_last_module(
  582. struct audioreach_container *container);
  583. struct audioreach_module *audioreach_get_container_first_module(
  584. struct audioreach_container *container);
  585. struct audioreach_module *audioreach_get_container_next_module(
  586. struct audioreach_container *container,
  587. struct audioreach_module *module);
  588. #define list_for_each_container_module(mod, cont) \
  589. for (mod = audioreach_get_container_first_module(cont); mod != NULL; \
  590. mod = audioreach_get_container_next_module(cont, mod))
  591. #endif /* __AUDIOREACH_H__ */