linux/include/sound/sof/ipc4/header.h

/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
/*
 * This file is provided under a dual BSD/GPLv2 license.  When using or
 * redistributing this file, you may do so under either license.
 *
 * Copyright(c) 2022 Intel Corporation
 */

#ifndef __INCLUDE_SOUND_SOF_IPC4_HEADER_H__
#define __INCLUDE_SOUND_SOF_IPC4_HEADER_H__

#include <linux/types.h>
#include <uapi/sound/sof/abi.h>

/* maximum message size for mailbox Tx/Rx */
#define SOF_IPC4_MSG_MAX_SIZE

/** \addtogroup sof_uapi uAPI
 *  SOF uAPI specification.
 *  @{
 */

/**
 * struct sof_ipc4_msg - Placeholder of an IPC4 message
 * @header_u64:		IPC4 header as single u64 number
 * @primary:		Primary, mandatory part of the header
 * @extension:		Extended part of the header, if not used it should be
 *			set to 0
 * @data_size:		Size of data in bytes pointed by @data_ptr
 * @data_ptr:		Pointer to the optional payload of a message
 */
struct sof_ipc4_msg {};

/**
 * struct sof_ipc4_tuple - Generic type/ID and parameter tuple
 * @type:		type/ID
 * @size:		size of the @value array in bytes
 * @value:		value for the given type
 */
struct sof_ipc4_tuple {} __packed;

/*
 * IPC4 messages have two 32 bit identifier made up as follows :-
 *
 * header - msg type, msg id, msg direction ...
 * extension - extra params such as msg data size in mailbox
 *
 * These are sent at the start of the IPC message in the mailbox. Messages
 * should not be sent in the doorbell (special exceptions for firmware).
 */

/*
 * IPC4 primary header bit allocation for messages
 * bit 0-23:	message type specific
 * bit 24-28:	type:	enum sof_ipc4_global_msg if target is SOF_IPC4_FW_GEN_MSG
 *			enum sof_ipc4_module_type if target is SOF_IPC4_MODULE_MSG
 * bit 29:	response - sof_ipc4_msg_dir
 * bit 30:	target - enum sof_ipc4_msg_target
 * bit 31:	reserved, unused
 */

/* Value of target field - must fit into 1 bit */
enum sof_ipc4_msg_target {};

/* Value of type field - must fit into 5 bits */
enum sof_ipc4_global_msg {};

/* Value of response field - must fit into 1 bit */
enum sof_ipc4_msg_dir {};

enum sof_ipc4_pipeline_state {};

/* Generic message fields (bit 24-30) */

/* encoded to header's msg_tgt field */
#define SOF_IPC4_MSG_TARGET_SHIFT
#define SOF_IPC4_MSG_TARGET_MASK
#define SOF_IPC4_MSG_TARGET(x)
#define SOF_IPC4_MSG_IS_MODULE_MSG(x)

/* encoded to header's rsp field */
#define SOF_IPC4_MSG_DIR_SHIFT
#define SOF_IPC4_MSG_DIR_MASK
#define SOF_IPC4_MSG_DIR(x)

/* encoded to header's type field */
#define SOF_IPC4_MSG_TYPE_SHIFT
#define SOF_IPC4_MSG_TYPE_MASK
#define SOF_IPC4_MSG_TYPE_SET(x)
#define SOF_IPC4_MSG_TYPE_GET(x)

/* Global message type specific field definitions */

/* pipeline creation ipc msg */
#define SOF_IPC4_GLB_PIPE_INSTANCE_SHIFT
#define SOF_IPC4_GLB_PIPE_INSTANCE_MASK
#define SOF_IPC4_GLB_PIPE_INSTANCE_ID(x)

#define SOF_IPC4_GLB_PIPE_PRIORITY_SHIFT
#define SOF_IPC4_GLB_PIPE_PRIORITY_MASK
#define SOF_IPC4_GLB_PIPE_PRIORITY(x)

#define SOF_IPC4_GLB_PIPE_MEM_SIZE_SHIFT
#define SOF_IPC4_GLB_PIPE_MEM_SIZE_MASK
#define SOF_IPC4_GLB_PIPE_MEM_SIZE(x)

#define SOF_IPC4_GLB_PIPE_EXT_LP_SHIFT
#define SOF_IPC4_GLB_PIPE_EXT_LP_MASK
#define SOF_IPC4_GLB_PIPE_EXT_LP(x)

