Changeset 9efad54 in mainline for uspace/lib/usbhost/src/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/lib/usbhost/src/endpoint.c

    rc901632 r9efad54  
    4141#include <str_error.h>
    4242#include <usb/debug.h>
     43#include <usb/descriptor.h>
    4344#include <usb/host/hcd.h>
    4445
     
    5051/** Initialize provided endpoint structure.
    5152 */
    52 void endpoint_init(endpoint_t *ep, device_t *dev, const usb_endpoint_desc_t *desc)
     53void endpoint_init(endpoint_t *ep, device_t *dev, const usb_endpoint_descriptors_t *desc)
    5354{
    5455        memset(ep, 0, sizeof(endpoint_t));
     
    6263        fibril_condvar_initialize(&ep->avail);
    6364
    64         ep->endpoint = desc->endpoint_no;
    65         ep->direction = desc->direction;
    66         ep->transfer_type = desc->transfer_type;
    67         ep->max_packet_size = desc->max_packet_size;
    68         ep->packets = desc->packets;
    69 
    70         ep->bandwidth = endpoint_count_bw(ep, desc->max_packet_size);
     65        ep->endpoint = USB_ED_GET_EP(desc->endpoint);
     66        ep->direction = USB_ED_GET_DIR(desc->endpoint);
     67        ep->transfer_type = USB_ED_GET_TRANSFER_TYPE(desc->endpoint);
     68        ep->max_packet_size = USB_ED_GET_MPS(desc->endpoint);
     69        ep->packets_per_uframe = USB_ED_GET_ADD_OPPS(desc->endpoint) + 1;
     70
     71        /** Direction both is our construct never present in descriptors */
     72        if (ep->transfer_type == USB_TRANSFER_CONTROL)
     73                ep->direction = USB_DIRECTION_BOTH;
     74
     75        ep->max_transfer_size = ep->max_packet_size * ep->packets_per_uframe;
     76
     77        ep->bandwidth = endpoint_count_bw(ep, ep->max_transfer_size);
    7178}
    7279
Note: See TracChangeset for help on using the changeset viewer.