[HDAUDBUS] Wait until the correct number of responses was received. CORE-15465
[reactos.git] / drivers / wdm / audio / hdaudbus / hdaudbus.h
1 #pragma once
2
3 #define YDEBUG
4 #include <ntddk.h>
5 #include <debug.h>
6 #include <initguid.h>
7 #include <hdaudio.h>
8 #include <stdio.h>
9
10 #define TAG_HDA 'bADH'
11
12
13 // include Haiku headers
14 #include "driver.h"
15
16 #define MAKE_RATE(base, multiply, divide) \
17 ((base == 44100 ? FORMAT_44_1_BASE_RATE : 0) \
18 | ((multiply - 1) << FORMAT_MULTIPLY_RATE_SHIFT) \
19 | ((divide - 1) << FORMAT_DIVIDE_RATE_SHIFT))
20
21 #define HDAC_INPUT_STREAM_OFFSET(index) \
22 ((index) * HDAC_STREAM_SIZE)
23 #define HDAC_OUTPUT_STREAM_OFFSET(num_input_streams, index) \
24 ((num_input_streams + (index)) * HDAC_STREAM_SIZE)
25 #define HDAC_BIDIR_STREAM_OFFSET(num_input_streams, num_output_streams, index) \
26 ((num_input_streams + num_output_streams \
27 + (index)) * HDAC_STREAM_SIZE)
28
29 #define ALIGN(size, align) (((size) + align - 1) & ~(align - 1))
30
31
32 typedef struct {
33 ULONG response;
34 ULONG flags;
35 }RIRB_RESPONSE, *PRIRB_RESPONSE;
36
37 typedef struct
38 {
39 PDEVICE_OBJECT ChildPDO;
40 ULONG FunctionGroup;
41 ULONG NodeId;
42 }HDA_CODEC_AUDIO_GROUP, *PHDA_CODEC_AUDIO_GROUP;
43
44 typedef struct
45 {
46 USHORT VendorId;
47 USHORT ProductId;
48 UCHAR Major;
49 UCHAR Minor;
50 UCHAR Revision;
51 UCHAR Stepping;
52 UCHAR Addr;
53
54 ULONG Responses[MAX_CODEC_RESPONSES];
55 ULONG ResponseCount;
56 KSEMAPHORE ResponseSemaphore;
57
58 PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS];
59 ULONG AudioGroupCount;
60
61 }HDA_CODEC_ENTRY, *PHDA_CODEC_ENTRY;
62
63
64 typedef struct
65 {
66 BOOLEAN IsFDO;
67 PDEVICE_OBJECT LowerDevice;
68
69 PUCHAR RegBase;
70 SIZE_T RegLength;
71 PKINTERRUPT Interrupt;
72
73 ULONG CorbLength;
74 PULONG CorbBase;
75 ULONG RirbLength;
76 PRIRB_RESPONSE RirbBase;
77 ULONG RirbReadPos;
78 ULONG CorbWritePos;
79 PVOID StreamPositions;
80
81 PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS + 1];
82
83 }HDA_FDO_DEVICE_EXTENSION, *PHDA_FDO_DEVICE_EXTENSION;
84
85 typedef struct
86 {
87 BOOLEAN IsFDO;
88 BOOLEAN ReportedMissing;
89 PHDA_CODEC_ENTRY Codec;
90 PHDA_CODEC_AUDIO_GROUP AudioGroup;
91 PDEVICE_OBJECT FDO;
92 }HDA_PDO_DEVICE_EXTENSION, *PHDA_PDO_DEVICE_EXTENSION;
93
94
95 typedef struct {
96 ULONG device : 16;
97 ULONG vendor : 16;
98 ULONG stepping : 8;
99 ULONG revision : 8;
100 ULONG minor : 4;
101 ULONG major : 4;
102 ULONG _reserved0 : 8;
103 ULONG count : 8;
104 ULONG _reserved1 : 8;
105 ULONG start : 8;
106 ULONG _reserved2 : 8;
107 }CODEC_RESPONSE, *PCODEC_RESPONSE;
108
109
110 PVOID
111 AllocateItem(
112 IN POOL_TYPE PoolType,
113 IN SIZE_T NumberOfBytes);
114
115 VOID
116 FreeItem(
117 IN PVOID Item);
118
119 /* fdo.cpp */
120 KSERVICE_ROUTINE HDA_InterruptService;
121 IO_DPC_ROUTINE HDA_DpcForIsr;
122
123 NTSTATUS
124 NTAPI
125 HDA_FDOStartDevice(
126 IN PDEVICE_OBJECT DeviceObject,
127 IN PIRP Irp);
128
129 NTSTATUS
130 NTAPI
131 HDA_FDORemoveDevice(
132 _In_ PDEVICE_OBJECT DeviceObject,
133 _Inout_ PIRP Irp);
134
135 NTSTATUS
136 NTAPI
137 HDA_FDOQueryBusRelations(
138 IN PDEVICE_OBJECT DeviceObject,
139 IN PIRP Irp);
140
141 VOID
142 HDA_SendVerbs(
143 IN PDEVICE_OBJECT DeviceObject,
144 IN PHDA_CODEC_ENTRY Codec,
145 IN PULONG Verbs,
146 OUT PULONG Responses,
147 IN ULONG Count);
148
149 /* pdo.cpp*/
150
151 NTSTATUS
152 HDA_PDORemoveDevice(
153 _In_ PDEVICE_OBJECT DeviceObject);
154
155 NTSTATUS
156 HDA_PDOQueryBusInformation(
157 IN PIRP Irp);
158
159 NTSTATUS
160 NTAPI
161 HDA_PDOQueryId(
162 IN PDEVICE_OBJECT DeviceObject,
163 IN PIRP Irp);
164
165 NTSTATUS
166 HDA_PDOHandleQueryDeviceText(
167 IN PIRP Irp);
168
169 NTSTATUS
170 HDA_PDOQueryBusDeviceCapabilities(
171 IN PIRP Irp);
172
173 NTSTATUS
174 HDA_PDOQueryBusDevicePnpState(
175 IN PIRP Irp);
176
177 /* businterface.cpp */
178
179 NTSTATUS
180 HDA_PDOHandleQueryInterface(
181 IN PDEVICE_OBJECT DeviceObject,
182 IN PIRP Irp);