Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 375211d2 in mainline


Ignore:
Timestamp:
2017-11-20T22:15:11Z (4 years ago)
Author:
Aearsis <Hlavaty.Ondrej@…>
Branches:
lfn, master
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)
Message:

usbhost: updated determining MPS for USB 3

USB 3 changes the meaning of the max packet size in device descriptor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/hcd.c

    r9162b27 r375211d2  
    6767 * the first 8B of the device descriptor to determine it.
    6868 *
    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
    7170 */
    7271int hcd_get_ep0_max_packet_size(uint16_t *mps, hcd_t *hcd, device_t *dev)
    7372{
     73        assert(mps);
     74
    7475        static const uint16_t mps_fixed [] = {
    7576                [USB_SPEED_LOW] = 8,
     
    9293            GET_DEVICE_DESC(CTRL_PIPE_MIN_PACKET_SIZE);
    9394
    94         usb_log_debug("Requesting first 8B of device descriptor.");
     95        usb_log_debug("Requesting first 8B of device descriptor to determine MPS.");
    9596        ssize_t got = hcd_send_batch_sync(hcd, dev, control_ep, USB_DIRECTION_IN,
    9697            (char *) &desc, CTRL_PIPE_MIN_PACKET_SIZE, *(uint64_t *)&get_device_desc_8,
     
    103104        }
    104105
    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        }
    106119        return EOK;
    107120}
Note: See TracChangeset for help on using the changeset viewer.