Changeset 6271a34 in mainline


Ignore:
Timestamp:
2018-01-20T18:21:39Z (6 years ago)
Author:
Jenda <jenda.jzqk73@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2aaba7e
Parents:
51c1d500
Message:

handle HS/SS max_packet_size

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/device.c

    r51c1d500 r6271a34  
    8787        dev->base.endpoints[0] = ep0_base;
    8888
     89        usb_log_debug2("Looking up new device initial speed: %i", dev->base.speed);
     90        ep0_base->max_packet_size = hc_get_ep0_initial_mps(dev->base.speed);
     91
    8992        /* Address device */
    9093        if ((err = hc_address_device(dev)))
  • uspace/lib/usbhost/include/usb/host/utility.h

    r51c1d500 r6271a34  
    4646typedef void (*endpoint_reset_toggle_t)(endpoint_t *);
    4747
     48uint16_t hc_get_ep0_initial_mps(usb_speed_t);
    4849int hc_get_ep0_max_packet_size(uint16_t *, bus_t *, device_t *);
    4950void hc_reset_toggles(const usb_transfer_batch_t *batch, endpoint_reset_toggle_t);
  • uspace/lib/usbhost/src/utility.c

    r51c1d500 r6271a34  
    4242#include "utility.h"
    4343
    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 */
     54uint16_t hc_get_ep0_initial_mps(usb_speed_t speed)
     55{
    5756        static const uint16_t mps_fixed [] = {
    5857                [USB_SPEED_LOW] = 8,
     
    6160        };
    6261
    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 */
     77int 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) {
    6583                return EOK;
    6684        }
Note: See TracChangeset for help on using the changeset viewer.