#define SOF_IPC4_GLB_PIPE_EXT_CORE_ID_SHIFT
#define SOF_IPC4_GLB_PIPE_EXT_CORE_ID_MASK
#define SOF_IPC4_GLB_PIPE_EXT_CORE_ID(x)

/* pipeline set state ipc msg */
#define SOF_IPC4_GLB_PIPE_STATE_ID_SHIFT
#define SOF_IPC4_GLB_PIPE_STATE_ID_MASK
#define SOF_IPC4_GLB_PIPE_STATE_ID(x)

#define SOF_IPC4_GLB_PIPE_STATE_SHIFT
#define SOF_IPC4_GLB_PIPE_STATE_MASK
#define SOF_IPC4_GLB_PIPE_STATE(x)

/* pipeline set state IPC msg extension */
#define SOF_IPC4_GLB_PIPE_STATE_EXT_MULTI

/* load library ipc msg */
#define SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID_SHIFT
#define SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID(x)

/* chain dma ipc message */
#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_SHIFT
#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_MASK
#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID(x)

#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_SHIFT
#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_MASK
#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID(x)

#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_SHIFT
#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_MASK
#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE(x)

#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE_SHIFT
#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE_MASK
#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE(x)

#define SOF_IPC4_GLB_CHAIN_DMA_SCS_SHIFT
#define SOF_IPC4_GLB_CHAIN_DMA_SCS_MASK
#define SOF_IPC4_GLB_CHAIN_DMA_SCS(x)

#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_SHIFT
#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_MASK
#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE(x)

enum sof_ipc4_channel_config {};

enum sof_ipc4_interleaved_style {};

enum sof_ipc4_sample_type {};

struct sof_ipc4_audio_format {} __packed __aligned();

#define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT_SHIFT
#define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT_MASK
#define SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(x)
#define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_SHIFT
#define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH_MASK
#define SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(x)
#define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_SHIFT
#define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE_MASK
#define SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(x)

/* Module message type specific field definitions */

enum sof_ipc4_module_type {};

struct sof_ipc4_base_module_cfg {} __packed __aligned();

/* common module ipc msg */
#define SOF_IPC4_MOD_INSTANCE_SHIFT
#define SOF_IPC4_MOD_INSTANCE_MASK
#define SOF_IPC4_MOD_INSTANCE(x)

#define SOF_IPC4_MOD_ID_SHIFT
#define SOF_IPC4_MOD_ID_MASK
#define SOF_IPC4_MOD_ID(x)

/* init module ipc msg */
#define SOF_IPC4_MOD_EXT_PARAM_SIZE_SHIFT
#define SOF_IPC4_MOD_EXT_PARAM_SIZE_MASK
#define SOF_IPC4_MOD_EXT_PARAM_SIZE(x)

#define SOF_IPC4_MOD_EXT_PPL_ID_SHIFT
#define SOF_IPC4_MOD_EXT_PPL_ID_MASK
#define SOF_IPC4_MOD_EXT_PPL_ID(x)

#define SOF_IPC4_MOD_EXT_CORE_ID_SHIFT
#define SOF_IPC4_MOD_EXT_CORE_ID_MASK
#define SOF_IPC4_MOD_EXT_CORE_ID(x)

#define SOF_IPC4_MOD_EXT_DOMAIN_SHIFT
#define SOF_IPC4_MOD_EXT_DOMAIN_MASK
#define SOF_IPC4_MOD_EXT_DOMAIN(x)

/*  bind/unbind module ipc msg */
#define SOF_IPC4_MOD_EXT_DST_MOD_ID_SHIFT
#define SOF_IPC4_MOD_EXT_DST_MOD_ID_MASK
#define SOF_IPC4_MOD_EXT_DST_MOD_ID(x)

#define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE_SHIFT
#define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE_MASK
#define SOF_IPC4_MOD_EXT_DST_MOD_INSTANCE(x)

#define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID_SHIFT
#define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID_MASK
#define SOF_IPC4_MOD_EXT_DST_MOD_QUEUE_ID(x)

#define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID_SHIFT
#define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID_MASK
#define SOF_IPC4_MOD_EXT_SRC_MOD_QUEUE_ID(x)

#define MOD_ENABLE_LOG
#define MOD_SYSTEM_TIME

/* set module large config */
#define SOF_IPC4_MOD_EXT_MSG_SIZE_SHIFT
#define SOF_IPC4_MOD_EXT_MSG_SIZE_MASK
#define SOF_IPC4_MOD_EXT_MSG_SIZE(x)

