header.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
  2. /*
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * Copyright(c) 2022 Intel Corporation
  7. */
  8. #ifndef __INCLUDE_SOUND_SOF_IPC4_HEADER_H__
  9. #define __INCLUDE_SOUND_SOF_IPC4_HEADER_H__
  10. #include <linux/types.h>
  11. #include <uapi/sound/sof/abi.h>
  12. /* maximum message size for mailbox Tx/Rx */
  13. #define SOF_IPC4_MSG_MAX_SIZE 4096
  14. /** \addtogroup sof_uapi uAPI
  15. * SOF uAPI specification.
  16. * @{
  17. */
  18. /**
  19. * struct sof_ipc4_msg - Placeholder of an IPC4 message
  20. * @header_u64: IPC4 header as single u64 number
  21. * @primary: Primary, mandatory part of the header
  22. * @extension: Extended part of the header, if not used it should be
  23. * set to 0
  24. * @data_size: Size of data in bytes pointed by @data_ptr
  25. * @data_ptr: Pointer to the optional payload of a message
  26. */
  27. struct sof_ipc4_msg {
  28. union {
  29. u64 header_u64;
  30. struct {
  31. u32 primary;
  32. u32 extension;
  33. };
  34. };
  35. size_t data_size;
  36. void *data_ptr;
  37. };
  38. /**
  39. * struct sof_ipc4_tuple - Generic type/ID and parameter tuple
  40. * @type: type/ID
  41. * @size: size of the @value array in bytes
  42. * @value: value for the given type
  43. */
  44. struct sof_ipc4_tuple {
  45. uint32_t type;
  46. uint32_t size;
  47. uint32_t value[];
  48. } __packed;
  49. /*
  50. * IPC4 messages have two 32 bit identifier made up as follows :-
  51. *
  52. * header - msg type, msg id, msg direction ...
  53. * extension - extra params such as msg data size in mailbox
  54. *
  55. * These are sent at the start of the IPC message in the mailbox. Messages
  56. * should not be sent in the doorbell (special exceptions for firmware).
  57. */
  58. /*
  59. * IPC4 primary header bit allocation for messages
  60. * bit 0-23: message type specific
  61. * bit 24-28: type: enum sof_ipc4_global_msg if target is SOF_IPC4_FW_GEN_MSG
  62. * enum sof_ipc4_module_type if target is SOF_IPC4_MODULE_MSG
  63. * bit 29: response - sof_ipc4_msg_dir
  64. * bit 30: target - enum sof_ipc4_msg_target
  65. * bit 31: reserved, unused
  66. */
  67. /* Value of target field - must fit into 1 bit */
  68. enum sof_ipc4_msg_target {
  69. /* Global FW message */
  70. SOF_IPC4_FW_GEN_MSG,
  71. /* Module message */
  72. SOF_IPC4_MODULE_MSG
  73. };
  74. /* Value of type field - must fit into 5 bits */
  75. enum sof_ipc4_global_msg {
  76. SOF_IPC4_GLB_BOOT_CONFIG,
  77. SOF_IPC4_GLB_ROM_CONTROL,
  78. SOF_IPC4_GLB_IPCGATEWAY_CMD,
  79. /* 3 .. 12: RESERVED - do not use */
  80. SOF_IPC4_GLB_PERF_MEASUREMENTS_CMD = 13,
  81. SOF_IPC4_GLB_CHAIN_DMA,
  82. SOF_IPC4_GLB_LOAD_MULTIPLE_MODULES,
  83. SOF_IPC4_GLB_UNLOAD_MULTIPLE_MODULES,
  84. /* pipeline settings */
  85. SOF_IPC4_GLB_CREATE_PIPELINE,
  86. SOF_IPC4_GLB_DELETE_PIPELINE,
  87. SOF_IPC4_GLB_SET_PIPELINE_STATE,
  88. SOF_IPC4_GLB_GET_PIPELINE_STATE,
  89. SOF_IPC4_GLB_GET_PIPELINE_CONTEXT_SIZE,
  90. SOF_IPC4_GLB_SAVE_PIPELINE,
  91. SOF_IPC4_GLB_RESTORE_PIPELINE,
  92. /*
  93. * library loading
  94. *
  95. * Loads library (using Code Load or HD/A Host Output DMA)
  96. */
  97. SOF_IPC4_GLB_LOAD_LIBRARY,
  98. /*
  99. * Prepare the host DMA channel for library loading, must be followed by
  100. * a SOF_IPC4_GLB_LOAD_LIBRARY message as the library loading step
  101. */
  102. SOF_IPC4_GLB_LOAD_LIBRARY_PREPARE,
  103. SOF_IPC4_GLB_INTERNAL_MESSAGE,
  104. /* Notification (FW to SW driver) */
  105. SOF_IPC4_GLB_NOTIFICATION,
  106. /* 28 .. 31: RESERVED - do not use */
  107. SOF_IPC4_GLB_TYPE_LAST,
  108. };
  109. /* Value of response field - must fit into 1 bit */
  110. enum sof_ipc4_msg_dir {
  111. SOF_IPC4_MSG_REQUEST,
  112. SOF_IPC4_MSG_REPLY,
  113. };
  114. enum sof_ipc4_pipeline_state {
  115. SOF_IPC4_PIPE_INVALID_STATE,
  116. SOF_IPC4_PIPE_UNINITIALIZED,
  117. SOF_IPC4_PIPE_RESET,
  118. SOF_IPC4_PIPE_PAUSED,
  119. SOF_IPC4_PIPE_RUNNING,
  120. SOF_IPC4_PIPE_EOS
  121. };
  122. /* Generic message fields (bit 24-30) */
  123. /* encoded to header's msg_tgt field */
  124. #define SOF_IPC4_MSG_TARGET_SHIFT 30
  125. #define SOF_IPC4_MSG_TARGET_MASK BIT(30)
  126. #define SOF_IPC4_MSG_TARGET(x) ((x) << SOF_IPC4_MSG_TARGET_SHIFT)
  127. #define SOF_IPC4_MSG_IS_MODULE_MSG(x) ((x) & SOF_IPC4_MSG_TARGET_MASK ? 1 : 0)
  128. /* encoded to header's rsp field */
  129. #define SOF_IPC4_MSG_DIR_SHIFT 29
  130. #define SOF_IPC4_MSG_DIR_MASK BIT(29)
  131. #define SOF_IPC4_MSG_DIR(x) ((x) << SOF_IPC4_MSG_DIR_SHIFT)
  132. /* encoded to header's type field */
  133. #define SOF_IPC4_MSG_TYPE_SHIFT 24
  134. #define SOF_IPC4_MSG_TYPE_MASK GENMASK(28, 24)
  135. #define SOF_IPC4_MSG_TYPE_SET(x) (((x) << SOF_IPC4_MSG_TYPE_SHIFT) & \
  136. SOF_IPC4_MSG_TYPE_MASK)
  137. #define SOF_IPC4_MSG_TYPE_GET(x) (((x) & SOF_IPC4_MSG_TYPE_MASK) >> \
  138. SOF_IPC4_MSG_TYPE_SHIFT)
  139. /* Global message type specific field definitions */
  140. /* pipeline creation ipc msg */
  141. #define SOF_IPC4_GLB_PIPE_INSTANCE_SHIFT 16
  142. #define SOF_IPC4_GLB_PIPE_INSTANCE_MASK GENMASK(23, 16)
  143. #define SOF_IPC4_GLB_PIPE_INSTANCE_ID(x) ((x) << SOF_IPC4_GLB_PIPE_INSTANCE_SHIFT)
  144. #define SOF_IPC4_GLB_PIPE_PRIORITY_SHIFT 11
  145. #define SOF_IPC4_GLB_PIPE_PRIORITY_MASK GENMASK(15, 11)
  146. #define SOF_IPC4_GLB_PIPE_PRIORITY(x) ((x) << SOF_IPC4_GLB_PIPE_PRIORITY_SHIFT)
  147. #define SOF_IPC4_GLB_PIPE_MEM_SIZE_SHIFT 0
  148. #define SOF_IPC4_GLB_PIPE_MEM_SIZE_MASK GENMASK(10, 0)
  149. #define SOF_IPC4_GLB_PIPE_MEM_SIZE(x) ((x) << SOF_IPC4_GLB_PIPE_MEM_SIZE_SHIFT)
  150. #define SOF_IPC4_GLB_PIPE_EXT_LP_SHIFT 0
  151. #define SOF_IPC4_GLB_PIPE_EXT_LP_MASK BIT(0)
  152. #define SOF_IPC4_GLB_PIPE_EXT_LP(x) ((x) << SOF_IPC4_GLB_PIPE_EXT_LP_SHIFT)
  153. #define SOF_IPC4_GLB_PIPE_EXT_CORE_ID_SHIFT 20
  154. #define SOF_IPC4_GLB_PIPE_EXT_CORE_ID_MASK GENMASK(23, 20)
  155. #define SOF_IPC4_GLB_PIPE_EXT_CORE_ID(x) ((x) << SOF_IPC4_GLB_PIPE_EXT_CORE_ID_SHIFT)
  156. /* pipeline set state ipc msg */
  157. #define SOF_IPC4_GLB_PIPE_STATE_ID_SHIFT 16
  158. #define SOF_IPC4_GLB_PIPE_STATE_ID_MASK GENMASK(23, 16)
  159. #define SOF_IPC4_GLB_PIPE_STATE_ID(x) ((x) << SOF_IPC4_GLB_PIPE_STATE_ID_SHIFT)
  160. #define SOF_IPC4_GLB_PIPE_STATE_SHIFT 0
  161. #define SOF_IPC4_GLB_PIPE_STATE_MASK GENMASK(15, 0)
  162. #define SOF_IPC4_GLB_PIPE_STATE(x) ((x) << SOF_IPC4_GLB_PIPE_STATE_SHIFT)
  163. /* pipeline set state IPC msg extension */
  164. #define SOF_IPC4_GLB_PIPE_STATE_EXT_MULTI BIT(0)
  165. /* load library ipc msg */
  166. #define SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID_SHIFT 16
  167. #define SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID(x) ((x) << SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID_SHIFT)
  168. /* chain dma ipc message */
  169. #define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_SHIFT 0
  170. #define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_MASK GENMASK(4, 0)
  171. #define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID(x) (((x) << SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_SHIFT) & \
  172. SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_MASK)
  173. #define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_SHIFT 8
  174. #define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_MASK GENMASK(12, 8)
  175. #define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID(x) (((x) << SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_SHIFT) & \
  176. SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_MASK)
  177. #define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_SHIFT 16
  178. #define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_MASK BIT(16)
  179. #define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE(x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_SHIFT)
  180. #define SOF_IPC4_GLB_CHAIN_DMA_ENABLE_SHIFT 17
  181. #define SOF_IPC4_GLB_CHAIN_DMA_ENABLE_MASK BIT(17)
  182. #define SOF_IPC4_GLB_CHAIN_DMA_ENABLE(x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_ENABLE_SHIFT)
  183. #define SOF_IPC4_GLB_CHAIN_DMA_SCS_SHIFT 18
  184. #define SOF_IPC4_GLB_CHAIN_DMA_SCS_MASK BIT(18)
  185. #define SOF_IPC4_GLB_CHAIN_DMA_SCS(x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_SCS_SHIFT)
  186. #define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_SHIFT 0
  187. #define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_MASK GENMASK(24, 0)
  188. #define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE(x) (((x) << \
  189. SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_SHIFT) & \
  190. SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_MASK)
  191. enum sof_ipc4_channel_config {
  192. /* one channel only. */
  193. SOF_IPC4_CHANNEL_CONFIG_MONO,
  194. /* L & R. */
  195. SOF_IPC4_CHANNEL_CONFIG_STEREO,
  196. /* L, R & LFE; PCM only. */
  197. SOF_IPC4_CHANNEL_CONFIG_2_POINT_1,
  198. /* L, C & R; MP3 & AAC only. */
  199. SOF_IPC4_CHANNEL_CONFIG_3_POINT_0,
  200. /* L, C, R & LFE; PCM only. */
  201. SOF_IPC4_CHANNEL_CONFIG_3_POINT_1,
  202. /* L, R, Ls & Rs; PCM only. */
  203. SOF_IPC4_CHANNEL_CONFIG_QUATRO,
  204. /* L, C, R & Cs; MP3 & AAC only. */
  205. SOF_IPC4_CHANNEL_CONFIG_4_POINT_0,
  206. /* L, C, R, Ls & Rs. */
  207. SOF_IPC4_CHANNEL_CONFIG_5_POINT_0,
  208. /* L, C, R, Ls, Rs & LFE. */
  209. SOF_IPC4_CHANNEL_CONFIG_5_POINT_1,
  210. /* one channel replicated in two. */
  211. SOF_IPC4_CHANNEL_CONFIG_DUAL_MONO,
  212. /* Stereo (L,R) in 4 slots, 1st stream: [ L, R, -, - ] */
  213. SOF_IPC4_CHANNEL_CONFIG_I2S_DUAL_STEREO_0,
  214. /* Stereo (L,R) in 4 slots, 2nd stream: [ -, -, L, R ] */
  215. SOF_IPC4_CHANNEL_CONFIG_I2S_DUAL_STEREO_1,
  216. /* L, C, R, Ls, Rs & LFE., LS, RS */
  217. SOF_IPC4_CHANNEL_CONFIG_7_POINT_1,
  218. };
  219. enum sof_ipc4_interleaved_style {
  220. SOF_IPC4_CHANNELS_INTERLEAVED,
  221. SOF_IPC4_CHANNELS_NONINTERLEAVED,
  222. };
  223. enum sof_ipc4_sample_type {
  224. SOF_IPC4_MSB_INTEGER, /* integer with Most Significant Byte first */
  225. SOF_IPC4_LSB_INTEGER, /* integer with Least Significant Byte first */
  226. };
  227. struct sof_ipc4_audio_format {
  228. uint32_t sampling_frequency;
  229. uint32_t bit_depth;
  230. uint32_t ch_map;
  231. uint32_t ch_cfg; /* sof_ipc4_channel_config */
  232. uint32_t interleaving_style;
  233. uint32_t fmt_cfg; /* channels_count valid_bit_depth s_type */
  234. } __packed __aligned(4);
  235. #define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT_SHIFT 0
  236. #define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT_MASK GENMASK(7, 0)
  237. #define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(x) \
  238. ((x) & SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT_MASK)
  239. #define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_SHIFT 8
  240. #define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_MASK GENMASK(15, 8)
  241. #define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(x) \
  242. (((x) & SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_MASK) >> \
  243. SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_SHIFT)
  244. #define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_SHIFT 16
  245. #define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_MASK GENMASK(23, 16)
  246. #define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(x) \
  247. (((x) & SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_MASK) >> \
  248. SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_SHIFT)
  249. /* Module message type specific field definitions */
  250. enum sof_ipc4_module_type {
  251. SOF_IPC4_MOD_INIT_INSTANCE,
  252. SOF_IPC4_MOD_CONFIG_GET,
  253. SOF_IPC4_MOD_CONFIG_SET,
  254. SOF_IPC4_MOD_LARGE_CONFIG_GET,
  255. SOF_IPC4_MOD_LARGE_CONFIG_SET,
  256. SOF_IPC4_MOD_BIND,
  257. SOF_IPC4_MOD_UNBIND,
  258. SOF_IPC4_MOD_SET_DX,
  259. SOF_IPC4_MOD_SET_D0IX,
  260. SOF_IPC4_MOD_ENTER_MODULE_RESTORE,
  261. SOF_IPC4_MOD_EXIT_MODULE_RESTORE,
  262. SOF_IPC4_MOD_DELETE_INSTANCE,
  263. SOF_IPC4_MOD_TYPE_LAST,
  264. };
  265. struct sof_ipc4_base_module_cfg {
  266. uint32_t cpc; /* the max count of Cycles Per Chunk processing */
  267. uint32_t ibs; /* input Buffer Size (in bytes) */
  268. uint32_t obs; /* output Buffer Size (in bytes) */
  269. uint32_t is_pages; /* number of physical pages used */
  270. struct sof_ipc4_audio_format audio_fmt;
  271. } __packed __aligned(4);
  272. /* common module ipc msg */
  273. #define SOF_IPC4_MOD_INSTANCE_SHIFT 16
  274. #define SOF_IPC4_MOD_INSTANCE_MASK GENMASK(23, 16)
  275. #define SOF_IPC4_MOD_INSTANCE(x) ((x) << SOF_IPC4_MOD_INSTANCE_SHIFT)
  276. #define SOF_IPC4_MOD_ID_SHIFT 0
  277. #define SOF_IPC4_MOD_ID_MASK GENMASK(15, 0)
  278. #define SOF_IPC4_MOD_ID(x) ((x) << SOF_IPC4_MOD_ID_SHIFT)
  279. /* init module ipc msg */
  280. #define SOF_IPC4_MOD_EXT_PARAM_SIZE_SHIFT 0
  281. #define SOF_IPC4_MOD_EXT_PARAM_SIZE_MASK GENMASK(15, 0)
  282. #define SOF_IPC4_MOD_EXT_PARAM_SIZE(x) ((x) << SOF_IPC4_MOD_EXT_PARAM_SIZE_SHIFT)
  283. #define SOF_IPC4_MOD_EXT_PPL_ID_SHIFT 16
  284. #define SOF_IPC4_MOD_EXT_PPL_ID_MASK GENMASK(23, 16)
  285. #define SOF_IPC4_MOD_EXT_PPL_ID(x) ((x) << SOF_IPC4_MOD_EXT_PPL_ID_SHIFT)
  286. #define SOF_IPC4_MOD_EXT_CORE_ID_SHIFT 24
  287. #define SOF_IPC4_MOD_EXT_CORE_ID_MASK GENMASK(27, 24)
  288. #define SOF_IPC4_MOD_EXT_CORE_ID(x) ((x) << SOF_IPC4_MOD_EXT_CORE_ID_SHIFT)
  289. #define SOF_IPC4_MOD_EXT_DOMAIN_SHIFT 28
  290. #define SOF_IPC4_MOD_EXT_DOMAIN_MASK BIT(28)
  291. #define SOF_IPC4_MOD_EXT_DOMAIN(x) ((x) << SOF_IPC4_MOD_EXT_DOMAIN_SHIFT)
  292. /* bind/unbind module ipc msg */
  293. #define SOF_IPC4_MOD_EXT_DST_MOD_ID_SHIFT 0
  294. #define SOF_IPC4_MOD_EXT_DST_MOD_ID_MASK GENMASK(15, 0)
  295. #define SOF_IPC4_MOD_EXT_DST_MOD_ID(x) ((x) << SOF_IPC4_MOD_EXT_DST_MOD_ID_SHIFT)
  296. #define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE_SHIFT 16
  297. #define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE_MASK GENMASK(23, 16)
  298. #define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE(x) ((x) << SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE_SHIFT)
  299. #define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID_SHIFT 24
  300. #define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID_MASK GENMASK(26, 24)
  301. #define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID(x) ((x) << SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID_SHIFT)
  302. #define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID_SHIFT 27
  303. #define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID_MASK GENMASK(29, 27)
  304. #define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID(x) ((x) << SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID_SHIFT)
  305. #define MOD_ENABLE_LOG 6
  306. #define MOD_SYSTEM_TIME 20
  307. /* set module large config */
  308. #define SOF_IPC4_MOD_EXT_MSG_SIZE_SHIFT 0
  309. #define SOF_IPC4_MOD_EXT_MSG_SIZE_MASK GENMASK(19, 0)
  310. #define SOF_IPC4_MOD_EXT_MSG_SIZE(x) ((x) << SOF_IPC4_MOD_EXT_MSG_SIZE_SHIFT)
  311. #define SOF_IPC4_MOD_EXT_MSG_PARAM_ID_SHIFT 20
  312. #define SOF_IPC4_MOD_EXT_MSG_PARAM_ID_MASK GENMASK(27, 20)
  313. #define SOF_IPC4_MOD_EXT_MSG_PARAM_ID(x) ((x) << SOF_IPC4_MOD_EXT_MSG_PARAM_ID_SHIFT)
  314. #define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK_SHIFT 28
  315. #define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK_MASK BIT(28)
  316. #define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK(x) ((x) << SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK_SHIFT)
  317. #define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK_SHIFT 29
  318. #define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK_MASK BIT(29)
  319. #define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK(x) ((x) << SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK_SHIFT)
  320. /* Init instance messagees */
  321. #define SOF_IPC4_MOD_INIT_BASEFW_MOD_ID 0
  322. #define SOF_IPC4_MOD_INIT_BASEFW_INSTANCE_ID 0
  323. enum sof_ipc4_base_fw_params {
  324. SOF_IPC4_FW_PARAM_ENABLE_LOGS = 6,
  325. SOF_IPC4_FW_PARAM_FW_CONFIG,
  326. SOF_IPC4_FW_PARAM_HW_CONFIG_GET,
  327. SOF_IPC4_FW_PARAM_MODULES_INFO_GET,
  328. SOF_IPC4_FW_PARAM_LIBRARIES_INFO_GET = 16,
  329. SOF_IPC4_FW_PARAM_SYSTEM_TIME = 20,
  330. };
  331. enum sof_ipc4_fw_config_params {
  332. SOF_IPC4_FW_CFG_FW_VERSION,
  333. SOF_IPC4_FW_CFG_MEMORY_RECLAIMED,
  334. SOF_IPC4_FW_CFG_SLOW_CLOCK_FREQ_HZ,
  335. SOF_IPC4_FW_CFG_FAST_CLOCK_FREQ_HZ,
  336. SOF_IPC4_FW_CFG_DMA_BUFFER_CONFIG,
  337. SOF_IPC4_FW_CFG_ALH_SUPPORT_LEVEL,
  338. SOF_IPC4_FW_CFG_DL_MAILBOX_BYTES,
  339. SOF_IPC4_FW_CFG_UL_MAILBOX_BYTES,
  340. SOF_IPC4_FW_CFG_TRACE_LOG_BYTES,
  341. SOF_IPC4_FW_CFG_MAX_PPL_COUNT,
  342. SOF_IPC4_FW_CFG_MAX_ASTATE_COUNT,
  343. SOF_IPC4_FW_CFG_MAX_MODULE_PIN_COUNT,
  344. SOF_IPC4_FW_CFG_MODULES_COUNT,
  345. SOF_IPC4_FW_CFG_MAX_MOD_INST_COUNT,
  346. SOF_IPC4_FW_CFG_MAX_LL_TASKS_PER_PRI_COUNT,
  347. SOF_IPC4_FW_CFG_LL_PRI_COUNT,
  348. SOF_IPC4_FW_CFG_MAX_DP_TASKS_COUNT,
  349. SOF_IPC4_FW_CFG_MAX_LIBS_COUNT,
  350. SOF_IPC4_FW_CFG_SCHEDULER_CONFIG,
  351. SOF_IPC4_FW_CFG_XTAL_FREQ_HZ,
  352. SOF_IPC4_FW_CFG_CLOCKS_CONFIG,
  353. SOF_IPC4_FW_CFG_RESERVED,
  354. SOF_IPC4_FW_CFG_POWER_GATING_POLICY,
  355. SOF_IPC4_FW_CFG_ASSERT_MODE,
  356. SOF_IPC4_FW_RESERVED1,
  357. SOF_IPC4_FW_RESERVED2,
  358. SOF_IPC4_FW_RESERVED3,
  359. SOF_IPC4_FW_RESERVED4,
  360. SOF_IPC4_FW_RESERVED5,
  361. SOF_IPC4_FW_CONTEXT_SAVE
  362. };
  363. struct sof_ipc4_fw_version {
  364. uint16_t major;
  365. uint16_t minor;
  366. uint16_t hotfix;
  367. uint16_t build;
  368. } __packed;
  369. /* Payload data for SOF_IPC4_MOD_SET_DX */
  370. struct sof_ipc4_dx_state_info {
  371. /* core(s) to apply the change */
  372. uint32_t core_mask;
  373. /* core state: 0: put core_id to D3; 1: put core_id to D0 */
  374. uint32_t dx_mask;
  375. } __packed __aligned(4);
  376. /* Reply messages */
  377. /*
  378. * IPC4 primary header bit allocation for replies
  379. * bit 0-23: status
  380. * bit 24-28: type: enum sof_ipc4_global_msg if target is SOF_IPC4_FW_GEN_MSG
  381. * enum sof_ipc4_module_type if target is SOF_IPC4_MODULE_MSG
  382. * bit 29: response - sof_ipc4_msg_dir
  383. * bit 30: target - enum sof_ipc4_msg_target
  384. * bit 31: reserved, unused
  385. */
  386. #define SOF_IPC4_REPLY_STATUS GENMASK(23, 0)
  387. /* Notification messages */
  388. /*
  389. * IPC4 primary header bit allocation for notifications
  390. * bit 0-15: notification type specific
  391. * bit 16-23: enum sof_ipc4_notification_type
  392. * bit 24-28: SOF_IPC4_GLB_NOTIFICATION
  393. * bit 29: response - sof_ipc4_msg_dir
  394. * bit 30: target - enum sof_ipc4_msg_target
  395. * bit 31: reserved, unused
  396. */
  397. #define SOF_IPC4_MSG_IS_NOTIFICATION(x) (SOF_IPC4_MSG_TYPE_GET(x) == \
  398. SOF_IPC4_GLB_NOTIFICATION)
  399. #define SOF_IPC4_NOTIFICATION_TYPE_SHIFT 16
  400. #define SOF_IPC4_NOTIFICATION_TYPE_MASK GENMASK(23, 16)
  401. #define SOF_IPC4_NOTIFICATION_TYPE_GET(x) (((x) & SOF_IPC4_NOTIFICATION_TYPE_MASK) >> \
  402. SOF_IPC4_NOTIFICATION_TYPE_SHIFT)
  403. #define SOF_IPC4_LOG_CORE_SHIFT 12
  404. #define SOF_IPC4_LOG_CORE_MASK GENMASK(15, 12)
  405. #define SOF_IPC4_LOG_CORE_GET(x) (((x) & SOF_IPC4_LOG_CORE_MASK) >> \
  406. SOF_IPC4_LOG_CORE_SHIFT)
  407. /* Value of notification type field - must fit into 8 bits */
  408. enum sof_ipc4_notification_type {
  409. /* Phrase detected (notification from WoV module) */
  410. SOF_IPC4_NOTIFY_PHRASE_DETECTED = 4,
  411. /* Event from a resource (pipeline or module instance) */
  412. SOF_IPC4_NOTIFY_RESOURCE_EVENT,
  413. /* Debug log buffer status changed */
  414. SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS,
  415. /* Timestamp captured at the link */
  416. SOF_IPC4_NOTIFY_TIMESTAMP_CAPTURED,
  417. /* FW complete initialization */
  418. SOF_IPC4_NOTIFY_FW_READY,
  419. /* Audio classifier result (ACA) */
  420. SOF_IPC4_NOTIFY_FW_AUD_CLASS_RESULT,
  421. /* Exception caught by DSP FW */
  422. SOF_IPC4_NOTIFY_EXCEPTION_CAUGHT,
  423. /* 11 is skipped by the existing cavs firmware */
  424. /* Custom module notification */
  425. SOF_IPC4_NOTIFY_MODULE_NOTIFICATION = 12,
  426. /* 13 is reserved - do not use */
  427. /* Probe notify data available */
  428. SOF_IPC4_NOTIFY_PROBE_DATA_AVAILABLE = 14,
  429. /* AM module notifications */
  430. SOF_IPC4_NOTIFY_ASYNC_MSG_SRVC_MESSAGE,
  431. SOF_IPC4_NOTIFY_TYPE_LAST,
  432. };
  433. struct sof_ipc4_notify_resource_data {
  434. uint32_t resource_type;
  435. uint32_t resource_id;
  436. uint32_t event_type;
  437. uint32_t reserved;
  438. uint32_t data[6];
  439. } __packed __aligned(4);
  440. #define SOF_IPC4_DEBUG_DESCRIPTOR_SIZE 12 /* 3 x u32 */
  441. /*
  442. * The debug memory window is divided into 16 slots, and the
  443. * first slot is used as a recorder for the other 15 slots.
  444. */
  445. #define SOF_IPC4_MAX_DEBUG_SLOTS 15
  446. #define SOF_IPC4_DEBUG_SLOT_SIZE 0x1000
  447. /* debug log slot types */
  448. #define SOF_IPC4_DEBUG_SLOT_UNUSED 0x00000000
  449. #define SOF_IPC4_DEBUG_SLOT_CRITICAL_LOG 0x54524300 /* byte 0: core ID */
  450. #define SOF_IPC4_DEBUG_SLOT_DEBUG_LOG 0x474f4c00 /* byte 0: core ID */
  451. #define SOF_IPC4_DEBUG_SLOT_GDB_STUB 0x42444700
  452. #define SOF_IPC4_DEBUG_SLOT_TELEMETRY 0x4c455400
  453. #define SOF_IPC4_DEBUG_SLOT_BROKEN 0x44414544
  454. /**
  455. * struct sof_ipc4_notify_module_data - payload for module notification
  456. * @instance_id: instance ID of the originator module of the notification
  457. * @module_id: module ID of the originator of the notification
  458. * @event_id: module specific event id
  459. * @event_data_size: Size of the @event_data (if any) in bytes
  460. * @event_data: Optional notification data, module and notification dependent
  461. */
  462. struct sof_ipc4_notify_module_data {
  463. uint16_t instance_id;
  464. uint16_t module_id;
  465. uint32_t event_id;
  466. uint32_t event_data_size;
  467. uint8_t event_data[];
  468. } __packed __aligned(4);
  469. /*
  470. * ALSA kcontrol change notification
  471. *
  472. * The event_id of struct sof_ipc4_notify_module_data is divided into two u16:
  473. * upper u16: magic number for ALSA kcontrol types: 0xA15A
  474. * lower u16: param_id of the control, which is the type of the control
  475. * The event_data contains the struct sof_ipc4_control_msg_payload of the control
  476. * which sent the notification.
  477. */
  478. #define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_MASK GENMASK(31, 16)
  479. #define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL 0xA15A0000
  480. #define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_PARAMID_MASK GENMASK(15, 0)
  481. /** @}*/
  482. #endif