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]
#include <sys/usb/usba.h> int usb_get_alt_if(dev_info_t *dip, uint_t interface_number, uint_t *alternate_number, usb_flags_t flags);
int usb_set_alt_if(dev_info_t *dip, uint_t interface_number, uint_t alternate_number, usb_flags_t flags, void (*callback)(usb_pipe_handle_t pipe_handle, usb_opaque_t callback_arg, int rval, usb_cb_flags_t flags), usb_opaque_t callback_arg);
int usb_get_if_number(dev_info_t *dip);
boolean_t usb_owns_device(dev_info_t *dip);
Pointer to device's dev_info structure.
Interface of the desired alternate.
Address where current alternate setting is returned.
No flags are recognized. Reserved for future expansion.
For usb_set_alt_if(): dip
Pointer to device's dev_info structure.
Interface of the desired alternate.
Alternate interface number to be set.
Only USB_FLAGS_SLEEP is recognized. Wait for completion and do not call callback.
Callback handler to notify of asynchronous completion.
Second argument passed to callback handler.
For usb_get_if_number(): dip
Pointer to device's dev_info structure.
For usb_owns_device(): dip
Pointer to device's dev_info structure.
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.
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.
The usb_get_alt_if() function requests the device to return the current alternate setting of the given interface. This function ignores the flags argument and always blocks.
The usb_set_alt_if() 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 interface_number.
If USB_FLAGS_SLEEP is set in flags, usb_set_alt_if() blocks until completed. Otherwise, usb_set_alt_if() returns immediately and calls the callback handler when completed.
callback is the asynchronous callback handler and takes the following arguments: usb_pipe_handle_t pipe_handle
Handle of the default control pipe used to perform the request.
Callback_arg specified to usb_set_alt_if().
Request status.
Status of the queueing operation. Can be: USB_CB_NO_INFO - Callback was uneventful. USB_CB_ASYNC_REQ_FAILED - Error queueing request. USB_CB_NO_RESOURCES - Error allocating resources.
The usb_get_if_number() function returns the interface number, or USB_COMBINED_NODE or USB_DEVICE_NODE node indicating that the driver is bound to the entire device.
The usb_owns_device() function returns B_TRUE if the driver of the dip argument owns the entire device, or B_FALSE if it owns just a particular interface.
Interface's alternate setting was successfully obtained.
Called from interrupt context.
The interface number is invalid. An access error occurred.
For usb_set_alt_if(): USB_SUCCESS
Alternate interface was successfully set.
dip is NULL. USB_FLAGS_SLEEP is clear and callback is NULL.
dip does not own the interface to be set.
Called from interrupt context with USB_FLAGS_SLEEP specified.
Pipe handle is NULL, invalid, or refers to a pipe that is closing or closed.
The interface number and/or alternate setting are invalid. Pipes were open. An access error occurred.
For usb_get_if_number():
USB_COMBINED_NODE if the driver is responsible for the entire active device configuration. The dip doesn't correspond to an entire physical device.
USB_DEVICE_NODE if the driver is responsible for the entire device. The dip corresponds to an entire physical device.
interface number: otherwise.
For usb_owns_device(): B_TRUE
Driver of the dip argument owns the entire device.
Driver of the dip argument owns only the current interface.
The usb_set_alt_if() function may always be called from user or kernel context. It may be called from interrupt context only if USB_FLAGS_SLEEP is not set in flags. If the USB_CB_ASYNC_REQ_FAILED bit is clear in usb_cb_flags_t, the callback, if supplied, can block because it is executing in kernel context. Otherwise the callback cannot block. See usb_callback_flags(9S) for more information on callbacks.
The usb_get_alt_if() function may be called from user or kernel context.
/* 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)); } }
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Architecture PCI-based systems |
Interface stability Committed |