1 [CCode (cprefix = "usb_", cheader_filename = "usb.h")]
3 [CCode (cprefix = "USB_CLASS_", cheader_filename = "usb.h")]
17 [CCode (cprefix = "USB_DT_", cheader_filename = "usb.h")]
18 public enum DescriptorType {
30 [CCode (cprefix = "USB_DT_", cheader_filename = "usb.h")]
31 public enum DescriptorSize {
32 [CCode (cname = "USB_DT_DEVICE_SIZE")]
34 [CCode (cname = "USB_DT_CONFIG_SIZE")]
36 [CCode (cname = "USB_DT_INTERFACE_SIZE")]
38 [CCode (cname = "USB_DT_ENDPOINT_SIZE")]
40 [CCode (cname = "USB_DT_ENDPOINT_AUDIO_SIZE")]
42 [CCode (cname = "USB_DT_HUB_NONVAR_SIZE")]
46 [CCode (cprefix = "USB_ENDPOINT_", cheader_filename = "usb.h")]
47 public enum EndpointAttribute {
58 [CCode (cprefix = "USB_ENDPOINT_", cheader_filename = "usb.h")]
59 public enum EndpointAddress {
66 [CCode (cprefix = "USB_REQ_", cheader_filename = "usb.h")]
81 [CCode (cprefix = "USB_TYPE_", cheader_filename = "usb.h")]
89 [CCode (cname = "struct usb_endpoint_descriptor", cheader_filename = "usb.h")]
90 public struct EndpointDescriptor {
92 public uint8 bDescriptorType;
93 public uint8 bEndpointAddress;
94 public uint8 bmAttributes;
95 public uint16 wMaxPacketSize;
96 public uint8 bInterval;
97 public uint8 bRefresh;
98 public uint8 bSynchAddress;
100 [CCode (array_length_cname = "extralen")]
101 public uchar[] extra;
104 [CCode (cname = "struct usb_interface_descriptor", cheader_filename = "usb.h")]
105 public struct InterfaceDescriptor {
106 public uint8 bLength;
107 public uint8 bDescriptorType;
108 public uint8 bInterfaceNumber;
109 public uint8 bAlternateSetting;
110 public uint8 bNumEndpoints;
111 public uint8 bInterfaceClass;
112 public uint8 bInterfaceSubClass;
113 public uint8 bInterfaceProtocol;
114 public uint8 iInterface;
116 [CCode (array_length_cname = "bNumEndpoints", array_length_type = "uint8_t")]
117 public EndpointDescriptor[] endpoint;
119 [CCode (array_length_cname = "extralen")]
120 public uchar[] extra;
123 [CCode (cname = "struct usb_interface", cheader_filename = "usb.h")]
124 public struct Interface {
125 [CCode (array_length_cname = "num_altsetting")]
126 public InterfaceDescriptor[] altsetting;
129 [Compact, CCode (cname = "struct usd_config_descriptor")]
130 public class ConfigDescriptor {
131 public uint8 bLength;
132 public uint8 bDescriptorType;
133 public uint16 wTotalLength;
134 public uint8 bNumInterfaces;
135 public uint8 bConfigurationValue;
136 public uint8 iConfiguration;
137 public uint8 bmAttributes;
138 public uint8 MaxPower;
140 [CCode (array_length_cname = "bNumInterfaces", array_length_type = "uint8_t")]
141 public Interface[] @interface;
142 [CCode (array_length_cname = "extralen")]
143 public uchar[] extra;
146 [CCode (cname = "struct usb_device_descriptor", cheader_filename = "usb.h")]
147 public struct DeviceDescriptor {
148 public uint8 bLength;
149 public uint8 bDescriptorType;
150 public uint16 bcdUSB;
151 public uint8 bDeviceClass;
152 public uint8 bDeviceSubClass;
153 public uint8 bDeviceProtocol;
154 public uint8 bMaxPacketSize0;
155 public uint16 idVendor;
156 public uint16 idProduct;
157 public uint16 bcdDevice;
158 public uint8 iManufacturer;
159 public uint8 iProduct;
160 public uint8 iSerialNumber;
161 public uint8 bNumConfigurations;
164 [Compact, CCode (cname = "struct usb_device", cprefix = "usb_", cheader_filename = "usb.h")]
165 public class Device {
168 public string filename;
170 public DeviceDescriptor descriptor;
171 [CCode (array_length = false)]
172 public ConfigDescriptor config;
175 public uchar num_children;
176 [CCode (array_length_cname = "num_children", array_length_type = "unsigned char")]
177 public Device[] children;
180 [Compact, CCode (cname = "struct usb_bus", cheader_filename = "usb.h")]
184 public string dirname;
185 public Device devices;
186 public uint32 location;
187 public Device root_dev;
190 [Compact, CCode (cname = "usb_dev_handle", cprefix = "usb_", cheader_filename = "usb.h", free_function = "usb_close")]
191 public class DeviceHandle {
192 [CCode (cname = "usb_open")]
193 public DeviceHandle (Device dev);
194 public int get_string (int index, int langid, [CCode (array_length = false)] char[] buf, size_t buflen);
195 public int get_string_simple (int index, [CCode (array_length = false)] char[] buf, size_t buflen);
197 public int get_descriptor_by_endpoint (int ep, uchar type, uchar index, void * buf, int size);
198 public int get_descriptor (uchar type, uchar index, void * buf, int size);
199 public int bulk_write (int ep, [CCode (array_length = false)] char[] bytes, int size, int timeout);
200 public int bulk_read (int ep, [CCode (array_length = false)] char[] bytes, int size, int timeout);
201 public int interrupt_write (int ep, [CCode (array_length = false)] char[] bytes, int size, int timeout);
202 public int interrupt_read (int ep, [CCode (array_length = false)] char[] bytes, int size, int timeout);
203 public int control_msg (int requesttype, int request, int value, int index, char[] bytes, int size, int timeout);
204 public int set_configuration (int configuration);
205 public int claim_interface (int @interface);
206 public int release_interface (int @interface);
207 public int set_altinterface (int alternate);
208 public int resetep (uint ep);
209 public int clear_halt (uint ep);
211 public unowned Device device ();
214 [CCode (array_length = false)]
215 public static weak char[] strerror ();
216 public static void init ();
217 public static void set_debug (int level);
218 public static int find_busses ();
219 public static int find_devices ();
220 public static unowned Bus get_busses ();
221 [CCode (cname = "USB_LE16_TO_CPU")]
222 public static uint16 le16_to_cpu (uint16 x);