6bdbc542f44abd575d2926edfcc04d4bb2b3a52a
[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
57 PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS];
58 ULONG AudioGroupCount;
59
60 }HDA_CODEC_ENTRY, *PHDA_CODEC_ENTRY;
61
62
63 typedef struct
64 {
65 BOOLEAN IsFDO;
66 PDEVICE_OBJECT LowerDevice;
67
68 PUCHAR RegBase;
69 SIZE_T RegLength;
70 PKINTERRUPT Interrupt;
71
72 ULONG CorbLength;
73 PULONG CorbBase;
74 ULONG RirbLength;
75 PRIRB_RESPONSE RirbBase;
76 ULONG RirbReadPos;
77 ULONG CorbWritePos;
78 PVOID StreamPositions;
79
80 PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS + 1];
81
82 }HDA_FDO_DEVICE_EXTENSION, *PHDA_FDO_DEVICE_EXTENSION;
83
84 typedef struct
85 {
86 BOOLEAN IsFDO;
87 BOOLEAN ReportedMissing;
88 PHDA_CODEC_ENTRY Codec;
89 PHDA_CODEC_AUDIO_GROUP AudioGroup;
90 PDEVICE_OBJECT FDO;
91 }HDA_PDO_DEVICE_EXTENSION, *PHDA_PDO_DEVICE_EXTENSION;
92
93
94 typedef struct {
95 ULONG device : 16;
96 ULONG vendor : 16;
97 ULONG stepping : 8;
98 ULONG revision : 8;
99 ULONG minor : 4;
100 ULONG major : 4;
101 ULONG _reserved0 : 8;
102 ULONG count : 8;
103 ULONG _reserved1 : 8;
104 ULONG start : 8;
105 ULONG _reserved2 : 8;
106 }CODEC_RESPONSE, *PCODEC_RESPONSE;
107
108
109 PVOID
110 AllocateItem(
111 IN POOL_TYPE PoolType,
112 IN SIZE_T NumberOfBytes);
113
114 VOID
115 FreeItem(
116 IN PVOID Item);
117
118 /* fdo.cpp */
119 KSERVICE_ROUTINE HDA_InterruptService;
120 IO_DPC_ROUTINE HDA_DpcForIsr;
121
122 NTSTATUS
123 NTAPI
124 HDA_FDOStartDevice(
125 IN PDEVICE_OBJECT DeviceObject,
126 IN PIRP Irp);
127
128 NTSTATUS
129 NTAPI
130 HDA_FDORemoveDevice(
131 _In_ PDEVICE_OBJECT DeviceObject,
132 _Inout_ PIRP Irp);
133
134 NTSTATUS
135 NTAPI
136 HDA_FDOQueryBusRelations(
137 IN PDEVICE_OBJECT DeviceObject,
138 IN PIRP Irp);
139
140 VOID
141 HDA_SendVerbs(
142 IN PDEVICE_OBJECT DeviceObject,
143 IN PHDA_CODEC_ENTRY Codec,
144 IN PULONG Verbs,
145 OUT PULONG Responses,
146 IN ULONG Count);
147
148 /* pdo.cpp*/
149
150 NTSTATUS
151 HDA_PDORemoveDevice(
152 _In_ PDEVICE_OBJECT DeviceObject);
153
154 NTSTATUS
155 HDA_PDOQueryBusInformation(
156 IN PIRP Irp);
157
158 NTSTATUS
159 NTAPI
160 HDA_PDOQueryId(
161 IN PDEVICE_OBJECT DeviceObject,
162 IN PIRP Irp);
163
164 NTSTATUS
165 HDA_PDOHandleQueryDeviceText(
166 IN PIRP Irp);
167
168 NTSTATUS
169 HDA_PDOQueryBusDeviceCapabilities(
170 IN PIRP Irp);
171
172 NTSTATUS
173 HDA_PDOQueryBusDevicePnpState(
174 IN PIRP Irp);
175
176 /* businterface.cpp */
177
178 NTSTATUS
179 HDA_PDOHandleQueryInterface(
180 IN PDEVICE_OBJECT DeviceObject,
181 IN PIRP Irp);