fedf0935a4d0ff1b0f00e5fb4de8a413e7c20d2f
[reactos.git] / reactos / include / ddk / hdaudio.h
1 #ifndef _HDAUDIO_H_
2 #define _HDAUDIO_H_
3
4 #ifdef _MSC_VER
5 #pragma warning(disable:4201)
6 #pragma warning(disable:4214)
7 #endif
8
9 DEFINE_GUID (GUID_HDAUDIO_BUS_INTERFACE, 0xd2eaf88b, 0xab18, 0x41a8, 0xb6, 0x64, 0x8d, 0x59, 0x21, 0x67, 0x67, 0x1b);
10 DEFINE_GUID(GUID_HDAUDIO_BUS_INTERFACE_BDL, 0xb4d65397, 0x5634, 0x40b0, 0xb0, 0x68, 0xf5, 0xb9, 0xf8, 0xb9, 0x67, 0xa5);
11 DEFINE_GUID (GUID_HDAUDIO_BUS_INTERFACE_V2, 0xb52af5fb, 0x424b, 0x4bb9, 0xa1, 0x60, 0x5b, 0x38, 0xbe, 0x94, 0xe5, 0x68);
12 DEFINE_GUID (GUID_HDAUDIO_BUS_CLASS, 0xbbd1a745, 0xadd6, 0x4575, 0x9c, 0x2e, 0x9b, 0x42, 0x8d, 0x1c, 0x32, 0x66);
13
14 #ifndef _HDAUDIO_CODEC_TRANSFER_
15 #define _HDAUDIO_CODEC_TRANSFER_
16
17 typedef struct _HDAUDIO_CODEC_COMMAND
18 {
19 union
20 {
21 struct
22 {
23 ULONG Data : 8;
24 ULONG VerbId : 12;
25 ULONG Node : 8;
26 ULONG CodecAddress : 4;
27 } Verb8;
28 struct
29 {
30 ULONG Data : 16;
31 ULONG VerbId : 4;
32 ULONG Node : 8;
33 ULONG CodecAddress : 4;
34 } Verb16;
35 ULONG Command;
36 };
37 } HDAUDIO_CODEC_COMMAND, *PHDAUDIO_CODEC_COMMAND;
38
39 typedef struct _HDAUDIO_CODEC_RESPONSE
40 {
41 union
42 {
43 struct
44 {
45 union
46 {
47 struct
48 {
49 ULONG Response : 26;
50 ULONG Tag : 6;
51 } Unsolicited;
52 ULONG Response;
53 };
54 ULONG SDataIn : 4;
55 ULONG IsUnsolicitedResponse : 1;
56 ULONG :25;
57 ULONG HasFifoOverrun : 1;
58 ULONG IsValid : 1;
59 };
60 ULONGLONG CompleteResponse;
61 };
62 } HDAUDIO_CODEC_RESPONSE, *PHDAUDIO_CODEC_RESPONSE;
63
64 typedef struct _HDAUDIO_CODEC_TRANSFER
65 {
66 HDAUDIO_CODEC_COMMAND Output;
67 HDAUDIO_CODEC_RESPONSE Input;
68 } HDAUDIO_CODEC_TRANSFER, *PHDAUDIO_CODEC_TRANSFER;
69 #endif
70
71 typedef struct _HDAUDIO_STREAM_FORMAT
72 {
73 ULONG SampleRate;
74 USHORT ValidBitsPerSample;
75 USHORT ContainerSize;
76 USHORT NumberOfChannels;
77 } HDAUDIO_STREAM_FORMAT, *PHDAUDIO_STREAM_FORMAT;
78
79 typedef struct _HDAUDIO_CONVERTER_FORMAT
80 {
81 union
82 {
83 struct
84 {
85 USHORT NumberOfChannels : 4;
86 USHORT BitsPerSample : 3;
87 USHORT : 1;
88 USHORT SampleRate : 7;
89 USHORT StreamType : 1;
90 };
91 USHORT ConverterFormat;
92 };
93 } HDAUDIO_CONVERTER_FORMAT, *PHDAUDIO_CONVERTER_FORMAT;
94
95 typedef enum _HDAUDIO_STREAM_STATE
96 {
97 ResetState = 0,
98 StopState = 1,
99 PauseState = 1,
100 RunState = 2
101 } HDAUDIO_STREAM_STATE, *PHDAUDIO_STREAM_STATE;
102
103 typedef VOID (*PHDAUDIO_TRANSFER_COMPLETE_CALLBACK)(HDAUDIO_CODEC_TRANSFER *, PVOID);
104
105 typedef VOID (*PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK)(HDAUDIO_CODEC_RESPONSE, PVOID);
106
107 typedef struct _HDAUDIO_DEVICE_INFORMATION
108 {
109 USHORT Size; // size of this structure
110 USHORT DeviceVersion; // maj.min (maj is high byte, min is low byte)
111 USHORT DriverVersion; // maj.min (maj is high byte, min is low byte)
112 USHORT CodecsDetected; // mask of codecs present. Bit number == SDI line number
113 BOOLEAN IsStripingSupported; // TRUE if striping (2 SDO lines) is supported
114 } HDAUDIO_DEVICE_INFORMATION, *PHDAUDIO_DEVICE_INFORMATION;
115
116 typedef struct _HDAUDIO_BUFFER_DESCRIPTOR
117 {
118 PHYSICAL_ADDRESS Address;
119 ULONG Length;
120 ULONG InterruptOnCompletion;
121 } HDAUDIO_BUFFER_DESCRIPTOR, *PHDAUDIO_BUFFER_DESCRIPTOR;
122
123
124 typedef NTSTATUS (*PTRANSFER_CODEC_VERBS) (IN PVOID _context, IN ULONG Count, IN OUT PHDAUDIO_CODEC_TRANSFER CodecTransfer, IN PHDAUDIO_TRANSFER_COMPLETE_CALLBACK Callback, IN PVOID Context);
125 typedef NTSTATUS (*PALLOCATE_CAPTURE_DMA_ENGINE) (IN PVOID _context, IN UCHAR CodecAddress, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHANDLE Handle, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat);
126 typedef NTSTATUS (*PALLOCATE_RENDER_DMA_ENGINE) (IN PVOID _context, IN PHDAUDIO_STREAM_FORMAT StreamFormat, IN BOOLEAN Stripe, OUT PHANDLE Handle, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat);
127 typedef NTSTATUS (*PCHANGE_BANDWIDTH_ALLOCATION) (IN PVOID _context, IN HANDLE Handle, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat);
128 typedef NTSTATUS (*PALLOCATE_DMA_BUFFER) (IN PVOID _context, IN HANDLE Handle, IN SIZE_T RequestedBufferSize, OUT PMDL *BufferMdl, OUT PSIZE_T AllocatedBufferSize, OUT PUCHAR StreamId, OUT PULONG FifoSize);
129 typedef NTSTATUS (*PFREE_DMA_BUFFER) (IN PVOID _context, IN HANDLE Handle);
130 typedef NTSTATUS (*PFREE_DMA_ENGINE) (IN PVOID _context, IN HANDLE Handle);
131 typedef NTSTATUS (*PSET_DMA_ENGINE_STATE) (IN PVOID _context, IN HDAUDIO_STREAM_STATE StreamState, IN ULONG NumberOfHandles, IN PHANDLE Handles);
132 typedef VOID (*PGET_WALL_CLOCK_REGISTER) (IN PVOID _context, OUT PULONG *Wallclock);
133 typedef NTSTATUS (*PGET_LINK_POSITION_REGISTER) (IN PVOID _context, IN HANDLE Handle, OUT PULONG *Position);
134 typedef NTSTATUS (*PREGISTER_EVENT_CALLBACK) (IN PVOID _context, IN PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine, IN PVOID Context, OUT PUCHAR Tag);
135 typedef NTSTATUS (*PUNREGISTER_EVENT_CALLBACK) (IN PVOID _context, IN UCHAR Tag);
136 typedef NTSTATUS (*PGET_DEVICE_INFORMATION) (IN PVOID _context, IN OUT PHDAUDIO_DEVICE_INFORMATION DeviceInformation);
137 typedef VOID (*PGET_RESOURCE_INFORMATION) (IN PVOID _context, OUT PUCHAR CodecAddress, OUT PUCHAR FunctionGroupStartNode);
138
139 typedef struct _HDAUDIO_BUS_INTERFACE
140 {
141 USHORT Size;
142 USHORT Version;
143 PVOID Context;
144 PINTERFACE_REFERENCE InterfaceReference;
145 PINTERFACE_DEREFERENCE InterfaceDereference;
146
147 PTRANSFER_CODEC_VERBS TransferCodecVerbs;
148 PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine;
149 PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine;
150 PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation;
151 PALLOCATE_DMA_BUFFER AllocateDmaBuffer;
152 PFREE_DMA_BUFFER FreeDmaBuffer;
153 PFREE_DMA_ENGINE FreeDmaEngine;
154 PSET_DMA_ENGINE_STATE SetDmaEngineState;
155 PGET_WALL_CLOCK_REGISTER GetWallClockRegister;
156 PGET_LINK_POSITION_REGISTER GetLinkPositionRegister;
157 PREGISTER_EVENT_CALLBACK RegisterEventCallback;
158 PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback;
159 PGET_DEVICE_INFORMATION GetDeviceInformation;
160 PGET_RESOURCE_INFORMATION GetResourceInformation;
161 } HDAUDIO_BUS_INTERFACE, *PHDAUDIO_BUS_INTERFACE;
162
163 typedef void (*PHDAUDIO_BDL_ISR) (IN VOID *Context, IN ULONG InterruptBitMask);
164
165 typedef NTSTATUS (*PALLOCATE_CONTIGUOUS_DMA_BUFFER) (IN PVOID _context, IN HANDLE Handle,
166 ULONG RequestedBufferSize, OUT PVOID *DataBuffer, OUT PHDAUDIO_BUFFER_DESCRIPTOR *BdlBuffer);
167 typedef NTSTATUS (*PFREE_CONTIGUOUS_DMA_BUFFER) (IN PVOID _context, IN HANDLE Handle);
168 typedef NTSTATUS (*PSETUP_DMA_ENGINE_WITH_BDL) (IN PVOID _context, IN HANDLE Handle, IN ULONG BufferLength,
169 IN ULONG Lvi, IN PHDAUDIO_BDL_ISR Isr, IN PVOID Context, OUT PUCHAR StreamId, OUT PULONG FifoSize);
170
171 typedef struct _HDAUDIO_BUS_INTERFACE_BDL
172 {
173 USHORT Size;
174 USHORT Version;
175 PVOID Context;
176 PINTERFACE_REFERENCE InterfaceReference;
177 PINTERFACE_DEREFERENCE InterfaceDereference;
178
179 PTRANSFER_CODEC_VERBS TransferCodecVerbs;
180 PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine;
181 PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine;
182 PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation;
183 PALLOCATE_CONTIGUOUS_DMA_BUFFER AllocateContiguousDmaBuffer;
184 PSETUP_DMA_ENGINE_WITH_BDL SetupDmaEngineWithBdl;
185 PFREE_CONTIGUOUS_DMA_BUFFER FreeContiguousDmaBuffer;
186 PFREE_DMA_ENGINE FreeDmaEngine;
187 PSET_DMA_ENGINE_STATE SetDmaEngineState;
188 PGET_WALL_CLOCK_REGISTER GetWallClockRegister;
189 PGET_LINK_POSITION_REGISTER GetLinkPositionRegister;
190 PREGISTER_EVENT_CALLBACK RegisterEventCallback;
191 PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback;
192 PGET_DEVICE_INFORMATION GetDeviceInformation;
193 PGET_RESOURCE_INFORMATION GetResourceInformation;
194 } HDAUDIO_BUS_INTERFACE_BDL, *PHDAUDIO_BUS_INTERFACE_BDL;
195
196 typedef NTSTATUS (*PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION) (IN PVOID _context,
197 IN HANDLE Handle,
198 IN ULONG NotificationCount,
199 IN SIZE_T RequestedBufferSize,
200 OUT PMDL *BufferMdl,
201 OUT PSIZE_T AllocatedBufferSize,
202 OUT PSIZE_T OffsetFromFirstPage,
203 OUT PUCHAR StreamId,
204 OUT PULONG FifoSize);
205
206 typedef NTSTATUS (*PFREE_DMA_BUFFER_WITH_NOTIFICATION) (IN PVOID _context,
207 IN HANDLE Handle,
208 IN PMDL BufferMdl,
209 IN SIZE_T BufferSize);
210
211 typedef NTSTATUS (*PREGISTER_NOTIFICATION_EVENT) (IN PVOID _context,
212 IN HANDLE Handle,
213 IN PKEVENT NotificationEvent);
214
215 typedef NTSTATUS (*PUNREGISTER_NOTIFICATION_EVENT) (IN PVOID _context,
216 IN HANDLE Handle,
217 IN PKEVENT NotificationEvent);
218
219 typedef struct _HDAUDIO_BUS_INTERFACE_V2
220 {
221 USHORT Size;
222 USHORT Version;
223 PVOID Context;
224 PINTERFACE_REFERENCE InterfaceReference;
225 PINTERFACE_DEREFERENCE InterfaceDereference;
226
227 PTRANSFER_CODEC_VERBS TransferCodecVerbs;
228 PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine;
229 PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine;
230 PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation;
231 PALLOCATE_DMA_BUFFER AllocateDmaBuffer;
232 PFREE_DMA_BUFFER FreeDmaBuffer;
233 PFREE_DMA_ENGINE FreeDmaEngine;
234 PSET_DMA_ENGINE_STATE SetDmaEngineState;
235 PGET_WALL_CLOCK_REGISTER GetWallClockRegister;
236 PGET_LINK_POSITION_REGISTER GetLinkPositionRegister;
237 PREGISTER_EVENT_CALLBACK RegisterEventCallback;
238 PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback;
239 PGET_DEVICE_INFORMATION GetDeviceInformation;
240 PGET_RESOURCE_INFORMATION GetResourceInformation;
241 PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION AllocateDmaBufferWithNotification;
242 PFREE_DMA_BUFFER_WITH_NOTIFICATION FreeDmaBufferWithNotification;
243 PREGISTER_NOTIFICATION_EVENT RegisterNotificationEvent;
244 PUNREGISTER_NOTIFICATION_EVENT UnregisterNotificationEvent;
245 } HDAUDIO_BUS_INTERFACE_V2, *PHDAUDIO_BUS_INTERFACE_V2;
246
247 #ifdef _MSC_VER
248 #pragma warning(default:4201)
249 #pragma warning(default:4214)
250 #endif
251
252 #endif // _HDAUDIO_H_
253