2 .\" Copyright (c) 2004, 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_CFG 9F "Jan 5, 2004"
8 usb_get_cfg, usb_set_cfg \- Get and set current USB device configuration
12 #include <sys/usb/usba.h>
16 \fBint\fR \fBusb_get_cfg\fR(\fBdev_info_t *\fR\fIdip\fR, \fBuint_t\fR \fIcfgval\fR, \fBusb_flags_t\fR \fIflags\fR);
21 \fBint\fR \fBusb_set_cfg\fR(\fBdev_info_t *\fR\fIdip\fR, \fBuint_t\fR \fIcfg_index\fR, \fBusb_flags_t\fR \fIflags\fR,
22 \fBvoid (*\fR\fIcallback\fR)(usb_pipe_handle_t \fIpipe_handle\fR, \fBusb_opaque_t\fR
23 \fIcallback_arg\fR, \fBint\fR \fIrval\fR, \fBusb_cb_flags_t\fR \fIflags)\fR, \fBusb_opaque_t\fR
30 Solaris DDI specific (Solaris DDI)
34 For \fBusb_get_cfg()\fR:
41 Pointer to device's dev_info structure.
50 Pointer to returned configuration value.
59 Not used. Always waits for completion.
64 For \fBusb_set_cfg()\fR:
71 Pointer to device's dev_info structure.
80 Desired device configuration index. Set to USB_DEV_DEFAULT_CONFIG_INDEX to
81 restore default configuration.
90 Only USB_FLAGS_SLEEP is recognized. Wait for completion and do not call
100 Callback handler to notify of asynchronous completion.
106 \fB\fIcallback_arg\fR\fR
109 Second argument passed to callback handler.
115 The \fBusb_get_cfg()\fR function retrieves the current configuration. It
116 ignores the flags argument and always blocks while contacting the device.
119 The \fBusb_set_cfg()\fR function sets a new configuration. Because this call
120 changes the device's mode of operation, the device must be quiescent and have
121 all pipes, with the exception of the default control pipe, closed. The driver
122 must have control over the entire device and cannot own just a single interface
123 on a composite device. Additionally, its device node must not be a parent to
124 other device nodes that can be operated by other drivers. The driver must own
125 the device exclusively, otherwise drivers managing other parts of the device
126 would be affected without their knowledge or control.
129 This call updates all internal USBA framework data structures, whereas issuing
130 a raw USB_REQ_SET_CFG device request does not. The \fBusb_set_cfg()\fR
131 function is the only supported programmatic way to change device configuration.
134 This call blocks if USB_FLAGS_SLEEP is set in flags. It returns immediately
135 and calls the callback on completion if USB_FLAGS_SLEEP is not set.
139 For \fBusb_get_cfg()\fR:
146 New configuration is retrieved.
152 \fBUSB_INVALID_ARGS\fR
155 \fIcfgval\fR or \fIdip\fR is NULL.
164 Configuration cannot be retrieved.
169 For \fBusb_set_cfg()\fR:
176 New configuration is set.
182 \fBUSB_INVALID_ARGS\fR
187 USB_FLAGS_SLEEP is clear and callback is NULL.
193 \fBUSB_INVALID_CONTEXT\fR
196 Called from interrupt context with USB_FLAGS_SLEEP specified.
202 \fBUSB_INVALID_PERM\fR
205 Caller does not own entire device or device is a parent to child devices.
214 One or more pipes other than the default control pipe are open on the device.
220 \fBUSB_INVALID_PIPE\fR
223 Pipe handle is NULL or invalid, or pipe is closing or closed.
232 An illegal configuration is specified.
234 One or more pipes other than the default control pipe are open on the device.
240 The \fBusb_get_cfg()\fR function may be called from user or kernel context.
243 The \fBusb_set_cfg()\fR function may be called from user or kernel context
244 always. It may be called from interrupt context only if USB_FLAGS_SLEEP is not
248 If the USB_CB_ASYNC_REQ_FAILED bit is clear in usb_cb_flags_t, the callback, if
249 supplied, can block because it is executing in kernel context. Otherwise the
250 callback cannot block. Please see \fBusb_callback_flags\fR(9S) for more
251 information on callbacks.
256 Setting the configuration to the one at index 1 (in the
257 array of usb_cfg_data_t configuration nodes as returned
258 by usb_get_dev_data()), and verifying what the configuration
259 is at that index. (See usb_get_dev_data(9F)).
261 uint_t cfg_index = 1;
264 * Assume all pipes other than the default control pipe
265 * are closed and make sure all requests to the default
266 * control pipe have completed. /
270 if (usb_set_cfg(dip, cfg_index, USB_FLAGS_SLEEP, NULL, 0)
273 "%s%d: Error setting USB device to configuration #%d",
274 ddi_driver_name(dip), ddi_get_instance(dip), cfg_index);
277 if (usb_get_cfg(dip, &bConfigurationValue, 0) == USB_SUCCESS) {
278 cmn_err (CE_WARN, "%s%d: USB device active configuration is %d",
279 ddi_driver_name(dip), ddi_get_instance(dip),
280 bConfigurationValue);
292 See \fBattributes\fR(5) for descriptions of the following attributes:
300 ATTRIBUTE TYPE ATTRIBUTE VALUE
302 Architecture PCI-based systems
304 Interface stability Committed
310 \fBattributes\fR(5), \fBusb_get_alt_if\fR(9F), \fBusb_get_dev_data\fR(9F),
311 \fBusb_get_string_descr\fR(9F), \fBusb_pipe_open\fR(9F),
312 \fBusb_callback_flags\fR(9S), \fBusb_cfg_descr\fR(9S), \fBusb_ep_descr\fR(9S),
313 \fBusb_if_descr\fR(9S)