1 .\" $NetBSD: ugen.4,v 1.13 2001/09/11 22:52:54 wiz Exp $
3 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Lennart Augustsson.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
30 .\" $FreeBSD: head/share/man/man4/ugen.4 238705 2012-07-22 21:43:46Z wblock $
37 .Nd USB generic device support
40 is integrated into the
46 driver provides support for all USB devices that do not have
48 It supports access to all parts of the device,
49 but not in a way that is as convenient as a special purpose driver.
51 There can be up to 127 USB devices connected to a USB bus.
52 Each USB device can have up to 16 endpoints.
53 Each of these endpoints
54 will communicate in one of four different modes: control, isochronous,
56 Each of the endpoints will have a different
58 The four least significant bits in the minor device
59 number determine which endpoint the device accesses, and the rest
60 of the bits determine which USB device.
62 If an endpoint address is used both for input and output, the device
63 can be opened for both read or write.
65 To find out which endpoints exist, there are a series of
67 operations on the control endpoint that return the USB descriptors
68 of the device, configurations, interfaces, and endpoints.
70 The control transfer mode can only happen on the control endpoint
71 which is always endpoint 0.
72 The control endpoint accepts a request
73 and may respond with an answer to such a request.
79 .\" The isochronous transfer mode can be in or out depending on the
81 .\" To perform I/O on an isochronous endpoint
86 .\" Before any I/O operations can take place the transfer rate in
87 .\" bytes/second has to be set.
90 .\" .Dv USB_SET_ISO_RATE .
91 .\" Performing this call sets up a buffer corresponding to
92 .\" about 1 second of data.
94 The bulk transfer mode can be in or out depending on the
96 To perform I/O on a bulk endpoint
101 All I/O operations on a bulk endpoint are unbuffered.
103 The interrupt transfer mode can be in or out depending on the
105 To perform I/O on an interrupt endpoint
110 A moderate amount of buffering is done
113 All endpoints handle the following
116 .Bl -tag -width indent
117 .It Dv USB_SET_SHORT_XFER Pq Vt int
118 Allow short read transfer.
119 Normally a transfer from the device
120 which is shorter than the request specified is reported as an
122 .It Dv USB_SET_TIMEOUT Pq Vt int
123 Set the timeout on the device operations
124 The time is specified in milliseconds.
125 The value 0 is used to indicate that there is
129 The control endpoint (endpoint 0) handles the following
132 .Bl -tag -width indent
133 .It Dv USB_GET_CONFIG Pq Vt int
134 Get the device configuration number.
135 .It Dv USB_SET_CONFIG Pq Vt int
136 Set the device into the given configuration number.
138 This operation can only be performed when the control endpoint
139 is the sole open endpoint.
140 .It Dv USB_GET_ALTINTERFACE Pq Vt "struct usb_alt_interface"
141 Get the alternative setting number for the interface with the given
145 is ignored in this call.
147 struct usb_alt_interface {
148 int uai_config_index;
149 int uai_interface_index;
153 .It Dv USB_SET_ALTINTERFACE Pq Vt "struct usb_alt_interface"
154 Set the alternative setting to the given number in the interface with the
158 is ignored in this call.
160 This operation can only be performed when no endpoints for the interface
162 .It Dv USB_GET_NO_ALT Pq Vt "struct usb_alt_interface"
163 Return the number of different alternate settings in the
166 .It Dv USB_GET_DEVICE_DESC Pq Vt usb_device_descriptor_t
167 Return the device descriptor.
168 .It Dv USB_GET_CONFIG_DESC Pq Vt "struct usb_config_desc"
169 Return the descriptor for the configuration with the given index.
170 For convenience, the current configuration can be specified by
171 .Dv USB_CURRENT_CONFIG_INDEX .
173 struct usb_config_desc {
174 int ucd_config_index;
175 usb_config_descriptor_t ucd_desc;
178 .It Dv USB_GET_INTERFACE_DESC Pq Vt "struct usb_interface_desc"
179 Return the interface descriptor for an interface specified by its
180 configuration index, interface index, and alternative index.
181 For convenience, the current alternative can be specified by
182 .Dv USB_CURRENT_ALT_INDEX .
184 struct usb_interface_desc {
185 int uid_config_index;
186 int uid_interface_index;
188 usb_interface_descriptor_t uid_desc;
191 .It Dv USB_GET_ENDPOINT_DESC Pq Vt "struct usb_endpoint_desc"
192 Return the endpoint descriptor for the endpoint specified by its
193 configuration index, interface index, alternative index, and
196 struct usb_endpoint_desc {
197 int ued_config_index;
198 int ued_interface_index;
200 int ued_endpoint_index;
201 usb_endpoint_descriptor_t ued_desc;
204 .It Dv USB_GET_FULL_DESC Pq Vt "struct usb_full_desc"
205 Return all the descriptors for the given configuration.
207 struct usb_full_desc {
208 int ufd_config_index;
215 field should point to a memory area of the size given in the
218 The proper size can be determined by first issuing a
219 .Dv USB_GET_CONFIG_DESC
223 .It Dv USB_GET_STRING_DESC Pq Vt "struct usb_string_desc"
224 Get a string descriptor for the given language ID and
227 struct usb_string_desc {
228 int usd_string_index;
230 usb_string_descriptor_t usd_desc;
233 .It Dv USB_DO_REQUEST Pq Vt "struct usb_ctl_request"
234 Send a USB request to the device on the control endpoint.
235 Any data sent to/from the device is located at
237 The size of the transferred data is determined from the
241 field is ignored in this call.
244 field can be used to flag that the request is allowed to
245 be shorter than the requested size, and
247 will contain the actual size on completion.
249 struct usb_ctl_request {
251 usb_device_request_t ucr_request;
254 #define USBD_SHORT_XFER_OK 0x04 /* allow short reads */
255 int ucr_actlen; /* actual length transferred */
258 This is a dangerous operation in that it can perform arbitrary operations
260 Some of the most dangerous (e.g., changing the device
261 address) are not allowed.
262 .It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info"
263 Get an information summary for the device.
264 This call will not issue any USB transactions.
267 Note that there are two different ways of addressing configurations,
268 interfaces, alternatives, and endpoints: by index or by number.
269 The index is the ordinal number (starting from 0) of the descriptor
270 as presented by the device.
271 The number is the respective number of
272 the entity as found in its descriptor.
273 Enumeration of descriptors
274 uses the index, getting and setting typically uses numbers.
277 all endpoints (except the control endpoint) for the current configuration
278 can be found by iterating the
281 .Va config_desc->bNumInterface Ns \-1
282 and for each of these, iterating the
285 .Va interface_desc->bNumEndpoints .
289 .Dv USB_CURRENT_CONFIG_INDEX
293 .Dv USB_CURRENT_ALT_INDEX .
295 .Bl -tag -width ".Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar EE" -compact
296 .It Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar EE
311 .\" The driver is not yet finished; there is no access to isochronous endpoints.