1 /** @file
2   Header file for DxePchHdaNhltLib - NHLT structure definitions.
3 
4   Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
5 
6   SPDX-License-Identifier: BSD-2-Clause-Patent
7 **/
8 
9 #ifndef _DXE_HDA_NHLT_H_
10 #define _DXE_HDA_NHLT_H_
11 
12 #include <IndustryStandard/Acpi.h>
13 
14 //
15 // ACPI support protocol instance signature definition.
16 //
17 #define NHLT_ACPI_TABLE_SIGNATURE  SIGNATURE_32 ('N', 'H', 'L', 'T')
18 
19 // MSFT defined structures
20 #define SPEAKER_FRONT_LEFT      0x1
21 #define SPEAKER_FRONT_RIGHT     0x2
22 #define SPEAKER_FRONT_CENTER    0x4
23 #define SPEAKER_BACK_LEFT       0x10
24 #define SPEAKER_BACK_RIGHT      0x20
25 
26 #define KSAUDIO_SPEAKER_MONO   (SPEAKER_FRONT_CENTER)
27 #define KSAUDIO_SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT)
28 #define KSAUDIO_SPEAKER_QUAD   (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT)
29 
30 #define WAVE_FORMAT_EXTENSIBLE    0xFFFE
31 #define KSDATAFORMAT_SUBTYPE_PCM \
32         {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}
33 
34 #pragma pack (push, 1)
35 
36 typedef struct {
37   UINT16  wFormatTag;
38   UINT16  nChannels;
39   UINT32  nSamplesPerSec;
40   UINT32  nAvgBytesPerSec;
41   UINT16  nBlockAlign;
42   UINT16  wBitsPerSample;
43   UINT16  cbSize;
44 } WAVEFORMATEX;
45 
46 typedef struct {
47   WAVEFORMATEX Format;
48   union {
49     UINT16 wValidBitsPerSample;
50     UINT16 wSamplesPerBlock;
51     UINT16 wReserved;
52   } Samples;
53   UINT32       dwChannelMask;
54   GUID         SubFormat;
55 } WAVEFORMATEXTENSIBLE;
56 
57 //
58 // List of supported link type.
59 //
60 enum NHLT_LINK_TYPE
61 {
62   HdaNhltLinkHd   = 0,
63   HdaNhltLinkDsp  = 1,
64   HdaNhltLinkDmic = 2,
65   HdaNhltLinkSsp  = 3,
66   HdaNhltLinkInvalid
67 };
68 
69 //
70 // List of supported device type.
71 //
72 enum NHLT_DEVICE_TYPE
73 {
74   HdaNhltDeviceBt   = 0,
75   HdaNhltDeviceDmic = 1,
76   HdaNhltDeviceI2s  = 4,
77   HdaNhltDeviceInvalid
78 };
79 
80 typedef struct {
81   UINT32    CapabilitiesSize;
82   UINT8     Capabilities[1];
83 } SPECIFIC_CONFIG;
84 
85 typedef struct {
86   WAVEFORMATEXTENSIBLE Format;
87   SPECIFIC_CONFIG      FormatConfiguration;
88 } FORMAT_CONFIG;
89 
90 typedef struct {
91   UINT8           FormatsCount;
92   FORMAT_CONFIG   FormatsConfiguration[1];
93 } FORMATS_CONFIG;
94 
95 typedef struct {
96   UINT8           DeviceId[16];
97   UINT8           DeviceInstanceId;
98   UINT8           DevicePortId;
99 } DEVICE_INFO;
100 
101 typedef struct {
102   UINT8           DeviceInfoCount;
103   DEVICE_INFO     DeviceInformation[1];
104 } DEVICES_INFO;
105 
106 typedef struct {
107   UINT32          EndpointDescriptorLength;
108   UINT8           LinkType;
109   UINT8           InstanceId;
110   UINT16          HwVendorId;
111   UINT16          HwDeviceId;
112   UINT16          HwRevisionId;
113   UINT32          HwSubsystemId;
114   UINT8           DeviceType;
115   UINT8           Direction;
116   UINT8           VirtualBusId;
117   SPECIFIC_CONFIG EndpointConfig;
118   FORMATS_CONFIG  FormatsConfig;
119   DEVICES_INFO    DevicesInformation;
120 } ENDPOINT_DESCRIPTOR;
121 
122 //
123 // High Level Table structure
124 //
125 typedef struct {
126   EFI_ACPI_DESCRIPTION_HEADER Header; //{'N', 'H', 'L', 'T'}
127   UINT8                       EndpointCount;   // Actual number of endpoints
128   ENDPOINT_DESCRIPTOR         EndpointDescriptors[1];
129   SPECIFIC_CONFIG             OedConfiguration;
130 } NHLT_ACPI_TABLE;
131 
132 #pragma pack (pop)
133 
134 #endif // _DXE_HDA_NHLT_H_
135 
136