Sync with trunk (r48545)
[reactos.git] / include / ddk / strmini.h
1 #ifndef _STREAM_H
2 #define _STREAM_H
3
4 #include <ntddk.h>
5 #include <windef.h>
6 #include <ks.h>
7
8 #define STREAMAPI __stdcall
9 #define STREAM_SYSTEM_TIME_MASK ((STREAM_SYSTEM_TIME)0x00000001FFFFFFFF)
10
11 typedef enum {
12 DebugLevelFatal = 0,
13 DebugLevelError,
14 DebugLevelWarning,
15 DebugLevelInfo,
16 DebugLevelTrace,
17 DebugLevelVerbose,
18 DebugLevelMaximum
19 } STREAM_DEBUG_LEVEL;
20
21 #if DBG
22
23 #define DebugPrint(x) StreamClassDebugPrint x
24 #define DEBUG_BREAKPOINT() DbgBreakPoint()
25 #define DEBUG_ASSERT(exp) \
26 if ( !(exp) ) { \
27 StreamClassDebugAssert( __FILE__, __LINE__, #exp, exp); \
28 }
29 #else
30
31 #define DebugPrint(x)
32 #define DEBUG_BREAKPOINT()
33 #define DEBUG_ASSERT(exp)
34
35 #endif
36
37 typedef PHYSICAL_ADDRESS STREAM_PHYSICAL_ADDRESS, *PSTREAM_PHYSICAL_ADDRESS;
38 __GNU_EXTENSION typedef unsigned __int64 STREAM_SYSTEM_TIME, *PSTREAM_SYSTEM_TIME;
39 __GNU_EXTENSION typedef unsigned __int64 STREAM_TIMESTAMP, *PSTREAM_TIMESTAMP;
40
41 typedef enum {
42 TIME_GET_STREAM_TIME,
43 TIME_READ_ONBOARD_CLOCK,
44 TIME_SET_ONBOARD_CLOCK
45 } TIME_FUNCTION;
46
47 typedef struct _HW_TIME_CONTEXT {
48 struct _HW_DEVICE_EXTENSION *HwDeviceExtension;
49 struct _HW_STREAM_OBJECT *HwStreamObject;
50 TIME_FUNCTION Function;
51 ULONGLONG Time;
52 ULONGLONG SystemTime;
53 } HW_TIME_CONTEXT, *PHW_TIME_CONTEXT;
54
55 typedef struct _HW_EVENT_DESCRIPTOR {
56 BOOLEAN Enable;
57 PKSEVENT_ENTRY EventEntry;
58 PKSEVENTDATA EventData;
59 __GNU_EXTENSION union {
60 struct _HW_STREAM_OBJECT * StreamObject;
61 struct _HW_DEVICE_EXTENSION *DeviceExtension;
62 };
63 ULONG EnableEventSetIndex;
64 PVOID HwInstanceExtension;
65 ULONG Reserved;
66 } HW_EVENT_DESCRIPTOR, *PHW_EVENT_DESCRIPTOR;
67
68 struct _HW_STREAM_REQUEST_BLOCK;
69
70 typedef VOID (STREAMAPI *PHW_RECEIVE_STREAM_DATA_SRB) (IN struct _HW_STREAM_REQUEST_BLOCK *SRB);
71 typedef VOID (STREAMAPI *PHW_RECEIVE_STREAM_CONTROL_SRB) (IN struct _HW_STREAM_REQUEST_BLOCK *SRB);
72 typedef NTSTATUS (STREAMAPI *PHW_EVENT_ROUTINE) (IN PHW_EVENT_DESCRIPTOR EventDescriptor);
73 typedef VOID (STREAMAPI *PHW_CLOCK_FUNCTION) (IN PHW_TIME_CONTEXT HwTimeContext);
74
75 typedef struct _HW_CLOCK_OBJECT {
76 PHW_CLOCK_FUNCTION HwClockFunction;
77 ULONG ClockSupportFlags;
78 ULONG Reserved[2];
79 } HW_CLOCK_OBJECT, *PHW_CLOCK_OBJECT;
80
81 #define CLOCK_SUPPORT_CAN_SET_ONBOARD_CLOCK 0x1
82 #define CLOCK_SUPPORT_CAN_READ_ONBOARD_CLOCK 0x2
83 #define CLOCK_SUPPORT_CAN_RETURN_STREAM_TIME 0x4
84
85 typedef struct _HW_STREAM_OBJECT {
86 ULONG SizeOfThisPacket;
87 ULONG StreamNumber;
88 PVOID HwStreamExtension;
89 PHW_RECEIVE_STREAM_DATA_SRB ReceiveDataPacket;
90 PHW_RECEIVE_STREAM_CONTROL_SRB ReceiveControlPacket;
91 HW_CLOCK_OBJECT HwClockObject;
92 BOOLEAN Dma;
93 BOOLEAN Pio;
94 PVOID HwDeviceExtension;
95 ULONG StreamHeaderMediaSpecific;
96 ULONG StreamHeaderWorkspace;
97 BOOLEAN Allocator;
98 PHW_EVENT_ROUTINE HwEventRoutine;
99 ULONG Reserved[2];
100 } HW_STREAM_OBJECT, *PHW_STREAM_OBJECT;
101
102 typedef struct _HW_STREAM_HEADER {
103 ULONG NumberOfStreams;
104 ULONG SizeOfHwStreamInformation;
105 ULONG NumDevPropArrayEntries;
106 PKSPROPERTY_SET DevicePropertiesArray;
107 ULONG NumDevEventArrayEntries;
108 PKSEVENT_SET DeviceEventsArray;
109 PKSTOPOLOGY Topology;
110 PHW_EVENT_ROUTINE DeviceEventRoutine;
111 LONG NumDevMethodArrayEntries;
112 PKSMETHOD_SET DeviceMethodsArray;
113 } HW_STREAM_HEADER, *PHW_STREAM_HEADER;
114
115 typedef struct _HW_STREAM_INFORMATION {
116 ULONG NumberOfPossibleInstances;
117 KSPIN_DATAFLOW DataFlow;
118 BOOLEAN DataAccessible;
119 ULONG NumberOfFormatArrayEntries;
120 PKSDATAFORMAT* StreamFormatsArray;
121 PVOID ClassReserved[4];
122 ULONG NumStreamPropArrayEntries;
123 PKSPROPERTY_SET StreamPropertiesArray;
124 ULONG NumStreamEventArrayEntries;
125 PKSEVENT_SET StreamEventsArray;
126 GUID* Category;
127 GUID* Name;
128 ULONG MediumsCount;
129 const KSPIN_MEDIUM* Mediums;
130 BOOLEAN BridgeStream;
131 ULONG Reserved[2];
132 } HW_STREAM_INFORMATION, *PHW_STREAM_INFORMATION;
133
134 typedef struct _HW_STREAM_DESCRIPTOR {
135 HW_STREAM_HEADER StreamHeader;
136 HW_STREAM_INFORMATION StreamInfo;
137 } HW_STREAM_DESCRIPTOR, *PHW_STREAM_DESCRIPTOR;
138
139 typedef struct _STREAM_TIME_REFERENCE {
140 STREAM_TIMESTAMP CurrentOnboardClockValue;
141 LARGE_INTEGER OnboardClockFrequency;
142 LARGE_INTEGER CurrentSystemTime;
143 ULONG Reserved[2];
144 } STREAM_TIME_REFERENCE, *PSTREAM_TIME_REFERENCE;
145
146 typedef struct _STREAM_DATA_INTERSECT_INFO {
147 ULONG StreamNumber;
148 PKSDATARANGE DataRange;
149 PVOID DataFormatBuffer;
150 ULONG SizeOfDataFormatBuffer;
151 } STREAM_DATA_INTERSECT_INFO, *PSTREAM_DATA_INTERSECT_INFO;
152
153 typedef struct _STREAM_PROPERTY_DESCRIPTOR {
154 PKSPROPERTY Property;
155 ULONG PropertySetID;
156 PVOID PropertyInfo;
157 ULONG PropertyInputSize;
158 ULONG PropertyOutputSize;
159 } STREAM_PROPERTY_DESCRIPTOR, *PSTREAM_PROPERTY_DESCRIPTOR;
160
161 typedef struct _STREAM_METHOD_DESCRIPTOR {
162 ULONG MethodSetID;
163 PKSMETHOD Method;
164 PVOID MethodInfo;
165 LONG MethodInputSize;
166 LONG MethodOutputSize;
167 } STREAM_METHOD_DESCRIPTOR, *PSTREAM_METHOD_DESCRIPTOR;
168
169 #define STREAM_REQUEST_BLOCK_SIZE sizeof(STREAM_REQUEST_BLOCK)
170
171 typedef enum _SRB_COMMAND {
172 SRB_READ_DATA,
173 SRB_WRITE_DATA,
174 SRB_GET_STREAM_STATE,
175 SRB_SET_STREAM_STATE,
176 SRB_SET_STREAM_PROPERTY,
177 SRB_GET_STREAM_PROPERTY,
178 SRB_OPEN_MASTER_CLOCK,
179
180 SRB_INDICATE_MASTER_CLOCK,
181 SRB_UNKNOWN_STREAM_COMMAND,
182 SRB_SET_STREAM_RATE,
183 SRB_PROPOSE_DATA_FORMAT,
184 SRB_CLOSE_MASTER_CLOCK,
185 SRB_PROPOSE_STREAM_RATE,
186 SRB_SET_DATA_FORMAT,
187 SRB_GET_DATA_FORMAT,
188 SRB_BEGIN_FLUSH,
189 SRB_END_FLUSH,
190
191 SRB_GET_STREAM_INFO = 0x100,
192 SRB_OPEN_STREAM,
193 SRB_CLOSE_STREAM,
194 SRB_OPEN_DEVICE_INSTANCE,
195 SRB_CLOSE_DEVICE_INSTANCE,
196 SRB_GET_DEVICE_PROPERTY,
197 SRB_SET_DEVICE_PROPERTY,
198 SRB_INITIALIZE_DEVICE,
199 SRB_CHANGE_POWER_STATE,
200 SRB_UNINITIALIZE_DEVICE,
201 SRB_UNKNOWN_DEVICE_COMMAND,
202 SRB_PAGING_OUT_DRIVER,
203 SRB_GET_DATA_INTERSECTION,
204 SRB_INITIALIZATION_COMPLETE,
205 SRB_SURPRISE_REMOVAL
206
207 #if (NTDDI_VERSION >= NTDDI_WINXP)
208 ,SRB_DEVICE_METHOD
209 ,SRB_STREAM_METHOD
210 #if ( (NTDDI_VERSION >= NTDDI_WINXPSP2) && (NTDDI_VERSION < NTDDI_WS03) ) || (NTDDI_VERSION >= NTDDI_WS03SP1)
211 ,SRB_NOTIFY_IDLE_STATE
212 #endif
213 #endif
214 } SRB_COMMAND;
215
216 typedef struct {
217 PHYSICAL_ADDRESS PhysicalAddress;
218 ULONG Length;
219 } KSSCATTER_GATHER, *PKSSCATTER_GATHER;
220
221
222 typedef struct _HW_STREAM_REQUEST_BLOCK {
223 ULONG SizeOfThisPacket;
224 SRB_COMMAND Command;
225 NTSTATUS Status;
226 PHW_STREAM_OBJECT StreamObject;
227 PVOID HwDeviceExtension;
228 PVOID SRBExtension;
229
230 union _CommandData {
231 PKSSTREAM_HEADER DataBufferArray;
232 PHW_STREAM_DESCRIPTOR StreamBuffer;
233 KSSTATE StreamState;
234 PSTREAM_TIME_REFERENCE TimeReference;
235 PSTREAM_PROPERTY_DESCRIPTOR PropertyInfo;
236 PKSDATAFORMAT OpenFormat;
237 struct _PORT_CONFIGURATION_INFORMATION *ConfigInfo;
238 HANDLE MasterClockHandle;
239 DEVICE_POWER_STATE DeviceState;
240 PSTREAM_DATA_INTERSECT_INFO IntersectInfo;
241
242 #if (NTDDI_VERSION >= NTDDI_WINXP)
243 PVOID MethodInfo;
244 LONG FilterTypeIndex;
245 #if ( (NTDDI_VERSION >= NTDDI_WINXPSP2) && (NTDDI_VERSION < NTDDI_WS03) ) || (NTDDI_VERSION >= NTDDI_WS03SP1)
246 BOOLEAN Idle;
247 #endif
248 #endif
249 } CommandData;
250
251 ULONG NumberOfBuffers;
252 ULONG TimeoutCounter;
253 ULONG TimeoutOriginal;
254 struct _HW_STREAM_REQUEST_BLOCK *NextSRB;
255
256 PIRP Irp;
257 ULONG Flags;
258 PVOID HwInstanceExtension;
259
260 __GNU_EXTENSION union {
261 ULONG NumberOfBytesToTransfer;
262 ULONG ActualBytesTransferred;
263 };
264
265 PKSSCATTER_GATHER ScatterGatherBuffer;
266 ULONG NumberOfPhysicalPages;
267 ULONG NumberOfScatterGatherElements;
268 ULONG Reserved[1];
269 } HW_STREAM_REQUEST_BLOCK, *PHW_STREAM_REQUEST_BLOCK;
270
271 #define SRB_HW_FLAGS_DATA_TRANSFER 0x01
272 #define SRB_HW_FLAGS_STREAM_REQUEST 0x2
273
274 typedef enum {
275 PerRequestExtension,
276 DmaBuffer,
277 SRBDataBuffer
278 } STREAM_BUFFER_TYPE;
279
280 typedef struct _ACCESS_RANGE {
281 STREAM_PHYSICAL_ADDRESS RangeStart;
282 ULONG RangeLength;
283 BOOLEAN RangeInMemory;
284 ULONG Reserved;
285 } ACCESS_RANGE, *PACCESS_RANGE;
286
287 typedef struct _PORT_CONFIGURATION_INFORMATION {
288 ULONG SizeOfThisPacket;
289 PVOID HwDeviceExtension;
290 PDEVICE_OBJECT ClassDeviceObject;
291 PDEVICE_OBJECT PhysicalDeviceObject;
292 ULONG SystemIoBusNumber;
293 INTERFACE_TYPE AdapterInterfaceType;
294 ULONG BusInterruptLevel;
295 ULONG BusInterruptVector;
296 KINTERRUPT_MODE InterruptMode;
297 ULONG DmaChannel;
298 ULONG NumberOfAccessRanges;
299 PACCESS_RANGE AccessRanges;
300 ULONG StreamDescriptorSize;
301 PIRP Irp;
302 PKINTERRUPT InterruptObject;
303 PADAPTER_OBJECT DmaAdapterObject;
304 PDEVICE_OBJECT RealPhysicalDeviceObject;
305 ULONG Reserved[1];
306 } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
307
308 typedef VOID (STREAMAPI *PHW_RECEIVE_DEVICE_SRB) (IN PHW_STREAM_REQUEST_BLOCK SRB);
309 typedef VOID (STREAMAPI *PHW_CANCEL_SRB) (IN PHW_STREAM_REQUEST_BLOCK SRB);
310 typedef VOID (STREAMAPI *PHW_REQUEST_TIMEOUT_HANDLER) (IN PHW_STREAM_REQUEST_BLOCK SRB);
311 typedef BOOLEAN (STREAMAPI *PHW_INTERRUPT) (IN PVOID DeviceExtension);
312 typedef VOID (STREAMAPI *PHW_TIMER_ROUTINE) (IN PVOID Context);
313 typedef VOID (STREAMAPI *PHW_PRIORITY_ROUTINE) (IN PVOID Context);
314 typedef VOID (STREAMAPI *PHW_QUERY_CLOCK_ROUTINE) (IN PHW_TIME_CONTEXT TimeContext);
315 typedef BOOLEAN (STREAMAPI *PHW_RESET_ADAPTER) (IN PVOID DeviceExtension);
316
317 typedef enum _STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE {
318 ReadyForNextStreamDataRequest,
319 ReadyForNextStreamControlRequest,
320 HardwareStarved,
321 StreamRequestComplete,
322 SignalMultipleStreamEvents,
323 SignalStreamEvent,
324 DeleteStreamEvent,
325 StreamNotificationMaximum
326 } STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE, *PSTREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE;
327
328 typedef enum _STREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE {
329 ReadyForNextDeviceRequest,
330 DeviceRequestComplete,
331 SignalMultipleDeviceEvents,
332 SignalDeviceEvent,
333 DeleteDeviceEvent,
334 #if (NTDDI_VERSION >= NTDDI_WINXP)
335 SignalMultipleDeviceInstanceEvents,
336 #endif
337 DeviceNotificationMaximum
338 } STREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE, *PSTREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE;
339
340 #define STREAM_CLASS_VERSION_20 0x0200
341
342 typedef struct _HW_INITIALIZATION_DATA {
343 #if (NTDDI_VERSION >= NTDDI_WINXP)
344 __GNU_EXTENSION union {
345 ULONG HwInitializationDataSize;
346 __GNU_EXTENSION struct {
347 USHORT SizeOfThisPacket;
348 USHORT StreamClassVersion;
349 };
350 };
351 #else
352 ULONG HwInitializationDataSize;
353 #endif /* NTDDI_VERSION >= NTDDI_WINXP */
354
355 PHW_INTERRUPT HwInterrupt;
356 PHW_RECEIVE_DEVICE_SRB HwReceivePacket;
357 PHW_CANCEL_SRB HwCancelPacket;
358 PHW_REQUEST_TIMEOUT_HANDLER HwRequestTimeoutHandler;
359 ULONG DeviceExtensionSize;
360 ULONG PerRequestExtensionSize;
361 ULONG PerStreamExtensionSize;
362 ULONG FilterInstanceExtensionSize;
363 BOOLEAN BusMasterDMA;
364 BOOLEAN Dma24BitAddresses;
365 ULONG BufferAlignment;
366 BOOLEAN TurnOffSynchronization;
367 ULONG DmaBufferSize;
368
369 #if (NTDDI_VERSION >= NTDDI_WINXP)
370 ULONG NumNameExtensions;
371 PWCHAR *NameExtensionArray;
372 #else
373 ULONG Reserved[2];
374 #endif
375 } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
376
377 typedef enum _STREAM_PRIORITY {
378 High,
379 Dispatch,
380 Low,
381 LowToHigh
382 } STREAM_PRIORITY, *PSTREAM_PRIORITY;
383
384
385 VOID
386 StreamClassAbortOutstandingRequests(
387 IN PVOID HwDeviceExtension,
388 IN PHW_STREAM_OBJECT HwStreamObject,
389 IN NTSTATUS Status);
390
391 VOID
392 STREAMAPI
393 StreamClassCallAtNewPriority(
394 IN PHW_STREAM_OBJECT StreamObject,
395 IN PVOID HwDeviceExtension,
396 IN STREAM_PRIORITY Priority,
397 IN PHW_PRIORITY_ROUTINE PriorityRoutine,
398 IN PVOID Context);
399
400 VOID
401 STREAMAPI
402 StreamClassCompleteRequestAndMarkQueueReady(
403 IN PHW_STREAM_REQUEST_BLOCK Srb);
404
405 VOID
406 STREAMAPI
407 StreamClassDebugAssert(
408 IN PCHAR File,
409 IN ULONG Line,
410 IN PCHAR AssertText,
411 IN ULONG AssertValue);
412
413 VOID
414 __cdecl
415 StreamClassDebugPrint(
416 IN STREAM_DEBUG_LEVEL DebugPrintLevel,
417 IN PCCHAR DebugMessage,
418 ...);
419
420 VOID
421 __cdecl
422 StreamClassDeviceNotification(
423 IN STREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE NotificationType,
424 IN PVOID HwDeviceExtension,
425 IN PHW_STREAM_REQUEST_BLOCK pSrb,
426 IN PKSEVENT_ENTRY EventEntry,
427 IN GUID *EventSet,
428 IN ULONG EventId);
429
430 VOID
431 STREAMAPI
432 StreamClassFilterReenumerateStreams(
433 IN PVOID HwInstanceExtension,
434 IN ULONG StreamDescriptorSize);
435
436 PVOID
437 STREAMAPI
438 StreamClassGetDmaBuffer(
439 IN PVOID HwDeviceExtension);
440
441
442 PKSEVENT_ENTRY
443 StreamClassGetNextEvent(
444 IN PVOID HwInstanceExtension_OR_HwDeviceExtension,
445 IN PHW_STREAM_OBJECT HwStreamObject,
446 IN GUID * EventGuid,
447 IN ULONG EventItem,
448 IN PKSEVENT_ENTRY CurrentEvent);
449
450 STREAM_PHYSICAL_ADDRESS
451 STREAMAPI
452 StreamClassGetPhysicalAddress(
453 IN PVOID HwDeviceExtension,
454 IN PHW_STREAM_REQUEST_BLOCK HwSRB,
455 IN PVOID VirtualAddress,
456 IN STREAM_BUFFER_TYPE Type,
457 IN ULONG *Length);
458
459 VOID
460 StreamClassQueryMasterClock(
461 IN PHW_STREAM_OBJECT HwStreamObject,
462 IN HANDLE MasterClockHandle,
463 IN TIME_FUNCTION TimeFunction,
464 IN PHW_QUERY_CLOCK_ROUTINE ClockCallbackRoutine);
465
466 VOID
467 STREAMAPI
468 StreamClassQueryMasterClockSync(
469 IN HANDLE MasterClockHandle,
470 IN PHW_TIME_CONTEXT TimeContext);
471
472 BOOLEAN
473 STREAMAPI
474 StreamClassReadWriteConfig(
475 IN PVOID HwDeviceExtension,
476 IN BOOLEAN Read,
477 IN PVOID Buffer,
478 IN ULONG Offset,
479 IN ULONG Length);
480
481 VOID
482 STREAMAPI
483 StreamClassReenumerateStreams(
484 IN PVOID HwDeviceExtension,
485 IN ULONG StreamDescriptorSize);
486
487 NTSTATUS
488 STREAMAPI
489 StreamClassRegisterAdapter(
490 IN PVOID Argument1,
491 IN PVOID Argument2,
492 IN PHW_INITIALIZATION_DATA HwInitializationData);
493
494 #define StreamClassRegisterMinidriver StreamClassRegisterAdapter
495
496 NTSTATUS
497 StreamClassRegisterFilterWithNoKSPins(
498 IN PDEVICE_OBJECT DeviceObject,
499 IN const GUID *InterfaceClassGUID,
500 IN ULONG PinCount,
501 IN BOOLEAN *PinDirection,
502 IN KSPIN_MEDIUM *MediumList,
503 IN GUID *CategoryList);
504
505 VOID
506 STREAMAPI
507 StreamClassScheduleTimer(
508 IN PHW_STREAM_OBJECT StreamObject,
509 IN PVOID HwDeviceExtension,
510 IN ULONG NumberOfMicroseconds,
511 IN PHW_TIMER_ROUTINE TimerRoutine,
512 IN PVOID Context);
513
514 VOID
515 __cdecl
516 StreamClassStreamNotification(
517 IN STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE NotificationType,
518 IN PHW_STREAM_OBJECT StreamObject,
519 IN ...);
520
521 #endif /* _STREAM_H */