Changeset 375211d2 in mainline
- Timestamp:
- 2017-11-20T22:15:11Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6d91888
- Parents:
- 9162b27
- git-author:
- Aearsis <Hlavaty.Ondrej@…> (2017-11-20 22:13:54)
- git-committer:
- Aearsis <Hlavaty.Ondrej@…> (2017-11-20 22:15:11)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/hcd.c
r9162b27 r375211d2 67 67 * the first 8B of the device descriptor to determine it. 68 68 * 69 * @return Combined value of max_packet_size and scheduling oppertunities, 70 * see usb_standard_device_descriptor_t. 69 * @return Max packet size for EP 0 71 70 */ 72 71 int hcd_get_ep0_max_packet_size(uint16_t *mps, hcd_t *hcd, device_t *dev) 73 72 { 73 assert(mps); 74 74 75 static const uint16_t mps_fixed [] = { 75 76 [USB_SPEED_LOW] = 8, … … 92 93 GET_DEVICE_DESC(CTRL_PIPE_MIN_PACKET_SIZE); 93 94 94 usb_log_debug("Requesting first 8B of device descriptor .");95 usb_log_debug("Requesting first 8B of device descriptor to determine MPS."); 95 96 ssize_t got = hcd_send_batch_sync(hcd, dev, control_ep, USB_DIRECTION_IN, 96 97 (char *) &desc, CTRL_PIPE_MIN_PACKET_SIZE, *(uint64_t *)&get_device_desc_8, … … 103 104 } 104 105 105 *mps = uint16_usb2host(desc.max_packet_size); 106 if (desc.descriptor_type != USB_DESCTYPE_DEVICE) { 107 usb_log_error("The device responded with wrong device descriptor."); 108 return EIO; 109 } 110 111 uint16_t version = uint16_usb2host(desc.usb_spec_version); 112 if (version < 0x0300) { 113 /* USB 2 and below have MPS raw in the field */ 114 *mps = desc.max_packet_size; 115 } else { 116 /* USB 3 have MPS as an 2-based exponent */ 117 *mps = (1 << desc.max_packet_size); 118 } 106 119 return EOK; 107 120 }
Note:
See TracChangeset
for help on using the changeset viewer.