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

    rc901632 r9efad54  
    186186}
    187187
    188 static const usb_endpoint_desc_t usb2_default_control_ep = {
    189         .endpoint_no = 0,
    190         .transfer_type = USB_TRANSFER_CONTROL,
    191         .direction = USB_DIRECTION_BOTH,
    192         .max_packet_size = CTRL_PIPE_MIN_PACKET_SIZE,
    193         .packets = 1,
    194 };
    195 
    196 
    197188static const usb_target_t usb2_default_target = {{
    198189        .address = USB_ADDRESS_DEFAULT,
     
    221212        usb_log_debug("Device(%d): Adding default target (0:0)", address);
    222213
     214        usb_endpoint_descriptors_t ep0_desc = {
     215            .endpoint.max_packet_size = CTRL_PIPE_MIN_PACKET_SIZE,
     216        };
    223217        endpoint_t *default_ep;
    224         err = bus_endpoint_add(dev, &usb2_default_control_ep, &default_ep);
     218        err = bus_endpoint_add(dev, &ep0_desc, &default_ep);
    225219        if (err != EOK) {
    226220                usb_log_error("Device(%d): Failed to add default target: %s.",
     
    229223        }
    230224
    231         uint16_t max_packet_size;
    232         if ((err = hcd_get_ep0_max_packet_size(&max_packet_size, &bus->base, dev)))
     225        if ((err = hcd_get_ep0_max_packet_size(&ep0_desc.endpoint.max_packet_size, &bus->base, dev)))
    233226                goto err_address;
    234227
     
    254247        dev->address = address;
    255248
    256         const usb_endpoint_desc_t control_ep = {
    257                 .endpoint_no = 0,
    258                 .transfer_type = USB_TRANSFER_CONTROL,
    259                 .direction = USB_DIRECTION_BOTH,
    260                 .max_packet_size = max_packet_size,
    261                 .packets = 1,
    262         };
    263 
    264249        /* Register EP on the new address */
    265250        usb_log_debug("Device(%d): Registering control EP.", address);
    266         err = bus_endpoint_add(dev, &control_ep, NULL);
     251        err = bus_endpoint_add(dev, &ep0_desc, NULL);
    267252        if (err != EOK) {
    268253                usb_log_error("Device(%d): Failed to register EP0: %s",
     
    352337}
    353338
    354 static endpoint_t *usb2_bus_create_ep(device_t *dev, const usb_endpoint_desc_t *desc)
     339static endpoint_t *usb2_bus_create_ep(device_t *dev, const usb_endpoint_descriptors_t *desc)
    355340{
    356341        endpoint_t *ep = malloc(sizeof(endpoint_t));
Note: See TracChangeset for help on using the changeset viewer.