4 * USB Camera driver interface.
6 * This file is part of the w32api package.
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
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.
27 #pragma GCC system_header
30 #if !defined(__USB_H) && !defined(__USBDI_H)
31 #error include usb.h or usbdi.h before usbcamdi.h
42 #if defined(_BATTERYCLASS_)
43 #define USBCAMAPI DECLSPEC_EXPORT
45 #define USBCAMAPI DECLSPEC_IMPORT
49 /* FIXME: Unknown definition */
50 typedef PVOID PHW_STREAM_REQUEST_BLOCK
;
52 DEFINE_GUID(GUID_USBCAMD_INTERFACE
,
53 0x2bcb75c0, 0xb27f, 0x11d1, 0xba, 0x41, 0x0, 0xa0, 0xc9, 0xd, 0x2b, 0x5);
55 #define USBCAMD_PROCESSPACKETEX_DropFrame 0x0002
56 #define USBCAMD_PROCESSPACKETEX_NextFrameIsStill 0x0004
57 #define USBCAMD_PROCESSPACKETEX_CurrentFrameIsStill 0x0008
59 #define USBCAMD_DATA_PIPE 0x0001
60 #define USBCAMD_MULTIPLEX_PIPE 0x0002
61 #define USBCAMD_SYNC_PIPE 0x0004
62 #define USBCAMD_DONT_CARE_PIPE 0x0008
64 #define USBCAMD_VIDEO_STREAM 0x1
65 #define USBCAMD_STILL_STREAM 0x2
66 #define USBCAMD_VIDEO_STILL_STREAM (USBCAMD_VIDEO_STREAM | USBCAMD_STILL_STREAM)
68 #define USBCAMD_STOP_STREAM 0x00000001
69 #define USBCAMD_START_STREAM 0x00000000
71 typedef struct _pipe_config_descriptor
{
72 CHAR StreamAssociation
;
73 UCHAR PipeConfigFlags
;
74 } USBCAMD_Pipe_Config_Descriptor
, *PUSBCAMD_Pipe_Config_Descriptor
;
77 USBCAMD_CamControlFlag_NoVideoRawProcessing
= 1,
78 USBCAMD_CamControlFlag_NoStillRawProcessing
= 2,
79 USBCAMD_CamControlFlag_AssociatedFormat
= 4,
80 USBCAMD_CamControlFlag_EnableDeviceEvents
= 8
81 } USBCAMD_CamControlFlags
;
83 typedef NTSTATUS DDKAPI
84 (*PCAM_ALLOCATE_BW_ROUTINE
)(
85 PDEVICE_OBJECT BusDeviceObject
,
87 PULONG RawFrameLength
,
90 typedef NTSTATUS DDKAPI
91 (*PCAM_ALLOCATE_BW_ROUTINE_EX
)(
92 PDEVICE_OBJECT BusDeviceObject
,
94 PULONG RawFrameLength
,
98 typedef NTSTATUS DDKAPI
99 (*PCAM_CONFIGURE_ROUTINE
)(
100 PDEVICE_OBJECT BusDeviceObject
,
102 PUSBD_INTERFACE_INFORMATION Interface
,
103 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
,
105 PLONG SyncPipeIndex
);
107 typedef NTSTATUS DDKAPI
108 (*PCAM_CONFIGURE_ROUTINE_EX
)(
109 PDEVICE_OBJECT BusDeviceObject
,
111 PUSBD_INTERFACE_INFORMATION Interface
,
112 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
,
113 ULONG PipeConfigListSize
,
114 PUSBCAMD_Pipe_Config_Descriptor PipeConfig
,
115 PUSB_DEVICE_DESCRIPTOR DeviceDescriptor
);
117 typedef NTSTATUS DDKAPI
118 (*PCAM_FREE_BW_ROUTINE
)(
119 PDEVICE_OBJECT BusDeviceObject
,
120 PVOID DeviceContext
);
122 typedef NTSTATUS DDKAPI
123 (*PCAM_FREE_BW_ROUTINE_EX
)(
124 PDEVICE_OBJECT BusDeviceObject
,
128 typedef NTSTATUS DDKAPI
129 (*PCAM_INITIALIZE_ROUTINE
)(
130 PDEVICE_OBJECT BusDeviceObject
,
131 PVOID DeviceContext
);
134 (*PCAM_NEW_FRAME_ROUTINE
)(
139 (*PCAM_NEW_FRAME_ROUTINE_EX
)(
145 typedef NTSTATUS DDKAPI
146 (*PCAM_PROCESS_RAW_FRAME_ROUTINE
)(
147 PDEVICE_OBJECT BusDeviceObject
,
152 PVOID RawFrameBuffer
,
153 ULONG RawFrameLength
,
154 ULONG NumberOfPackets
,
155 PULONG BytesReturned
);
157 typedef NTSTATUS DDKAPI
158 (*PCAM_PROCESS_RAW_FRAME_ROUTINE_EX
)(
159 PDEVICE_OBJECT BusDeviceObject
,
164 PVOID RawFrameBuffer
,
165 ULONG RawFrameLength
,
166 ULONG NumberOfPackets
,
167 PULONG BytesReturned
,
168 ULONG ActualRawFrameLength
,
172 (*PCAM_PROCESS_PACKET_ROUTINE
)(
173 PDEVICE_OBJECT BusDeviceObject
,
175 PVOID CurrentFrameContext
,
176 PUSBD_ISO_PACKET_DESCRIPTOR SyncPacket
,
178 PUSBD_ISO_PACKET_DESCRIPTOR DataPacket
,
180 PBOOLEAN FrameComplete
,
181 PBOOLEAN NextFrameIsStill
);
184 (*PCAM_PROCESS_PACKET_ROUTINE_EX
)(
185 PDEVICE_OBJECT BusDeviceObject
,
187 PVOID CurrentFrameContext
,
188 PUSBD_ISO_PACKET_DESCRIPTOR SyncPacket
,
190 PUSBD_ISO_PACKET_DESCRIPTOR DataPacket
,
192 PBOOLEAN FrameComplete
,
194 PULONG ValidDataOffset
);
196 typedef NTSTATUS DDKAPI
197 (*PCAM_STATE_ROUTINE
)(
198 PDEVICE_OBJECT BusDeviceObject
,
199 PVOID DeviceContext
);
201 typedef NTSTATUS DDKAPI
202 (*PCAM_START_CAPTURE_ROUTINE
)(
203 PDEVICE_OBJECT BusDeviceObject
,
204 PVOID DeviceContext
);
206 typedef NTSTATUS DDKAPI
207 (*PCAM_START_CAPTURE_ROUTINE_EX
)(
208 PDEVICE_OBJECT BusDeviceObject
,
212 typedef NTSTATUS DDKAPI
213 (*PCAM_STOP_CAPTURE_ROUTINE
)(
214 PDEVICE_OBJECT BusDeviceObject
,
215 PVOID DeviceContext
);
217 typedef NTSTATUS DDKAPI
218 (*PCAM_STOP_CAPTURE_ROUTINE_EX
)(
219 PDEVICE_OBJECT BusDeviceObject
,
223 typedef struct _USBCAMD_DEVICE_DATA
{
225 PCAM_INITIALIZE_ROUTINE CamInitialize
;
226 PCAM_INITIALIZE_ROUTINE CamUnInitialize
;
227 PCAM_PROCESS_PACKET_ROUTINE CamProcessUSBPacket
;
228 PCAM_NEW_FRAME_ROUTINE CamNewVideoFrame
;
229 PCAM_PROCESS_RAW_FRAME_ROUTINE CamProcessRawVideoFrame
;
230 PCAM_START_CAPTURE_ROUTINE CamStartCapture
;
231 PCAM_STOP_CAPTURE_ROUTINE CamStopCapture
;
232 PCAM_CONFIGURE_ROUTINE CamConfigure
;
233 PCAM_STATE_ROUTINE CamSaveState
;
234 PCAM_STATE_ROUTINE CamRestoreState
;
235 PCAM_ALLOCATE_BW_ROUTINE CamAllocateBandwidth
;
236 PCAM_FREE_BW_ROUTINE CamFreeBandwidth
;
237 } USBCAMD_DEVICE_DATA
, *PUSBCAMD_DEVICE_DATA
;
239 typedef struct _USBCAMD_DEVICE_DATA2
{
241 PCAM_INITIALIZE_ROUTINE CamInitialize
;
242 PCAM_INITIALIZE_ROUTINE CamUnInitialize
;
243 PCAM_PROCESS_PACKET_ROUTINE_EX CamProcessUSBPacketEx
;
244 PCAM_NEW_FRAME_ROUTINE_EX CamNewVideoFrameEx
;
245 PCAM_PROCESS_RAW_FRAME_ROUTINE_EX CamProcessRawVideoFrameEx
;
246 PCAM_START_CAPTURE_ROUTINE_EX CamStartCaptureEx
;
247 PCAM_STOP_CAPTURE_ROUTINE_EX CamStopCaptureEx
;
248 PCAM_CONFIGURE_ROUTINE_EX CamConfigureEx
;
249 PCAM_STATE_ROUTINE CamSaveState
;
250 PCAM_STATE_ROUTINE CamRestoreState
;
251 PCAM_ALLOCATE_BW_ROUTINE_EX CamAllocateBandwidthEx
;
252 PCAM_FREE_BW_ROUTINE_EX CamFreeBandwidthEx
;
253 } USBCAMD_DEVICE_DATA2
, *PUSBCAMD_DEVICE_DATA2
;
258 USBCAMD_InitializeNewInterface(
259 /*IN*/ PVOID DeviceContext
,
260 /*IN*/ PVOID DeviceData
,
261 /*IN*/ ULONG Version
,
262 /*IN*/ ULONG CamControlFlag
);
265 (*PCOMMAND_COMPLETE_FUNCTION
)(
267 PVOID CommandContext
,
270 typedef NTSTATUS DDKAPI
271 (*PFNUSBCAMD_BulkReadWrite
)(
272 /*IN*/ PVOID DeviceContext
,
273 /*IN*/ USHORT PipeIndex
,
275 /*IN*/ ULONG BufferLength
,
276 /*IN*/ PCOMMAND_COMPLETE_FUNCTION CommandComplete
,
277 /*IN*/ PVOID CommandContext
);
279 typedef NTSTATUS DDKAPI
280 (*PFNUSBCAMD_SetIsoPipeState
)(
281 /*IN*/ PVOID DeviceContext
,
282 /*IN*/ ULONG PipeStateFlags
);
284 typedef NTSTATUS DDKAPI
285 (*PFNUSBCAMD_CancelBulkReadWrite
)(
286 /*IN*/ PVOID DeviceContext
,
287 /*IN*/ ULONG PipeIndex
);
289 typedef NTSTATUS DDKAPI
290 (*PFNUSBCAMD_SetVideoFormat
)(
291 /*IN*/ PVOID DeviceContext
,
292 /*IN*/ PHW_STREAM_REQUEST_BLOCK pSrb
);
294 typedef NTSTATUS DDKAPI
295 (*PFNUSBCAMD_WaitOnDeviceEvent
)(
296 /*IN*/ PVOID DeviceContext
,
297 /*IN*/ ULONG PipeIndex
,
299 /*IN*/ ULONG BufferLength
,
300 /*IN*/ PCOMMAND_COMPLETE_FUNCTION EventComplete
,
301 /*IN*/ PVOID EventContext
,
302 /*IN*/ BOOLEAN LoopBack
);
307 USBCAMD_AdapterReceivePacket(
308 /*IN*/ PHW_STREAM_REQUEST_BLOCK Srb
,
309 /*IN*/ PUSBCAMD_DEVICE_DATA DeviceData
,
310 /*IN*/ PDEVICE_OBJECT
*DeviceObject
,
311 /*IN*/ BOOLEAN NeedsCompletion
);
316 USBCAMD_ControlVendorCommand(
317 /*IN*/ PVOID DeviceContext
,
318 /*IN*/ UCHAR Request
,
322 /*IN OUT*/ PULONG BufferLength
,
323 /*IN*/ BOOLEAN GetData
,
324 /*IN*/ PCOMMAND_COMPLETE_FUNCTION CommandComplete
,
325 /*IN*/ PVOID CommandContext
);
328 (*PADAPTER_RECEIVE_PACKET_ROUTINE
)(
329 /*IN*/ PHW_STREAM_REQUEST_BLOCK Srb
);
337 ULONG DeviceContextSize
,
338 ULONG FrameContextSize
,
339 PADAPTER_RECEIVE_PACKET_ROUTINE ReceivePacket
);
344 USBCAMD_GetRegistryKeyValue(
345 /*IN*/ HANDLE Handle
,
346 /*IN*/ PWCHAR KeyNameString
,
347 /*IN*/ ULONG KeyNameStringLength
,
349 /*IN*/ ULONG DataLength
);
354 USBCAMD_SelectAlternateInterface(
355 /*IN*/ PVOID DeviceContext
,
356 /*IN OUT*/ PUSBD_INTERFACE_INFORMATION RequestInterface
);
358 #define USBCAMD_VERSION_200 0x200
360 typedef struct _USBCAMD_INTERFACE
{
362 PFNUSBCAMD_WaitOnDeviceEvent USBCAMD_WaitOnDeviceEvent
;
363 PFNUSBCAMD_BulkReadWrite USBCAMD_BulkReadWrite
;
364 PFNUSBCAMD_SetVideoFormat USBCAMD_SetVideoFormat
;
365 PFNUSBCAMD_SetIsoPipeState USBCAMD_SetIsoPipeState
;
366 PFNUSBCAMD_CancelBulkReadWrite USBCAMD_CancelBulkReadWrite
;
367 } USBCAMD_INTERFACE
, *PUSBCAMD_INTERFACE
;
370 (*PSTREAM_RECEIVE_PACKET
)(
372 /*IN*/ PVOID DeviceContext
,
373 /*IN*/ PBOOLEAN Completed
);
375 #if defined(DEBUG_LOG)
380 USBCAMD_Debug_LogEntry(
386 #define ILOGENTRY(sig, info1, info2, info3) \
387 USBCAMD_Debug_LogEntry(sig, (ULONG)info1, (ULONG)info2, (ULONG)info3)
391 #define ILOGENTRY(sig, info1, info2, info3)
393 #endif /* DEBUG_LOG */
401 #endif /* !defined(__USB_H) && !defined(__USBDI_H) */
404 #endif /* __USBCAMDI_H */