Changeset c804484 in mainline for uspace/lib/usbdev/src/pipes.c


Ignore:
Timestamp:
2011-12-12T13:14:09Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3538b0e
Parents:
1561e8b
Message:

libusbdev: Move pipe init/init_default register/unregister impelmentation to pipes.c

File:
1 edited

Legend:

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

    r1561e8b rc804484  
    292292        return usb_pipe_write_no_check(pipe, 0, buffer, size);
    293293}
     294/*----------------------------------------------------------------------------*/
     295/** Initialize USB endpoint pipe.
     296 *
     297 * @param pipe Endpoint pipe to be initialized.
     298 * @param connection Connection to the USB device backing this pipe (the wire).
     299 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).
     300 * @param transfer_type Transfer type (e.g. interrupt or bulk).
     301 * @param max_packet_size Maximum packet size in bytes.
     302 * @param direction Endpoint direction (in/out).
     303 * @return Error code.
     304 */
     305int usb_pipe_initialize(usb_pipe_t *pipe,
     306    usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
     307    usb_transfer_type_t transfer_type, size_t max_packet_size,
     308    usb_direction_t direction)
     309{
     310        assert(pipe);
     311        assert(connection);
     312
     313        fibril_mutex_initialize(&pipe->guard);
     314        pipe->wire = connection;
     315        pipe->endpoint_no = endpoint_no;
     316        pipe->transfer_type = transfer_type;
     317        pipe->max_packet_size = max_packet_size;
     318        pipe->direction = direction;
     319        pipe->auto_reset_halt = false;
     320
     321        return EOK;
     322}
     323/*----------------------------------------------------------------------------*/
     324/** Initialize USB endpoint pipe as the default zero control pipe.
     325 *
     326 * @param pipe Endpoint pipe to be initialized.
     327 * @param connection Connection to the USB device backing this pipe (the wire).
     328 * @return Error code.
     329 */
     330int usb_pipe_initialize_default_control(usb_pipe_t *pipe,
     331    usb_device_connection_t *connection)
     332{
     333        assert(pipe);
     334        assert(connection);
     335
     336        int rc = usb_pipe_initialize(pipe, connection, 0, USB_TRANSFER_CONTROL,
     337            CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH);
     338
     339        pipe->auto_reset_halt = true;
     340
     341        return rc;
     342}
     343/*----------------------------------------------------------------------------*/
     344/** Register endpoint with the host controller.
     345 *
     346 * @param pipe Pipe to be registered.
     347 * @param interval Polling interval.
     348 * @return Error code.
     349 */
     350int usb_pipe_register(usb_pipe_t *pipe, unsigned interval)
     351{
     352        assert(pipe);
     353        assert(pipe->wire);
     354
     355        return usb_device_register_endpoint(pipe->wire,
     356           pipe->endpoint_no, pipe->transfer_type,
     357           pipe->direction, pipe->max_packet_size, interval);
     358}
     359/*----------------------------------------------------------------------------*/
     360/** Revert endpoint registration with the host controller.
     361 *
     362 * @param pipe Pipe to be unregistered.
     363 * @return Error code.
     364 */
     365int usb_pipe_unregister(usb_pipe_t *pipe)
     366{
     367        assert(pipe);
     368        assert(pipe->wire);
     369
     370        return usb_device_unregister_endpoint(pipe->wire,
     371            pipe->endpoint_no, pipe->direction);
     372}
     373
    294374/**
    295375 * @}
Note: See TracChangeset for help on using the changeset viewer.