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