ipc4-topology.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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_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_INIT_CONFIG_MASK GENMASK(11, 8)
  26. #define SOF_IPC4_MODULE_INIT_CONFIG_TYPE_BASE_CFG 0
  27. #define SOF_IPC4_MODULE_INIT_CONFIG_TYPE_BASE_CFG_WITH_EXT 1
  28. #define SOF_IPC4_MODULE_INSTANCE_LIST_ITEM_SIZE 12
  29. #define SOF_IPC4_PIPELINE_OBJECT_SIZE 448
  30. #define SOF_IPC4_DATA_QUEUE_OBJECT_SIZE 128
  31. #define SOF_IPC4_LL_TASK_OBJECT_SIZE 72
  32. #define SOF_IPC4_DP_TASK_OBJECT_SIZE 104
  33. #define SOF_IPC4_DP_TASK_LIST_SIZE (12 + 8)
  34. #define SOF_IPC4_LL_TASK_LIST_ITEM_SIZE 12
  35. #define SOF_IPC4_FW_MAX_PAGE_COUNT 20
  36. #define SOF_IPC4_FW_MAX_QUEUE_COUNT 8
  37. /* Node index and mask applicable for host copier and ALH/HDA type DAI copiers */
  38. #define SOF_IPC4_NODE_INDEX_MASK 0xFF
  39. #define SOF_IPC4_NODE_INDEX(x) ((x) & SOF_IPC4_NODE_INDEX_MASK)
  40. #define SOF_IPC4_NODE_TYPE(x) ((x) << 8)
  41. #define SOF_IPC4_GET_NODE_TYPE(node_id) ((node_id) >> 8)
  42. /* Node ID for SSP type DAI copiers */
  43. #define SOF_IPC4_NODE_INDEX_INTEL_SSP(x) (((x) & 0xf) << 4)
  44. /* Node ID for DMIC type DAI copiers */
  45. #define SOF_IPC4_NODE_INDEX_INTEL_DMIC(x) ((x) & 0x7)
  46. #define SOF_IPC4_GAIN_ALL_CHANNELS_MASK 0xffffffff
  47. #define SOF_IPC4_VOL_ZERO_DB 0x7fffffff
  48. #define SOF_IPC4_DMA_DEVICE_MAX_COUNT 16
  49. #define SOF_IPC4_CHAIN_DMA_NODE_ID 0x7fffffff
  50. #define SOF_IPC4_INVALID_NODE_ID 0xffffffff
  51. /* FW requires minimum 4ms DMA buffer size */
  52. #define SOF_IPC4_MIN_DMA_BUFFER_SIZE 4
  53. /* ChainDMA in fw uses 5ms DMA buffer */
  54. #define SOF_IPC4_CHAIN_DMA_BUFFER_SIZE 5
  55. /*
  56. * The base of multi-gateways. Multi-gateways addressing starts from
  57. * ALH_MULTI_GTW_BASE and there are ALH_MULTI_GTW_COUNT multi-sources
  58. * and ALH_MULTI_GTW_COUNT multi-sinks available.
  59. * Addressing is continuous from ALH_MULTI_GTW_BASE to
  60. * ALH_MULTI_GTW_BASE + ALH_MULTI_GTW_COUNT - 1.
  61. */
  62. #define ALH_MULTI_GTW_BASE 0x50
  63. /* A magic number from FW */
  64. #define ALH_MULTI_GTW_COUNT 8
  65. enum sof_ipc4_copier_module_config_params {
  66. /*
  67. * Use LARGE_CONFIG_SET to initialize timestamp event. Ipc mailbox must
  68. * contain properly built CopierConfigTimestampInitData struct.
  69. */
  70. SOF_IPC4_COPIER_MODULE_CFG_PARAM_TIMESTAMP_INIT = 1,
  71. /*
  72. * Use LARGE_CONFIG_SET to initialize copier sink. Ipc mailbox must contain
  73. * properly built CopierConfigSetSinkFormat struct.
  74. */
  75. SOF_IPC4_COPIER_MODULE_CFG_PARAM_SET_SINK_FORMAT,
  76. /*
  77. * Use LARGE_CONFIG_SET to initialize and enable on Copier data segment
  78. * event. Ipc mailbox must contain properly built DataSegmentEnabled struct.
  79. */
  80. SOF_IPC4_COPIER_MODULE_CFG_PARAM_DATA_SEGMENT_ENABLED,
  81. /*
  82. * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non
  83. * HD-A gateways.
  84. */
  85. SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING,
  86. /*
  87. * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non
  88. * HD-A gateways and corresponding total processed data
  89. */
  90. SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING_EXTENDED,
  91. /*
  92. * Use LARGE_CONFIG_SET to setup attenuation on output pins. Data is just uint32_t.
  93. * note Config is only allowed when output pin is set up for 32bit and source
  94. * is connected to Gateway
  95. */
  96. SOF_IPC4_COPIER_MODULE_CFG_ATTENUATION,
  97. };
  98. struct sof_ipc4_copier_config_set_sink_format {
  99. /* Id of sink */
  100. u32 sink_id;
  101. /*
  102. * Input format used by the source
  103. * attention must be the same as present if already initialized.
  104. */
  105. struct sof_ipc4_audio_format source_fmt;
  106. /* Output format used by the sink */
  107. struct sof_ipc4_audio_format sink_fmt;
  108. } __packed __aligned(4);
  109. /**
  110. * struct sof_ipc4_pipeline - pipeline config data
  111. * @priority: Priority of this pipeline
  112. * @lp_mode: Low power mode
  113. * @mem_usage: Memory usage
  114. * @core_id: Target core for the pipeline
  115. * @state: Pipeline state
  116. * @use_chain_dma: flag to indicate if the firmware shall use chained DMA
  117. * @msg: message structure for pipeline
  118. * @skip_during_fe_trigger: skip triggering this pipeline during the FE DAI trigger
  119. */
  120. struct sof_ipc4_pipeline {
  121. uint32_t priority;
  122. uint32_t lp_mode;
  123. uint32_t mem_usage;
  124. uint32_t core_id;
  125. int state;
  126. bool use_chain_dma;
  127. struct sof_ipc4_msg msg;
  128. bool skip_during_fe_trigger;
  129. };
  130. /**
  131. * struct sof_ipc4_multi_pipeline_data - multi pipeline trigger IPC data
  132. * @count: Number of pipelines to be triggered
  133. * @pipeline_instance_ids: Flexible array of IDs of the pipelines to be triggered
  134. */
  135. struct ipc4_pipeline_set_state_data {
  136. u32 count;
  137. DECLARE_FLEX_ARRAY(u32, pipeline_instance_ids);
  138. } __packed;
  139. /**
  140. * struct sof_ipc4_pin_format - Module pin format
  141. * @pin_index: pin index
  142. * @buffer_size: buffer size in bytes
  143. * @audio_fmt: audio format for the pin
  144. *
  145. * This structure can be used for both output or input pins and the pin_index is relative to the
  146. * pin type i.e output/input pin
  147. */
  148. struct sof_ipc4_pin_format {
  149. u32 pin_index;
  150. u32 buffer_size;
  151. struct sof_ipc4_audio_format audio_fmt;
  152. };
  153. /**
  154. * struct sof_ipc4_available_audio_format - Available audio formats
  155. * @output_pin_fmts: Available output pin formats
  156. * @input_pin_fmts: Available input pin formats
  157. * @num_input_formats: Number of input pin formats
  158. * @num_output_formats: Number of output pin formats
  159. */
  160. struct sof_ipc4_available_audio_format {
  161. struct sof_ipc4_pin_format *output_pin_fmts;
  162. struct sof_ipc4_pin_format *input_pin_fmts;
  163. u32 num_input_formats;
  164. u32 num_output_formats;
  165. };
  166. /**
  167. * struct sof_copier_gateway_cfg - IPC gateway configuration
  168. * @node_id: ID of Gateway Node
  169. * @dma_buffer_size: Preferred Gateway DMA buffer size (in bytes)
  170. * @config_length: Length of gateway node configuration blob specified in #config_data
  171. * config_data: Gateway node configuration blob
  172. */
  173. struct sof_copier_gateway_cfg {
  174. uint32_t node_id;
  175. uint32_t dma_buffer_size;
  176. uint32_t config_length;
  177. uint32_t config_data[];
  178. };
  179. /**
  180. * struct sof_ipc4_copier_data - IPC data for copier
  181. * @base_config: Base configuration including input audio format
  182. * @out_format: Output audio format
  183. * @copier_feature_mask: Copier feature mask
  184. * @gtw_cfg: Gateway configuration
  185. */
  186. struct sof_ipc4_copier_data {
  187. struct sof_ipc4_base_module_cfg base_config;
  188. struct sof_ipc4_audio_format out_format;
  189. uint32_t copier_feature_mask;
  190. struct sof_copier_gateway_cfg gtw_cfg;
  191. };
  192. /**
  193. * struct sof_ipc4_gtw_attributes: Gateway attributes
  194. * @lp_buffer_alloc: Gateway data requested in low power memory
  195. * @alloc_from_reg_file: Gateway data requested in register file memory
  196. * @rsvd: reserved for future use
  197. */
  198. struct sof_ipc4_gtw_attributes {
  199. uint32_t lp_buffer_alloc : 1;
  200. uint32_t alloc_from_reg_file : 1;
  201. uint32_t rsvd : 30;
  202. };
  203. /**
  204. * struct sof_ipc4_dma_device_stream_ch_map: abstract representation of
  205. * channel mapping to DMAs
  206. * @device: representation of hardware device address or FIFO
  207. * @channel_mask: channels handled by @device. Channels are expected to be
  208. * contiguous
  209. */
  210. struct sof_ipc4_dma_device_stream_ch_map {
  211. uint32_t device;
  212. uint32_t channel_mask;
  213. };
  214. /**
  215. * struct sof_ipc4_dma_stream_ch_map: DMA configuration data
  216. * @device_count: Number valid items in mapping array
  217. * @mapping: device address and channel mask
  218. */
  219. struct sof_ipc4_dma_stream_ch_map {
  220. uint32_t device_count;
  221. struct sof_ipc4_dma_device_stream_ch_map mapping[SOF_IPC4_DMA_DEVICE_MAX_COUNT];
  222. } __packed;
  223. #define SOF_IPC4_DMA_METHOD_HDA 1
  224. #define SOF_IPC4_DMA_METHOD_GPDMA 2 /* defined for consistency but not used */
  225. #define SOF_IPC4_CHAIN_DMA_BUF_SIZE_MS 2
  226. /**
  227. * struct sof_ipc4_dma_config: DMA configuration
  228. * @dma_method: HDAudio or GPDMA
  229. * @pre_allocated_by_host: 1 if host driver allocates DMA channels, 0 otherwise
  230. * @dma_channel_id: for HDaudio defined as @stream_id - 1
  231. * @stream_id: HDaudio stream tag
  232. * @dma_stream_channel_map: array of device/channel mappings
  233. * @dma_priv_config_size: currently not used
  234. * @dma_priv_config: currently not used
  235. */
  236. struct sof_ipc4_dma_config {
  237. uint8_t dma_method;
  238. uint8_t pre_allocated_by_host;
  239. uint16_t rsvd;
  240. uint32_t dma_channel_id;
  241. uint32_t stream_id;
  242. struct sof_ipc4_dma_stream_ch_map dma_stream_channel_map;
  243. uint32_t dma_priv_config_size;
  244. uint8_t dma_priv_config[];
  245. } __packed;
  246. #define SOF_IPC4_GTW_DMA_CONFIG_ID 0x1000
  247. /**
  248. * struct sof_ipc4_dma_config: DMA configuration
  249. * @type: set to SOF_IPC4_GTW_DMA_CONFIG_ID
  250. * @length: sizeof(struct sof_ipc4_dma_config) + dma_config.dma_priv_config_size
  251. * @dma_config: actual DMA configuration
  252. */
  253. struct sof_ipc4_dma_config_tlv {
  254. uint32_t type;
  255. uint32_t length;
  256. struct sof_ipc4_dma_config dma_config;
  257. } __packed;
  258. /** struct sof_ipc4_alh_configuration_blob: ALH blob
  259. * @gw_attr: Gateway attributes
  260. * @alh_cfg: ALH configuration data
  261. */
  262. struct sof_ipc4_alh_configuration_blob {
  263. struct sof_ipc4_gtw_attributes gw_attr;
  264. struct sof_ipc4_dma_stream_ch_map alh_cfg;
  265. };
  266. /**
  267. * struct sof_ipc4_copier - copier config data
  268. * @data: IPC copier data
  269. * @copier_config: Copier + blob
  270. * @ipc_config_size: Size of copier_config
  271. * @available_fmt: Available audio format
  272. * @frame_fmt: frame format
  273. * @msg: message structure for copier
  274. * @gtw_attr: Gateway attributes for copier blob
  275. * @dai_type: DAI type
  276. * @dai_index: DAI index
  277. * @dma_config_tlv: DMA configuration
  278. */
  279. struct sof_ipc4_copier {
  280. struct sof_ipc4_copier_data data;
  281. u32 *copier_config;
  282. uint32_t ipc_config_size;
  283. void *ipc_config_data;
  284. struct sof_ipc4_available_audio_format available_fmt;
  285. u32 frame_fmt;
  286. struct sof_ipc4_msg msg;
  287. struct sof_ipc4_gtw_attributes *gtw_attr;
  288. u32 dai_type;
  289. int dai_index;
  290. struct sof_ipc4_dma_config_tlv dma_config_tlv[SOF_IPC4_DMA_DEVICE_MAX_COUNT];
  291. };
  292. /**
  293. * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data
  294. * @channel: Channel ID
  295. * @value: Value associated with @channel
  296. */
  297. struct sof_ipc4_ctrl_value_chan {
  298. u32 channel;
  299. u32 value;
  300. };
  301. /**
  302. * struct sof_ipc4_control_data - IPC data for kcontrol IO
  303. * @msg: message structure for kcontrol IO
  304. * @index: pipeline ID
  305. * @chanv: channel ID and value array used by volume type controls
  306. * @data: data for binary kcontrols
  307. */
  308. struct sof_ipc4_control_data {
  309. struct sof_ipc4_msg msg;
  310. int index;
  311. union {
  312. DECLARE_FLEX_ARRAY(struct sof_ipc4_ctrl_value_chan, chanv);
  313. DECLARE_FLEX_ARRAY(struct sof_abi_hdr, data);
  314. };
  315. };
  316. #define SOF_IPC4_SWITCH_CONTROL_PARAM_ID 200
  317. #define SOF_IPC4_ENUM_CONTROL_PARAM_ID 201
  318. /**
  319. * struct sof_ipc4_control_msg_payload - IPC payload for kcontrol parameters
  320. * @id: unique id of the control
  321. * @num_elems: Number of elements in the chanv array
  322. * @reserved: reserved for future use, must be set to 0
  323. * @chanv: channel ID and value array
  324. */
  325. struct sof_ipc4_control_msg_payload {
  326. uint16_t id;
  327. uint16_t num_elems;
  328. uint32_t reserved[4];
  329. DECLARE_FLEX_ARRAY(struct sof_ipc4_ctrl_value_chan, chanv);
  330. } __packed;
  331. /**
  332. * struct sof_ipc4_gain_params - IPC gain parameters
  333. * @channels: Channels
  334. * @init_val: Initial value
  335. * @curve_type: Curve type
  336. * @reserved: reserved for future use
  337. * @curve_duration_l: Curve duration low part
  338. * @curve_duration_h: Curve duration high part
  339. */
  340. struct sof_ipc4_gain_params {
  341. uint32_t channels;
  342. uint32_t init_val;
  343. uint32_t curve_type;
  344. uint32_t reserved;
  345. uint32_t curve_duration_l;
  346. uint32_t curve_duration_h;
  347. } __packed __aligned(4);
  348. /**
  349. * struct sof_ipc4_gain_data - IPC gain init blob
  350. * @base_config: IPC base config data
  351. * @params: Initial parameters for the gain module
  352. */
  353. struct sof_ipc4_gain_data {
  354. struct sof_ipc4_base_module_cfg base_config;
  355. struct sof_ipc4_gain_params params;
  356. } __packed __aligned(4);
  357. /**
  358. * struct sof_ipc4_gain - gain config data
  359. * @data: IPC gain blob
  360. * @available_fmt: Available audio format
  361. * @msg: message structure for gain
  362. */
  363. struct sof_ipc4_gain {
  364. struct sof_ipc4_gain_data data;
  365. struct sof_ipc4_available_audio_format available_fmt;
  366. struct sof_ipc4_msg msg;
  367. };
  368. /**
  369. * struct sof_ipc4_mixer - mixer config data
  370. * @base_config: IPC base config data
  371. * @available_fmt: Available audio format
  372. * @msg: IPC4 message struct containing header and data info
  373. */
  374. struct sof_ipc4_mixer {
  375. struct sof_ipc4_base_module_cfg base_config;
  376. struct sof_ipc4_available_audio_format available_fmt;
  377. struct sof_ipc4_msg msg;
  378. };
  379. /*
  380. * struct sof_ipc4_src_data - IPC data for SRC
  381. * @base_config: IPC base config data
  382. * @sink_rate: Output rate for sink module
  383. */
  384. struct sof_ipc4_src_data {
  385. struct sof_ipc4_base_module_cfg base_config;
  386. uint32_t sink_rate;
  387. } __packed __aligned(4);
  388. /**
  389. * struct sof_ipc4_src - SRC config data
  390. * @data: IPC base config data
  391. * @available_fmt: Available audio format
  392. * @msg: IPC4 message struct containing header and data info
  393. */
  394. struct sof_ipc4_src {
  395. struct sof_ipc4_src_data data;
  396. struct sof_ipc4_available_audio_format available_fmt;
  397. struct sof_ipc4_msg msg;
  398. };
  399. /**
  400. * struct sof_ipc4_base_module_cfg_ext - base module config extension containing the pin format
  401. * information for the module. Both @num_input_pin_fmts and @num_output_pin_fmts cannot be 0 for a
  402. * module.
  403. * @num_input_pin_fmts: number of input pin formats in the @pin_formats array
  404. * @num_output_pin_fmts: number of output pin formats in the @pin_formats array
  405. * @reserved: reserved for future use
  406. * @pin_formats: flexible array consisting of @num_input_pin_fmts input pin format items followed
  407. * by @num_output_pin_fmts output pin format items
  408. */
  409. struct sof_ipc4_base_module_cfg_ext {
  410. u16 num_input_pin_fmts;
  411. u16 num_output_pin_fmts;
  412. u8 reserved[12];
  413. DECLARE_FLEX_ARRAY(struct sof_ipc4_pin_format, pin_formats);
  414. } __packed;
  415. /**
  416. * struct sof_ipc4_process - process config data
  417. * @base_config: IPC base config data
  418. * @base_config_ext: Base config extension data for module init
  419. * @output_format: Output audio format
  420. * @available_fmt: Available audio format
  421. * @ipc_config_data: Process module config data
  422. * @ipc_config_size: Size of process module config data
  423. * @msg: IPC4 message struct containing header and data info
  424. * @base_config_ext_size: Size of the base config extension data in bytes
  425. * @init_config: Module init config type (SOF_IPC4_MODULE_INIT_CONFIG_TYPE_*)
  426. */
  427. struct sof_ipc4_process {
  428. struct sof_ipc4_base_module_cfg base_config;
  429. struct sof_ipc4_base_module_cfg_ext *base_config_ext;
  430. struct sof_ipc4_audio_format output_format;
  431. struct sof_ipc4_available_audio_format available_fmt;
  432. void *ipc_config_data;
  433. uint32_t ipc_config_size;
  434. struct sof_ipc4_msg msg;
  435. u32 base_config_ext_size;
  436. u32 init_config;
  437. };
  438. bool sof_ipc4_copier_is_single_bitdepth(struct snd_sof_dev *sdev,
  439. struct sof_ipc4_pin_format *pin_fmts,
  440. u32 pin_fmts_size);
  441. #endif