#define SOF_IPC4_MOD_EXT_MSG_PARAM_ID_SHIFT
#define SOF_IPC4_MOD_EXT_MSG_PARAM_ID_MASK
#define SOF_IPC4_MOD_EXT_MSG_PARAM_ID(x)

#define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK_SHIFT
#define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK_MASK
#define SOF_IPC4_MOD_EXT_MSG_LAST_BLOCK(x)

#define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK_SHIFT
#define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK_MASK
#define SOF_IPC4_MOD_EXT_MSG_FIRST_BLOCK(x)

/* Init instance messagees */
#define SOF_IPC4_MOD_INIT_BASEFW_MOD_ID
#define SOF_IPC4_MOD_INIT_BASEFW_INSTANCE_ID

enum sof_ipc4_base_fw_params {};

enum sof_ipc4_fw_config_params {};

struct sof_ipc4_fw_version {} __packed;

/* Payload data for SOF_IPC4_MOD_SET_DX */
struct sof_ipc4_dx_state_info {} __packed __aligned();

/* Reply messages */

/*
 * IPC4 primary header bit allocation for replies
 * bit 0-23:	status
 * bit 24-28:	type:	enum sof_ipc4_global_msg if target is SOF_IPC4_FW_GEN_MSG
 *			enum sof_ipc4_module_type if target is SOF_IPC4_MODULE_MSG
 * bit 29:	response - sof_ipc4_msg_dir
 * bit 30:	target - enum sof_ipc4_msg_target
 * bit 31:	reserved, unused
 */

#define SOF_IPC4_REPLY_STATUS

/* Notification messages */

/*
 * IPC4 primary header bit allocation for notifications
 * bit 0-15:	notification type specific
 * bit 16-23:	enum sof_ipc4_notification_type
 * bit 24-28:	SOF_IPC4_GLB_NOTIFICATION
 * bit 29:	response - sof_ipc4_msg_dir
 * bit 30:	target - enum sof_ipc4_msg_target
 * bit 31:	reserved, unused
 */

#define SOF_IPC4_MSG_IS_NOTIFICATION(x)

#define SOF_IPC4_NOTIFICATION_TYPE_SHIFT
#define SOF_IPC4_NOTIFICATION_TYPE_MASK
#define SOF_IPC4_NOTIFICATION_TYPE_GET(x)

#define SOF_IPC4_LOG_CORE_SHIFT
#define SOF_IPC4_LOG_CORE_MASK
#define SOF_IPC4_LOG_CORE_GET(x)

/* Value of notification type field - must fit into 8 bits */
enum sof_ipc4_notification_type {};

struct sof_ipc4_notify_resource_data {} __packed __aligned();

#define SOF_IPC4_DEBUG_DESCRIPTOR_SIZE

/*
 * The debug memory window is divided into 16 slots, and the
 * first slot is used as a recorder for the other 15 slots.
 */
#define SOF_IPC4_MAX_DEBUG_SLOTS
#define SOF_IPC4_DEBUG_SLOT_SIZE

/* debug log slot types */
#define SOF_IPC4_DEBUG_SLOT_UNUSED
#define SOF_IPC4_DEBUG_SLOT_CRITICAL_LOG
#define SOF_IPC4_DEBUG_SLOT_DEBUG_LOG
#define SOF_IPC4_DEBUG_SLOT_GDB_STUB
#define SOF_IPC4_DEBUG_SLOT_TELEMETRY
#define SOF_IPC4_DEBUG_SLOT_BROKEN

/**
 * struct sof_ipc4_notify_module_data - payload for module notification
 * @instance_id: instance ID of the originator module of the notification
 * @module_id: module ID of the originator of the notification
 * @event_id: module specific event id
 * @event_data_size: Size of the @event_data (if any) in bytes
 * @event_data: Optional notification data, module and notification dependent
 */
struct sof_ipc4_notify_module_data {} __packed __aligned();

/*
 * ALSA kcontrol change notification
 *
 * The event_id of struct sof_ipc4_notify_module_data is divided into two u16:
 *  upper u16: magic number for ALSA kcontrol types: 0xA15A
 *  lower u16: param_id of the control, which is the type of the control
 * The event_data contains the struct sof_ipc4_control_msg_payload of the control
 * which sent the notification.
 */
#define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_MASK
#define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL
#define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_PARAMID_MASK

/** @}*/

#endif