1 /*---------------------------------------------------------------------------* 2 Project: USB Host Stack (UHS) 3 File: uhs_types.h 4 Description: Core public data types 5 6 Copyright (C) 2011 Nintendo. All rights reserved. 7 8 These coded instructions, statements, and computer programs contain 9 proprietary information of Nintendo of America Inc. and/or Nintendo 10 Company Ltd., and are protected by Federal copyright law. They may 11 not be disclosed to third parties or copied or duplicated in any form, 12 in whole or in part, without the prior written consent of Nintendo. 13 14 *---------------------------------------------------------------------------*/ 15 #ifndef __UHS_TYPES_H__ 16 #define __UHS_TYPES_H__ 17 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /*---------------------------------------------------------------------------* 24 * 25 * Constants defined for this file 26 * -- #Defines -- 27 * 28 *---------------------------------------------------------------------------*/ 29 /* Per device EP counts, reflecting standard USB architecture */ 30 #define UHS_MAX_ENDPOINTS 32 31 #define UHS_MAX_ENDPOINT_PAIRS 16 32 #define UHS_MAX_USER_ENDPOINT_PAIRS (UHS_MAX_ENDPOINT_PAIRS-1) 33 34 /* These are upper limits imposed by UHS; we must define some upper limit making 35 it high enough to satisfy all. */ 36 #define UHS_MAX_CONFIGURATIONS_PER_DEVICE 32 37 #define UHS_MAX_INTERFACES_PER_CONFIGURATION 32 38 #define UHS_MAX_ALT_INTERFACE_SETTINGS 64 39 #define UHS_MAX_DEVICE_MANUFACTURER_DESCRIPTION_SIZE 64 40 #define UHS_MAX_DEVICE_PRODUCT_DESCRIPTION_SIZE 64 41 #define UHS_MAX_DEVICE_SERIAL_NUMBER_DESCRIPTION_SIZE 64 42 #define UHS_MAX_INTERFACE_DESCRIPTION_SIZE 64 43 #define UHS_MAX_TRANSACTIONS_PER_CLIENT 64 44 45 /* Maximum number of class driver registrations that a specific 46 client is allowed to submit. */ 47 #define UHS_MAX_CLIENT_CLASS_DRV_REGISTRATIONS 16 48 49 /* Maximum number of USB interfaces that a specific client is 50 allowed to own */ 51 #define UHS_MAX_CLIENT_INTERFACES 32 52 53 /* Maximum number of stacked hubs guaranteed to be supported */ 54 #define UHS_MAX_HUB_HIERARCHY 8 55 56 /* Maximum number of URBs that may be submitted to any one endpoint */ 57 #define UHS_MAX_URBS_PER_ENDPOINT 256 58 59 /* Maximum contiguous transfer size allowed by a single URB */ 60 #define UHS_MAX_URB_XFER_SIZE 0x10000000 61 62 /* Maximum number of devices that may be returned via UhsQueryInterfaces(), 63 for sanity */ 64 #define UHS_MAX_QUERIED_INTERFACES 1000 65 66 /* Special flag for UhsTime to indicate infinite */ 67 #define UHS_TIME_FOREVER -1 68 69 /* Flag for indicating invalid port number */ 70 #define UHS_HUB_PORT_NUMBER_INVALID 0 71 72 /* Macro for constructing UhsEndpointMask */ 73 #define UHS_MAKE_EP_OUT_MASK(endpointNumber) (1 << ((endpointNumber))) 74 #define UHS_MAKE_EP_IN_MASK(endpointNumber) (1 << ((endpointNumber)+16)) 75 76 /*---------------------------------------------------------------------------* 77 * 78 * Data types defined for this file 79 * -- Structs, Typedefs, Enums -- 80 * 81 *---------------------------------------------------------------------------*/ 82 typedef s32 UhsStatus; 83 typedef s32 UhsDevRegHandle; 84 typedef s32 UhsInterfaceHandle; 85 typedef s32 UhsClientHandle; 86 typedef void* UhsClientContext; 87 typedef u32 UhsEndpointMask; 88 typedef s8 UhsEndpointNumber; 89 typedef u32 UhsEndpointOptions; 90 typedef u32 UhsDeviceOptions; 91 typedef s32 UhsTime; 92 typedef s16 UhsHubPortNum; 93 typedef u32 UhsDeviceUid; 94 95 typedef enum { 96 UHS_DEVICE_SPEED_INVALID = 0, 97 UHS_DEVICE_SPEED_LOW, /* USB 1.1 */ 98 UHS_DEVICE_SPEED_FULL, /* USB 1.1 */ 99 UHS_DEVICE_SPEED_HIGH /* USB 2.0 */ 100 }UhsDeviceSpeed; 101 102 typedef enum { 103 UHS_EP_CMD_INVALID, 104 UHS_EP_CMD_ENABLE, 105 UHS_EP_CMD_DISABLE, 106 UHS_EP_CMD_CANCEL, 107 UHS_EP_CMD_CANCEL_AND_RESET, 108 }UhsEpCommandType; 109 110 /* for backward compatibility */ 111 #define UHS_EP_CMD_RESET UHS_EP_CMD_CANCEL 112 113 typedef enum { 114 UHS_DEV_CMD_INVALID, 115 UHS_DEV_CMD_RESET, 116 UHS_DEV_CMD_DISABLE, 117 UHS_DEV_CMD_SUSPEND, 118 UHS_DEV_CMD_RESUME, 119 UHS_DEV_CMD_DESTROY 120 }UhsDeviceCommandType; 121 122 typedef enum { 123 UHS_EP_TYPE_INVALID, 124 UHS_EP_TYPE_CONTROL, 125 UHS_EP_TYPE_ISOC, 126 UHS_EP_TYPE_BULK, 127 UHS_EP_TYPE_INTERRUPT 128 }UhsEpType; 129 130 typedef enum { 131 UHS_DEV_POWER_MANAGEMENT_STATE_INVALID, 132 UHS_DEV_POWER_MANAGEMENT_STATE_SUSPENDED, 133 UHS_DEV_POWER_MANAGEMENT_STATE_RESUMED 134 }UhsDevicePowerManagementState; 135 136 /* UhsEndpointOptions definitions */ 137 #define UHS_EP_OPTION_NONE 0x00000000 138 #define UHS_EP_OPTION_PRESERVE_MAX_LIMITS 0x00000001 139 140 /* Public UhsDeviceOptions definitions */ 141 #define UHS_DEV_OPTION_NONE 0x00000000 142 #define UHS_DEV_OPTION_UNCONDITIONAL 0x00000001 143 144 /* USB directions, used in endpoint descriptor bEndpointAddress field 145 and in control requests bRequestType. */ 146 typedef enum { 147 UHS_DIRECTION_INVALID, 148 UHS_DIRECTION_TO_DEVICE, /* "out" */ 149 UHS_DIRECTION_TO_HOST /* "in" */ 150 }UhsDirection; 151 152 PACKED_STRUCT_BEGIN 153 /* 154 * Identification of USB devices for probing and hotplugging 155 * matchFlags: Bit mask controlling which fields below are used to match 156 * against new devices. 157 * idVendor: USB vendor ID for a device; numbers are assigned 158 * by the USB forum to its members. 159 * idProduct: Vendor-assigned product ID. 160 * bcdDeviceLo: Low end of range of vendor-assigned product version numbers. 161 * This is also used to identify individual product versions, for 162 * a range consisting of a single device. 163 * bcdDeviceHi: High end of version number range. The range of product 164 * versions is inclusive. 165 * bDeviceClass: Class of device 166 * bDeviceSubClass: Subclass of device, associated with bDeviceClass. 167 * bDeviceProtocol: Protocol of device, associated with bDeviceClass. 168 * bInterfaceClass: Class of interface 169 * bInterfaceSubClass: Subclass of interface, associated with bInterfaceClass. 170 * bInterfaceProtocol: Protocol of interface, associated with bInterfaceClass. 171 * driverInfo: Holds information used by the driver. Usually it holds 172 * a pointer to a descriptor understood by the driver, or perhaps 173 * device flags. 174 */ 175 typedef struct { 176 /* which fields to match against? */ 177 u16 matchFlags; 178 179 /* Used for product specific matches; range is inclusive */ 180 u16 idVendor; 181 u16 idProduct; 182 u16 bcdDeviceLo; 183 u16 bcdDeviceHi; 184 185 /* Used for device class matches */ 186 u8 bDeviceClass; 187 u8 bDeviceSubClass; 188 u8 bDeviceProtocol; 189 190 /* Used for interface class matches */ 191 u8 bInterfaceClass; 192 u8 bInterfaceSubClass; 193 u8 bInterfaceProtocol; 194 }PACKED_STRUCT_ATTRIBUTE UhsDeviceId; 195 196 #define UHS_INVALID_DEVICE_ID {0,0,0,0,0,0,0,0,0,0,0} 197 198 /* matchFlags bitmask */ 199 #define UHS_DEVICE_ID_MATCH_VENDOR 0x0001 200 #define UHS_DEVICE_ID_MATCH_PRODUCT 0x0002 201 #define UHS_DEVICE_ID_MATCH_DEV_LO 0x0004 202 #define UHS_DEVICE_ID_MATCH_DEV_HI 0x0008 203 #define UHS_DEVICE_ID_MATCH_DEV_CLASS 0x0010 204 #define UHS_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020 205 #define UHS_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040 206 #define UHS_DEVICE_ID_MATCH_INT_CLASS 0x0080 207 #define UHS_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100 208 #define UHS_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 209 #define UHS_DEVICE_ID_WILDCARD 0 210 211 212 /* 213 * Interfaces are presented to prospective drivers using this 214 * structure, which provides device, interface and endpoint information 215 */ 216 typedef struct { 217 /* handle associated with this specific device interface */ 218 UhsInterfaceHandle ifHandle; 219 220 /* speed of device interface */ 221 UhsDeviceSpeed devSpeed; 222 223 /* console port information */ 224 s32 hcGroup; 225 s32 hcIndex; 226 UhsHubPortNum port[UHS_MAX_HUB_HIERARCHY]; 227 228 /* unique device id, providing a way for a class driver to know 229 if multiple interfaces belong to the same physical device */ 230 UhsDeviceUid deviceUid; 231 232 /* number of alternate settings offered by this interface */ 233 s32 altSettings; 234 235 /* standard descriptors */ 236 UhsDeviceDescriptor devDescriptor; 237 UhsConfigDescriptor cfgDescriptor; 238 UhsInterfaceDescriptor ifDescriptor; 239 240 /* Index corresponds with endpoint number in bEndpointAddress. Index '0' is not 241 valid (as it is managed by the core host stack) but it is instantiated in these 242 arrays that that the index corresponds directly with endpoint number. */ 243 UhsEndpointDescriptor epInDescriptors[UHS_MAX_ENDPOINT_PAIRS]; 244 UhsEndpointDescriptor epOutDescriptors[UHS_MAX_ENDPOINT_PAIRS]; 245 246 }PACKED_STRUCT_ATTRIBUTE UhsInterfaceProfile; 247 248 typedef enum { 249 UHS_INTERFACE_INVALID_INDICATION, 250 UHS_INTERFACE_SUSPEND_INDICATION, 251 UHS_INTERFACE_RESUME_INDICATION, 252 UHS_INTERFACE_PROBE_INDICATION, 253 UHS_INTERFACE_DISCONNECT_INDICATION 254 }UhsInterfaceIndication; 255 256 #define UHS_INTERFACE_INDICATION_NAMES \ 257 {"UHS_INTERFACE_INVALID_INDICATION","UHS_INTERFACE_SUSPEND_INDICATION","UHS_INTERFACE_RESUME_INDICATION",\ 258 "UHS_INTERFACE_PROBE_INDICATION","UHS_INTERFACE_DISCONNECT_INDICATION"} 259 260 261 #define MAX_NUM_ISOC_FRAMES 32 262 263 typedef enum { 264 UHS_ISOC_START_TYPE_ABSOLUTE, 265 UHS_ISOC_START_TYPE_RELATIVE, 266 UHS_ISOC_START_TYPE_CONTINUE 267 } UhsIsocStartType; 268 269 typedef struct { 270 /* to be filled in when API is invoked */ 271 u32 bufSize; 272 273 /* fields populated by UHS when transaction completes */ 274 UhsStatus status; 275 u32 xferSize; 276 }PACKED_STRUCT_ATTRIBUTE UhsIsocFrameElement; 277 278 typedef struct { 279 u32 numberOfFrames; 280 void* pBuffer; 281 u32 totalBufSize; 282 UhsIsocFrameElement frames[MAX_NUM_ISOC_FRAMES]; 283 }PACKED_STRUCT_ATTRIBUTE UhsIsocPayload; 284 285 PACKED_STRUCT_END 286 287 /*---------------------------------------------------------------------------* 288 * 289 * -- Async API Callbacks Prototypes -- 290 * 291 *---------------------------------------------------------------------------*/ 292 typedef void (*UhsControlUrbCompletionCallback)(UhsClientContext clientContext, 293 UhsStatus status, 294 UhsInterfaceHandle ifHandle, 295 u8 bRequest, 296 u8 bRequestType, 297 u16 wValue, 298 u16 wIndex, 299 void* pData, 300 u32 xferSize); 301 typedef void (*UhsInterruptUrbCompletionCallback)(UhsClientContext clientContext, 302 UhsStatus status, 303 UhsInterfaceHandle ifHandle, 304 UhsEndpointNumber epNumber, 305 UhsDirection direction, 306 void* pData, 307 u32 xferSize); 308 typedef void (*UhsBulkUrbCompletionCallback)(UhsClientContext clientContext, 309 UhsStatus status, 310 UhsInterfaceHandle ifHandle, 311 UhsEndpointNumber epNumber, 312 UhsDirection direction, 313 void* pData, 314 u32 xferSize); 315 typedef void (*UhsIsocUrbCompletionCallback)(UhsClientContext clientContext, 316 UhsStatus status, 317 UhsInterfaceHandle ifHandle, 318 UhsEndpointNumber epNumber, 319 UhsDirection direction, 320 void* pData, 321 u32 numEntries, 322 UhsIsocFrameElement* isocFrameData); 323 typedef void (*UhsIfProbeFunction)(UhsClientContext clientContext, 324 UhsInterfaceProfile* pIfProfile); 325 typedef void (*UhsIfIndicationFunction)(UhsClientContext clientContext, 326 UhsInterfaceHandle ifHandle, 327 UhsInterfaceIndication ifIndication); 328 329 /*---------------------------------------------------------------------------* 330 * 331 * -- in-line helper functions for use with UHS API -- 332 * 333 *---------------------------------------------------------------------------*/ 334 335 /** 336 * uhs_endpoint_num - get the endpoint's number 337 * @epd: endpoint to be checked 338 * 339 * Returns @epd's number: 0 to 15. 340 */ uhs_endpoint_num(const UhsEndpointDescriptor * epd)341 static inline int uhs_endpoint_num(const UhsEndpointDescriptor *epd) 342 { 343 return epd->bEndpointAddress & UHS_ENDPOINT_NUMBER_MASK; 344 } 345 346 /** 347 * uhs_endpoint_dir_in - check if the endpoint has IN direction 348 * @epd: endpoint to be checked 349 * 350 * Returns TRUE if the endpoint is of type IN, otherwise it 351 * returns FALSE. 352 */ uhs_endpoint_dir_in(const UhsEndpointDescriptor * epd)353 static inline BOOL uhs_endpoint_dir_in(const UhsEndpointDescriptor *epd) 354 { 355 return((epd->bEndpointAddress & UHS_ENDPOINT_DIR_MASK) == UHS_DIR_IN) ? TRUE : FALSE; 356 } 357 358 /** 359 * uhs_endpoint_dir_out - check if the endpoint has OUT direction 360 * @epd: endpoint to be checked 361 * 362 * Returns TRUE if the endpoint is of type OUT, otherwise it 363 * returns FALSE. 364 */ uhs_endpoint_dir_out(const UhsEndpointDescriptor * epd)365 static inline BOOL uhs_endpoint_dir_out(const UhsEndpointDescriptor *epd) 366 { 367 return((epd->bEndpointAddress & UHS_ENDPOINT_DIR_MASK) == UHS_DIR_OUT) ? TRUE : FALSE; 368 } 369 370 /** 371 * uhs_endpoint_address - form an endpoint address 372 * @epNumber: endpoint number 373 * @direction: direction of endpoint 374 * 375 * Returns endpoint address. 376 */ uhs_endpoint_address(UhsEndpointNumber epNumber,UhsDirection direction)377 static inline u8 uhs_endpoint_address(UhsEndpointNumber epNumber, 378 UhsDirection direction) 379 { 380 u8 bEndpointAddress = (u8)((epNumber<<UHS_ENDPOINT_NUMBER_SHIFT) & 381 UHS_ENDPOINT_NUMBER_MASK); 382 if (direction==UHS_DIRECTION_TO_HOST) { 383 bEndpointAddress |= (UHS_ENDPOINT_DIR_IN<<UHS_ENDPOINT_DIR_SHIFT); 384 } else { 385 bEndpointAddress |= (UHS_ENDPOINT_DIR_OUT<<UHS_ENDPOINT_DIR_SHIFT); 386 } 387 return bEndpointAddress; 388 } 389 390 /** 391 * uhs_endpoint_xfer_bulk - check if the endpoint has bulk transfer type 392 * @epd: endpoint to be checked 393 * 394 * Returns TRUE if the endpoint is of type bulk, otherwise it 395 * returns FALSE. 396 */ uhs_endpoint_xfer_bulk(const UhsEndpointDescriptor * epd)397 static inline BOOL uhs_endpoint_xfer_bulk(const UhsEndpointDescriptor *epd) 398 { 399 return((epd->bmAttributes & UHS_ENDPOINT_XFERTYPE_MASK) == 400 UHS_ENDPOINT_XFER_BULK) ? TRUE : FALSE; 401 } 402 403 /** 404 * uhs_endpoint_xfer_control - check if the endpoint has control transfer type 405 * @epd: endpoint to be checked 406 * 407 * Returns TRUE if the endpoint is of type control, otherwise it 408 * returns FALSE. 409 */ uhs_endpoint_xfer_control(const UhsEndpointDescriptor * epd)410 static inline BOOL uhs_endpoint_xfer_control(const UhsEndpointDescriptor *epd) 411 { 412 return((epd->bmAttributes & UHS_ENDPOINT_XFERTYPE_MASK) == 413 UHS_ENDPOINT_XFER_CONTROL) ? TRUE : FALSE; 414 } 415 416 /** 417 * uhs_endpoint_xfer_int - check if the endpoint has interrupt transfer type 418 * @epd: endpoint to be checked 419 * 420 * Returns TRUE if the endpoint is of type interrupt, otherwise 421 * it returns FALSE. 422 */ uhs_endpoint_xfer_int(const UhsEndpointDescriptor * epd)423 static inline BOOL uhs_endpoint_xfer_int(const UhsEndpointDescriptor *epd) 424 { 425 return((epd->bmAttributes & UHS_ENDPOINT_XFERTYPE_MASK) == 426 UHS_ENDPOINT_XFER_INT); 427 } 428 429 /** 430 * uhs_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type 431 * @epd: endpoint to be checked 432 * 433 * Returns TRUE if the endpoint is of type isochronous, 434 * otherwise it returns FALSE. 435 */ uhs_endpoint_xfer_isoc(const UhsEndpointDescriptor * epd)436 static inline BOOL uhs_endpoint_xfer_isoc(const UhsEndpointDescriptor *epd) 437 { 438 return((epd->bmAttributes & UHS_ENDPOINT_XFERTYPE_MASK) == 439 UHS_ENDPOINT_XFER_ISOC) ? TRUE : FALSE; 440 } 441 442 /** 443 * uhs_endpoint_is_bulk_in - check if the endpoint is bulk IN 444 * @epd: endpoint to be checked 445 * 446 * Returns TRUE if the endpoint has bulk transfer type and IN 447 * direction, otherwise it returns FALSE. 448 */ uhs_endpoint_is_bulk_in(const UhsEndpointDescriptor * epd)449 static inline BOOL uhs_endpoint_is_bulk_in(const UhsEndpointDescriptor *epd) 450 { 451 return uhs_endpoint_xfer_bulk(epd) && uhs_endpoint_dir_in(epd); 452 } 453 454 /** 455 * uhs_endpoint_is_bulk_out - check if the endpoint is bulk OUT 456 * @epd: endpoint to be checked 457 * 458 * Returns TRUE if the endpoint has bulk transfer type and OUT 459 * direction, otherwise it returns FALSE. 460 */ uhs_endpoint_is_bulk_out(const UhsEndpointDescriptor * epd)461 static inline BOOL uhs_endpoint_is_bulk_out(const UhsEndpointDescriptor *epd) 462 { 463 return uhs_endpoint_xfer_bulk(epd) && uhs_endpoint_dir_out(epd); 464 } 465 466 /** 467 * uhs_endpoint_is_int_in - check if the endpoint is interrupt IN 468 * @epd: endpoint to be checked 469 * 470 * Returns TRUE if the endpoint has interrupt transfer type and 471 * IN direction, otherwise it returns FALSE. 472 */ uhs_endpoint_is_int_in(const UhsEndpointDescriptor * epd)473 static inline BOOL uhs_endpoint_is_int_in(const UhsEndpointDescriptor *epd) 474 { 475 return uhs_endpoint_xfer_int(epd) && uhs_endpoint_dir_in(epd); 476 } 477 478 /** 479 * uhs_endpoint_is_int_out - check if the endpoint is interrupt OUT 480 * @epd: endpoint to be checked 481 * 482 * Returns TRUE if the endpoint has interrupt transfer type and 483 * OUT direction, otherwise it returns FALSE. 484 */ uhs_endpoint_is_int_out(const UhsEndpointDescriptor * epd)485 static inline BOOL uhs_endpoint_is_int_out(const UhsEndpointDescriptor *epd) 486 { 487 return uhs_endpoint_xfer_int(epd) && uhs_endpoint_dir_out(epd); 488 } 489 490 /** 491 * uhs_endpoint_is_isoc_in - check if the endpoint is isochronous IN 492 * @epd: endpoint to be checked 493 * 494 * Returns TRUE if the endpoint has isochronous transfer type 495 * and IN direction, otherwise it returns FALSE. 496 */ uhs_endpoint_is_isoc_in(const UhsEndpointDescriptor * epd)497 static inline BOOL uhs_endpoint_is_isoc_in(const UhsEndpointDescriptor *epd) 498 { 499 return uhs_endpoint_xfer_isoc(epd) && uhs_endpoint_dir_in(epd); 500 } 501 502 /** 503 * uhs_endpoint_is_isoc_out - check if the endpoint is isochronous OUT 504 * @epd: endpoint to be checked 505 * 506 * Returns TRUE if the endpoint has isochronous transfer type 507 * and OUT direction, otherwise it returns FALSE. 508 */ uhs_endpoint_is_isoc_out(const UhsEndpointDescriptor * epd)509 static inline BOOL uhs_endpoint_is_isoc_out(const UhsEndpointDescriptor *epd) 510 { 511 return uhs_endpoint_xfer_isoc(epd) && uhs_endpoint_dir_out(epd); 512 } 513 514 /** 515 * uhs_endpoint_mask - get the endpoint's mask, a logical representation 516 * used by UHS API 517 * @epd: endpoint to be checked 518 * 519 * Returns @epd's mask of type UhsEndpointMask. 520 */ uhs_endpoint_mask(const UhsEndpointDescriptor * epd)521 static inline UhsEndpointMask uhs_endpoint_mask(const UhsEndpointDescriptor *epd) 522 { 523 if (uhs_endpoint_dir_in(epd)) { 524 return(1 << (uhs_endpoint_num(epd)+16)); 525 } else { 526 return(1 << uhs_endpoint_num(epd)); 527 } 528 } 529 530 /** 531 * uhs_endpoint_direction - get the endpoint's direction, a 532 * logical representation used by UHS API 533 * @epd: endpoint to be checked 534 * 535 * Returns @epd's direction of type UhsDirection. 536 */ uhs_endpoint_direction(const UhsEndpointDescriptor * epd)537 static inline UhsDirection uhs_endpoint_direction(const UhsEndpointDescriptor *epd) 538 { 539 if (uhs_endpoint_dir_in(epd)) { 540 return UHS_DIRECTION_TO_HOST; 541 } else { 542 return UHS_DIRECTION_TO_DEVICE; 543 } 544 } 545 546 /** 547 * uhs_endpoint_type - get the endpoint's transfer type 548 * @epd: endpoint to be checked 549 * 550 * Returns value of type UhsEpType. 551 */ uhs_endpoint_type(const UhsEndpointDescriptor * epd)552 static inline UhsEpType uhs_endpoint_type(const UhsEndpointDescriptor *epd) 553 { 554 UhsEpType epType=UHS_EP_TYPE_INVALID; 555 switch (epd->bmAttributes & UHS_ENDPOINT_XFERTYPE_MASK) { 556 case UHS_ENDPOINT_XFER_CONTROL: 557 epType=UHS_EP_TYPE_CONTROL; 558 break; 559 case UHS_ENDPOINT_XFER_ISOC: 560 epType=UHS_EP_TYPE_ISOC; 561 break; 562 case UHS_ENDPOINT_XFER_BULK: 563 epType=UHS_EP_TYPE_BULK; 564 break; 565 case UHS_ENDPOINT_XFER_INT: 566 epType=UHS_EP_TYPE_INTERRUPT; 567 break; 568 default: 569 break; 570 } 571 return epType; 572 } 573 574 575 /** 576 * uhs_endpoint_is_valid - determine whether specified endpoint 577 * descriptor is valid 578 * @epd: endpoint to be checked 579 * 580 * Returns value of type BOOL. 581 */ uhs_endpoint_is_valid(const UhsEndpointDescriptor * epd)582 static inline BOOL uhs_endpoint_is_valid(const UhsEndpointDescriptor *epd) 583 { 584 BOOL valid=FALSE; 585 if ((epd->bLength>=UHS_DT_ENDPOINT_SIZE) && 586 (epd->bEndpointAddress!=0)) { 587 valid=TRUE; 588 } 589 return valid; 590 } 591 592 /** 593 * uhs_mark_endpoint_invalid - marks an endpoint as being 594 * "invalid" 595 * @epd: endpoint to be marked invalid 596 * 597 * Returns nothing. 598 */ uhs_mark_endpoint_invalid(UhsEndpointDescriptor * epd)599 static inline void uhs_mark_endpoint_invalid(UhsEndpointDescriptor *epd) 600 { 601 epd->bLength=0; 602 epd->bEndpointAddress=0; 603 } 604 605 #ifdef __cplusplus 606 } 607 #endif 608 609 #endif // __UHS_TYPES_H__ 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631