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.
17 .\" 3. All advertising materials mentioning features or use of this software
18 .\" must display the following acknowledgement:
19 .\" This product includes software developed by the NetBSD
20 .\" Foundation, Inc. and its contributors.
21 .\" 4. Neither the name of The NetBSD Foundation nor the names of its
22 .\" contributors may be used to endorse or promote products derived
23 .\" from this software without specific prior written permission.
25 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 .\" POSSIBILITY OF SUCH DAMAGE.
37 .\" $FreeBSD: src/share/man/man4/ugen.4,v 1.1.2.2 2001/12/17 11:30:12 ru Exp $
38 .\" $DragonFly: src/share/man/man4/ugen.4,v 1.2 2003/06/17 06:36:59 dillon Exp $
45 .Nd USB generic device support
51 driver provides support for all USB devices that do not have
53 It supports access to all parts of the device,
54 but not in a way that is as convenient as a special purpose driver.
56 There can be up to 127 USB devices connected to a USB bus.
57 Each USB device can have up to 16 endpoints.
58 Each of these endpoints
59 will communicate in one of four different modes: control, isochronous,
61 Each of the endpoints will have a different
63 The four least significant bits in the minor device
64 number determines which endpoint the device accesses and the rest
65 of the bits determines which USB device.
67 If an endpoint address is used both for input and output the device
68 can be opened for both read or write.
70 To find out what endpoints that exist there are a series of
72 operation on the control endpoint that returns the USB descriptors
73 of the device, configurations, interfaces, and endpoints.
75 The control transfer mode can only happen on the control endpoint
76 which is always endpoint 0.
77 The control endpoint accepts request
78 and may respond with an answer to such request.
84 .\" The isochronous transfer mode can be in or out depending on the
86 .\" To perform I/O on an isochronous endpoint
91 .\" Before any I/O operations can take place the transfer rate in
92 .\" bytes/second has to be set.
95 .\" .Dv USB_SET_ISO_RATE .
96 .\" Performing this call sets up a buffer corresponding to
97 .\" about 1 second of data.
99 The bulk transfer mode can be in or out depending on the
101 To perform I/O on a bulk endpoint
106 All I/O operations on a bulk endpoint are unbuffered.
108 The interrupt transfer mode can only be in.
109 To perform input from an interrupt endpoint
112 A moderate amount of buffering is done
115 All endpoints handle the following
118 .Bl -tag -width indent
119 .It Dv USB_SET_SHORT_XFER Pq Vt int
120 Allow short read transfer.
121 Normally a transfer from the device
122 which is shorter than the request specified is reported as an
124 .It Dv USB_SET_TIMEOUT Pq Vt int
125 Set the timeout on the device operations, the time is specified
127 The value 0 is used to indicate that there is
131 The control endpoint (endpoint 0) handles the following
134 .Bl -tag -width indent
135 .It Dv USB_GET_CONFIG Pq Vt int
136 Get the device configuration number.
137 .It Dv USB_SET_CONFIG Pq Vt int
138 Set the device into the given configuration number.
140 This operation can only be performed when the control endpoint
141 is the sole open endpoint.
142 .It Dv USB_GET_ALTINTERFACE Pq Vt "struct usb_alt_interface"
143 Get the alternative setting number for the interface with the given
147 is ignored in this call.
149 struct usb_alt_interface {
155 .It Dv USB_SET_ALTINTERFACE Pq Vt "struct usb_alt_interface"
156 Set the alternative setting to the given number in the interface with the
160 is ignored in this call.
162 This operation can only be performed when no endpoints for the interface
164 .It Dv USB_GET_NO_ALT Pq Vt "struct usb_alt_interface"
165 Return the number of different alternate settings in the
168 .It Dv USB_GET_DEVICE_DESC Pq Vt usb_device_descriptor_t
169 Return the device descriptor.
170 .It Dv USB_GET_CONFIG_DESC Pq Vt "struct usb_config_desc"
171 Return the descriptor for the configuration with the given index.
172 For convenience the current configuration can be specified by
173 .Dv USB_CURRENT_CONFIG_INDEX .
175 struct usb_config_desc {
177 usb_config_descriptor_t desc;
180 .It Dv USB_GET_INTERFACE_DESC Pq Vt "struct usb_interface_desc"
181 Return the interface descriptor for an interface specified by its
182 configuration index, interface index, and alternative index.
183 For convenience the current alternative can be specified by
184 .Dv USB_CURRENT_ALT_INDEX .
186 struct usb_interface_desc {
190 usb_interface_descriptor_t desc;
193 .It Dv USB_GET_ENDPOINT_DESC Pq Vt "struct usb_endpoint_desc"
194 Return the endpoint descriptor for the endpoint specified by its
195 configuration index, interface index, alternative index, and
198 struct usb_endpoint_desc {
203 usb_endpoint_descriptor_t desc;
206 .It Dv USB_GET_FULL_DESC Pq Vt "struct usb_full_desc"
207 Return all the descriptors for the given configuration.
209 struct usb_full_desc {
217 field should point to a memory area of the size given in the
220 The proper size can be determined by first issuing a
221 .Dv USB_GET_CONFIG_DESC
225 .It Dv USB_GET_STRING_DESC Pq Vt "struct usb_string_desc"
226 Get a string descriptor for the given language ID and
229 struct usb_string_desc {
232 usb_string_descriptor_t desc;
235 .It Dv USB_DO_REQUEST Pq Vt "struct usb_ctl_request"
236 Send a USB request to the device on the control endpoint.
237 Any data sent to/from the device is located at
239 The size of the transferred data is determined from the
243 field is ignored in this call.
246 field can be used to flag that the request is allowed to
247 be shorter than the requested size, and the
249 will contain the actual size on completion.
251 struct usb_ctl_request {
253 usb_device_request_t request;
256 #define USBD_SHORT_XFER_OK 0x04 /* allow short reads */
257 int actlen; /* actual length transferred */
260 This is a dangerous operation in that it can perform arbitrary operations
262 Some of the most dangerous (e.g., changing the device
263 address) are not allowed.
264 .It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info"
265 Get an information summary for the device.
267 issue any USB transactions.
270 Note that there are two different ways of addressing configurations, interfaces,
271 alternatives, and endpoints: by index or by number.
272 The index is the ordinal number (starting from 0) of the descriptor
273 as presented by the device.
274 The number is the respective number of
275 the entity as found in its descriptor.
276 Enumeration of descriptors
277 use the index, getting and setting typically uses numbers.
280 all endpoints (except the control endpoint) for the current configuration
281 can be found by iterating the
284 .Va config_desc->bNumInterface Ns \-1
285 and for each of these iterating the
288 .Va interface_desc->bNumEndpoints .
292 .Dv USB_CURRENT_CONFIG_INDEX
296 .Dv USB_CURRENT_ALT_INDEX .
298 .Bl -tag -width ".Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar EE" -compact
299 .It Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar EE
314 .\" The driver is not yet finished; there is no access to isochronous endpoints.