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