2 .\" Copyright (c) 2006 Sun Microsystems, Inc., All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH USB_GET_ALT_IF 9F "Dec 29, 2006"
8 usb_get_alt_if, usb_set_alt_if, usb_get_if_number, usb_owns_device \- Get and
9 set alternate interface values
13 #include <sys/usb/usba.h>
17 \fBint\fR \fBusb_get_alt_if\fR(\fBdev_info_t *\fR\fIdip\fR, \fBuint_t\fR \fIinterface_number\fR,
18 \fBuint_t *\fR\fIalternate_number\fR, \fBusb_flags_t\fR \fIflags\fR);
23 \fBint\fR \fBusb_set_alt_if\fR(\fBdev_info_t *\fR\fIdip\fR, \fBuint_t\fR \fIinterface_number\fR,
24 \fBuint_t\fR \fIalternate_number\fR, \fBusb_flags_t\fR \fIflags\fR,
25 \fBvoid (*\fR\fIcallback\fR)(usb_pipe_handle_t \fIpipe_handle\fR,
26 \fBusb_opaque_t\fR \fIcallback_arg\fR, \fBint\fR \fIrval\fR, \fBusb_cb_flags_t\fR \fIflags\fR),
27 \fBusb_opaque_t\fR \fIcallback_arg\fR);
34 \fBint\fR \fBusb_get_if_number\fR(\fBdev_info_t *\fR\fIdip\fR);
41 \fBboolean_t\fR \fBusb_owns_device\fR(\fBdev_info_t *\fR\fIdip\fR);
47 Solaris DDI specific (Solaris DDI)
51 For \fBusb_get_alt_if()\fR:
58 Pointer to device's \fBdev_info\fR structure.
64 \fB\fIinterface_number\fR\fR
67 Interface of the desired alternate.
73 \fB\fIalternate_number\fR\fR
76 Address where current alternate setting is returned.
85 No flags are recognized. Reserved for future expansion.
90 For \fBusb_set_alt_if()\fR:
97 Pointer to device's \fBdev_info\fR structure.
103 \fB\fIinterface_number\fR\fR
106 Interface of the desired alternate.
112 \fB\fIalternate_number\fR\fR
115 Alternate interface number to be set.
124 Only USB_FLAGS_SLEEP is recognized. Wait for completion and do not call
134 Callback handler to notify of asynchronous completion.
140 \fB\fIcallback_arg\fR\fR
143 Second argument passed to callback handler.
148 For \fBusb_get_if_number()\fR:
155 Pointer to device's \fBdev_info\fR structure.
160 For \fBusb_owns_device()\fR:
167 Pointer to device's \fBdev_info\fR structure.
173 USB devices can have multiple configurations, each with many interfaces. Within
174 interfaces are alternate settings, and within alternate settings are endpoints.
177 Each interface within a configuration may be represented by the kernel as a
178 device node. Only one set of device nodes (interfaces as determined by the
179 configuration) can be active at one time.
182 Alternates to an interface represent different ways the kernel sees a device
183 node. Only one alternate setting within an interface can be active (or
184 selected) at one time. The functions presented in this man page get or set
185 interface or alternate setting information.
188 The \fBusb_get_alt_if()\fR function requests the device to return the current
189 alternate setting of the given interface. This function ignores the flags
190 argument and always blocks.
193 The \fBusb_set_alt_if()\fR function requests the device to set the interface
194 and its alternate setting as specified. Because this call changes the current
195 device's interface and sets the new interface's mode of operation as seen by
196 the system, the driver must insure that all pipes other than the default
197 control pipe are closed and quiescent. To avoid contending with another driver
198 for a different part of the device, the driver must be bound to: the entire
199 device, the interface-association which includes the alternative interface, or
200 to the interface whose number is \fIinterface_number\fR.
203 If \fBUSB_FLAGS_SLEEP\fR is set in flags, \fBusb_set_alt_if()\fR blocks until
204 completed. Otherwise, \fBusb_set_alt_if()\fR returns immediately and calls the
205 callback handler when completed.
208 \fIcallback\fR is the asynchronous callback handler and takes the following
213 \fBusb_pipe_handle_t pipe_handle\fR
217 Handle of the default control pipe used to perform the request.
223 \fBusb_opaque_t callback_arg\fR
227 Callback_arg specified to \fBusb_set_alt_if()\fR.
243 \fBusb_cb_flags_t callback_flags:\fR
247 Status of the queueing operation. Can be:
249 USB_CB_NO_INFO - Callback was uneventful.
251 USB_CB_ASYNC_REQ_FAILED - Error queueing request.
253 USB_CB_NO_RESOURCES - Error allocating resources.
258 The \fBusb_get_if_number()\fR function returns the interface number, or
259 \fBUSB_COMBINED_NODE\fR or \fBUSB_DEVICE_NODE\fR node indicating that the
260 driver is bound to the entire device.
263 The \fBusb_owns_device()\fR function returns \fBB_TRUE\fR if the driver of the
264 dip argument owns the entire device, or \fBB_FALSE\fR if it owns just a
265 particular interface.
269 For \fBusb_get_alt_if()\fR:
276 Interface's alternate setting was successfully obtained.
282 \fBUSB_INVALID_ARGS\fR
285 Pointer to alternate_number and/or dip are NULL.
291 \fBUSB_INVALID_CONTEXT\fR
294 Called from interrupt context.
303 The interface number is invalid.
305 An access error occurred.
310 For \fBusb_set_alt_if()\fR:
317 Alternate interface was successfully set.
323 \fBUSB_INVALID_ARGS\fR
326 dip is NULL. USB_FLAGS_SLEEP is clear and callback is NULL.
332 \fBUSB_INVALID_PERM\fR
335 dip does not own the interface to be set.
341 \fBUSB_INVALID_CONTEXT\fR
344 Called from interrupt context with USB_FLAGS_SLEEP specified.
350 \fBUSB_INVALID_PIPE\fR
353 Pipe handle is NULL, invalid, or refers to a pipe that is closing or closed.
362 The interface number and/or alternate setting are invalid.
366 An access error occurred.
371 For \fBusb_get_if_number()\fR:
374 \fBUSB_COMBINED_NODE\fR if the driver is responsible for the entire active
375 device configuration. The \fBdip\fR doesn't correspond to an entire physical
379 \fBUSB_DEVICE_NODE\fR if the driver is responsible for the entire device. The
380 \fIdip\fR corresponds to an entire physical device.
383 interface number: otherwise.
386 For \fBusb_owns_device()\fR:
393 Driver of the dip argument owns the entire device.
402 Driver of the dip argument owns only the current interface.
408 The \fBusb_get_if_number()\fR and \fBusb_owns_device()\fR functions may be
409 called from user or kernel context.
412 The \fBusb_set_alt_if()\fR function may always be called from user or kernel
413 context. It may be called from interrupt context only if \fBUSB_FLAGS_SLEEP\fR
414 is not set in flags. If the \fBUSB_CB_ASYNC_REQ_FAILED\fR bit is clear in
415 \fBusb_cb_flags_t\fR, the callback, if supplied, can block because it is
416 executing in kernel context. Otherwise the callback cannot block. See
417 \fBusb_callback_flags\fR(9S) for more information on callbacks.
420 The \fBusb_get_alt_if()\fR function may be called from user or kernel context.
425 /* Change alternate setting of interface 0. Wait for completion. */
427 dip, 0, new_alternate_setting_num, USB_FLAGS_SLEEP, NULL, 0) !=
430 "%s%d: Error setting alternate setting on pipe",
431 ddi_driver_name(dip), ddi_get_instance(dip));
440 See \fBattributes\fR(5) for descriptions of the following attributes:
448 ATTRIBUTE TYPE ATTRIBUTE VALUE
450 Architecture PCI-based systems
452 Interface stability Committed
458 \fBattributes\fR(5), \fBusb_pipe_ctrl_xfer\fR(9F), \fBusb_get_dev_data\fR(9F),
459 \fBusb_get_string_descr\fR(9F), \fBusb_get_cfg\fR(9F)