brintos

brintos / linux-shallow public Read only

0
0
Text · 14.7 KiB · f4dc499 Raw
483 lines · c
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 or4 * redistributing this file, you may do so under either license.5 *6 * Copyright(c) 2022 Intel Corporation7 */8 9#ifndef __INCLUDE_SOUND_SOF_IPC4_TOPOLOGY_H__10#define __INCLUDE_SOUND_SOF_IPC4_TOPOLOGY_H__11 12#include <sound/sof/ipc4/header.h>13 14#define SOF_IPC4_FW_PAGE_SIZE BIT(12)15#define SOF_IPC4_FW_PAGE(x) ((((x) + BIT(12) - 1) & ~(BIT(12) - 1)) >> 12)16#define SOF_IPC4_FW_ROUNDUP(x) (((x) + BIT(6) - 1) & (~(BIT(6) - 1)))17 18#define SOF_IPC4_MODULE_LOAD_TYPE		GENMASK(3, 0)19#define SOF_IPC4_MODULE_AUTO_START		BIT(4)20/*21 * Two module schedule domains in fw :22 * LL domain - Low latency domain23 * DP domain - Data processing domain24 * The LL setting should be equal to !DP setting25 */26#define SOF_IPC4_MODULE_LL		BIT(5)27#define SOF_IPC4_MODULE_DP		BIT(6)28#define SOF_IPC4_MODULE_LIB_CODE		BIT(7)29#define SOF_IPC4_MODULE_INIT_CONFIG_MASK	GENMASK(11, 8)30 31#define SOF_IPC4_MODULE_INIT_CONFIG_TYPE_BASE_CFG		032#define SOF_IPC4_MODULE_INIT_CONFIG_TYPE_BASE_CFG_WITH_EXT	133 34#define SOF_IPC4_MODULE_INSTANCE_LIST_ITEM_SIZE 1235#define SOF_IPC4_PIPELINE_OBJECT_SIZE 44836#define SOF_IPC4_DATA_QUEUE_OBJECT_SIZE 12837#define SOF_IPC4_LL_TASK_OBJECT_SIZE 7238#define SOF_IPC4_DP_TASK_OBJECT_SIZE 10439#define SOF_IPC4_DP_TASK_LIST_SIZE (12 + 8)40#define SOF_IPC4_LL_TASK_LIST_ITEM_SIZE 1241#define SOF_IPC4_FW_MAX_PAGE_COUNT 2042#define SOF_IPC4_FW_MAX_QUEUE_COUNT 843 44/* Node index and mask applicable for host copier and ALH/HDA type DAI copiers */45#define SOF_IPC4_NODE_INDEX_MASK	0xFF46#define SOF_IPC4_NODE_INDEX(x)	((x) & SOF_IPC4_NODE_INDEX_MASK)47#define SOF_IPC4_NODE_TYPE(x)  ((x) << 8)48#define SOF_IPC4_GET_NODE_TYPE(node_id) ((node_id) >> 8)49 50/* Node ID for SSP type DAI copiers */51#define SOF_IPC4_NODE_INDEX_INTEL_SSP(x) (((x) & 0xf) << 4)52 53/* Node ID for DMIC type DAI copiers */54#define SOF_IPC4_NODE_INDEX_INTEL_DMIC(x) ((x) & 0x7)55 56#define SOF_IPC4_GAIN_ALL_CHANNELS_MASK 0xffffffff57#define SOF_IPC4_VOL_ZERO_DB	0x7fffffff58 59#define SOF_IPC4_DMA_DEVICE_MAX_COUNT 1660 61#define SOF_IPC4_INVALID_NODE_ID	0xffffffff62 63/* FW requires minimum 2ms DMA buffer size */64#define SOF_IPC4_MIN_DMA_BUFFER_SIZE	265 66/*67 * The base of multi-gateways. Multi-gateways addressing starts from68 * ALH_MULTI_GTW_BASE and there are ALH_MULTI_GTW_COUNT multi-sources69 * and ALH_MULTI_GTW_COUNT multi-sinks available.70 * Addressing is continuous from ALH_MULTI_GTW_BASE to71 * ALH_MULTI_GTW_BASE + ALH_MULTI_GTW_COUNT - 1.72 */73#define ALH_MULTI_GTW_BASE	0x5074/* A magic number from FW */75#define ALH_MULTI_GTW_COUNT	876 77enum sof_ipc4_copier_module_config_params {78/*79 * Use LARGE_CONFIG_SET to initialize timestamp event. Ipc mailbox must80 * contain properly built CopierConfigTimestampInitData struct.81 */82	SOF_IPC4_COPIER_MODULE_CFG_PARAM_TIMESTAMP_INIT = 1,83/*84 * Use LARGE_CONFIG_SET to initialize copier sink. Ipc mailbox must contain85 * properly built CopierConfigSetSinkFormat struct.86 */87	SOF_IPC4_COPIER_MODULE_CFG_PARAM_SET_SINK_FORMAT,88/*89 * Use LARGE_CONFIG_SET to initialize and enable on Copier data segment90 * event. Ipc mailbox must contain properly built DataSegmentEnabled struct.91 */92	SOF_IPC4_COPIER_MODULE_CFG_PARAM_DATA_SEGMENT_ENABLED,93/*94 * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non95 * HD-A gateways.96 */97	SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING,98/*99 * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non100 * HD-A gateways and corresponding total processed data101 */102	SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING_EXTENDED,103/*104 * Use LARGE_CONFIG_SET to setup attenuation on output pins. Data is just uint32_t.105 * note Config is only allowed when output pin is set up for 32bit and source106 * is connected to Gateway107 */108	SOF_IPC4_COPIER_MODULE_CFG_ATTENUATION,109};110 111struct sof_ipc4_copier_config_set_sink_format {112/* Id of sink */113	u32 sink_id;114/*115 * Input format used by the source116 * attention must be the same as present if already initialized.117 */118	struct sof_ipc4_audio_format source_fmt;119/* Output format used by the sink */120	struct sof_ipc4_audio_format sink_fmt;121} __packed __aligned(4);122 123/**124 * struct sof_ipc4_pipeline - pipeline config data125 * @priority: Priority of this pipeline126 * @lp_mode: Low power mode127 * @mem_usage: Memory usage128 * @core_id: Target core for the pipeline129 * @state: Pipeline state130 * @use_chain_dma: flag to indicate if the firmware shall use chained DMA131 * @msg: message structure for pipeline132 * @skip_during_fe_trigger: skip triggering this pipeline during the FE DAI trigger133 */134struct sof_ipc4_pipeline {135	uint32_t priority;136	uint32_t lp_mode;137	uint32_t mem_usage;138	uint32_t core_id;139	int state;140	bool use_chain_dma;141	struct sof_ipc4_msg msg;142	bool skip_during_fe_trigger;143};144 145/**146 * struct sof_ipc4_multi_pipeline_data - multi pipeline trigger IPC data147 * @count: Number of pipelines to be triggered148 * @pipeline_instance_ids: Flexible array of IDs of the pipelines to be triggered149 */150struct ipc4_pipeline_set_state_data {151	u32 count;152	DECLARE_FLEX_ARRAY(u32, pipeline_instance_ids);153} __packed;154 155/**156 * struct sof_ipc4_pin_format - Module pin format157 * @pin_index: pin index158 * @buffer_size: buffer size in bytes159 * @audio_fmt: audio format for the pin160 *161 * This structure can be used for both output or input pins and the pin_index is relative to the162 * pin type i.e output/input pin163 */164struct sof_ipc4_pin_format {165	u32 pin_index;166	u32 buffer_size;167	struct sof_ipc4_audio_format audio_fmt;168};169 170/**171 * struct sof_ipc4_available_audio_format - Available audio formats172 * @output_pin_fmts: Available output pin formats173 * @input_pin_fmts: Available input pin formats174 * @num_input_formats: Number of input pin formats175 * @num_output_formats: Number of output pin formats176 */177struct sof_ipc4_available_audio_format {178	struct sof_ipc4_pin_format *output_pin_fmts;179	struct sof_ipc4_pin_format *input_pin_fmts;180	u32 num_input_formats;181	u32 num_output_formats;182};183 184/**185 * struct sof_copier_gateway_cfg - IPC gateway configuration186 * @node_id: ID of Gateway Node187 * @dma_buffer_size: Preferred Gateway DMA buffer size (in bytes)188 * @config_length: Length of gateway node configuration blob specified in #config_data189 * config_data: Gateway node configuration blob190 */191struct sof_copier_gateway_cfg {192	uint32_t node_id;193	uint32_t dma_buffer_size;194	uint32_t config_length;195	uint32_t config_data[];196};197 198/**199 * struct sof_ipc4_copier_data - IPC data for copier200 * @base_config: Base configuration including input audio format201 * @out_format: Output audio format202 * @copier_feature_mask: Copier feature mask203 * @gtw_cfg: Gateway configuration204 */205struct sof_ipc4_copier_data {206	struct sof_ipc4_base_module_cfg base_config;207	struct sof_ipc4_audio_format out_format;208	uint32_t copier_feature_mask;209	struct sof_copier_gateway_cfg gtw_cfg;210};211 212/**213 * struct sof_ipc4_gtw_attributes: Gateway attributes214 * @lp_buffer_alloc: Gateway data requested in low power memory215 * @alloc_from_reg_file: Gateway data requested in register file memory216 * @rsvd: reserved for future use217 */218struct sof_ipc4_gtw_attributes {219	uint32_t lp_buffer_alloc : 1;220	uint32_t alloc_from_reg_file : 1;221	uint32_t rsvd : 30;222};223 224/**225 * struct sof_ipc4_dma_device_stream_ch_map: abstract representation of226 * channel mapping to DMAs227 * @device: representation of hardware device address or FIFO228 * @channel_mask: channels handled by @device. Channels are expected to be229 * contiguous230 */231struct sof_ipc4_dma_device_stream_ch_map {232	uint32_t device;233	uint32_t channel_mask;234};235 236/**237 * struct sof_ipc4_dma_stream_ch_map: DMA configuration data238 * @device_count: Number valid items in mapping array239 * @mapping: device address and channel mask240 */241struct sof_ipc4_dma_stream_ch_map {242	uint32_t device_count;243	struct sof_ipc4_dma_device_stream_ch_map mapping[SOF_IPC4_DMA_DEVICE_MAX_COUNT];244} __packed;245 246#define SOF_IPC4_DMA_METHOD_HDA   1247#define SOF_IPC4_DMA_METHOD_GPDMA 2 /* defined for consistency but not used */248 249/**250 * struct sof_ipc4_dma_config: DMA configuration251 * @dma_method: HDAudio or GPDMA252 * @pre_allocated_by_host: 1 if host driver allocates DMA channels, 0 otherwise253 * @dma_channel_id: for HDaudio defined as @stream_id - 1254 * @stream_id: HDaudio stream tag255 * @dma_stream_channel_map: array of device/channel mappings256 * @dma_priv_config_size: currently not used257 * @dma_priv_config: currently not used258 */259struct sof_ipc4_dma_config {260	uint8_t dma_method;261	uint8_t pre_allocated_by_host;262	uint16_t rsvd;263	uint32_t dma_channel_id;264	uint32_t stream_id;265	struct sof_ipc4_dma_stream_ch_map dma_stream_channel_map;266	uint32_t dma_priv_config_size;267	uint8_t dma_priv_config[];268} __packed;269 270#define SOF_IPC4_GTW_DMA_CONFIG_ID 0x1000271 272/**273 * struct sof_ipc4_dma_config: DMA configuration274 * @type: set to SOF_IPC4_GTW_DMA_CONFIG_ID275 * @length: sizeof(struct sof_ipc4_dma_config) + dma_config.dma_priv_config_size276 * @dma_config: actual DMA configuration277 */278struct sof_ipc4_dma_config_tlv {279	uint32_t type;280	uint32_t length;281	struct sof_ipc4_dma_config dma_config;282} __packed;283 284/** struct sof_ipc4_alh_configuration_blob: ALH blob285 * @gw_attr: Gateway attributes286 * @alh_cfg: ALH configuration data287 */288struct sof_ipc4_alh_configuration_blob {289	struct sof_ipc4_gtw_attributes gw_attr;290	struct sof_ipc4_dma_stream_ch_map alh_cfg;291};292 293/**294 * struct sof_ipc4_copier - copier config data295 * @data: IPC copier data296 * @copier_config: Copier + blob297 * @ipc_config_size: Size of copier_config298 * @available_fmt: Available audio format299 * @frame_fmt: frame format300 * @msg: message structure for copier301 * @gtw_attr: Gateway attributes for copier blob302 * @dai_type: DAI type303 * @dai_index: DAI index304 * @dma_config_tlv: DMA configuration305 */306struct sof_ipc4_copier {307	struct sof_ipc4_copier_data data;308	u32 *copier_config;309	uint32_t ipc_config_size;310	void *ipc_config_data;311	struct sof_ipc4_available_audio_format available_fmt;312	u32 frame_fmt;313	struct sof_ipc4_msg msg;314	struct sof_ipc4_gtw_attributes *gtw_attr;315	u32 dai_type;316	int dai_index;317	struct sof_ipc4_dma_config_tlv dma_config_tlv[SOF_IPC4_DMA_DEVICE_MAX_COUNT];318};319 320/**321 * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data322 * @channel: Channel ID323 * @value: Value associated with @channel324 */325struct sof_ipc4_ctrl_value_chan {326	u32 channel;327	u32 value;328};329 330/**331 * struct sof_ipc4_control_data - IPC data for kcontrol IO332 * @msg: message structure for kcontrol IO333 * @index: pipeline ID334 * @chanv: channel ID and value array used by volume type controls335 * @data: data for binary kcontrols336 */337struct sof_ipc4_control_data {338	struct sof_ipc4_msg msg;339	int index;340 341	union {342		DECLARE_FLEX_ARRAY(struct sof_ipc4_ctrl_value_chan, chanv);343		DECLARE_FLEX_ARRAY(struct sof_abi_hdr, data);344	};345};346 347#define SOF_IPC4_SWITCH_CONTROL_PARAM_ID	200348#define SOF_IPC4_ENUM_CONTROL_PARAM_ID		201349 350/**351 * struct sof_ipc4_control_msg_payload - IPC payload for kcontrol parameters352 * @id: unique id of the control353 * @num_elems: Number of elements in the chanv array354 * @reserved: reserved for future use, must be set to 0355 * @chanv: channel ID and value array356 */357struct sof_ipc4_control_msg_payload {358	uint16_t id;359	uint16_t num_elems;360	uint32_t reserved[4];361	DECLARE_FLEX_ARRAY(struct sof_ipc4_ctrl_value_chan, chanv);362} __packed;363 364/**365 * struct sof_ipc4_gain_params - IPC gain parameters366 * @channels: Channels367 * @init_val: Initial value368 * @curve_type: Curve type369 * @reserved: reserved for future use370 * @curve_duration_l: Curve duration low part371 * @curve_duration_h: Curve duration high part372 */373struct sof_ipc4_gain_params {374	uint32_t channels;375	uint32_t init_val;376	uint32_t curve_type;377	uint32_t reserved;378	uint32_t curve_duration_l;379	uint32_t curve_duration_h;380} __packed __aligned(4);381 382/**383 * struct sof_ipc4_gain_data - IPC gain init blob384 * @base_config: IPC base config data385 * @params: Initial parameters for the gain module386 */387struct sof_ipc4_gain_data {388	struct sof_ipc4_base_module_cfg base_config;389	struct sof_ipc4_gain_params params;390} __packed __aligned(4);391 392/**393 * struct sof_ipc4_gain - gain config data394 * @data: IPC gain blob395 * @available_fmt: Available audio format396 * @msg: message structure for gain397 */398struct sof_ipc4_gain {399	struct sof_ipc4_gain_data data;400	struct sof_ipc4_available_audio_format available_fmt;401	struct sof_ipc4_msg msg;402};403 404/**405 * struct sof_ipc4_mixer - mixer config data406 * @base_config: IPC base config data407 * @available_fmt: Available audio format408 * @msg: IPC4 message struct containing header and data info409 */410struct sof_ipc4_mixer {411	struct sof_ipc4_base_module_cfg base_config;412	struct sof_ipc4_available_audio_format available_fmt;413	struct sof_ipc4_msg msg;414};415 416/*417 * struct sof_ipc4_src_data - IPC data for SRC418 * @base_config: IPC base config data419 * @sink_rate: Output rate for sink module420 */421struct sof_ipc4_src_data {422	struct sof_ipc4_base_module_cfg base_config;423	uint32_t sink_rate;424} __packed __aligned(4);425 426/**427 * struct sof_ipc4_src - SRC config data428 * @data: IPC base config data429 * @available_fmt: Available audio format430 * @msg: IPC4 message struct containing header and data info431 */432struct sof_ipc4_src {433	struct sof_ipc4_src_data data;434	struct sof_ipc4_available_audio_format available_fmt;435	struct sof_ipc4_msg msg;436};437 438/**439 * struct sof_ipc4_base_module_cfg_ext - base module config extension containing the pin format440 * information for the module. Both @num_input_pin_fmts and @num_output_pin_fmts cannot be 0 for a441 * module.442 * @num_input_pin_fmts: number of input pin formats in the @pin_formats array443 * @num_output_pin_fmts: number of output pin formats in the @pin_formats array444 * @reserved: reserved for future use445 * @pin_formats: flexible array consisting of @num_input_pin_fmts input pin format items followed446 *		 by @num_output_pin_fmts output pin format items447 */448struct sof_ipc4_base_module_cfg_ext {449	u16 num_input_pin_fmts;450	u16 num_output_pin_fmts;451	u8 reserved[12];452	DECLARE_FLEX_ARRAY(struct sof_ipc4_pin_format, pin_formats);453} __packed;454 455/**456 * struct sof_ipc4_process - process config data457 * @base_config: IPC base config data458 * @base_config_ext: Base config extension data for module init459 * @output_format: Output audio format460 * @available_fmt: Available audio format461 * @ipc_config_data: Process module config data462 * @ipc_config_size: Size of process module config data463 * @msg: IPC4 message struct containing header and data info464 * @base_config_ext_size: Size of the base config extension data in bytes465 * @init_config: Module init config type (SOF_IPC4_MODULE_INIT_CONFIG_TYPE_*)466 */467struct sof_ipc4_process {468	struct sof_ipc4_base_module_cfg base_config;469	struct sof_ipc4_base_module_cfg_ext *base_config_ext;470	struct sof_ipc4_audio_format output_format;471	struct sof_ipc4_available_audio_format available_fmt;472	void *ipc_config_data;473	uint32_t ipc_config_size;474	struct sof_ipc4_msg msg;475	u32 base_config_ext_size;476	u32 init_config;477};478 479bool sof_ipc4_copier_is_single_bitdepth(struct snd_sof_dev *sdev,480					struct sof_ipc4_pin_format *pin_fmts,481					u32 pin_fmts_size);482#endif483