'\" te .\" Copyright (c) 2004, 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] .TH usb_client_dev_data 9S "5 Jan 2004" "SunOS 5.11" "Data Structures for Drivers" .SH NAME usb_client_dev_data \- Device configuration information .SH SYNOPSIS .LP .nf #include .fi .SH INTERFACE LEVEL .sp .LP Solaris DDI specific (Solaris DDI) .SH DESCRIPTION .sp .LP The usb_client_dev_data_t structure carries all device configuration information. It is provided to a USB client driver through a call to \fBusb_get_dev_data\fR(9F). Most USBA functions require information which comes from this structure. .sp .LP The usb_client_dev_data_t structure fields are: .sp .in +2 .nf usb_pipe_handle_t dev_default_ph; /* deflt ctrl pipe handle */ ddi_iblock_cookie_t dev_iblock_cookie;/* for calls to mutex_init */ /* for mutexes used by intr */ /* context callbacks. */ usb_dev_descr_t *dev_descr; /* parsed* dev. descriptor */ char *dev_mfg; /* manufacturer's ID string */ char *dev_product; /* product ID string */ char *dev_serial; /* serial num. string */ usb_reg_parse_lvl_t dev_parse_level; /* Parse level */ /* reflecting the tree */ /* (if any) returned through */ /* the dev_cfg array. */ usb_cfg_data_t *dev_cfg; /* parsed* descr tree.*/ uint_t dev_n_cfg; /* num cfgs in parsed descr. */ /* tree, dev_cfg array below.*/ usb_cfg_data_t *dev_curr_cfg; /* Pointer to the tree config*/ /* corresponding to the cfg */ /* active at the time of the */ /* usb_get_dev_data() call */ int dev_curr_if; /* First active interface in */ /* tree under driver's control.*/ /* Always zero when driver */ /* controls whole device. */ * A parsed descriptor is in a struct whose fields' have been adjusted to the host processor. This may include endianness adjustment (the USB standard defines that devices report in little-endian bit order) or structure padding as necessary. .fi .in -2 .sp .LP dev_parse_level represents the extent of the device represented by the tree returned by the dev_cfg field and has the following possible values: .sp .ne 2 .mk .na \fBUSB_PARSE_LVL_NONE\fR .ad .RS 22n .rt Build no tree. dev_n_cfg returns 0, dev_cfg and dev_curr_cfg are returned NULL, the dev_curr_xxx fields are invalid. .RE .sp .ne 2 .mk .na \fBUSB_PARSE_LVL_IF\fR .ad .RS 22n .rt Parse configured interface only, if configuration# and interface properties are set (as when different interfaces are viewed by the OS as different device instances). If an OS device instance is set up to represent an entire physical device, this works like USB_PARSE_LVL_ALL. .RE .sp .ne 2 .mk .na \fBUSB_PARSE_LVL_CFG\fR .ad .RS 22n .rt Parse entire configuration of configured interface only. This is like USB_PARSE_LVL_IF except entire configuration is returned. .RE .sp .ne 2 .mk .na \fBUSB_PARSE_LVL_ALL\fR .ad .RS 22n .rt Parse entire device (all configurations), even when driver is bound to a single interface of a single configuration. .RE .sp .LP The default control pipe handle is used mainly for control commands and device setup. .sp .LP The dev_iblock_cookie is used to initialize client driver mutexes which are used in interrupt-context callback handlers. (All callback handlers called with USB_CB_INTR_CONTEXT in their usb_cb_flags_t arg execute in interrupt context.) This cookie is used in lieu of one returned by \fBddi_get_iblock_cookie\fR(9F). Mutexes used in other handlers or under other conditions should initialize per \fBmutex_init\fR(9F). .sp .LP The parsed standard USB device descriptor is used for device type identification. .sp .LP The several ID strings, including the manufacturer's ID, product ID, and serial number may be used to identify the device in messages or to compare it to other devices. .sp .LP The descriptor tree, returned by dev_cfg, makes a device's parsed standard USB descriptors available to the driver. The tree is designed to be easily traversed to get any or all standard \fIUSB 2.0\fR descriptors. (See the "Tree Structure" section of this manpage below.) dev_n_cfg returns the number of configurations in the tree. Note that this value may differ from the number of configurations returned in the device descriptor. .sp .LP A returned parse_level field of USB_PARSE_LVL_ALL indicates that all configurations are represented in the tree. This results when USB_PARSE_LVL_ALL is explicitly requested by the caller in the flags argument to \fBusb_get_dev_data()\fR, or when the whole device is seen by the system for the current OS device node (as opposed to only a single configuration for that OS device node). USB_PARSE_LVL_CFG is returned when one entire configuration is returned in the tree. USB_PARSE_LVL_IF is returned when one interface of one configuration is returned in the tree. In the latter two cases, the returned configuration is at dev_cfg[USB_DEV_DEFAULT_CONFIG_INDEX]. USB_PARSE_LVL_NONE is returned when no tree is returned. Note that the value of this field can differ from the parse_level requested as an argument to \fBusb_get_dev_data()\fR. .SS "TREE STRUCTURE" .sp .LP The root of the tree is dev_cfg, an array of usb_cfg_data_t configuration nodes, each representing one device configuration. The array index does not correspond to a configuration's value; use the bConfigurationValue field of the configuration descriptor within to find out the proper number for a given configuration. .sp .LP The size of the array is returned in dev_n_cfg. The array itself is not NULL terminated. .sp .LP When USB_PARSE_LVL_ALL is returned in dev_parse_level, index 0 pertains to the first valid configuration. This pertains to device configuration 1 as USB configuration 0 is not defined. When dev_parse_level returns USB_PARSE_LVL_CFG or USB_PARSE_LVL_IF, index 0 pertains to the device's one configuration recognized by the system. (Note that the configuration level is the only descriptor level in the tree where the index value does not correspond to the descriptor's value.) .sp .LP Each usb_cfg_data_t configuration node contains a parsed usb configuration descriptor (usb_cfg_descr_t cfg_descr) a pointer to its string description (char *cfg_str) and string size (cfg_strsize), a pointer to an array of interface nodes (usb_if_data_t *cfg_if), and a pointer to an array of class/vendor (cv) descriptor nodes (usb_cvs_data_t *cfg_cvs). The interface node array size is kept in cfg_n_if, and the cv node array size is kept in cfg_n_cvs; neither array is NULL terminated. When USB_PARSE_LVL_IF is returned in dev_parse_level, the only interface (or alternate group) included in the tree is that which is recognized by the system for the current OS device node. .sp .LP Each interface can present itself potentially in one of several alternate ways. An alternate tree node (usb_alt_if_data_t) represents an alternate representation. Each usb_if_data_t interface node points to an array of alternate nodes (usb_alt_if_data_t *if_alt) and contains the size of the array (if_n_alt). .sp .LP Each interface alternate node holds an interface descriptor (usb_if_descr_t altif_descr), a pointer to its string description (char *altif_str), and has its own set of endpoints and bound cv descriptors. The pointer to the array of endpoints is usb_ep_data_t *altif_ep); the endpoint array size is altif_n_ep. The pointer to the array of cv descriptors is usb_cvs_data_t *altif_cvs; the cv descriptor array size is altif_n_cvs. .sp .LP Each endpoint node holds an endpoint descriptor (usb_ep_descr_t ep_descr), a pointer to an array of cv descriptors for that endpoint (usb_cvs_data_t *ep_cvs), and the size of that array (ep_n_cvs). An endpoint descriptor may be passed to \fBusb_pipe_open\fR(9F) to establish a logical connection for data transfer. .sp .LP Class and vendor descriptors (cv descriptors) are grouped with the configuration, interface or endpoint descriptors they immediately follow in the raw data returned by the device. Tree nodes representing such descriptors (usb_cvs_data_t) contain a pointer to the raw data (uchar_t *cvs_buf) and the size of the data (uint_t cvs_buf_len). .sp .LP Configuration and interface alternate nodes return string descriptions. Note that all string descriptions returned have a maximum length of USB_MAXSTRINGLEN bytes and are in English ASCII. .SH EXAMPLES .sp .LP In the following example, a device's configuration data, including the following descriptor tree, is retrieved by \fBusb_get_dev_data\fR(9F) into usb_client_dev_data_t *reg_data: .sp .in +2 .nf config 1 iface 0 alt 0 endpt 0 config 2 iface 0 iface 1 alt 0 endpt 0 cv 0 alt 1 endpt 0 endpt 1 cv 0 endpt 2 alt 2 endpt 0 cv 0 and suppose that the C/V data is of the following format: typedef struct cv_data { char char1; short short1; char char2; } cv_data_t; Parse the data of C/V descriptor 0, second configuration (index 1), iface 1, alt 2, endpt 0. usb_client_dev_data_t reg_data; usb_cvs_data_t *cv_node; cv_data_t parsed_data; cv_node = ®_data->dev_cfg[1].cfg_if[1].if_alt[2].altif_ep[0].ep_cvs[0]; (void)usb_parse_data("csc", (void *)(&cv_node->cvs_buf), cv_node->cvs_buf_len, &parsed_data, sizeof(cv_data_t)); .fi .in -2 .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ ArchitecturePCI-based systems _ Interface stabilityCommitted .TE .SH SEE ALSO .sp .LP \fBusb_get_alt_if\fR(9F), \fBusb_get_cfg\fR(9F), \fBusb_get_dev_data\fR(9F), \fBusb_get_string_descr\fR(9F), \fBusb_lookup_ep_data\fR(9F), \fBusb_parse_data\fR(9F), \fBusb_pipe_open\fR(9F), \fBusb_cfg_descr\fR(9S), \fBusb_if_descr\fR(9S), \fBusb_ep_descr\fR(9S), \fBusb_string_descr\fR(9S)