Print this page
5832 EOF wireless usb (aka UWB)
Reviewed by: TBD
Reviewed by: TBD
Approved by: TBD
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/usb/usbai.h
+++ new/usr/src/uts/common/sys/usb/usbai.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 + *
25 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 26 */
25 27
26 28 #ifndef _SYS_USB_USBAI_H
27 29 #define _SYS_USB_USBAI_H
28 30
29 31
30 32 #ifdef __cplusplus
31 33 extern "C" {
32 34 #endif
33 35
34 36 /* This header file is for USBA2.0 */
35 37 #define USBA_MAJOR_VER 2
36 38 #define USBA_MINOR_VER 0
37 39
38 40 /*
39 41 * USBAI: Interfaces Between USBA and Client Driver
40 42 *
41 43 *
42 44 * Universal USB device state management :
43 45 *
44 46 * PWRED_DWN---<3----4>--ONLINE---<2-----1>-DISCONNECTED
45 47 * | ^ |
46 48 * | 6 |
47 49 * | | |
48 50 * | 5 |
49 51 * | v |
50 52 * +----5>----------SUSPENDED----<5----7>---+
51 53 *
52 54 * 1 = Device Unplug
53 55 * 2 = Original Device reconnected
54 56 * 3 = Device idles for time T & transitions to low power state
55 57 * 4 = Remote wakeup by device OR Application kicking off IO to device
56 58 * 5 = Notification to save state prior to DDI_SUSPEND
57 59 * 6 = Notification to restore state after DDI_RESUME with correct device
58 60 * 7 = Notification to restore state after DDI_RESUME with device
59 61 * disconnected or a wrong device
60 62 *
61 63 * NOTE: device states 0x80 to 0xff are device specific and can be
62 64 * used by client drivers
63 65 */
64 66 #define USB_DEV_ONLINE 1 /* device is online */
65 67 #define USB_DEV_DISCONNECTED 2 /* indicates disconnect */
66 68 #define USB_DEV_SUSPENDED 3 /* DDI_SUSPEND operation */
67 69 #define USB_DEV_PWRED_DOWN 4 /* indicates power off state */
68 70
69 71
70 72 /*
71 73 * ***************************************************************************
72 74 * USBA error and status definitions
73 75 * ***************************************************************************
74 76 */
75 77
76 78
77 79 /*
78 80 * USBA function return values
79 81 */
80 82 #define USB_SUCCESS 0 /* call success */
81 83 #define USB_FAILURE -1 /* unspecified USBA or HCD error */
82 84 #define USB_NO_RESOURCES -2 /* no resources available */
83 85 #define USB_NO_BANDWIDTH -3 /* no bandwidth available */
84 86 #define USB_NOT_SUPPORTED -4 /* function not supported by HCD */
85 87 #define USB_PIPE_ERROR -5 /* error occured on the pipe */
86 88 #define USB_INVALID_PIPE -6 /* pipe handle passed is invalid */
87 89 #define USB_NO_FRAME_NUMBER -7 /* frame No or ASAP not specified */
88 90 #define USB_INVALID_START_FRAME -8 /* starting USB frame not valid */
89 91 #define USB_HC_HARDWARE_ERROR -9 /* usb host controller error */
90 92 #define USB_INVALID_REQUEST -10 /* request had invalid values */
91 93 #define USB_INVALID_CONTEXT -11 /* sleep flag in interrupt context */
92 94 #define USB_INVALID_VERSION -12 /* invalid version specified */
93 95 #define USB_INVALID_ARGS -13 /* invalid func args specified */
94 96 #define USB_INVALID_PERM -14 /* privileged operation */
95 97 #define USB_BUSY -15 /* busy condition */
96 98
97 99
98 100 /*
99 101 * USB request completion flags, more than one may be set.
100 102 * The following flags are returned after a recovery action by
101 103 * HCD or USBA (autoclearing) or callbacks from pipe_close,
102 104 * abort, reset, or stop polling. More than one may be set.
103 105 *
104 106 * For sync requests, the client should check the request structure
105 107 * for this flag to determine what has happened.
106 108 *
107 109 * All callbacks are queued to preserve order. Note that if a normal callback
108 110 * uses a kernel thread, order is not guaranteed since each callback may use
109 111 * its own thread. The next request will be submitted to the
110 112 * HCD after the threads exits.
111 113 *
112 114 * Exception callbacks using a kernel thread may do auto clearing and no
113 115 * new request will be started until this thread has completed its work.
114 116 */
115 117 typedef enum {
116 118 USB_CB_NO_INFO = 0x00, /* no exception */
117 119 USB_CB_STALL_CLEARED = 0x01, /* func stall cleared */
118 120 USB_CB_FUNCTIONAL_STALL = 0x02, /* func stall occurred */
119 121 USB_CB_PROTOCOL_STALL = 0x04, /* protocal stall occurred */
120 122 USB_CB_RESET_PIPE = 0x10, /* pipe was reset */
121 123 USB_CB_ASYNC_REQ_FAILED = 0x80, /* thread couldn't be started */
122 124 USB_CB_NO_RESOURCES = 0x100, /* no resources */
123 125 USB_CB_SUBMIT_FAILED = 0x200, /* req was queued then submitted */
124 126 /* to HCD which rejected it */
125 127 USB_CB_INTR_CONTEXT = 0x400 /* Callback is in interrupt context. */
126 128 } usb_cb_flags_t;
127 129
128 130
129 131 /*
130 132 * completion reason
131 133 *
132 134 * Set by HCD; only one can be set.
133 135 */
134 136 typedef enum {
135 137 USB_CR_OK = 0, /* no errors detected */
136 138 USB_CR_CRC = 1, /* crc error detected */
137 139 USB_CR_BITSTUFFING = 2, /* bit stuffing violation */
138 140 USB_CR_DATA_TOGGLE_MM = 3, /* d/t PID did not match */
139 141 USB_CR_STALL = 4, /* e/p returned stall PID */
140 142 USB_CR_DEV_NOT_RESP = 5, /* device not responding */
141 143 USB_CR_PID_CHECKFAILURE = 6, /* check bits on PID failed */
142 144 USB_CR_UNEXP_PID = 7, /* receive PID was not valid */
143 145 USB_CR_DATA_OVERRUN = 8, /* data size exceeded */
144 146 USB_CR_DATA_UNDERRUN = 9, /* less data received */
145 147 USB_CR_BUFFER_OVERRUN = 10, /* memory write can't keep up */
146 148 USB_CR_BUFFER_UNDERRUN = 11, /* buffer underrun */
147 149 USB_CR_TIMEOUT = 12, /* command timed out */
148 150 USB_CR_NOT_ACCESSED = 13, /* Not accessed by hardware */
149 151 USB_CR_NO_RESOURCES = 14, /* no resources */
150 152 USB_CR_UNSPECIFIED_ERR = 15, /* unspecified usba or hcd err */
151 153 USB_CR_STOPPED_POLLING = 16, /* intr/isoc IN polling stopped */
152 154 USB_CR_PIPE_CLOSING = 17, /* intr/isoc IN pipe closed */
153 155 USB_CR_PIPE_RESET = 18, /* intr/isoc IN pipe reset */
154 156 USB_CR_NOT_SUPPORTED = 19, /* command not supported */
155 157 USB_CR_FLUSHED = 20, /* this request was flushed */
156 158 USB_CR_HC_HARDWARE_ERR = 21 /* usb host controller error */
157 159 } usb_cr_t;
158 160
159 161
160 162 /*
161 163 * ***************************************************************************
162 164 * General definitions, used all over
163 165 * ***************************************************************************
164 166 *
165 167 * A pipe handle is returned by usb_pipe_open() on success for
166 168 * all pipes except the default pipe which is accessed from
167 169 * the registration structure. Placed here as forward referenced by
168 170 * usb_client_dev_data_t below.
169 171 *
170 172 * The pipe_handle is opaque to the client driver.
171 173 */
172 174 typedef struct usb_pipe_handle *usb_pipe_handle_t;
173 175
174 176 /*
175 177 * General opaque pointer.
176 178 */
177 179 typedef struct usb_opaque *usb_opaque_t;
178 180
179 181
180 182 /*
181 183 * USB flags argument to USBA interfaces
182 184 */
183 185 typedef enum {
184 186 /* do not block until resources are available */
185 187 USB_FLAGS_NOSLEEP = 0x0000,
186 188 /* block until resources are available */
187 189 USB_FLAGS_SLEEP = 0x0100,
188 190 /* reserved */
189 191 USB_FLAGS_RESERVED = 0xFE00
190 192 } usb_flags_t;
191 193
192 194
193 195 /*
194 196 * ***************************************************************************
195 197 * Descriptor definitions (from USB 2.0 specification, chapter 9)
196 198 * ***************************************************************************
197 199 */
198 200
199 201
200 202 /*
201 203 * USB Descriptor Management
202 204 *
203 205 * Standard USB descriptors:
204 206 *
205 207 * USB devices present their configuration information in response to
206 208 * a GET_DESCRIPTOR request in a form which is little-endian and,
207 209 * for multibyte integers, unaligned. It is also position-dependent,
208 210 * which makes non-sequential access to particular interface or
209 211 * endpoint data inconvenient.
210 212 * A GET_DESCRIPTOR request may yield a chunk of data that contains
211 213 * multiple descriptor types. For example, a GET_DESCRIPTOR request
212 214 * for a CONFIGURATION descriptor could return the configuration
213 215 * descriptor followed by an interface descriptor and the relevant
214 216 * endpoint descriptors.
215 217 *
216 218 * usb_get_dev_data() interface provides an easy way to get all
217 219 * the descriptors and avoids parsing standard descriptors by each
218 220 * client driver
219 221 *
220 222 * usb_dev_descr:
221 223 * usb device descriptor, refer to USB 2.0/9.6.1,
222 224 */
223 225 typedef struct usb_dev_descr {
224 226 uint8_t bLength; /* descriptor size */
225 227 uint8_t bDescriptorType; /* set to DEVICE */
226 228 uint16_t bcdUSB; /* USB spec rel. number in bcd */
227 229 uint8_t bDeviceClass; /* class code */
228 230 uint8_t bDeviceSubClass; /* sub class code */
229 231 uint8_t bDeviceProtocol; /* protocol code */
230 232 uint8_t bMaxPacketSize0; /* max pkt size of e/p 0 */
231 233 uint16_t idVendor; /* vendor ID */
232 234 uint16_t idProduct; /* product ID */
233 235 uint16_t bcdDevice; /* device release number in bcd */
234 236 uint8_t iManufacturer; /* manufacturing string */
235 237 uint8_t iProduct; /* product string */
236 238 uint8_t iSerialNumber; /* serial number string index */
237 239 uint8_t bNumConfigurations; /* #configs for device */
238 240 } usb_dev_descr_t;
239 241
240 242
241 243 /*
242 244 * USB Device Qualifier Descriptor
243 245 *
244 246 * The device_qualifier descriptor describes information about a High
245 247 * speed capable device that would change if the device were operating
246 248 * at other (Full) speed. Example: if the device is currently operating
247 249 * at Full-speed, the device_qualifier returns information about how if
248 250 * would operate at high-speed and vice-versa.
249 251 *
250 252 * usb_dev_qlf_descr:
251 253 *
252 254 * usb device qualifier descriptor, refer to USB 2.0/9.6.2
253 255 */
254 256 typedef struct usb_dev_qlf_descr {
255 257 uint8_t bLength; /* descriptor size */
256 258 uint8_t bDescriptorType; /* set to DEVICE */
257 259 uint16_t bcdUSB; /* USB spec rel. number in bcd */
258 260 uint8_t bDeviceClass; /* class code */
259 261 uint8_t bDeviceSubClass; /* sub class code */
260 262 uint8_t bDeviceProtocol; /* protocol code */
261 263 uint8_t bMaxPacketSize0; /* max pkt size of e/p 0 */
262 264 uint8_t bNumConfigurations; /* #configs for device */
263 265 uint8_t bReserved; /* reserved field */
264 266 } usb_dev_qlf_descr_t;
265 267
266 268
267 269 /*
268 270 * usb_cfg_descr:
269 271 * usb configuration descriptor, refer to USB 2.0/9.6.3
270 272 */
271 273 typedef struct usb_cfg_descr {
272 274 uint8_t bLength; /* descriptor size */
273 275 uint8_t bDescriptorType; /* set to CONFIGURATION */
274 276 uint16_t wTotalLength; /* total length of data returned */
275 277 uint8_t bNumInterfaces; /* # interfaces in config */
276 278 uint8_t bConfigurationValue; /* arg for SetConfiguration */
277 279 uint8_t iConfiguration; /* configuration string */
278 280 uint8_t bmAttributes; /* config characteristics */
279 281 uint8_t bMaxPower; /* max pwr consumption */
280 282 } usb_cfg_descr_t;
281 283
282 284 /*
283 285 * Default configuration index setting for devices with multiple
284 286 * configurations. Note the distinction between config index and config
285 287 * number
286 288 */
287 289 #define USB_DEV_DEFAULT_CONFIG_INDEX 0
288 290
289 291 /*
290 292 * bmAttribute values for Configuration Descriptor
291 293 */
292 294 #define USB_CFG_ATTR_SELFPWR 0x40
293 295 #define USB_CFG_ATTR_REMOTE_WAKEUP 0x20
294 296 #define USB_CFG_ATTR_BAT_PWR 0x10
295 297
296 298 /*
297 299 * USB Other Speed Configuration Descriptor
298 300 *
299 301 * The other_speed_configuration descriptor describes a configuration of
300 302 * a High speed capable device if it were operating at its other possible
301 303 * (Full) speed and vice-versa.
302 304 *
303 305 * usb_other_speed_cfg_descr:
304 306 * usb other speed configuration descriptor, refer to USB 2.0/9.6.4
305 307 */
306 308 typedef struct usb_other_speed_cfg_descr {
307 309 uint8_t bLength; /* descriptor size */
308 310 uint8_t bDescriptorType; /* set to CONFIGURATION */
309 311 uint16_t wTotalLength; /* total length of data returned */
310 312 uint8_t bNumInterfaces; /* # interfaces in config */
311 313 uint8_t bConfigurationValue; /* arg for SetConfiguration */
312 314 uint8_t iConfiguration; /* configuration string */
313 315 uint8_t bmAttributes; /* config characteristics */
314 316 uint8_t bMaxPower; /* max pwr consumption */
315 317 } usb_other_speed_cfg_descr_t;
316 318
317 319
318 320 /*
319 321 * usb_ia_descr:
320 322 * usb interface association descriptor, refer to USB 2.0 ECN(IAD)
321 323 */
322 324 typedef struct usb_ia_descr {
323 325 uint8_t bLength; /* descriptor size */
324 326 uint8_t bDescriptorType; /* INTERFACE_ASSOCIATION */
325 327 uint8_t bFirstInterface; /* 1st interface number */
326 328 uint8_t bInterfaceCount; /* number of interfaces */
327 329 uint8_t bFunctionClass; /* class code */
328 330 uint8_t bFunctionSubClass; /* sub class code */
329 331 uint8_t bFunctionProtocol; /* protocol code */
330 332 uint8_t iFunction; /* description string */
331 333 } usb_ia_descr_t;
332 334
333 335
334 336 /*
335 337 * usb_if_descr:
336 338 * usb interface descriptor, refer to USB 2.0/9.6.5
337 339 */
338 340 typedef struct usb_if_descr {
339 341 uint8_t bLength; /* descriptor size */
340 342 uint8_t bDescriptorType; /* set to INTERFACE */
341 343 uint8_t bInterfaceNumber; /* interface number */
342 344 uint8_t bAlternateSetting; /* alt. interface number */
343 345 uint8_t bNumEndpoints; /* # of endpoints */
344 346 uint8_t bInterfaceClass; /* class code */
345 347 uint8_t bInterfaceSubClass; /* sub class code */
346 348 uint8_t bInterfaceProtocol; /* protocol code */
347 349 uint8_t iInterface; /* description string */
348 350 } usb_if_descr_t;
349 351
350 352
351 353 /*
352 354 * usb_ep_descr:
353 355 * usb endpoint descriptor, refer to USB 2.0/9.6.6
354 356 */
355 357 typedef struct usb_ep_descr {
356 358 uint8_t bLength; /* descriptor size */
357 359 uint8_t bDescriptorType; /* set to ENDPOINT */
358 360 uint8_t bEndpointAddress; /* address of this e/p */
359 361 uint8_t bmAttributes; /* transfer type */
360 362 uint16_t wMaxPacketSize; /* maximum packet size */
361 363 uint8_t bInterval; /* e/p polling interval */
362 364 } usb_ep_descr_t;
363 365
364 366 /*
365 367 * bEndpointAddress masks
366 368 */
367 369 #define USB_EP_NUM_MASK 0x0F /* endpoint number mask */
368 370 #define USB_EP_DIR_MASK 0x80 /* direction mask */
369 371 #define USB_EP_DIR_OUT 0x00 /* OUT endpoint */
370 372 #define USB_EP_DIR_IN 0x80 /* IN endpoint */
371 373
372 374 /*
373 375 * bmAttribute transfer types for endpoints
374 376 */
375 377 #define USB_EP_ATTR_MASK 0x03 /* transfer type mask */
376 378 #define USB_EP_ATTR_CONTROL 0x00 /* control transfer */
377 379 #define USB_EP_ATTR_ISOCH 0x01 /* isochronous transfer */
378 380 #define USB_EP_ATTR_BULK 0x02 /* bulk transfer */
379 381 #define USB_EP_ATTR_INTR 0x03 /* interrupt transfer */
380 382
381 383 /*
382 384 * bmAttribute synchronization types for endpoints (isochronous only)
383 385 */
384 386 #define USB_EP_SYNC_MASK 0x0C /* synchronization mask */
385 387 #define USB_EP_SYNC_NONE 0x00 /* no synchronization */
386 388 #define USB_EP_SYNC_ASYNC 0x04 /* asynchronous */
387 389 #define USB_EP_SYNC_ADPT 0x08 /* adaptive */
388 390 #define USB_EP_SYNC_SYNC 0x0C /* synchronous */
389 391
390 392 /*
391 393 * bmAttribute synchronization feedback types for endpoints (isochronous only)
392 394 */
393 395 #define USB_EP_USAGE_MASK 0x30 /* sync feedback mask */
394 396 #define USB_EP_USAGE_DATA 0x00 /* data endpoint */
395 397 #define USB_EP_USAGE_FEED 0x10 /* feedback endpoint */
396 398 #define USB_EP_USAGE_IMPL 0x20 /* implicit feedback endpoint */
397 399
398 400 /*
399 401 * wMaxPacketSize values for endpoints (isoch and interrupt, high speed only)
400 402 */
401 403 #define USB_EP_MAX_PKTSZ_MASK 0x03FF /* Mask for packetsize bits */
402 404 #define USB_EP_MAX_XACTS_MASK 0x0C00 /* Max Transactns/microframe */
403 405 #define USB_EP_MAX_XACTS_SHIFT 10 /* Above is 10 bits from end */
404 406
405 407 /*
406 408 * Ranges for endpoint parameter values.
407 409 */
408 410
409 411 /* Min and Max NAK rates for high sped control endpoints. */
410 412 #define USB_EP_MIN_HIGH_CONTROL_INTRVL 0
411 413 #define USB_EP_MAX_HIGH_CONTROL_INTRVL 255
412 414
413 415 /* Min and Max NAK rates for high speed bulk endpoints. */
414 416 #define USB_EP_MIN_HIGH_BULK_INTRVL 0
415 417 #define USB_EP_MAX_HIGH_BULK_INTRVL 255
416 418
417 419 /* Min and Max polling intervals for low, full speed interrupt endpoints. */
418 420 #define USB_EP_MIN_LOW_INTR_INTRVL 1
419 421 #define USB_EP_MAX_LOW_INTR_INTRVL 255
420 422 #define USB_EP_MIN_FULL_INTR_INTRVL 1
421 423 #define USB_EP_MAX_FULL_INTR_INTRVL 255
422 424
423 425 /*
424 426 * Min and Max polling intervals for high speed interrupt endpoints, and for
425 427 * isochronous endpoints.
426 428 * Note that the interval is 2**(value-1). See Section 9.6.6 of USB 2.0 spec.
427 429 */
428 430 #define USB_EP_MIN_HIGH_INTR_INTRVL 1
429 431 #define USB_EP_MAX_HIGH_INTR_INTRVL 16
430 432 #define USB_EP_MIN_FULL_ISOCH_INTRVL 1
431 433 #define USB_EP_MAX_FULL_ISOCH_INTRVL 16
432 434 #define USB_EP_MIN_HIGH_ISOCH_INTRVL 1
433 435 #define USB_EP_MAX_HIGH_ISOCH_INTRVL 16
434 436
435 437 /*
436 438 * usb_string_descr:
437 439 * usb string descriptor, refer to USB 2.0/9.6.7
↓ open down ↓ |
404 lines elided |
↑ open up ↑ |
438 440 */
439 441 typedef struct usb_string_descr {
440 442 uint8_t bLength; /* descr size */
441 443 uint8_t bDescriptorType; /* set to STRING */
442 444 uint8_t bString[1]; /* variable length unicode */
443 445 /* encoded string */
444 446 } usb_string_descr_t;
445 447
446 448 #define USB_MAXSTRINGLEN 255 /* max string descr length */
447 449
448 -
449 450 /*
450 - * usb_bos_descr:
451 - * usb BOS descriptor, refer to WUSB 1.0/7.4.1
452 - */
453 -typedef struct usb_bos_descr {
454 - uint8_t bLength;
455 - uint8_t bDescriptorType;
456 - uint16_t wTotalLength;
457 - uint8_t bNumDeviceCaps;
458 -} usb_bos_descr_t;
459 -
460 -/*
461 - * usb_dev_cap_header:
462 - * usb device capability descriptor header, refer to WUSB 1.0/7.4.1
463 - */
464 -typedef struct usb_cap_descr_header {
465 - uint8_t bLength;
466 - uint8_t bDescriptorType;
467 - uint8_t bDevCapabilityType;
468 -} usb_cap_descr_header_t;
469 -
470 -typedef struct usb_cap_descr {
471 - uint8_t bLength;
472 - uint8_t bDescriptorType; /* set to DEVICE CAPABILITY */
473 - uint8_t bDevCapabilityType;
474 - uint8_t bCapValue[1]; /* variable length data */
475 -} usb_cap_descr_t;
476 -
477 -#define USB_CAP_TYPE_WUSB 1
478 -
479 -/* Wireless USB device capability descriptor - UWB descriptor */
480 -typedef struct usb_uwb_cap_descr {
481 - uint8_t bLength;
482 - uint8_t bDescriptorType;
483 - uint8_t bDevCapabilityType;
484 - uint8_t bmAttributes;
485 - uint16_t wPHYRates;
486 - uint8_t bmTFITXPowerInfo;
487 - uint8_t bmFFITXPowerInfo;
488 - uint16_t bmBandGroup;
489 - uint8_t bReserved;
490 -} usb_uwb_cap_descr_t;
491 -
492 -/*
493 - * usb_ep_comp_descr:
494 - * usb endpoint companion descriptor, refer to WUSB 1.0/7.4.4
495 - */
496 -typedef struct usb_ep_comp_descr {
497 - uint8_t bLength;
498 - uint8_t bDescriptorType;
499 - uint8_t bMaxBurst;
500 - uint8_t bMaxSequence;
501 - uint16_t wMaxStreamDelay;
502 - uint16_t wOverTheAirPacketSize;
503 - uint8_t bOverTheAirInterval;
504 - uint8_t bmCompAttributes;
505 -} usb_ep_comp_descr_t;
506 -
507 -/*
508 - * usb_security_descr:
509 - * usb security descriptor, refer to WUSB 1.0/7.4.5
510 - */
511 -typedef struct usb_security_descr {
512 - uint8_t bLength;
513 - uint8_t bDescriptorType;
514 - uint16_t wTotalLength;
515 - uint8_t bNumEncryptionTypes;
516 -} usb_security_descr_t;
517 -
518 -/*
519 - * usb_encryption_descr:
520 - * usb encryption descriptor, refer to WUSB 1.0/7.4.5
521 - */
522 -typedef struct usb_encryption_descr {
523 - uint8_t bLength;
524 - uint8_t bDescriptorType;
525 - uint8_t bEncryptionType;
526 - uint8_t bEncryptionValue;
527 - uint8_t bAuthKeyIndex;
528 -} usb_encryption_descr_t;
529 -
530 -#define USB_ENC_TYPE_UNSECURE 0x00
531 -#define USB_ENC_TYPE_WIRED 0x01
532 -#define USB_ENC_TYPE_CCM_1 0x02
533 -#define USB_ENC_TYPE_RSA_1 0x03
534 -
535 -/*
536 - * usb_key_descr:
537 - * usb key descriptor, refer to WUSB 1.0/7.4.5
538 - */
539 -typedef struct usb_key_descr {
540 - uint8_t bLength;
541 - uint8_t bDescriptorType;
542 - uint8_t tTKID[3];
543 - uint8_t bReserved;
544 - uint8_t KeyData[1]; /* variable length */
545 -} usb_key_descr_t;
546 -
547 -#define USB_EP_COMP_DESCR_SIZE 10
548 -#define USB_BOS_DESCR_SIZE 5
549 -#define USB_CAP_DESCR_HEADER_SIZE 3
550 -#define USB_UWB_CAP_DESCR_SIZE 11
551 -#define USB_SECURITY_DESCR_SIZE 5
552 -#define USB_ENCRYPTION_DESCR_SIZE 5
553 -
554 -
555 -/*
556 451 * ***************************************************************************
557 452 * Client driver registration with USBA
558 453 * ***************************************************************************
559 454 *
560 455 * The client registers with USBA during attach in two steps
561 456 * using usb_client_attach() and usb_get_dev_data(). On completion, the
562 457 * registration data has been initialized. Most data items are
563 458 * straightforward. Among the items returned in the data is the tree of
564 459 * parsed descriptors, in dev_cfg; the number of configurations parsed,
565 460 * in dev_n_cfg; a pointer to the current configuration in the tree,
566 461 * in dev_curr_cfg; the index of the first valid interface in the
567 462 * tree, in dev_curr_if, and a parse level that accurately reflects what
568 463 * is in the tree, in dev_parse_level.
569 464 */
570 465
571 466
572 467 /*
573 468 * ***************************************************************************
574 469 * Data structures used in the configuration tree
575 470 * ***************************************************************************
576 471 */
577 472
578 473 /*
579 474 * Tree data structure for each configuration in the tree
580 475 */
581 476 typedef struct usb_cfg_data {
582 477 struct usb_cfg_descr cfg_descr; /* parsed config descr */
583 478 struct usb_if_data *cfg_if; /* interfaces for this cfg */
584 479 /* indexed by interface num */
585 480 struct usb_cvs_data *cfg_cvs; /* class/vendor specific */
586 481 /* descrs mod/extend cfg */
587 482 char *cfg_str; /* string descriptor */
588 483 uint_t cfg_n_if; /* #elements in cfg_if[] */
589 484 uint_t cfg_n_cvs; /* #elements in cfg_cvs[] */
590 485 uint_t cfg_strsize; /* size of string descr */
591 486 } usb_cfg_data_t;
592 487
593 488
594 489 /*
595 490 * Tree data structure for each alternate interface set
596 491 * in each represented configuration
597 492 */
598 493 typedef struct usb_if_data {
599 494 struct usb_alt_if_data *if_alt; /* sparse array of alts */
600 495 /* indexed by alt setting */
601 496 uint_t if_n_alt; /* #elements in if_alt[] */
602 497 } usb_if_data_t;
603 498
604 499
605 500 /*
606 501 * Tree data structure for each alternate of each alternate interface set
607 502 */
608 503 typedef struct usb_alt_if_data {
609 504 usb_if_descr_t altif_descr; /* parsed alternate if descr */
610 505 struct usb_ep_data *altif_ep; /* endpts for alt if */
611 506 /* (not a sparse array */
612 507 struct usb_cvs_data *altif_cvs; /* cvs for this alt if */
613 508 char *altif_str; /* string descriptor */
614 509 uint_t altif_n_ep; /* #elements in altif_ep[] */
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
615 510 uint_t altif_n_cvs; /* #elements in altif_cvs[] */
616 511 uint_t altif_strsize; /* size of string descr */
617 512 } usb_alt_if_data_t;
618 513
619 514
620 515 /*
621 516 * Tree data structure for each endpoint of each alternate
622 517 */
623 518 typedef struct usb_ep_data {
624 519 usb_ep_descr_t ep_descr; /* endpoint descriptor */
625 - usb_ep_comp_descr_t ep_comp_descr; /* endpoint companion descr */
626 520 struct usb_cvs_data *ep_cvs; /* cv mod/extending this ep */
627 521 uint_t ep_n_cvs; /* #elements in ep_cvs[] */
628 522 } usb_ep_data_t;
629 523
630 524
631 525 /*
632 526 * Tree data structure for each class/vendor specific descriptor
633 527 */
634 528 typedef struct usb_cvs_data {
635 529 uchar_t *cvs_buf; /* raw data of cvs descr */
636 530 uint_t cvs_buf_len; /* cvs_buf size */
637 531 } usb_cvs_data_t;
638 532
639 533
640 534 /*
641 - * Data structure for wireless USB specific descriptor
642 - */
643 -typedef struct usb_bos_data {
644 - usb_bos_descr_t bos_descr; /* parsed bos descr */
645 - usb_uwb_cap_descr_t bos_uwb_cap; /* uwb cap descr */
646 -} usb_bos_data_t;
647 -
648 -
649 -/*
650 535 * Parse_level determines the extent to which the tree is built, the amount
651 536 * of parsing usb_client_attach() is to do. It has the following values:
652 537 *
653 538 * USB_PARSE_LVL_NONE - Build no tree. dev_n_cfg will return 0, dev_cfg
654 539 * will return NULL, the dev_curr_xxx fields will be
655 540 * invalid.
656 541 * USB_PARSE_LVL_IF - Parse configured interface only, if configuration#
657 542 * and interface properties are set (as when different
658 543 * interfaces are viewed by the OS as different device
659 544 * instances). If an OS device instance is set up to
660 545 * represent an entire physical device, this works
661 546 * like USB_PARSE_LVL_ALL.
662 547 * USB_PARSE_LVL_CFG - Parse entire configuration of configured interface
663 548 * only. This is like USB_PARSE_LVL_IF except entire
664 549 * configuration is returned.
665 550 * USB_PARSE_LVL_ALL - Parse entire device (all configurations), even
666 551 * when driver is bound to a single interface of a
667 552 * single configuration.
668 553 */
669 554 typedef enum {
670 555 USB_PARSE_LVL_NONE = 0,
671 556 USB_PARSE_LVL_IF = 1,
672 557 USB_PARSE_LVL_CFG = 2,
673 558 USB_PARSE_LVL_ALL = 3
674 559 } usb_reg_parse_lvl_t;
675 560
676 561
677 562 /*
678 563 * Registration data returned by usb_get_dev_data(). Configuration tree roots
679 564 * are returned in dev_cfg array.
680 565 */
681 566 typedef struct usb_client_dev_data {
682 567 usb_pipe_handle_t dev_default_ph; /* default pipe handle */
683 568 ddi_iblock_cookie_t dev_iblock_cookie; /* for mutex_init's */
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
684 569 struct usb_dev_descr *dev_descr; /* cooked device descriptor */
685 570 char *dev_mfg; /* manufacturing ID */
686 571 char *dev_product; /* product ID */
687 572 char *dev_serial; /* serial number */
688 573 usb_reg_parse_lvl_t dev_parse_level; /* USB_PARSE_LVL_* flag */
689 574 struct usb_cfg_data *dev_cfg; /* configs for this device */
690 575 /* indexed by config index */
691 576 uint_t dev_n_cfg; /* #elements in dev_cfg[] */
692 577 struct usb_cfg_data *dev_curr_cfg; /* current cfg */
693 578 int dev_curr_if; /* current interface number */
694 - struct usb_bos_data *dev_bos; /* bos for this device */
695 579 } usb_client_dev_data_t;
696 580
697 581
698 582 /*
699 583 * ***************************************************************************
700 584 * Device configuration descriptor tree functions
701 585 * ***************************************************************************
702 586 */
703 587
704 588 /*
705 589 * usb_get_dev_data:
706 590 * returns initialized registration data. Most data items are clear.
707 591 * Among the items returned is the tree ofparsed descriptors in dev_cfg;
708 592 * and the number of configurations parsed in dev_n_cfg.
709 593 *
710 594 * Arguments:
711 595 * dip - pointer to devinfo node of the client
712 596 * dev_data - return registration data at this address
713 597 * parse_level - See above
714 598 * flags - None used
715 599 *
716 600 * Return Values:
717 601 * USB_SUCCESS - usb_register_client succeeded
718 602 * USB_INVALID_ARGS - received null dip or reg argument
719 603 * USB_INVALID_CONTEXT - called with sleep from callback context
720 604 * USB_FAILURE - bad descriptor info or other internal failure
721 605 *
722 606 * Notes:
723 607 * 1) The non-standard USB descriptors are returned in RAW format.
724 608 *
725 609 * 2) The registration data is unshared. Each client receives its own copy.
726 610 * (The default control pipe may be shared, even though its tree
727 611 * description will be unique per device.)
728 612 *
729 613 */
730 614 int usb_get_dev_data(
731 615 dev_info_t *dip,
732 616 usb_client_dev_data_t **dev_data,
733 617 usb_reg_parse_lvl_t parse_level,
734 618 usb_flags_t flags);
735 619
736 620 /*
737 621 * usb_free_dev_data:
738 622 * undoes what usb_get_dev_data() set up. It releases
739 623 * memory for all strings, descriptors, and trees set up by usb_get_dev_data().
740 624 *
741 625 * Arguments:
742 626 * dip - pointer to devinfo node of the client
743 627 * dev_data - pointer to registration data containing the tree.
744 628 */
745 629 void usb_free_dev_data(
746 630 dev_info_t *dip,
747 631 usb_client_dev_data_t *dev_data);
748 632
749 633 /*
750 634 * usb_free_descr_tree:
751 635 * Take down the configuration tree while leaving the rest of the
752 636 * registration intact. This can be used, for example, after attach has
753 637 * copied any descriptors it needs from the tree, but the rest of the
754 638 * registration data needs to remain intact.
755 639 *
756 640 * The following usb_client_dev_data_t fields will be modified:
757 641 * dev_cfg will be NULL
758 642 * dev_n_cfg will be 0
759 643 * dev_curr_cfg_ndx and dev_curr_if will be invalid
760 644 * dev_parse_level will be USB_REG_DESCR_NONE
761 645 *
762 646 * Arguments:
763 647 * dip - pointer to devinfo node of the client
764 648 * dev_data - pointer to registration data containing the tree.
765 649 */
766 650 void usb_free_descr_tree(
767 651 dev_info_t *dip,
768 652 usb_client_dev_data_t *dev_data);
769 653
770 654
771 655 /*
772 656 * usb_print_descr_tree:
773 657 * Dump to the screen a descriptor tree as returned by
774 658 * usbai_register_client.
775 659 *
776 660 * Arguments:
777 661 * dip - pointer to devinfo of the client
778 662 * dev_data - pointer to registration area containing the tree
779 663 *
780 664 * Returns:
781 665 * USB_SUCCESS - tree successfully dumped
782 666 * USB_INVALID_CONTEXT - called from callback context
783 667 * USB_INVALID_ARGS - bad arguments given
784 668 */
785 669 int usb_print_descr_tree(
786 670 dev_info_t *dip,
787 671 usb_client_dev_data_t *dev_data);
788 672
789 673
790 674 /*
791 675 * ***************************************************************************
792 676 * Registration and versioning
793 677 * ***************************************************************************
794 678 */
795 679
796 680
797 681 /*
798 682 * USBA client drivers are required to define USBDRV_MAJOR_VER
799 683 * USBDRV_MINOR_VER and pass USBDRV_VERSION as the version
800 684 * number to usb_client_attach
801 685 */
802 686 #if !defined(USBA_MAJOR_VER) || !defined(USBA_MINOR_VER)
803 687 #error incorrect USBA header
804 688 #endif
805 689
806 690 /*
807 691 * Driver major version must be the same as USBA major version, and
808 692 * driver minor version must be <= USBA minor version
809 693 */
810 694 #if !defined(USBA_FRAMEWORK)
811 695 #if defined(USBDRV_MAJOR_VER) && defined(USBDRV_MINOR_VER)
812 696
813 697 #if (USBDRV_MAJOR_VER != USBA_MAJOR_VER)
814 698 #error USBA and driver major versions do not match
815 699 #endif
816 700 #if (USBDRV_MINOR_VER > USBA_MINOR_VER)
817 701 #error USBA and driver minor versions do not match
818 702 #endif
819 703
820 704 #endif
821 705 #endif
822 706
823 707 #define USBA_MAKE_VER(major, minor) ((major) << 8 | (minor))
824 708 #define USBA_GET_MAJOR(ver) ((ver) >> 8)
825 709 #define USBA_GET_MINOR(ver) ((ver) & 0xff)
826 710
827 711 #define USBDRV_VERSION USBA_MAKE_VER(USBDRV_MAJOR_VER, USBDRV_MINOR_VER)
828 712
829 713
830 714 /*
831 715 * usb_client_attach:
832 716 *
833 717 * Arguments:
834 718 * dip - pointer to devinfo node of the client
835 719 * version - USBA registration version number
836 720 * flags - None used
837 721 *
838 722 * Return Values:
839 723 * USB_SUCCESS - attach succeeded
840 724 * USB_INVALID_ARGS - received null dip or reg argument
841 725 * USB_INVALID_CONTEXT - called with sleep from callback context
842 726 * or not at attach time
843 727 * USB_INVALID_VERSION - version argument is incorrect.
844 728 * USB_FAILURE - other internal failure
845 729 */
846 730 int usb_client_attach(
847 731 dev_info_t *dip,
848 732 uint_t version,
849 733 usb_flags_t flags);
850 734
851 735 /*
852 736 * usb_client_detach:
853 737 *
854 738 * Arguments:
855 739 * dip - pointer to devinfo node of the client
856 740 * dev_data - pointer to data to free. may be NULL
857 741 */
858 742 void usb_client_detach(
859 743 dev_info_t *dip,
860 744 struct usb_client_dev_data *dev_data);
861 745
862 746 /*
863 747 * ***************************************************************************
864 748 * Functions for parsing / retrieving data from the descriptor tree
865 749 * ***************************************************************************
866 750 */
867 751
868 752 /*
869 753 * Function for unpacking any kind of little endian data, usually desriptors
870 754 *
871 755 * Arguments:
872 756 * format - string indicating the format in c, s, w, eg. "2c4ws"
873 757 * which describes 2 bytes, 4 int, one short.
874 758 * The number prefix parses the number of items of
875 759 * the following type.
876 760 * data - pointer to the LE data buffer
877 761 * datalen - length of the data
878 762 * structure - pointer to return structure where the unpacked data
879 763 * will be written
880 764 * structlen - length of the return structure
881 765 *
882 766 * return value:
883 767 * total number of bytes of the original data that was unpacked
884 768 * or USB_PARSE_ERROR
885 769 */
886 770 #define USB_PARSE_ERROR 0
887 771
888 772 size_t usb_parse_data(
889 773 char *format,
890 774 uchar_t *data,
891 775 size_t datalen,
892 776 void *structure,
893 777 size_t structlen);
894 778
895 779 /*
896 780 * usb_lookup_ep_data:
897 781 * Function to get specific endpoint data
898 782 * This function will not access the device.
899 783 *
900 784 * Arguments:
901 785 * dip - pointer to dev info
902 786 * dev_datap - pointer to registration data
903 787 * interface - requested interface
904 788 * alternate - requested alternate
905 789 * skip - number of endpoints which match the requested type and
906 790 * direction to skip before finding one to retrieve
907 791 * type - endpoint type
908 792 * direction - endpoint direction: USB_EP_DIR_IN/OUT or none
909 793 *
910 794 * Return Values:
911 795 * NULL or an endpoint data pointer
912 796 */
913 797 usb_ep_data_t *usb_lookup_ep_data(
914 798 dev_info_t *dip,
915 799 usb_client_dev_data_t *dev_datap,
916 800 uint_t interface,
917 801 uint_t alternate,
918 802 uint_t skip,
919 803 uint_t type,
920 804 uint_t direction);
921 805
922 806
923 807 /* Language ID for string descriptors. */
924 808 #define USB_LANG_ID 0x0409 /* English, US */
925 809
926 810 /*
927 811 * usb_get_string_descr:
928 812 * Reads the string descriptor. This function access the device and
929 813 * blocks.
930 814 *
931 815 * Arguments:
932 816 * dip - pointer to devinfo of the client.
933 817 * langid - LANGID to read different LOCALEs.
934 818 * index - index to the string.
935 819 * buf - user provided buffer for string descriptor.
936 820 * buflen - user provided length of the buffer.
937 821 *
938 822 * Return Values:
939 823 * USB_SUCCESS - descriptor is valid.
940 824 * USB_FAILURE - full descriptor could not be retrieved.
941 825 */
942 826 int usb_get_string_descr(
943 827 dev_info_t *dip,
944 828 uint16_t langid,
945 829 uint8_t index,
946 830 char *buf,
947 831 size_t buflen);
948 832
949 833
950 834 /*
951 835 * ***************************************************************************
952 836 * Addressing utility functions
953 837 * ***************************************************************************
954 838 */
955 839
956 840 /*
957 841 * usb_get_addr returns the current usb address, mostly for debugging
958 842 * purposes. The address may change after hotremove/insert.
959 843 * This address will not change on a disconnect/reconnect of open device.
960 844 */
961 845 int usb_get_addr(dev_info_t *dip);
962 846
963 847
964 848 /*
965 849 * usb_get_if_number returns USB_COMBINED_NODE or USB_DEVICE_NODE
966 850 * if the driver is responsible for the entire device.
967 851 * Otherwise it returns the interface number.
968 852 */
969 853 #define USB_COMBINED_NODE -1
970 854 #define USB_DEVICE_NODE -2
971 855
972 856 int usb_get_if_number(
973 857 dev_info_t *dip);
974 858
975 859 boolean_t usb_owns_device(
976 860 dev_info_t *dip);
977 861
978 862
979 863 /*
980 864 * ***************************************************************************
981 865 * Pipe Management definitions and functions
982 866 * ***************************************************************************
983 867 */
984 868
985 869
986 870 /*
987 871 *
988 872 * usb_pipe_state:
989 873 *
990 874 * PIPE_STATE_IDLE:
991 875 * The pipe's policy is set, but the pipe currently isn't transferring
992 876 * data.
993 877 *
994 878 * PIPE_STATE_ACTIVE:
995 879 * The pipe's policy has been set, and the pipe is able to transmit data.
996 880 * When a control or bulk pipe is opened, the pipe's state is
997 881 * automatically set to PIPE_STATE_ACTIVE. For an interrupt or
998 882 * isochronous pipe, the pipe state becomes PIPE_STATE_ACTIVE once
999 883 * the polling on the pipe has been initiated.
1000 884 *
1001 885 * PIPE_STATE_ERROR:
1002 886 * The device has generated a error on the pipe. The client driver
1003 887 * must call usb_pipe_reset() to clear any leftover state that's associated
1004 888 * with the pipe, clear the data toggle, and reset the state of the pipe.
1005 889 *
1006 890 * Calling usb_pipe_reset() on a control or bulk pipe resets the state to
1007 891 * PIPE_STATE_ACTIVE. Calling usb_pipe_reset() on an interrupt or
1008 892 * isochronous pipe, resets the state to PIPE_STATE_IDLE.
1009 893 *
1010 894 * State Diagram for Bulk/Control
1011 895 *
1012 896 * +-<--normal completion------------------<-------^
1013 897 * | |
1014 898 * V |
1015 899 * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE]
1016 900 * ^ |
1017 901 * | v
1018 902 * - usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error
1019 903 *
1020 904 * State Diagram for Interrupt/Isochronous IN
1021 905 *
1022 906 * +-<--usb_pipe_stop_isoc/intr_polling----<-------^
1023 907 * | |
1024 908 * V |
1025 909 * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE]
1026 910 * ^ |
1027 911 * | v
1028 912 * + usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error
1029 913 *
1030 914 * State Diagram for Interrupt/Isochronous OUT
1031 915 *
1032 916 * +-<--normal completion------------------<-------^
1033 917 * | |
1034 918 * V |
1035 919 * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE]
1036 920 * ^ |
1037 921 * | v
1038 922 * + usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error
1039 923 *
1040 924 *
1041 925 * The following table indicates which operations are allowed with each
1042 926 * pipe state:
1043 927 *
1044 928 * -------------------------------------------------------------------------+
1045 929 * ctrl/bulk | idle | active | error | sync closing | async closing|
1046 930 * -------------------------------------------------------------------------+
1047 931 * pipe xfer | OK |queue (USBA)| reject | reject | reject |
1048 932 * pipe reset | no-op | OK | OK | reject | reject |
1049 933 * pipe close | OK | wait&close | OK | no-op | no-op |
1050 934 * -------------------------------------------------------------------------+
1051 935 *
1052 936 * -------------------------------------------------------------------------+
1053 937 * intr/isoc IN | idle | active | error | sync closing | async closing|
1054 938 * -------------------------------------------------------------------------+
1055 939 * pipe xfer | OK | reject | reject | reject | reject |
1056 940 * pipe stoppoll| no-op | OK | no-op | reject | reject |
1057 941 * pipe reset | no-op | OK | OK | reject | reject |
1058 942 * pipe close | OK | wait&close | OK | no-op | no-op |
1059 943 * -------------------------------------------------------------------------+
1060 944 *
1061 945 * -------------------------------------------------------------------------+
1062 946 * intr/isoc OUT| idle | active | error | sync closing | async closing|
1063 947 * -------------------------------------------------------------------------+
1064 948 * pipe xfer | OK |queue (HCD) | reject | reject | reject |
1065 949 * pipe stoppoll| reject| reject | reject | reject | reject |
1066 950 * pipe reset | no-op | OK | OK | reject | reject |
1067 951 * pipe close | OK | wait&close | OK | no-op | no-op |
1068 952 * -------------------------------------------------------------------------+
1069 953 */
1070 954 typedef enum {
1071 955 USB_PIPE_STATE_CLOSED = 0,
1072 956 USB_PIPE_STATE_IDLE = 1,
1073 957 USB_PIPE_STATE_ACTIVE = 2,
1074 958 USB_PIPE_STATE_ERROR = 3,
1075 959 USB_PIPE_STATE_CLOSING = 4
1076 960 } usb_pipe_state_t;
1077 961
1078 962
1079 963 /*
1080 964 * pipe state control:
1081 965 *
1082 966 * return values:
1083 967 * USB_SUCCESS - success
1084 968 * USB_FAILURE - unspecified failure
1085 969 */
1086 970 int usb_pipe_get_state(
1087 971 usb_pipe_handle_t pipe_handle,
1088 972 usb_pipe_state_t *pipe_state,
1089 973 usb_flags_t flags);
1090 974
1091 975
1092 976 /*
1093 977 * usb_pipe_policy
1094 978 *
1095 979 * Pipe policy specifies how a pipe to an endpoint should be used
1096 980 * by the client driver and the HCD.
1097 981 */
1098 982 typedef struct usb_pipe_policy {
1099 983 /*
1100 984 * This is a hint indicating how many asynchronous operations
1101 985 * requiring a kernel thread will be concurrently active.
1102 986 * Allow at least one for synch exception callback handling
1103 987 * and another for asynchronous closing of pipes.
1104 988 */
1105 989 uchar_t pp_max_async_reqs;
1106 990 } usb_pipe_policy_t;
1107 991
1108 992
1109 993 /*
1110 994 * usb_pipe_open():
1111 995 *
1112 996 * Before using any pipe including the default pipe, it must be opened.
1113 997 * On success, a pipe handle is returned for use in other usb_pipe_*()
1114 998 * functions.
1115 999 *
1116 1000 * The default pipe can only be opened by the hub driver.
1117 1001 *
1118 1002 * For isochronous and interrupt pipes, bandwidth has been allocated and
1119 1003 * guaranteed.
1120 1004 *
1121 1005 * Only the default pipe can be shared. All other control pipes are
1122 1006 * excusively opened by default. A pipe policy and endpoint descriptor
1123 1007 * must always be provided except for default pipe.
1124 1008 *
1125 1009 * Arguments:
1126 1010 * dip - devinfo ptr.
1127 1011 * ep - endpoint descriptor pointer.
1128 1012 * pipe_policy - pointer to pipe policy which provides hints on how
1129 1013 * the pipe will be used.
1130 1014 * flags - USB_FLAGS_SLEEP wait for resources to become
1131 1015 * available.
1132 1016 * pipe_handle - a pipe handle pointer. on a successful open,
1133 1017 * a pipe_handle is returned in this pointer.
1134 1018 *
1135 1019 * Return values:
1136 1020 * USB_SUCCESS - open succeeded.
1137 1021 * USB_FAILURE - unspecified open failure or pipe is already open.
1138 1022 * USB_NO_RESOURCES - no resources were available to complete the open.
1139 1023 * USB_NO_BANDWIDTH - no bandwidth available (isoc/intr pipes).
1140 1024 * USB_* - refer to list of all possible return values in
1141 1025 * this file
1142 1026 */
1143 1027 int usb_pipe_open(
1144 1028 dev_info_t *dip,
1145 1029 usb_ep_descr_t *ep,
1146 1030 usb_pipe_policy_t *pipe_policy,
1147 1031 usb_flags_t flags,
1148 1032 usb_pipe_handle_t *pipe_handle);
1149 1033
1150 1034
1151 1035 /*
1152 1036 * usb_pipe_close():
1153 1037 *
1154 1038 * Closes the pipe, releases resources and frees the pipe_handle.
1155 1039 * Automatic polling, if active, will be terminated.
1156 1040 *
1157 1041 * Arguments:
1158 1042 * dip - devinfo ptr.
1159 1043 * pipe_handle - pipe handle.
1160 1044 * flags - USB_FLAGS_SLEEP:
1161 1045 * wait for resources, pipe
1162 1046 * to become free, and all callbacks completed.
1163 1047 * cb - If USB_FLAGS_SLEEP has not been specified, a
1164 1048 * callback will be performed.
1165 1049 * cb_arg - the 2nd argument of the callback. Note that the
1166 1050 * pipehandle will be zeroed and therefore not passed.
1167 1051 *
1168 1052 * Notes:
1169 1053 *
1170 1054 * Pipe close always succeeds regardless whether USB_FLAGS_SLEEP has been
1171 1055 * specified or not. An async close will always succeed if the hint in the
1172 1056 * pipe policy has been correct about the max number of async requests
1173 1057 * required.
1174 1058 * In the unlikely event that no async requests can be queued, this
1175 1059 * function will continue retrying before returning
1176 1060 *
1177 1061 * USBA prevents the client from submitting subsequent requests to a pipe
1178 1062 * that is being closed.
1179 1063 * Additional usb_pipe_close() requests on the same pipe causes USBA to
1180 1064 * wait for the previous close(s) to complete.
1181 1065 *
1182 1066 * The pipe will not be destroyed until all activity on the pipe has
1183 1067 * been drained, including outstanding request callbacks, async requests,
1184 1068 * and other usb_pipe_*() calls.
1185 1069 *
1186 1070 * Calling usb_pipe_close() from a deferred callback (in kernel context)
1187 1071 * with USB_FLAGS_SLEEP set, will cause deadlock
1188 1072 */
1189 1073 void usb_pipe_close(
1190 1074 dev_info_t *dip,
1191 1075 usb_pipe_handle_t pipe_handle,
1192 1076 usb_flags_t flags,
1193 1077 void (*cb)(
1194 1078 usb_pipe_handle_t ph,
1195 1079 usb_opaque_t arg, /* cb arg */
1196 1080 int rval,
1197 1081 usb_cb_flags_t flags),
1198 1082 usb_opaque_t cb_arg);
1199 1083
1200 1084
1201 1085 /*
1202 1086 * usb_pipe_drain_reqs
1203 1087 * this function blocks until there are no more requests
1204 1088 * owned by this dip on the pipe
1205 1089 *
1206 1090 * Arguments:
1207 1091 * dip - devinfo pointer
1208 1092 * pipe_handle - opaque pipe handle
1209 1093 * timeout - timeout in seconds
1210 1094 * flags - USB_FLAGS_SLEEP:
1211 1095 * wait for completion.
1212 1096 * cb - if USB_FLAGS_SLEEP has not been specified
1213 1097 * this callback function will be called on
1214 1098 * completion. This callback may be NULL
1215 1099 * and no notification of completion will then
1216 1100 * be provided.
1217 1101 * cb_arg - 2nd argument to callback function.
1218 1102 *
1219 1103 * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has
1220 1104 * been specified
1221 1105 *
1222 1106 * Returns:
1223 1107 * USB_SUCCESS - pipe successfully reset or request queued
1224 1108 * USB_FAILURE - timeout
1225 1109 * USB_INVALID_PIPE - pipe is invalid or already closed
1226 1110 * USB_INVALID_CONTEXT - called from interrupt context
1227 1111 * USB_INVALID_ARGS - invalid arguments
1228 1112 * USB_* - refer to return values defines in this file
1229 1113 */
1230 1114 int usb_pipe_drain_reqs(
1231 1115 dev_info_t *dip,
1232 1116 usb_pipe_handle_t pipe_handle,
1233 1117 uint_t time,
1234 1118 usb_flags_t flags,
1235 1119 void (*cb)(
1236 1120 usb_pipe_handle_t ph,
1237 1121 usb_opaque_t arg, /* cb arg */
1238 1122 int rval,
1239 1123 usb_cb_flags_t flags),
1240 1124 usb_opaque_t cb_arg);
1241 1125
1242 1126
1243 1127 /*
1244 1128 * Resetting a pipe: Refer to USB 2.0/10.5.2.2
1245 1129 * The pipe's requests are retired and the pipe is cleared. The host state
1246 1130 * is moved to active. If the reflected endpoint state needs to be changed,
1247 1131 * that must be explicitly requested by the client driver. The reset
1248 1132 * completes after all request callbacks have been completed.
1249 1133 *
1250 1134 * Arguments:
1251 1135 * dip - devinfo pointer.
1252 1136 * pipe_handle - pipe handle.
1253 1137 * flags - USB_FLAGS_SLEEP:
1254 1138 * wait for completion.
1255 1139 * cb - if USB_FLAGS_SLEEP has not been specified
1256 1140 * this callback function will be called on
1257 1141 * completion. This callback may be NULL
1258 1142 * and no notification of completion will then
1259 1143 * be provided.
1260 1144 * cb_arg - 2nd argument to callback function.
1261 1145 *
1262 1146 * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has
1263 1147 * been specified
1264 1148 *
1265 1149 * Note: Completion notification may be *before* all async request threads
1266 1150 * have completed but *after* all immediate callbacks have completed.
1267 1151 */
1268 1152 void usb_pipe_reset(
1269 1153 dev_info_t *dip,
1270 1154 usb_pipe_handle_t pipe_handle,
1271 1155 usb_flags_t usb_flags,
1272 1156 void (*cb)(
1273 1157 usb_pipe_handle_t ph,
1274 1158 usb_opaque_t arg,
1275 1159 int rval,
1276 1160 usb_cb_flags_t flags),
1277 1161 usb_opaque_t cb_arg);
1278 1162
1279 1163
1280 1164 /*
1281 1165 * The client driver can store a private data pointer in the
1282 1166 * pipe_handle.
1283 1167 *
1284 1168 * return values:
1285 1169 * USB_SUCCESS - success
1286 1170 * USB_FAILURE - unspecified failure
1287 1171 */
1288 1172 int usb_pipe_set_private(
1289 1173 usb_pipe_handle_t pipe_handle,
1290 1174 usb_opaque_t data);
1291 1175
1292 1176
1293 1177 usb_opaque_t usb_pipe_get_private(
1294 1178 usb_pipe_handle_t pipe_handle);
1295 1179
1296 1180
1297 1181 /*
1298 1182 * ***************************************************************************
1299 1183 * Transfer request definitions and functions
1300 1184 * ***************************************************************************
1301 1185 */
1302 1186
1303 1187
1304 1188 /*
1305 1189 * USB xfer request attributes.
1306 1190 * Set by the client driver, more than one may be set
1307 1191 *
1308 1192 * SHORT_XFER_OK if less data is transferred than specified, no error is
1309 1193 * returned.
1310 1194 * AUTOCLEARING if there is an exception, the pipe will be reset first
1311 1195 * and a functional stall cleared before a callback is done.
1312 1196 * PIPE_RESET if there is an exception, the pipe will be reset only
1313 1197 * ONE_XFER polling will automatically stop on the first callback.
1314 1198 * ISOC_START_FRAME use startframe specified.
1315 1199 * USB_ATTRS_ISOC_XFER_ASAP let the host controller decide on the first
1316 1200 * available frame.
1317 1201 *
1318 1202 * USB_ATTRS_ISOC_START_FRAME and USB_ATTRS_ISOC_XFER_ASAP are mutually
1319 1203 * exclusive
1320 1204 *
1321 1205 * combinations of flag and attributes:
1322 1206 *
1323 1207 * usb_flags usb_req_attrs semantics
1324 1208 * ---------------------------------------------------------
1325 1209 * SLEEP USB_ATTRS_SHORT_XFER_OK legal for IN pipes
1326 1210 * SLEEP USB_ATTRS_AUTOCLEARING legal
1327 1211 * SLEEP USB_ATTRS_PIPE_RESET legal
1328 1212 * SLEEP USB_ATTRS_ONE_XFER legal for interrupt IN pipes
1329 1213 * SLEEP USB_ATTRS_ISOC_START_FRAME illegal
1330 1214 * SLEEP USB_ATTRS_ISOC_XFER_ASAP illegal
1331 1215 *
1332 1216 * noSLEEP USB_ATTRS_SHORT_XFER_OK legal for all IN pipes
1333 1217 * noSLEEP USB_ATTRS_AUTOCLEARING legal
1334 1218 * noSLEEP USB_ATTRS_PIPE_RESET legal
1335 1219 * noSLEEP USB_ATTRS_ONE_XFER legal
1336 1220 * noSLEEP USB_ATTRS_ISOC_START_FRAME legal
1337 1221 * noSLEEP USB_ATTRS_ISOC_XFER_ASAP legal
1338 1222 */
1339 1223 typedef enum {
1340 1224 USB_ATTRS_NONE = 0,
1341 1225
1342 1226 /* only ctrl/bulk/intr IN pipes */
1343 1227 USB_ATTRS_SHORT_XFER_OK = 0x01, /* short data xfer is ok */
1344 1228 USB_ATTRS_PIPE_RESET = 0x02, /* reset pipe only on exc */
1345 1229 USB_ATTRS_AUTOCLEARING = 0x12, /* autoclear STALLs */
1346 1230
1347 1231 /* intr pipes only: one poll with data */
1348 1232 USB_ATTRS_ONE_XFER = 0x100,
1349 1233
1350 1234 /* only for isoch pipe */
1351 1235 USB_ATTRS_ISOC_START_FRAME = 0x200, /* Starting frame# specified */
1352 1236 USB_ATTRS_ISOC_XFER_ASAP = 0x400 /* HCD decides START_FRAME# */
1353 1237 } usb_req_attrs_t;
1354 1238
1355 1239
1356 1240 /*
1357 1241 * Note: client drivers are required to provide data buffers (mblks) for most
1358 1242 * requests
1359 1243 * IN OUT
1360 1244 * ctlr request if wLength > 0 if wLength > 0
1361 1245 * bulk request yes yes
1362 1246 * intr request no yes
1363 1247 * isoc request no yes
1364 1248 */
1365 1249
1366 1250 /*
1367 1251 * ===========================================================================
1368 1252 * USB control request management
1369 1253 * ===========================================================================
1370 1254 */
1371 1255
1372 1256 /*
1373 1257 * A client driver allocates and uses the usb_ctrl_req_t for all control
1374 1258 * pipe requests.
1375 1259 *
1376 1260 * Direction of the xfer will be determined based on the bmRequestType.
1377 1261 *
1378 1262 * NULL callbacks are permitted, timeout = 0 indicates infinite timeout.
1379 1263 * All timeouts are in seconds.
1380 1264 *
1381 1265 * All fields are initialized by client except for data on IN request
1382 1266 * in which case the client is responsible for deallocating.
1383 1267 *
1384 1268 * Control requests may be reused. The client driver is responsible
1385 1269 * for reinitializing some fields, eg data read/write pointers.
1386 1270 *
1387 1271 * Control requests can be queued.
1388 1272 */
1389 1273 typedef struct usb_ctrl_req {
1390 1274 uint8_t ctrl_bmRequestType; /* characteristics of request */
1391 1275 uint8_t ctrl_bRequest; /* specific request */
1392 1276 uint16_t ctrl_wValue; /* varies according to request */
1393 1277 uint16_t ctrl_wIndex; /* index or offset */
1394 1278 uint16_t ctrl_wLength; /* number of bytes to xfer */
1395 1279
1396 1280 mblk_t *ctrl_data; /* the data for the data phase */
1397 1281 /* IN: allocated by HCD */
1398 1282 /* OUT: allocated by client */
1399 1283 uint_t ctrl_timeout; /* how long before HCD retires req */
1400 1284 usb_opaque_t ctrl_client_private; /* for client private info */
1401 1285 usb_req_attrs_t ctrl_attributes; /* attributes for this req */
1402 1286
1403 1287 /*
1404 1288 * callback function for control pipe requests
1405 1289 *
1406 1290 * a normal callback will be done upon:
1407 1291 * - successful completion of a control pipe request
1408 1292 *
1409 1293 * callback arguments are:
1410 1294 * - the pipe_handle
1411 1295 * - usb_ctrl_req_t pointer
1412 1296 */
1413 1297 void (*ctrl_cb)(usb_pipe_handle_t ph,
1414 1298 struct usb_ctrl_req *req);
1415 1299
1416 1300 /*
1417 1301 * exception callback function for control pipe
1418 1302 *
1419 1303 * a exception callback will be done upon:
1420 1304 * - an exception/error (all types)
1421 1305 * - partial xfer of data unless SHORT_XFER_OK has been set
1422 1306 *
1423 1307 * callback arguments are:
1424 1308 * - the pipe_handle
1425 1309 * - usb_ctrl_req_t pointer
1426 1310 *
1427 1311 * if USB_ATTRS_AUTOCLEARING was set, autoclearing will be attempted
1428 1312 * and usb_cb_flags_t in usb_ctrl_req may indicate what was done
1429 1313 */
1430 1314 void (*ctrl_exc_cb)(usb_pipe_handle_t ph,
1431 1315 struct usb_ctrl_req *req);
1432 1316
1433 1317 /* set by USBA/HCD on completion */
1434 1318 usb_cr_t ctrl_completion_reason; /* set by HCD */
1435 1319 usb_cb_flags_t ctrl_cb_flags; /* Callback context / handling flgs */
1436 1320 } usb_ctrl_req_t;
1437 1321
1438 1322
1439 1323 /*
1440 1324 * In the setup packet, the descriptor type is passed in the high byte of the
1441 1325 * wValue field.
1442 1326 * descriptor types:
1443 1327 */
1444 1328 #define USB_DESCR_TYPE_SETUP_DEV 0x0100
1445 1329 #define USB_DESCR_TYPE_SETUP_CFG 0x0200
1446 1330 #define USB_DESCR_TYPE_SETUP_STRING 0x0300
1447 1331 #define USB_DESCR_TYPE_SETUP_IF 0x0400
1448 1332 #define USB_DESCR_TYPE_SETUP_EP 0x0500
1449 1333 #define USB_DESCR_TYPE_SETUP_DEV_QLF 0x0600
1450 1334 #define USB_DESCR_TYPE_SETUP_OTHER_SPEED_CFG 0x0700
1451 1335 #define USB_DESCR_TYPE_SETUP_IF_PWR 0x0800
1452 1336
1453 1337 #define USB_DESCR_TYPE_DEV 0x01
1454 1338 #define USB_DESCR_TYPE_CFG 0x02
1455 1339 #define USB_DESCR_TYPE_STRING 0x03
1456 1340 #define USB_DESCR_TYPE_IF 0x04
1457 1341 #define USB_DESCR_TYPE_EP 0x05
1458 1342 #define USB_DESCR_TYPE_DEV_QLF 0x06
1459 1343 #define USB_DESCR_TYPE_OTHER_SPEED_CFG 0x07
1460 1344 #define USB_DESCR_TYPE_IF_PWR 0x08
1461 1345 #define USB_DESCR_TYPE_IA 0x0B
1462 1346
1463 1347 #define USB_DESCR_TYPE_WA 0x21
1464 1348 #define USB_DESCR_TYPE_RPIPE 0x22
1465 1349
1466 1350 /* Wireless USB extension, refer to WUSB 1.0/7.4 */
1467 1351 #define USB_DESCR_TYPE_SECURITY 0x0c
1468 1352 #define USB_DESCR_TYPE_KEY 0x0d
1469 1353 #define USB_DESCR_TYPE_ENCRYPTION 0x0e
1470 1354 #define USB_DESCR_TYPE_BOS 0x0f
1471 1355 #define USB_DESCR_TYPE_DEV_CAPABILITY 0x10
1472 1356 #define USB_DESCR_TYPE_WIRELESS_EP_COMP 0x11
1473 1357
1474 1358 #define USB_WA_DESCR_SIZE 14
1475 1359 #define USB_RPIPE_DESCR_SIZE 28
1476 1360
1477 1361 /*
1478 1362 * device request type
1479 1363 */
1480 1364 #define USB_DEV_REQ_HOST_TO_DEV 0x00
1481 1365 #define USB_DEV_REQ_DEV_TO_HOST 0x80
1482 1366 #define USB_DEV_REQ_DIR_MASK 0x80
1483 1367
1484 1368 #define USB_DEV_REQ_TYPE_STANDARD 0x00
1485 1369 #define USB_DEV_REQ_TYPE_CLASS 0x20
1486 1370 #define USB_DEV_REQ_TYPE_VENDOR 0x40
1487 1371 #define USB_DEV_REQ_TYPE_MASK 0x60
1488 1372
1489 1373 #define USB_DEV_REQ_RCPT_DEV 0x00
1490 1374 #define USB_DEV_REQ_RCPT_IF 0x01
1491 1375 #define USB_DEV_REQ_RCPT_EP 0x02
1492 1376 #define USB_DEV_REQ_RCPT_OTHER 0x03
1493 1377 #define USB_DEV_REQ_RCPT_MASK 0x03
1494 1378
1495 1379 /* Wire adapter class extension for request recipient */
1496 1380 #define USB_DEV_REQ_RCPT_PORT 0x04
1497 1381 #define USB_DEV_REQ_RCPT_RPIPE 0x05
1498 1382
1499 1383 /*
1500 1384 * device request
1501 1385 */
1502 1386 #define USB_REQ_GET_STATUS 0x00
1503 1387 #define USB_REQ_CLEAR_FEATURE 0x01
1504 1388 #define USB_REQ_SET_FEATURE 0x03
1505 1389 #define USB_REQ_SET_ADDRESS 0x05
1506 1390 #define USB_REQ_GET_DESCR 0x06
1507 1391 #define USB_REQ_SET_DESCR 0x07
1508 1392 #define USB_REQ_GET_CFG 0x08
1509 1393 #define USB_REQ_SET_CFG 0x09
1510 1394 #define USB_REQ_GET_IF 0x0a
1511 1395 #define USB_REQ_SET_IF 0x0b
1512 1396 #define USB_REQ_SYNC_FRAME 0x0c
1513 1397 /* Wireless USB extension, refer to WUSB 1.0/7.3.1 */
1514 1398 #define USB_REQ_SET_ENCRYPTION 0x0d
1515 1399 #define USB_REQ_GET_ENCRYPTION 0x0e
1516 1400 #define USB_REQ_RPIPE_ABORT 0x0e
1517 1401 #define USB_REQ_SET_HANDSHAKE 0x0f
1518 1402 #define USB_REQ_RPIPE_RESET 0x0f
1519 1403 #define USB_REQ_GET_HANDSHAKE 0x10
1520 1404 #define USB_REQ_SET_CONNECTION 0x11
1521 1405 #define USB_REQ_SET_SECURITY_DATA 0x12
1522 1406 #define USB_REQ_GET_SECURITY_DATA 0x13
1523 1407 #define USB_REQ_SET_WUSB_DATA 0x14
1524 1408 #define USB_REQ_LOOPBACK_DATA_WRITE 0x15
1525 1409 #define USB_REQ_LOOPBACK_DATA_READ 0x16
1526 1410 #define USB_REQ_SET_INTERFACE_DS 0x17
1527 1411
1528 1412 /* language ID for string descriptors */
1529 1413 #define USB_LANG_ID 0x0409
1530 1414
1531 1415 /*
1532 1416 * Standard Feature Selectors
1533 1417 */
1534 1418 #define USB_EP_HALT 0x0000
1535 1419 #define USB_DEV_REMOTE_WAKEUP 0x0001
1536 1420 #define USB_DEV_TEST_MODE 0x0002
1537 1421 /* Wireless USB extension, refer to WUSB 1.0/7.3.1 */
1538 1422 #define USB_DEV_WUSB 0x0003
1539 1423
1540 1424
1541 1425 /*
1542 1426 * Allocate usb control request
1543 1427 *
1544 1428 * Arguments:
1545 1429 * dip - dev_info pointer of the client driver
1546 1430 * len - length of "data" for this control request.
1547 1431 * if 0, no mblk is alloc'ed
1548 1432 * flags - USB_FLAGS_SLEEP: Sleep if resources are not available
1549 1433 *
1550 1434 * Return Values:
1551 1435 * usb_ctrl_req_t pointer on success, NULL on failure
1552 1436 *
1553 1437 * Implementation NOTE: the dip allows checking on detach for memory leaks
1554 1438 */
1555 1439 usb_ctrl_req_t *usb_alloc_ctrl_req(
1556 1440 dev_info_t *dip,
1557 1441 size_t len,
1558 1442 usb_flags_t flags);
1559 1443
1560 1444
1561 1445 /*
1562 1446 * free USB control request
1563 1447 */
1564 1448 void usb_free_ctrl_req(
1565 1449 usb_ctrl_req_t *reqp);
1566 1450
1567 1451
1568 1452 /*
1569 1453 * usb_pipe_ctrl_xfer();
1570 1454 * Client driver calls this function to issue the control
1571 1455 * request to the USBA which will queue or transport it to the device
1572 1456 *
1573 1457 * Arguments:
1574 1458 * pipe_handle - control pipe pipehandle (obtained via usb_pipe_open()
1575 1459 * reqp - pointer to control request
1576 1460 * flags - USB_FLAGS_SLEEP:
1577 1461 * wait for the request to complete
1578 1462 *
1579 1463 * Return values:
1580 1464 * USB_SUCCESS - successfully queued (no sleep) or successfully
1581 1465 * completed (with sleep specified)
1582 1466 * USB_FAILURE - failure
1583 1467 * USB_NO_RESOURCES - no resources
1584 1468 */
1585 1469 int usb_pipe_ctrl_xfer(usb_pipe_handle_t pipe_handle,
1586 1470 usb_ctrl_req_t *reqp,
1587 1471 usb_flags_t flags);
1588 1472
1589 1473
1590 1474 /*
1591 1475 * ---------------------------------------------------------------------------
1592 1476 * Wrapper function which allocates and deallocates a request structure, and
1593 1477 * performs a control transfer.
1594 1478 * ---------------------------------------------------------------------------
1595 1479 */
1596 1480
1597 1481 /*
1598 1482 * Setup arguments for usb_pipe_ctrl_xfer_wait:
1599 1483 *
1600 1484 * bmRequestType - characteristics of request
1601 1485 * bRequest - specific request
1602 1486 * wValue - varies according to request
1603 1487 * wIndex - index or offset
1604 1488 * wLength - number of bytes to xfer
1605 1489 * attrs - required request attributes
1606 1490 * data - pointer to pointer to data
1607 1491 * IN: HCD will allocate data
1608 1492 * OUT: clients driver allocates data
1609 1493 */
1610 1494 typedef struct usb_ctrl_setup {
1611 1495 uchar_t bmRequestType;
1612 1496 uchar_t bRequest;
1613 1497 uint16_t wValue;
1614 1498 uint16_t wIndex;
1615 1499 uint16_t wLength;
1616 1500 usb_req_attrs_t attrs;
1617 1501 } usb_ctrl_setup_t;
1618 1502
1619 1503
1620 1504 /*
1621 1505 * usb_pipe_ctrl_xfer_wait():
1622 1506 * for simple synchronous control transactions this wrapper function
1623 1507 * will perform the allocation, xfer, and deallocation.
1624 1508 * USB_ATTRS_AUTOCLEARING will be enabled
1625 1509 *
1626 1510 * Arguments:
1627 1511 * pipe_handle - control pipe pipehandle (obtained via usb_pipe_open())
1628 1512 * setup - contains pointer to client's devinfo,
1629 1513 * setup descriptor params, attributes and data
1630 1514 * completion_reason - completion status.
1631 1515 * cb_flags - request completions flags.
1632 1516 * flags - none.
1633 1517 *
1634 1518 * Return Values:
1635 1519 * USB_SUCCESS - request successfully executed.
1636 1520 * USB_FAILURE - request failed.
1637 1521 * USB_* - refer to list of all possible return values in
1638 1522 * this file
1639 1523 *
1640 1524 * NOTES:
1641 1525 * - in the case of failure, the client should check completion_reason and
1642 1526 * and cb_flags and determine further recovery action
1643 1527 * - the client should check data and if non-zero, free the data on
1644 1528 * completion
1645 1529 */
1646 1530 int usb_pipe_ctrl_xfer_wait(
1647 1531 usb_pipe_handle_t pipe_handle,
1648 1532 usb_ctrl_setup_t *setup,
1649 1533 mblk_t **data,
1650 1534 usb_cr_t *completion_reason,
1651 1535 usb_cb_flags_t *cb_flags,
1652 1536 usb_flags_t flags);
1653 1537
1654 1538
1655 1539 /*
1656 1540 * ---------------------------------------------------------------------------
1657 1541 * Some utility defines and wrapper functions for standard control requests.
1658 1542 * ---------------------------------------------------------------------------
1659 1543 */
1660 1544
1661 1545 /*
1662 1546 *
1663 1547 * Status bits returned by a usb_get_status().
1664 1548 */
1665 1549 #define USB_DEV_SLF_PWRD_STATUS 1 /* Supports Self Power */
1666 1550 #define USB_DEV_RWAKEUP_STATUS 2 /* Remote Wakeup Enabled */
1667 1551 #define USB_DEV_BAT_PWRD_STATUS 4 /* Battery Powered */
1668 1552 #define USB_EP_HALT_STATUS 1 /* Endpoint is Halted */
1669 1553 #define USB_IF_STATUS 0 /* Interface Status is 0 */
1670 1554
1671 1555 /* length of data returned by USB_REQ_GET_STATUS */
1672 1556 #define USB_GET_STATUS_LEN 2
1673 1557
1674 1558 /*
1675 1559 * wrapper function returning status of device, interface, or endpoint
1676 1560 *
1677 1561 * Arguments:
1678 1562 * dip - devinfo pointer.
1679 1563 * ph - pipe handle
1680 1564 * type - bmRequestType to be used
1681 1565 * what - 0 for device, otherwise interface or ep number
1682 1566 * status - pointer to returned status.
1683 1567 * flags - USB_FLAGS_SLEEP (mandatory)
1684 1568 *
1685 1569 * Return Values:
1686 1570 * valid usb_status_t or USB_FAILURE
1687 1571 *
1688 1572 */
1689 1573 int usb_get_status(
1690 1574 dev_info_t *dip,
1691 1575 usb_pipe_handle_t ph,
1692 1576 uint_t type, /* bmRequestType */
1693 1577 uint_t what, /* 0, interface, endpoint number */
1694 1578 uint16_t *status,
1695 1579 usb_flags_t flags);
1696 1580
1697 1581
1698 1582 /*
1699 1583 * function for clearing feature of device, interface, or endpoint
1700 1584 *
1701 1585 * Arguments:
1702 1586 * dip - devinfo pointer.
1703 1587 * type - bmRequestType to be used
1704 1588 * feature - feature to be cleared
1705 1589 * what - 0 for device, otherwise interface or ep number
1706 1590 * flags - USB_FLAGS_SLEEP (mandatory)
1707 1591 * cb - if USB_FLAGS_SLEEP has not been specified
1708 1592 * this callback function will be called on
1709 1593 * completion. This callback may be NULL
1710 1594 * and no notification of completion will then
1711 1595 * be provided.
1712 1596 * cb_arg - 2nd argument to callback function.
1713 1597 *
1714 1598 * Return Values:
1715 1599 * USB_SUCCESS clearing feature succeeded
1716 1600 * USB_FAILURE clearing feature failed
1717 1601 * USB_* refer to list of all possible return values in
1718 1602 * this file
1719 1603 */
1720 1604 int usb_clr_feature(
1721 1605 dev_info_t *dip,
1722 1606 uint_t type, /* bmRequestType */
1723 1607 uint_t feature,
1724 1608 uint_t what, /* 0, interface, endpoint number */
1725 1609 usb_flags_t flags,
1726 1610 void (*cb)(
1727 1611 usb_pipe_handle_t ph,
1728 1612 usb_opaque_t arg,
1729 1613 int rval,
1730 1614 usb_cb_flags_t flags),
1731 1615 usb_opaque_t cb_arg);
1732 1616
1733 1617
1734 1618 /*
1735 1619 * usb_set_cfg():
1736 1620 * Sets the configuration. Use this function with caution as
1737 1621 * the framework is normally responsible for configuration changes.
1738 1622 * Changing configuration will fail if pipes are still open or
1739 1623 * when invoked from a driver bound to an interface on a composite
1740 1624 * device. This function access the device and blocks.
1741 1625 *
1742 1626 * Arguments:
1743 1627 * dip - devinfo pointer.
1744 1628 * cfg_index - Index of configuration to set. Corresponds to
1745 1629 * index in the usb_client_dev_data_t tree of
1746 1630 * configurations. See usb_client_dev_data_t(9F).
1747 1631 * usb_flags - USB_FLAGS_SLEEP:
1748 1632 * wait for completion.
1749 1633 * cb - if USB_FLAGS_SLEEP has not been specified
1750 1634 * this callback function will be called on
1751 1635 * completion. This callback may be NULL
1752 1636 * and no notification of completion will then
1753 1637 * be provided.
1754 1638 * cb_arg - 2nd argument to callback function.
1755 1639 *
1756 1640 * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has
1757 1641 * been specified
1758 1642 *
1759 1643 * Return Values:
1760 1644 * USB_SUCCESS: new configuration was set or async request
1761 1645 * submitted successfully.
1762 1646 * USB_FAILURE: new configuration could not be set because
1763 1647 * it may been illegal configuration or this
1764 1648 * caller was not allowed to change configs or
1765 1649 * pipes were still open or async request
1766 1650 * could not be submitted.
1767 1651 * USB_* refer to list of all possible return values in
1768 1652 * this file
1769 1653 *
1770 1654 * the pipe handle argument in the callback will be the default pipe handle
1771 1655 */
1772 1656 int usb_set_cfg(
1773 1657 dev_info_t *dip,
1774 1658 uint_t cfg_index,
1775 1659 usb_flags_t usb_flags,
1776 1660 void (*cb)(
1777 1661 usb_pipe_handle_t ph,
1778 1662 usb_opaque_t arg,
1779 1663 int rval,
1780 1664 usb_cb_flags_t flags),
1781 1665 usb_opaque_t cb_arg);
1782 1666
1783 1667
1784 1668 /*
1785 1669 * usb_get_cfg:
1786 1670 * dip - pointer to devinfo node
1787 1671 * cfgval - pointer to cfgval
1788 1672 * usb_flags - none, will always block
1789 1673 *
1790 1674 * return values:
1791 1675 * USB_SUCCESS - current cfg value is returned to cfgval
1792 1676 * USB_* - refer to list of all possible return values in
1793 1677 * this file
1794 1678 */
1795 1679 int usb_get_cfg(
1796 1680 dev_info_t *dip,
1797 1681 uint_t *cfgval,
1798 1682 usb_flags_t usb_flags);
1799 1683
1800 1684
1801 1685 /*
1802 1686 * The following functions set or get the alternate interface
1803 1687 * setting.
1804 1688 *
1805 1689 * usb_set_alt_if:
1806 1690 * dip - pointer to devinfo node
1807 1691 * interface - interface
1808 1692 * alt_number - alternate to set to
1809 1693 * usb_flags - USB_FLAGS_SLEEP:
1810 1694 * wait for completion.
1811 1695 * cb - if USB_FLAGS_SLEEP has not been specified
1812 1696 * this callback function will be called on
1813 1697 * completion. This callback may be NULL
1814 1698 * and no notification of completion will then
1815 1699 * be provided.
1816 1700 * cb_arg - 2nd argument to callback function.
1817 1701 *
1818 1702 * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has
1819 1703 * been specified
1820 1704 *
1821 1705 * the pipe handle argument in the callback will be the default pipe handle
1822 1706 *
1823 1707 * return values:
1824 1708 * USB_SUCCESS: alternate was set or async request was
1825 1709 * submitted.
1826 1710 * USB_FAILURE: alternate could not be set because pipes
1827 1711 * were still open or some access error occurred
1828 1712 * or an invalid alt if value was passed or
1829 1713 * async request could not be submitted
1830 1714 * USB_INVALID_PERM the driver does not own the device or the interface
1831 1715 * USB_* refer to list of all possible return values in
1832 1716 * this file
1833 1717 */
1834 1718 int usb_set_alt_if(
1835 1719 dev_info_t *dip,
1836 1720 uint_t interface,
1837 1721 uint_t alt_number,
1838 1722 usb_flags_t usb_flags,
1839 1723 void (*cb)(
1840 1724 usb_pipe_handle_t ph,
1841 1725 usb_opaque_t arg,
1842 1726 int rval,
1843 1727 usb_cb_flags_t flags),
1844 1728 usb_opaque_t cb_arg);
1845 1729
1846 1730
1847 1731
1848 1732 /* flags must be USB_FLAGS_SLEEP, and this function will block */
1849 1733 int usb_get_alt_if(
1850 1734 dev_info_t *dip,
1851 1735 uint_t if_number,
1852 1736 uint_t *alt_number,
1853 1737 usb_flags_t flags);
1854 1738
1855 1739
1856 1740 /*
1857 1741 * ===========================================================================
1858 1742 * USB bulk request management
1859 1743 * ===========================================================================
1860 1744 */
1861 1745
1862 1746 /*
1863 1747 * A client driver allocates/uses the usb_bulk_req_t for bulk pipe xfers.
1864 1748 *
1865 1749 * NOTES:
1866 1750 * - bulk pipe sharing is not supported
1867 1751 * - semantics of combinations of flag and attributes:
1868 1752 *
1869 1753 * flags Type attributes data timeout semantics
1870 1754 * ----------------------------------------------------------------
1871 1755 * x x x == NULL x illegal
1872 1756 *
1873 1757 * no sleep IN x != NULL 0 fill buffer, no timeout
1874 1758 * callback when xfer-len has
1875 1759 * been xferred
1876 1760 * no sleep IN x != NULL > 0 fill buffer, with timeout
1877 1761 * callback when xfer-len has
1878 1762 * been xferred
1879 1763 *
1880 1764 * sleep IN x != NULL 0 fill buffer, no timeout
1881 1765 * unblock when xfer-len has
1882 1766 * been xferred
1883 1767 * no callback
1884 1768 * sleep IN x != NULL > 0 fill buffer, with timeout
1885 1769 * unblock when xfer-len has
1886 1770 * been xferred or timeout
1887 1771 * no callback
1888 1772 *
1889 1773 * X OUT SHORT_XFER_OK x x illegal
1890 1774 *
1891 1775 * no sleep OUT x != NULL 0 empty buffer, no timeout
1892 1776 * callback when xfer-len has
1893 1777 * been xferred
1894 1778 * no sleep OUT x != NULL > 0 empty buffer, with timeout
1895 1779 * callback when xfer-len has
1896 1780 * been xferred or timeout
1897 1781 *
1898 1782 * sleep OUT x != NULL 0 empty buffer, no timeout
1899 1783 * unblock when xfer-len has
1900 1784 * been xferred
1901 1785 * no callback
1902 1786 * sleep OUT x != NULL > 0 empty buffer, with timeout
1903 1787 * unblock when xfer-len has
1904 1788 * been xferred or timeout
1905 1789 * no callback
1906 1790 *
1907 1791 * - bulk_len and bulk_data must be > 0. SHORT_XFER_OK is not applicable.
1908 1792 *
1909 1793 * - multiple bulk requests can be queued
1910 1794 *
1911 1795 * - Splitting large Bulk xfer:
1912 1796 * The HCD driver, due to internal constraints, can only do a limited size bulk
1913 1797 * data xfer per request. The current limitations are 32K for UHCI and 128K
1914 1798 * for OHCI. So, a client driver may first determine this limitation (by
1915 1799 * calling the USBA interface usb_pipe_bulk_transfer_size()); and restrict
1916 1800 * itself to doing xfers in multiples of this fixed size. This forces a client
1917 1801 * driver to do data xfers in a loop for a large request, splitting it into
1918 1802 * multiple chunks of fixed size.
1919 1803 */
1920 1804 typedef struct usb_bulk_req {
1921 1805 uint_t bulk_len; /* number of bytes to xfer */
1922 1806 mblk_t *bulk_data; /* the data for the data phase */
1923 1807 /* IN: allocated by HCD */
1924 1808 /* OUT: allocated by client */
1925 1809 uint_t bulk_timeout; /* xfer timeout value in secs */
1926 1810 usb_opaque_t bulk_client_private; /* Client specific information */
1927 1811 usb_req_attrs_t bulk_attributes; /* xfer-attributes */
1928 1812
1929 1813 /* Normal Callback function (For synch xfers) */
1930 1814 void (*bulk_cb)(usb_pipe_handle_t ph,
1931 1815 struct usb_bulk_req *req);
1932 1816
1933 1817 /* Exception Callback function (For asynch xfers) */
1934 1818 void (*bulk_exc_cb)(usb_pipe_handle_t ph,
1935 1819 struct usb_bulk_req *req);
1936 1820
1937 1821 /* set by USBA/HCD on completion */
1938 1822 usb_cr_t bulk_completion_reason; /* set by HCD */
1939 1823 usb_cb_flags_t bulk_cb_flags; /* Callback context / handling flgs */
1940 1824 } usb_bulk_req_t;
1941 1825
1942 1826
1943 1827 /*
1944 1828 * Allocate/free usb bulk request
1945 1829 *
1946 1830 * Arguments:
1947 1831 * dip - pointer to dev_info_t of the client driver
1948 1832 * len - 0 or length of mblk to be allocated
1949 1833 * flags - USB_FLAGS_SLEEP:
1950 1834 * wait for resources
1951 1835 *
1952 1836 * Return Values:
1953 1837 * usb_bulk_req_t on success, NULL on failure
1954 1838 */
1955 1839 usb_bulk_req_t *usb_alloc_bulk_req(
1956 1840 dev_info_t *dip,
1957 1841 size_t len,
1958 1842 usb_flags_t flags);
1959 1843
1960 1844
1961 1845 void usb_free_bulk_req(
1962 1846 usb_bulk_req_t *reqp);
1963 1847
1964 1848
1965 1849 /*
1966 1850 * usb_pipe_bulk_xfer():
1967 1851 *
1968 1852 * Client drivers call this function to issue the bulk xfer to the USBA
1969 1853 * which will queue or transfer it to the device
1970 1854 *
1971 1855 * Arguments:
1972 1856 * pipe_handle - bulk pipe handle (obtained via usb_pipe_open()
1973 1857 * reqp - pointer to bulk data xfer request (IN or OUT)
1974 1858 * flags - USB_FLAGS_SLEEP:
1975 1859 * wait for the request to complete
1976 1860 *
1977 1861 * Return Values:
1978 1862 * USB_SUCCESS - success
1979 1863 * USB_FAILURE - unspecified failure
1980 1864 * USB_NO_RESOURCES - no resources
1981 1865 *
1982 1866 */
1983 1867 int usb_pipe_bulk_xfer(
1984 1868 usb_pipe_handle_t pipe_handle,
1985 1869 usb_bulk_req_t *reqp,
1986 1870 usb_flags_t flags);
1987 1871
1988 1872 /* Get maximum bulk transfer size */
1989 1873 int usb_pipe_get_max_bulk_transfer_size(
1990 1874 dev_info_t *dip,
1991 1875 size_t *size);
1992 1876
1993 1877
1994 1878 /*
1995 1879 * ===========================================================================
1996 1880 * USB interrupt pipe request management
1997 1881 * ===========================================================================
1998 1882 */
1999 1883
2000 1884 /*
2001 1885 * A client driver allocates and uses the usb_intr_req_t for
2002 1886 * all interrupt pipe transfers.
2003 1887 *
2004 1888 * USB_FLAGS_SLEEP indicates here just to wait for resources except
2005 1889 * for ONE_XFER where we also wait for completion
2006 1890 *
2007 1891 * semantics flags and attribute combinations:
2008 1892 *
2009 1893 * Notes:
2010 1894 * none attributes indicates neither ONE_XFER nor SHORT_XFER_OK
2011 1895 *
2012 1896 * flags Type attributes data timeout semantics
2013 1897 * ----------------------------------------------------------------
2014 1898 * x IN x != NULL x illegal
2015 1899 * x IN ONE_XFER=0 x !=0 illegal
2016 1900 *
2017 1901 * x IN ONE_XFER=0 NULL 0 continuous polling,
2018 1902 * many callbacks
2019 1903 * request is returned on
2020 1904 * stop polling
2021 1905 *
2022 1906 * no sleep IN ONE_XFER NULL 0 one time poll, no timeout,
2023 1907 * one callback
2024 1908 * no sleep IN ONE_XFER NULL !=0 one time poll, with
2025 1909 * timeout, one callback
2026 1910 *
2027 1911 * sleep IN ONE_XFER NULL 0 one time poll, no timeout,
2028 1912 * no callback,
2029 1913 * block for completion
2030 1914 * sleep IN ONE_XFER NULL !=0 one time poll, with timeout,
2031 1915 * no callback
2032 1916 * block for completion
2033 1917 *
2034 1918 * x OUT x NULL x illegal
2035 1919 * x OUT ONE_XFER x x illegal
2036 1920 * x OUT SHORT_XFER_OK x x illegal
2037 1921 *
2038 1922 * x OUT none != NULL 0 xfer until data exhausted,
2039 1923 * no timeout, one callback
2040 1924 * x OUT none != NULL !=0 xfer until data exhausted,
2041 1925 * with timeout, one callback
2042 1926 *
2043 1927 * - Reads (IN):
2044 1928 *
2045 1929 * The client driver does *not* provide a data buffer.
2046 1930 * By default, a READ request would mean continuous polling for data IN. The
2047 1931 * HCD typically reads "wMaxPacketSize" amount of 'periodic data'. A client
2048 1932 * driver may force the HCD to read instead intr_len
2049 1933 * amount of 'periodic data' (See section 1).
2050 1934 *
2051 1935 * The HCD issues a callback to the client after each polling interval if
2052 1936 * it has read in some data. Note that the amount of data read IN is either
2053 1937 * intr_len or 'wMaxPacketSize' in length.
2054 1938 *
2055 1939 * Normally, the HCD keeps polling interrupt pipe forever even if there is
2056 1940 * no data to be read IN. A client driver may stop this polling by
2057 1941 * calling usb_pipe_stop_intr_polling().
2058 1942 *
2059 1943 * If a client driver chooses to pass USB_ATTRS_ONE_XFER as
2060 1944 * 'xfer_attributes' the HCD will poll for data until some data is received.
2061 1945 * HCD reads in the data and does a callback and stops polling for any more
2062 1946 * data. In this case, the client driver need not explicitly call
2063 1947 * usb_pipe_stop_intr_polling().
2064 1948 *
2065 1949 * When continuous polling is stopped, the original request is returned with
2066 1950 * USB_CR_STOPPED_POLLING.
2067 1951 *
2068 1952 * - Writes (OUT):
2069 1953 *
2070 1954 * A client driver provides the data buffer, and data, needed for intr write.
2071 1955 * There is no continuous write mode, a la read (See previous section).
2072 1956 * The USB_ATTRS_ONE_XFER attribute is illegal.
2073 1957 * By default USBA keeps writing intr data until the provided data buffer
2074 1958 * has been written out. The HCD does ONE callback to the client driver.
2075 1959 * Queueing is supported.
2076 1960 * Max size is 8k
2077 1961 */
2078 1962 typedef struct usb_intr_req {
2079 1963 uint_t intr_len; /* OUT: size of total xfer */
2080 1964 /* IN : packet size */
2081 1965 mblk_t *intr_data; /* the data for the data phase */
2082 1966 /* IN: allocated by HCD */
2083 1967 /* OUT: allocated by client */
2084 1968 usb_opaque_t intr_client_private; /* Client specific information */
2085 1969 uint_t intr_timeout; /* only with ONE TIME POLL, in secs */
2086 1970 usb_req_attrs_t intr_attributes;
2087 1971
2088 1972 /* Normal callback function (For synch transfers) */
2089 1973 void (*intr_cb)(usb_pipe_handle_t ph,
2090 1974 struct usb_intr_req *req);
2091 1975
2092 1976 /* Exception callback function (For asynch transfers) */
2093 1977 void (*intr_exc_cb)(usb_pipe_handle_t ph,
2094 1978 struct usb_intr_req *req);
2095 1979
2096 1980 /* set by USBA/HCD on completion */
2097 1981 usb_cr_t intr_completion_reason; /* set by HCD */
2098 1982 usb_cb_flags_t intr_cb_flags; /* Callback context / handling flgs */
2099 1983 } usb_intr_req_t;
2100 1984
2101 1985
2102 1986 /*
2103 1987 * Allocate/free usb interrupt pipe request
2104 1988 *
2105 1989 * Arguments:
2106 1990 * dip - pointer to dev_info_t of the client driver
2107 1991 * reqp - pointer to request structure
2108 1992 * len - 0 or length of mblk for this interrupt request
2109 1993 * flags - USB_FLAGS_SLEEP:
2110 1994 * Sleep if resources are not available
2111 1995 *
2112 1996 * Return Values:
2113 1997 * usb_intr_req_t on success, NULL on failure
2114 1998 */
2115 1999 usb_intr_req_t *usb_alloc_intr_req(
2116 2000 dev_info_t *dip,
2117 2001 size_t len,
2118 2002 usb_flags_t flags);
2119 2003
2120 2004
2121 2005 void usb_free_intr_req(
2122 2006 usb_intr_req_t *reqp);
2123 2007
2124 2008
2125 2009 /*
2126 2010 * usb_pipe_intr_xfer():
2127 2011 *
2128 2012 * Client drivers call this function to issue the intr xfer to USBA/HCD
2129 2013 * which starts polling the device
2130 2014 *
2131 2015 * Arguments:
2132 2016 * pipe_handle - interrupt pipe handle (obtained via usb_pipe_open()
2133 2017 * reqp - pointer tothe interrupt pipe xfer request (IN or OUT)
2134 2018 * flags - USB_FLAGS_SLEEP:
2135 2019 * wait for resources to be available
2136 2020 *
2137 2021 * return values:
2138 2022 * USB_SUCCESS - success
2139 2023 * USB_FAILURE - unspecified failure
2140 2024 * USB_NO_RESOURCES - no resources
2141 2025 *
2142 2026 * NOTE: start polling on an IN pipe that is already being polled is a NOP.
2143 2027 * We don't queue requests on OUT pipe
2144 2028 */
2145 2029 int usb_pipe_intr_xfer(
2146 2030 usb_pipe_handle_t pipe_handle,
2147 2031 usb_intr_req_t *req,
2148 2032 usb_flags_t flags);
2149 2033
2150 2034
2151 2035 /*
2152 2036 * usb_pipe_stop_intr_polling():
2153 2037 *
2154 2038 * Client drivers call this function to stop the automatic data-in/out transfers
2155 2039 * without closing the pipe.
2156 2040 *
2157 2041 * If USB_FLAGS_SLEEP has been specified then this function will block until
2158 2042 * polling has been stopped and all callbacks completed. If USB_FLAGS_SLEEP
2159 2043 * has NOT been specified then polling is terminated when the original
2160 2044 * request that started the polling has been returned with
2161 2045 * USB_CR_STOPPED_POLLING
2162 2046 *
2163 2047 * Stop polling should never fail.
2164 2048 *
2165 2049 * Args:-
2166 2050 * pipe_handle - interrupt pipe handle (obtained via usb_pipe_open()).
2167 2051 * flags - USB_FLAGS_SLEEP:
2168 2052 * wait for the resources to be available.
2169 2053 */
2170 2054 void usb_pipe_stop_intr_polling(
2171 2055 usb_pipe_handle_t pipe_handle,
2172 2056 usb_flags_t flags);
2173 2057
2174 2058
2175 2059 /*
2176 2060 * ===========================================================================
2177 2061 * USB isochronous xfer management
2178 2062 * ===========================================================================
2179 2063 */
2180 2064
2181 2065 /*
2182 2066 * The usb frame number is an absolute number since boot and incremented
2183 2067 * every 1 ms.
2184 2068 */
2185 2069 typedef uint64_t usb_frame_number_t;
2186 2070
2187 2071 /*
2188 2072 * USB ischronous packet descriptor
2189 2073 *
2190 2074 * An array of structures of type usb_isoc_pkt_descr_t must be allocated and
2191 2075 * initialized by the client driver using usb_alloc_isoc_req(). The client
2192 2076 * driver must set isoc_pkt_length in each packet descriptor before submitting
2193 2077 * the request.
2194 2078 */
2195 2079 typedef struct usb_isoc_pkt_descr {
2196 2080 /*
2197 2081 * Set by the client driver, for all isochronous requests, to the
2198 2082 * number of bytes to transfer in a frame.
2199 2083 */
2200 2084 ushort_t isoc_pkt_length;
2201 2085
2202 2086 /*
2203 2087 * Set by HCD to actual number of bytes sent/received in frame.
2204 2088 */
2205 2089 ushort_t isoc_pkt_actual_length;
2206 2090
2207 2091 /*
2208 2092 * Per frame status set by HCD both for the isochronous IN and OUT
2209 2093 * requests. If any status is non-zero then isoc_error_count in the
2210 2094 * isoc_req will be non-zero.
2211 2095 */
2212 2096 usb_cr_t isoc_pkt_status;
2213 2097 } usb_isoc_pkt_descr_t;
2214 2098
2215 2099
2216 2100 /*
2217 2101 * USB isochronous request
2218 2102 *
2219 2103 * The client driver allocates the usb_isoc_req_t before sending an
2220 2104 * isochronous requests.
2221 2105 *
2222 2106 * USB_FLAGS_SLEEP indicates here just to wait for resources but not
2223 2107 * to wait for completion
2224 2108 *
2225 2109 * Semantics of various combinations for data xfers:
2226 2110 *
2227 2111 * Note: attributes considered in this table are ONE_XFER, START_FRAME,
2228 2112 * XFER_ASAP, SHORT_XFER
2229 2113 *
2230 2114 *
2231 2115 * flags Type attributes data semantics
2232 2116 * ---------------------------------------------------------------------
2233 2117 * x x x NULL illegal
2234 2118 *
2235 2119 * x x ONE_XFER x illegal
2236 2120 *
2237 2121 * x IN x !=NULL continuous polling,
2238 2122 * many callbacks
2239 2123 *
2240 2124 * x IN ISOC_START_FRAME !=NULL invalid if Current_frame# >
2241 2125 * "isoc_frame_no"
2242 2126 * x IN ISOC_XFER_ASAP !=NULL "isoc_frame_no" ignored.
2243 2127 * HCD determines when to
2244 2128 * insert xfer
2245 2129 *
2246 2130 * x OUT ONE_XFER x illegal
2247 2131 * x OUT SHORT_XFER_OK x illegal
2248 2132 *
2249 2133 * x OUT ISOC_START_FRAME !=NULL invalid if Current_frame# >
2250 2134 * "isoc_frame_no"
2251 2135 * x OUT ISOC_XFER_ASAP !=NULL "isoc_frame_no" ignored.
2252 2136 * HCD determines when to
2253 2137 * insert xfer
2254 2138 */
2255 2139 typedef struct usb_isoc_req {
2256 2140 /*
2257 2141 * Starting frame number will be set by the client driver in which
2258 2142 * to begin this request. This frame number is used to synchronize
2259 2143 * requests queued to different isochronous pipes. The frame number
2260 2144 * is optional and client driver can skip starting frame number by
2261 2145 * setting USB_ISOC_ATTRS_ASAP. In this case, HCD will decide starting
2262 2146 * frame number for this isochronous request. If this field is 0,
2263 2147 * then this indicates an invalid frame number.
2264 2148 */
2265 2149 usb_frame_number_t isoc_frame_no;
2266 2150
2267 2151 /*
2268 2152 * Number of isochronous data packets.
2269 2153 * The first field is set by client driver and may not exceed
2270 2154 * the maximum number of entries in the usb isochronous packet
2271 2155 * descriptors.
2272 2156 */
2273 2157 ushort_t isoc_pkts_count;
2274 2158
2275 2159 /*
2276 2160 * The sum of all pkt lengths in the isoc request. Recommend to
2277 2161 * set it to zero, so the sum of isoc_pkt_length in the
2278 2162 * isoc_pkt_descr list will be used automatically and no check
2279 2163 * will be apply to this element.
2280 2164 */
2281 2165 ushort_t isoc_pkts_length;
2282 2166
2283 2167 /*
2284 2168 * This field will be set by HCD and this field indicates the number
2285 2169 * of packets that completed with errors.
2286 2170 */
2287 2171 ushort_t isoc_error_count;
2288 2172
2289 2173 /*
2290 2174 * Attributes specific to particular usb isochronous request.
2291 2175 * Supported values are: USB_ATTRS_ISOC_START_FRAME,
2292 2176 * USB_ATTRS_ISOC_XFER_ASAP.
2293 2177 */
2294 2178 usb_req_attrs_t isoc_attributes;
2295 2179
2296 2180 /*
2297 2181 * Isochronous OUT:
2298 2182 * allocated and set by client driver, freed and zeroed by HCD
2299 2183 * on successful completion
2300 2184 * Isochronous IN:
2301 2185 * allocated and set by HCD, freed by client driver
2302 2186 */
2303 2187 mblk_t *isoc_data;
2304 2188
2305 2189 /*
2306 2190 * The client driver specific private information.
2307 2191 */
2308 2192 usb_opaque_t isoc_client_private;
2309 2193
2310 2194 /*
2311 2195 * Isochronous OUT:
2312 2196 * must be allocated & initialized by client driver
2313 2197 * Isochronous IN:
2314 2198 * must be allocated by client driver
2315 2199 */
2316 2200 struct usb_isoc_pkt_descr *isoc_pkt_descr;
2317 2201
2318 2202 /* Normal callback function (For synch transfers) */
2319 2203 void (*isoc_cb)(usb_pipe_handle_t ph,
2320 2204 struct usb_isoc_req *req);
2321 2205
2322 2206 /* Exception callback function (For asynch transfers) */
2323 2207 void (*isoc_exc_cb)(usb_pipe_handle_t ph,
2324 2208 struct usb_isoc_req *req);
2325 2209
2326 2210 /* set by USBA/HCD on completion */
2327 2211 usb_cr_t isoc_completion_reason; /* set by HCD */
2328 2212 /* Callback context / handling flgs */
2329 2213 usb_cb_flags_t isoc_cb_flags;
2330 2214 } usb_isoc_req_t;
2331 2215
2332 2216
2333 2217 /*
2334 2218 * Allocate/free usb isochronous resources
2335 2219 *
2336 2220 * isoc_pkts_count must be > 0
2337 2221 *
2338 2222 * Arguments:
2339 2223 * dip - client driver's devinfo pointer
2340 2224 * isoc_pkts_count - number of pkts required
2341 2225 * len - 0 or size of mblk to allocate
2342 2226 * flags - USB_FLAGS_SLEEP:
2343 2227 * wait for resources
2344 2228 *
2345 2229 * Return Values:
2346 2230 * usb_isoc_req pointer or NULL
2347 2231 */
2348 2232 usb_isoc_req_t *usb_alloc_isoc_req(
2349 2233 dev_info_t *dip,
2350 2234 uint_t isoc_pkts_count,
2351 2235 size_t len,
2352 2236 usb_flags_t flags);
2353 2237
2354 2238 void usb_free_isoc_req(
2355 2239 usb_isoc_req_t *usb_isoc_req);
2356 2240
2357 2241 /*
2358 2242 * Returns current usb frame number.
2359 2243 */
2360 2244 usb_frame_number_t usb_get_current_frame_number(
2361 2245 dev_info_t *dip);
2362 2246
2363 2247 /*
2364 2248 * Get maximum isochronous packets per usb isochronous request
2365 2249 */
2366 2250 uint_t usb_get_max_pkts_per_isoc_request(
2367 2251 dev_info_t *dip);
2368 2252
2369 2253 /*
2370 2254 * usb_pipe_isoc_xfer()
2371 2255 *
2372 2256 * Client drivers call this to issue the isoch xfer (IN and OUT) to the USBA
2373 2257 * which starts polling the device.
2374 2258 *
2375 2259 * Arguments:
2376 2260 * pipe_handle - isoc pipe handle (obtained via usb_pipe_open().
2377 2261 * reqp - pointer to the isochronous pipe IN xfer request
2378 2262 * allocated by the client driver.
2379 2263 * flags - USB_FLAGS_SLEEP:
2380 2264 * wait for the resources to be available.
2381 2265 *
2382 2266 * return values:
2383 2267 * USB_SUCCESS - success.
2384 2268 * USB_FAILURE - unspecified failure.
2385 2269 * USB_NO_RESOURCES - no resources.
2386 2270 * USB_NO_FRAME_NUMBER - START_FRAME, ASAP flags not specified.
2387 2271 * USB_INVALID_START_FRAME - Starting USB frame number invalid.
2388 2272 *
2389 2273 * Notes:
2390 2274 * - usb_pipe_isoc_xfer on an IN pipe that is already being polled is a NOP.
2391 2275 * - requests can be queued on an OUT pipe.
2392 2276 */
2393 2277 int usb_pipe_isoc_xfer(
2394 2278 usb_pipe_handle_t pipe_handle,
2395 2279 usb_isoc_req_t *reqp,
2396 2280 usb_flags_t flags);
2397 2281
2398 2282 /*
2399 2283 * usb_pipe_stop_isoc_polling():
2400 2284 *
2401 2285 * Client drivers call this function to stop the automatic data-in/out
2402 2286 * transfers without closing the isoc pipe.
2403 2287 *
2404 2288 * If USB_FLAGS_SLEEP has been specified then this function will block until
2405 2289 * polling has been stopped and all callbacks completed. If USB_FLAGS_SLEEP
2406 2290 * has NOT been specified then polling is terminated when the original
2407 2291 * request that started the polling has been returned with
2408 2292 * USB_CR_STOPPED_POLLING
2409 2293 *
2410 2294 * Stop polling should never fail.
2411 2295 *
2412 2296 * Arguments:
2413 2297 * pipe_handle - isoc pipe handle (obtained via usb_pipe_open().
2414 2298 * flags - USB_FLAGS_SLEEP:
2415 2299 * wait for polling to be stopped and all
2416 2300 * callbacks completed.
2417 2301 */
2418 2302 void usb_pipe_stop_isoc_polling(
2419 2303 usb_pipe_handle_t pipe_handle,
2420 2304 usb_flags_t flags);
2421 2305
2422 2306 /*
2423 2307 * ***************************************************************************
2424 2308 * USB device power management:
2425 2309 * ***************************************************************************
2426 2310 */
2427 2311
2428 2312 /*
2429 2313 *
2430 2314 * As any usb device will have a max of 4 possible power states
2431 2315 * the #define for them are provided below with mapping to the
2432 2316 * corresponding OS power levels.
2433 2317 */
2434 2318 #define USB_DEV_PWR_D0 USB_DEV_OS_FULL_PWR
2435 2319 #define USB_DEV_PWR_D1 5
2436 2320 #define USB_DEV_PWR_D2 6
2437 2321 #define USB_DEV_PWR_D3 USB_DEV_OS_PWR_OFF
2438 2322
2439 2323 #define USB_DEV_OS_PWR_0 0
2440 2324 #define USB_DEV_OS_PWR_1 1
2441 2325 #define USB_DEV_OS_PWR_2 2
2442 2326 #define USB_DEV_OS_PWR_3 3
2443 2327 #define USB_DEV_OS_PWR_OFF USB_DEV_OS_PWR_0
2444 2328 #define USB_DEV_OS_FULL_PWR USB_DEV_OS_PWR_3
2445 2329
2446 2330 /* Bit Masks for Power States */
2447 2331 #define USB_DEV_OS_PWRMASK_D0 1
2448 2332 #define USB_DEV_OS_PWRMASK_D1 2
2449 2333 #define USB_DEV_OS_PWRMASK_D2 4
2450 2334 #define USB_DEV_OS_PWRMASK_D3 8
2451 2335
2452 2336 /* conversion for OS to Dx levels */
2453 2337 #define USB_DEV_OS_PWR2USB_PWR(l) (USB_DEV_OS_FULL_PWR - (l))
2454 2338
2455 2339 /* from OS level to Dx mask */
2456 2340 #define USB_DEV_PWRMASK(l) (1 << (USB_DEV_OS_FULL_PWR - (l)))
2457 2341
2458 2342 /* Macro to check valid power level */
2459 2343 #define USB_DEV_PWRSTATE_OK(state, level) \
2460 2344 (((state) & USB_DEV_PWRMASK((level))) == 0)
2461 2345
2462 2346 int usb_handle_remote_wakeup(
2463 2347 dev_info_t *dip,
2464 2348 int cmd);
2465 2349
2466 2350 /* argument to usb_handle_remote wakeup function */
2467 2351 #define USB_REMOTE_WAKEUP_ENABLE 1
2468 2352 #define USB_REMOTE_WAKEUP_DISABLE 2
2469 2353
2470 2354 int usb_create_pm_components(
2471 2355 dev_info_t *dip,
2472 2356 uint_t *pwrstates);
2473 2357
2474 2358 /*
2475 2359 * ***************************************************************************
2476 2360 * System event registration
2477 2361 * ***************************************************************************
2478 2362 */
2479 2363
2480 2364 /* Functions for registering hotplug callback functions. */
2481 2365
2482 2366 int usb_register_hotplug_cbs(
2483 2367 dev_info_t *dip,
2484 2368 int (*disconnect_event_handler)(dev_info_t *dip),
2485 2369 int (*reconnect_event_handler)(dev_info_t *dip));
2486 2370
2487 2371 void usb_unregister_hotplug_cbs(dev_info_t *dip);
2488 2372
2489 2373 /*
2490 2374 * Reset_level determines the extent to which the device is reset,
2491 2375 * It has the following values:
2492 2376 *
2493 2377 * USB_RESET_LVL_REATTACH - The device is reset, the original driver is
2494 2378 * detached and a new driver attaching process
2495 2379 * is started according to the updated
2496 2380 * compatible name. This reset level applies to
2497 2381 * the firmware download with the descriptors
2498 2382 * changing, or other situations in which the
2499 2383 * device needs to be reenumerated.
2500 2384 *
2501 2385 * USB_RESET_LVL_DEFAULT - Default reset level. The device is reset, all
2502 2386 * error status is cleared, the device state
2503 2387 * machines and registers are also cleared and
2504 2388 * need to be reinitialized in the driver. The
2505 2389 * current driver remains attached. This reset
2506 2390 * level applies to hardware error recovery, or
2507 2391 * firmware download without descriptors
2508 2392 * changing.
2509 2393 */
2510 2394 typedef enum {
2511 2395 USB_RESET_LVL_REATTACH = 0,
2512 2396 USB_RESET_LVL_DEFAULT = 1
2513 2397 } usb_dev_reset_lvl_t;
2514 2398
2515 2399 /*
2516 2400 * usb_reset_device:
2517 2401 *
2518 2402 * Client drivers call this function to request hardware reset for themselves,
2519 2403 * which may be required in some situations such as:
2520 2404 *
2521 2405 * 1) Some USB devices need the driver to upload firmware into devices' RAM
2522 2406 * and initiate a hardware reset in order to activate the new firmware.
2523 2407 * 2) Hardware reset may help drivers to recover devices from an error state
2524 2408 * caused by physical or firmware defects.
2525 2409 *
2526 2410 * Arguments:
2527 2411 * dip - pointer to devinfo of the client
2528 2412 * reset_level - see above
2529 2413 *
2530 2414 * Return values:
2531 2415 * USB_SUCCESS - With USB_RESET_LVL_DEFAULT: the device was reset
2532 2416 * successfully.
2533 2417 * - With USB_RESET_LVL_REATTACH: reenumeration was
2534 2418 * started successfully or a previous reset is still
2535 2419 * in progress.
2536 2420 * USB_FAILURE - The state of the device's parent hub is invalid
2537 2421 * (disconnected or suspended).
2538 2422 * - Called when the driver being detached.
2539 2423 * - The device failed to be reset with
2540 2424 * USB_RESET_LVL_DEFAULT specified.
2541 2425 * - Reenumeration failed to start up with
2542 2426 * - USB_RESET_LVL_REATTACH specified.
2543 2427 * USB_INVALID_ARGS - Invalid arguments.
2544 2428 * USB_INVALID_PERM - The driver of the dip doesn't own entire device.
2545 2429 * USB_BUSY - One or more pipes other than the default control
2546 2430 * pipe are open on the device with
2547 2431 * USB_RESET_LVL_DEFAULT specified.
2548 2432 * USB_INVALID_CONTEXT - Called from interrupt context with
2549 2433 * USB_RESET_LVL_DEFAULT specified.
2550 2434 */
2551 2435
2552 2436 int usb_reset_device(
2553 2437 dev_info_t *dip,
2554 2438 usb_dev_reset_lvl_t reset_level);
2555 2439
2556 2440
2557 2441 /*
2558 2442 * **************************************************************************
2559 2443 * USB device driver registration and callback functions remaining
2560 2444 * Contracted Project Private (for VirtualBox USB Device Capture)
2561 2445 * **************************************************************************
2562 2446 */
2563 2447
2564 2448 /*
2565 2449 * getting the device strings of manufacturer, product and serial number
2566 2450 */
2567 2451 typedef struct usb_dev_str {
2568 2452 char *usb_mfg; /* manufacturer string */
2569 2453 char *usb_product; /* product string */
2570 2454 char *usb_serialno; /* serial number string */
2571 2455 } usb_dev_str_t;
2572 2456
2573 2457 /*
2574 2458 * It is the callback function type for capture driver.
2575 2459 * Arguments:
2576 2460 * dev_descr - pointer to device descriptor
2577 2461 * dev_str - pointer to device strings
2578 2462 * path - pointer to device physical path
2579 2463 * bus - USB bus address
2580 2464 * port - USB port number
2581 2465 * drv - capture driver name.
2582 2466 * It is returned by the callback func.
2583 2467 * Return Values:
2584 2468 * USB_SUCCESS - VirtualBox will capture the device
2585 2469 * USB_FAILURE - VirtualBox will not capture the device
2586 2470 */
2587 2471 typedef int (*usb_dev_driver_callback_t)(
2588 2472 usb_dev_descr_t *dev_descr,
2589 2473 usb_dev_str_t *dev_str,
2590 2474 char *path,
2591 2475 int bus,
2592 2476 int port,
2593 2477 char **drv,
2594 2478 void *reserved);
2595 2479
2596 2480 /*
2597 2481 * Register the callback function in the usba.
2598 2482 * Argument:
2599 2483 * dip - client driver's devinfo pointer
2600 2484 * cb - callback function
2601 2485 *
2602 2486 * Return Values:
2603 2487 * USB_SUCCESS - the registeration was successful
2604 2488 * USB_FAILURE - the registeration failed
2605 2489 */
2606 2490 int usb_register_dev_driver(
2607 2491 dev_info_t *dip,
2608 2492 usb_dev_driver_callback_t cb);
2609 2493
2610 2494 /*
2611 2495 * Unregister the callback function in the usba.
2612 2496 */
2613 2497 void usb_unregister_dev_driver(dev_info_t *dip);
2614 2498
2615 2499
2616 2500 /*
2617 2501 * ***************************************************************************
2618 2502 * USB Device and interface class, subclass and protocol codes
2619 2503 * ***************************************************************************
2620 2504 */
2621 2505
2622 2506 /*
2623 2507 * Available device and interface class codes.
2624 2508 * Those which are device class codes are noted.
2625 2509 */
2626 2510
2627 2511 #define USB_CLASS_AUDIO 1
2628 2512 #define USB_CLASS_COMM 2 /* Communication device class and */
2629 2513 #define USB_CLASS_CDC_CTRL 2 /* CDC-control iface class, also 2 */
2630 2514 #define USB_CLASS_HID 3
2631 2515 #define USB_CLASS_PHYSICAL 5
2632 2516 #define USB_CLASS_IMAGE 6
2633 2517 #define USB_CLASS_PRINTER 7
2634 2518 #define USB_CLASS_MASS_STORAGE 8
2635 2519 #define USB_CLASS_HUB 9 /* Device class */
2636 2520 #define USB_CLASS_CDC_DATA 10
2637 2521 #define USB_CLASS_CCID 11
2638 2522 #define USB_CLASS_SECURITY 13
2639 2523 #define USB_CLASS_VIDEO 14
2640 2524 #define USB_CLASS_DIAG 220 /* Device class */
2641 2525 #define USB_CLASS_WIRELESS 224
2642 2526 #define USB_CLASS_MISC 239 /* Device class */
2643 2527 #define USB_CLASS_APP 254
2644 2528 #define USB_CLASS_VENDOR_SPEC 255 /* Device class */
2645 2529
2646 2530 #define USB_CLASS_PER_INTERFACE 0 /* Class info is at interface level */
2647 2531
2648 2532 /* Audio subclass. */
2649 2533 #define USB_SUBCLS_AUD_CONTROL 0x01
2650 2534 #define USB_SUBCLS_AUD_STREAMING 0x02
2651 2535 #define USB_SUBCLS_AUD_MIDI_STREAMING 0x03
2652 2536
2653 2537 /* Comms subclass. */
2654 2538 #define USB_SUBCLS_CDCC_DIRECT_LINE 0x01
2655 2539 #define USB_SUBCLS_CDCC_ABSTRCT_CTRL 0x02
2656 2540 #define USB_SUBCLS_CDCC_PHONE_CTRL 0x03
2657 2541 #define USB_SUBCLS_CDCC_MULTCNL_ISDN 0x04
2658 2542 #define USB_SUBCLS_CDCC_ISDN 0x05
2659 2543 #define USB_SUBCLS_CDCC_ETHERNET 0x06
2660 2544 #define USB_SUBCLS_CDCC_ATM_NETWORK 0x07
2661 2545
2662 2546 /* HID subclass and protocols. */
2663 2547 #define USB_SUBCLS_HID_1 1
2664 2548
2665 2549 #define USB_PROTO_HID_KEYBOARD 0x01 /* legacy keyboard */
2666 2550 #define USB_PROTO_HID_MOUSE 0x02 /* legacy mouse */
2667 2551
2668 2552 /* Printer subclass and protocols. */
2669 2553 #define USB_SUBCLS_PRINTER_1 1
2670 2554
2671 2555 #define USB_PROTO_PRINTER_UNI 0x01 /* Unidirectional interface */
2672 2556 #define USB_PROTO_PRINTER_BI 0x02 /* Bidirectional interface */
2673 2557
2674 2558 /* Mass storage subclasses and protocols. */
2675 2559 #define USB_SUBCLS_MS_RBC_T10 0x1 /* flash */
2676 2560 #define USB_SUBCLS_MS_SFF8020I 0x2 /* CD-ROM */
2677 2561 #define USB_SUBCLS_MS_QIC_157 0x3 /* tape */
2678 2562 #define USB_SUBCLS_MS_UFI 0x4 /* USB Floppy Disk Drive */
2679 2563 #define USB_SUBCLS_MS_SFF8070I 0x5 /* floppy */
2680 2564 #define USB_SUBCLS_MS_SCSI 0x6 /* transparent scsi */
2681 2565
2682 2566 #define USB_PROTO_MS_CBI_WC 0x00 /* USB CBI Proto w/cmp intr */
2683 2567 #define USB_PROTO_MS_CBI 0x01 /* USB CBI Protocol */
2684 2568 #define USB_PROTO_MS_ISD_1999_SILICN 0x02 /* ZIP Protocol */
2685 2569 #define USB_PROTO_MS_BULK_ONLY 0x50 /* USB Bulk Only Protocol */
2686 2570
2687 2571 /* Application subclasses. */
2688 2572 #define USB_SUBCLS_APP_FIRMWARE 0x01 /* app spec f/w subclass */
2689 2573 #define USB_SUBCLS_APP_IRDA 0x02 /* app spec IrDa subclass */
2690 2574 #define USB_SUBCLS_APP_TEST 0x03 /* app spec test subclass */
2691 2575
2692 2576 /* Video subclasses */
2693 2577 #define USB_SUBCLS_VIDEO_CONTROL 0x01 /* video control */
2694 2578 #define USB_SUBCLS_VIDEO_STREAM 0x02 /* video stream */
2695 2579 #define USB_SUBCLS_VIDEO_COLLECTION 0x03 /* video interface collection */
2696 2580
2697 2581 /* Wireless controller subclasses and protocols, refer to WUSB 1.0 chapter 8 */
2698 2582 #define USB_SUBCLS_WUSB_1 0x01 /* RF controller */
2699 2583 #define USB_SUBCLS_WUSB_2 0x02 /* Wireless adapter */
2700 2584 #define USB_PROTO_WUSB_HWA 0x01 /* host wire adapter */
2701 2585 #define USB_PROTO_WUSB_DWA 0x02 /* device wire adapter */
2702 2586 #define USB_PROTO_WUSB_DWA_ISO 0x03 /* device wire adapter isoc */
2703 2587 #define USB_PROTO_WUSB_RC 0x02 /* UWB radio controller */
2704 2588
2705 2589 /* Association subclass and protocol, Association Model Supplement to WUSB1.0 */
2706 2590 #define USB_SUBCLS_CBAF 0x03 /* cable association */
2707 2591 #define USB_PROTO_CBAF 0x01 /* CBAF protocol */
2708 2592
2709 2593 /* Misc subclasses and protocols, refer to WUSB 1.0 chapter 8 */
2710 2594 #define USB_SUBCLS_MISC_COMMON 0x02 /* common class */
2711 2595 #define USB_PROTO_MISC_WA 0x02 /* multifunction wire adapter */
2712 2596
2713 2597 #ifdef __cplusplus
2714 2598 }
2715 2599 #endif
2716 2600
2717 2601 #endif /* _SYS_USB_USBAI_H */
↓ open down ↓ |
2013 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX