18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 48c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright(c) 2018 Intel Corporation. All rights reserved. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __INCLUDE_SOUND_SOF_TOPOLOGY_H__ 108c2ecf20Sopenharmony_ci#define __INCLUDE_SOUND_SOF_TOPOLOGY_H__ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <sound/sof/header.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * Component 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* types of component */ 198c2ecf20Sopenharmony_cienum sof_comp_type { 208c2ecf20Sopenharmony_ci SOF_COMP_NONE = 0, 218c2ecf20Sopenharmony_ci SOF_COMP_HOST, 228c2ecf20Sopenharmony_ci SOF_COMP_DAI, 238c2ecf20Sopenharmony_ci SOF_COMP_SG_HOST, /**< scatter gather variant */ 248c2ecf20Sopenharmony_ci SOF_COMP_SG_DAI, /**< scatter gather variant */ 258c2ecf20Sopenharmony_ci SOF_COMP_VOLUME, 268c2ecf20Sopenharmony_ci SOF_COMP_MIXER, 278c2ecf20Sopenharmony_ci SOF_COMP_MUX, 288c2ecf20Sopenharmony_ci SOF_COMP_SRC, 298c2ecf20Sopenharmony_ci SOF_COMP_SPLITTER, 308c2ecf20Sopenharmony_ci SOF_COMP_TONE, 318c2ecf20Sopenharmony_ci SOF_COMP_SWITCH, 328c2ecf20Sopenharmony_ci SOF_COMP_BUFFER, 338c2ecf20Sopenharmony_ci SOF_COMP_EQ_IIR, 348c2ecf20Sopenharmony_ci SOF_COMP_EQ_FIR, 358c2ecf20Sopenharmony_ci SOF_COMP_KEYWORD_DETECT, 368c2ecf20Sopenharmony_ci SOF_COMP_KPB, /* A key phrase buffer component */ 378c2ecf20Sopenharmony_ci SOF_COMP_SELECTOR, /**< channel selector component */ 388c2ecf20Sopenharmony_ci SOF_COMP_DEMUX, 398c2ecf20Sopenharmony_ci SOF_COMP_ASRC, /**< Asynchronous sample rate converter */ 408c2ecf20Sopenharmony_ci SOF_COMP_DCBLOCK, 418c2ecf20Sopenharmony_ci SOF_COMP_SMART_AMP, /**< smart amplifier component */ 428c2ecf20Sopenharmony_ci /* keep FILEREAD/FILEWRITE as the last ones */ 438c2ecf20Sopenharmony_ci SOF_COMP_FILEREAD = 10000, /**< host test based file IO */ 448c2ecf20Sopenharmony_ci SOF_COMP_FILEWRITE = 10001, /**< host test based file IO */ 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* XRUN action for component */ 488c2ecf20Sopenharmony_ci#define SOF_XRUN_STOP 1 /**< stop stream */ 498c2ecf20Sopenharmony_ci#define SOF_XRUN_UNDER_ZERO 2 /**< send 0s to sink */ 508c2ecf20Sopenharmony_ci#define SOF_XRUN_OVER_NULL 4 /**< send data to NULL */ 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* create new generic component - SOF_IPC_TPLG_COMP_NEW */ 538c2ecf20Sopenharmony_cistruct sof_ipc_comp { 548c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 558c2ecf20Sopenharmony_ci uint32_t id; 568c2ecf20Sopenharmony_ci enum sof_comp_type type; 578c2ecf20Sopenharmony_ci uint32_t pipeline_id; 588c2ecf20Sopenharmony_ci uint32_t core; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci /* extended data length, 0 if no extended data */ 618c2ecf20Sopenharmony_ci uint32_t ext_data_length; 628c2ecf20Sopenharmony_ci} __packed; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* 658c2ecf20Sopenharmony_ci * Component Buffers 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* 698c2ecf20Sopenharmony_ci * SOF memory capabilities, add new ones at the end 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_ci#define SOF_MEM_CAPS_RAM (1 << 0) 728c2ecf20Sopenharmony_ci#define SOF_MEM_CAPS_ROM (1 << 1) 738c2ecf20Sopenharmony_ci#define SOF_MEM_CAPS_EXT (1 << 2) /**< external */ 748c2ecf20Sopenharmony_ci#define SOF_MEM_CAPS_LP (1 << 3) /**< low power */ 758c2ecf20Sopenharmony_ci#define SOF_MEM_CAPS_HP (1 << 4) /**< high performance */ 768c2ecf20Sopenharmony_ci#define SOF_MEM_CAPS_DMA (1 << 5) /**< DMA'able */ 778c2ecf20Sopenharmony_ci#define SOF_MEM_CAPS_CACHE (1 << 6) /**< cacheable */ 788c2ecf20Sopenharmony_ci#define SOF_MEM_CAPS_EXEC (1 << 7) /**< executable */ 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* 818c2ecf20Sopenharmony_ci * overrun will cause ring buffer overwrite, instead of XRUN. 828c2ecf20Sopenharmony_ci */ 838c2ecf20Sopenharmony_ci#define SOF_BUF_OVERRUN_PERMITTED BIT(0) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* 868c2ecf20Sopenharmony_ci * underrun will cause readback of 0s, instead of XRUN. 878c2ecf20Sopenharmony_ci */ 888c2ecf20Sopenharmony_ci#define SOF_BUF_UNDERRUN_PERMITTED BIT(1) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* the UUID size in bytes, shared between FW and host */ 918c2ecf20Sopenharmony_ci#define SOF_UUID_SIZE 16 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* create new component buffer - SOF_IPC_TPLG_BUFFER_NEW */ 948c2ecf20Sopenharmony_cistruct sof_ipc_buffer { 958c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 968c2ecf20Sopenharmony_ci uint32_t size; /**< buffer size in bytes */ 978c2ecf20Sopenharmony_ci uint32_t caps; /**< SOF_MEM_CAPS_ */ 988c2ecf20Sopenharmony_ci uint32_t flags; /**< SOF_BUF_ flags defined above */ 998c2ecf20Sopenharmony_ci uint32_t reserved; /**< reserved for future use */ 1008c2ecf20Sopenharmony_ci} __packed; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci/* generic component config data - must always be after struct sof_ipc_comp */ 1038c2ecf20Sopenharmony_cistruct sof_ipc_comp_config { 1048c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 1058c2ecf20Sopenharmony_ci uint32_t periods_sink; /**< 0 means variable */ 1068c2ecf20Sopenharmony_ci uint32_t periods_source;/**< 0 means variable */ 1078c2ecf20Sopenharmony_ci uint32_t reserved1; /**< reserved */ 1088c2ecf20Sopenharmony_ci uint32_t frame_fmt; /**< SOF_IPC_FRAME_ */ 1098c2ecf20Sopenharmony_ci uint32_t xrun_action; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci /* reserved for future use */ 1128c2ecf20Sopenharmony_ci uint32_t reserved[2]; 1138c2ecf20Sopenharmony_ci} __packed; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* generic host component */ 1168c2ecf20Sopenharmony_cistruct sof_ipc_comp_host { 1178c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 1188c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 1198c2ecf20Sopenharmony_ci uint32_t direction; /**< SOF_IPC_STREAM_ */ 1208c2ecf20Sopenharmony_ci uint32_t no_irq; /**< don't send periodic IRQ to host/DSP */ 1218c2ecf20Sopenharmony_ci uint32_t dmac_config; /**< DMA engine specific */ 1228c2ecf20Sopenharmony_ci} __packed; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci/* generic DAI component */ 1258c2ecf20Sopenharmony_cistruct sof_ipc_comp_dai { 1268c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 1278c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 1288c2ecf20Sopenharmony_ci uint32_t direction; /**< SOF_IPC_STREAM_ */ 1298c2ecf20Sopenharmony_ci uint32_t dai_index; /**< index of this type dai */ 1308c2ecf20Sopenharmony_ci uint32_t type; /**< DAI type - SOF_DAI_ */ 1318c2ecf20Sopenharmony_ci uint32_t reserved; /**< reserved */ 1328c2ecf20Sopenharmony_ci} __packed; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci/* generic mixer component */ 1358c2ecf20Sopenharmony_cistruct sof_ipc_comp_mixer { 1368c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 1378c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 1388c2ecf20Sopenharmony_ci} __packed; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci/* volume ramping types */ 1418c2ecf20Sopenharmony_cienum sof_volume_ramp { 1428c2ecf20Sopenharmony_ci SOF_VOLUME_LINEAR = 0, 1438c2ecf20Sopenharmony_ci SOF_VOLUME_LOG, 1448c2ecf20Sopenharmony_ci SOF_VOLUME_LINEAR_ZC, 1458c2ecf20Sopenharmony_ci SOF_VOLUME_LOG_ZC, 1468c2ecf20Sopenharmony_ci}; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci/* generic volume component */ 1498c2ecf20Sopenharmony_cistruct sof_ipc_comp_volume { 1508c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 1518c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 1528c2ecf20Sopenharmony_ci uint32_t channels; 1538c2ecf20Sopenharmony_ci uint32_t min_value; 1548c2ecf20Sopenharmony_ci uint32_t max_value; 1558c2ecf20Sopenharmony_ci uint32_t ramp; /**< SOF_VOLUME_ */ 1568c2ecf20Sopenharmony_ci uint32_t initial_ramp; /**< ramp space in ms */ 1578c2ecf20Sopenharmony_ci} __packed; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci/* generic SRC component */ 1608c2ecf20Sopenharmony_cistruct sof_ipc_comp_src { 1618c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 1628c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 1638c2ecf20Sopenharmony_ci /* either source or sink rate must be non zero */ 1648c2ecf20Sopenharmony_ci uint32_t source_rate; /**< source rate or 0 for variable */ 1658c2ecf20Sopenharmony_ci uint32_t sink_rate; /**< sink rate or 0 for variable */ 1668c2ecf20Sopenharmony_ci uint32_t rate_mask; /**< SOF_RATE_ supported rates */ 1678c2ecf20Sopenharmony_ci} __packed; 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci/* generic ASRC component */ 1708c2ecf20Sopenharmony_cistruct sof_ipc_comp_asrc { 1718c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 1728c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 1738c2ecf20Sopenharmony_ci /* either source or sink rate must be non zero */ 1748c2ecf20Sopenharmony_ci uint32_t source_rate; /**< Define fixed source rate or */ 1758c2ecf20Sopenharmony_ci /**< use 0 to indicate need to get */ 1768c2ecf20Sopenharmony_ci /**< the rate from stream */ 1778c2ecf20Sopenharmony_ci uint32_t sink_rate; /**< Define fixed sink rate or */ 1788c2ecf20Sopenharmony_ci /**< use 0 to indicate need to get */ 1798c2ecf20Sopenharmony_ci /**< the rate from stream */ 1808c2ecf20Sopenharmony_ci uint32_t asynchronous_mode; /**< synchronous 0, asynchronous 1 */ 1818c2ecf20Sopenharmony_ci /**< When 1 the ASRC tracks and */ 1828c2ecf20Sopenharmony_ci /**< compensates for drift. */ 1838c2ecf20Sopenharmony_ci uint32_t operation_mode; /**< push 0, pull 1, In push mode the */ 1848c2ecf20Sopenharmony_ci /**< ASRC consumes a defined number */ 1858c2ecf20Sopenharmony_ci /**< of frames at input, with varying */ 1868c2ecf20Sopenharmony_ci /**< number of frames at output. */ 1878c2ecf20Sopenharmony_ci /**< In pull mode the ASRC outputs */ 1888c2ecf20Sopenharmony_ci /**< a defined number of frames while */ 1898c2ecf20Sopenharmony_ci /**< number of input frames varies. */ 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci /* reserved for future use */ 1928c2ecf20Sopenharmony_ci uint32_t reserved[4]; 1938c2ecf20Sopenharmony_ci} __attribute__((packed)); 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci/* generic MUX component */ 1968c2ecf20Sopenharmony_cistruct sof_ipc_comp_mux { 1978c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 1988c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 1998c2ecf20Sopenharmony_ci} __packed; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* generic tone generator component */ 2028c2ecf20Sopenharmony_cistruct sof_ipc_comp_tone { 2038c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 2048c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 2058c2ecf20Sopenharmony_ci int32_t sample_rate; 2068c2ecf20Sopenharmony_ci int32_t frequency; 2078c2ecf20Sopenharmony_ci int32_t amplitude; 2088c2ecf20Sopenharmony_ci int32_t freq_mult; 2098c2ecf20Sopenharmony_ci int32_t ampl_mult; 2108c2ecf20Sopenharmony_ci int32_t length; 2118c2ecf20Sopenharmony_ci int32_t period; 2128c2ecf20Sopenharmony_ci int32_t repeats; 2138c2ecf20Sopenharmony_ci int32_t ramp_step; 2148c2ecf20Sopenharmony_ci} __packed; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci/** \brief Types of processing components */ 2178c2ecf20Sopenharmony_cienum sof_ipc_process_type { 2188c2ecf20Sopenharmony_ci SOF_PROCESS_NONE = 0, /**< None */ 2198c2ecf20Sopenharmony_ci SOF_PROCESS_EQFIR, /**< Intel FIR */ 2208c2ecf20Sopenharmony_ci SOF_PROCESS_EQIIR, /**< Intel IIR */ 2218c2ecf20Sopenharmony_ci SOF_PROCESS_KEYWORD_DETECT, /**< Keyword Detection */ 2228c2ecf20Sopenharmony_ci SOF_PROCESS_KPB, /**< KeyPhrase Buffer Manager */ 2238c2ecf20Sopenharmony_ci SOF_PROCESS_CHAN_SELECTOR, /**< Channel Selector */ 2248c2ecf20Sopenharmony_ci SOF_PROCESS_MUX, 2258c2ecf20Sopenharmony_ci SOF_PROCESS_DEMUX, 2268c2ecf20Sopenharmony_ci SOF_PROCESS_DCBLOCK, 2278c2ecf20Sopenharmony_ci SOF_PROCESS_SMART_AMP, /**< Smart Amplifier */ 2288c2ecf20Sopenharmony_ci}; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci/* generic "effect", "codec" or proprietary processing component */ 2318c2ecf20Sopenharmony_cistruct sof_ipc_comp_process { 2328c2ecf20Sopenharmony_ci struct sof_ipc_comp comp; 2338c2ecf20Sopenharmony_ci struct sof_ipc_comp_config config; 2348c2ecf20Sopenharmony_ci uint32_t size; /**< size of bespoke data section in bytes */ 2358c2ecf20Sopenharmony_ci uint32_t type; /**< sof_ipc_process_type */ 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci /* reserved for future use */ 2388c2ecf20Sopenharmony_ci uint32_t reserved[7]; 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci uint8_t data[0]; 2418c2ecf20Sopenharmony_ci} __packed; 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/* frees components, buffers and pipelines 2448c2ecf20Sopenharmony_ci * SOF_IPC_TPLG_COMP_FREE, SOF_IPC_TPLG_PIPE_FREE, SOF_IPC_TPLG_BUFFER_FREE 2458c2ecf20Sopenharmony_ci */ 2468c2ecf20Sopenharmony_cistruct sof_ipc_free { 2478c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 2488c2ecf20Sopenharmony_ci uint32_t id; 2498c2ecf20Sopenharmony_ci} __packed; 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_cistruct sof_ipc_comp_reply { 2528c2ecf20Sopenharmony_ci struct sof_ipc_reply rhdr; 2538c2ecf20Sopenharmony_ci uint32_t id; 2548c2ecf20Sopenharmony_ci uint32_t offset; 2558c2ecf20Sopenharmony_ci} __packed; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci/* 2588c2ecf20Sopenharmony_ci * Pipeline 2598c2ecf20Sopenharmony_ci */ 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci/** \brief Types of pipeline scheduling time domains */ 2628c2ecf20Sopenharmony_cienum sof_ipc_pipe_sched_time_domain { 2638c2ecf20Sopenharmony_ci SOF_TIME_DOMAIN_DMA = 0, /**< DMA interrupt */ 2648c2ecf20Sopenharmony_ci SOF_TIME_DOMAIN_TIMER, /**< Timer interrupt */ 2658c2ecf20Sopenharmony_ci}; 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci/* new pipeline - SOF_IPC_TPLG_PIPE_NEW */ 2688c2ecf20Sopenharmony_cistruct sof_ipc_pipe_new { 2698c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 2708c2ecf20Sopenharmony_ci uint32_t comp_id; /**< component id for pipeline */ 2718c2ecf20Sopenharmony_ci uint32_t pipeline_id; /**< pipeline id */ 2728c2ecf20Sopenharmony_ci uint32_t sched_id; /**< Scheduling component id */ 2738c2ecf20Sopenharmony_ci uint32_t core; /**< core we run on */ 2748c2ecf20Sopenharmony_ci uint32_t period; /**< execution period in us*/ 2758c2ecf20Sopenharmony_ci uint32_t priority; /**< priority level 0 (low) to 10 (max) */ 2768c2ecf20Sopenharmony_ci uint32_t period_mips; /**< worst case instruction count per period */ 2778c2ecf20Sopenharmony_ci uint32_t frames_per_sched;/**< output frames of pipeline, 0 is variable */ 2788c2ecf20Sopenharmony_ci uint32_t xrun_limit_usecs; /**< report xruns greater than limit */ 2798c2ecf20Sopenharmony_ci uint32_t time_domain; /**< scheduling time domain */ 2808c2ecf20Sopenharmony_ci} __packed; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci/* pipeline construction complete - SOF_IPC_TPLG_PIPE_COMPLETE */ 2838c2ecf20Sopenharmony_cistruct sof_ipc_pipe_ready { 2848c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 2858c2ecf20Sopenharmony_ci uint32_t comp_id; 2868c2ecf20Sopenharmony_ci} __packed; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_cistruct sof_ipc_pipe_free { 2898c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 2908c2ecf20Sopenharmony_ci uint32_t comp_id; 2918c2ecf20Sopenharmony_ci} __packed; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci/* connect two components in pipeline - SOF_IPC_TPLG_COMP_CONNECT */ 2948c2ecf20Sopenharmony_cistruct sof_ipc_pipe_comp_connect { 2958c2ecf20Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 2968c2ecf20Sopenharmony_ci uint32_t source_id; 2978c2ecf20Sopenharmony_ci uint32_t sink_id; 2988c2ecf20Sopenharmony_ci} __packed; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci/* external events */ 3018c2ecf20Sopenharmony_cienum sof_event_types { 3028c2ecf20Sopenharmony_ci SOF_EVENT_NONE = 0, 3038c2ecf20Sopenharmony_ci SOF_KEYWORD_DETECT_DAPM_EVENT, 3048c2ecf20Sopenharmony_ci}; 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci/* extended data struct for UUID components */ 3078c2ecf20Sopenharmony_cistruct sof_ipc_comp_ext { 3088c2ecf20Sopenharmony_ci uint8_t uuid[SOF_UUID_SIZE]; 3098c2ecf20Sopenharmony_ci} __packed; 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci#endif 312