~ubuntu-branches/ubuntu/raring/vala-0.20/raring-proposed

« back to all changes in this revision

Viewing changes to vapi/libusb-1.0.vapi

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-04-05 13:45:05 UTC
  • Revision ID: package-import@ubuntu.com-20130405134505-yyk3rec9904i7p8o
Tags: upstream-0.20.1
ImportĀ upstreamĀ versionĀ 0.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
[CCode (cprefix = "libusb_", cheader_filename = "libusb.h")]
 
2
namespace LibUSB {
 
3
        [CCode (cname = "enum libusb_class_code", cprefix = "LIBUSB_CLASS_")]
 
4
        public enum ClassCode {
 
5
                PER_INTERFACE,
 
6
                AUDIO,
 
7
                COMM,
 
8
                HID,
 
9
                PRINTER,
 
10
                PTP,
 
11
                MASS_STORAGE,
 
12
                HUB,
 
13
                DATA,
 
14
                VENDOR_SPEC
 
15
        }
 
16
 
 
17
        [CCode (cname = "enum libusb_descriptor_type", cprefix = "LIBUSB_DT_")]
 
18
        public enum DescriptorType {
 
19
                DEVICE,
 
20
                CONFIG,
 
21
                STRING,
 
22
                INTERFACE,
 
23
                ENDPOINT,
 
24
                HID,
 
25
                REPORT,
 
26
                PHYSICAL,
 
27
                HUB
 
28
        }
 
29
 
 
30
        [CCode (cprefix = "LIBUSB_DT_")]
 
31
        namespace DescriptorTypeSize {
 
32
                public const int DEVICE_SIZE;
 
33
                public const int CONFIG_SIZE;
 
34
                public const int INTERFACE_SIZE;
 
35
                public const int ENDPOINT_SIZE;
 
36
                public const int ENDPOINT_AUDIO_SIZE;
 
37
                public const int HUB_NONVAR_SIZE;
 
38
        }
 
39
 
 
40
        namespace EndpointMask {
 
41
                [CCode (cname = "LIBUSB_ENDPOINT_ADDRESS_MASK")]
 
42
                public const int ADDRESS;
 
43
                [CCode (cname = "LIBUSB_ENDPOINT_DIR_MASK")]
 
44
                public const int DIR;
 
45
                [CCode (cname = "LIBUSB_ENDPOINT_DIR_MASK")]
 
46
                public const int DIRECTION;
 
47
        }
 
48
 
 
49
        [CCode (cname = "enum libusb_endpoint_direction", cprefix = "LIBUSB_ENDPOINT_")]
 
50
        public enum EndpointDirection {
 
51
                IN,
 
52
                OUT,
 
53
                [CCode (cname = "LIBUSB_ENDPOINT_DIR_MASK")]
 
54
                MASK
 
55
        }
 
56
 
 
57
        [CCode (cname = "enum libusb_transfer_type", cprefix = "LIBUSB_TRANSFER_TYPE_")]
 
58
        public enum TransferType {
 
59
                CONTROL,
 
60
                ISOCHRONOUS,
 
61
                BULK,
 
62
                INTERRUPT
 
63
        }
 
64
 
 
65
        [CCode (cname = "enum libusb_standard_request", cprefix = "LIBUSB_REQUEST_")]
 
66
        public enum StandardRequest {
 
67
                GET_STATUS,
 
68
                CLEAR_FEATURE,
 
69
                SET_FEATURE,
 
70
                SET_ADDRESS,
 
71
                GET_DESCRIPTOR,
 
72
                SET_DESCRIPTOR,
 
73
                GET_CONFIGURATION,
 
74
                GET_INTERFACE,
 
75
                SET_INTERFACE,
 
76
                SYNCH_FRAME
 
77
        }
 
78
 
 
79
        [CCode (cname = "enum libusb_request_type", cprefix = "LIBUSB_REQUEST_TYPE_")]
 
80
        public enum RequestType {
 
81
                STANDARD,
 
82
                CLASS,
 
83
                VENDOR,
 
84
                RESERVED
 
85
        }
 
86
 
 
87
        [CCode (cname = "enum libusb_request_recipient", cprefix = "LIBUSB_RECIPIENT_")]
 
88
        public enum RequestRecipient {
 
89
                DEVICE,
 
90
                INTERFACE,
 
91
                ENDPOINT,
 
92
                OTHER
 
93
        }
 
94
 
 
95
        [CCode (cname = "enum libusb_iso_sync_type", cprefix = "LIBUSB_ISO_SYNC_TYPE_")]
 
96
        public enum IsoSyncType {
 
97
                NONE,
 
98
                ASYNC,
 
99
                ADAPTIVE,
 
100
                SYNC,
 
101
                MASK
 
102
        }
 
103
 
 
104
        [CCode (cname = "enum libusb_iso_usage_type", cprefix = "LIBUSB_ISO_USAGE_TYPE_")]
 
105
        public enum IsoUsageType {
 
106
                DATA,
 
107
                FEEDBACK,
 
108
                IMPLICIT,
 
109
                MASK
 
110
        }
 
111
 
 
112
        [CCode (cname = "enum libusb_error", cprefix = "LIBUSB_ERROR_")]
 
113
        public enum Error {
 
114
                [CCode (cname = "LIBUSB_SUCCESS")]
 
115
                SUCCESS,
 
116
                IO,
 
117
                INVALID_PARAM,
 
118
                ACCESS,
 
119
                NO_DEVICE,
 
120
                NOT_FOUND,
 
121
                BUSY,
 
122
                TIMEOUT,
 
123
                OVERFLOW,
 
124
                PIPE,
 
125
                INTERRUPTED,
 
126
                NO_MEM,
 
127
                NOT_SUPPORTED,
 
128
                OTHER
 
129
        }
 
130
 
 
131
        [CCode (cname = "enum libusb_transfer_flags", cprefix = "LIBUSB_TRANSFER_")]
 
132
        public enum TransferFlags {
 
133
                SHORT_NOT_OK,
 
134
                FREE_BUFFER,
 
135
                FREE_TRANSFER
 
136
        }
 
137
 
 
138
        [CCode (cname = "struct libusb_device_descriptor")]
 
139
        public struct DeviceDescriptor {
 
140
                public uint8 bLength;
 
141
                public uint8 bDescriptorType;
 
142
                public uint16 bcdUSB;
 
143
                public uint8 bDeviceClass;
 
144
                public uint8 bDeviceSubClass;
 
145
                public uint8 bDeviceProtocol;
 
146
                public uint8 bMaxPacketSize0;
 
147
                public uint16 idVendor;
 
148
                public uint16 idProduct;
 
149
                public uint16 bcdDevice;
 
150
                public uint8 iManufacturer;
 
151
                public uint8 iProduct;
 
152
                public uint8 iSerialNumber;
 
153
                public uint8 bNumConfigurations;
 
154
 
 
155
                [CCode (cname = "libusb_get_device_descriptor", instance_pos = -1)]
 
156
                public DeviceDescriptor (Device device);
 
157
        }
 
158
 
 
159
        [CCode (cname = "struct libusb_endpoint_descriptor", cprefix = "libusb_")]
 
160
        public struct EndpointDescriptor {
 
161
                public uint8 bLength;
 
162
                public uint8 bDescriptorType;
 
163
                public uint8 bEndpointAddress;
 
164
                public uint8 bmAttributes;
 
165
                public uint16 wMaxPacketSize;
 
166
                public uint8 bInterval;
 
167
                public uint8 bRefresh;
 
168
                public uint8 bSynchAddress;
 
169
                [CCode (array_length_cname = "extra_length")]
 
170
                public uint8[] extra;
 
171
        }
 
172
 
 
173
        [CCode (cname = "struct libusb_interface_descriptor")]
 
174
        public struct InterfaceDescriptor {
 
175
                public uint8 bLength;
 
176
                public uint8 bDescriptorType;
 
177
                public uint8 bInterfaceNumber;
 
178
                public uint8 bAlternateSetting;
 
179
                public uint8 bNumEndpoints;
 
180
                public uint8 bInterfaceClass;
 
181
                public uint8 bInterfaceSubClass;
 
182
                public uint8 bInterfaceProtocol;
 
183
                public uint8 iInterface;
 
184
                [CCode (array_length_cname = "bNumEndpoints", array_length_type = "uint8_t")]
 
185
                public EndpointDescriptor[] endpoint;
 
186
                [CCode (array_length_cname = "extra_length")]
 
187
                public uint8[] extra;
 
188
        }
 
189
 
 
190
        [CCode (cname = "struct libusb_interface")]
 
191
        public struct Interface {
 
192
                [CCode (array_length_cname = "num_altsetting")]
 
193
                public InterfaceDescriptor[] altsetting;
 
194
        }
 
195
 
 
196
        [Compact, CCode (cname = "struct libusb_config_descriptor", free_function = "libusb_free_config_descriptor")]
 
197
        public class ConfigDescriptor {
 
198
                public uint8 bLength;
 
199
                public uint8 bDescriptorType;
 
200
                public uint16 wTotalLength;
 
201
                public uint8 bNumInterfaces;
 
202
                public uint8 bConfigurationValue;
 
203
                public uint8 iConfiguration;
 
204
                public uint8 bmAttributes;
 
205
                public uint8 MaxPower;
 
206
                [CCode (array_length_cname = "bNumInterfaces")]
 
207
                public Interface[] @interface;
 
208
                [CCode (array_length_cname = "extra_length")]
 
209
                public uint8[] extra;
 
210
        }
 
211
 
 
212
 
 
213
        [Compact, CCode (cname = "libusb_device_handle", cprefix = "libusb_", free_function = "libusb_close")]
 
214
        public class DeviceHandle {
 
215
                public DeviceHandle (Device device) {
 
216
                        DeviceHandle handle;
 
217
                        device.open(out handle);
 
218
                }
 
219
 
 
220
                [CCode (cname = "libusb_open_device_with_vid_pid")]
 
221
                public DeviceHandle.from_vid_pid (Context? context, uint16 vendor_id, uint16 product_id);
 
222
                public unowned Device get_device ();
 
223
                public int get_configuration (out int config);
 
224
                public int set_configuration (int configuration);
 
225
                public int claim_interface (int interface_number);
 
226
                public int release_interface (int interface_number);
 
227
                public int set_interface_alt_setting (int interface_number, int alternate_setting);
 
228
                public int clear_halt (uchar endpoint);
 
229
                [CCode (cname = "libusb_reset_device")]
 
230
                public int reset ();
 
231
                public int kernel_driver_active (int @interface);
 
232
                public int detach_kernel_driver (int @interface);
 
233
                public int attach_kernel_driver (int @interface);
 
234
 
 
235
                public int get_string_descriptor_ascii (uint8 desc_index, uint8[] data);
 
236
                public int get_descriptor (uint8 desc_type, uint8 desc_index, uint8[] data);
 
237
                public int get_string_descriptor (uint desc_index, uint16 langid, uint8[] data);
 
238
 
 
239
                public int control_transfer (uint8 bmRequestType, uint8 bRequest, uint16 wValue, uint16 wIndex, [CCode (array_length = false)] uint8[] data, uint16 wLength, uint timeout);
 
240
                public int bulk_transfer (uint8 endpoint, uint8[] data, out int transferred, uint timeout);
 
241
                public int interrupt_transfer (uint8 endpoint, uint8[] data, out int transferred, uint timeout);
 
242
        }
 
243
 
 
244
        [CCode (cname = "libusb_device", cprefix = "libusb_", ref_function = "libusb_ref_device", unref_function = "libusb_unref_device")]
 
245
        public class Device {
 
246
                public uint8 get_bus_number ();
 
247
                public uint8 get_device_address ();
 
248
                public int get_max_packet_size (uint8 endpoint);
 
249
                public int open (out DeviceHandle handle);
 
250
 
 
251
                public int get_active_config_descriptor (out ConfigDescriptor config);
 
252
                public int get_config_descriptor (uint8 config_index, out ConfigDescriptor config);
 
253
                public int get_config_descriptor_by_value (uint8 ConfigurationValue, out ConfigDescriptor config);
 
254
                public int get_device_descriptor (out DeviceDescriptor desc);
 
255
        }
 
256
 
 
257
        [Compact, CCode (cname = "libusb_context", cprefix = "libusb_", free_function = "libusb_exit")]
 
258
        public class Context {
 
259
                public static int init (out Context context);
 
260
                public void set_debug (int level);
 
261
                public ssize_t get_device_list ([CCode (array_length = false)] out Device[] list);
 
262
                public DeviceHandle open_device_with_vid_pid (uint16 vendor_id, uint16 product_id);
 
263
 
 
264
                public int try_lock_events ();
 
265
                public void lock_events ();
 
266
                public void unlock_events ();
 
267
                public int event_handling_ok ();
 
268
                public int event_handler_active ();
 
269
                public void lock_event_waiters ();
 
270
                public void unlock_event_waiters ();
 
271
                public int wait_for_event (Posix.timeval tv);
 
272
                public int handle_events_timeout (Posix.timeval tv);
 
273
                public int handle_events ();
 
274
                public int handle_events_locked (Posix.timeval tv);
 
275
                public int get_next_timeout (out Posix.timeval tv);
 
276
                public void set_pollfd_notifiers (pollfd_added_cb added_cb, pollfd_removed_cb removed_cb, void* user_data);
 
277
                [CCode (array_length = false)]
 
278
                public unowned PollFD[] get_pollfds ();
 
279
        }
 
280
 
 
281
        public static uint16 le16_to_cpu (uint16 n);
 
282
        public static uint16 cpu_to_le16 (uint16 n);
 
283
        [CCode (cname = "malloc", cheader_filename = "stdlib.h")]
 
284
        private static void* malloc (ulong n_bytes);
 
285
 
 
286
        [Compact, CCode (cname = "struct libusb_control_setup")]
 
287
        public class ControlSetup {
 
288
                public uint8 bmRequestType;
 
289
                public int8 bRequest;
 
290
                public uint16 wValue;
 
291
                public uint16 wIndex;
 
292
                public uint16 wLength;
 
293
        }
 
294
 
 
295
        [CCode (cname = "enum libusb_transfer_status", cprefix = "LIBUSB_TRANSFER_")]
 
296
        public enum TransferStatus {
 
297
                COMPLETED,
 
298
                ERROR,
 
299
                TIMED_OUT,
 
300
                CANCELLED,
 
301
                STALL,
 
302
                NO_DEVICE,
 
303
                OVERFLOW
 
304
        }
 
305
 
 
306
        [CCode (cname = "struct libusb_iso_packet_descriptor")]
 
307
        public struct IsoPacketDescriptor {
 
308
                public uint length;
 
309
                public uint actual_length;
 
310
                public TransferStatus status;
 
311
        }
 
312
 
 
313
        [CCode (has_target = false)]
 
314
        public delegate void transfer_cb_fn (Transfer transfer);
 
315
 
 
316
        [Compact, CCode (cname = "struct libusb_transfer", cprefix = "libusb_", free_function = "libusb_free_transfer")]
 
317
        public class Transfer {
 
318
                public DeviceHandle dev_handle;
 
319
                public uint8 flags;
 
320
                public uint8 endpoint;
 
321
                public uint8 type;
 
322
                public uint timeout;
 
323
                public TransferStatus status;
 
324
                public int length;
 
325
                public int actual_length;
 
326
                public transfer_cb_fn @callback;
 
327
                public void* user_data;
 
328
                [CCode (array_length_cname = "length")]
 
329
                public uint8[] buffer;
 
330
                public int num_iso_packets;
 
331
                [CCode (array_length = false)]
 
332
                public IsoPacketDescriptor[] iso_packet_desc;
 
333
 
 
334
                [CCode (cname = "libusb_alloc_transfer")]
 
335
                public Transfer (int iso_packets = 0);
 
336
                [CCode (cname = "libusb_submit_transfer")]
 
337
                public int submit ();
 
338
                [CCode (cname = "libusb_cancel_transfer")]
 
339
                public int cancel ();
 
340
                [CCode (cname = "libusb_contrel_transfer_get_data", array_length = false)]
 
341
                public unowned char[] control_get_data ();
 
342
                [CCode (cname = "libusb_control_transfer_get_setup")]
 
343
                public unowned ControlSetup control_get_setup ();
 
344
 
 
345
                public static void fill_control_setup ([CCode (array_length = false)] uint8[] buffer, uint8 bmRequestType, uint8 bRequest, uint16 wValue, uint16 wIndex, uint16 wLength);
 
346
                public void fill_control_transfer (DeviceHandle dev_handle, [CCode (array_length = false)] uint8[] buffer, transfer_cb_fn @callback, void* user_data, uint timeout);
 
347
                public void fill_bulk_transfer (DeviceHandle dev_handle, uint8 endpoint, uint8[] buffer, transfer_cb_fn @callback, void* user_data, uint timeout);
 
348
                public void fill_interrupt_transfer (DeviceHandle dev_handle, uint8 endpoint, uint8[] buffer, transfer_cb_fn @callback, void* user_data, uint timeout);
 
349
                public void fill_iso_transfer (DeviceHandle dev_handle, uint8 endpoint, uint8[] buffer, int num_iso_packets, transfer_cb_fn @callback, void* user_data, uint timeout);
 
350
                public void set_packet_lengths (uint length);
 
351
                [CCode (array_length = false)]
 
352
                public unowned uint8[] get_iso_packet_buffer (uint packet);
 
353
                [CCode (array_length = false)]
 
354
                public unowned uint8[] get_iso_packet_buffer_simple (int packet);
 
355
        }
 
356
 
 
357
        [CCode (has_target = false)]
 
358
        public delegate void pollfd_added_cb (int fd, short events, void* user_data);
 
359
        [CCode (has_target = false)]
 
360
        public delegate void pollfd_removed_cb (int fd, void* user_data);
 
361
 
 
362
        [Compact, CCode (cname = "struct libusb_pollfd")]
 
363
        public class PollFD {
 
364
                public int fd;
 
365
                public short events;
 
366
        }
 
367
}