Deleted Added
full compact
usb_device.h (239176) usb_device.h (246616)
1/* $FreeBSD: head/sys/dev/usb/usb_device.h 239176 2012-08-10 14:44:04Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/usb_device.h 246616 2013-02-10 10:56:13Z hselasky $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. 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 _USB_DEVICE_H_
28#define _USB_DEVICE_H_
29
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. 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 _USB_DEVICE_H_
28#define _USB_DEVICE_H_
29
30struct usb_symlink; /* UGEN */
30#ifndef USB_GLOBAL_INCLUDE_FILE
31#include <dev/usb/usb_core.h>
32#include <dev/usb/usb_busdma.h>
33#include <dev/usb/usb_transfer.h>
34#endif
35
36struct usb_bus_methods;
37struct usb_config_descriptor;
31struct usb_device; /* linux compat */
32struct usb_fs_privdata;
38struct usb_device; /* linux compat */
39struct usb_fs_privdata;
40struct usb_hw_ep_profile;
41struct usb_symlink; /* UGEN */
33
34#define USB_CTRL_XFER_MAX 2
35
36/* "usb_config_parse()" commands */
37
38#define USB_CFG_ALLOC 0
39#define USB_CFG_FREE 1
40#define USB_CFG_INIT 2

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

103struct usb_power_save {
104 usb_ticks_t last_xfer_time; /* copy of "ticks" */
105 usb_size_t type_refs[4]; /* transfer reference count */
106 usb_size_t read_refs; /* data read references */
107 usb_size_t write_refs; /* data write references */
108};
109
110/*
42
43#define USB_CTRL_XFER_MAX 2
44
45/* "usb_config_parse()" commands */
46
47#define USB_CFG_ALLOC 0
48#define USB_CFG_FREE 1
49#define USB_CFG_INIT 2

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

112struct usb_power_save {
113 usb_ticks_t last_xfer_time; /* copy of "ticks" */
114 usb_size_t type_refs[4]; /* transfer reference count */
115 usb_size_t read_refs; /* data read references */
116 usb_size_t write_refs; /* data write references */
117};
118
119/*
120 * The following structure is used when trying to allocate hardware
121 * endpoints for an USB configuration in USB device side mode.
122 */
123struct usb_hw_ep_scratch_sub {
124 const struct usb_hw_ep_profile *pf;
125 uint16_t max_frame_size;
126 uint8_t hw_endpoint_out;
127 uint8_t hw_endpoint_in;
128 uint8_t needs_ep_type;
129 uint8_t needs_in:1;
130 uint8_t needs_out:1;
131};
132
133/*
134 * The following structure is used when trying to allocate hardware
135 * endpoints for an USB configuration in USB device side mode.
136 */
137struct usb_hw_ep_scratch {
138 struct usb_hw_ep_scratch_sub ep[USB_EP_MAX];
139 struct usb_hw_ep_scratch_sub *ep_max;
140 struct usb_config_descriptor *cd;
141 struct usb_device *udev;
142 struct usb_bus_methods *methods;
143 uint8_t bmOutAlloc[(USB_EP_MAX + 15) / 16];
144 uint8_t bmInAlloc[(USB_EP_MAX + 15) / 16];
145};
146
147/*
148 * The following structure is used when generating USB descriptors
149 * from USB templates.
150 */
151struct usb_temp_setup {
152 void *buf;
153 usb_size_t size;
154 enum usb_dev_speed usb_speed;
155 uint8_t self_powered;
156 uint8_t bNumEndpoints;
157 uint8_t bInterfaceNumber;
158 uint8_t bAlternateSetting;
159 uint8_t bConfigurationValue;
160 usb_error_t err;
161};
162
163/*
164 * The scratch area for USB devices. Access to this structure is
165 * protected by the enumeration SX lock.
166 */
167union usb_device_scratch {
168 struct usb_hw_ep_scratch hw_ep_scratch[1];
169 struct usb_temp_setup temp_setup[1];
170 struct {
171 struct usb_xfer dummy;
172 struct usb_setup_params parm;
173 } xfer_setup[1];
174 uint8_t data[255];
175};
176
177/*
111 * The following structure defines an USB device. There exists one of
112 * these structures for every USB device.
113 */
114struct usb_device {
115 struct usb_clear_stall_msg cs_msg[2]; /* generic clear stall
116 * messages */
117 struct sx ctrl_sx;
118 struct sx enum_sx;

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

186 struct usb_interface *linux_iface_start;
187 struct usb_interface *linux_iface_end;
188 struct usb_host_endpoint *linux_endpoint_start;
189 struct usb_host_endpoint *linux_endpoint_end;
190 uint16_t devnum;
191#endif
192
193 uint32_t clear_stall_errors; /* number of clear-stall failures */
178 * The following structure defines an USB device. There exists one of
179 * these structures for every USB device.
180 */
181struct usb_device {
182 struct usb_clear_stall_msg cs_msg[2]; /* generic clear stall
183 * messages */
184 struct sx ctrl_sx;
185 struct sx enum_sx;

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

253 struct usb_interface *linux_iface_start;
254 struct usb_interface *linux_iface_end;
255 struct usb_host_endpoint *linux_endpoint_start;
256 struct usb_host_endpoint *linux_endpoint_end;
257 uint16_t devnum;
258#endif
259
260 uint32_t clear_stall_errors; /* number of clear-stall failures */
261
262 union usb_device_scratch scratch;
194};
195
196/* globals */
197
198extern int usb_template;
199
200/* function prototypes */
201

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

222void usb_devinfo(struct usb_device *udev, char *dst_ptr, uint16_t dst_len);
223void usb_free_device(struct usb_device *, uint8_t);
224void usb_linux_free_device(struct usb_device *dev);
225uint8_t usb_peer_can_wakeup(struct usb_device *udev);
226struct usb_endpoint *usb_endpoint_foreach(struct usb_device *udev, struct usb_endpoint *ep);
227void usb_set_device_state(struct usb_device *, enum usb_dev_state);
228enum usb_dev_state usb_get_device_state(struct usb_device *);
229
263};
264
265/* globals */
266
267extern int usb_template;
268
269/* function prototypes */
270

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

291void usb_devinfo(struct usb_device *udev, char *dst_ptr, uint16_t dst_len);
292void usb_free_device(struct usb_device *, uint8_t);
293void usb_linux_free_device(struct usb_device *dev);
294uint8_t usb_peer_can_wakeup(struct usb_device *udev);
295struct usb_endpoint *usb_endpoint_foreach(struct usb_device *udev, struct usb_endpoint *ep);
296void usb_set_device_state(struct usb_device *, enum usb_dev_state);
297enum usb_dev_state usb_get_device_state(struct usb_device *);
298
230void usbd_enum_lock(struct usb_device *);
299uint8_t usbd_enum_lock(struct usb_device *);
231void usbd_enum_unlock(struct usb_device *);
232void usbd_sr_lock(struct usb_device *);
233void usbd_sr_unlock(struct usb_device *);
234uint8_t usbd_enum_is_locked(struct usb_device *);
235
236#endif /* _USB_DEVICE_H_ */
300void usbd_enum_unlock(struct usb_device *);
301void usbd_sr_lock(struct usb_device *);
302void usbd_sr_unlock(struct usb_device *);
303uint8_t usbd_enum_is_locked(struct usb_device *);
304
305#endif /* _USB_DEVICE_H_ */