More work on USB related definitions
[reactos.git] / include / psdk / usbcamdi.h
1 /*
2 * usbcamdi.h
3 *
4 * USB Camera driver interface.
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23 #pragma once
24
25 #if !defined(__USB_H) && !defined(__USBDI_H)
26 #error include usb.h or usbdi.h before usbcamdi.h
27 #else
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #if defined(_BATTERYCLASS_)
34 #define USBCAMAPI
35 #else
36 #define USBCAMAPI DECLSPEC_IMPORT
37 #endif
38
39 DEFINE_GUID(GUID_USBCAMD_INTERFACE,
40 0x2bcb75c0, 0xb27f, 0x11d1, 0xba, 0x41, 0x0, 0xa0, 0xc9, 0xd, 0x2b, 0x5);
41
42 #define USBCAMD_PROCESSPACKETEX_DropFrame 0x0002
43 #define USBCAMD_PROCESSPACKETEX_NextFrameIsStill 0x0004
44 #define USBCAMD_PROCESSPACKETEX_CurrentFrameIsStill 0x0008
45
46 #define USBCAMD_DATA_PIPE 0x0001
47 #define USBCAMD_MULTIPLEX_PIPE 0x0002
48 #define USBCAMD_SYNC_PIPE 0x0004
49 #define USBCAMD_DONT_CARE_PIPE 0x0008
50
51 #define USBCAMD_VIDEO_STREAM 0x1
52 #define USBCAMD_STILL_STREAM 0x2
53 #define USBCAMD_VIDEO_STILL_STREAM (USBCAMD_VIDEO_STREAM | USBCAMD_STILL_STREAM)
54
55 #define USBCAMD_STOP_STREAM 0x00000001
56 #define USBCAMD_START_STREAM 0x00000000
57
58 typedef struct _pipe_config_descriptor {
59 CHAR StreamAssociation;
60 UCHAR PipeConfigFlags;
61 } USBCAMD_Pipe_Config_Descriptor, *PUSBCAMD_Pipe_Config_Descriptor;
62
63 typedef enum {
64 USBCAMD_CamControlFlag_NoVideoRawProcessing = 1,
65 USBCAMD_CamControlFlag_NoStillRawProcessing = 2,
66 USBCAMD_CamControlFlag_AssociatedFormat = 4,
67 USBCAMD_CamControlFlag_EnableDeviceEvents = 8
68 } USBCAMD_CamControlFlags;
69
70 typedef NTSTATUS
71 (NTAPI *PCAM_ALLOCATE_BW_ROUTINE)(
72 IN PDEVICE_OBJECT BusDeviceObject,
73 IN PVOID DeviceContext,
74 IN PULONG RawFrameLength,
75 IN PVOID Format);
76
77 typedef NTSTATUS
78 (NTAPI *PCAM_ALLOCATE_BW_ROUTINE_EX)(
79 IN PDEVICE_OBJECT BusDeviceObject,
80 IN PVOID DeviceContext,
81 IN PULONG RawFrameLength,
82 IN PVOID Format,
83 IN ULONG StreamNumber);
84
85 typedef NTSTATUS
86 (NTAPI *PCAM_CONFIGURE_ROUTINE)(
87 IN PDEVICE_OBJECT BusDeviceObject,
88 IN PVOID DeviceContext,
89 IN PUSBD_INTERFACE_INFORMATION Interface,
90 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
91 IN PLONG DataPipeIndex,
92 IN PLONG SyncPipeIndex);
93
94 typedef NTSTATUS
95 (NTAPI *PCAM_CONFIGURE_ROUTINE_EX)(
96 IN PDEVICE_OBJECT BusDeviceObject,
97 IN PVOID DeviceContext,
98 IN PUSBD_INTERFACE_INFORMATION Interface,
99 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
100 IN ULONG PipeConfigListSize,
101 IN PUSBCAMD_Pipe_Config_Descriptor PipeConfig,
102 IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
103
104 typedef NTSTATUS
105 (NTAPI *PCAM_FREE_BW_ROUTINE)(
106 IN PDEVICE_OBJECT BusDeviceObject,
107 IN PVOID DeviceContext);
108
109 typedef NTSTATUS
110 (NTAPI *PCAM_FREE_BW_ROUTINE_EX)(
111 IN PDEVICE_OBJECT BusDeviceObject,
112 IN PVOID DeviceContext,
113 IN ULONG StreamNumber);
114
115 typedef NTSTATUS
116 (NTAPI *PCAM_INITIALIZE_ROUTINE)(
117 PDEVICE_OBJECT BusDeviceObject,
118 PVOID DeviceContext);
119
120 typedef VOID
121 (NTAPI *PCAM_NEW_FRAME_ROUTINE)(
122 IN PVOID DeviceContext,
123 IN PVOID FrameContext);
124
125 typedef VOID
126 (NTAPI *PCAM_NEW_FRAME_ROUTINE_EX)(
127 IN PVOID DeviceContext,
128 IN PVOID FrameContext,
129 IN ULONG StreamNumber,
130 OUT PULONG FrameLength);
131
132 typedef NTSTATUS
133 (NTAPI *PCAM_PROCESS_RAW_FRAME_ROUTINE)(
134 IN PDEVICE_OBJECT BusDeviceObject,
135 IN PVOID DeviceContext,
136 IN PVOID FrameContext,
137 IN PVOID FrameBuffer,
138 IN ULONG FrameLength,
139 OUT PVOID RawFrameBuffer,
140 IN ULONG RawFrameLength,
141 IN ULONG NumberOfPackets,
142 OUT PULONG BytesReturned);
143
144 typedef NTSTATUS
145 (NTAPI *PCAM_PROCESS_RAW_FRAME_ROUTINE_EX)(
146 IN PDEVICE_OBJECT BusDeviceObject,
147 IN PVOID DeviceContext,
148 IN PVOID FrameContext,
149 IN PVOID FrameBuffer,
150 IN ULONG FrameLength,
151 OUT PVOID RawFrameBuffer,
152 IN ULONG RawFrameLength,
153 IN ULONG NumberOfPackets,
154 OUT PULONG BytesReturned,
155 IN ULONG ActualRawFrameLength,
156 IN ULONG StreamNumber);
157
158 typedef ULONG
159 (NTAPI *PCAM_PROCESS_PACKET_ROUTINE)(
160 IN PDEVICE_OBJECT BusDeviceObject,
161 IN PVOID DeviceContext,
162 IN PVOID CurrentFrameContext,
163 IN PUSBD_ISO_PACKET_DESCRIPTOR SyncPacket OPTIONAL,
164 IN PVOID SyncBuffer OPTIONAL,
165 IN PUSBD_ISO_PACKET_DESCRIPTOR DataPacket OPTIONAL,
166 IN OUT PVOID DataBuffer,
167 OUT PBOOLEAN FrameComplete,
168 OUT PBOOLEAN NextFrameIsStill);
169
170 typedef ULONG
171 (NTAPI *PCAM_PROCESS_PACKET_ROUTINE_EX)(
172 IN PDEVICE_OBJECT BusDeviceObject,
173 IN PVOID DeviceContext,
174 IN PVOID CurrentFrameContext,
175 IN PUSBD_ISO_PACKET_DESCRIPTOR SyncPacket OPTIONAL,
176 IN PVOID SyncBuffer OPTIONAL,
177 IN PUSBD_ISO_PACKET_DESCRIPTOR DataPacket OPTIONAL,
178 IN OUT PVOID DataBuffer,
179 OUT PBOOLEAN FrameComplete,
180 OUT PULONG PacketFlag,
181 OUT PULONG ValidDataOffset);
182
183 typedef NTSTATUS
184 (NTAPI *PCAM_STATE_ROUTINE)(
185 IN PDEVICE_OBJECT BusDeviceObject,
186 IN PVOID DeviceContext);
187
188 typedef NTSTATUS
189 (NTAPI *PCAM_START_CAPTURE_ROUTINE)(
190 IN PDEVICE_OBJECT BusDeviceObject,
191 IN PVOID DeviceContext);
192
193 typedef NTSTATUS
194 (NTAPI *PCAM_START_CAPTURE_ROUTINE_EX)(
195 IN PDEVICE_OBJECT BusDeviceObject,
196 IN PVOID DeviceContext,
197 IN ULONG StreamNumber);
198
199 typedef NTSTATUS
200 (NTAPI *PCAM_STOP_CAPTURE_ROUTINE)(
201 IN PDEVICE_OBJECT BusDeviceObject,
202 IN PVOID DeviceContext);
203
204 typedef NTSTATUS
205 (NTAPI *PCAM_STOP_CAPTURE_ROUTINE_EX)(
206 IN PDEVICE_OBJECT BusDeviceObject,
207 IN PVOID DeviceContext,
208 IN ULONG StreamNumber);
209
210 typedef struct _USBCAMD_DEVICE_DATA {
211 ULONG Sig;
212 PCAM_INITIALIZE_ROUTINE CamInitialize;
213 PCAM_INITIALIZE_ROUTINE CamUnInitialize;
214 PCAM_PROCESS_PACKET_ROUTINE CamProcessUSBPacket;
215 PCAM_NEW_FRAME_ROUTINE CamNewVideoFrame;
216 PCAM_PROCESS_RAW_FRAME_ROUTINE CamProcessRawVideoFrame;
217 PCAM_START_CAPTURE_ROUTINE CamStartCapture;
218 PCAM_STOP_CAPTURE_ROUTINE CamStopCapture;
219 PCAM_CONFIGURE_ROUTINE CamConfigure;
220 PCAM_STATE_ROUTINE CamSaveState;
221 PCAM_STATE_ROUTINE CamRestoreState;
222 PCAM_ALLOCATE_BW_ROUTINE CamAllocateBandwidth;
223 PCAM_FREE_BW_ROUTINE CamFreeBandwidth;
224 } USBCAMD_DEVICE_DATA, *PUSBCAMD_DEVICE_DATA;
225
226 typedef struct _USBCAMD_DEVICE_DATA2 {
227 ULONG Sig;
228 PCAM_INITIALIZE_ROUTINE CamInitialize;
229 PCAM_INITIALIZE_ROUTINE CamUnInitialize;
230 PCAM_PROCESS_PACKET_ROUTINE_EX CamProcessUSBPacketEx;
231 PCAM_NEW_FRAME_ROUTINE_EX CamNewVideoFrameEx;
232 PCAM_PROCESS_RAW_FRAME_ROUTINE_EX CamProcessRawVideoFrameEx;
233 PCAM_START_CAPTURE_ROUTINE_EX CamStartCaptureEx;
234 PCAM_STOP_CAPTURE_ROUTINE_EX CamStopCaptureEx;
235 PCAM_CONFIGURE_ROUTINE_EX CamConfigureEx;
236 PCAM_STATE_ROUTINE CamSaveState;
237 PCAM_STATE_ROUTINE CamRestoreState;
238 PCAM_ALLOCATE_BW_ROUTINE_EX CamAllocateBandwidthEx;
239 PCAM_FREE_BW_ROUTINE_EX CamFreeBandwidthEx;
240 } USBCAMD_DEVICE_DATA2, *PUSBCAMD_DEVICE_DATA2;
241
242 USBCAMAPI
243 ULONG
244 NTAPI
245 USBCAMD_InitializeNewInterface(
246 IN PVOID DeviceContext,
247 IN PVOID DeviceData,
248 IN ULONG Version,
249 IN ULONG CamControlFlag);
250
251 typedef NTSTATUS
252 (NTAPI *PCOMMAND_COMPLETE_FUNCTION)(
253 IN PVOID DeviceContext,
254 IN OUT PVOID CommandContext,
255 IN NTSTATUS NtStatus);
256
257 typedef NTSTATUS
258 (NTAPI *PFNUSBCAMD_BulkReadWrite)(
259 IN PVOID DeviceContext,
260 IN USHORT PipeIndex,
261 IN PVOID Buffer,
262 IN ULONG BufferLength,
263 IN PCOMMAND_COMPLETE_FUNCTION CommandComplete,
264 IN PVOID CommandContext);
265
266 typedef NTSTATUS
267 (NTAPI *PFNUSBCAMD_SetIsoPipeState)(
268 IN PVOID DeviceContext,
269 IN ULONG PipeStateFlags);
270
271 typedef NTSTATUS
272 (NTAPI *PFNUSBCAMD_CancelBulkReadWrite)(
273 IN PVOID DeviceContext,
274 IN ULONG PipeIndex);
275
276 typedef NTSTATUS
277 (NTAPI *PFNUSBCAMD_SetVideoFormat)(
278 IN PVOID DeviceContext,
279 IN PHW_STREAM_REQUEST_BLOCK pSrb);
280
281 typedef NTSTATUS
282 (NTAPI *PFNUSBCAMD_WaitOnDeviceEvent)(
283 IN PVOID DeviceContext,
284 IN ULONG PipeIndex,
285 IN PVOID Buffer,
286 IN ULONG BufferLength,
287 IN PCOMMAND_COMPLETE_FUNCTION EventComplete,
288 IN PVOID EventContext,
289 IN BOOLEAN LoopBack);
290
291 typedef VOID
292 (NTAPI *PADAPTER_RECEIVE_PACKET_ROUTINE)(
293 IN OUT PHW_STREAM_REQUEST_BLOCK Srb);
294
295 #define USBCAMD_VERSION_200 0x200
296
297 typedef struct _USBCAMD_INTERFACE {
298 INTERFACE Interface;
299 PFNUSBCAMD_WaitOnDeviceEvent USBCAMD_WaitOnDeviceEvent;
300 PFNUSBCAMD_BulkReadWrite USBCAMD_BulkReadWrite;
301 PFNUSBCAMD_SetVideoFormat USBCAMD_SetVideoFormat;
302 PFNUSBCAMD_SetIsoPipeState USBCAMD_SetIsoPipeState;
303 PFNUSBCAMD_CancelBulkReadWrite USBCAMD_CancelBulkReadWrite;
304 } USBCAMD_INTERFACE, *PUSBCAMD_INTERFACE;
305
306 typedef VOID
307 (NTAPI *PSTREAM_RECEIVE_PACKET)(
308 IN PVOID Srb,
309 IN PVOID DeviceContext,
310 IN PBOOLEAN Completed);
311
312 /* FIXME : Do we need USBCAMAPI here ? */
313
314 USBCAMAPI
315 PVOID
316 NTAPI
317 USBCAMD_AdapterReceivePacket(
318 IN PHW_STREAM_REQUEST_BLOCK Srb,
319 IN PUSBCAMD_DEVICE_DATA DeviceData,
320 IN PDEVICE_OBJECT *DeviceObject,
321 IN BOOLEAN NeedsCompletion);
322
323 USBCAMAPI
324 NTSTATUS
325 NTAPI
326 USBCAMD_ControlVendorCommand(
327 IN PVOID DeviceContext,
328 IN UCHAR Request,
329 IN USHORT Value,
330 IN USHORT Index,
331 IN OUT PVOID Buffer,
332 IN OUT PULONG BufferLength,
333 IN BOOLEAN GetData,
334 IN PCOMMAND_COMPLETE_FUNCTION CommandComplete OPTIONAL,
335 IN PVOID CommandContext OPTIONAL);
336
337 USBCAMAPI
338 ULONG
339 NTAPI
340 USBCAMD_DriverEntry(
341 IN PVOID Context1,
342 IN PVOID Context2,
343 IN ULONG DeviceContextSize,
344 IN ULONG FrameContextSize,
345 IN PADAPTER_RECEIVE_PACKET_ROUTINE ReceivePacket);
346
347 USBCAMAPI
348 NTSTATUS
349 NTAPI
350 USBCAMD_GetRegistryKeyValue(
351 IN HANDLE Handle,
352 IN PWCHAR KeyNameString,
353 IN ULONG KeyNameStringLength,
354 IN PVOID Data,
355 IN ULONG DataLength);
356
357 USBCAMAPI
358 NTSTATUS
359 NTAPI
360 USBCAMD_SelectAlternateInterface(
361 IN PVOID DeviceContext,
362 IN OUT PUSBD_INTERFACE_INFORMATION RequestInterface);
363
364 #if defined(DEBUG_LOG)
365
366 USBCAMAPI
367 VOID
368 NTAPI
369 USBCAMD_Debug_LogEntry(
370 IN CHAR *Name,
371 IN ULONG Info1,
372 IN ULONG Info2,
373 IN ULONG Info3);
374
375 #define ILOGENTRY(sig, info1, info2, info3) \
376 USBCAMD_Debug_LogEntry(sig, (ULONG)info1, (ULONG)info2, (ULONG)info3)
377
378 #else
379
380 #define ILOGENTRY(sig, info1, info2, info3)
381
382 #endif /* DEBUG_LOG */
383
384 #ifdef __cplusplus
385 }
386 #endif
387
388 #endif /* !defined(__USB_H) && !defined(__USBDI_H) */