Changeset 9efad54 in mainline for uspace/drv/bus/usb/xhci/endpoint.c


Ignore:
Timestamp:
2018-01-06T21:15:48Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
56257ba
Parents:
c901632
Message:

usb: move endpoint descriptor parsing to HC

This better separates responsibilities. Now the device driver does not
care about the contents of an endpoint descriptor, and HC can parse the
values according to device's actual speed.

Currently, it is device driver's responsibility to fetch endpoint
descriptors, map them and register pipes - sending the endpoint
descriptor back to HC. HC then parses it, and fills the pipe
description, which then sends back to device driver. We shall probably
fetch the endpoint descriptor from inside the HC (also fixing the USB
spec violation of communication with EP0).

File:
1 edited

Legend:

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

    rc901632 r9efad54  
    5252 * @return Error code.
    5353 */
    54 int xhci_endpoint_init(xhci_endpoint_t *xhci_ep, device_t *dev, const usb_endpoint_desc_t *desc)
     54int xhci_endpoint_init(xhci_endpoint_t *xhci_ep, device_t *dev, const usb_endpoint_descriptors_t *desc)
    5555{
    5656        assert(xhci_ep);
     
    6060        endpoint_init(ep, dev, desc);
    6161
    62         xhci_ep->max_streams = desc->usb3.max_streams;
    63         xhci_ep->max_burst = desc->usb3.max_burst;
    64         xhci_ep->mult = desc->usb3.mult;
    65 
    66         // TODO: process according to 6.2.3.6 of XHCI specification; hardcoded for HS/SS EPs
    67         xhci_ep->interval = desc->interval - 1;
     62        xhci_ep->max_streams = USB_SSC_MAX_STREAMS(desc->companion);
     63        xhci_ep->max_burst = desc->companion.max_burst + 1;
     64        xhci_ep->mult = USB_SSC_MULT(desc->companion) + 1;
     65
     66        /* In USB 3, the semantics of wMaxPacketSize changed. Now the number of
     67         * packets per service interval is determined from max_burst and mult.
     68         */
     69        if (dev->speed >= USB_SPEED_SUPER) {
     70                ep->packets_per_uframe = xhci_ep->max_burst * xhci_ep->mult;
     71                ep->max_transfer_size = ep->max_packet_size * ep->packets_per_uframe;
     72        }
     73
     74        xhci_ep->interval = desc->endpoint.poll_interval;
     75        /* Only Low/Full speed interrupt endpoints have interval set directly,
     76         * others have 2-based log of it.
     77         */
     78        if (dev->speed >= USB_SPEED_HIGH || ep->transfer_type != USB_TRANSFER_INTERRUPT) {
     79                xhci_ep->interval = 1 << (xhci_ep->interval - 1);
     80        }
    6881
    6982        if (xhci_ep->base.transfer_type == USB_TRANSFER_ISOCHRONOUS) {
    70                 xhci_ep->isoch_max_size = desc->usb3.bytes_per_interval
    71                         ? desc->usb3.bytes_per_interval
    72                         : desc->max_packet_size * (desc->packets + 1);
     83                xhci_ep->isoch_max_size = desc->companion.bytes_per_interval
     84                        ? desc->companion.bytes_per_interval
     85                        : ep->max_transfer_size;
    7386                /* Technically there could be superspeed plus too. */
    7487
     
    497510        dev->endpoints[ep->base.endpoint] = NULL;
    498511        ep->base.device = NULL;
    499 
    500         endpoint_del_ref(&ep->base);
    501512}
    502513
Note: See TracChangeset for help on using the changeset viewer.