topology.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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_TOPOLOGY_H__
  9. #define __INCLUDE_SOUND_SOF_TOPOLOGY_H__
  10. #include <sound/sof/header.h>
  11. /*
  12. * Component
  13. */
  14. /* types of component */
  15. enum sof_comp_type {
  16. SOF_COMP_NONE = 0,
  17. SOF_COMP_HOST,
  18. SOF_COMP_DAI,
  19. SOF_COMP_SG_HOST, /**< scatter gather variant */
  20. SOF_COMP_SG_DAI, /**< scatter gather variant */
  21. SOF_COMP_VOLUME,
  22. SOF_COMP_MIXER,
  23. SOF_COMP_MUX,
  24. SOF_COMP_SRC,
  25. SOF_COMP_DEPRECATED0, /* Formerly SOF_COMP_SPLITTER */
  26. SOF_COMP_TONE,
  27. SOF_COMP_DEPRECATED1, /* Formerly SOF_COMP_SWITCH */
  28. SOF_COMP_BUFFER,
  29. SOF_COMP_EQ_IIR,
  30. SOF_COMP_EQ_FIR,
  31. SOF_COMP_KEYWORD_DETECT,
  32. SOF_COMP_KPB, /* A key phrase buffer component */
  33. SOF_COMP_SELECTOR, /**< channel selector component */
  34. SOF_COMP_DEMUX,
  35. SOF_COMP_ASRC, /**< Asynchronous sample rate converter */
  36. SOF_COMP_DCBLOCK,
  37. SOF_COMP_SMART_AMP, /**< smart amplifier component */
  38. SOF_COMP_MODULE_ADAPTER, /**< module adapter */
  39. /* keep FILEREAD/FILEWRITE as the last ones */
  40. SOF_COMP_FILEREAD = 10000, /**< host test based file IO */
  41. SOF_COMP_FILEWRITE = 10001, /**< host test based file IO */
  42. };
  43. /* XRUN action for component */
  44. #define SOF_XRUN_STOP 1 /**< stop stream */
  45. #define SOF_XRUN_UNDER_ZERO 2 /**< send 0s to sink */
  46. #define SOF_XRUN_OVER_NULL 4 /**< send data to NULL */
  47. /* create new generic component - SOF_IPC_TPLG_COMP_NEW */
  48. struct sof_ipc_comp {
  49. struct sof_ipc_cmd_hdr hdr;
  50. uint32_t id;
  51. uint32_t type;
  52. uint32_t pipeline_id;
  53. uint32_t core;
  54. /* extended data length, 0 if no extended data */
  55. uint32_t ext_data_length;
  56. } __packed __aligned(4);
  57. /*
  58. * Component Buffers
  59. */
  60. /*
  61. * SOF memory capabilities, add new ones at the end
  62. */
  63. #define SOF_MEM_CAPS_RAM BIT(0)
  64. #define SOF_MEM_CAPS_ROM BIT(1)
  65. #define SOF_MEM_CAPS_EXT BIT(2) /**< external */
  66. #define SOF_MEM_CAPS_LP BIT(3) /**< low power */
  67. #define SOF_MEM_CAPS_HP BIT(4) /**< high performance */
  68. #define SOF_MEM_CAPS_DMA BIT(5) /**< DMA'able */
  69. #define SOF_MEM_CAPS_CACHE BIT(6) /**< cacheable */
  70. #define SOF_MEM_CAPS_EXEC BIT(7) /**< executable */
  71. #define SOF_MEM_CAPS_L3 BIT(8) /**< L3 memory */
  72. /*
  73. * overrun will cause ring buffer overwrite, instead of XRUN.
  74. */
  75. #define SOF_BUF_OVERRUN_PERMITTED BIT(0)
  76. /*
  77. * underrun will cause readback of 0s, instead of XRUN.
  78. */
  79. #define SOF_BUF_UNDERRUN_PERMITTED BIT(1)
  80. /* the UUID size in bytes, shared between FW and host */
  81. #define SOF_UUID_SIZE 16
  82. /* create new component buffer - SOF_IPC_TPLG_BUFFER_NEW */
  83. struct sof_ipc_buffer {
  84. struct sof_ipc_comp comp;
  85. uint32_t size; /**< buffer size in bytes */
  86. uint32_t caps; /**< SOF_MEM_CAPS_ */
  87. uint32_t flags; /**< SOF_BUF_ flags defined above */
  88. uint32_t reserved; /**< reserved for future use */
  89. } __packed __aligned(4);
  90. /* generic component config data - must always be after struct sof_ipc_comp */
  91. struct sof_ipc_comp_config {
  92. struct sof_ipc_cmd_hdr hdr;
  93. uint32_t periods_sink; /**< 0 means variable */
  94. uint32_t periods_source;/**< 0 means variable */
  95. uint32_t reserved1; /**< reserved */
  96. uint32_t frame_fmt; /**< SOF_IPC_FRAME_ */
  97. uint32_t xrun_action;
  98. /* reserved for future use */
  99. uint32_t reserved[2];
  100. } __packed __aligned(4);
  101. /* generic host component */
  102. struct sof_ipc_comp_host {
  103. struct sof_ipc_comp comp;
  104. struct sof_ipc_comp_config config;
  105. uint32_t direction; /**< SOF_IPC_STREAM_ */
  106. uint32_t no_irq; /**< don't send periodic IRQ to host/DSP */
  107. uint32_t dmac_config; /**< DMA engine specific */
  108. } __packed __aligned(4);
  109. /* generic DAI component */
  110. struct sof_ipc_comp_dai {
  111. struct sof_ipc_comp comp;
  112. struct sof_ipc_comp_config config;
  113. uint32_t direction; /**< SOF_IPC_STREAM_ */
  114. uint32_t dai_index; /**< index of this type dai */
  115. uint32_t type; /**< DAI type - SOF_DAI_ */
  116. uint32_t reserved; /**< reserved */
  117. } __packed __aligned(4);
  118. /* generic mixer component */
  119. struct sof_ipc_comp_mixer {
  120. struct sof_ipc_comp comp;
  121. struct sof_ipc_comp_config config;
  122. } __packed __aligned(4);
  123. /* volume ramping types */
  124. enum sof_volume_ramp {
  125. SOF_VOLUME_LINEAR = 0,
  126. SOF_VOLUME_LOG,
  127. SOF_VOLUME_LINEAR_ZC,
  128. SOF_VOLUME_LOG_ZC,
  129. SOF_VOLUME_WINDOWS_FADE,
  130. SOF_VOLUME_WINDOWS_NO_FADE,
  131. };
  132. /* generic volume component */
  133. struct sof_ipc_comp_volume {
  134. struct sof_ipc_comp comp;
  135. struct sof_ipc_comp_config config;
  136. uint32_t channels;
  137. uint32_t min_value;
  138. uint32_t max_value;
  139. uint32_t ramp; /**< SOF_VOLUME_ */
  140. uint32_t initial_ramp; /**< ramp space in ms */
  141. } __packed __aligned(4);
  142. /* generic SRC component */
  143. struct sof_ipc_comp_src {
  144. struct sof_ipc_comp comp;
  145. struct sof_ipc_comp_config config;
  146. /* either source or sink rate must be non zero */
  147. uint32_t source_rate; /**< source rate or 0 for variable */
  148. uint32_t sink_rate; /**< sink rate or 0 for variable */
  149. uint32_t rate_mask; /**< SOF_RATE_ supported rates */
  150. } __packed __aligned(4);
  151. /* generic ASRC component */
  152. struct sof_ipc_comp_asrc {
  153. struct sof_ipc_comp comp;
  154. struct sof_ipc_comp_config config;
  155. /* either source or sink rate must be non zero */
  156. uint32_t source_rate; /**< Define fixed source rate or */
  157. /**< use 0 to indicate need to get */
  158. /**< the rate from stream */
  159. uint32_t sink_rate; /**< Define fixed sink rate or */
  160. /**< use 0 to indicate need to get */
  161. /**< the rate from stream */
  162. uint32_t asynchronous_mode; /**< synchronous 0, asynchronous 1 */
  163. /**< When 1 the ASRC tracks and */
  164. /**< compensates for drift. */
  165. uint32_t operation_mode; /**< push 0, pull 1, In push mode the */
  166. /**< ASRC consumes a defined number */
  167. /**< of frames at input, with varying */
  168. /**< number of frames at output. */
  169. /**< In pull mode the ASRC outputs */
  170. /**< a defined number of frames while */
  171. /**< number of input frames varies. */
  172. /* reserved for future use */
  173. uint32_t reserved[4];
  174. } __packed __aligned(4);
  175. /* generic MUX component */
  176. struct sof_ipc_comp_mux {
  177. struct sof_ipc_comp comp;
  178. struct sof_ipc_comp_config config;
  179. } __packed __aligned(4);
  180. /* generic tone generator component */
  181. struct sof_ipc_comp_tone {
  182. struct sof_ipc_comp comp;
  183. struct sof_ipc_comp_config config;
  184. int32_t sample_rate;
  185. int32_t frequency;
  186. int32_t amplitude;
  187. int32_t freq_mult;
  188. int32_t ampl_mult;
  189. int32_t length;
  190. int32_t period;
  191. int32_t repeats;
  192. int32_t ramp_step;
  193. } __packed __aligned(4);
  194. /** \brief Types of processing components */
  195. enum sof_ipc_process_type {
  196. SOF_PROCESS_NONE = 0, /**< None */
  197. SOF_PROCESS_EQFIR, /**< Intel FIR */
  198. SOF_PROCESS_EQIIR, /**< Intel IIR */
  199. SOF_PROCESS_KEYWORD_DETECT, /**< Keyword Detection */
  200. SOF_PROCESS_KPB, /**< KeyPhrase Buffer Manager */
  201. SOF_PROCESS_CHAN_SELECTOR, /**< Channel Selector */
  202. SOF_PROCESS_MUX,
  203. SOF_PROCESS_DEMUX,
  204. SOF_PROCESS_DCBLOCK,
  205. SOF_PROCESS_SMART_AMP, /**< Smart Amplifier */
  206. };
  207. /* generic "effect", "codec" or proprietary processing component */
  208. struct sof_ipc_comp_process {
  209. struct sof_ipc_comp comp;
  210. struct sof_ipc_comp_config config;
  211. uint32_t size; /**< size of bespoke data section in bytes */
  212. uint32_t type; /**< sof_ipc_process_type */
  213. /* reserved for future use */
  214. uint32_t reserved[7];
  215. unsigned char data[];
  216. } __packed __aligned(4);
  217. /* frees components, buffers and pipelines
  218. * SOF_IPC_TPLG_COMP_FREE, SOF_IPC_TPLG_PIPE_FREE, SOF_IPC_TPLG_BUFFER_FREE
  219. */
  220. struct sof_ipc_free {
  221. struct sof_ipc_cmd_hdr hdr;
  222. uint32_t id;
  223. } __packed __aligned(4);
  224. struct sof_ipc_comp_reply {
  225. struct sof_ipc_reply rhdr;
  226. uint32_t id;
  227. uint32_t offset;
  228. } __packed __aligned(4);
  229. /*
  230. * Pipeline
  231. */
  232. /** \brief Types of pipeline scheduling time domains */
  233. enum sof_ipc_pipe_sched_time_domain {
  234. SOF_TIME_DOMAIN_DMA = 0, /**< DMA interrupt */
  235. SOF_TIME_DOMAIN_TIMER, /**< Timer interrupt */
  236. };
  237. /* new pipeline - SOF_IPC_TPLG_PIPE_NEW */
  238. struct sof_ipc_pipe_new {
  239. struct sof_ipc_cmd_hdr hdr;
  240. uint32_t comp_id; /**< component id for pipeline */
  241. uint32_t pipeline_id; /**< pipeline id */
  242. uint32_t sched_id; /**< Scheduling component id */
  243. uint32_t core; /**< core we run on */
  244. uint32_t period; /**< execution period in us*/
  245. uint32_t priority; /**< priority level 0 (low) to 10 (max) */
  246. uint32_t period_mips; /**< worst case instruction count per period */
  247. uint32_t frames_per_sched;/**< output frames of pipeline, 0 is variable */
  248. uint32_t xrun_limit_usecs; /**< report xruns greater than limit */
  249. uint32_t time_domain; /**< scheduling time domain */
  250. } __packed __aligned(4);
  251. /* pipeline construction complete - SOF_IPC_TPLG_PIPE_COMPLETE */
  252. struct sof_ipc_pipe_ready {
  253. struct sof_ipc_cmd_hdr hdr;
  254. uint32_t comp_id;
  255. } __packed __aligned(4);
  256. struct sof_ipc_pipe_free {
  257. struct sof_ipc_cmd_hdr hdr;
  258. uint32_t comp_id;
  259. } __packed __aligned(4);
  260. /* connect two components in pipeline - SOF_IPC_TPLG_COMP_CONNECT */
  261. struct sof_ipc_pipe_comp_connect {
  262. struct sof_ipc_cmd_hdr hdr;
  263. uint32_t source_id;
  264. uint32_t sink_id;
  265. } __packed __aligned(4);
  266. /* external events */
  267. enum sof_event_types {
  268. SOF_EVENT_NONE = 0,
  269. SOF_KEYWORD_DETECT_DAPM_EVENT,
  270. };
  271. #endif