libusb.h (194676) | libusb.h (195560) |
---|---|
1/* $FreeBSD: head/lib/libusb/libusb.h 194676 2009-06-23 01:04:58Z thompsa $ */ | 1/* $FreeBSD: head/lib/libusb/libusb.h 195560 2009-07-10 14:15:53Z thompsa $ */ |
2/*- 3 * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 12 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#ifndef __LIBUSB_H__ 28#define __LIBUSB_H__ 29 | 2/*- 3 * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 12 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#ifndef __LIBUSB_H__ 28#define __LIBUSB_H__ 29 |
30#include <sys/time.h> 31#include <sys/types.h> 32#include <sys/endian.h> 33#include <sys/queue.h> 34 |
|
30#include <stdint.h> 31#include <time.h> 32#include <string.h> 33#include <pthread.h> 34 | 35#include <stdint.h> 36#include <time.h> 37#include <string.h> 38#include <pthread.h> 39 |
35#include <sys/time.h> 36#include <sys/types.h> 37#include <sys/endian.h> | |
38 39#ifdef __cplusplus 40extern "C" { 41#endif 42#if 0 43} /* indent fix */ 44 45#endif 46 | 40 41#ifdef __cplusplus 42extern "C" { 43#endif 44#if 0 45} /* indent fix */ 46 47#endif 48 |
47struct list_head { 48 struct list_head *prev, *next; 49}; 50 | |
51/* libusb enums */ 52 53enum libusb_class_code { 54 LIBUSB_CLASS_PER_INTERFACE = 0, 55 LIBUSB_CLASS_AUDIO = 1, 56 LIBUSB_CLASS_COMM = 2, 57 LIBUSB_CLASS_HID = 3, 58 LIBUSB_CLASS_PTP = 6, --- 119 unchanged lines hidden (view full) --- 178}; 179 180enum libusb_debug_level { 181 LIBUSB_DEBUG_NO=0, 182 LIBUSB_DEBUG_FUNCTION=1, 183 LIBUSB_DEBUG_TRANSFER=2, 184}; 185 | 49/* libusb enums */ 50 51enum libusb_class_code { 52 LIBUSB_CLASS_PER_INTERFACE = 0, 53 LIBUSB_CLASS_AUDIO = 1, 54 LIBUSB_CLASS_COMM = 2, 55 LIBUSB_CLASS_HID = 3, 56 LIBUSB_CLASS_PTP = 6, --- 119 unchanged lines hidden (view full) --- 176}; 177 178enum libusb_debug_level { 179 LIBUSB_DEBUG_NO=0, 180 LIBUSB_DEBUG_FUNCTION=1, 181 LIBUSB_DEBUG_TRANSFER=2, 182}; 183 |
184/* internal structures */ 185 186typedef struct libusb_pollfd { 187 int fd; 188 short events; 189} libusb_pollfd; 190 191struct usb_pollfd { 192 TAILQ_ENTRY(usb_pollfd) list; 193 struct libusb_pollfd pollfd; 194}; 195 196struct usb_transfer { 197 TAILQ_ENTRY(usb_transfer) list; 198 int num_iso_packets; 199 struct timeval timeout; 200 int transferred; 201 uint8_t flags; 202}; 203 204struct usb_ep_tr { 205 TAILQ_ENTRY(usb_ep_tr) list; 206 uint8_t addr; 207 uint8_t idx; 208 uint8_t flags; 209 void *os_priv; 210}; |
|
186/* libusb structures */ 187 188typedef void (*libusb_pollfd_added_cb) (int fd, short events, void *user_data); 189typedef void (*libusb_pollfd_removed_cb) (int fd, void *user_data); 190 191typedef struct libusb_context { 192 int debug; 193 int debug_fixed; 194 195 int ctrl_pipe[2]; 196 | 211/* libusb structures */ 212 213typedef void (*libusb_pollfd_added_cb) (int fd, short events, void *user_data); 214typedef void (*libusb_pollfd_removed_cb) (int fd, void *user_data); 215 216typedef struct libusb_context { 217 int debug; 218 int debug_fixed; 219 220 int ctrl_pipe[2]; 221 |
197 struct list_head usb_devs; | 222 TAILQ_HEAD(usb_devs_list, libusb_device) usb_devs; |
198 pthread_mutex_t usb_devs_lock; 199 | 223 pthread_mutex_t usb_devs_lock; 224 |
200 struct list_head open_devs; | 225 TAILQ_HEAD(open_devs_list, libusb_device_handle) open_devs; |
201 pthread_mutex_t open_devs_lock; 202 | 226 pthread_mutex_t open_devs_lock; 227 |
203 struct list_head flying_transfers; | 228 TAILQ_HEAD(flying_transfers_list, usb_transfer) flying_transfers; |
204 pthread_mutex_t flying_transfers_lock; 205 | 229 pthread_mutex_t flying_transfers_lock; 230 |
206 struct list_head pollfds; | 231 TAILQ_HEAD(pollfds_list, usb_pollfd) pollfds; |
207 pthread_mutex_t pollfds_lock; 208 209 unsigned int pollfd_modify; 210 pthread_mutex_t pollfd_modify_lock; 211 212 libusb_pollfd_added_cb fd_added_cb; 213 libusb_pollfd_removed_cb fd_removed_cb; 214 void *fd_cb_user_data; --- 10 unchanged lines hidden (view full) --- 225 int refcnt; 226 227 struct libusb_context *ctx; 228 229 uint8_t bus_number; 230 uint8_t device_address; 231 uint8_t num_configurations; 232 | 232 pthread_mutex_t pollfds_lock; 233 234 unsigned int pollfd_modify; 235 pthread_mutex_t pollfd_modify_lock; 236 237 libusb_pollfd_added_cb fd_added_cb; 238 libusb_pollfd_removed_cb fd_removed_cb; 239 void *fd_cb_user_data; --- 10 unchanged lines hidden (view full) --- 250 int refcnt; 251 252 struct libusb_context *ctx; 253 254 uint8_t bus_number; 255 uint8_t device_address; 256 uint8_t num_configurations; 257 |
233 struct list_head list; | 258 TAILQ_ENTRY(libusb_device) list; |
234 unsigned long session_data; 235 void *os_priv; 236} libusb_device; 237 238typedef struct libusb_device_handle { 239 pthread_mutex_t lock; 240 unsigned long claimed_interfaces; 241 | 259 unsigned long session_data; 260 void *os_priv; 261} libusb_device; 262 263typedef struct libusb_device_handle { 264 pthread_mutex_t lock; 265 unsigned long claimed_interfaces; 266 |
242 struct list_head list; | 267 TAILQ_ENTRY(libusb_device_handle) list; |
243 struct libusb_device *dev; 244 void *os_priv; | 268 struct libusb_device *dev; 269 void *os_priv; |
270 TAILQ_HEAD(ep_list, usb_ep_tr) ep_list; |
|
245} libusb_device_handle; 246 247typedef struct libusb_device_descriptor { 248 uint8_t bLength; 249 uint8_t bDescriptorType; 250 uint16_t bcdUSB; 251 uint8_t bDeviceClass; 252 uint8_t bDeviceSubClass; --- 85 unchanged lines hidden (view full) --- 338 libusb_transfer_cb_fn callback; 339 void *user_data; 340 unsigned char *buffer; 341 void *os_priv; 342 int num_iso_packets; 343 struct libusb_iso_packet_descriptor iso_packet_desc[0]; 344} libusb_transfer __aligned(sizeof(void *)); 345 | 271} libusb_device_handle; 272 273typedef struct libusb_device_descriptor { 274 uint8_t bLength; 275 uint8_t bDescriptorType; 276 uint16_t bcdUSB; 277 uint8_t bDeviceClass; 278 uint8_t bDeviceSubClass; --- 85 unchanged lines hidden (view full) --- 364 libusb_transfer_cb_fn callback; 365 void *user_data; 366 unsigned char *buffer; 367 void *os_priv; 368 int num_iso_packets; 369 struct libusb_iso_packet_descriptor iso_packet_desc[0]; 370} libusb_transfer __aligned(sizeof(void *)); 371 |
346typedef struct libusb_pollfd { 347 int fd; 348 short events; 349} libusb_pollfd; 350 | |
351/* Library initialisation */ 352 353void libusb_set_debug(libusb_context * ctx, int level); 354int libusb_init(libusb_context ** context); 355void libusb_exit(struct libusb_context *ctx); 356 357/* Device handling and enumeration */ 358 359ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list); 360void libusb_free_device_list(libusb_device ** list, int unref_devices); 361uint8_t libusb_get_bus_number(libusb_device * dev); 362uint8_t libusb_get_device_address(libusb_device * dev); | 372/* Library initialisation */ 373 374void libusb_set_debug(libusb_context * ctx, int level); 375int libusb_init(libusb_context ** context); 376void libusb_exit(struct libusb_context *ctx); 377 378/* Device handling and enumeration */ 379 380ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list); 381void libusb_free_device_list(libusb_device ** list, int unref_devices); 382uint8_t libusb_get_bus_number(libusb_device * dev); 383uint8_t libusb_get_device_address(libusb_device * dev); |
384int libusb_clear_halt(libusb_device_handle *devh, unsigned char endpoint); |
|
363int libusb_get_max_packet_size(libusb_device * dev, unsigned char endpoint); 364libusb_device *libusb_ref_device(libusb_device * dev); 365void libusb_unref_device(libusb_device * dev); 366int libusb_open(libusb_device * dev, libusb_device_handle ** devh); 367libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, uint16_t product_id); 368void libusb_close(libusb_device_handle * devh); 369libusb_device *libusb_get_device(libusb_device_handle * devh); 370int libusb_get_configuration(libusb_device_handle * devh, int *config); --- 57 unchanged lines hidden --- | 385int libusb_get_max_packet_size(libusb_device * dev, unsigned char endpoint); 386libusb_device *libusb_ref_device(libusb_device * dev); 387void libusb_unref_device(libusb_device * dev); 388int libusb_open(libusb_device * dev, libusb_device_handle ** devh); 389libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, uint16_t product_id); 390void libusb_close(libusb_device_handle * devh); 391libusb_device *libusb_get_device(libusb_device_handle * devh); 392int libusb_get_configuration(libusb_device_handle * devh, int *config); --- 57 unchanged lines hidden --- |