summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/usb_get_alt_if.9f
blob: 837fdf0fc32a398b840d907e71be071b5a529e86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
'\" te
.\" Copyright (c) 2006 Sun Microsystems, Inc., All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH USB_GET_ALT_IF 9F "Dec 29, 2006"
.SH NAME
usb_get_alt_if, usb_set_alt_if, usb_get_if_number, usb_owns_device \- Get and
set alternate interface values
.SH SYNOPSIS
.LP
.nf
#include <sys/usb/usba.h>



\fBint\fR \fBusb_get_alt_if\fR(\fBdev_info_t *\fR\fIdip\fR, \fBuint_t\fR \fIinterface_number\fR,
     \fBuint_t *\fR\fIalternate_number\fR, \fBusb_flags_t\fR \fIflags\fR);
.fi

.LP
.nf
\fBint\fR \fBusb_set_alt_if\fR(\fBdev_info_t *\fR\fIdip\fR, \fBuint_t\fR \fIinterface_number\fR,
     \fBuint_t\fR \fIalternate_number\fR, \fBusb_flags_t\fR \fIflags\fR,
     \fBvoid (*\fR\fIcallback\fR)(usb_pipe_handle_t \fIpipe_handle\fR,
     \fBusb_opaque_t\fR \fIcallback_arg\fR, \fBint\fR \fIrval\fR, \fBusb_cb_flags_t\fR \fIflags\fR),
     \fBusb_opaque_t\fR \fIcallback_arg\fR);
.fi

.LP
.nf
\fB\fR

\fBint\fR \fBusb_get_if_number\fR(\fBdev_info_t *\fR\fIdip\fR);
.fi

.LP
.nf
\fB\fR

\fBboolean_t\fR \fBusb_owns_device\fR(\fBdev_info_t *\fR\fIdip\fR);
.fi

.SH INTERFACE LEVEL
.sp
.LP
Solaris DDI specific (Solaris DDI)
.SH PARAMETERS
.sp
.LP
For \fBusb_get_alt_if()\fR:
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 20n
Pointer to device's \fBdev_info\fR structure.
.RE

.sp
.ne 2
.na
\fB\fIinterface_number\fR\fR
.ad
.RS 20n
Interface of the desired alternate.
.RE

.sp
.ne 2
.na
\fB\fIalternate_number\fR\fR
.ad
.RS 20n
Address where current alternate setting is returned.
.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 20n
No flags are recognized. Reserved for future expansion.
.RE

.sp
.LP
For \fBusb_set_alt_if()\fR:
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 20n
Pointer to device's \fBdev_info\fR structure.
.RE

.sp
.ne 2
.na
\fB\fIinterface_number\fR\fR
.ad
.RS 20n
Interface of the desired alternate.
.RE

.sp
.ne 2
.na
\fB\fIalternate_number\fR\fR
.ad
.RS 20n
Alternate interface number to be set.
.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 20n
Only USB_FLAGS_SLEEP is recognized. Wait for completion and do not call
callback.
.RE

.sp
.ne 2
.na
\fB\fIcallback\fR\fR
.ad
.RS 20n
Callback handler to notify of asynchronous completion.
.RE

.sp
.ne 2
.na
\fB\fIcallback_arg\fR\fR
.ad
.RS 20n
Second argument passed to callback handler.
.RE

.sp
.LP
For \fBusb_get_if_number()\fR:
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 7n
Pointer to device's \fBdev_info\fR structure.
.RE

.sp
.LP
For \fBusb_owns_device()\fR:
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 7n
Pointer to device's \fBdev_info\fR structure.
.RE

.SH DESCRIPTION
.sp
.LP
USB devices can have multiple configurations, each with many interfaces. Within
interfaces are alternate settings, and within alternate settings are endpoints.
.sp
.LP
Each interface within a configuration may be represented by the kernel as a
device node. Only one set of device nodes (interfaces as determined by the
configuration) can be active at one time.
.sp
.LP
Alternates to an interface represent different ways the kernel sees a device
node. Only one alternate setting within an interface can be active (or
selected) at one time.  The functions presented in this man page get or set
interface or alternate setting information.
.sp
.LP
The \fBusb_get_alt_if()\fR function requests the device to return the current
alternate setting of the given interface. This function ignores the flags
argument and always blocks.
.sp
.LP
The \fBusb_set_alt_if()\fR function requests the device to set the interface
and its alternate setting as specified. Because this call changes the current
device's interface and sets the new interface's mode of operation as seen by
the system, the driver must insure that all pipes other than the default
control pipe are closed and quiescent. To avoid contending with another driver
for a different part of the device, the driver must be bound to: the entire
device, the interface-association which includes the alternative interface, or
to the interface whose number is \fIinterface_number\fR.
.sp
.LP
If \fBUSB_FLAGS_SLEEP\fR is set in flags, \fBusb_set_alt_if()\fR blocks until
completed. Otherwise, \fBusb_set_alt_if()\fR returns immediately and calls the
callback handler when completed.
.sp
.LP
\fIcallback\fR is the asynchronous callback handler and takes the following
arguments:
.sp
.ne 2
.na
\fBusb_pipe_handle_t pipe_handle\fR
.ad
.sp .6
.RS 4n
Handle of the default control pipe used to perform the request.
.RE

