| 1 |
|
| 2 |
|
| 3 |
#ifndef _NHLT_H_ |
| 4 |
#define _NHLT_H_ |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
#include <stddef.h> |
| 8 |
|
| 9 |
struct nhlt; |
| 10 |
struct nhlt_endpoint; |
| 11 |
struct nhlt_format; |
| 12 |
struct nhlt_format_config; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
struct nhlt *nhlt_init(void); |
| 43 |
|
| 44 |
|
| 45 |
size_t nhlt_current_size(struct nhlt *nhlt); |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
struct nhlt_endp_descriptor { |
| 53 |
|
| 54 |
int link; |
| 55 |
int device; |
| 56 |
int direction; |
| 57 |
uint16_t vid; |
| 58 |
uint16_t did; |
| 59 |
|
| 60 |
const void *cfg; |
| 61 |
size_t cfg_size; |
| 62 |
|
| 63 |
const struct nhlt_format_config *formats; |
| 64 |
size_t num_formats; |
| 65 |
}; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
int nhlt_add_endpoints(struct nhlt *nhlt, |
| 73 |
const struct nhlt_endp_descriptor *epds, |
| 74 |
size_t num_epds); |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
int nhlt_add_ssp_endpoints(struct nhlt *nhlt, int virtual_bus_id, |
| 82 |
const struct nhlt_endp_descriptor *epds, size_t num_epds); |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
struct nhlt_endpoint *nhlt_add_endpoint(struct nhlt *nhlt, int link_type, |
| 92 |
int device_type, int dir, |
| 93 |
uint16_t vid, uint16_t did); |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
int nhlt_endpoint_append_config(struct nhlt_endpoint *endpoint, |
| 101 |
const void *config, size_t config_sz); |
| 102 |
|
| 103 |
|
| 104 |
struct nhlt_format *nhlt_add_format(struct nhlt_endpoint *endpoint, |
| 105 |
int num_channels, |
| 106 |
int sample_freq_khz, |
| 107 |
int container_bits_per_sample, |
| 108 |
int valid_bits_per_sample, |
| 109 |
uint32_t speaker_mask); |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
int nhlt_format_append_config(struct nhlt_format *format, const void *config, |
| 117 |
size_t config_sz); |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
int nhlt_endpoint_add_formats(struct nhlt_endpoint *endpoint, |
| 126 |
const struct nhlt_format_config *formats, |
| 127 |
size_t num_formats); |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
void nhlt_next_instance(struct nhlt *nhlt, int link_type); |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
uintptr_t nhlt_serialize(struct nhlt *nhlt, uintptr_t acpi_addr); |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
uintptr_t nhlt_serialize_oem_overrides(struct nhlt *nhlt, uintptr_t acpi_addr, |
| 152 |
const char *oem_id, const char *oem_table_id, |
| 153 |
uint32_t oem_revision); |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
uintptr_t nhlt_soc_serialize(struct nhlt *nhlt, uintptr_t acpi_addr); |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
uintptr_t nhlt_soc_serialize_oem_overrides(struct nhlt *nhlt, |
| 168 |
uintptr_t acpi_addr, const char *oem_id, const char *oem_table_id, |
| 169 |
uint32_t oem_revision); |
| 170 |
|
| 171 |
|
| 172 |
enum { |
| 173 |
NHLT_LINK_HDA, |
| 174 |
NHLT_LINK_DSP, |
| 175 |
NHLT_LINK_PDM, |
| 176 |
NHLT_LINK_SSP, |
| 177 |
NHLT_MAX_LINK_TYPES, |
| 178 |
}; |
| 179 |
|
| 180 |
enum { |
| 181 |
NHLT_SSP_DEV_BT, |
| 182 |
NHLT_SSP_DEV_MODEM, |
| 183 |
NHLT_SSP_DEV_FM, |
| 184 |
NHLT_SSP_DEV_RESERVED, |
| 185 |
NHLT_SSP_DEV_I2S = 4, |
| 186 |
}; |
| 187 |
|
| 188 |
enum { |
| 189 |
NHLT_PDM_DEV, |
| 190 |
NHLT_PDM_DEV_CAVS15, |
| 191 |
}; |
| 192 |
|
| 193 |
|
| 194 |
enum { |
| 195 |
NHLT_DIR_RENDER, |
| 196 |
NHLT_DIR_CAPTURE, |
| 197 |
NHLT_DIR_BIDIRECTIONAL, |
| 198 |
}; |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
enum { |
| 203 |
SPEAKER_FRONT_LEFT = 1 << 0, |
| 204 |
SPEAKER_FRONT_RIGHT = 1 << 1, |
| 205 |
SPEAKER_FRONT_CENTER = 1 << 2, |
| 206 |
SPEAKER_LOW_FREQUENCY = 1 << 3, |
| 207 |
SPEAKER_BACK_LEFT = 1 << 4, |
| 208 |
SPEAKER_BACK_RIGHT = 1 << 5, |
| 209 |
SPEAKER_FRONT_LEFT_OF_CENTER = 1 << 6, |
| 210 |
SPEAKER_FRONT_RIGHT_OF_CENTER = 1 << 7, |
| 211 |
SPEAKER_BACK_CENTER = 1 << 8, |
| 212 |
SPEAKER_SIDE_LEFT = 1 << 9, |
| 213 |
SPEAKER_SIDE_RIGHT = 1 << 10, |
| 214 |
SPEAKER_TOP_CENTER = 1 << 11, |
| 215 |
SPEAKER_TOP_FRONT_LEFT = 1 << 12, |
| 216 |
SPEAKER_TOP_FRONT_CENTER = 1 << 13, |
| 217 |
SPEAKER_TOP_FRONT_RIGHT = 1 << 14, |
| 218 |
SPEAKER_TOP_BACK_LEFT = 1 << 15, |
| 219 |
SPEAKER_TOP_BACK_CENTER = 1 << 16, |
| 220 |
SPEAKER_TOP_BACK_RIGHT = 1 << 17, |
| 221 |
}; |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
struct sub_format { |
| 226 |
uint32_t data1; |
| 227 |
uint16_t data2; |
| 228 |
uint16_t data3; |
| 229 |
uint8_t data4[8]; |
| 230 |
}; |
| 231 |
|
| 232 |
struct nhlt_specific_config { |
| 233 |
uint32_t size; |
| 234 |
void *capabilities; |
| 235 |
}; |
| 236 |
|
| 237 |
struct nhlt_waveform { |
| 238 |
uint16_t tag; |
| 239 |
uint16_t num_channels; |
| 240 |
uint32_t samples_per_second; |
| 241 |
uint32_t bytes_per_second; |
| 242 |
uint16_t block_align; |
| 243 |
uint16_t bits_per_sample; |
| 244 |
uint16_t extra_size; |
| 245 |
uint16_t valid_bits_per_sample; |
| 246 |
uint32_t channel_mask; |
| 247 |
struct sub_format sub_format; |
| 248 |
}; |
| 249 |
|
| 250 |
struct nhlt_format { |
| 251 |
struct nhlt_waveform waveform; |
| 252 |
struct nhlt_specific_config config; |
| 253 |
}; |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
struct nhlt_format_config { |
| 260 |
int num_channels; |
| 261 |
int sample_freq_khz; |
| 262 |
int container_bits_per_sample; |
| 263 |
int valid_bits_per_sample; |
| 264 |
uint32_t speaker_mask; |
| 265 |
const char *settings_file; |
| 266 |
}; |
| 267 |
|
| 268 |
|
| 269 |
#define MAX_FORMATS 2 |
| 270 |
struct nhlt_endpoint { |
| 271 |
uint32_t length; |
| 272 |
uint8_t link_type; |
| 273 |
uint8_t instance_id; |
| 274 |
uint16_t vendor_id; |
| 275 |
uint16_t device_id; |
| 276 |
uint16_t revision_id; |
| 277 |
uint32_t subsystem_id; |
| 278 |
uint8_t device_type; |
| 279 |
uint8_t direction; |
| 280 |
uint8_t virtual_bus_id; |
| 281 |
struct nhlt_specific_config config; |
| 282 |
uint8_t num_formats; |
| 283 |
struct nhlt_format formats[MAX_FORMATS]; |
| 284 |
}; |
| 285 |
|
| 286 |
#define MAX_ENDPOINTS 8 |
| 287 |
struct nhlt { |
| 288 |
uint32_t subsystem_id; |
| 289 |
uint8_t num_endpoints; |
| 290 |
struct nhlt_endpoint endpoints[MAX_ENDPOINTS]; |
| 291 |
uint8_t current_instance_id[NHLT_MAX_LINK_TYPES]; |
| 292 |
}; |
| 293 |
|
| 294 |
struct nhlt_tdm_config { |
| 295 |
uint8_t virtual_slot; |
| 296 |
uint8_t config_type; |
| 297 |
}; |
| 298 |
|
| 299 |
enum { |
| 300 |
NHLT_TDM_BASIC, |
| 301 |
NHLT_TDM_MIC_ARRAY, |
| 302 |
NHLT_TDM_RENDER_WITH_LOOPBACK, |
| 303 |
NHLT_TDM_RENDER_FEEDBACK, |
| 304 |
NHLT_TDM_MULTI_MODE, |
| 305 |
NHLT_TDM_MULTI_MODE_MIC_ARRAY = NHLT_TDM_MULTI_MODE | NHLT_TDM_MIC_ARRAY |
| 306 |
}; |
| 307 |
|
| 308 |
struct nhlt_feedback_config { |
| 309 |
struct nhlt_tdm_config tdm_config; |
| 310 |
uint8_t feedback_virtual_slot; |
| 311 |
uint16_t feedback_channels; |
| 312 |
uint16_t feedback_valid_bits_per_sample; |
| 313 |
}; |
| 314 |
|
| 315 |
struct nhlt_dmic_array_config { |
| 316 |
struct nhlt_tdm_config tdm_config; |
| 317 |
uint8_t array_type; |
| 318 |
}; |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
enum { |
| 325 |
NHLT_MIC_ARRAY_2CH_SMALL = 0xa, |
| 326 |
NHLT_MIC_ARRAY_2CH_BIG = 0xb, |
| 327 |
NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc, |
| 328 |
NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd, |
| 329 |
NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe, |
| 330 |
NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf, |
| 331 |
}; |
| 332 |
|
| 333 |
#endif |