]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - share/man/man4/ugen.4
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / share / man / man4 / ugen.4
1 .\" $NetBSD: ugen.4,v 1.13 2001/09/11 22:52:54 wiz Exp $
2 .\"
3 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Lennart Augustsson.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
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 .\"
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.
29 .\"
30 .\" $FreeBSD$
31 .\"
32 .Dd July 22, 2012
33 .Dt UGEN 4
34 .Os
35 .Sh NAME
36 .Nm ugen
37 .Nd USB generic device support
38 .Sh SYNOPSIS
39 .Nm
40 is integrated into the
41 .Xr usb 4
42 kernel module.
43 .Sh DESCRIPTION
44 The
45 .Nm
46 driver provides support for all USB devices that do not have
47 a special driver.
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.
50 .Pp
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,
55 bulk, or interrupt.
56 Each of the endpoints will have a different
57 device node.
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.
61 .Pp
62 If an endpoint address is used both for input and output, the device
63 can be opened for both read or write.
64 .Pp
65 To find out which endpoints exist, there are a series of
66 .Xr ioctl 2
67 operations on the control endpoint that return the USB descriptors
68 of the device, configurations, interfaces, and endpoints.
69 .Pp
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.
74 Control requests
75 are issued by
76 .Xr ioctl 2
77 calls.
78 .\" .Pp
79 .\" The isochronous transfer mode can be in or out depending on the
80 .\" endpoint.
81 .\" To perform I/O on an isochronous endpoint
82 .\" .Xr read 2
83 .\" and
84 .\" .Xr write 2
85 .\" should be used.
86 .\" Before any I/O operations can take place the transfer rate in
87 .\" bytes/second has to be set.
88 .\" This is done with
89 .\" .Xr ioctl 2
90 .\" .Dv USB_SET_ISO_RATE .
91 .\" Performing this call sets up a buffer corresponding to
92 .\" about 1 second of data.
93 .Pp
94 The bulk transfer mode can be in or out depending on the
95 endpoint.
96 To perform I/O on a bulk endpoint
97 .Xr read 2
98 and
99 .Xr write 2
100 should be used.
101 All I/O operations on a bulk endpoint are unbuffered.
102 .Pp
103 The interrupt transfer mode can be in or out depending on the
104 endpoint.
105 To perform I/O on an interrupt endpoint
106 .Xr read 2
107 and
108 .Xr write 2
109 should be used.
110 A moderate amount of buffering is done
111 by the driver.
112 .Pp
113 All endpoints handle the following
114 .Xr ioctl 2
115 calls:
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
121 error.
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
126 no timeout.
127 .El
128 .Pp
129 The control endpoint (endpoint 0) handles the following
130 .Xr ioctl 2
131 calls:
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.
137 .Pp
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
142 index.
143 The
144 .Va uai_config_index
145 is ignored in this call.
146 .Bd -literal
147 struct usb_alt_interface {
148         int     uai_config_index;
149         int     uai_interface_index;
150         int     uai_alt_no;
151 };
152 .Ed
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
155 given index.
156 The
157 .Va uai_config_index
158 is ignored in this call.
159 .Pp
160 This operation can only be performed when no endpoints for the interface
161 are open.
162 .It Dv USB_GET_NO_ALT Pq Vt "struct usb_alt_interface"
163 Return the number of different alternate settings in the
164 .Va uai_alt_no
165 field.
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 .
172 .Bd -literal
173 struct usb_config_desc {
174         int     ucd_config_index;
175         usb_config_descriptor_t ucd_desc;
176 };
177 .Ed
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 .
183 .Bd -literal
184 struct usb_interface_desc {
185         int     uid_config_index;
186         int     uid_interface_index;
187         int     uid_alt_index;
188         usb_interface_descriptor_t uid_desc;
189 };
190 .Ed
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
194 endpoint index.
195 .Bd -literal
196 struct usb_endpoint_desc {
197         int     ued_config_index;
198         int     ued_interface_index;
199         int     ued_alt_index;
200         int     ued_endpoint_index;
201         usb_endpoint_descriptor_t ued_desc;
202 };
203 .Ed
204 .It Dv USB_GET_FULL_DESC Pq Vt "struct usb_full_desc"
205 Return all the descriptors for the given configuration.
206 .Bd -literal
207 struct usb_full_desc {
208         int     ufd_config_index;
209         u_int   ufd_size;
210         u_char  *ufd_data;
211 };
212 .Ed
213 The
214 .Va ufd_data
215 field should point to a memory area of the size given in the
216 .Va ufd_size
217 field.
218 The proper size can be determined by first issuing a
219 .Dv USB_GET_CONFIG_DESC
220 and inspecting the
221 .Va wTotalLength
222 field.
223 .It Dv USB_GET_STRING_DESC Pq Vt "struct usb_string_desc"
224 Get a string descriptor for the given language ID and
225 string index.
226 .Bd -literal
227 struct usb_string_desc {
228         int     usd_string_index;
229         int     usd_language_id;
230         usb_string_descriptor_t usd_desc;
231 };
232 .Ed
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
236 .Va ucr_data .
237 The size of the transferred data is determined from the
238 .Va ucr_request .
239 The
240 .Va ucr_addr
241 field is ignored in this call.
242 The
243 .Va ucr_flags
244 field can be used to flag that the request is allowed to
245 be shorter than the requested size, and
246 .Va ucr_actlen
247 will contain the actual size on completion.
248 .Bd -literal
249 struct usb_ctl_request {
250         int     ucr_addr;
251         usb_device_request_t ucr_request;
252         void    *ucr_data;
253         int     ucr_flags;
254 #define USBD_SHORT_XFER_OK      0x04    /* allow short reads */
255         int     ucr_actlen;             /* actual length transferred */
256 };
257 .Ed
258 This is a dangerous operation in that it can perform arbitrary operations
259 on the device.
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.
265 .El
266 .Pp
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.
275 .Pp
276 Example:
277 all endpoints (except the control endpoint) for the current configuration
278 can be found by iterating the
279 .Va interface_index
280 from 0 to
281 .Va config_desc->bNumInterface Ns \-1
282 and for each of these, iterating the
283 .Va endpoint_index
284 from 0 to
285 .Va interface_desc->bNumEndpoints .
286 The
287 .Va config_index
288 should be set to
289 .Dv USB_CURRENT_CONFIG_INDEX
290 and
291 .Va alt_index
292 should be set to
293 .Dv USB_CURRENT_ALT_INDEX .
294 .Sh FILES
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
297 Endpoint
298 .Ar EE
299 of device
300 .Ar N .
301 .El
302 .Sh SEE ALSO
303 .Xr usb 4
304 .Sh HISTORY
305 The
306 .Nm
307 driver
308 appeared in
309 .Nx 1.4 .
310 .\" .Sh BUGS
311 .\" The driver is not yet finished; there is no access to isochronous endpoints.