]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - share/man/man4/ugen.4
MFC r317584:
[FreeBSD/stable/8.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 .\" 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.
24 .\"
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.
36 .\"
37 .\" $FreeBSD$
38 .\"
39 .Dd July 22, 2012
40 .Dt UGEN 4
41 .Os
42 .Sh NAME
43 .Nm ugen
44 .Nd USB generic device support
45 .Sh SYNOPSIS
46 .Nm
47 is integrated into the
48 .Xr usb 4
49 kernel module.
50 .Sh DESCRIPTION
51 The
52 .Nm
53 driver provides support for all USB devices that do not have
54 a special driver.
55 It supports access to all parts of the device,
56 but not in a way that is as convenient as a special purpose driver.
57 .Pp
58 There can be up to 127 USB devices connected to a USB bus.
59 Each USB device can have up to 16 endpoints.
60 Each of these endpoints
61 will communicate in one of four different modes: control, isochronous,
62 bulk, or interrupt.
63 Each of the endpoints will have a different
64 device node.
65 The four least significant bits in the minor device
66 number determine which endpoint the device accesses, and the rest
67 of the bits determine which USB device.
68 .Pp
69 If an endpoint address is used both for input and output, the device
70 can be opened for both read or write.
71 .Pp
72 To find out which endpoints exist, there are a series of
73 .Xr ioctl 2
74 operations on the control endpoint that return the USB descriptors
75 of the device, configurations, interfaces, and endpoints.
76 .Pp
77 The control transfer mode can only happen on the control endpoint
78 which is always endpoint 0.
79 The control endpoint accepts a request
80 and may respond with an answer to such a request.
81 Control requests
82 are issued by
83 .Xr ioctl 2
84 calls.
85 .\" .Pp
86 .\" The isochronous transfer mode can be in or out depending on the
87 .\" endpoint.
88 .\" To perform I/O on an isochronous endpoint
89 .\" .Xr read 2
90 .\" and
91 .\" .Xr write 2
92 .\" should be used.
93 .\" Before any I/O operations can take place the transfer rate in
94 .\" bytes/second has to be set.
95 .\" This is done with
96 .\" .Xr ioctl 2
97 .\" .Dv USB_SET_ISO_RATE .
98 .\" Performing this call sets up a buffer corresponding to
99 .\" about 1 second of data.
100 .Pp
101 The bulk transfer mode can be in or out depending on the
102 endpoint.
103 To perform I/O on a bulk endpoint
104 .Xr read 2
105 and
106 .Xr write 2
107 should be used.
108 All I/O operations on a bulk endpoint are unbuffered.
109 .Pp
110 The interrupt transfer mode can be in or out depending on the
111 endpoint.
112 To perform I/O on an interrupt endpoint
113 .Xr read 2
114 and
115 .Xr write 2
116 should be used.
117 A moderate amount of buffering is done
118 by the driver.
119 .Pp
120 All endpoints handle the following
121 .Xr ioctl 2
122 calls:
123 .Bl -tag -width indent
124 .It Dv USB_SET_SHORT_XFER Pq Vt int
125 Allow short read transfer.
126 Normally a transfer from the device
127 which is shorter than the request specified is reported as an
128 error.
129 .It Dv USB_SET_TIMEOUT Pq Vt int
130 Set the timeout on the device operations
131 The time is specified in milliseconds.
132 The value 0 is used to indicate that there is
133 no timeout.
134 .El
135 .Pp
136 The control endpoint (endpoint 0) handles the following
137 .Xr ioctl 2
138 calls:
139 .Bl -tag -width indent
140 .It Dv USB_GET_CONFIG Pq Vt int
141 Get the device configuration number.
142 .It Dv USB_SET_CONFIG Pq Vt int
143 Set the device into the given configuration number.
144 .Pp
145 This operation can only be performed when the control endpoint
146 is the sole open endpoint.
147 .It Dv USB_GET_ALTINTERFACE Pq Vt "struct usb_alt_interface"
148 Get the alternative setting number for the interface with the given
149 index.
150 The
151 .Va uai_config_index
152 is ignored in this call.
153 .Bd -literal
154 struct usb_alt_interface {
155         int     uai_config_index;
156         int     uai_interface_index;
157         int     uai_alt_no;
158 };
159 .Ed
160 .It Dv USB_SET_ALTINTERFACE Pq Vt "struct usb_alt_interface"
161 Set the alternative setting to the given number in the interface with the
162 given index.
163 The
164 .Va uai_config_index
165 is ignored in this call.
166 .Pp
167 This operation can only be performed when no endpoints for the interface
168 are open.
169 .It Dv USB_GET_NO_ALT Pq Vt "struct usb_alt_interface"
170 Return the number of different alternate settings in the
171 .Va uai_alt_no
172 field.
173 .It Dv USB_GET_DEVICE_DESC Pq Vt usb_device_descriptor_t
174 Return the device descriptor.
175 .It Dv USB_GET_CONFIG_DESC Pq Vt "struct usb_config_desc"
176 Return the descriptor for the configuration with the given index.
177 For convenience, the current configuration can be specified by
178 .Dv USB_CURRENT_CONFIG_INDEX .
179 .Bd -literal
180 struct usb_config_desc {
181         int     ucd_config_index;
182         usb_config_descriptor_t ucd_desc;
183 };
184 .Ed
185 .It Dv USB_GET_INTERFACE_DESC Pq Vt "struct usb_interface_desc"
186 Return the interface descriptor for an interface specified by its
187 configuration index, interface index, and alternative index.
188 For convenience, the current alternative can be specified by
189 .Dv USB_CURRENT_ALT_INDEX .
190 .Bd -literal
191 struct usb_interface_desc {
192         int     uid_config_index;
193         int     uid_interface_index;
194         int     uid_alt_index;
195         usb_interface_descriptor_t uid_desc;
196 };
197 .Ed
198 .It Dv USB_GET_ENDPOINT_DESC Pq Vt "struct usb_endpoint_desc"
199 Return the endpoint descriptor for the endpoint specified by its
200 configuration index, interface index, alternative index, and
201 endpoint index.
202 .Bd -literal
203 struct usb_endpoint_desc {
204         int     ued_config_index;
205         int     ued_interface_index;
206         int     ued_alt_index;
207         int     ued_endpoint_index;
208         usb_endpoint_descriptor_t ued_desc;
209 };
210 .Ed
211 .It Dv USB_GET_FULL_DESC Pq Vt "struct usb_full_desc"
212 Return all the descriptors for the given configuration.
213 .Bd -literal
214 struct usb_full_desc {
215         int     ufd_config_index;
216         u_int   ufd_size;
217         u_char  *ufd_data;
218 };
219 .Ed
220 The
221 .Va ufd_data
222 field should point to a memory area of the size given in the
223 .Va ufd_size
224 field.
225 The proper size can be determined by first issuing a
226 .Dv USB_GET_CONFIG_DESC
227 and inspecting the
228 .Va wTotalLength
229 field.
230 .It Dv USB_GET_STRING_DESC Pq Vt "struct usb_string_desc"
231 Get a string descriptor for the given language ID and
232 string index.
233 .Bd -literal
234 struct usb_string_desc {
235         int     usd_string_index;
236         int     usd_language_id;
237         usb_string_descriptor_t usd_desc;
238 };
239 .Ed
240 .It Dv USB_DO_REQUEST Pq Vt "struct usb_ctl_request"
241 Send a USB request to the device on the control endpoint.
242 Any data sent to/from the device is located at
243 .Va ucr_data .
244 The size of the transferred data is determined from the
245 .Va ucr_request .
246 The
247 .Va ucr_addr
248 field is ignored in this call.
249 The
250 .Va ucr_flags
251 field can be used to flag that the request is allowed to
252 be shorter than the requested size, and
253 .Va ucr_actlen
254 will contain the actual size on completion.
255 .Bd -literal
256 struct usb_ctl_request {
257         int     ucr_addr;
258         usb_device_request_t ucr_request;
259         void    *ucr_data;
260         int     ucr_flags;
261 #define USBD_SHORT_XFER_OK      0x04    /* allow short reads */
262         int     ucr_actlen;             /* actual length transferred */
263 };
264 .Ed
265 This is a dangerous operation in that it can perform arbitrary operations
266 on the device.
267 Some of the most dangerous (e.g., changing the device
268 address) are not allowed.
269 .It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info"
270 Get an information summary for the device.
271 This call will not issue any USB transactions.
272 .El
273 .Pp
274 Note that there are two different ways of addressing configurations,
275 interfaces, alternatives, and endpoints: by index or by number.
276 The index is the ordinal number (starting from 0) of the descriptor
277 as presented by the device.
278 The number is the respective number of
279 the entity as found in its descriptor.
280 Enumeration of descriptors
281 uses the index, getting and setting typically uses numbers.
282 .Pp
283 Example:
284 all endpoints (except the control endpoint) for the current configuration
285 can be found by iterating the
286 .Va interface_index
287 from 0 to
288 .Va config_desc->bNumInterface Ns \-1
289 and for each of these, iterating the
290 .Va endpoint_index
291 from 0 to
292 .Va interface_desc->bNumEndpoints .
293 The
294 .Va config_index
295 should be set to
296 .Dv USB_CURRENT_CONFIG_INDEX
297 and
298 .Va alt_index
299 should be set to
300 .Dv USB_CURRENT_ALT_INDEX .
301 .Sh FILES
302 .Bl -tag -width ".Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar EE" -compact
303 .It Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar EE
304 Endpoint
305 .Ar EE
306 of device
307 .Ar N .
308 .El
309 .Sh SEE ALSO
310 .Xr usb 4
311 .Sh HISTORY
312 The
313 .Nm
314 driver
315 appeared in
316 .Nx 1.4 .
317 .\" .Sh BUGS
318 .\" The driver is not yet finished; there is no access to isochronous endpoints.