Changeset 9e5b162 in mainline for uspace/lib/usbdev/src/pipesinit.c


Ignore:
Timestamp:
2018-01-05T22:09:24Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
86650db
Parents:
35c37fc
Message:

usbdev: refactored usb_pipe_init

Finally.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/pipesinit.c

    r35c37fc r9e5b162  
    208208        }
    209209
    210         unsigned max_burst = 0;
    211         unsigned max_streams = 0;
    212         unsigned bytes_per_interval = 0;
    213         unsigned mult = 0;
     210        usb_endpoint_desc_t ep_desc = {
     211                .endpoint_no = ep_no,
     212                .transfer_type = description.transfer_type,
     213                .direction = description.direction,
     214                // FIXME: USB2 max_packet_size is limited to 1023 bytes, 1024+ doesn't work for USB3
     215                // See 4.14.2.1.1 of XHCI specification -> possibly refactor into one somehow-named field
     216                .max_packet_size
     217                        = ED_MPS_PACKET_SIZE_GET(uint16_usb2host(endpoint_desc->max_packet_size)),
     218                .interval = endpoint_desc->poll_interval,
     219                // FIXME: USB2 packets and USB3 max_burst are probably the same thing
     220                .packets
     221                        = ED_MPS_TRANS_OPPORTUNITIES_GET(uint16_usb2host(endpoint_desc->max_packet_size)),
     222        };
     223
     224        /* TODO Extract USB2-related information */
     225        ep_desc.usb2 = (usb2_endpoint_desc_t) { 0 };
     226
    214227        if (companion_desc) {
    215                 max_burst = companion_desc->max_burst;
    216                 max_streams = SS_COMPANION_MAX_STREAMS(companion_desc->attributes);
    217                 bytes_per_interval = companion_desc->bytes_per_interval;
    218                 mult = SS_COMPANION_MULT(companion_desc->attributes);
    219         }
    220 
    221         // FIXME: USB2 packets and USB3 max_burst are probably the same thing
    222         // FIXME: USB2 max_packet_size is limited to 1023 bytes, 1024+ doesn't work for USB3
    223         // See 4.14.2.1.1 of XHCI specification -> possibly refactor into one somehow-named field
    224         int rc = usb_pipe_initialize(&ep_mapping->pipe,
    225             ep_no, description.transfer_type,
    226             ED_MPS_PACKET_SIZE_GET(
    227                 uint16_usb2host(endpoint_desc->max_packet_size)),
    228             description.direction, ED_MPS_TRANS_OPPORTUNITIES_GET(
    229                 uint16_usb2host(endpoint_desc->max_packet_size)),
    230             max_burst, max_streams, bytes_per_interval, mult, bus_session);
    231         if (rc != EOK) {
    232                 return rc;
    233         }
     228                ep_desc.usb3 = (usb3_endpoint_desc_t) {
     229                        .max_burst = companion_desc->max_burst,
     230                        .max_streams
     231                                = SS_COMPANION_MAX_STREAMS(companion_desc->attributes),
     232                        .bytes_per_interval
     233                                = companion_desc->bytes_per_interval,
     234                        .mult = SS_COMPANION_MULT(companion_desc->attributes),
     235                };
     236        }
     237
     238        int err = usb_pipe_initialize(&ep_mapping->pipe, bus_session, &ep_desc);
     239        if (err)
     240                return err;
    234241
    235242        ep_mapping->present = true;
Note: See TracChangeset for help on using the changeset viewer.