| 1 |
/* LIBUSB-WIN32, Generic Windows USB Library |
| 2 |
* Copyright (c) 2002-2005 Stephan Meyer <[email protected]> |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Lesser General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library 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 GNU |
| 12 |
* Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public |
| 15 |
* License along with this library; if not, write to the Free Software |
| 16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 |
*/ |
| 18 |
|
| 19 |
|
| 20 |
#include <windows.h> |
| 21 |
#include <errno.h> |
| 22 |
|
| 23 |
#include "usb.h" |
| 24 |
|
| 25 |
#define LIBUSB_DLL_NAME "libusb0.dll" |
| 26 |
|
| 27 |
|
| 28 |
typedef usb_dev_handle * (*usb_open_t)(struct usb_device *dev); |
| 29 |
typedef int (*usb_close_t)(usb_dev_handle *dev); |
| 30 |
typedef int (*usb_get_string_t)(usb_dev_handle *dev, int index, int langid, |
| 31 |
char *buf, size_t buflen); |
| 32 |
typedef int (*usb_get_string_simple_t)(usb_dev_handle *dev, int index, |
| 33 |
char *buf, size_t buflen); |
| 34 |
typedef int (*usb_get_descriptor_by_endpoint_t)(usb_dev_handle *udev, int ep, |
| 35 |
unsigned char type, |
| 36 |
unsigned char index, |
| 37 |
void *buf, int size); |
| 38 |
typedef int (*usb_get_descriptor_t)(usb_dev_handle *udev, unsigned char type, |
| 39 |
unsigned char index, void *buf, int size); |
| 40 |
typedef int (*usb_bulk_write_t)(usb_dev_handle *dev, int ep, char *bytes, |
| 41 |
int size, int timeout); |
| 42 |
typedef int (*usb_bulk_read_t)(usb_dev_handle *dev, int ep, char *bytes, |
| 43 |
int size, int timeout); |
| 44 |
typedef int (*usb_interrupt_write_t)(usb_dev_handle *dev, int ep, char *bytes, |
| 45 |
int size, int timeout); |
| 46 |
typedef int (*usb_interrupt_read_t)(usb_dev_handle *dev, int ep, char *bytes, |
| 47 |
int size, int timeout); |
| 48 |
typedef int (*usb_control_msg_t)(usb_dev_handle *dev, int requesttype, |
| 49 |
int request, int value, int index, |
| 50 |
char *bytes, int size, int timeout); |
| 51 |
typedef int (*usb_set_configuration_t)(usb_dev_handle *dev, int configuration); |
| 52 |
typedef int (*usb_claim_interface_t)(usb_dev_handle *dev, int interface); |
| 53 |
typedef int (*usb_release_interface_t)(usb_dev_handle *dev, int interface); |
| 54 |
typedef int (*usb_set_altinterface_t)(usb_dev_handle *dev, int alternate); |
| 55 |
typedef int (*usb_resetep_t)(usb_dev_handle *dev, unsigned int ep); |
| 56 |
typedef int (*usb_clear_halt_t)(usb_dev_handle *dev, unsigned int ep); |
| 57 |
typedef int (*usb_reset_t)(usb_dev_handle *dev); |
| 58 |
typedef int (*usb_reset_ex_t)(usb_dev_handle *dev, unsigned int reset_type); |
| 59 |
typedef char * (*usb_strerror_t)(void); |
| 60 |
typedef void (*usb_init_t)(void); |
| 61 |
typedef void (*usb_set_debug_t)(int level); |
| 62 |
typedef int (*usb_find_busses_t)(void); |
| 63 |
typedef int (*usb_find_devices_t)(void); |
| 64 |
typedef struct usb_device * (*usb_device_t)(usb_dev_handle *dev); |
| 65 |
typedef struct usb_bus * (*usb_get_busses_t)(void); |
| 66 |
typedef int (*usb_install_service_np_t)(void); |
| 67 |
typedef int (*usb_uninstall_service_np_t)(void); |
| 68 |
typedef int (*usb_install_driver_np_t)(const char *inf_file); |
| 69 |
typedef const struct usb_version * (*usb_get_version_t)(void); |
| 70 |
typedef int (*usb_isochronous_setup_async_t)(usb_dev_handle *dev, |
| 71 |
void **context, |
| 72 |
unsigned char ep, int pktsize); |
| 73 |
typedef int (*usb_bulk_setup_async_t)(usb_dev_handle *dev, void **context, |
| 74 |
unsigned char ep); |
| 75 |
typedef int (*usb_interrupt_setup_async_t)(usb_dev_handle *dev, void **context, |
| 76 |
unsigned char ep); |
| 77 |
typedef int (*usb_submit_async_t)(void *context, char *bytes, int size); |
| 78 |
typedef int (*usb_reap_async_t)(void *context, int timeout); |
| 79 |
typedef int (*usb_reap_async_nocancel_t)(void *context, int timeout); |
| 80 |
typedef int (*usb_cancel_async_t)(void *context); |
| 81 |
typedef int (*usb_free_async_t)(void **context); |
| 82 |
|
| 83 |
|
| 84 |
static usb_open_t _usb_open = NULL; |
| 85 |
static usb_close_t _usb_close = NULL; |
| 86 |
static usb_get_string_t _usb_get_string = NULL; |
| 87 |
static usb_get_string_simple_t _usb_get_string_simple = NULL; |
| 88 |
static usb_get_descriptor_by_endpoint_t _usb_get_descriptor_by_endpoint = NULL; |
| 89 |
static usb_get_descriptor_t _usb_get_descriptor = NULL; |
| 90 |
static usb_bulk_write_t _usb_bulk_write = NULL; |
| 91 |
static usb_bulk_read_t _usb_bulk_read = NULL; |
| 92 |
static usb_interrupt_write_t _usb_interrupt_write = NULL; |
| 93 |
static usb_interrupt_read_t _usb_interrupt_read = NULL; |
| 94 |
static usb_control_msg_t _usb_control_msg = NULL; |
| 95 |
static usb_set_configuration_t _usb_set_configuration = NULL; |
| 96 |
static usb_claim_interface_t _usb_claim_interface = NULL; |
| 97 |
static usb_release_interface_t _usb_release_interface = NULL; |
| 98 |
static usb_set_altinterface_t _usb_set_altinterface = NULL; |
| 99 |
static usb_resetep_t _usb_resetep = NULL; |
| 100 |
static usb_clear_halt_t _usb_clear_halt = NULL; |
| 101 |
static usb_reset_t _usb_reset = NULL; |
| 102 |
static usb_reset_ex_t _usb_reset_ex = NULL; |
| 103 |
static usb_strerror_t _usb_strerror = NULL; |
| 104 |
static usb_init_t _usb_init = NULL; |
| 105 |
static usb_set_debug_t _usb_set_debug = NULL; |
| 106 |
static usb_find_busses_t _usb_find_busses = NULL; |
| 107 |
static usb_find_devices_t _usb_find_devices = NULL; |
| 108 |
static usb_device_t _usb_device = NULL; |
| 109 |
static usb_get_busses_t _usb_get_busses = NULL; |
| 110 |
static usb_install_service_np_t _usb_install_service_np = NULL; |
| 111 |
static usb_uninstall_service_np_t _usb_uninstall_service_np = NULL; |
| 112 |
static usb_install_driver_np_t _usb_install_driver_np = NULL; |
| 113 |
static usb_get_version_t _usb_get_version = NULL; |
| 114 |
static usb_isochronous_setup_async_t _usb_isochronous_setup_async = NULL; |
| 115 |
static usb_bulk_setup_async_t _usb_bulk_setup_async = NULL; |
| 116 |
static usb_interrupt_setup_async_t _usb_interrupt_setup_async = NULL; |
| 117 |
static usb_submit_async_t _usb_submit_async = NULL; |
| 118 |
static usb_reap_async_t _usb_reap_async = NULL; |
| 119 |
static usb_reap_async_nocancel_t _usb_reap_async_nocancel = NULL; |
| 120 |
static usb_cancel_async_t _usb_cancel_async = NULL; |
| 121 |
static usb_free_async_t _usb_free_async = NULL; |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
void usb_init(void) |
| 127 |
{ |
| 128 |
HINSTANCE libusb_dll = LoadLibrary(LIBUSB_DLL_NAME); |
| 129 |
|
| 130 |
if (!libusb_dll) |
| 131 |
return; |
| 132 |
|
| 133 |
_usb_open = (usb_open_t) |
| 134 |
GetProcAddress(libusb_dll, "usb_open"); |
| 135 |
_usb_close = (usb_close_t) |
| 136 |
GetProcAddress(libusb_dll, "usb_close"); |
| 137 |
_usb_get_string = (usb_get_string_t) |
| 138 |
GetProcAddress(libusb_dll, "usb_get_string"); |
| 139 |
_usb_get_string_simple = (usb_get_string_simple_t) |
| 140 |
GetProcAddress(libusb_dll, "usb_get_string_simple"); |
| 141 |
_usb_get_descriptor_by_endpoint = (usb_get_descriptor_by_endpoint_t) |
| 142 |
GetProcAddress(libusb_dll, "usb_get_descriptor_by_endpoint"); |
| 143 |
_usb_get_descriptor = (usb_get_descriptor_t) |
| 144 |
GetProcAddress(libusb_dll, "usb_get_descriptor"); |
| 145 |
_usb_bulk_write = (usb_bulk_write_t) |
| 146 |
GetProcAddress(libusb_dll, "usb_bulk_write"); |
| 147 |
_usb_bulk_read = (usb_bulk_read_t) |
| 148 |
GetProcAddress(libusb_dll, "usb_bulk_read"); |
| 149 |
_usb_interrupt_write = (usb_interrupt_write_t) |
| 150 |
GetProcAddress(libusb_dll, "usb_interrupt_write"); |
| 151 |
_usb_interrupt_read = (usb_interrupt_read_t) |
| 152 |
GetProcAddress(libusb_dll, "usb_interrupt_read"); |
| 153 |
_usb_control_msg = (usb_control_msg_t) |
| 154 |
GetProcAddress(libusb_dll, "usb_control_msg"); |
| 155 |
_usb_set_configuration = (usb_set_configuration_t) |
| 156 |
GetProcAddress(libusb_dll, "usb_set_configuration"); |
| 157 |
_usb_claim_interface = (usb_claim_interface_t) |
| 158 |
GetProcAddress(libusb_dll, "usb_claim_interface"); |
| 159 |
_usb_release_interface = (usb_release_interface_t) |
| 160 |
GetProcAddress(libusb_dll, "usb_release_interface"); |
| 161 |
_usb_set_altinterface = (usb_set_altinterface_t) |
| 162 |
GetProcAddress(libusb_dll, "usb_set_altinterface"); |
| 163 |
_usb_resetep = (usb_resetep_t) |
| 164 |
GetProcAddress(libusb_dll, "usb_resetep"); |
| 165 |
_usb_clear_halt = (usb_clear_halt_t) |
| 166 |
GetProcAddress(libusb_dll, "usb_clear_halt"); |
| 167 |
_usb_reset = (usb_reset_t) |
| 168 |
GetProcAddress(libusb_dll, "usb_reset"); |
| 169 |
_usb_reset_ex = (usb_reset_ex_t) |
| 170 |
GetProcAddress(libusb_dll, "usb_reset_ex"); |
| 171 |
_usb_strerror = (usb_strerror_t) |
| 172 |
GetProcAddress(libusb_dll, "usb_strerror"); |
| 173 |
_usb_init = (usb_init_t) |
| 174 |
GetProcAddress(libusb_dll, "usb_init"); |
| 175 |
_usb_set_debug = (usb_set_debug_t) |
| 176 |
GetProcAddress(libusb_dll, "usb_set_debug"); |
| 177 |
_usb_find_busses = (usb_find_busses_t) |
| 178 |
GetProcAddress(libusb_dll, "usb_find_busses"); |
| 179 |
_usb_find_devices = (usb_find_devices_t) |
| 180 |
GetProcAddress(libusb_dll, "usb_find_devices"); |
| 181 |
_usb_device = (usb_device_t) |
| 182 |
GetProcAddress(libusb_dll, "usb_device"); |
| 183 |
_usb_get_busses = (usb_get_busses_t) |
| 184 |
GetProcAddress(libusb_dll, "usb_get_busses"); |
| 185 |
_usb_install_service_np = (usb_install_service_np_t) |
| 186 |
GetProcAddress(libusb_dll, "usb_install_service_np"); |
| 187 |
_usb_uninstall_service_np = (usb_uninstall_service_np_t) |
| 188 |
GetProcAddress(libusb_dll, "usb_uninstall_service_np"); |
| 189 |
_usb_install_driver_np = (usb_install_driver_np_t) |
| 190 |
GetProcAddress(libusb_dll, "usb_install_driver_np"); |
| 191 |
_usb_get_version = (usb_get_version_t) |
| 192 |
GetProcAddress(libusb_dll, "usb_get_version"); |
| 193 |
_usb_isochronous_setup_async = (usb_isochronous_setup_async_t) |
| 194 |
GetProcAddress(libusb_dll, "usb_isochronous_setup_async"); |
| 195 |
_usb_bulk_setup_async = (usb_bulk_setup_async_t) |
| 196 |
GetProcAddress(libusb_dll, "usb_bulk_setup_async"); |
| 197 |
_usb_interrupt_setup_async = (usb_interrupt_setup_async_t) |
| 198 |
GetProcAddress(libusb_dll, "usb_interrupt_setup_async"); |
| 199 |
_usb_submit_async = (usb_submit_async_t) |
| 200 |
GetProcAddress(libusb_dll, "usb_submit_async"); |
| 201 |
_usb_reap_async = (usb_reap_async_t) |
| 202 |
GetProcAddress(libusb_dll, "usb_reap_async"); |
| 203 |
_usb_reap_async_nocancel = (usb_reap_async_nocancel_t) |
| 204 |
GetProcAddress(libusb_dll, "usb_reap_async_nocancel"); |
| 205 |
_usb_cancel_async = (usb_cancel_async_t) |
| 206 |
GetProcAddress(libusb_dll, "usb_cancel_async"); |
| 207 |
_usb_free_async = (usb_free_async_t) |
| 208 |
GetProcAddress(libusb_dll, "usb_free_async"); |
| 209 |
|
| 210 |
if (_usb_init) |
| 211 |
_usb_init(); |
| 212 |
} |
| 213 |
|
| 214 |
usb_dev_handle *usb_open(struct usb_device *dev) |
| 215 |
{ |
| 216 |
if (_usb_open) |
| 217 |
return _usb_open(dev); |
| 218 |
else |
| 219 |
return NULL; |
| 220 |
} |
| 221 |
|
| 222 |
int usb_close(usb_dev_handle *dev) |
| 223 |
{ |
| 224 |
if (_usb_close) |
| 225 |
return _usb_close(dev); |
| 226 |
else |
| 227 |
return -ENOFILE; |
| 228 |
} |
| 229 |
|
| 230 |
int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf, |
| 231 |
size_t buflen) |
| 232 |
{ |
| 233 |
if (_usb_get_string) |
| 234 |
return _usb_get_string(dev, index, langid, buf, buflen); |
| 235 |
else |
| 236 |
return -ENOFILE; |
| 237 |
} |
| 238 |
|
| 239 |
int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf, |
| 240 |
size_t buflen) |
| 241 |
{ |
| 242 |
if (_usb_get_string_simple) |
| 243 |
return _usb_get_string_simple(dev, index, buf, buflen); |
| 244 |
else |
| 245 |
return -ENOFILE; |
| 246 |
} |
| 247 |
|
| 248 |
int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep, |
| 249 |
unsigned char type, unsigned char index, |
| 250 |
void *buf, int size) |
| 251 |
{ |
| 252 |
if (_usb_get_descriptor_by_endpoint) |
| 253 |
return _usb_get_descriptor_by_endpoint(udev, ep, type, index, buf, size); |
| 254 |
else |
| 255 |
return -ENOFILE; |
| 256 |
} |
| 257 |
|
| 258 |
int usb_get_descriptor(usb_dev_handle *udev, unsigned char type, |
| 259 |
unsigned char index, void *buf, int size) |
| 260 |
{ |
| 261 |
if (_usb_get_descriptor) |
| 262 |
return _usb_get_descriptor(udev, type, index, buf, size); |
| 263 |
else |
| 264 |
return -ENOFILE; |
| 265 |
} |
| 266 |
|
| 267 |
int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, |
| 268 |
int timeout) |
| 269 |
{ |
| 270 |
if (_usb_bulk_write) |
| 271 |
return _usb_bulk_write(dev, ep, bytes, size, timeout); |
| 272 |
else |
| 273 |
return -ENOFILE; |
| 274 |
} |
| 275 |
|
| 276 |
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, |
| 277 |
int timeout) |
| 278 |
{ |
| 279 |
if (_usb_bulk_read) |
| 280 |
return _usb_bulk_read(dev, ep, bytes, size, timeout); |
| 281 |
else |
| 282 |
return -ENOFILE; |
| 283 |
} |
| 284 |
|
| 285 |
int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size, |
| 286 |
int timeout) |
| 287 |
{ |
| 288 |
if (_usb_interrupt_write) |
| 289 |
return _usb_interrupt_write(dev, ep, bytes, size, timeout); |
| 290 |
else |
| 291 |
return -ENOFILE; |
| 292 |
} |
| 293 |
|
| 294 |
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, |
| 295 |
int timeout) |
| 296 |
{ |
| 297 |
if (_usb_interrupt_read) |
| 298 |
return _usb_interrupt_read(dev, ep, bytes, size, timeout); |
| 299 |
else |
| 300 |
return -ENOFILE; |
| 301 |
} |
| 302 |
|
| 303 |
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, |
| 304 |
int value, int index, char *bytes, int size, |
| 305 |
int timeout) |
| 306 |
{ |
| 307 |
if (_usb_control_msg) |
| 308 |
return _usb_control_msg(dev, requesttype, request, value, index, bytes, |
| 309 |
size, timeout); |
| 310 |
else |
| 311 |
return -ENOFILE; |
| 312 |
} |
| 313 |
|
| 314 |
int usb_set_configuration(usb_dev_handle *dev, int configuration) |
| 315 |
{ |
| 316 |
if (_usb_set_configuration) |
| 317 |
return _usb_set_configuration(dev, configuration); |
| 318 |
else |
| 319 |
return -ENOFILE; |
| 320 |
} |
| 321 |
|
| 322 |
int usb_claim_interface(usb_dev_handle *dev, int interface) |
| 323 |
{ |
| 324 |
if (_usb_claim_interface) |
| 325 |
return _usb_claim_interface(dev, interface); |
| 326 |
else |
| 327 |
return -ENOFILE; |
| 328 |
} |
| 329 |
|
| 330 |
int usb_release_interface(usb_dev_handle *dev, int interface) |
| 331 |
{ |
| 332 |
if (_usb_release_interface) |
| 333 |
return _usb_release_interface(dev, interface); |
| 334 |
else |
| 335 |
return -ENOFILE; |
| 336 |
} |
| 337 |
|
| 338 |
int usb_set_altinterface(usb_dev_handle *dev, int alternate) |
| 339 |
{ |
| 340 |
if (_usb_set_altinterface) |
| 341 |
return _usb_set_altinterface(dev, alternate); |
| 342 |
else |
| 343 |
return -ENOFILE; |
| 344 |
} |
| 345 |
|
| 346 |
int usb_resetep(usb_dev_handle *dev, unsigned int ep) |
| 347 |
{ |
| 348 |
if (_usb_resetep) |
| 349 |
return _usb_resetep(dev, ep); |
| 350 |
else |
| 351 |
return -ENOFILE; |
| 352 |
} |
| 353 |
|
| 354 |
int usb_clear_halt(usb_dev_handle *dev, unsigned int ep) |
| 355 |
{ |
| 356 |
if (_usb_clear_halt) |
| 357 |
return _usb_clear_halt(dev, ep); |
| 358 |
else |
| 359 |
return -ENOFILE; |
| 360 |
} |
| 361 |
|
| 362 |
int usb_reset(usb_dev_handle *dev) |
| 363 |
{ |
| 364 |
if (_usb_reset) |
| 365 |
return _usb_reset(dev); |
| 366 |
else |
| 367 |
return -ENOFILE; |
| 368 |
} |
| 369 |
|
| 370 |
int usb_reset_ex(usb_dev_handle *dev, unsigned int reset_type) |
| 371 |
{ |
| 372 |
if (_usb_reset_ex) |
| 373 |
return _usb_reset_ex(dev, reset_type); |
| 374 |
else |
| 375 |
return -ENOFILE; |
| 376 |
} |
| 377 |
|
| 378 |
char *usb_strerror(void) |
| 379 |
{ |
| 380 |
if (_usb_strerror) |
| 381 |
return _usb_strerror(); |
| 382 |
else |
| 383 |
return NULL; |
| 384 |
} |
| 385 |
|
| 386 |
void usb_set_debug(int level) |
| 387 |
{ |
| 388 |
if (_usb_set_debug) |
| 389 |
return _usb_set_debug(level); |
| 390 |
} |
| 391 |
|
| 392 |
int usb_find_busses(void) |
| 393 |
{ |
| 394 |
if (_usb_find_busses) |
| 395 |
return _usb_find_busses(); |
| 396 |
else |
| 397 |
return -ENOFILE; |
| 398 |
} |
| 399 |
|
| 400 |
int usb_find_devices(void) |
| 401 |
{ |
| 402 |
if (_usb_find_devices) |
| 403 |
return _usb_find_devices(); |
| 404 |
else |
| 405 |
return -ENOFILE; |
| 406 |
} |
| 407 |
|
| 408 |
struct usb_device *usb_device_(usb_dev_handle *dev) |
| 409 |
{ |
| 410 |
if (_usb_device) |
| 411 |
return _usb_device(dev); |
| 412 |
else |
| 413 |
return NULL; |
| 414 |
} |
| 415 |
|
| 416 |
struct usb_bus *usb_get_busses(void) |
| 417 |
{ |
| 418 |
if (_usb_get_busses) |
| 419 |
return _usb_get_busses(); |
| 420 |
else |
| 421 |
return NULL; |
| 422 |
} |
| 423 |
|
| 424 |
int usb_install_service_np(void) |
| 425 |
{ |
| 426 |
if (_usb_install_service_np) |
| 427 |
return _usb_install_service_np(); |
| 428 |
else |
| 429 |
return -ENOFILE; |
| 430 |
} |
| 431 |
|
| 432 |
int usb_uninstall_service_np(void) |
| 433 |
{ |
| 434 |
if (_usb_uninstall_service_np) |
| 435 |
return _usb_uninstall_service_np(); |
| 436 |
else |
| 437 |
return -ENOFILE; |
| 438 |
} |
| 439 |
|
| 440 |
int usb_install_driver_np(const char *inf_file) |
| 441 |
{ |
| 442 |
if (_usb_install_driver_np) |
| 443 |
return _usb_install_driver_np(inf_file); |
| 444 |
else |
| 445 |
return -ENOFILE; |
| 446 |
} |
| 447 |
|
| 448 |
const struct usb_version *usb_get_version(void) |
| 449 |
{ |
| 450 |
if (_usb_get_version) |
| 451 |
return _usb_get_version(); |
| 452 |
else |
| 453 |
return NULL; |
| 454 |
} |
| 455 |
|
| 456 |
int usb_isochronous_setup_async(usb_dev_handle *dev, void **context, |
| 457 |
unsigned char ep, int pktsize) |
| 458 |
{ |
| 459 |
if (_usb_isochronous_setup_async) |
| 460 |
return _usb_isochronous_setup_async(dev, context, ep, pktsize); |
| 461 |
else |
| 462 |
return -ENOFILE; |
| 463 |
} |
| 464 |
|
| 465 |
int usb_bulk_setup_async(usb_dev_handle *dev, void **context, |
| 466 |
unsigned char ep) |
| 467 |
{ |
| 468 |
if (_usb_bulk_setup_async) |
| 469 |
return _usb_bulk_setup_async(dev, context, ep); |
| 470 |
else |
| 471 |
return -ENOFILE; |
| 472 |
} |
| 473 |
|
| 474 |
int usb_interrupt_setup_async(usb_dev_handle *dev, void **context, |
| 475 |
unsigned char ep) |
| 476 |
{ |
| 477 |
if (_usb_interrupt_setup_async) |
| 478 |
return _usb_interrupt_setup_async(dev, context, ep); |
| 479 |
else |
| 480 |
return -ENOFILE; |
| 481 |
} |
| 482 |
|
| 483 |
int usb_submit_async(void *context, char *bytes, int size) |
| 484 |
{ |
| 485 |
if (_usb_submit_async) |
| 486 |
return _usb_submit_async(context, bytes, size); |
| 487 |
else |
| 488 |
return -ENOFILE; |
| 489 |
} |
| 490 |
|
| 491 |
int usb_reap_async(void *context, int timeout) |
| 492 |
{ |
| 493 |
if (_usb_reap_async) |
| 494 |
return _usb_reap_async(context, timeout); |
| 495 |
else |
| 496 |
return -ENOFILE; |
| 497 |
} |
| 498 |
|
| 499 |
int usb_reap_async_nocancel(void *context, int timeout) |
| 500 |
{ |
| 501 |
if (_usb_reap_async_nocancel) |
| 502 |
return _usb_reap_async_nocancel(context, timeout); |
| 503 |
else |
| 504 |
return -ENOFILE; |
| 505 |
} |
| 506 |
|
| 507 |
int usb_cancel_async(void *context) |
| 508 |
{ |
| 509 |
if (_usb_cancel_async) |
| 510 |
return _usb_cancel_async(context); |
| 511 |
else |
| 512 |
return -ENOFILE; |
| 513 |
} |
| 514 |
|
| 515 |
int usb_free_async(void **context) |
| 516 |
{ |
| 517 |
if (_usb_free_async) |
| 518 |
return _usb_free_async(context); |
| 519 |
else |
| 520 |
return -ENOFILE; |
| 521 |
} |