q6core.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __Q6CORE_H__
  6. #define __Q6CORE_H__
  7. #include <ipc/apr.h>
  8. #include <dsp/apr_audio-v2.h>
  9. #define AVCS_CMD_ADSP_EVENT_GET_STATE 0x0001290C
  10. #define AVCS_CMDRSP_ADSP_EVENT_GET_STATE 0x0001290D
  11. #define AVCS_API_VERSION_V4 4
  12. #define AVCS_API_VERSION_V5 5
  13. #define APRV2_IDS_SERVICE_ID_ADSP_CORE_V (0x3)
  14. bool q6core_is_adsp_ready(void);
  15. #if IS_ENABLED(CONFIG_MSM_AVTIMER)
  16. int avcs_core_query_timer_offset(int64_t *av_offset, int32_t clock_id);
  17. #else
  18. static inline int avcs_core_query_timer_offset(int64_t *av_offset,
  19. int32_t clock_id) {
  20. return 0;
  21. }
  22. #endif
  23. int q6core_get_service_version(uint32_t service_id,
  24. struct avcs_fwk_ver_info *ver_info,
  25. size_t size);
  26. size_t q6core_get_fwk_version_size(uint32_t service_id);
  27. struct audio_uevent_data {
  28. struct kobject kobj;
  29. struct kobj_type ktype;
  30. };
  31. int q6core_init_uevent_data(struct audio_uevent_data *uevent_data, char *name);
  32. void q6core_destroy_uevent_data(struct audio_uevent_data *uevent_data);
  33. int q6core_send_uevent(struct audio_uevent_data *uevent_data, char *name);
  34. int q6core_get_avcs_api_version_per_service(uint32_t service_id);
  35. #define ADSP_CMD_SET_DTS_EAGLE_DATA_ID 0x00012919
  36. #define DTS_EAGLE_LICENSE_ID 0x00028346
  37. struct adsp_dts_eagle {
  38. struct apr_hdr hdr;
  39. uint32_t id;
  40. uint32_t overwrite;
  41. uint32_t size;
  42. char data[];
  43. };
  44. int core_dts_eagle_set(int size, char *data);
  45. int core_dts_eagle_get(int id, int size, char *data);
  46. #define ADSP_CMD_SET_DOLBY_MANUFACTURER_ID 0x00012918
  47. struct adsp_dolby_manufacturer_id {
  48. struct apr_hdr hdr;
  49. int manufacturer_id;
  50. };
  51. uint32_t core_set_dolby_manufacturer_id(int manufacturer_id);
  52. /* Dolby Surround1 Module License ID. This ID is used as an identifier
  53. * for DS1 license via ADSP generic license mechanism.
  54. * Please refer AVCS_CMD_SET_LICENSE for more details.
  55. */
  56. #define DOLBY_DS1_LICENSE_ID 0x00000001
  57. #define AVCS_CMD_SET_LICENSE 0x00012919
  58. struct avcs_cmd_set_license {
  59. struct apr_hdr hdr;
  60. uint32_t id; /**< A unique ID used to refer to this license */
  61. uint32_t overwrite;
  62. /* 0 = do not overwrite an existing license with this id.
  63. * 1 = overwrite an existing license with this id.
  64. */
  65. uint32_t size;
  66. /**< Size in bytes of the license data following this header. */
  67. /* uint8_t* data , data and padding follows this structure
  68. * total packet size needs to be multiple of 4 Bytes
  69. */
  70. };
  71. #define AVCS_CMD_GET_LICENSE_VALIDATION_RESULT 0x0001291A
  72. struct avcs_cmd_get_license_validation_result {
  73. struct apr_hdr hdr;
  74. uint32_t id; /**< A unique ID used to refer to this license */
  75. };
  76. #define AVCS_CMDRSP_GET_LICENSE_VALIDATION_RESULT 0x0001291B
  77. struct avcs_cmdrsp_get_license_validation_result {
  78. uint32_t result;
  79. /* ADSP_EOK if the license validation result was successfully retrieved.
  80. * ADSP_ENOTEXIST if there is no license with the given id.
  81. * ADSP_ENOTIMPL if there is no validation function for a license
  82. * with this id.
  83. */
  84. uint32_t size;
  85. /* Length in bytes of the result that follows this structure*/
  86. };
  87. /* Set Q6 topologies */
  88. /*
  89. * Registers custom topologies in the aDSP for
  90. * use in audio, voice, AFE and LSM.
  91. */
  92. #define AVCS_CMD_SHARED_MEM_MAP_REGIONS 0x00012924
  93. #define AVCS_CMDRSP_SHARED_MEM_MAP_REGIONS 0x00012925
  94. #define AVCS_CMD_SHARED_MEM_UNMAP_REGIONS 0x00012926
  95. /* Commands the AVCS to map multiple shared memory regions with remote
  96. * processor ID. All mapped regions must be from the same memory pool.
  97. *
  98. * Return:
  99. * ADSP_EOK : SUCCESS
  100. * ADSP_EHANDLE : Failed due to incorrect handle.
  101. * ADSP_EBADPARAM : Failed due to bad parameters.
  102. *
  103. * Dependencies:
  104. * The mem_map_handle should be obtained earlier
  105. * using AVCS_CMD_SHARED_MEM_MAP_REGIONS with pool ID
  106. * ADSP_MEMORY_MAP_MDF_SHMEM_4K_POOL.
  107. */
  108. #define AVCS_CMD_MAP_MDF_SHARED_MEMORY 0x00012930
  109. #define AVCS_CMD_REGISTER_TOPOLOGIES 0x00012923
  110. /* The payload for the AVCS_CMD_REGISTER_TOPOLOGIES command */
  111. struct avcs_cmd_register_topologies {
  112. struct apr_hdr hdr;
  113. uint32_t payload_addr_lsw;
  114. /* Lower 32 bits of the topology buffer address. */
  115. uint32_t payload_addr_msw;
  116. /* Upper 32 bits of the topology buffer address. */
  117. uint32_t mem_map_handle;
  118. /* Unique identifier for an address.
  119. * -This memory map handle is returned by the aDSP through the
  120. * memory map command.
  121. * -NULL mem_map_handle is interpreted as in-band parameter
  122. * passing.
  123. * -Client has the flexibility to choose in-band or out-of-band.
  124. * -Out-of-band is recommended in this case.
  125. */
  126. uint32_t payload_size;
  127. /* Size in bytes of the valid data in the topology buffer. */
  128. } __packed;
  129. #define AVCS_CMD_DEREGISTER_TOPOLOGIES 0x0001292a
  130. /* The payload for the AVCS_CMD_DEREGISTER_TOPOLOGIES command */
  131. struct avcs_cmd_deregister_topologies {
  132. struct apr_hdr hdr;
  133. uint32_t payload_addr_lsw;
  134. /* Lower 32 bits of the topology buffer address. */
  135. uint32_t payload_addr_msw;
  136. /* Upper 32 bits of the topology buffer address. */
  137. uint32_t mem_map_handle;
  138. /* Unique identifier for an address.
  139. * -This memory map handle is returned by the aDSP through the
  140. * memory map command.
  141. * -NULL mem_map_handle is interpreted as in-band parameter
  142. * passing.
  143. * -Client has the flexibility to choose in-band or out-of-band.
  144. * -Out-of-band is recommended in this case.
  145. */
  146. uint32_t payload_size;
  147. /* Size in bytes of the valid data in the topology buffer. */
  148. uint32_t mode;
  149. /* 1: Deregister selected topologies
  150. * 2: Deregister all topologies
  151. */
  152. } __packed;
  153. #define AVCS_MODE_DEREGISTER_ALL_CUSTOM_TOPOLOGIES 2
  154. #define AVCS_CMD_LOAD_TOPO_MODULES 0x0001296C
  155. #define AVCS_CMD_UNLOAD_TOPO_MODULES 0x0001296D
  156. #define CORE_LOAD_TOPOLOGY 0
  157. #define CORE_UNLOAD_TOPOLOGY 1
  158. struct avcs_cmd_load_unload_topo_modules {
  159. struct apr_hdr hdr;
  160. uint32_t topology_id;
  161. } __packed;
  162. #define AVCS_LOAD_MODULES 1
  163. #define AVCS_UNLOAD_MODULES 0
  164. #define AVCS_CMD_LOAD_MODULES 0x00012989
  165. #define AVCS_CMD_UNLOAD_MODULES 0x0001298A
  166. #define AVCS_CMD_RSP_LOAD_MODULES 0x0001298B
  167. /*
  168. * Module is generic, such as a preprocessor,
  169. * postprocessor, or volume control
  170. * module.
  171. */
  172. #define AMDB_MODULE_TYPE_GENERIC 0
  173. /** Module is a decoder. */
  174. #define AMDB_MODULE_TYPE_DECODER 1
  175. /** Module is an encoder. */
  176. #define AMDB_MODULE_TYPE_ENCODER 2
  177. /** Module is a converter. */
  178. #define AMDB_MODULE_TYPE_CONVERTER 3
  179. /** Module is a packetizer. */
  180. #define AMDB_MODULE_TYPE_PACKETIZER 4
  181. /** Module is a depacketizer. */
  182. #define AMDB_MODULE_TYPE_DEPACKETIZER 5
  183. struct avcs_load_unload_modules_sec_payload {
  184. uint32_t module_type;
  185. /*
  186. * < Type of module.
  187. * @values
  188. * - #AMDB_MODULE_TYPE_GENERIC
  189. * - #AMDB_MODULE_TYPE_DECODER
  190. * - #AMDB_MODULE_TYPE_ENCODER
  191. * - #AMDB_MODULE_TYPE_CONVERTER
  192. * - #AMDB_MODULE_TYPE_PACKETIZER
  193. * - #AMDB_MODULE_TYPE_DEPACKETIZER
  194. */
  195. uint32_t id1;
  196. /*
  197. * < One of the following types of IDs:
  198. * - Format ID for the encoder, decoder, and packetizer module types
  199. * - Module ID for the generic module type
  200. * - Source format ID for the converter module type
  201. */
  202. uint32_t id2;
  203. /*
  204. * < Sink format ID for the converter module type.
  205. * Zero for other module types
  206. */
  207. uint32_t handle_lsw;
  208. /* < LSW of the Handle to the module loaded */
  209. uint32_t handle_msw;
  210. /* < MSW of the Handle to the module loaded. */
  211. } __packed;
  212. struct avcs_load_unload_modules_payload {
  213. uint32_t num_modules;
  214. /**< Number of modules being registered */
  215. struct avcs_load_unload_modules_sec_payload load_unload_info[0];
  216. /*
  217. * < Load/unload information for num_modules.
  218. * It will be of type avcs_load_unload_info_t[num_modules]
  219. */
  220. } __packed;
  221. struct avcs_load_unload_modules_meminfo {
  222. uint32_t data_payload_addr_lsw;
  223. /**< Lower 32 bits of the 64-bit data payload address. */
  224. uint32_t data_payload_addr_msw;
  225. /**< Upper 32 bits of the 64-bit data payload address. */
  226. uint32_t mem_map_handle;
  227. /*
  228. * < Unique identifier for an address. The aDSP returns this memory map
  229. * handle through the #AVCS_CMD_SHARED_MEM_MAP_REGIONS command.
  230. * @values @vertspace{-2}
  231. * - NULL -- Parameter data payloads are within the message payload
  232. * (in-band).
  233. * - Non-NULL -- Parameter data payloads begin at the address specified
  234. * in the data_payload_addr_lsw and data_payload_addr_msw fields
  235. * (out-of-band).
  236. * The client can choose in-band or out-of-band
  237. */
  238. uint32_t buffer_size;
  239. /*
  240. * < Actual size (in bytes) of the valid data
  241. * in the data payload address.
  242. */
  243. } __packed;
  244. struct avcs_cmd_dynamic_modules {
  245. struct apr_hdr hdr;
  246. struct avcs_load_unload_modules_meminfo meminfo;
  247. struct avcs_load_unload_modules_payload payload;
  248. } __packed;
  249. int32_t q6core_avcs_load_unload_modules(struct avcs_load_unload_modules_payload *payload,
  250. uint32_t preload_type);
  251. /* This command allows a remote client(HLOS) creates a client to LPASS NPA
  252. * resource node. Currently, this command supports only the NPA Sleep resource
  253. * "/island/core/drivers" node ID.
  254. */
  255. #define AVCS_CMD_CREATE_LPASS_NPA_CLIENT 0x00012985
  256. #define AVCS_SLEEP_ISLAND_CORE_DRIVER_NODE_ID 0x00000001
  257. struct avcs_cmd_create_lpass_npa_client_t {
  258. struct apr_hdr hdr;
  259. uint32_t node_id;
  260. /* Unique ID of the NPA node.
  261. * @values
  262. * - #AVCS_SLEEP_ISLAND_CORE_DRIVER_NODE_ID
  263. */
  264. char client_name[16];
  265. /* Client name, up to a maximum of sixteen characters.*/
  266. };
  267. /* In response to the #AVCS_CMD_CREATE_LPASS_NPA_CLIENT command, the AVCS
  268. * returns the handle to remote HLOS client.
  269. */
  270. #define AVCS_CMDRSP_CREATE_LPASS_NPA_CLIENT 0x00012986
  271. struct avcs_cmdrsp_create_lpass_npa_client_t {
  272. uint32_t status;
  273. /* Status message (error code).
  274. * @values
  275. * - ADSP_EOK -- Create was successful
  276. * - ADSP_EFAILED -- Create failed
  277. */
  278. uint32_t client_handle;
  279. /* Handle of the client.*/
  280. };
  281. /* The remote HLOS client use this command to issue the request to the npa
  282. * resource. Remote client(HLOS) must send the valid npa client handle and
  283. * resource id info.
  284. */
  285. #define AVCS_CMD_REQUEST_LPASS_NPA_RESOURCES 0x00012987
  286. #define AVCS_SLEEP_NODE_ISLAND_TRANSITION_RESOURCE_ID 0x00000001
  287. #define SLEEP_RESTRICT_ISLAND 0x0
  288. #define SLEEP_ALLOW_ISLAND 0x1
  289. /* Immediately following this structure is the resource request configuration
  290. * data payload. Payload varies depend on the resource_id requested.
  291. * Currently supported only island transition payload.
  292. */
  293. struct avcs_cmd_request_lpass_npa_resources_t {
  294. struct apr_hdr hdr;
  295. uint32_t client_handle;
  296. /* Handle of the client.
  297. * @values
  298. * - Valid uint32 number
  299. */
  300. uint32_t resource_id;
  301. /* Unique ID of the NPA resource ID.
  302. * @values
  303. * - #AVCS_SLEEP_NODE_ISLAND_TRANSITION_RESOURCE_ID
  304. */
  305. };
  306. /* This structure contains the sleep node resource payload data.
  307. */
  308. struct avcs_sleep_node_island_transition_config_t {
  309. struct avcs_cmd_request_lpass_npa_resources_t req_lpass_npa_rsc;
  310. uint32_t island_allow_mode;
  311. /* Specifies the island state.
  312. * @values
  313. * - #SLEEP_RESTRICT_ISLAND
  314. * - #SLEEP_ALLOW_ISLAND
  315. */
  316. };
  317. /* This command allows remote client(HLOS) to destroy the npa node client
  318. * handle, which is created using the #AVCS_CMD_CREATE_LPASS_NPA_CLIENT command.
  319. * Remote client(HLOS) must send the valid npa client handle.
  320. */
  321. #define AVCS_CMD_DESTROY_LPASS_NPA_CLIENT 0x00012988
  322. struct avcs_cmd_destroy_lpass_npa_client_t {
  323. struct apr_hdr hdr;
  324. uint32_t client_handle;
  325. /* Handle of the client.
  326. * @values
  327. * - Valid uint32 number
  328. */
  329. };
  330. int q6core_map_memory_regions(phys_addr_t *buf_add, uint32_t mempool_id,
  331. uint32_t *bufsz, uint32_t bufcnt, uint32_t *map_handle);
  332. int q6core_memory_unmap_regions(uint32_t mem_map_handle);
  333. int q6core_map_mdf_memory_regions(uint64_t *buf_add, uint32_t mempool_id,
  334. uint32_t *bufsz, uint32_t bufcnt, uint32_t *map_handle);
  335. int q6core_map_mdf_shared_memory(uint32_t map_handle, uint64_t *buf_add,
  336. uint32_t proc_id, uint32_t *bufsz, uint32_t bufcnt);
  337. int32_t core_set_license(uint32_t key, uint32_t module_id);
  338. int32_t core_get_license_status(uint32_t module_id);
  339. int32_t q6core_load_unload_topo_modules(uint32_t topology_id,
  340. bool preload_type);
  341. int q6core_create_lpass_npa_client(uint32_t node_id, char *client_name,
  342. uint32_t *client_handle);
  343. int q6core_destroy_lpass_npa_client(uint32_t client_handle);
  344. int q6core_request_island_transition(uint32_t client_handle,
  345. uint32_t island_allow_mode);
  346. int q6core_get_avcs_avs_build_version_info(
  347. uint32_t *build_major_version, uint32_t *build_minor_version,
  348. uint32_t *build_branch_version);
  349. #endif /* __Q6CORE_H__ */