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