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