Debian Codegraph @

cjeca32/ausb/ausb_l.h

raw symbols SCIP
1 /* USB support for the Cyberjack family of readers.
2 *
3 * Previous version were (C) 2004-2005 by Harald Welte <[email protected]>
4 * This version is a rewrite (asynchronous USB is no longer needed).
5 *
6 * (C) 2007 Martin Preuss <[email protected]>
7 *
8 * Distributed and licensed under the terms of GNU LGPL, Version 2.1
9 */
10
11
12 #ifndef _AUSB_L_H
13 #define _AUSB_L_H
14
15 #define AUSB_CYBERJACK_VENDOR_ID 0xc4b
16 #define AUSB_MAX_TIMEOUT 600
17
18 #ifdef ENABLE_NONSERIAL
19
20 #include <inttypes.h>
21
22 #include "usbdev_l.h"
23
24
25
26 typedef struct ausb_dev_handle ausb_dev_handle;
27
28
29 /* virtual functions */
30 typedef void (*AUSB_CLOSE_FN)(ausb_dev_handle *ah);
31 typedef int (*AUSB_START_INTERRUPT_FN)(ausb_dev_handle *ah, int ep);
32 typedef int (*AUSB_STOP_INTERRUPT_FN)(ausb_dev_handle *ah);
33 typedef int (*AUSB_BULK_WRITE_FN)(ausb_dev_handle *ah, int ep,
34 char *bytes, int size,
35 int timeout);
36 typedef int (*AUSB_BULK_READ_FN)(ausb_dev_handle *ah, int ep,
37 char *bytes, int size,
38 int timeout);
39
40 typedef int (*AUSB_CLAIM_INTERFACE_FN)(ausb_dev_handle *ah, int interface);
41 typedef int (*AUSB_RELEASE_INTERFACE_FN)(ausb_dev_handle *ah, int interface);
42 typedef int (*AUSB_SET_CONFIGURATION_FN)(ausb_dev_handle *ah, int interface);
43
44 typedef int (*AUSB_RESET_FN)(ausb_dev_handle *ah);
45 typedef int (*AUSB_HALT_FN)(ausb_dev_handle *ah, unsigned int ep);
46 typedef int (*AUSB_CLEAR_HALT_FN)(ausb_dev_handle *ah, unsigned int ep);
47 typedef int (*AUSB_RESET_ENDPOINT_FN)(ausb_dev_handle *ah, unsigned int ep);
48 typedef int (*AUSB_RESET_PIPE)(ausb_dev_handle *ah, int ep);
49
50
51 typedef int (*AUSB_GET_KERNEL_DRIVER_NAME)(ausb_dev_handle *ah, int interface, char *name,
52 unsigned int namelen);
53 typedef int (*AUSB_DETACH_KERNEL_DRIVER_FN)(ausb_dev_handle *dev, int interface);
54 typedef int (*AUSB_REATTACH_KERNEL_DRIVER_FN)(ausb_dev_handle *dev, int interface);
55
56
57 typedef void (*AUSB_LOG_FN)(ausb_dev_handle *ah,
58 const char *text,
59 const void *pData, uint32_t ulDataLen);
60
61
62 typedef void (*AUSB_CALLBACK)(const uint8_t *data,
63 uint32_t dlength,
64 void *userdata);
65
66
67 /* structures */
68 struct ausb_callback {
69 AUSB_CALLBACK handler;
70 void *userdata;
71 };
72
73
74 struct ausb_dev_handle {
75 rsct_usbdev_t device;
76 struct ausb_callback cb;
77 void *extraData;
78 uint16_t pid;
79
80 AUSB_CLOSE_FN closeFn;
81 AUSB_START_INTERRUPT_FN startInterruptFn;
82 AUSB_STOP_INTERRUPT_FN stopInterruptFn;
83 AUSB_BULK_WRITE_FN bulkWriteFn;
84 AUSB_BULK_READ_FN bulkReadFn;
85
86 AUSB_CLAIM_INTERFACE_FN claimInterfaceFn;
87 AUSB_RELEASE_INTERFACE_FN releaseInterfaceFn;
88 AUSB_SET_CONFIGURATION_FN setConfigurationFn;
89
90 AUSB_RESET_FN resetFn;
91 AUSB_CLEAR_HALT_FN clearHaltFn;
92 AUSB_RESET_ENDPOINT_FN resetEndpointFn;
93 AUSB_RESET_PIPE resetPipeFn;
94
95 AUSB_GET_KERNEL_DRIVER_NAME getKernelDriverNameFn;
96 AUSB_DETACH_KERNEL_DRIVER_FN detachKernelDriverFn;
97 AUSB_REATTACH_KERNEL_DRIVER_FN reattachKernelDriverFn;
98
99 };
100
101
102
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106
107
108
109 /** @name Functions used commonly by all implementations
110 */
111 /*@{*/
112
113 /* intitialization */
114 int ausb_init(void);
115
116
117 /**
118 * Register a callback which is called as soon as an URB request is
119 * finished.
120 * @param ah ausb handle obtained via @ref ausb_open
121 * @param callback callback function to be used. This function receives a
122 * pointer to the received interrupt data and caller-specified user data
123 * @param userdata userdata to be passed to the callback function
124 */
125 int ausb_register_callback(ausb_dev_handle *ah,
126 AUSB_CALLBACK callback,
127 void *userdata);
128
129 int ausb_claim_interface(ausb_dev_handle *ah, int interface);
130 int ausb_release_interface(ausb_dev_handle *ah, int interface);
131 int ausb_set_configuration(ausb_dev_handle *dev, int configuration);
132
133 int ausb_get_kernel_driver_name(ausb_dev_handle *ah, int interface, char *name,
134 unsigned int namelen);
135 int ausb_detach_kernel_driver(ausb_dev_handle *dev, int interface);
136 int ausb_reattach_kernel_driver(ausb_dev_handle *dev, int interface);
137
138 int ausb_reset(ausb_dev_handle *ah);
139 int ausb_clear_halt(ausb_dev_handle *ah, unsigned int ep);
140 int ausb_reset_endpoint(ausb_dev_handle *ah, unsigned int ep);
141 int ausb_reset_pipe(ausb_dev_handle *ah, int ep);
142
143 void ausb_set_log_fn(AUSB_LOG_FN fn);
144
145 void ausb_log(ausb_dev_handle *ah, const char *text,
146 const void *pData, uint32_t ulDataLen);
147
148 /*@}*/
149
150 #ifdef USE_USB1
151 int ausb11_extend(ausb_dev_handle *ah);
152 int ausb31_extend(ausb_dev_handle *ah);
153 #else
154 int ausb1_extend(ausb_dev_handle *ah);
155 int ausb3_extend(ausb_dev_handle *ah);
156 #endif
157
158
159 /** @name Functions which are implemented differently for
160 * different configurations.
161 */
162 /*@{*/
163 /**
164 * Open the given USB device. This creates the necessary
165 * ausb handle which must be free'd when it is no longer
166 * needed by calling @ref ausb_close.
167 * @return ausb handle to be used by other functions in this group
168 * @param dev usb device object obtained from libusb
169 *
170 */
171 ausb_dev_handle *ausb_open(rsct_usbdev_t *dev, int t);
172
173
174 int ausb_close(ausb_dev_handle *ah);
175
176 int ausb_start_interrupt(ausb_dev_handle *ah, int ep);
177 int ausb_stop_interrupt(ausb_dev_handle *ah);
178
179 int ausb_bulk_write(ausb_dev_handle *ah, int ep, char *bytes, int size,
180 int timeout);
181 int ausb_bulk_read(ausb_dev_handle *ah, int ep, char *bytes, int size,
182 int timeout);
183
184 /*@}*/
185
186 #ifdef __cplusplus
187 }
188 #endif
189
190 #endif
191
192 #endif /* _AUSB_H */
193
194