| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/usb/usb_device_impl.h" | 5 #include "device/usb/usb_device_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 case LIBUSB_ENDPOINT_OUT: | 50 case LIBUSB_ENDPOINT_OUT: |
| 51 return USB_DIRECTION_OUTBOUND; | 51 return USB_DIRECTION_OUTBOUND; |
| 52 default: | 52 default: |
| 53 NOTREACHED(); | 53 NOTREACHED(); |
| 54 return USB_DIRECTION_INBOUND; | 54 return USB_DIRECTION_INBOUND; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 UsbSynchronizationType GetSynchronizationType( | 58 UsbSynchronizationType GetSynchronizationType( |
| 59 const libusb_endpoint_descriptor* descriptor) { | 59 const libusb_endpoint_descriptor* descriptor) { |
| 60 switch (descriptor->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) { | 60 switch ((descriptor->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) >> 2) { |
| 61 case LIBUSB_ISO_SYNC_TYPE_NONE: | 61 case LIBUSB_ISO_SYNC_TYPE_NONE: |
| 62 return USB_SYNCHRONIZATION_NONE; | 62 return USB_SYNCHRONIZATION_NONE; |
| 63 case LIBUSB_ISO_SYNC_TYPE_ASYNC: | 63 case LIBUSB_ISO_SYNC_TYPE_ASYNC: |
| 64 return USB_SYNCHRONIZATION_ASYNCHRONOUS; | 64 return USB_SYNCHRONIZATION_ASYNCHRONOUS; |
| 65 case LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: | 65 case LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: |
| 66 return USB_SYNCHRONIZATION_ADAPTIVE; | 66 return USB_SYNCHRONIZATION_ADAPTIVE; |
| 67 case LIBUSB_ISO_SYNC_TYPE_SYNC: | 67 case LIBUSB_ISO_SYNC_TYPE_SYNC: |
| 68 return USB_SYNCHRONIZATION_SYNCHRONOUS; | 68 return USB_SYNCHRONIZATION_SYNCHRONOUS; |
| 69 default: | 69 default: |
| 70 NOTREACHED(); | 70 NOTREACHED(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 82 return USB_TRANSFER_BULK; | 82 return USB_TRANSFER_BULK; |
| 83 case LIBUSB_TRANSFER_TYPE_INTERRUPT: | 83 case LIBUSB_TRANSFER_TYPE_INTERRUPT: |
| 84 return USB_TRANSFER_INTERRUPT; | 84 return USB_TRANSFER_INTERRUPT; |
| 85 default: | 85 default: |
| 86 NOTREACHED(); | 86 NOTREACHED(); |
| 87 return USB_TRANSFER_CONTROL; | 87 return USB_TRANSFER_CONTROL; |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 UsbUsageType GetUsageType(const libusb_endpoint_descriptor* descriptor) { | 91 UsbUsageType GetUsageType(const libusb_endpoint_descriptor* descriptor) { |
| 92 switch (descriptor->bmAttributes & LIBUSB_ISO_USAGE_TYPE_MASK) { | 92 switch ((descriptor->bmAttributes & LIBUSB_ISO_USAGE_TYPE_MASK) >> 4) { |
| 93 case LIBUSB_ISO_USAGE_TYPE_DATA: | 93 case LIBUSB_ISO_USAGE_TYPE_DATA: |
| 94 return USB_USAGE_DATA; | 94 return USB_USAGE_DATA; |
| 95 case LIBUSB_ISO_USAGE_TYPE_FEEDBACK: | 95 case LIBUSB_ISO_USAGE_TYPE_FEEDBACK: |
| 96 return USB_USAGE_FEEDBACK; | 96 return USB_USAGE_FEEDBACK; |
| 97 case LIBUSB_ISO_USAGE_TYPE_IMPLICIT: | 97 case LIBUSB_ISO_USAGE_TYPE_IMPLICIT: |
| 98 return USB_USAGE_EXPLICIT_FEEDBACK; | 98 return USB_USAGE_EXPLICIT_FEEDBACK; |
| 99 default: | 99 default: |
| 100 NOTREACHED(); | 100 NOTREACHED(); |
| 101 return USB_USAGE_DATA; | 101 return USB_USAGE_DATA; |
| 102 } | 102 } |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 399 } |
| 400 } else { | 400 } else { |
| 401 VLOG(1) << "Failed to read device descriptor to cache string descriptors: " | 401 VLOG(1) << "Failed to read device descriptor to cache string descriptors: " |
| 402 << ConvertPlatformUsbErrorToString(rv); | 402 << ConvertPlatformUsbErrorToString(rv); |
| 403 } | 403 } |
| 404 strings_cached_ = true; | 404 strings_cached_ = true; |
| 405 } | 405 } |
| 406 #endif // !defined(USE_UDEV) | 406 #endif // !defined(USE_UDEV) |
| 407 | 407 |
| 408 } // namespace device | 408 } // namespace device |
| OLD | NEW |