1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 /**
8  * Non-HD Audio Link Table (NHLT) definitions taken from
9  *
10  * Intel Smart Sound Technology Audio DSP Non-HD Audio ACPI High Level Design
11  * Revision 0.7
12  * November 2015
13  */
14 
15 // Including ACPI table header definitions here to avoid including
16 // ACPICA header file
17 
18 #if !__cplusplus
19 #error "C++ only header"
20 #else
21 
22 namespace audio {
23 namespace intel_hda {
24 
25 constexpr const char* ACPI_NHLT_SIGNATURE = "NHLT";
26 
27 #define ACPI_NAME_SIZE         4
28 #define ACPI_OEM_ID_SIZE       6
29 #define ACPI_OEM_TABLE_ID_SIZE 8
30 
31 struct acpi_table_header_t {
32     char     signature[ACPI_NAME_SIZE];
33     uint32_t length;
34     uint8_t  revision;
35     uint8_t  checksum;
36     char     oem_id[ACPI_OEM_ID_SIZE];
37     char     oem_table_id[ACPI_OEM_TABLE_ID_SIZE];
38     uint32_t oem_revision;
39     char     asl_compiler_id[ACPI_NAME_SIZE];
40     uint32_t asl_compiler_revision;
41 } __PACKED;
42 
43 struct specific_config_t {
44     uint32_t capabilities_size;
45     uint8_t  capabilities[];
46 } __PACKED;
47 
48 struct format_config_t {
49     uint16_t format_tag;
50     uint16_t n_channels;
51     uint32_t n_samples_per_sec;
52     uint32_t n_avg_bytes_per_sec;
53     uint16_t n_block_align;
54     uint16_t bits_per_sample;
55     uint16_t cb_size;
56     uint16_t valid_bits_per_sample;
57     uint32_t channel_mask;
58     uint8_t  subformat_guid[16];
59     specific_config_t config;
60 } __PACKED;
61 
62 struct formats_config_t {
63     uint8_t format_config_count;
64     format_config_t format_configs[];
65 } __PACKED;
66 
67 struct nhlt_descriptor_t {
68     uint32_t length;
69     uint8_t  link_type;
70     uint8_t  instance_id;
71     uint16_t vendor_id;
72     uint16_t device_id;
73     uint16_t revision_id;
74     uint32_t subsystem_id;
75     uint8_t  device_type;
76     uint8_t  direction;
77     uint8_t  virtual_bus_id;
78     specific_config_t config;
79     // followed by formats_config_t format_configs
80 } __PACKED;
81 
82 constexpr uint8_t NHLT_LINK_TYPE_HDA = 0;
83 constexpr uint8_t NHLT_LINK_TYPE_PDM = 2;
84 constexpr uint8_t NHLT_LINK_TYPE_SSP = 3;
85 
86 constexpr uint8_t NHLT_DIRECTION_RENDER  = 0;
87 constexpr uint8_t NHLT_DIRECTION_CAPTURE = 1;
88 constexpr uint8_t NHLT_DIRECTION_BIDIR   = 2;
89 
90 struct nhlt_table_t {
91     acpi_table_header_t header;
92     uint8_t             endpoint_desc_count;
93     nhlt_descriptor_t   endpoints[];
94     // followed by specific_config_t oed_config;
95 } __PACKED;
96 
97 }  // namespace intel_hda
98 }  // namespace audio
99 
100 #endif
101