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 "Sep 16, 2016"
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
29 Solaris DDI specific (Solaris DDI)
32 For \fBusb_get_cfg()\fR:
39 Pointer to device's dev_info structure.
48 Pointer to returned configuration value.
57 Not used. Always waits for completion.
62 For \fBusb_set_cfg()\fR:
69 Pointer to device's dev_info structure.
78 Desired device configuration index. Set to USB_DEV_DEFAULT_CONFIG_INDEX to
79 restore default configuration.
88 Only USB_FLAGS_SLEEP is recognized. Wait for completion and do not call
98 Callback handler to notify of asynchronous completion.
104 \fB\fIcallback_arg\fR\fR
107 Second argument passed to callback handler.
112 The \fBusb_get_cfg()\fR function retrieves the current configuration. It
113 ignores the flags argument and always blocks while contacting the device.
116 The \fBusb_set_cfg()\fR function sets a new configuration. Because this call
117 changes the device's mode of operation, the device must be quiescent and have
118 all pipes, with the exception of the default control pipe, closed. The driver
119 must have control over the entire device and cannot own just a single interface
120 on a composite device. Additionally, its device node must not be a parent to
121 other device nodes that can be operated by other drivers. The driver must own
122 the device exclusively, otherwise drivers managing other parts of the device
123 would be affected without their knowledge or control.
126 This call updates all internal USBA framework data structures, whereas issuing
127 a raw USB_REQ_SET_CFG device request does not. The \fBusb_set_cfg()\fR
128 function is the only supported programmatic way to change device configuration.
131 This call blocks if USB_FLAGS_SLEEP is set in flags. It returns immediately
132 and calls the callback on completion if USB_FLAGS_SLEEP is not set.
135 For \fBusb_get_cfg()\fR:
142 New configuration is retrieved.
148 \fBUSB_INVALID_ARGS\fR
151 \fIcfgval\fR or \fIdip\fR is NULL.
160 Configuration cannot be retrieved.
165 For \fBusb_set_cfg()\fR:
172 New configuration is set.
178 \fBUSB_INVALID_ARGS\fR
183 USB_FLAGS_SLEEP is clear and callback is NULL.
189 \fBUSB_INVALID_CONTEXT\fR
192 Called from interrupt context with USB_FLAGS_SLEEP specified.
198 \fBUSB_INVALID_PERM\fR
201 Caller does not own entire device or device is a parent to child devices.
210 One or more pipes other than the default control pipe are open on the device.
216 \fBUSB_INVALID_PIPE\fR
219 Pipe handle is NULL or invalid, or pipe is closing or closed.
228 An illegal configuration is specified.
230 One or more pipes other than the default control pipe are open on the device.
235 The \fBusb_get_cfg()\fR function may be called from user or kernel context.
238 The \fBusb_set_cfg()\fR function may be called from user or kernel context
239 always. It may be called from interrupt context only if USB_FLAGS_SLEEP is not
243 If the USB_CB_ASYNC_REQ_FAILED bit is clear in usb_cb_flags_t, the callback, if
244 supplied, can block because it is executing in kernel context. Otherwise the
245 callback cannot block. Please see \fBusb_callback_flags\fR(9S) for more
246 information on callbacks.
250 Setting the configuration to the one at index 1 (in the
251 array of usb_cfg_data_t configuration nodes as returned
252 by usb_get_dev_data()), and verifying what the configuration
253 is at that index. (See usb_get_dev_data(9F)).
255 uint_t cfg_index = 1;
258 * Assume all pipes other than the default control pipe
259 * are closed and make sure all requests to the default
260 * control pipe have completed. /
264 if (usb_set_cfg(dip, cfg_index, USB_FLAGS_SLEEP, NULL, 0)
267 "%s%d: Error setting USB device to configuration #%d",
268 ddi_driver_name(dip), ddi_get_instance(dip), cfg_index);
271 if (usb_get_cfg(dip, &bConfigurationValue, 0) == USB_SUCCESS) {
272 cmn_err (CE_WARN, "%s%d: USB device active configuration is %d",
273 ddi_driver_name(dip), ddi_get_instance(dip),
274 bConfigurationValue);
285 See \fBattributes\fR(5) for descriptions of the following attributes:
293 ATTRIBUTE TYPE ATTRIBUTE VALUE
295 Architecture PCI-based systems
297 Interface stability Committed
302 \fBattributes\fR(5), \fBusb_get_alt_if\fR(9F), \fBusb_get_dev_data\fR(9F),
303 \fBusb_get_string_descr\fR(9F), \fBusb_pipe_xopen\fR(9F),
304 \fBusb_callback_flags\fR(9S), \fBusb_cfg_descr\fR(9S), \fBusb_ep_descr\fR(9S),
305 \fBusb_if_descr\fR(9S)