ed8b45ced1c07baaf2e55c07cb888bb37c315507
[reactos.git] / reactos / drivers / wdm / audio / backpln / portcls / private.hpp
1 /*
2 PortCls FDO Extension
3
4 by Andrew Greenwood
5 */
6
7 #ifndef PORTCLS_PRIVATE_H
8 #define PORTCLS_PRIVATE_H
9
10 //#define _KS_NO_ANONYMOUS_STRUCTURES_
11 #define PC_IMPLEMENTATION
12
13 #include <ntddk.h>
14 #include <portcls.h>
15 #define NDEBUG
16 #include <debug.h>
17
18 #include <dmusicks.h>
19 #include <kcom.h>
20 #include "interfaces.hpp"
21 #include <ks.h>
22 #include <ksmedia.h>
23 #include <intrin.h>
24
25 #define TAG_PORTCLASS 'SLCP'
26
27 #define PC_ASSERT(exp) \
28 (VOID)((!(exp)) ? \
29 RtlAssert((PVOID) #exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
30
31 #define PC_ASSERT_IRQL(x) PC_ASSERT(KeGetCurrentIrql() <= (x))
32 #define PC_ASSERT_IRQL_EQUAL(x) PC_ASSERT(KeGetCurrentIrql()==(x))
33
34 extern
35 "C"
36 NTSTATUS
37 NTAPI
38 PortClsCreate(
39 IN PDEVICE_OBJECT DeviceObject,
40 IN PIRP Irp);
41
42 extern
43 "C"
44 NTSTATUS
45 NTAPI
46 PortClsPnp(
47 IN PDEVICE_OBJECT DeviceObject,
48 IN PIRP Irp);
49
50 extern
51 "C"
52 NTSTATUS
53 NTAPI
54 PortClsPower(
55 IN PDEVICE_OBJECT DeviceObject,
56 IN PIRP Irp);
57
58 extern
59 "C"
60 NTSTATUS
61 NTAPI
62 PortClsSysControl(
63 IN PDEVICE_OBJECT DeviceObject,
64 IN PIRP Irp);
65
66 NTSTATUS
67 NewMiniportDMusUART(
68 OUT PMINIPORT* OutMiniport,
69 IN REFCLSID ClassId);
70
71 NTSTATUS
72 NewMiniportFmSynth(
73 OUT PMINIPORT* OutMiniport,
74 IN REFCLSID ClassId);
75
76 NTSTATUS
77 NewPortDMus(
78 OUT PPORT* OutPort);
79
80 NTSTATUS
81 NewPortTopology(
82 OUT PPORT* OutPort);
83
84 NTSTATUS
85 NewPortWaveCyclic(
86 OUT PPORT* OutPort);
87
88 NTSTATUS
89 NewPortWavePci(
90 OUT PPORT* OutPort);
91
92 NTSTATUS
93 NewIDrmPort(
94 OUT PDRMPORT2 *OutPort);
95
96 NTSTATUS
97 NewPortClsVersion(
98 OUT PPORTCLSVERSION * OutVersion);
99
100 NTSTATUS
101 NewPortFilterWaveCyclic(
102 OUT IPortFilterWaveCyclic ** OutFilter);
103
104 NTSTATUS
105 NewPortPinWaveCyclic(
106 OUT IPortPinWaveCyclic ** OutPin);
107
108 NTSTATUS
109 NewPortFilterWavePci(
110 OUT IPortFilterWavePci ** OutFilter);
111
112 NTSTATUS
113 NewPortPinWavePci(
114 OUT IPortPinWavePci ** OutPin);
115
116 PDEVICE_OBJECT
117 GetDeviceObjectFromWaveCyclic(
118 IPortWavePci* iface);
119
120 PDEVICE_OBJECT
121 GetDeviceObjectFromPortWavePci(
122 IPortWavePci* iface);
123
124 PMINIPORTWAVEPCI
125 GetWavePciMiniport(
126 PPORTWAVEPCI Port);
127
128
129 NTSTATUS
130 NewPortFilterDMus(
131 OUT PPORTFILTERDMUS * OutFilter);
132
133
134 NTSTATUS
135 NewPortPinDMus(
136 OUT PPORTPINDMUS * OutPin);
137
138 VOID
139 GetDMusMiniport(
140 IN IPortDMus * iface,
141 IN PMINIPORTDMUS * Miniport,
142 IN PMINIPORTMIDI * MidiMiniport);
143
144 #if (NTDDI_VERSION >= NTDDI_VISTA)
145
146 NTSTATUS
147 NewPortFilterWaveRT(
148 OUT IPortFilterWaveRT ** OutFilter);
149
150 NTSTATUS
151 NewPortPinWaveRT(
152 OUT IPortPinWaveRT ** OutPin);
153
154 PMINIPORTWAVERT
155 GetWaveRTMiniport(
156 IN IPortWaveRT* iface);
157
158 PDEVICE_OBJECT
159 GetDeviceObjectFromPortWaveRT(
160 IPortWaveRT* iface);
161
162
163 NTSTATUS
164 NewPortWaveRTStream(
165 PPORTWAVERTSTREAM *OutStream);
166
167 NTSTATUS
168 NewPortWaveRT(
169 OUT PPORT* OutPort);
170
171
172 #endif
173
174 NTSTATUS
175 NewPortFilterTopology(
176 OUT IPortFilterTopology ** OutFilter);
177
178 PMINIPORTTOPOLOGY
179 GetTopologyMiniport(
180 PPORTTOPOLOGY Port);
181
182 NTSTATUS
183 NTAPI
184 NewDispatchObject(
185 IN PIRP Irp,
186 IN IIrpTarget * Target,
187 IN ULONG ObjectCreateItemCount,
188 IN PKSOBJECT_CREATE_ITEM ObjectCreateItem);
189
190 PMINIPORTWAVECYCLIC
191 GetWaveCyclicMiniport(
192 IN IPortWaveCyclic* iface);
193
194 PVOID
195 AllocateItem(
196 IN POOL_TYPE PoolType,
197 IN SIZE_T NumberOfBytes,
198 IN ULONG Tag);
199
200 VOID
201 FreeItem(
202 IN PVOID Item,
203 IN ULONG Tag);
204
205 NTSTATUS
206 NTAPI
207 NewIrpQueue(
208 IN IIrpQueue **Queue);
209
210 NTSTATUS
211 NTAPI
212 TopologyPropertyHandler(
213 IN PIRP Irp,
214 IN PKSIDENTIFIER Request,
215 IN OUT PVOID Data);
216
217 NTSTATUS
218 NTAPI
219 PinPropertyHandler(
220 IN PIRP Irp,
221 IN PKSIDENTIFIER Request,
222 IN OUT PVOID Data);
223
224 extern
225 "C"
226 NTSTATUS
227 NTAPI
228 PcDmaMasterDescription(
229 IN PRESOURCELIST ResourceList OPTIONAL,
230 IN BOOLEAN ScatterGather,
231 IN BOOLEAN Dma32BitAddresses,
232 IN BOOLEAN IgnoreCount,
233 IN BOOLEAN Dma64BitAddresses,
234 IN DMA_WIDTH DmaWidth,
235 IN DMA_SPEED DmaSpeed,
236 IN ULONG MaximumLength,
237 IN ULONG DmaPort,
238 OUT PDEVICE_DESCRIPTION DeviceDescription);
239
240 extern
241 "C"
242 NTSTATUS
243 NTAPI
244 PcDmaSlaveDescription(
245 IN PRESOURCELIST ResourceList OPTIONAL,
246 IN ULONG DmaIndex,
247 IN BOOL DemandMode,
248 IN ULONG AutoInitialize,
249 IN DMA_SPEED DmaSpeed,
250 IN ULONG MaximumLength,
251 IN ULONG DmaPort,
252 OUT PDEVICE_DESCRIPTION DeviceDescription);
253
254 extern
255 "C"
256 NTSTATUS
257 NTAPI
258 PcCreateSubdeviceDescriptor(
259 OUT SUBDEVICE_DESCRIPTOR ** OutSubdeviceDescriptor,
260 IN ULONG InterfaceCount,
261 IN GUID * InterfaceGuids,
262 IN ULONG IdentifierCount,
263 IN KSIDENTIFIER *Identifier,
264 IN ULONG FilterPropertiesCount,
265 IN KSPROPERTY_SET * FilterProperties,
266 IN ULONG Unknown1,
267 IN ULONG Unknown2,
268 IN ULONG PinPropertiesCount,
269 IN KSPROPERTY_SET * PinProperties,
270 IN ULONG EventSetCount,
271 IN KSEVENT_SET * EventSet,
272 IN PPCFILTER_DESCRIPTOR FilterDescription);
273
274 extern
275 "C"
276 NTSTATUS
277 NTAPI
278 PcValidateConnectRequest(
279 IN PIRP Irp,
280 IN KSPIN_FACTORY * Descriptor,
281 OUT PKSPIN_CONNECT* Connect);
282
283 NTSTATUS
284 NTAPI
285 PcCreateItemDispatch(
286 IN PDEVICE_OBJECT DeviceObject,
287 IN PIRP Irp);
288
289 PDEVICE_OBJECT
290 GetDeviceObject(
291 IPortWaveCyclic* iface);
292
293 VOID
294 NTAPI
295 PcIoTimerRoutine(
296 IN PDEVICE_OBJECT DeviceObject,
297 IN PVOID Context);
298
299 NTSTATUS
300 NTAPI
301 NewIUnregisterSubdevice(
302 OUT PUNREGISTERSUBDEVICE *OutDevice);
303
304 NTSTATUS
305 NTAPI
306 NewIUnregisterPhysicalConnection(
307 OUT PUNREGISTERPHYSICALCONNECTION *OutConnection);
308
309 NTSTATUS
310 NTAPI
311 PcHandlePropertyWithTable(
312 IN PIRP Irp,
313 IN ULONG PropertySetCount,
314 IN PKSPROPERTY_SET PropertySet,
315 IN PSUBDEVICE_DESCRIPTOR Descriptor);
316
317 #define DEFINE_KSPROPERTY_CONNECTIONSET(PinSet,\
318 PropStateHandler, PropDataFormatHandler)\
319 DEFINE_KSPROPERTY_TABLE(PinSet) {\
320 DEFINE_KSPROPERTY_ITEM_CONNECTION_STATE(PropStateHandler, PropStateHandler),\
321 DEFINE_KSPROPERTY_ITEM_CONNECTION_DATAFORMAT(PropDataFormatHandler, PropDataFormatHandler)\
322 }
323
324 #define DEFINE_KSPROPERTY_ITEM_AUDIO_POSITION(GetHandler, SetHandler)\
325 DEFINE_KSPROPERTY_ITEM(\
326 KSPROPERTY_AUDIO_POSITION,\
327 (GetHandler),\
328 sizeof(KSPROPERTY),\
329 sizeof(KSAUDIO_POSITION),\
330 (SetHandler),\
331 NULL, 0, NULL, NULL, 0)
332
333 #define DEFINE_KSPROPERTY_AUDIOSET(PinSet,\
334 PropPositionHandler)\
335 DEFINE_KSPROPERTY_TABLE(PinSet) {\
336 DEFINE_KSPROPERTY_ITEM_AUDIO_POSITION(PropPositionHandler, PropPositionHandler)\
337 }
338
339
340
341
342 #define DEFINE_KSPROPERTY_PINPROPOSEDATAFORMAT(PinSet,\
343 PropGeneral, PropInstances, PropIntersection)\
344 DEFINE_KSPROPERTY_TABLE(PinSet) {\
345 DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(PropInstances),\
346 DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(PropGeneral),\
347 DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(PropGeneral),\
348 DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(PropGeneral),\
349 DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(PropIntersection),\
350 DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(PropGeneral),\
351 DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(PropGeneral),\
352 DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(PropGeneral),\
353 DEFINE_KSPROPERTY_ITEM_PIN_GLOBALCINSTANCES(PropGeneral),\
354 DEFINE_KSPROPERTY_ITEM_PIN_NECESSARYINSTANCES(PropGeneral),\
355 DEFINE_KSPROPERTY_ITEM_PIN_PHYSICALCONNECTION(PropGeneral),\
356 DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(PropGeneral),\
357 DEFINE_KSPROPERTY_ITEM_PIN_NAME(PropGeneral),\
358 DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES(PropGeneral),\
359 DEFINE_KSPROPERTY_ITEM_PIN_PROPOSEDATAFORMAT(PropGeneral)\
360 }
361
362 typedef struct
363 {
364 KSDEVICE_HEADER KsDeviceHeader;
365 PDEVICE_OBJECT PhysicalDeviceObject;
366 PDEVICE_OBJECT PrevDeviceObject;
367 PCPFNSTARTDEVICE StartDevice;
368 ULONG_PTR Unused[4];
369 IAdapterPowerManagement * AdapterPowerManagement;
370 ULONG MaxSubDevices;
371 KSOBJECT_CREATE_ITEM * CreateItems;
372
373 IResourceList* resources;
374
375 LIST_ENTRY TimerList;
376 KSPIN_LOCK TimerListLock;
377
378 } PCLASS_DEVICE_EXTENSION, *PPCLASS_DEVICE_EXTENSION;
379
380
381 typedef struct
382 {
383 PVOID Pin;
384 PIO_WORKITEM WorkItem;
385 PIRP Irp;
386 }CLOSESTREAM_CONTEXT, *PCLOSESTREAM_CONTEXT;
387
388 typedef struct
389 {
390 LIST_ENTRY Entry;
391 PIO_TIMER_ROUTINE pTimerRoutine;
392 PVOID Context;
393 }TIMER_CONTEXT, *PTIMER_CONTEXT;
394
395 #endif