header.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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) 2018 Intel Corporation
  7. */
  8. #ifndef __INCLUDE_SOUND_SOF_HEADER_H__
  9. #define __INCLUDE_SOUND_SOF_HEADER_H__
  10. #include <linux/types.h>
  11. #include <uapi/sound/sof/abi.h>
  12. /** \addtogroup sof_uapi uAPI
  13. * SOF uAPI specification.
  14. * @{
  15. */
  16. /*
  17. * IPC messages have a prefixed 32 bit identifier made up as follows :-
  18. *
  19. * 0xGCCCNNNN where
  20. * G is global cmd type (4 bits)
  21. * C is command type (12 bits)
  22. * I is the ID number (16 bits) - monotonic and overflows
  23. *
  24. * This is sent at the start of the IPM message in the mailbox. Messages should
  25. * not be sent in the doorbell (special exceptions for firmware .
  26. */
  27. /* Global Message - Generic */
  28. #define SOF_GLB_TYPE_SHIFT 28
  29. #define SOF_GLB_TYPE_MASK (0xfUL << SOF_GLB_TYPE_SHIFT)
  30. #define SOF_GLB_TYPE(x) ((x) << SOF_GLB_TYPE_SHIFT)
  31. /* Command Message - Generic */
  32. #define SOF_CMD_TYPE_SHIFT 16
  33. #define SOF_CMD_TYPE_MASK (0xfffL << SOF_CMD_TYPE_SHIFT)
  34. #define SOF_CMD_TYPE(x) ((x) << SOF_CMD_TYPE_SHIFT)
  35. /* Global Message Types */
  36. #define SOF_IPC_GLB_REPLY SOF_GLB_TYPE(0x1U)
  37. #define SOF_IPC_GLB_COMPOUND SOF_GLB_TYPE(0x2U)
  38. #define SOF_IPC_GLB_TPLG_MSG SOF_GLB_TYPE(0x3U)
  39. #define SOF_IPC_GLB_PM_MSG SOF_GLB_TYPE(0x4U)
  40. #define SOF_IPC_GLB_COMP_MSG SOF_GLB_TYPE(0x5U)
  41. #define SOF_IPC_GLB_STREAM_MSG SOF_GLB_TYPE(0x6U)
  42. #define SOF_IPC_FW_READY SOF_GLB_TYPE(0x7U)
  43. #define SOF_IPC_GLB_DAI_MSG SOF_GLB_TYPE(0x8U)
  44. #define SOF_IPC_GLB_TRACE_MSG SOF_GLB_TYPE(0x9U)
  45. #define SOF_IPC_GLB_GDB_DEBUG SOF_GLB_TYPE(0xAU)
  46. #define SOF_IPC_GLB_TEST_MSG SOF_GLB_TYPE(0xBU)
  47. #define SOF_IPC_GLB_PROBE SOF_GLB_TYPE(0xCU)
  48. #define SOF_IPC_GLB_DEBUG SOF_GLB_TYPE(0xDU)
  49. /*
  50. * DSP Command Message Types
  51. */
  52. /* topology */
  53. #define SOF_IPC_TPLG_COMP_NEW SOF_CMD_TYPE(0x001)
  54. #define SOF_IPC_TPLG_COMP_FREE SOF_CMD_TYPE(0x002)
  55. #define SOF_IPC_TPLG_COMP_CONNECT SOF_CMD_TYPE(0x003)
  56. #define SOF_IPC_TPLG_PIPE_NEW SOF_CMD_TYPE(0x010)
  57. #define SOF_IPC_TPLG_PIPE_FREE SOF_CMD_TYPE(0x011)
  58. #define SOF_IPC_TPLG_PIPE_CONNECT SOF_CMD_TYPE(0x012)
  59. #define SOF_IPC_TPLG_PIPE_COMPLETE SOF_CMD_TYPE(0x013)
  60. #define SOF_IPC_TPLG_BUFFER_NEW SOF_CMD_TYPE(0x020)
  61. #define SOF_IPC_TPLG_BUFFER_FREE SOF_CMD_TYPE(0x021)
  62. /* PM */
  63. #define SOF_IPC_PM_CTX_SAVE SOF_CMD_TYPE(0x001)
  64. #define SOF_IPC_PM_CTX_RESTORE SOF_CMD_TYPE(0x002)
  65. #define SOF_IPC_PM_CTX_SIZE SOF_CMD_TYPE(0x003)
  66. #define SOF_IPC_PM_CLK_SET SOF_CMD_TYPE(0x004)
  67. #define SOF_IPC_PM_CLK_GET SOF_CMD_TYPE(0x005)
  68. #define SOF_IPC_PM_CLK_REQ SOF_CMD_TYPE(0x006)
  69. #define SOF_IPC_PM_CORE_ENABLE SOF_CMD_TYPE(0x007)
  70. #define SOF_IPC_PM_GATE SOF_CMD_TYPE(0x008)
  71. /* component runtime config - multiple different types */
  72. #define SOF_IPC_COMP_SET_VALUE SOF_CMD_TYPE(0x001)
  73. #define SOF_IPC_COMP_GET_VALUE SOF_CMD_TYPE(0x002)
  74. #define SOF_IPC_COMP_SET_DATA SOF_CMD_TYPE(0x003)
  75. #define SOF_IPC_COMP_GET_DATA SOF_CMD_TYPE(0x004)
  76. #define SOF_IPC_COMP_NOTIFICATION SOF_CMD_TYPE(0x005)
  77. /* DAI messages */
  78. #define SOF_IPC_DAI_CONFIG SOF_CMD_TYPE(0x001)
  79. #define SOF_IPC_DAI_LOOPBACK SOF_CMD_TYPE(0x002)
  80. /* stream */
  81. #define SOF_IPC_STREAM_PCM_PARAMS SOF_CMD_TYPE(0x001)
  82. #define SOF_IPC_STREAM_PCM_PARAMS_REPLY SOF_CMD_TYPE(0x002)
  83. #define SOF_IPC_STREAM_PCM_FREE SOF_CMD_TYPE(0x003)
  84. #define SOF_IPC_STREAM_TRIG_START SOF_CMD_TYPE(0x004)
  85. #define SOF_IPC_STREAM_TRIG_STOP SOF_CMD_TYPE(0x005)
  86. #define SOF_IPC_STREAM_TRIG_PAUSE SOF_CMD_TYPE(0x006)
  87. #define SOF_IPC_STREAM_TRIG_RELEASE SOF_CMD_TYPE(0x007)
  88. #define SOF_IPC_STREAM_TRIG_DRAIN SOF_CMD_TYPE(0x008)
  89. #define SOF_IPC_STREAM_TRIG_XRUN SOF_CMD_TYPE(0x009)
  90. #define SOF_IPC_STREAM_POSITION SOF_CMD_TYPE(0x00a)
  91. #define SOF_IPC_STREAM_VORBIS_PARAMS SOF_CMD_TYPE(0x010)
  92. #define SOF_IPC_STREAM_VORBIS_FREE SOF_CMD_TYPE(0x011)
  93. /* probe */
  94. #define SOF_IPC_PROBE_INIT SOF_CMD_TYPE(0x001)
  95. #define SOF_IPC_PROBE_DEINIT SOF_CMD_TYPE(0x002)
  96. #define SOF_IPC_PROBE_DMA_ADD SOF_CMD_TYPE(0x003)
  97. #define SOF_IPC_PROBE_DMA_INFO SOF_CMD_TYPE(0x004)
  98. #define SOF_IPC_PROBE_DMA_REMOVE SOF_CMD_TYPE(0x005)
  99. #define SOF_IPC_PROBE_POINT_ADD SOF_CMD_TYPE(0x006)
  100. #define SOF_IPC_PROBE_POINT_INFO SOF_CMD_TYPE(0x007)
  101. #define SOF_IPC_PROBE_POINT_REMOVE SOF_CMD_TYPE(0x008)
  102. /* trace */
  103. #define SOF_IPC_TRACE_DMA_PARAMS SOF_CMD_TYPE(0x001)
  104. #define SOF_IPC_TRACE_DMA_POSITION SOF_CMD_TYPE(0x002)
  105. #define SOF_IPC_TRACE_DMA_PARAMS_EXT SOF_CMD_TYPE(0x003)
  106. #define SOF_IPC_TRACE_FILTER_UPDATE SOF_CMD_TYPE(0x004) /**< ABI3.17 */
  107. #define SOF_IPC_TRACE_DMA_FREE SOF_CMD_TYPE(0x005) /**< ABI3.20 */
  108. /* debug */
  109. #define SOF_IPC_DEBUG_MEM_USAGE SOF_CMD_TYPE(0x001)
  110. /* test */
  111. #define SOF_IPC_TEST_IPC_FLOOD SOF_CMD_TYPE(0x001)
  112. /* Get message component id */
  113. #define SOF_IPC_MESSAGE_ID(x) ((x) & 0xffff)
  114. /* maximum message size for mailbox Tx/Rx */
  115. #define SOF_IPC_MSG_MAX_SIZE 384
  116. /*
  117. * Structure Header - Header for all IPC structures except command structs.
  118. * The size can be greater than the structure size and that means there is
  119. * extended bespoke data beyond the end of the structure including variable
  120. * arrays.
  121. */
  122. struct sof_ipc_hdr {
  123. uint32_t size; /**< size of structure */
  124. } __packed;
  125. /*
  126. * Command Header - Header for all IPC commands. Identifies IPC message.
  127. * The size can be greater than the structure size and that means there is
  128. * extended bespoke data beyond the end of the structure including variable
  129. * arrays.
  130. */
  131. struct sof_ipc_cmd_hdr {
  132. uint32_t size; /**< size of structure */
  133. uint32_t cmd; /**< SOF_IPC_GLB_ + cmd */
  134. } __packed;
  135. /*
  136. * Generic reply message. Some commands override this with their own reply
  137. * types that must include this at start.
  138. */
  139. struct sof_ipc_reply {
  140. struct sof_ipc_cmd_hdr hdr;
  141. int32_t error; /**< negative error numbers */
  142. } __packed;
  143. /*
  144. * Compound commands - SOF_IPC_GLB_COMPOUND.
  145. *
  146. * Compound commands are sent to the DSP as a single IPC operation. The
  147. * commands are split into blocks and each block has a header. This header
  148. * identifies the command type and the number of commands before the next
  149. * header.
  150. */
  151. struct sof_ipc_compound_hdr {
  152. struct sof_ipc_cmd_hdr hdr;
  153. uint32_t count; /**< count of 0 means end of compound sequence */
  154. } __packed;
  155. /**
  156. * OOPS header architecture specific data.
  157. */
  158. struct sof_ipc_dsp_oops_arch_hdr {
  159. uint32_t arch; /* Identifier of architecture */
  160. uint32_t totalsize; /* Total size of oops message */
  161. } __packed;
  162. /**
  163. * OOPS header platform specific data.
  164. */
  165. struct sof_ipc_dsp_oops_plat_hdr {
  166. uint32_t configidhi; /* ConfigID hi 32bits */
  167. uint32_t configidlo; /* ConfigID lo 32bits */
  168. uint32_t numaregs; /* Special regs num */
  169. uint32_t stackoffset; /* Offset to stack pointer from beginning of
  170. * oops message
  171. */
  172. uint32_t stackptr; /* Stack ptr */
  173. } __packed;
  174. /** @}*/
  175. #endif