.sp
.ne 2
.na
\fBusb_opaque_t callback_arg\fR
.ad
.sp .6
.RS 4n
Callback_arg specified to \fBusb_set_alt_if()\fR.
.RE

.sp
.ne 2
.na
\fBint rval\fR
.ad
.sp .6
.RS 4n
Request status.
.RE

.sp
.ne 2
.na
\fBusb_cb_flags_t callback_flags:\fR
.ad
.sp .6
.RS 4n
Status of the queueing operation. Can be:
.sp
USB_CB_NO_INFO - Callback was uneventful.
.sp
USB_CB_ASYNC_REQ_FAILED   -  Error queueing request.
.sp
USB_CB_NO_RESOURCES   -   Error allocating resources.
.RE

.sp
.LP
The \fBusb_get_if_number()\fR function returns the interface number, or
\fBUSB_COMBINED_NODE\fR or \fBUSB_DEVICE_NODE\fR node indicating that the
driver is bound to the entire device.
.sp
.LP
The \fBusb_owns_device()\fR function returns \fBB_TRUE\fR if the driver of the
dip  argument owns the entire device, or \fBB_FALSE\fR if it owns just a
particular interface.
.SH RETURN VALUES
.sp
.LP
For \fBusb_get_alt_if()\fR:
.sp
.ne 2
.na
\fBUSB_SUCCESS\fR
.ad
.RS 23n
Interface's alternate setting was successfully obtained.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_ARGS\fR
.ad
.RS 23n
Pointer to alternate_number and/or dip are NULL.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_CONTEXT\fR
.ad
.RS 23n
Called from interrupt context.
.RE

.sp
.ne 2
.na
\fBUSB_FAILURE\fR
.ad
.RS 23n
The interface number is invalid.
.sp
An access error occurred.
.RE

.sp
.LP
For \fBusb_set_alt_if()\fR:
.sp
.ne 2
.na
\fBUSB_SUCCESS\fR
.ad
.RS 23n
Alternate interface was successfully set.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_ARGS\fR
.ad
.RS 23n
dip is NULL. USB_FLAGS_SLEEP is clear and callback is NULL.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_PERM\fR
.ad
.RS 23n
dip does not own the interface to be set.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_CONTEXT\fR
.ad
.RS 23n
Called from interrupt context with USB_FLAGS_SLEEP specified.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_PIPE\fR
.ad
.RS 23n
Pipe handle is NULL, invalid, or refers to a pipe that is closing or closed.
.RE

.sp
.ne 2
.na
\fBUSB_FAILURE\fR
.ad
.RS 23n
The interface number and/or alternate setting are invalid.
.sp
Pipes were open.
.sp
An access error occurred.
.RE

.sp
.LP
For \fBusb_get_if_number()\fR:
.sp
.LP
\fBUSB_COMBINED_NODE\fR if the driver is responsible for the entire active
device configuration. The \fBdip\fR doesn't correspond to an entire physical
device.
.sp
.LP
\fBUSB_DEVICE_NODE\fR if the driver is responsible for the entire device. The
\fIdip\fR corresponds to an entire physical device.
.sp
.LP
interface number: otherwise.
.sp
.LP
For \fBusb_owns_device()\fR:
.sp
.ne 2
.na
\fBB_TRUE\fR
.ad
.RS 11n
Driver of the dip argument owns the entire device.
.RE

.sp
.ne 2
.na
\fBB_FALSE\fR
.ad
.RS 11n
Driver of the dip argument owns only the current interface.
.RE

.SH CONTEXT
.sp
.LP
The \fBusb_get_if_number()\fR and \fBusb_owns_device()\fR functions may be
called from user or kernel context.
.sp
.LP
The \fBusb_set_alt_if()\fR function may always be called from user or kernel
context. It may be called from interrupt context only if \fBUSB_FLAGS_SLEEP\fR
is not set in flags. If the \fBUSB_CB_ASYNC_REQ_FAILED\fR bit is clear in
\fBusb_cb_flags_t\fR, the callback, if supplied, can block because it is
executing in kernel context. Otherwise the callback cannot block. See
\fBusb_callback_flags\fR(9S) for more information on callbacks.
.sp
.LP
The \fBusb_get_alt_if()\fR function may be called from user or kernel context.
.SH EXAMPLES
.sp
.in +2
.nf
/* Change alternate setting of interface 0.  Wait for completion. */
if (usb_set_alt_if(
    dip, 0, new_alternate_setting_num, USB_FLAGS_SLEEP, NULL, 0) !=
    USB_SUCCESS) {
        cmn_err (CE_WARN,
            "%s%d: Error setting alternate setting on pipe",
            ddi_driver_name(dip), ddi_get_instance(dip));
        }
}
.fi
.in -2

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Architecture	PCI-based systems
_
Interface stability	Committed
.TE

.SH SEE ALSO
.sp
.LP
\fBattributes\fR(5), \fBusb_pipe_ctrl_xfer\fR(9F), \fBusb_get_dev_data\fR(9F),
\fBusb_get_string_descr\fR(9F), \fBusb_get_cfg\fR(9F)