Changeset 6271a34 in mainline for uspace/lib/usbhost/src/utility.c
- Timestamp:
- 2018-01-20T18:21:39Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2aaba7e
- Parents:
- 51c1d500
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/utility.c
r51c1d500 r6271a34 42 42 #include "utility.h" 43 43 44 45 /** 46 * Get max packet size for the control endpoint 0. 47 * 48 * For LS, HS, and SS devices this value is fixed. For FS devices we must fetch 49 * the first 8B of the device descriptor to determine it. 50 * 51 * @return Max packet size for EP 0 52 */ 53 int hc_get_ep0_max_packet_size(uint16_t *mps, bus_t *bus, device_t *dev) 54 { 55 assert(mps); 56 44 /** 45 * Get initial max packet size for the control endpoint 0. 46 * 47 * For LS, HS, and SS devices this value is final and fixed. 48 * For FS devices, the default value of 8 is returned. The caller needs 49 * to fetch the first 8B of the device descriptor later in the initialization 50 * process and determine whether it should be increased. 51 * 52 * @return Max packet size for EP 0 (in bytes) 53 */ 54 uint16_t hc_get_ep0_initial_mps(usb_speed_t speed) 55 { 57 56 static const uint16_t mps_fixed [] = { 58 57 [USB_SPEED_LOW] = 8, … … 61 60 }; 62 61 63 if (dev->speed < ARRAY_SIZE(mps_fixed) && mps_fixed[dev->speed] != 0) { 64 *mps = mps_fixed[dev->speed]; 62 if (speed < ARRAY_SIZE(mps_fixed) && mps_fixed[speed] != 0) { 63 return mps_fixed[speed]; 64 } 65 return 8; // USB_SPEED_FULL default 66 } 67 68 /** 69 * Get max packet size for the control endpoint 0. 70 * 71 * For LS, HS, and SS devices the corresponding fixed value is obtained. 72 * For FS devices the first 8B of the device descriptor are fetched to 73 * determine it. 74 * 75 * @return Max packet size for EP 0 (in bytes) 76 */ 77 int hc_get_ep0_max_packet_size(uint16_t *mps, bus_t *bus, device_t *dev) 78 { 79 assert(mps); 80 81 *mps = hc_get_ep0_initial_mps(dev->speed); 82 if (dev->speed != USB_SPEED_FULL) { 65 83 return EOK; 66 84 }
Note:
See TracChangeset
for help on using the changeset viewer.