Changeset f8e8738 in mainline for uspace/lib/usb/include/usb/devdrv.h


Ignore:
Timestamp:
2011-04-07T20:22:40Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fee6381
Parents:
61257f4 (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:

Changes from development

File:
1 edited

Legend:

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

    r61257f4 rf8e8738  
    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,
Note: See TracChangeset for help on using the changeset viewer.