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

    rc901632 r9efad54  
    5050
    5151#include "bus.h"
     52#include "endpoint.h"
    5253
    5354#include "ddf_helpers.h"
     
    6566 * @return Error code.
    6667 */
    67 static int register_endpoint(
    68         ddf_fun_t *fun, usb_endpoint_desc_t *endpoint_desc)
     68static int register_endpoint(ddf_fun_t *fun, usb_pipe_desc_t *pipe_desc,
     69     const usb_endpoint_descriptors_t *ep_desc)
    6970{
    7071        assert(fun);
     
    7576        assert(dev);
    7677
    77         usb_log_debug("Register endpoint %d:%d %s-%s %zuB %ums.\n",
    78                 dev->address, endpoint_desc->endpoint_no,
    79                 usb_str_transfer_type(endpoint_desc->transfer_type),
    80                 usb_str_direction(endpoint_desc->direction),
    81                 endpoint_desc->max_packet_size, endpoint_desc->interval);
    82 
    83         return bus_endpoint_add(dev, endpoint_desc, NULL);
     78        endpoint_t *ep;
     79        const int err = bus_endpoint_add(dev, ep_desc, &ep);
     80        if (err)
     81                return err;
     82
     83        if (pipe_desc) {
     84                pipe_desc->endpoint_no = ep->endpoint;
     85                pipe_desc->direction = ep->direction;
     86                pipe_desc->transfer_type = ep->transfer_type;
     87                pipe_desc->max_transfer_size = ep->max_transfer_size;
     88        }
     89        endpoint_del_ref(ep);
     90
     91        return EOK;
    8492}
    8593
     
    8997  * @return Error code.
    9098  */
    91 static int unregister_endpoint(
    92         ddf_fun_t *fun, usb_endpoint_desc_t *endpoint_desc)
     99static int unregister_endpoint(ddf_fun_t *fun, const usb_pipe_desc_t *endpoint_desc)
    93100{
    94101        assert(fun);
     
    103110                .endpoint = endpoint_desc->endpoint_no
    104111        }};
    105 
    106         usb_log_debug("Unregister endpoint %d:%d %s.\n",
    107                 dev->address, endpoint_desc->endpoint_no,
    108                 usb_str_direction(endpoint_desc->direction));
    109112
    110113        endpoint_t *ep = bus_find_endpoint(dev, target, endpoint_desc->direction);
Note: See TracChangeset for help on using the changeset viewer.