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

    rc901632 r9efad54  
    128128}
    129129
    130 int bus_endpoint_add(device_t *device, const usb_endpoint_desc_t *desc, endpoint_t **out_ep)
     130int bus_endpoint_add(device_t *device, const usb_endpoint_descriptors_t *desc, endpoint_t **out_ep)
    131131{
    132132        int err;
     
    134134
    135135        bus_t *bus = device->bus;
    136 
    137         if (desc->max_packet_size == 0 || desc->packets == 0) {
    138                 usb_log_warning("Invalid endpoint description (mps %zu, %u packets)", desc->max_packet_size, desc->packets);
    139                 return EINVAL;
    140         }
    141136
    142137        const bus_ops_t *create_ops = BUS_OPS_LOOKUP(bus->ops, endpoint_create);
     
    149144                return ENOMEM;
    150145
    151         /* Temporary reference */
     146        /* Bus reference */
    152147        endpoint_add_ref(ep);
     148
     149        if (ep->max_transfer_size == 0) {
     150                usb_log_warning("Invalid endpoint description (mps %zu, "
     151                        "%u packets)", ep->max_packet_size, ep->packets_per_uframe);
     152                /* Bus reference */
     153                endpoint_del_ref(ep);
     154                return EINVAL;
     155        }
     156
     157        usb_log_debug("Register endpoint %d:%d %s-%s %zuB.\n",
     158            device->address, ep->endpoint,
     159            usb_str_transfer_type(ep->transfer_type),
     160            usb_str_direction(ep->direction),
     161            ep->max_transfer_size);
    153162
    154163        fibril_mutex_lock(&bus->guard);
     
    162171        }
    163172
    164         /* Temporary reference */
    165         endpoint_del_ref(ep);
    166173        return err;
    167174}
     
    193200{
    194201        assert(ep);
     202        assert(ep->device);
     203        assert(ep->device->bus);
     204        assert(ep->device->bus->ops);
    195205
    196206        bus_t *bus = endpoint_get_bus(ep);
    197207
    198         const bus_ops_t *ops = BUS_OPS_LOOKUP(ep->device->bus->ops, endpoint_unregister);
    199         if (!ops)
    200                 return ENOTSUP;
     208        const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, endpoint_unregister);
     209        if (!ops)
     210                return ENOTSUP;
     211
     212        usb_log_debug("Unregister endpoint %d:%d %s-%s %zuB.\n",
     213            ep->device->address, ep->endpoint,
     214            usb_str_transfer_type(ep->transfer_type),
     215            usb_str_direction(ep->direction),
     216            ep->max_transfer_size);
    201217
    202218        fibril_mutex_lock(&bus->guard);
Note: See TracChangeset for help on using the changeset viewer.