1 // SPDX-License-Identifier: BSD-3-Clause 2 // 3 // Copyright(c) 2021 Intel Corporation. All rights reserved. 4 // 5 // Author: Jaska Uimonen <jaska.uimonen@linux.intel.com> 6 7 #ifndef __NHLT_H 8 #define __NHLT_H 9 10 #include <stdint.h> 11 12 /* 13 * Nhlt defines and structs are derived from: 14 * https://01.org/sites/default/files/595976_intel_sst_nhlt.pdf 15 * 16 * Acpi description header for example: 17 * https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf 18 * 19 * Idea is to generate similar blob as you would get from: 20 * 'cat /sys/firmware/acpi/tables/NHLT' 21 * 22 */ 23 #define NHLT_LINK_TYPE_HDAUDIO 0 24 #define NHLT_LINK_TYPE_DSP 1 25 #define NHLT_LINK_TYPE_PDM 2 26 #define NHLT_LINK_TYPE_SSP 3 27 #define NHLT_LINK_TYPE_SLIMBUS 4 28 #define NHLT_LINK_TYPE_SOUNDWIRE 5 29 30 #define NHLT_VENDOR_ID_INTEL 0x8086 31 32 #define NHLT_DEVICE_ID_INTEL_PDM_DMIC 0xAE20 33 #define NHLT_DEVICE_ID_INTEL_BT_SIDEBAND 0xAE30 34 #define NHLT_DEVICE_ID_INTEL_I2S_TDM 0xAE34 35 36 #define NHLT_DEVICE_TYPE_SSP_BT_SIDEBAND 0 37 #define NHLT_DEVICE_TYPE_SSP_FM 1 38 #define NHLT_DEVICE_TYPE_SSP_MODEM 2 39 #define NHLT_DEVICE_TYPE_SSP_ANALOG 4 40 41 #define NHLT_ENDPOINT_DIRECTION_RENDER 0 42 #define NHLT_ENDPOINT_DIRECTION_CAPTURE 1 43 #define NHLT_ENDPOINT_DIRECTION_RENDER_WITH_LOOPBACK 2 44 #define NHLT_ENDPOINT_DIRECTION_FEEDBACK_FOR_RENDER 3 45 46 #define NHLT_DEVICE_CONFIG_TYPE_GENERIC 0 47 #define NHLT_DEVICE_CONFIG_TYPE_MICARRAY 1 48 #define NHLT_DEVICE_CONFIG_TYPE_RENDERWITHLOOPBACK 2 49 #define NHLT_DEVICE_CONFIG_TYPE_RENDERFEEDBACK 3 50 51 #define NHLT_MIC_ARRAY_TYPE_LINEAR_2_ELEMENT_SMALL 0xA 52 #define NHLT_MIC_ARRAY_TYPE_LINEAR_2_ELEMENT_BIG 0xB 53 #define NHLT_MIC_ARRAY_TYPE_LINEAR_4_ELEMENT_1ST_GEOMETRY 0xC 54 #define NHLT_MIC_ARRAY_TYPE_PLANAR_4_ELEMENT_L_SHAPED 0xD 55 #define NHLT_MIC_ARRAY_TYPE_PLANAR_4_ELEMENT_2ND_GEOMETRY 0xE 56 #define NHLT_MIC_ARRAY_TYPE_VENDOR_DEFINED 0xF 57 58 #define NHLT_MIC_ARRAY_NO_EXTENSION 0x0 59 #define NHLT_MIC_ARRAY_SNR_AND_SENSITIVITY_EXTENSION 0x1 60 61 #define NHLT_MIC_TYPE_OMNIDIRECTIONAL 0 62 #define NHLT_MIC_TYPE_SUBCARDIOID 1 63 #define NHLT_MIC_TYPE_CARDIOID 2 64 #define NHLT_MIC_TYPE_SUPERCARDIOID 3 65 #define NHLT_MIC_TYPE_HYPERCARDIOID 4 66 #define NHLT_MIC_TYPE_8SHAPED 5 67 #define NHLT_MIC_TYPE_RESERVED 6 68 #define NHLT_MIC_TYPE_VENDORDEFINED 7 69 70 #define NHLT_MIC_POSITION_TOP 0 71 #define NHLT_MIC_POSITION_BOTTOM 1 72 #define NHLT_MIC_POSITION_LEFT 2 73 #define NHLT_MIC_POSITION_RIGHT 3 74 #define NHLT_MIC_POSITION_FRONT 4 /*(default) */ 75 #define NHLT_MIC_POSITION_REAR 5 76 77 struct specific_config { 78 uint32_t capabilities_size; /* does not include size of this field */ 79 uint8_t capabilities[]; 80 } __attribute__((packed)); 81 82 struct device_specific_config { 83 uint8_t virtual_slot; 84 uint8_t config_type; 85 } __attribute__((packed)); 86 87 struct ssp_device_specific_config { 88 struct specific_config config; 89 struct device_specific_config device_config; 90 } __attribute__((packed)); 91 92 struct mic_snr_sensitivity_extension { 93 uint32_t snr; 94 uint32_t sensitivity; 95 } __attribute__((packed)); 96 97 struct mic_vendor_config { 98 uint8_t type; 99 uint8_t panel; 100 uint32_t speaker_position_distance; 101 uint32_t horizontal_offset; 102 uint32_t vertical_offset; 103 uint8_t frequency_low_band; 104 uint8_t frequency_high_band; 105 uint16_t direction_angle; 106 uint16_t elevation_angle; 107 uint16_t vertical_angle_begin; 108 uint16_t vertical_angle_end; 109 uint16_t horizontal_angle_begin; 110 uint16_t horizontal_angle_end; 111 } __attribute__((packed)); 112 113 struct mic_array_device_specific_config { 114 struct specific_config config; 115 struct device_specific_config device_config; 116 uint8_t array_type_ex; 117 } __attribute__((packed)); 118 119 struct mic_array_device_specific_vendor_config { 120 struct specific_config config; 121 struct device_specific_config device_config; 122 uint8_t array_type_ex; 123 uint8_t number_of_microphones; 124 uint8_t mic_vendor_configs[]; 125 } __attribute__((packed)); 126 127 struct WAVEFORMATEXTENSIBLE { 128 uint16_t wFormatTag; 129 uint16_t nChannels; 130 uint32_t nSamplesPerSec; 131 uint32_t nAvgBytesPerSec; 132 uint16_t nBlockAlign; 133 uint16_t wBitsPerSample; 134 uint16_t cbSize; 135 uint16_t wValidBitsPerSample; 136 uint32_t dwChannelMask; 137 uint32_t SubFormat[4]; 138 } __attribute__((packed)); 139 140 struct format_config { 141 struct WAVEFORMATEXTENSIBLE format; 142 struct specific_config vendor_blob; 143 } __attribute__((packed)); 144 145 struct formats_config { 146 uint8_t formats_count; 147 uint8_t f_configs[]; 148 } __attribute__((packed)); 149 150 struct endpoint_descriptor { 151 uint32_t length; /* includes the length of this field also */ 152 uint8_t link_type; 153 uint8_t instance_id; 154 uint16_t vendor_id; 155 uint16_t device_id; 156 uint16_t revision_id; 157 uint32_t subsystem_id; 158 uint8_t device_type; 159 uint8_t direction; 160 uint8_t virtualbus_id; 161 } __attribute__((packed)); 162 163 struct efi_acpi_description_header { 164 uint32_t signature; 165 uint32_t length; 166 uint8_t revision; 167 uint8_t checksum; 168 uint8_t oem_id[6]; 169 uint64_t oem_table_id; 170 uint32_t oem_revision; 171 uint32_t creator_id; 172 uint32_t creator_revision; 173 } __attribute__((packed)); 174 175 struct nhlt { 176 struct efi_acpi_description_header efi_acpi; 177 uint8_t endpoint_count; 178 uint8_t endpoints[]; 179 } __attribute__((packed)); 180 181 #endif /* __NHLT_H */ 182