Debian Codegraph @

spectro/driver_api.h

raw symbols SCIP
1 /* libusb-win32, Generic Windows USB Library
2 * Copyright (c) 2002-2005 Stephan Meyer <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19
20 #ifndef __DRIVER_API_H__
21 #define __DRIVER_API_H__
22
23 enum
24 {
25 LIBUSB_DEBUG_OFF,
26 LIBUSB_DEBUG_ERR,
27 LIBUSB_DEBUG_WRN,
28 LIBUSB_DEBUG_MSG,
29
30 LIBUSB_DEBUG_MAX = 0xff,
31 };
32
33
34 /* 64k */
35 #define LIBUSB_MAX_READ_WRITE 0x10000
36
37 #define LIBUSB_MAX_NUMBER_OF_DEVICES 256
38 #define LIBUSB_MAX_NUMBER_OF_CHILDREN 32
39
40 #define LIBUSB_IOCTL_SET_CONFIGURATION CTL_CODE(FILE_DEVICE_UNKNOWN,\
41 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
42
43 #define LIBUSB_IOCTL_GET_CONFIGURATION CTL_CODE(FILE_DEVICE_UNKNOWN,\
44 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
45
46 #define LIBUSB_IOCTL_SET_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
47 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
48
49 #define LIBUSB_IOCTL_GET_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
50 0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
51
52 #define LIBUSB_IOCTL_SET_FEATURE CTL_CODE(FILE_DEVICE_UNKNOWN,\
53 0x805, METHOD_BUFFERED, FILE_ANY_ACCESS)
54
55 #define LIBUSB_IOCTL_CLEAR_FEATURE CTL_CODE(FILE_DEVICE_UNKNOWN,\
56 0x806, METHOD_BUFFERED, FILE_ANY_ACCESS)
57
58 #define LIBUSB_IOCTL_GET_STATUS CTL_CODE(FILE_DEVICE_UNKNOWN,\
59 0x807, METHOD_BUFFERED, FILE_ANY_ACCESS)
60
61 #define LIBUSB_IOCTL_SET_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN,\
62 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
63
64 #define LIBUSB_IOCTL_GET_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN,\
65 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
66
67 #define LIBUSB_IOCTL_INTERRUPT_OR_BULK_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
68 0x80A, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
69
70 #define LIBUSB_IOCTL_INTERRUPT_OR_BULK_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
71 0x80B, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
72
73 #define LIBUSB_IOCTL_VENDOR_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
74 0x80C, METHOD_BUFFERED, FILE_ANY_ACCESS)
75
76 #define LIBUSB_IOCTL_VENDOR_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
77 0x80D, METHOD_BUFFERED, FILE_ANY_ACCESS)
78
79 #define LIBUSB_IOCTL_RESET_ENDPOINT CTL_CODE(FILE_DEVICE_UNKNOWN,\
80 0x80E, METHOD_BUFFERED, FILE_ANY_ACCESS)
81
82 #define LIBUSB_IOCTL_ABORT_ENDPOINT CTL_CODE(FILE_DEVICE_UNKNOWN,\
83 0x80F, METHOD_BUFFERED, FILE_ANY_ACCESS)
84
85 #define LIBUSB_IOCTL_RESET_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN,\
86 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)
87
88 #define LIBUSB_IOCTL_SET_DEBUG_LEVEL CTL_CODE(FILE_DEVICE_UNKNOWN,\
89 0x811, METHOD_BUFFERED, FILE_ANY_ACCESS)
90
91 #define LIBUSB_IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN,\
92 0x812, METHOD_BUFFERED, FILE_ANY_ACCESS)
93
94 #define LIBUSB_IOCTL_ISOCHRONOUS_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
95 0x813, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
96
97 #define LIBUSB_IOCTL_ISOCHRONOUS_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
98 0x814, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
99
100 #define LIBUSB_IOCTL_CLAIM_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
101 0x815, METHOD_BUFFERED, FILE_ANY_ACCESS)
102
103 #define LIBUSB_IOCTL_RELEASE_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
104 0x816, METHOD_BUFFERED, FILE_ANY_ACCESS)
105
106 /////////////////////////////////////////////////////////////////////////////
107 // supported after 0.1.12.2
108 /////////////////////////////////////////////////////////////////////////////
109
110 // [trobinso] adds support for querying device properties
111 #define LIBUSB_IOCTL_GET_DEVICE_PROPERTY CTL_CODE(FILE_DEVICE_UNKNOWN,\
112 0x900, METHOD_BUFFERED, FILE_ANY_ACCESS)
113
114 #define LIBUSB_IOCTL_GET_CUSTOM_REG_PROPERTY CTL_CODE(FILE_DEVICE_UNKNOWN,\
115 0x901, METHOD_BUFFERED, FILE_ANY_ACCESS)
116
117 /////////////////////////////////////////////////////////////////////////////
118
119 /////////////////////////////////////////////////////////////////////////////
120 // supported after 1.2.0.0
121 /////////////////////////////////////////////////////////////////////////////
122 #define LIBUSB_IOCTL_GET_CACHED_CONFIGURATION CTL_CODE(FILE_DEVICE_UNKNOWN,\
123 0x902, METHOD_BUFFERED, FILE_ANY_ACCESS)
124 /////////////////////////////////////////////////////////////////////////////
125
126 /////////////////////////////////////////////////////////////////////////////
127 // supported after 1.2.2.0
128 /////////////////////////////////////////////////////////////////////////////
129 #define LIBUSB_IOCTL_GET_OBJECT_NAME CTL_CODE(FILE_DEVICE_UNKNOWN,\
130 0x8FF, METHOD_BUFFERED, FILE_ANY_ACCESS)
131 /////////////////////////////////////////////////////////////////////////////
132
133 /////////////////////////////////////////////////////////////////////////////
134 // supported after 1.2.3.0
135 /////////////////////////////////////////////////////////////////////////////
136 #define LIBUSB_IOCTL_QUERY_DEVICE_INFORMATION CTL_CODE(FILE_DEVICE_UNKNOWN,\
137 0x904, METHOD_BUFFERED, FILE_ANY_ACCESS)
138
139 #define LIBUSB_IOCTL_SET_PIPE_POLICY CTL_CODE(FILE_DEVICE_UNKNOWN,\
140 0x906, METHOD_BUFFERED, FILE_ANY_ACCESS)
141
142 #define LIBUSB_IOCTL_GET_PIPE_POLICY CTL_CODE(FILE_DEVICE_UNKNOWN,\
143 0x907, METHOD_BUFFERED, FILE_ANY_ACCESS)
144
145 #define LIBUSB_IOCTL_SET_POWER_POLICY CTL_CODE(FILE_DEVICE_UNKNOWN,\
146 0x908, METHOD_BUFFERED, FILE_ANY_ACCESS)
147
148 #define LIBUSB_IOCTL_GET_POWER_POLICY CTL_CODE(FILE_DEVICE_UNKNOWN,\
149 0x909, METHOD_BUFFERED, FILE_ANY_ACCESS)
150
151 #define LIBUSB_IOCTL_CONTROL_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
152 0x90A, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
153
154 #define LIBUSB_IOCTL_CONTROL_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
155 0x90B, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
156
157 #define LIBUSB_IOCTL_FLUSH_PIPE CTL_CODE(FILE_DEVICE_UNKNOWN,\
158 0x90C, METHOD_BUFFERED, FILE_ANY_ACCESS)
159
160 #define LIBUSBK_IOCTL_CLAIM_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
161 0x90D, METHOD_BUFFERED, FILE_ANY_ACCESS)
162
163 #define LIBUSBK_IOCTL_RELEASE_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
164 0x90E, METHOD_BUFFERED, FILE_ANY_ACCESS)
165
166 #define LIBUSBK_IOCTL_RELEASE_ALL_INTERFACES CTL_CODE(FILE_DEVICE_UNKNOWN,\
167 0x90F, METHOD_BUFFERED, FILE_ANY_ACCESS)
168
169 #define LIBUSBK_IOCTL_SET_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
170 0x910, METHOD_BUFFERED, FILE_ANY_ACCESS)
171
172 #define LIBUSBK_IOCTL_GET_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
173 0x911, METHOD_BUFFERED, FILE_ANY_ACCESS)
174
175 /////////////////////////////////////////////////////////////////////////////
176 // supported after 1.2.4.8 (libusb0.sys only)
177 /////////////////////////////////////////////////////////////////////////////
178 #define LIBUSB_IOCTL_RESET_DEVICE_EX CTL_CODE(FILE_DEVICE_UNKNOWN,\
179 0x817, METHOD_BUFFERED, FILE_ANY_ACCESS)
180
181 #include <pshpack1.h>
182
183 enum LIBUSB0_TRANSFER_FLAGS
184 {
185 TRANSFER_FLAGS_SHORT_NOT_OK = 1 << 0,
186 TRANSFER_FLAGS_ISO_SET_START_FRAME = 1 << 30,
187 TRANSFER_FLAGS_ISO_ADD_LATENCY = 1 << 31,
188 };
189
190 /*
191 typedef struct
192 {
193 unsigned int timeout;
194 union
195 {
196 struct
197 {
198 unsigned int configuration;
199 } configuration;
200 struct
201 {
202 unsigned int interface;
203 unsigned int altsetting;
204 } interface;
205 struct
206 {
207 unsigned int endpoint;
208 unsigned int packet_size;
209
210 // TODO: max_transfer_size, short transfer not ok, use iso_start_frame
211 unsigned int max_transfer_size;
212 unsigned int transfer_flags;
213 unsigned int iso_start_frame_latency;
214 } endpoint;
215 struct
216 {
217 unsigned int type;
218 unsigned int recipient;
219 unsigned int request;
220 unsigned int value;
221 unsigned int index;
222 } vendor;
223 struct
224 {
225 unsigned int recipient;
226 unsigned int feature;
227 unsigned int index;
228 } feature;
229 struct
230 {
231 unsigned int recipient;
232 unsigned int index;
233 unsigned int status;
234 } status;
235 struct
236 {
237 unsigned int type;
238 unsigned int index;
239 unsigned int language_id;
240 unsigned int recipient;
241 } descriptor;
242 struct
243 {
244 unsigned int level;
245 } debug;
246 struct
247 {
248 unsigned int major;
249 unsigned int minor;
250 unsigned int micro;
251 unsigned int nano;
252 unsigned int mod_value;
253 } version;
254 struct
255 {
256 unsigned int property;
257 } device_property;
258 struct
259 {
260 unsigned int key_type;
261 unsigned int name_offset;
262 unsigned int value_offset;
263 unsigned int value_length;
264 } device_registry_key;
265 struct
266 {
267 // 0 - device plug and play registry key pathname
268 unsigned int objname_index;
269 } objname;
270 };
271 } libusb_request;
272 */
273
274 #pragma warning(disable:4201)
275
276 typedef struct
277 {
278 unsigned int interface_number;
279 unsigned int altsetting_number;
280
281 unsigned char intf_use_index:1; // libusbK Only
282 unsigned char altf_use_index:1; // libusbK Only
283 unsigned char:6;
284
285 short interface_index; // libusbK Only
286 short altsetting_index; // libusbK Only
287 }interface_request_t;
288
289 typedef struct
290 {
291 unsigned int timeout;
292 union
293 {
294 struct
295 {
296 unsigned int configuration;
297 } configuration;
298
299 interface_request_t intf;
300
301 struct
302 {
303 unsigned int endpoint;
304 unsigned int packet_size;
305
306 // TODO: max_transfer_size, short transfer not ok, use iso_start_frame
307 unsigned int max_transfer_size;
308 unsigned int transfer_flags;
309 unsigned int iso_start_frame_latency;
310 } endpoint;
311 struct
312 {
313 unsigned int type;
314 unsigned int recipient;
315 unsigned int request;
316 unsigned int value;
317 unsigned int index;
318 } vendor;
319 struct
320 {
321 unsigned int recipient;
322 unsigned int feature;
323 unsigned int index;
324 } feature;
325 struct
326 {
327 unsigned int recipient;
328 unsigned int index;
329 unsigned int status;
330 } status;
331 struct
332 {
333 unsigned int type;
334 unsigned int index;
335 unsigned int language_id;
336 unsigned int recipient;
337 } descriptor;
338 struct
339 {
340 unsigned int level;
341 } debug;
342 struct
343 {
344 unsigned int major;
345 unsigned int minor;
346 unsigned int micro;
347 unsigned int nano;
348 unsigned int mod_value;
349 } version;
350 struct
351 {
352 unsigned int property;
353 } device_property;
354 struct
355 {
356 unsigned int key_type;
357 unsigned int name_offset;
358 unsigned int value_offset;
359 unsigned int value_length;
360 } device_registry_key;
361 struct
362 {
363 // 0 - device plug and play registry key pathname
364 unsigned int objname_index;
365 } objname;
366 struct
367 {
368 ULONG information_type;
369 } query_device;
370 struct
371 {
372 unsigned int interface_index;
373 unsigned int pipe_id;
374 unsigned int policy_type;
375 } pipe_policy;
376 struct
377 {
378 unsigned int policy_type;
379 } power_policy;
380 struct
381 {
382 unsigned int reset_type;
383 } reset_ex;
384
385 // WDF_USB_CONTROL_SETUP_PACKET control;
386 struct
387 {
388 UCHAR RequestType;
389 UCHAR Request;
390 USHORT Value;
391 USHORT Index;
392 USHORT Length;
393 } control;
394 };
395 } libusb_request;
396 #pragma warning(default:4201)
397
398 #include <poppack.h>
399
400 #endif