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


Ignore:
Timestamp:
2012-02-09T20:35:12Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
591762c6
Parents:
7cede12c (diff), 3d4750f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    r7cede12c rb7068da  
    3131 */
    3232/** @file
    33  * Initialization of endpoint pipes.
     33 * Non trivial initialization of endpoint pipes.
    3434 *
    3535 */
     
    3838#include <usb/dev/dp.h>
    3939#include <usb/dev/request.h>
    40 #include <usbhc_iface.h>
    4140#include <errno.h>
    4241#include <assert.h>
    4342
    44 #define CTRL_PIPE_MIN_PACKET_SIZE 8
    4543#define DEV_DESCR_MAX_PACKET_SIZE_OFFSET 7
    46 
    4744
    4845#define NESTING(parentname, childname) \
     
    327324
    328325        return EOK;
    329 }
    330 
    331 /** Initialize USB endpoint pipe.
    332  *
    333  * @param pipe Endpoint pipe to be initialized.
    334  * @param connection Connection to the USB device backing this pipe (the wire).
    335  * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).
    336  * @param transfer_type Transfer type (e.g. interrupt or bulk).
    337  * @param max_packet_size Maximum packet size in bytes.
    338  * @param direction Endpoint direction (in/out).
    339  * @return Error code.
    340  */
    341 int usb_pipe_initialize(usb_pipe_t *pipe,
    342     usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
    343     usb_transfer_type_t transfer_type, size_t max_packet_size,
    344     usb_direction_t direction)
    345 {
    346         assert(pipe);
    347         assert(connection);
    348 
    349         fibril_mutex_initialize(&pipe->guard);
    350         pipe->wire = connection;
    351         pipe->hc_sess = NULL;
    352         fibril_mutex_initialize(&pipe->hc_sess_mutex);
    353         pipe->endpoint_no = endpoint_no;
    354         pipe->transfer_type = transfer_type;
    355         pipe->max_packet_size = max_packet_size;
    356         pipe->direction = direction;
    357         pipe->refcount = 0;
    358         pipe->refcount_soft = 0;
    359         pipe->auto_reset_halt = false;
    360 
    361         return EOK;
    362 }
    363 
    364 
    365 /** Initialize USB endpoint pipe as the default zero control pipe.
    366  *
    367  * @param pipe Endpoint pipe to be initialized.
    368  * @param connection Connection to the USB device backing this pipe (the wire).
    369  * @return Error code.
    370  */
    371 int usb_pipe_initialize_default_control(usb_pipe_t *pipe,
    372     usb_device_connection_t *connection)
    373 {
    374         assert(pipe);
    375         assert(connection);
    376 
    377         int rc = usb_pipe_initialize(pipe, connection,
    378             0, USB_TRANSFER_CONTROL, CTRL_PIPE_MIN_PACKET_SIZE,
    379             USB_DIRECTION_BOTH);
    380 
    381         pipe->auto_reset_halt = true;
    382 
    383         return rc;
    384326}
    385327
     
    435377}
    436378
    437 /** Register endpoint with the host controller.
    438  *
    439  * @param pipe Pipe to be registered.
    440  * @param interval Polling interval.
    441  * @param hc_connection Connection to the host controller (must be opened).
    442  * @return Error code.
    443  */
    444 int usb_pipe_register(usb_pipe_t *pipe, unsigned interval,
    445     usb_hc_connection_t *hc_connection)
    446 {
    447         assert(pipe);
    448         assert(pipe->wire);
    449         assert(hc_connection);
    450 
    451         if (!usb_hc_connection_is_opened(hc_connection))
    452                 return EBADF;
    453         async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
    454         if (!exch)
    455                 return ENOMEM;
    456         const int ret = usbhc_register_endpoint(exch,
    457             pipe->wire->address, pipe->endpoint_no, pipe->transfer_type,
    458             pipe->direction, pipe->max_packet_size, interval);
    459 
    460         async_exchange_end(exch);
    461         return ret;
    462 }
    463 
    464 /** Revert endpoint registration with the host controller.
    465  *
    466  * @param pipe Pipe to be unregistered.
    467  * @param hc_connection Connection to the host controller (must be opened).
    468  * @return Error code.
    469  */
    470 int usb_pipe_unregister(usb_pipe_t *pipe,
    471     usb_hc_connection_t *hc_connection)
    472 {
    473         assert(pipe);
    474         assert(pipe->wire);
    475         assert(hc_connection);
    476 
    477         if (!usb_hc_connection_is_opened(hc_connection))
    478                 return EBADF;
    479 
    480         async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
    481         if (!exch)
    482                 return ENOMEM;
    483         const int ret = usbhc_unregister_endpoint(exch,
    484             pipe->wire->address, pipe->endpoint_no, pipe->direction);
    485         async_exchange_end(exch);
    486 
    487         return ret;
    488 }
    489 
    490379/**
    491380 * @}
Note: See TracChangeset for help on using the changeset viewer.