162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 462306a36Sopenharmony_ci * redistributing this file, you may do so under either license. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright(c) 2022 Intel Corporation. All rights reserved. 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef __INCLUDE_SOUND_SOF_IPC4_HEADER_H__ 1062306a36Sopenharmony_ci#define __INCLUDE_SOUND_SOF_IPC4_HEADER_H__ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/types.h> 1362306a36Sopenharmony_ci#include <uapi/sound/sof/abi.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* maximum message size for mailbox Tx/Rx */ 1662306a36Sopenharmony_ci#define SOF_IPC4_MSG_MAX_SIZE 4096 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/** \addtogroup sof_uapi uAPI 1962306a36Sopenharmony_ci * SOF uAPI specification. 2062306a36Sopenharmony_ci * @{ 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/** 2462306a36Sopenharmony_ci * struct sof_ipc4_msg - Placeholder of an IPC4 message 2562306a36Sopenharmony_ci * @header_u64: IPC4 header as single u64 number 2662306a36Sopenharmony_ci * @primary: Primary, mandatory part of the header 2762306a36Sopenharmony_ci * @extension: Extended part of the header, if not used it should be 2862306a36Sopenharmony_ci * set to 0 2962306a36Sopenharmony_ci * @data_size: Size of data in bytes pointed by @data_ptr 3062306a36Sopenharmony_ci * @data_ptr: Pointer to the optional payload of a message 3162306a36Sopenharmony_ci */ 3262306a36Sopenharmony_cistruct sof_ipc4_msg { 3362306a36Sopenharmony_ci union { 3462306a36Sopenharmony_ci u64 header_u64; 3562306a36Sopenharmony_ci struct { 3662306a36Sopenharmony_ci u32 primary; 3762306a36Sopenharmony_ci u32 extension; 3862306a36Sopenharmony_ci }; 3962306a36Sopenharmony_ci }; 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci size_t data_size; 4262306a36Sopenharmony_ci void *data_ptr; 4362306a36Sopenharmony_ci}; 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/** 4662306a36Sopenharmony_ci * struct sof_ipc4_tuple - Generic type/ID and parameter tuple 4762306a36Sopenharmony_ci * @type: type/ID 4862306a36Sopenharmony_ci * @size: size of the @value array in bytes 4962306a36Sopenharmony_ci * @value: value for the given type 5062306a36Sopenharmony_ci */ 5162306a36Sopenharmony_cistruct sof_ipc4_tuple { 5262306a36Sopenharmony_ci uint32_t type; 5362306a36Sopenharmony_ci uint32_t size; 5462306a36Sopenharmony_ci uint32_t value[]; 5562306a36Sopenharmony_ci} __packed; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci/* 5862306a36Sopenharmony_ci * IPC4 messages have two 32 bit identifier made up as follows :- 5962306a36Sopenharmony_ci * 6062306a36Sopenharmony_ci * header - msg type, msg id, msg direction ... 6162306a36Sopenharmony_ci * extension - extra params such as msg data size in mailbox 6262306a36Sopenharmony_ci * 6362306a36Sopenharmony_ci * These are sent at the start of the IPC message in the mailbox. Messages 6462306a36Sopenharmony_ci * should not be sent in the doorbell (special exceptions for firmware). 6562306a36Sopenharmony_ci */ 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/* 6862306a36Sopenharmony_ci * IPC4 primary header bit allocation for messages 6962306a36Sopenharmony_ci * bit 0-23: message type specific 7062306a36Sopenharmony_ci * bit 24-28: type: enum sof_ipc4_global_msg if target is SOF_IPC4_FW_GEN_MSG 7162306a36Sopenharmony_ci * enum sof_ipc4_module_type if target is SOF_IPC4_MODULE_MSG 7262306a36Sopenharmony_ci * bit 29: response - sof_ipc4_msg_dir 7362306a36Sopenharmony_ci * bit 30: target - enum sof_ipc4_msg_target 7462306a36Sopenharmony_ci * bit 31: reserved, unused 7562306a36Sopenharmony_ci */ 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci/* Value of target field - must fit into 1 bit */ 7862306a36Sopenharmony_cienum sof_ipc4_msg_target { 7962306a36Sopenharmony_ci /* Global FW message */ 8062306a36Sopenharmony_ci SOF_IPC4_FW_GEN_MSG, 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci /* Module message */ 8362306a36Sopenharmony_ci SOF_IPC4_MODULE_MSG 8462306a36Sopenharmony_ci}; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci/* Value of type field - must fit into 5 bits */ 8762306a36Sopenharmony_cienum sof_ipc4_global_msg { 8862306a36Sopenharmony_ci SOF_IPC4_GLB_BOOT_CONFIG, 8962306a36Sopenharmony_ci SOF_IPC4_GLB_ROM_CONTROL, 9062306a36Sopenharmony_ci SOF_IPC4_GLB_IPCGATEWAY_CMD, 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci /* 3 .. 12: RESERVED - do not use */ 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci SOF_IPC4_GLB_PERF_MEASUREMENTS_CMD = 13, 9562306a36Sopenharmony_ci SOF_IPC4_GLB_CHAIN_DMA, 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci SOF_IPC4_GLB_LOAD_MULTIPLE_MODULES, 9862306a36Sopenharmony_ci SOF_IPC4_GLB_UNLOAD_MULTIPLE_MODULES, 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci /* pipeline settings */ 10162306a36Sopenharmony_ci SOF_IPC4_GLB_CREATE_PIPELINE, 10262306a36Sopenharmony_ci SOF_IPC4_GLB_DELETE_PIPELINE, 10362306a36Sopenharmony_ci SOF_IPC4_GLB_SET_PIPELINE_STATE, 10462306a36Sopenharmony_ci SOF_IPC4_GLB_GET_PIPELINE_STATE, 10562306a36Sopenharmony_ci SOF_IPC4_GLB_GET_PIPELINE_CONTEXT_SIZE, 10662306a36Sopenharmony_ci SOF_IPC4_GLB_SAVE_PIPELINE, 10762306a36Sopenharmony_ci SOF_IPC4_GLB_RESTORE_PIPELINE, 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci /* Loads library (using Code Load or HD/A Host Output DMA) */ 11062306a36Sopenharmony_ci SOF_IPC4_GLB_LOAD_LIBRARY, 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci /* 25: RESERVED - do not use */ 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci SOF_IPC4_GLB_INTERNAL_MESSAGE = 26, 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci /* Notification (FW to SW driver) */ 11762306a36Sopenharmony_ci SOF_IPC4_GLB_NOTIFICATION, 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci /* 28 .. 31: RESERVED - do not use */ 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci SOF_IPC4_GLB_TYPE_LAST, 12262306a36Sopenharmony_ci}; 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci/* Value of response field - must fit into 1 bit */ 12562306a36Sopenharmony_cienum sof_ipc4_msg_dir { 12662306a36Sopenharmony_ci SOF_IPC4_MSG_REQUEST, 12762306a36Sopenharmony_ci SOF_IPC4_MSG_REPLY, 12862306a36Sopenharmony_ci}; 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_cienum sof_ipc4_pipeline_state { 13162306a36Sopenharmony_ci SOF_IPC4_PIPE_INVALID_STATE, 13262306a36Sopenharmony_ci SOF_IPC4_PIPE_UNINITIALIZED, 13362306a36Sopenharmony_ci SOF_IPC4_PIPE_RESET, 13462306a36Sopenharmony_ci SOF_IPC4_PIPE_PAUSED, 13562306a36Sopenharmony_ci SOF_IPC4_PIPE_RUNNING, 13662306a36Sopenharmony_ci SOF_IPC4_PIPE_EOS 13762306a36Sopenharmony_ci}; 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci/* Generic message fields (bit 24-30) */ 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci/* encoded to header's msg_tgt field */ 14262306a36Sopenharmony_ci#define SOF_IPC4_MSG_TARGET_SHIFT 30 14362306a36Sopenharmony_ci#define SOF_IPC4_MSG_TARGET_MASK BIT(30) 14462306a36Sopenharmony_ci#define SOF_IPC4_MSG_TARGET(x) ((x) << SOF_IPC4_MSG_TARGET_SHIFT) 14562306a36Sopenharmony_ci#define SOF_IPC4_MSG_IS_MODULE_MSG(x) ((x) & SOF_IPC4_MSG_TARGET_MASK ? 1 : 0) 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci/* encoded to header's rsp field */ 14862306a36Sopenharmony_ci#define SOF_IPC4_MSG_DIR_SHIFT 29 14962306a36Sopenharmony_ci#define SOF_IPC4_MSG_DIR_MASK BIT(29) 15062306a36Sopenharmony_ci#define SOF_IPC4_MSG_DIR(x) ((x) << SOF_IPC4_MSG_DIR_SHIFT) 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci/* encoded to header's type field */ 15362306a36Sopenharmony_ci#define SOF_IPC4_MSG_TYPE_SHIFT 24 15462306a36Sopenharmony_ci#define SOF_IPC4_MSG_TYPE_MASK GENMASK(28, 24) 15562306a36Sopenharmony_ci#define SOF_IPC4_MSG_TYPE_SET(x) (((x) << SOF_IPC4_MSG_TYPE_SHIFT) & \ 15662306a36Sopenharmony_ci SOF_IPC4_MSG_TYPE_MASK) 15762306a36Sopenharmony_ci#define SOF_IPC4_MSG_TYPE_GET(x) (((x) & SOF_IPC4_MSG_TYPE_MASK) >> \ 15862306a36Sopenharmony_ci SOF_IPC4_MSG_TYPE_SHIFT) 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci/* Global message type specific field definitions */ 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci/* pipeline creation ipc msg */ 16362306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_INSTANCE_SHIFT 16 16462306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_INSTANCE_MASK GENMASK(23, 16) 16562306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_INSTANCE_ID(x) ((x) << SOF_IPC4_GLB_PIPE_INSTANCE_SHIFT) 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_PRIORITY_SHIFT 11 16862306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_PRIORITY_MASK GENMASK(15, 11) 16962306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_PRIORITY(x) ((x) << SOF_IPC4_GLB_PIPE_PRIORITY_SHIFT) 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_MEM_SIZE_SHIFT 0 17262306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_MEM_SIZE_MASK GENMASK(10, 0) 17362306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_MEM_SIZE(x) ((x) << SOF_IPC4_GLB_PIPE_MEM_SIZE_SHIFT) 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_EXT_LP_SHIFT 0 17662306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_EXT_LP_MASK BIT(0) 17762306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_EXT_LP(x) ((x) << SOF_IPC4_GLB_PIPE_EXT_LP_SHIFT) 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_EXT_CORE_ID_SHIFT 20 18062306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_EXT_CORE_ID_MASK GENMASK(23, 20) 18162306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_EXT_CORE_ID(x) ((x) << SOF_IPC4_GLB_PIPE_EXT_CORE_ID_SHIFT) 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci/* pipeline set state ipc msg */ 18462306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_STATE_ID_SHIFT 16 18562306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_STATE_ID_MASK GENMASK(23, 16) 18662306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_STATE_ID(x) ((x) << SOF_IPC4_GLB_PIPE_STATE_ID_SHIFT) 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_STATE_SHIFT 0 18962306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_STATE_MASK GENMASK(15, 0) 19062306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_STATE(x) ((x) << SOF_IPC4_GLB_PIPE_STATE_SHIFT) 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci/* pipeline set state IPC msg extension */ 19362306a36Sopenharmony_ci#define SOF_IPC4_GLB_PIPE_STATE_EXT_MULTI BIT(0) 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci/* load library ipc msg */ 19662306a36Sopenharmony_ci#define SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID_SHIFT 16 19762306a36Sopenharmony_ci#define SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID(x) ((x) << SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID_SHIFT) 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci/* chain dma ipc message */ 20062306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_SHIFT 0 20162306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_MASK GENMASK(4, 0) 20262306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID(x) (((x) << SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_SHIFT) & \ 20362306a36Sopenharmony_ci SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_MASK) 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_SHIFT 8 20662306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_MASK GENMASK(12, 8) 20762306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID(x) (((x) << SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_SHIFT) & \ 20862306a36Sopenharmony_ci SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_MASK) 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_SHIFT 16 21162306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_MASK BIT(16) 21262306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE(x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_SHIFT) 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE_SHIFT 17 21562306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE_MASK BIT(17) 21662306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE(x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_ENABLE_SHIFT) 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_SCS_SHIFT 18 21962306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_SCS_MASK BIT(18) 22062306a36Sopenharmony_ci#define SOF_IPC4_GLB_CHAIN_DMA_SCS(x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_SCS_SHIFT) 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_SHIFT 0 22362306a36Sopenharmony_ci#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_MASK GENMASK(24, 0) 22462306a36Sopenharmony_ci#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE(x) (((x) << \ 22562306a36Sopenharmony_ci SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_SHIFT) & \ 22662306a36Sopenharmony_ci SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_MASK) 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_cienum sof_ipc4_channel_config { 22962306a36Sopenharmony_ci /* one channel only. */ 23062306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_MONO, 23162306a36Sopenharmony_ci /* L & R. */ 23262306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_STEREO, 23362306a36Sopenharmony_ci /* L, R & LFE; PCM only. */ 23462306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_2_POINT_1, 23562306a36Sopenharmony_ci /* L, C & R; MP3 & AAC only. */ 23662306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_3_POINT_0, 23762306a36Sopenharmony_ci /* L, C, R & LFE; PCM only. */ 23862306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_3_POINT_1, 23962306a36Sopenharmony_ci /* L, R, Ls & Rs; PCM only. */ 24062306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_QUATRO, 24162306a36Sopenharmony_ci /* L, C, R & Cs; MP3 & AAC only. */ 24262306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_4_POINT_0, 24362306a36Sopenharmony_ci /* L, C, R, Ls & Rs. */ 24462306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_5_POINT_0, 24562306a36Sopenharmony_ci /* L, C, R, Ls, Rs & LFE. */ 24662306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_5_POINT_1, 24762306a36Sopenharmony_ci /* one channel replicated in two. */ 24862306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_DUAL_MONO, 24962306a36Sopenharmony_ci /* Stereo (L,R) in 4 slots, 1st stream: [ L, R, -, - ] */ 25062306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_I2S_DUAL_STEREO_0, 25162306a36Sopenharmony_ci /* Stereo (L,R) in 4 slots, 2nd stream: [ -, -, L, R ] */ 25262306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_I2S_DUAL_STEREO_1, 25362306a36Sopenharmony_ci /* L, C, R, Ls, Rs & LFE., LS, RS */ 25462306a36Sopenharmony_ci SOF_IPC4_CHANNEL_CONFIG_7_POINT_1, 25562306a36Sopenharmony_ci}; 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_cienum sof_ipc4_interleaved_style { 25862306a36Sopenharmony_ci SOF_IPC4_CHANNELS_INTERLEAVED, 25962306a36Sopenharmony_ci SOF_IPC4_CHANNELS_NONINTERLEAVED, 26062306a36Sopenharmony_ci}; 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_cienum sof_ipc4_sample_type { 26362306a36Sopenharmony_ci SOF_IPC4_MSB_INTEGER, /* integer with Most Significant Byte first */ 26462306a36Sopenharmony_ci SOF_IPC4_LSB_INTEGER, /* integer with Least Significant Byte first */ 26562306a36Sopenharmony_ci}; 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_cistruct sof_ipc4_audio_format { 26862306a36Sopenharmony_ci uint32_t sampling_frequency; 26962306a36Sopenharmony_ci uint32_t bit_depth; 27062306a36Sopenharmony_ci uint32_t ch_map; 27162306a36Sopenharmony_ci uint32_t ch_cfg; /* sof_ipc4_channel_config */ 27262306a36Sopenharmony_ci uint32_t interleaving_style; 27362306a36Sopenharmony_ci uint32_t fmt_cfg; /* channels_count valid_bit_depth s_type */ 27462306a36Sopenharmony_ci} __packed __aligned(4); 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT_SHIFT 0 27762306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT_MASK GENMASK(7, 0) 27862306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(x) \ 27962306a36Sopenharmony_ci ((x) & SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT_MASK) 28062306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_SHIFT 8 28162306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_MASK GENMASK(15, 8) 28262306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(x) \ 28362306a36Sopenharmony_ci (((x) & SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_MASK) >> \ 28462306a36Sopenharmony_ci SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_SHIFT) 28562306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_SHIFT 16 28662306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_MASK GENMASK(23, 16) 28762306a36Sopenharmony_ci#define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(x) \ 28862306a36Sopenharmony_ci (((x) & SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_MASK) >> \ 28962306a36Sopenharmony_ci SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_SHIFT) 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci/* Module message type specific field definitions */ 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_cienum sof_ipc4_module_type { 29462306a36Sopenharmony_ci SOF_IPC4_MOD_INIT_INSTANCE, 29562306a36Sopenharmony_ci SOF_IPC4_MOD_CONFIG_GET, 29662306a36Sopenharmony_ci SOF_IPC4_MOD_CONFIG_SET, 29762306a36Sopenharmony_ci SOF_IPC4_MOD_LARGE_CONFIG_GET, 29862306a36Sopenharmony_ci SOF_IPC4_MOD_LARGE_CONFIG_SET, 29962306a36Sopenharmony_ci SOF_IPC4_MOD_BIND, 30062306a36Sopenharmony_ci SOF_IPC4_MOD_UNBIND, 30162306a36Sopenharmony_ci SOF_IPC4_MOD_SET_DX, 30262306a36Sopenharmony_ci SOF_IPC4_MOD_SET_D0IX, 30362306a36Sopenharmony_ci SOF_IPC4_MOD_ENTER_MODULE_RESTORE, 30462306a36Sopenharmony_ci SOF_IPC4_MOD_EXIT_MODULE_RESTORE, 30562306a36Sopenharmony_ci SOF_IPC4_MOD_DELETE_INSTANCE, 30662306a36Sopenharmony_ci 30762306a36Sopenharmony_ci SOF_IPC4_MOD_TYPE_LAST, 30862306a36Sopenharmony_ci}; 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_cistruct sof_ipc4_base_module_cfg { 31162306a36Sopenharmony_ci uint32_t cpc; /* the max count of Cycles Per Chunk processing */ 31262306a36Sopenharmony_ci uint32_t ibs; /* input Buffer Size (in bytes) */ 31362306a36Sopenharmony_ci uint32_t obs; /* output Buffer Size (in bytes) */ 31462306a36Sopenharmony_ci uint32_t is_pages; /* number of physical pages used */ 31562306a36Sopenharmony_ci struct sof_ipc4_audio_format audio_fmt; 31662306a36Sopenharmony_ci} __packed __aligned(4); 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_ci/* common module ipc msg */ 31962306a36Sopenharmony_ci#define SOF_IPC4_MOD_INSTANCE_SHIFT 16 32062306a36Sopenharmony_ci#define SOF_IPC4_MOD_INSTANCE_MASK GENMASK(23, 16) 32162306a36Sopenharmony_ci#define SOF_IPC4_MOD_INSTANCE(x) ((x) << SOF_IPC4_MOD_INSTANCE_SHIFT) 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci#define SOF_IPC4_MOD_ID_SHIFT 0 32462306a36Sopenharmony_ci#define SOF_IPC4_MOD_ID_MASK GENMASK(15, 0) 32562306a36Sopenharmony_ci#define SOF_IPC4_MOD_ID(x) ((x) << SOF_IPC4_MOD_ID_SHIFT) 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci/* init module ipc msg */ 32862306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_PARAM_SIZE_SHIFT 0 32962306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_PARAM_SIZE_MASK GENMASK(15, 0) 33062306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_PARAM_SIZE(x) ((x) << SOF_IPC4_MOD_EXT_PARAM_SIZE_SHIFT) 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_PPL_ID_SHIFT 16 33362306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_PPL_ID_MASK GENMASK(23, 16) 33462306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_PPL_ID(x) ((x) << SOF_IPC4_MOD_EXT_PPL_ID_SHIFT) 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_CORE_ID_SHIFT 24 33762306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_CORE_ID_MASK GENMASK(27, 24) 33862306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_CORE_ID(x) ((x) << SOF_IPC4_MOD_EXT_CORE_ID_SHIFT) 33962306a36Sopenharmony_ci 34062306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DOMAIN_SHIFT 28 34162306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DOMAIN_MASK BIT(28) 34262306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DOMAIN(x) ((x) << SOF_IPC4_MOD_EXT_DOMAIN_SHIFT) 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci/* bind/unbind module ipc msg */ 34562306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_ID_SHIFT 0 34662306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_ID_MASK GENMASK(15, 0) 34762306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_ID(x) ((x) << SOF_IPC4_MOD_EXT_DST_MOD_ID_SHIFT) 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE_SHIFT 16 35062306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE_MASK GENMASK(23, 16) 35162306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE(x) ((x) << SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE_SHIFT) 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID_SHIFT 24 35462306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID_MASK GENMASK(26, 24) 35562306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID(x) ((x) << SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID_SHIFT) 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID_SHIFT 27 35862306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID_MASK GENMASK(29, 27) 35962306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID(x) ((x) << SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID_SHIFT) 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ci#define MOD_ENABLE_LOG 6 36262306a36Sopenharmony_ci#define MOD_SYSTEM_TIME 20 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci/* set module large config */ 36562306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_SIZE_SHIFT 0 36662306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_SIZE_MASK GENMASK(19, 0) 36762306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_SIZE(x) ((x) << SOF_IPC4_MOD_EXT_MSG_SIZE_SHIFT) 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_PARAM_ID_SHIFT 20 37062306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_PARAM_ID_MASK GENMASK(27, 20) 37162306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_PARAM_ID(x) ((x) << SOF_IPC4_MOD_EXT_MSG_PARAM_ID_SHIFT) 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK_SHIFT 28 37462306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK_MASK BIT(28) 37562306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK(x) ((x) << SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK_SHIFT) 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK_SHIFT 29 37862306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK_MASK BIT(29) 37962306a36Sopenharmony_ci#define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK(x) ((x) << SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK_SHIFT) 38062306a36Sopenharmony_ci 38162306a36Sopenharmony_ci/* Init instance messagees */ 38262306a36Sopenharmony_ci#define SOF_IPC4_MOD_INIT_BASEFW_MOD_ID 0 38362306a36Sopenharmony_ci#define SOF_IPC4_MOD_INIT_BASEFW_INSTANCE_ID 0 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_cienum sof_ipc4_base_fw_params { 38662306a36Sopenharmony_ci SOF_IPC4_FW_PARAM_ENABLE_LOGS = 6, 38762306a36Sopenharmony_ci SOF_IPC4_FW_PARAM_FW_CONFIG, 38862306a36Sopenharmony_ci SOF_IPC4_FW_PARAM_HW_CONFIG_GET, 38962306a36Sopenharmony_ci SOF_IPC4_FW_PARAM_MODULES_INFO_GET, 39062306a36Sopenharmony_ci SOF_IPC4_FW_PARAM_LIBRARIES_INFO_GET = 16, 39162306a36Sopenharmony_ci SOF_IPC4_FW_PARAM_SYSTEM_TIME = 20, 39262306a36Sopenharmony_ci}; 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_cienum sof_ipc4_fw_config_params { 39562306a36Sopenharmony_ci SOF_IPC4_FW_CFG_FW_VERSION, 39662306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MEMORY_RECLAIMED, 39762306a36Sopenharmony_ci SOF_IPC4_FW_CFG_SLOW_CLOCK_FREQ_HZ, 39862306a36Sopenharmony_ci SOF_IPC4_FW_CFG_FAST_CLOCK_FREQ_HZ, 39962306a36Sopenharmony_ci SOF_IPC4_FW_CFG_DMA_BUFFER_CONFIG, 40062306a36Sopenharmony_ci SOF_IPC4_FW_CFG_ALH_SUPPORT_LEVEL, 40162306a36Sopenharmony_ci SOF_IPC4_FW_CFG_DL_MAILBOX_BYTES, 40262306a36Sopenharmony_ci SOF_IPC4_FW_CFG_UL_MAILBOX_BYTES, 40362306a36Sopenharmony_ci SOF_IPC4_FW_CFG_TRACE_LOG_BYTES, 40462306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MAX_PPL_COUNT, 40562306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MAX_ASTATE_COUNT, 40662306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MAX_MODULE_PIN_COUNT, 40762306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MODULES_COUNT, 40862306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MAX_MOD_INST_COUNT, 40962306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MAX_LL_TASKS_PER_PRI_COUNT, 41062306a36Sopenharmony_ci SOF_IPC4_FW_CFG_LL_PRI_COUNT, 41162306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MAX_DP_TASKS_COUNT, 41262306a36Sopenharmony_ci SOF_IPC4_FW_CFG_MAX_LIBS_COUNT, 41362306a36Sopenharmony_ci SOF_IPC4_FW_CFG_SCHEDULER_CONFIG, 41462306a36Sopenharmony_ci SOF_IPC4_FW_CFG_XTAL_FREQ_HZ, 41562306a36Sopenharmony_ci SOF_IPC4_FW_CFG_CLOCKS_CONFIG, 41662306a36Sopenharmony_ci SOF_IPC4_FW_CFG_RESERVED, 41762306a36Sopenharmony_ci SOF_IPC4_FW_CFG_POWER_GATING_POLICY, 41862306a36Sopenharmony_ci SOF_IPC4_FW_CFG_ASSERT_MODE, 41962306a36Sopenharmony_ci}; 42062306a36Sopenharmony_ci 42162306a36Sopenharmony_cistruct sof_ipc4_fw_version { 42262306a36Sopenharmony_ci uint16_t major; 42362306a36Sopenharmony_ci uint16_t minor; 42462306a36Sopenharmony_ci uint16_t hotfix; 42562306a36Sopenharmony_ci uint16_t build; 42662306a36Sopenharmony_ci} __packed; 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci/* Payload data for SOF_IPC4_MOD_SET_DX */ 42962306a36Sopenharmony_cistruct sof_ipc4_dx_state_info { 43062306a36Sopenharmony_ci /* core(s) to apply the change */ 43162306a36Sopenharmony_ci uint32_t core_mask; 43262306a36Sopenharmony_ci /* core state: 0: put core_id to D3; 1: put core_id to D0 */ 43362306a36Sopenharmony_ci uint32_t dx_mask; 43462306a36Sopenharmony_ci} __packed __aligned(4); 43562306a36Sopenharmony_ci 43662306a36Sopenharmony_ci/* Reply messages */ 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci/* 43962306a36Sopenharmony_ci * IPC4 primary header bit allocation for replies 44062306a36Sopenharmony_ci * bit 0-23: status 44162306a36Sopenharmony_ci * bit 24-28: type: enum sof_ipc4_global_msg if target is SOF_IPC4_FW_GEN_MSG 44262306a36Sopenharmony_ci * enum sof_ipc4_module_type if target is SOF_IPC4_MODULE_MSG 44362306a36Sopenharmony_ci * bit 29: response - sof_ipc4_msg_dir 44462306a36Sopenharmony_ci * bit 30: target - enum sof_ipc4_msg_target 44562306a36Sopenharmony_ci * bit 31: reserved, unused 44662306a36Sopenharmony_ci */ 44762306a36Sopenharmony_ci 44862306a36Sopenharmony_ci#define SOF_IPC4_REPLY_STATUS GENMASK(23, 0) 44962306a36Sopenharmony_ci 45062306a36Sopenharmony_ci/* Notification messages */ 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci/* 45362306a36Sopenharmony_ci * IPC4 primary header bit allocation for notifications 45462306a36Sopenharmony_ci * bit 0-15: notification type specific 45562306a36Sopenharmony_ci * bit 16-23: enum sof_ipc4_notification_type 45662306a36Sopenharmony_ci * bit 24-28: SOF_IPC4_GLB_NOTIFICATION 45762306a36Sopenharmony_ci * bit 29: response - sof_ipc4_msg_dir 45862306a36Sopenharmony_ci * bit 30: target - enum sof_ipc4_msg_target 45962306a36Sopenharmony_ci * bit 31: reserved, unused 46062306a36Sopenharmony_ci */ 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci#define SOF_IPC4_MSG_IS_NOTIFICATION(x) (SOF_IPC4_MSG_TYPE_GET(x) == \ 46362306a36Sopenharmony_ci SOF_IPC4_GLB_NOTIFICATION) 46462306a36Sopenharmony_ci 46562306a36Sopenharmony_ci#define SOF_IPC4_NOTIFICATION_TYPE_SHIFT 16 46662306a36Sopenharmony_ci#define SOF_IPC4_NOTIFICATION_TYPE_MASK GENMASK(23, 16) 46762306a36Sopenharmony_ci#define SOF_IPC4_NOTIFICATION_TYPE_GET(x) (((x) & SOF_IPC4_NOTIFICATION_TYPE_MASK) >> \ 46862306a36Sopenharmony_ci SOF_IPC4_NOTIFICATION_TYPE_SHIFT) 46962306a36Sopenharmony_ci 47062306a36Sopenharmony_ci#define SOF_IPC4_LOG_CORE_SHIFT 12 47162306a36Sopenharmony_ci#define SOF_IPC4_LOG_CORE_MASK GENMASK(15, 12) 47262306a36Sopenharmony_ci#define SOF_IPC4_LOG_CORE_GET(x) (((x) & SOF_IPC4_LOG_CORE_MASK) >> \ 47362306a36Sopenharmony_ci SOF_IPC4_LOG_CORE_SHIFT) 47462306a36Sopenharmony_ci 47562306a36Sopenharmony_ci/* Value of notification type field - must fit into 8 bits */ 47662306a36Sopenharmony_cienum sof_ipc4_notification_type { 47762306a36Sopenharmony_ci /* Phrase detected (notification from WoV module) */ 47862306a36Sopenharmony_ci SOF_IPC4_NOTIFY_PHRASE_DETECTED = 4, 47962306a36Sopenharmony_ci /* Event from a resource (pipeline or module instance) */ 48062306a36Sopenharmony_ci SOF_IPC4_NOTIFY_RESOURCE_EVENT, 48162306a36Sopenharmony_ci /* Debug log buffer status changed */ 48262306a36Sopenharmony_ci SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS, 48362306a36Sopenharmony_ci /* Timestamp captured at the link */ 48462306a36Sopenharmony_ci SOF_IPC4_NOTIFY_TIMESTAMP_CAPTURED, 48562306a36Sopenharmony_ci /* FW complete initialization */ 48662306a36Sopenharmony_ci SOF_IPC4_NOTIFY_FW_READY, 48762306a36Sopenharmony_ci /* Audio classifier result (ACA) */ 48862306a36Sopenharmony_ci SOF_IPC4_NOTIFY_FW_AUD_CLASS_RESULT, 48962306a36Sopenharmony_ci /* Exception caught by DSP FW */ 49062306a36Sopenharmony_ci SOF_IPC4_NOTIFY_EXCEPTION_CAUGHT, 49162306a36Sopenharmony_ci /* 11 is skipped by the existing cavs firmware */ 49262306a36Sopenharmony_ci /* Custom module notification */ 49362306a36Sopenharmony_ci SOF_IPC4_NOTIFY_MODULE_NOTIFICATION = 12, 49462306a36Sopenharmony_ci /* 13 is reserved - do not use */ 49562306a36Sopenharmony_ci /* Probe notify data available */ 49662306a36Sopenharmony_ci SOF_IPC4_NOTIFY_PROBE_DATA_AVAILABLE = 14, 49762306a36Sopenharmony_ci /* AM module notifications */ 49862306a36Sopenharmony_ci SOF_IPC4_NOTIFY_ASYNC_MSG_SRVC_MESSAGE, 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ci SOF_IPC4_NOTIFY_TYPE_LAST, 50162306a36Sopenharmony_ci}; 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_cistruct sof_ipc4_notify_resource_data { 50462306a36Sopenharmony_ci uint32_t resource_type; 50562306a36Sopenharmony_ci uint32_t resource_id; 50662306a36Sopenharmony_ci uint32_t event_type; 50762306a36Sopenharmony_ci uint32_t reserved; 50862306a36Sopenharmony_ci uint32_t data[6]; 50962306a36Sopenharmony_ci} __packed __aligned(4); 51062306a36Sopenharmony_ci 51162306a36Sopenharmony_ci/** @}*/ 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ci#endif 514