Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c804484 in mainline


Ignore:
Timestamp:
2011-12-12T13:14:09Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
3538b0e
Parents:
1561e8b
Message:

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

Location:
uspace/lib/usbdev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    r1561e8b rc804484  
    4444#include <usb/dev/usb_device_connection.h>
    4545
     46#define CTRL_PIPE_MIN_PACKET_SIZE 8
    4647/** Abstraction of a logical connection to USB device endpoint.
    4748 * It encapsulates endpoint attributes (transfer type etc.) as well
     
    8081} usb_pipe_t;
    8182
    82 
    8383/** Description of endpoint characteristics. */
    8484typedef struct {
     
    115115} usb_endpoint_mapping_t;
    116116
    117 
    118117int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
    119118    usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
     
    124123int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
    125124    size_t, const uint8_t *, size_t, usb_device_connection_t *);
     125
    126126int usb_pipe_register(usb_pipe_t *, unsigned);
    127127int usb_pipe_unregister(usb_pipe_t *);
  • 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 * @}
  • uspace/lib/usbdev/src/pipesinit.c

    r1561e8b rc804484  
    4141#include <assert.h>
    4242
    43 #define CTRL_PIPE_MIN_PACKET_SIZE 8
    4443#define DEV_DESCR_MAX_PACKET_SIZE_OFFSET 7
    45 
    4644
    4745#define NESTING(parentname, childname) \
     
    326324
    327325        return EOK;
    328 }
    329 
    330 /** Initialize USB endpoint pipe.
    331  *
    332  * @param pipe Endpoint pipe to be initialized.
    333  * @param connection Connection to the USB device backing this pipe (the wire).
    334  * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).
    335  * @param transfer_type Transfer type (e.g. interrupt or bulk).
    336  * @param max_packet_size Maximum packet size in bytes.
    337  * @param direction Endpoint direction (in/out).
    338  * @return Error code.
    339  */
    340 int usb_pipe_initialize(usb_pipe_t *pipe,
    341     usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
    342     usb_transfer_type_t transfer_type, size_t max_packet_size,
    343     usb_direction_t direction)
    344 {
    345         assert(pipe);
    346         assert(connection);
    347 
    348         fibril_mutex_initialize(&pipe->guard);
    349         pipe->wire = connection;
    350         pipe->endpoint_no = endpoint_no;
    351         pipe->transfer_type = transfer_type;
    352         pipe->max_packet_size = max_packet_size;
    353         pipe->direction = direction;
    354         pipe->auto_reset_halt = false;
    355 
    356         return EOK;
    357 }
    358 
    359 /** Initialize USB endpoint pipe as the default zero control pipe.
    360  *
    361  * @param pipe Endpoint pipe to be initialized.
    362  * @param connection Connection to the USB device backing this pipe (the wire).
    363  * @return Error code.
    364  */
    365 int usb_pipe_initialize_default_control(usb_pipe_t *pipe,
    366     usb_device_connection_t *connection)
    367 {
    368         assert(pipe);
    369         assert(connection);
    370 
    371         int rc = usb_pipe_initialize(pipe, connection, 0, USB_TRANSFER_CONTROL,
    372             CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH);
    373 
    374         pipe->auto_reset_halt = true;
    375 
    376         return rc;
    377326}
    378327
     
    428377}
    429378
    430 /** Register endpoint with the host controller.
    431  *
    432  * @param pipe Pipe to be registered.
    433  * @param interval Polling interval.
    434  * @return Error code.
    435  */
    436 int usb_pipe_register(usb_pipe_t *pipe, unsigned interval)
    437 {
    438         assert(pipe);
    439         assert(pipe->wire);
    440 
    441         return usb_device_register_endpoint(pipe->wire,
    442            pipe->endpoint_no, pipe->transfer_type,
    443            pipe->direction, pipe->max_packet_size, interval);
    444 }
    445 
    446 /** Revert endpoint registration with the host controller.
    447  *
    448  * @param pipe Pipe to be unregistered.
    449  * @return Error code.
    450  */
    451 int usb_pipe_unregister(usb_pipe_t *pipe)
    452 {
    453         assert(pipe);
    454         assert(pipe->wire);
    455 
    456         return usb_device_unregister_endpoint(pipe->wire,
    457             pipe->endpoint_no, pipe->direction);
    458 }
    459 
    460379/**
    461380 * @}
Note: See TracChangeset for help on using the changeset viewer.