Changeset a4e18e1 in mainline for uspace/lib/usb/include


Ignore:
Timestamp:
2011-04-07T15:04:16Z (15 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
36cd378
Parents:
9d06563 (diff), a82889e (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:

partial merge form usb/development

Location:
uspace/lib/usb/include/usb
Files:
1 added
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/devdrv.h

    r9d06563 ra4e18e1  
    4747} usb_device_descriptors_t;
    4848
     49/** Wrapper for data related to alternate interface setting.
     50 * The pointers will typically point inside configuration descriptor and
     51 * thus you shall not deallocate them.
     52 */
     53typedef struct {
     54        /** Interface descriptor. */
     55        usb_standard_interface_descriptor_t *interface;
     56        /** Pointer to start of descriptor tree bound with this interface. */
     57        uint8_t *nested_descriptors;
     58        /** Size of data pointed by nested_descriptors in bytes. */
     59        size_t nested_descriptors_size;
     60} usb_alternate_interface_descriptors_t;
     61
     62/** Alternate interface settings. */
     63typedef struct {
     64        /** Array of alternate interfaces descriptions. */
     65        usb_alternate_interface_descriptors_t *alternatives;
     66        /** Size of @c alternatives array. */
     67        size_t alternative_count;
     68        /** Index of currently selected one. */
     69        size_t current;
     70} usb_alternate_interfaces_t;
     71
    4972/** USB device structure. */
    5073typedef struct {
     
    5679         */
    5780        usb_endpoint_mapping_t *pipes;
     81        /** Number of other endpoint pipes. */
     82        size_t pipes_count;
    5883        /** Current interface.
    5984         * Usually, drivers operate on single interface only.
     
    6186         */
    6287        int interface_no;
     88
     89        /** Alternative interfaces.
     90         * Set to NULL when the driver controls whole device
     91         * (i.e. more (or any) interfaces).
     92         */
     93        usb_alternate_interfaces_t *alternate_interfaces;
    6394
    6495        /** Some useful descriptors. */
     
    92123         */
    93124        const char *name;
    94         /** Expected endpoints description, excluding default control endpoint.
     125        /** Expected endpoints description.
     126         * This description shall exclude default control endpoint (pipe zero)
     127         * and must be NULL terminated.
     128         * When only control endpoint is expected, you may set NULL directly
     129         * without creating one item array containing NULL.
    95130         *
    96          * It MUST be of size expected_enpoints_count(excluding default ctrl) + 1
    97          * where the last record MUST BE NULL, otherwise catastrophic things may
    98          * happen.
     131         * When the driver expect single interrupt in endpoint,
     132         * the initialization may look like this:
     133\code
     134static usb_endpoint_description_t poll_endpoint_description = {
     135        .transfer_type = USB_TRANSFER_INTERRUPT,
     136        .direction = USB_DIRECTION_IN,
     137        .interface_class = USB_CLASS_HUB,
     138        .interface_subclass = 0,
     139        .interface_protocol = 0,
     140        .flags = 0
     141};
     142
     143static usb_endpoint_description_t *hub_endpoints[] = {
     144        &poll_endpoint_description,
     145        NULL
     146};
     147
     148static usb_driver_t hub_driver = {
     149        .endpoints = hub_endpoints,
     150        ...
     151};
     152\endcode
    99153         */
    100154        usb_endpoint_description_t **endpoints;
     
    105159int usb_driver_main(usb_driver_t *);
    106160
     161int usb_device_select_interface(usb_device_t *, uint8_t,
     162    usb_endpoint_description_t **);
     163
    107164typedef bool (*usb_polling_callback_t)(usb_device_t *,
    108165    uint8_t *, size_t, void *);
    109166typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *);
    110 
    111167
    112168int usb_device_auto_poll(usb_device_t *, size_t,
  • uspace/lib/usb/include/usb/host/batch.h

    r9d06563 ra4e18e1  
    3939#include <usbhc_iface.h>
    4040#include <usb/usb.h>
     41#include <usb/host/endpoint.h>
    4142
    4243typedef struct usb_transfer_batch usb_transfer_batch_t;
     
    6061        ddf_fun_t *fun;
    6162        void *arg;
     63        endpoint_t *ep;
    6264        void *private_data;
    6365};
     
    7880    void *arg,
    7981    ddf_fun_t *fun,
     82                endpoint_t *ep,
    8083    void *private_data
    8184);
  • uspace/lib/usb/include/usb/host/device_keeper.h

    r9d06563 ra4e18e1  
    4040#ifndef LIBUSB_HOST_DEVICE_KEEPER_H
    4141#define LIBUSB_HOST_DEVICE_KEEPER_H
     42
     43#include <adt/list.h>
    4244#include <devman.h>
    4345#include <fibril_synch.h>
    4446#include <usb/usb.h>
     47#include <usb/host/endpoint.h>
    4548
    4649/** Number of USB address for array dimensions. */
     
    5154        usb_speed_t speed;
    5255        bool occupied;
     56        link_t endpoints;
    5357        uint16_t control_used;
    54         uint16_t toggle_status[2];
    5558        devman_handle_t handle;
    5659};
     
    6871void usb_device_keeper_init(usb_device_keeper_t *instance);
    6972
    70 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance,
    71     usb_speed_t speed);
     73void usb_device_keeper_add_ep(
     74    usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep);
     75
     76void usb_device_keeper_reserve_default_address(
     77    usb_device_keeper_t *instance, usb_speed_t speed);
    7278
    7379void usb_device_keeper_release_default_address(usb_device_keeper_t *instance);
    7480
    7581void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance,
    76     usb_target_t target,
    77     const uint8_t *setup_data);
    78 
    79 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance,
    80     usb_target_t target, usb_direction_t direction);
    81 
    82 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance,
    83     usb_target_t target, usb_direction_t direction, bool toggle);
     82    usb_target_t target, const uint8_t *setup_data);
    8483
    8584usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance,
  • uspace/lib/usb/include/usb/host/usb_endpoint_manager.h

    r9d06563 ra4e18e1  
    3737 * This structure shall simplify the management.
    3838 */
    39 #ifndef LIBUSB_HOST_BANDWIDTH_H
    40 #define LIBUSB_HOST_BANDWIDTH_H
     39#ifndef LIBUSB_HOST_USB_ENDPOINT_MANAGER_H
     40#define LIBUSB_HOST_YSB_ENDPOINT_MANAGER_H
    4141
    4242#include <adt/hash_table.h>
    4343#include <fibril_synch.h>
    4444#include <usb/usb.h>
     45#include <usb/host/endpoint.h>
    4546
    4647#define BANDWIDTH_TOTAL_USB11 12000000
    4748#define BANDWIDTH_AVAILABLE_USB11 ((BANDWIDTH_TOTAL_USB11 / 10) * 9)
    4849
    49 typedef struct bandwidth {
    50         hash_table_t reserved;
     50typedef struct usb_endpoint_manager {
     51        hash_table_t ep_table;
    5152        fibril_mutex_t guard;
    52         size_t free;
    53         size_t (*usage_fnc)(usb_speed_t, usb_transfer_type_t, size_t, size_t);
    54 } bandwidth_t;
     53        fibril_condvar_t change;
     54        size_t free_bw;
     55} usb_endpoint_manager_t;
    5556
    5657size_t bandwidth_count_usb11(usb_speed_t speed, usb_transfer_type_t type,
    5758    size_t size, size_t max_packet_size);
    5859
    59 int bandwidth_init(bandwidth_t *instance, size_t bandwidth,
    60     size_t (*usage_fnc)(usb_speed_t, usb_transfer_type_t, size_t, size_t));
     60int usb_endpoint_manager_init(usb_endpoint_manager_t *instance,
     61    size_t available_bandwidth);
    6162
    62 void bandwidth_destroy(bandwidth_t *instance);
     63void usb_endpoint_manager_destroy(usb_endpoint_manager_t *instance);
    6364
    64 int bandwidth_reserve(bandwidth_t *instance, usb_address_t address,
    65     usb_endpoint_t endpoint, usb_direction_t direction, usb_speed_t speed,
    66     usb_transfer_type_t transfer_type, size_t max_packet_size, size_t size,
    67     unsigned interval);
     65int usb_endpoint_manager_register_ep(usb_endpoint_manager_t *instance,
     66    endpoint_t *ep, size_t data_size);
    6867
    69 int bandwidth_release(bandwidth_t *instance, usb_address_t address,
    70     usb_endpoint_t endpoint, usb_direction_t direction);
     68int usb_endpoint_manager_register_ep_wait(usb_endpoint_manager_t *instance,
     69    usb_address_t address, usb_endpoint_t ep, usb_direction_t direction,
     70    void *data, void (*data_remove_callback)(void* data, void* arg), void *arg,
     71    size_t bw);
    7172
    72 int bandwidth_use(bandwidth_t *instance, usb_address_t address,
    73     usb_endpoint_t endpoint, usb_direction_t direction);
     73int usb_endpoint_manager_unregister_ep(usb_endpoint_manager_t *instance,
     74    usb_address_t address, usb_endpoint_t ep, usb_direction_t direction);
    7475
    75 int bandwidth_free(bandwidth_t *instance, usb_address_t address,
    76     usb_endpoint_t endpoint, usb_direction_t direction);
     76endpoint_t * usb_endpoint_manager_get_ep(usb_endpoint_manager_t *instance,
     77    usb_address_t address, usb_endpoint_t ep, usb_direction_t direction,
     78    size_t *bw);
    7779
    7880#endif
     
    8082 * @}
    8183 */
     84
  • uspace/lib/usb/include/usb/pipes.h

    r9d06563 ra4e18e1  
    107107        /** Interface number the endpoint must belong to (-1 for any). */
    108108        int interface_no;
     109        /** Alternate interface setting to choose. */
     110        int interface_setting;
    109111        /** Found descriptor fitting the description. */
    110112        usb_standard_endpoint_descriptor_t *descriptor;
Note: See TracChangeset for help on using the changeset viewer.