1 /* SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright(c) 2019 Intel Corporation. All rights reserved. 4 * 5 * Author: Adrian Bonislawski <adrian.bonislawski@linux.intel.com> 6 * Artur Kloniecki <arturx.kloniecki@linux.intel.com> 7 */ 8 9 /** 10 * \file include/ipc/probe.h 11 * \brief Probe IPC definitions 12 * \author Adrian Bonislawski <adrian.bonislawski@linux.intel.com> 13 * \author Artur Kloniecki <arturx.kloniecki@linux.intel.com> 14 */ 15 16 #ifndef __IPC_PROBE_H__ 17 #define __IPC_PROBE_H__ 18 19 #include <ipc/header.h> 20 #include <sof/bit.h> 21 #include <stdint.h> 22 23 #define PROBE_PURPOSE_EXTRACTION 0x1 24 #define PROBE_PURPOSE_INJECTION 0x2 25 26 #define PROBE_EXTRACT_SYNC_WORD 0xBABEBEBA 27 28 /** 29 * \brief Definitions of shifts and masks for format encoding in probe 30 * extraction stream 31 * 32 * Audio format from extraction probes is encoded as 32 bit value. Following 33 * graphic explains encoding. 34 * 35 * A|BBBB|CCCC|DDDD|EEEEE|FF|GG|H|I|J|XXXXXXX 36 * A - 1 bit - Specifies Type Encoding - 1 for Standard encoding 37 * B - 4 bits - Specify Standard Type - 0 for Audio 38 * C - 4 bits - Specify Audio format - 0 for PCM 39 * D - 4 bits - Specify Sample Rate - value enumerating standard sample rates: 40 * 8000 Hz = 0x0 41 * 11025 Hz = 0x1 42 * 12000 Hz = 0x2 43 * 16000 Hz = 0x3 44 * 22050 Hz = 0x4 45 * 24000 Hz = 0x5 46 * 32000 Hz = 0x6 47 * 44100 Hz = 0x7 48 * 48000 Hz = 0x8 49 * 64000 Hz = 0x9 50 * 88200 Hz = 0xA 51 * 96000 Hz = 0xB 52 * 128000 Hz = 0xC 53 * 176400 Hz = 0xD 54 * 192000 Hz = 0xE 55 * none of the above = 0xF 56 * E - 5 bits - Specify Number of Channels minus 1 57 * F - 2 bits - Specify Sample Size, number of valid sample bytes minus 1 58 * G - 2 bits - Specify Container Size, number of container bytes minus 1 59 * H - 1 bit - Specifies Sample Format - 0 for Integer, 1 for Floating point 60 * I - 1 bit - Specifies Sample Endianness - 0 for LE 61 * J - 1 bit - Specifies Interleaving - 1 for Sample Interleaving 62 */ 63 #define PROBE_SHIFT_FMT_TYPE 31 64 #define PROBE_SHIFT_STANDARD_TYPE 27 65 #define PROBE_SHIFT_AUDIO_FMT 23 66 #define PROBE_SHIFT_SAMPLE_RATE 19 67 #define PROBE_SHIFT_NB_CHANNELS 14 68 #define PROBE_SHIFT_SAMPLE_SIZE 12 69 #define PROBE_SHIFT_CONTAINER_SIZE 10 70 #define PROBE_SHIFT_SAMPLE_FMT 9 71 #define PROBE_SHIFT_SAMPLE_END 8 72 #define PROBE_SHIFT_INTERLEAVING_ST 7 73 74 #define PROBE_MASK_FMT_TYPE MASK(31, 31) 75 #define PROBE_MASK_STANDARD_TYPE MASK(30, 27) 76 #define PROBE_MASK_AUDIO_FMT MASK(26, 23) 77 #define PROBE_MASK_SAMPLE_RATE MASK(22, 19) 78 #define PROBE_MASK_NB_CHANNELS MASK(18, 14) 79 #define PROBE_MASK_SAMPLE_SIZE MASK(13, 12) 80 #define PROBE_MASK_CONTAINER_SIZE MASK(11, 10) 81 #define PROBE_MASK_SAMPLE_FMT MASK(9, 9) 82 #define PROBE_MASK_SAMPLE_END MASK(8, 8) 83 #define PROBE_MASK_INTERLEAVING_ST MASK(7, 7) 84 85 /** 86 * Header for data packets sent via compressed PCM from extraction probes 87 */ 88 struct probe_data_packet { 89 uint32_t sync_word; /**< PROBE_EXTRACT_SYNC_WORD */ 90 uint32_t buffer_id; /**< Buffer ID from which data was extracted */ 91 uint32_t format; /**< Encoded data format */ 92 uint32_t timestamp_low; /**< Low 32 bits of timestamp in us */ 93 uint32_t timestamp_high; /**< High 32 bits of timestamp in us */ 94 uint32_t checksum; /**< CRC32 of header and payload */ 95 uint32_t data_size_bytes; /**< Size of following audio data */ 96 uint32_t data[]; /**< Audio data extracted from buffer */ 97 } __attribute__((packed, aligned(4))); 98 99 /** 100 * Description of probe dma 101 */ 102 struct probe_dma { 103 uint32_t stream_tag; /**< Stream tag associated with this DMA */ 104 uint32_t dma_buffer_size; /**< Size of buffer associated with this DMA */ 105 } __attribute__((packed, aligned(4))); 106 107 /** 108 * Description of probe point 109 */ 110 struct probe_point { 111 uint32_t buffer_id; /**< ID of buffer to which probe is attached */ 112 uint32_t purpose; /**< PROBE_PURPOSE_EXTRACTION or PROBE_PURPOSE_INJECTION */ 113 uint32_t stream_tag; /**< Stream tag of DMA via which data will be provided for injection. 114 * For extraction purposes, stream tag is ignored when received, 115 * but returned actual extraction stream tag via INFO function. 116 */ 117 } __attribute__((packed, aligned(4))); 118 119 /** 120 * \brief DMA ADD for probes. 121 * 122 * Used as payload for IPCs: SOF_IPC_PROBE_INIT, SOF_IPC_PROBE_DMA_ADD. 123 */ 124 struct sof_ipc_probe_dma_add_params { 125 struct sof_ipc_cmd_hdr hdr; /**< Header */ 126 uint32_t num_elems; /**< Count of DMAs specified in array */ 127 struct probe_dma probe_dma[]; /**< Array of DMAs to be added */ 128 } __attribute__((packed, aligned(4))); 129 130 /** 131 * \brief Reply to INFO functions. 132 * 133 * Used as payload for IPCs: SOF_IPC_PROBE_DMA_INFO, SOF_IPC_PROBE_POINT_INFO. 134 */ 135 struct sof_ipc_probe_info_params { 136 struct sof_ipc_reply rhdr; /**< Header */ 137 uint32_t num_elems; /**< Count of elements in array */ 138 union { 139 struct probe_dma probe_dma[0]; /**< DMA info */ 140 struct probe_point probe_point[0]; /**< Probe Point info */ 141 }; 142 } __attribute__((packed, aligned(4))); 143 144 /** 145 * \brief Probe DMA remove. 146 * 147 * Used as payload for IPC: SOF_IPC_PROBE_DMA_REMOVE 148 */ 149 struct sof_ipc_probe_dma_remove_params { 150 struct sof_ipc_cmd_hdr hdr; /**< Header */ 151 uint32_t num_elems; /**< Count of stream tags specified in array */ 152 uint32_t stream_tag[]; /**< Array of stream tags associated with DMAs to remove */ 153 } __attribute__((packed, aligned(4))); 154 155 /** 156 * \brief Add probe points. 157 * 158 * Used as payload for IPC: SOF_IPC_PROBE_POINT_ADD 159 */ 160 struct sof_ipc_probe_point_add_params { 161 struct sof_ipc_cmd_hdr hdr; /**< Header */ 162 uint32_t num_elems; /**< Count of Probe Points specified in array */ 163 struct probe_point probe_point[]; /**< Array of Probe Points to add */ 164 } __attribute__((packed, aligned(4))); 165 166 /** 167 * \brief Remove probe point. 168 * 169 * Used as payload for IPC: SOF_IPC_PROBE_POINT_REMOVE 170 */ 171 struct sof_ipc_probe_point_remove_params { 172 struct sof_ipc_cmd_hdr hdr; /**< Header */ 173 uint32_t num_elems; /**< Count of buffer IDs specified in array */ 174 uint32_t buffer_id[]; /**< Array of buffer IDs from which Probe Points should be removed */ 175 } __attribute__((packed, aligned(4))); 176 177 #endif /* __IPC_PROBE_H__ */ 178