Ignore:
File:
1 edited

Legend:

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

    rb77931d r7c95d6f5  
    192192        }
    193193
     194        if (ep_mapping->pipe == NULL) {
     195                return EBADMEM;
     196        }
    194197        if (ep_mapping->present) {
    195198                return EEXISTS;
    196199        }
    197200
    198         int rc = usb_pipe_initialize(&ep_mapping->pipe, wire,
     201        int rc = usb_pipe_initialize(ep_mapping->pipe, wire,
    199202            ep_no, description.transfer_type, endpoint->max_packet_size,
    200203            description.direction);
     
    251254 *
    252255 * The mapping array is expected to conform to following rules:
    253  * - @c pipe must be uninitialized pipe
     256 * - @c pipe must point to already allocated structure with uninitialized pipe
    254257 * - @c description must point to prepared endpoint description
    255258 * - @c descriptor does not need to be initialized (will be overwritten)
     
    294297        }
    295298
    296         /* Go through the mapping and set all endpoints to not present. */
    297         for (size_t i = 0; i < mapping_count; i++) {
     299        /*
     300         * Go through the mapping and set all endpoints to not present.
     301         */
     302        size_t i;
     303        for (i = 0; i < mapping_count; i++) {
    298304                mapping[i].present = false;
    299305                mapping[i].descriptor = NULL;
     
    301307        }
    302308
    303         /* Prepare the descriptor parser. */
     309        /*
     310         * Prepare the descriptor parser.
     311         */
    304312        const usb_dp_parser_t dp_parser = {
    305313                .nesting = descriptor_nesting
     
    446454 * @return Error code.
    447455 */
    448 int usb_pipe_register(usb_pipe_t *pipe, unsigned interval,
     456int usb_pipe_register(usb_pipe_t *pipe,
     457    unsigned int interval,
     458    usb_hc_connection_t *hc_connection)
     459{
     460        return usb_pipe_register_with_speed(pipe, USB_SPEED_MAX + 1,
     461            interval, hc_connection);
     462}
     463
     464/** Register endpoint with a speed at the host controller.
     465 *
     466 * You will rarely need to use this function because it is needed only
     467 * if the registered endpoint is of address 0 and there is no other way
     468 * to tell speed of the device at address 0.
     469 *
     470 * @param pipe Pipe to be registered.
     471 * @param speed Speed of the device
     472 *      (invalid speed means use previously specified one).
     473 * @param interval Polling interval.
     474 * @param hc_connection Connection to the host controller (must be opened).
     475 * @return Error code.
     476 */
     477int usb_pipe_register_with_speed(usb_pipe_t *pipe, usb_speed_t speed,
     478    unsigned int interval,
    449479    usb_hc_connection_t *hc_connection)
    450480{
    451481        assert(pipe);
    452482        assert(hc_connection);
    453 
     483       
    454484        if (!usb_hc_connection_is_opened(hc_connection))
    455485                return EBADF;
    456 
     486       
    457487        const usb_target_t target =
    458488            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
    459 #define _PACK2(high, low) (((high & 0xffff) << 16) | (low & 0xffff))
    460 
     489#define _PACK2(high, low) (((high) << 16) + (low))
     490#define _PACK3(high, middle, low) (((((high) << 8) + (middle)) << 8) + (low))
     491       
    461492        async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
    462493        int rc = async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    463494            IPC_M_USBHC_REGISTER_ENDPOINT, target.packed,
    464             _PACK2(pipe->transfer_type, pipe->direction),
     495            _PACK3(speed, pipe->transfer_type, pipe->direction),
    465496            _PACK2(pipe->max_packet_size, interval));
    466497        async_exchange_end(exch);
    467 
     498       
    468499#undef _PACK2
     500#undef _PACK3
     501       
    469502        return rc;
    470503}
Note: See TracChangeset for help on using the changeset viewer.