ipc4-topology.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. All rights reserved.
  7. */
  8. #ifndef __INCLUDE_SOUND_SOF_IPC4_TOPOLOGY_H__
  9. #define __INCLUDE_SOUND_SOF_IPC4_TOPOLOGY_H__
  10. #include <sound/sof/ipc4/header.h>
  11. #define SOF_IPC4_FW_PAGE_SIZE BIT(12)
  12. #define SOF_IPC4_FW_PAGE(x) ((((x) + BIT(12) - 1) & ~(BIT(12) - 1)) >> 12)
  13. #define SOF_IPC4_FW_ROUNDUP(x) (((x) + BIT(6) - 1) & (~(BIT(6) - 1)))
  14. #define SOF_IPC4_MODULE_LOAD_TYPE GENMASK(3, 0)
  15. #define SOF_IPC4_MODULE_AUTO_START BIT(4)
  16. /*
  17. * Two module schedule domains in fw :
  18. * LL domain - Low latency domain
  19. * DP domain - Data processing domain
  20. * The LL setting should be equal to !DP setting
  21. */
  22. #define SOF_IPC4_MODULE_LL BIT(5)
  23. #define SOF_IPC4_MODULE_DP BIT(6)
  24. #define SOF_IPC4_MODULE_LIB_CODE BIT(7)
  25. #define SOF_IPC4_MODULE_INSTANCE_LIST_ITEM_SIZE 12
  26. #define SOF_IPC4_PIPELINE_OBJECT_SIZE 448
  27. #define SOF_IPC4_DATA_QUEUE_OBJECT_SIZE 128
  28. #define SOF_IPC4_LL_TASK_OBJECT_SIZE 72
  29. #define SOF_IPC4_DP_TASK_OBJECT_SIZE 104
  30. #define SOF_IPC4_DP_TASK_LIST_SIZE (12 + 8)
  31. #define SOF_IPC4_LL_TASK_LIST_ITEM_SIZE 12
  32. #define SOF_IPC4_FW_MAX_PAGE_COUNT 20
  33. #define SOF_IPC4_FW_MAX_QUEUE_COUNT 8
  34. /* Node index and mask applicable for host copier and ALH/HDA type DAI copiers */
  35. #define SOF_IPC4_NODE_INDEX_MASK 0xFF
  36. #define SOF_IPC4_NODE_INDEX(x) ((x) & SOF_IPC4_NODE_INDEX_MASK)
  37. #define SOF_IPC4_NODE_TYPE(x) ((x) << 8)
  38. /* Node ID for SSP type DAI copiers */
  39. #define SOF_IPC4_NODE_INDEX_INTEL_SSP(x) (((x) & 0xf) << 4)
  40. /* Node ID for DMIC type DAI copiers */
  41. #define SOF_IPC4_NODE_INDEX_INTEL_DMIC(x) ((x) & 0x7)
  42. #define SOF_IPC4_GAIN_ALL_CHANNELS_MASK 0xffffffff
  43. #define SOF_IPC4_VOL_ZERO_DB 0x7fffffff
  44. #define ALH_MAX_NUMBER_OF_GTW 16
  45. /*
  46. * The base of multi-gateways. Multi-gateways addressing starts from
  47. * ALH_MULTI_GTW_BASE and there are ALH_MULTI_GTW_COUNT multi-sources
  48. * and ALH_MULTI_GTW_COUNT multi-sinks available.
  49. * Addressing is continuous from ALH_MULTI_GTW_BASE to
  50. * ALH_MULTI_GTW_BASE + ALH_MULTI_GTW_COUNT - 1.
  51. */
  52. #define ALH_MULTI_GTW_BASE 0x50
  53. /* A magic number from FW */
  54. #define ALH_MULTI_GTW_COUNT 8
  55. /**
  56. * struct sof_ipc4_pipeline - pipeline config data
  57. * @priority: Priority of this pipeline
  58. * @lp_mode: Low power mode
  59. * @mem_usage: Memory usage
  60. * @state: Pipeline state
  61. * @msg: message structure for pipeline
  62. */
  63. struct sof_ipc4_pipeline {
  64. uint32_t priority;
  65. uint32_t lp_mode;
  66. uint32_t mem_usage;
  67. int state;
  68. struct sof_ipc4_msg msg;
  69. };
  70. /**
  71. * struct sof_ipc4_available_audio_format - Available audio formats
  72. * @base_config: Available base config
  73. * @out_audio_fmt: Available output audio format
  74. * @ref_audio_fmt: Reference audio format to match runtime audio format
  75. * @dma_buffer_size: Available Gateway DMA buffer size (in bytes)
  76. * @audio_fmt_num: Number of available audio formats
  77. */
  78. struct sof_ipc4_available_audio_format {
  79. struct sof_ipc4_base_module_cfg *base_config;
  80. struct sof_ipc4_audio_format *out_audio_fmt;
  81. struct sof_ipc4_audio_format *ref_audio_fmt;
  82. u32 *dma_buffer_size;
  83. int audio_fmt_num;
  84. };
  85. /**
  86. * struct sof_copier_gateway_cfg - IPC gateway configuration
  87. * @node_id: ID of Gateway Node
  88. * @dma_buffer_size: Preferred Gateway DMA buffer size (in bytes)
  89. * @config_length: Length of gateway node configuration blob specified in #config_data
  90. * config_data: Gateway node configuration blob
  91. */
  92. struct sof_copier_gateway_cfg {
  93. uint32_t node_id;
  94. uint32_t dma_buffer_size;
  95. uint32_t config_length;
  96. uint32_t config_data[];
  97. };
  98. /**
  99. * struct sof_ipc4_copier_data - IPC data for copier
  100. * @base_config: Base configuration including input audio format
  101. * @out_format: Output audio format
  102. * @copier_feature_mask: Copier feature mask
  103. * @gtw_cfg: Gateway configuration
  104. */
  105. struct sof_ipc4_copier_data {
  106. struct sof_ipc4_base_module_cfg base_config;
  107. struct sof_ipc4_audio_format out_format;
  108. uint32_t copier_feature_mask;
  109. struct sof_copier_gateway_cfg gtw_cfg;
  110. };
  111. /**
  112. * struct sof_ipc4_gtw_attributes: Gateway attributes
  113. * @lp_buffer_alloc: Gateway data requested in low power memory
  114. * @alloc_from_reg_file: Gateway data requested in register file memory
  115. * @rsvd: reserved for future use
  116. */
  117. struct sof_ipc4_gtw_attributes {
  118. uint32_t lp_buffer_alloc : 1;
  119. uint32_t alloc_from_reg_file : 1;
  120. uint32_t rsvd : 30;
  121. };
  122. /** struct sof_ipc4_alh_multi_gtw_cfg: ALH gateway cfg data
  123. * @count: Number of streams (valid items in mapping array)
  124. * @alh_id: ALH stream id of a single ALH stream aggregated
  125. * @channel_mask: Channel mask
  126. * @mapping: ALH streams
  127. */
  128. struct sof_ipc4_alh_multi_gtw_cfg {
  129. uint32_t count;
  130. struct {
  131. uint32_t alh_id;
  132. uint32_t channel_mask;
  133. } mapping[ALH_MAX_NUMBER_OF_GTW];
  134. } __packed;
  135. /** struct sof_ipc4_alh_configuration_blob: ALH blob
  136. * @gw_attr: Gateway attributes
  137. * @alh_cfg: ALH configuration data
  138. */
  139. struct sof_ipc4_alh_configuration_blob {
  140. struct sof_ipc4_gtw_attributes gw_attr;
  141. struct sof_ipc4_alh_multi_gtw_cfg alh_cfg;
  142. };
  143. /**
  144. * struct sof_ipc4_copier - copier config data
  145. * @data: IPC copier data
  146. * @copier_config: Copier + blob
  147. * @ipc_config_size: Size of copier_config
  148. * @available_fmt: Available audio format
  149. * @frame_fmt: frame format
  150. * @msg: message structure for copier
  151. * @gtw_attr: Gateway attributes for copier blob
  152. * @dai_type: DAI type
  153. * @dai_index: DAI index
  154. */
  155. struct sof_ipc4_copier {
  156. struct sof_ipc4_copier_data data;
  157. u32 *copier_config;
  158. uint32_t ipc_config_size;
  159. void *ipc_config_data;
  160. struct sof_ipc4_available_audio_format available_fmt;
  161. u32 frame_fmt;
  162. struct sof_ipc4_msg msg;
  163. struct sof_ipc4_gtw_attributes *gtw_attr;
  164. u32 dai_type;
  165. int dai_index;
  166. };
  167. /**
  168. * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data
  169. * @channel: Channel ID
  170. * @value: gain value
  171. */
  172. struct sof_ipc4_ctrl_value_chan {
  173. u32 channel;
  174. u32 value;
  175. };
  176. /**
  177. * struct sof_ipc4_control_data - IPC data for kcontrol IO
  178. * @msg: message structure for kcontrol IO
  179. * @index: pipeline ID
  180. * @chanv: channel ID and value array used by volume type controls
  181. * @data: data for binary kcontrols
  182. */
  183. struct sof_ipc4_control_data {
  184. struct sof_ipc4_msg msg;
  185. int index;
  186. union {
  187. struct sof_ipc4_ctrl_value_chan chanv[0];
  188. struct sof_abi_hdr data[0];
  189. };
  190. };
  191. /**
  192. * struct sof_ipc4_gain_data - IPC gain blob
  193. * @channels: Channels
  194. * @init_val: Initial value
  195. * @curve_type: Curve type
  196. * @reserved: reserved for future use
  197. * @curve_duration_l: Curve duration low part
  198. * @curve_duration_h: Curve duration high part
  199. */
  200. struct sof_ipc4_gain_data {
  201. uint32_t channels;
  202. uint32_t init_val;
  203. uint32_t curve_type;
  204. uint32_t reserved;
  205. uint32_t curve_duration_l;
  206. uint32_t curve_duration_h;
  207. } __aligned(8);
  208. /**
  209. * struct sof_ipc4_gain - gain config data
  210. * @base_config: IPC base config data
  211. * @data: IPC gain blob
  212. * @available_fmt: Available audio format
  213. * @msg: message structure for gain
  214. */
  215. struct sof_ipc4_gain {
  216. struct sof_ipc4_base_module_cfg base_config;
  217. struct sof_ipc4_gain_data data;
  218. struct sof_ipc4_available_audio_format available_fmt;
  219. struct sof_ipc4_msg msg;
  220. };
  221. /**
  222. * struct sof_ipc4_mixer - mixer config data
  223. * @base_config: IPC base config data
  224. * @available_fmt: Available audio format
  225. * @msg: IPC4 message struct containing header and data info
  226. */
  227. struct sof_ipc4_mixer {
  228. struct sof_ipc4_base_module_cfg base_config;
  229. struct sof_ipc4_available_audio_format available_fmt;
  230. struct sof_ipc4_msg msg;
  231. };
  232. /**
  233. * struct sof_ipc4_src SRC config data
  234. * @base_config: IPC base config data
  235. * @sink_rate: Output rate for sink module
  236. * @available_fmt: Available audio format
  237. * @msg: IPC4 message struct containing header and data info
  238. */
  239. struct sof_ipc4_src {
  240. struct sof_ipc4_base_module_cfg base_config;
  241. uint32_t sink_rate;
  242. struct sof_ipc4_available_audio_format available_fmt;
  243. struct sof_ipc4_msg msg;
  244. };
  245. #endif