libusb10.h (552311f4bb98c81b1b9e0e81d74e0262fc12110b) libusb10.h (7bdc064b0b644d15bd9614d9e7db5c4279736d75)
1/* $FreeBSD$ */
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

--- 22 unchanged lines hidden (view full) ---

31#include <sys/queue.h>
32#endif
33
34#define GET_CONTEXT(ctx) (((ctx) == NULL) ? usbi_default_context : (ctx))
35#define UNEXPORTED __attribute__((__visibility__("hidden")))
36#define CTX_LOCK(ctx) pthread_mutex_lock(&(ctx)->ctx_lock)
37#define CTX_TRYLOCK(ctx) pthread_mutex_trylock(&(ctx)->ctx_lock)
38#define CTX_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->ctx_lock)
1/* $FreeBSD$ */
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

--- 22 unchanged lines hidden (view full) ---

31#include <sys/queue.h>
32#endif
33
34#define GET_CONTEXT(ctx) (((ctx) == NULL) ? usbi_default_context : (ctx))
35#define UNEXPORTED __attribute__((__visibility__("hidden")))
36#define CTX_LOCK(ctx) pthread_mutex_lock(&(ctx)->ctx_lock)
37#define CTX_TRYLOCK(ctx) pthread_mutex_trylock(&(ctx)->ctx_lock)
38#define CTX_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->ctx_lock)
39#define HOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock)
40#define HOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock)
39
40#define DPRINTF(ctx, dbg, format, args...) do { \
41 if ((ctx)->debug == dbg) { \
42 switch (dbg) { \
43 case LIBUSB_DEBUG_FUNCTION: \
44 printf("LIBUSB_FUNCTION: " \
45 format "\n", ## args); \
46 break; \

--- 20 unchanged lines hidden (view full) ---

67 uint8_t *curr_data;
68 uint32_t rem_len;
69 uint32_t last_len;
70 uint8_t state;
71#define LIBUSB_SUPER_XFER_ST_NONE 0
72#define LIBUSB_SUPER_XFER_ST_PEND 1
73};
74
41
42#define DPRINTF(ctx, dbg, format, args...) do { \
43 if ((ctx)->debug == dbg) { \
44 switch (dbg) { \
45 case LIBUSB_DEBUG_FUNCTION: \
46 printf("LIBUSB_FUNCTION: " \
47 format "\n", ## args); \
48 break; \

--- 20 unchanged lines hidden (view full) ---

69 uint8_t *curr_data;
70 uint32_t rem_len;
71 uint32_t last_len;
72 uint8_t state;
73#define LIBUSB_SUPER_XFER_ST_NONE 0
74#define LIBUSB_SUPER_XFER_ST_PEND 1
75};
76
77struct libusb_hotplug_callback_handle {
78 TAILQ_ENTRY(libusb_hotplug_callback_handle) entry;
79 int events;
80 int vendor;
81 int product;
82 int devclass;
83 libusb_hotplug_callback_fn fn;
84 void *user_data;
85};
86
75struct libusb_context {
76 int debug;
77 int debug_fixed;
78 int ctrl_pipe[2];
79 int tr_done_ref;
80 int tr_done_gen;
81
82 pthread_mutex_t ctx_lock;
87struct libusb_context {
88 int debug;
89 int debug_fixed;
90 int ctrl_pipe[2];
91 int tr_done_ref;
92 int tr_done_gen;
93
94 pthread_mutex_t ctx_lock;
95 pthread_mutex_t hotplug_lock;
83 pthread_cond_t ctx_cond;
96 pthread_cond_t ctx_cond;
97 pthread_t hotplug_handler;
84 pthread_t ctx_handler;
85#define NO_THREAD ((pthread_t)-1)
86
87 TAILQ_HEAD(, libusb_super_pollfd) pollfds;
88 TAILQ_HEAD(, libusb_super_transfer) tr_done;
98 pthread_t ctx_handler;
99#define NO_THREAD ((pthread_t)-1)
100
101 TAILQ_HEAD(, libusb_super_pollfd) pollfds;
102 TAILQ_HEAD(, libusb_super_transfer) tr_done;
103 TAILQ_HEAD(, libusb_hotplug_callback_handle) hotplug_cbh;
104 TAILQ_HEAD(, libusb_device) hotplug_devs;
89
90 struct libusb_super_pollfd ctx_poll;
91
92 libusb_pollfd_added_cb fd_added_cb;
93 libusb_pollfd_removed_cb fd_removed_cb;
94 void *fd_cb_user_data;
95};
96
97struct libusb_device {
98 int refcnt;
99
100 uint32_t claimed_interfaces;
101
102 struct libusb_super_pollfd dev_poll;
103
104 struct libusb_context *ctx;
105
105
106 struct libusb_super_pollfd ctx_poll;
107
108 libusb_pollfd_added_cb fd_added_cb;
109 libusb_pollfd_removed_cb fd_removed_cb;
110 void *fd_cb_user_data;
111};
112
113struct libusb_device {
114 int refcnt;
115
116 uint32_t claimed_interfaces;
117
118 struct libusb_super_pollfd dev_poll;
119
120 struct libusb_context *ctx;
121
122 TAILQ_ENTRY(libusb_device) hotplug_entry;
123
106 TAILQ_HEAD(, libusb_super_transfer) tr_head;
107
108 struct libusb20_device *os_priv;
109};
110
111extern struct libusb_context *usbi_default_context;
112
113void libusb10_add_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd, struct libusb20_device *pdev, int fd, short events);
114void libusb10_remove_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd);
115void libusb10_cancel_all_transfer(libusb_device *dev);
116
117#endif /* __LIBUSB10_H__ */
124 TAILQ_HEAD(, libusb_super_transfer) tr_head;
125
126 struct libusb20_device *os_priv;
127};
128
129extern struct libusb_context *usbi_default_context;
130
131void libusb10_add_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd, struct libusb20_device *pdev, int fd, short events);
132void libusb10_remove_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd);
133void libusb10_cancel_all_transfer(libusb_device *dev);
134
135#endif /* __LIBUSB10_H__ */