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_DEV_DATA 9F "Sep 16, 2016"
8 usb_get_dev_data, usb_free_dev_data, usb_free_descr_tree, usb_print_descr_tree
9 \- Retrieve device configuration information
13 #include <sys/usb/usba.h>
17 \fBint\fR \fBusb_get_dev_data\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_client_dev_data_t **\fR\fIdev_data\fR,
18 \fBusb_reg_parse_lvl_t\fR \fIparse_level\fR, \fBusb_flags_t\fR \fIflags\fR);
23 \fBvoid\fR \fBusb_free_dev_data\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_client_dev_data_t *\fR\fIdev_data\fR);
28 \fBvoid\fR \fBusb_free_descr_tree\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_client_dev_data_t *\fR\fIdev_data\fR);
33 \fBint\fR \fBusb_print_descr_tree\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_client_dev_data_t *\fR\fIdev_data\fR);
38 Solaris DDI specific (Solaris DDI)
41 For \fBusb_get_dev_data()\fR:
48 Pointer to device's dev_info structure.
57 Address in which pointer to info is returned.
63 \fB\fIparse_level\fR\fR
66 Portion of device represented in the tree of parsed descriptors. See below for
67 possible usb_reg_parse_lvl_t values and explanations.
81 For \fBusb_free_dev_data()\fR:
88 Pointer to device's dev_info structure.
97 Pointer to usb_client_dev_data_t to be freed.
102 For \fBusb_free_descr_tree()\fR:
109 Pointer to device's dev_info structure.
118 Pointer to usb_client_dev_data_t containing the descriptor tree to free.
123 For \fBusb_print_descr_tree()\fR:
130 Pointer to device's dev_info structure.
139 Pointer to usb_client_dev_data_t containing the descriptor tree to display
145 The \fBusb_get_dev_data()\fR function interrogates a device and returns its
146 configuration information in a usb_client_dev_data_t structure. Most USBA
147 functions require information which comes from a usb_client_dev_data_t, and all
148 other functions in this man page operate on this structure. Please see
149 \fBusb_client_dev_data(9S)\fR for a full content description. Pass the
150 usb_client_dev_data_t structure to \fBusb_client_detach\fR(9F) to completely
154 A descriptor tree is included in the information returned. The
155 usb_reg_parse_lvl_t type represents the extent of the device to be
156 represented by the returned tree (2nd arg to usb_get_dev_data) or what is
157 actually represented in the returned tree (dev_parse_level field of the
158 returned usb_client_dev_data_t). It has the following possible values:
162 \fBUSB_PARSE_LVL_NONE\fR
165 Build no tree. dev_n_cfg returns 0, dev_cfg and dev_curr_cfg are returned
166 NULL, and the dev_curr_xxx fields are invalid.
172 \fBUSB_PARSE_LVL_IF\fR
175 If configuration number and interface properties are set (as when different
176 interfaces are viewed by the OS as different device instances), parse
177 configured interface only. If an OS device instance is set up to represent an
178 entire physical device, USB_PARSE_LVL_IF works like USB_PARSE_LVL_ALL.
184 \fBUSB_PARSE_LVL_CFG\fR
187 Parse entire configuration of configured interface only. Behaves similarly to
188 USB_PARSE_LVL_IF, except that entire configuration is returned.
194 \fBUSB_PARSE_LVL_ALL\fR
197 Parse entire device (all configurations), even when driver is bound to a single
198 interface of a single configuration.
203 The \fBusb_free_dev_data()\fR function undoes what \fBusb_get_dev_data()\fR set
204 up. It releases memory for all strings, descriptors, and trees set up by
205 \fBusb_get_dev_data()\fR.
208 The \fBusb_free_descr_tree()\fR function frees the descriptor tree of its
209 usb_client_dev_data_t argument, while leaving the rest of the information
210 intact. The intent is for drivers to free memory after copying needed
211 descriptor information from the tree. Upon return, the following
212 usb_client_dev_data_t fields are modified as follows: dev_cfg is NULL,
213 dev_n_cfg is zero and dev_parse_level is USB_PARSE_LVL_NONE. Additionally,
214 dev_curr_cfg is NULL and dev_curr_if is invalid.
217 The \fBusb_print_descr_tree()\fR function is an easy-to-use diagnostic aid
218 which dumps the descriptor tree to the screen when the system is verbose booted
219 (\fBboot\fR \fB-v\fR). Output is spaced with blank lines for readability and
220 provides you with an on-screen look at what a device has to offer.
223 For \fBusb_get_dev_data()\fR:
230 Registration is successful.
236 \fBUSB_INVALID_ARGS\fR
239 \fIdip\fR or \fIdev_data\fR is \fBNULL\fR. \fIparse_level\fR is invalid.
245 \fBUSB_INVALID_CONTEXT\fR
248 Called from interrupt context.
254 \fBUSB_INVALID_VERSION\fR
257 \fBusb_client_attach\fR(9F) was not called first.
266 Bad descriptor info or other internal error.
271 For \fBusb_free_dev_data()\fR: None
274 For \fBusb_free_descr_tree()\fR: None, but no operation occurs if \fIdip\fR
275 and/or \fIdev_data\fR are NULL.
278 For \fBusb_print_descr_tree()\fR:
285 Descriptor tree dump is successful.
291 \fBUSB_INVALID_ARGS\fR
294 \fIdev_data\fR or \fIdip\fR are NULL.
300 \fBUSB_INVALID_CONTEXT\fR
303 Called from interrupt context.
317 The \fBusb_get_dev_data()\fR and \fBusb_print_descr_tree()\fR functions may be
318 called from user or kernel context.
321 The \fBusb_free_dev_data()\fR and \fBusb_free_descr_tree()\fR functions may be
322 called from user, kernel or interrupt context.
326 In this example, assume a device has the configuration shown
327 below, and the endpoint of config 2, iface 1, alt 1
328 which supports intr IN transfers needs to be found.
329 Config 2, iface 1 is the "default" config/iface for the
330 current OS device node.
350 usb_client_dev_data_t *dev_data;
351 usb_ep_descr_t ep_descr;
352 usb_ep_data_t *ep_tree_node;
353 uint8_t interface = 1;
354 uint8_t alternate = 1;
355 uint8_t first_ep_number = 0;
358 * We want default config/iface, so specify USB__PARSE_LVL_IF.
359 * Default config will be returned as dev_cfg[0].
361 if (usb_get_dev_data(dip, &dev_data,
362 USB_PARSE_LVL_IF, 0) != USB_SUCCESS) {
364 "%s%d: Couldn't get USB configuration descr tree",
365 ddi_driver_name(dip), ddi_get_instance(dip));
367 return (USB_FAILURE);
370 ep_tree_node = usb_lookup_ep_data(dip, dev_data, interface,
371 alternate, first_ep_number, USB_EP_ATTR_INTR, USB_EP_DIR_IN);
372 if (ep_tree_node != NULL) {
373 ep_descr = ep_tree_node->ep_descr;
376 "%s%d: Device is missing intr-IN endpoint",
377 ddi_driver_name(dip), ddi_get_instance(dip));
379 usb_free_descr_tree(dip, &dev_data);
381 return (USB_FAILURE);
389 See \fBattributes\fR(5) for descriptions of the following attributes:
397 ATTRIBUTE TYPE ATTRIBUTE VALUE
399 Architecture PCI-based systems
401 Interface stability Committed
406 \fBattributes\fR(5), \fBusb_client_attach\fR(9F), \fBusb_get_alt_if\fR(9F),
407 \fBusb_get_cfg\fR(9F), \fBusb_get_string_descr\fR(9F),
408 \fBusb_lookup_ep_data\fR(9F), \fBusb_parse_data\fR(9F),
409 \fBusb_pipe_xopen\fR(9F), \fBusb_cfg_descr\fR(9S),
410 \fBusb_client_dev_data(9S)\fR, \fBusb_ep_descr\fR(9S), \fBusb_if_descr\fR(9S),
411 \fBusb_string_descr\fR(9S)