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


Ignore:
Timestamp:
2011-04-17T19:17:55Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63517c2, cfbbe1d3
Parents:
ef354b6 (diff), 8595577b (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:

new report structure fixes

Location:
uspace/lib/usb/include/usb
Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/classes/hidparser.h

    ref354b6 re50cd7f  
    317317usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
    318318
     319usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, usb_hid_report_field_t *field, usb_hid_report_path_t *path, int flags, usb_hid_report_type_t type);
    319320
    320321/*
  • uspace/lib/usb/include/usb/classes/hub.h

    ref354b6 re50cd7f  
    4343 */
    4444typedef enum {
     45        USB_HUB_FEATURE_HUB_LOCAL_POWER = 0,
     46        USB_HUB_FEATURE_HUB_OVER_CURRENT = 1,
    4547        USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0,
    4648        USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1,
     
    5961        /* USB_HUB_FEATURE_ = , */
    6062} usb_hub_class_feature_t;
     63
    6164
    6265/** Header of standard hub descriptor without the "variadic" part. */
     
    149152            maximum of 255 ports).
    150153     */
    151     uint8_t * devices_removable;
     154    uint8_t devices_removable[32];
    152155
    153156    /**
  • uspace/lib/usb/include/usb/devdrv.h

    ref354b6 re50cd7f  
    162162    usb_endpoint_description_t **);
    163163
    164 typedef bool (*usb_polling_callback_t)(usb_device_t *,
    165     uint8_t *, size_t, void *);
    166 typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *);
     164int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *);
     165int usb_device_create_pipes(ddf_dev_t *, usb_device_connection_t *,
     166    usb_endpoint_description_t **, uint8_t *, size_t, int, int,
     167    usb_endpoint_mapping_t **, size_t *);
     168int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
     169int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **);
    167170
    168 int usb_device_auto_poll(usb_device_t *, size_t,
    169     usb_polling_callback_t, size_t, usb_polling_terminted_callback_t, void *);
     171size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t);
     172int usb_alternate_interfaces_create(uint8_t *, size_t, int,
     173    usb_alternate_interfaces_t **);
    170174
    171175#endif
  • uspace/lib/usb/include/usb/host/batch.h

    ref354b6 re50cd7f  
    4343typedef struct usb_transfer_batch usb_transfer_batch_t;
    4444struct usb_transfer_batch {
     45        endpoint_t *ep;
    4546        link_t link;
    46         usb_target_t target;
    47         usb_transfer_type_t transfer_type;
    48         usb_speed_t speed;
    49         usb_direction_t direction;
    5047        usbhc_iface_transfer_in_callback_t callback_in;
    5148        usbhc_iface_transfer_out_callback_t callback_out;
     49        void *arg;
    5250        char *buffer;
    53         char *transport_buffer;
     51        char *data_buffer;
    5452        size_t buffer_size;
    5553        char *setup_buffer;
    5654        size_t setup_size;
    57         size_t max_packet_size;
    5855        size_t transfered_size;
    5956        void (*next_step)(usb_transfer_batch_t *);
    6057        int error;
    6158        ddf_fun_t *fun;
    62         void *arg;
    63         endpoint_t *ep;
    6459        void *private_data;
     60        void (*private_data_dtor)(void *p_data);
    6561};
    6662
    6763void usb_transfer_batch_init(
    6864    usb_transfer_batch_t *instance,
    69     usb_target_t target,
    70     usb_transfer_type_t transfer_type,
    71     usb_speed_t speed,
    72     size_t max_packet_size,
     65    endpoint_t *ep,
    7366    char *buffer,
    74     char *transport_buffer,
     67    char *data_buffer,
    7568    size_t buffer_size,
    7669    char *setup_buffer,
     
    8073    void *arg,
    8174    ddf_fun_t *fun,
    82                 endpoint_t *ep,
    83     void *private_data
     75    void *private_data,
     76    void (*private_data_dtor)(void *p_data)
    8477);
     78
     79void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance);
     80void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance);
     81void usb_transfer_batch_finish(usb_transfer_batch_t *instance);
     82void usb_transfer_batch_dispose(usb_transfer_batch_t *instance);
     83
     84static inline void usb_transfer_batch_finish_error(
     85    usb_transfer_batch_t *instance, int error)
     86{
     87        assert(instance);
     88        instance->error = error;
     89        usb_transfer_batch_finish(instance);
     90}
    8591
    8692static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l)
     
    9096}
    9197
    92 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);
    93 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);
    94 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error);
    95 
    9698#endif
    9799/**
  • uspace/lib/usb/include/usb/host/device_keeper.h

    ref354b6 re50cd7f  
    5454        usb_speed_t speed;
    5555        bool occupied;
    56         link_t endpoints;
    57         uint16_t control_used;
    5856        devman_handle_t handle;
    5957};
     
    6563        struct usb_device_info devices[USB_ADDRESS_COUNT];
    6664        fibril_mutex_t guard;
    67         fibril_condvar_t change;
    6865        usb_address_t last_address;
    6966} usb_device_keeper_t;
    7067
    7168void usb_device_keeper_init(usb_device_keeper_t *instance);
    72 
    73 void usb_device_keeper_add_ep(
    74     usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep);
    75 
    76 void usb_device_keeper_reserve_default_address(
    77     usb_device_keeper_t *instance, usb_speed_t speed);
    78 
    79 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance);
    80 
    81 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance,
    82     usb_target_t target, const uint8_t *setup_data);
    8369
    8470usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance,
     
    9682usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
    9783    usb_address_t address);
    98 
    99 void usb_device_keeper_use_control(usb_device_keeper_t *instance,
    100     usb_target_t target);
    101 
    102 void usb_device_keeper_release_control(usb_device_keeper_t *instance,
    103     usb_target_t target);
    104 
    10584#endif
    10685/**
  • uspace/lib/usb/include/usb/host/endpoint.h

    ref354b6 re50cd7f  
    3939#include <bool.h>
    4040#include <adt/list.h>
     41#include <fibril_synch.h>
     42
    4143#include <usb/usb.h>
    4244
     
    4850        usb_speed_t speed;
    4951        size_t max_packet_size;
    50         bool active;
    5152        unsigned toggle:1;
    52         link_t same_device_eps;
     53        fibril_mutex_t guard;
     54        fibril_condvar_t avail;
     55        volatile bool active;
     56        struct {
     57                void *data;
     58                int (*toggle_get)(void *);
     59                void (*toggle_set)(void *, int);
     60        } hc_data;
    5361} endpoint_t;
    5462
     
    5967void endpoint_destroy(endpoint_t *instance);
    6068
     69void endpoint_set_hc_data(endpoint_t *instance,
     70    void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int));
     71
     72void endpoint_clear_hc_data(endpoint_t *instance);
     73
     74void endpoint_use(endpoint_t *instance);
     75
     76void endpoint_release(endpoint_t *instance);
     77
    6178int endpoint_toggle_get(endpoint_t *instance);
    6279
    6380void endpoint_toggle_set(endpoint_t *instance, int toggle);
    6481
    65 void endpoint_toggle_reset(link_t *ep);
    66 
    67 void endpoint_toggle_reset_filtered(link_t *ep, usb_endpoint_t epn);
    68 
     82void endpoint_toggle_reset_filtered(endpoint_t *instance, usb_target_t target);
    6983#endif
    7084/**
  • uspace/lib/usb/include/usb/host/usb_endpoint_manager.h

    ref354b6 re50cd7f  
    6666    endpoint_t *ep, size_t data_size);
    6767
    68 int 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);
    72 
    7368int usb_endpoint_manager_unregister_ep(usb_endpoint_manager_t *instance,
    7469    usb_address_t address, usb_endpoint_t ep, usb_direction_t direction);
     
    7873    size_t *bw);
    7974
     75void usb_endpoint_manager_reset_if_need(
     76    usb_endpoint_manager_t *instance, usb_target_t target, const uint8_t *data);
     77
     78static inline int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance,
     79    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
     80    usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size,
     81    size_t data_size)
     82{
     83        endpoint_t *ep = malloc(sizeof(endpoint_t));
     84        if (ep == NULL)
     85                return ENOMEM;
     86
     87        int ret = endpoint_init(ep, address, endpoint, direction, type, speed,
     88            max_packet_size);
     89        if (ret != EOK) {
     90                free(ep);
     91                return ret;
     92        }
     93
     94        ret = usb_endpoint_manager_register_ep(instance, ep, data_size);
     95        if (ret != EOK) {
     96                endpoint_destroy(ep);
     97                return ret;
     98        }
     99        return EOK;
     100}
    80101#endif
    81102/**
  • uspace/lib/usb/include/usb/hub.h

    ref354b6 re50cd7f  
    5959} usb_hc_attached_device_t;
    6060
    61 int usb_hc_reserve_default_address(usb_hc_connection_t *, usb_speed_t);
    62 int usb_hc_release_default_address(usb_hc_connection_t *);
    63 
    6461usb_address_t usb_hc_request_address(usb_hc_connection_t *, usb_speed_t);
    6562int usb_hc_register_device(usb_hc_connection_t *,
  • uspace/lib/usb/include/usb/pipes.h

    ref354b6 re50cd7f  
    4242#include <ipc/devman.h>
    4343#include <ddf/driver.h>
     44#include <fibril_synch.h>
    4445
    4546/** Abstraction of a physical connection to the device.
     
    5960 * This endpoint must be bound with existing usb_device_connection_t
    6061 * (i.e. the wire to send data over).
     62 *
     63 * Locking order: if you want to lock both mutexes
     64 * (@c guard and @c hc_phone_mutex), lock @c guard first.
     65 * It is not necessary to lock @c guard if you want to lock @c hc_phone_mutex
     66 * only.
    6167 */
    6268typedef struct {
     69        /** Guard of the whole pipe. */
     70        fibril_mutex_t guard;
     71
    6372        /** The connection used for sending the data. */
    6473        usb_device_connection_t *wire;
     
    7887        /** Phone to the host controller.
    7988         * Negative when no session is active.
     89         * It is an error to access this member without @c hc_phone_mutex
     90         * being locked.
     91         * If call over the phone is to be made, it must be preceeded by
     92         * call to pipe_add_ref() [internal libusb function].
    8093         */
    8194        int hc_phone;
     95
     96        /** Guard for serialization of requests over the phone. */
     97        fibril_mutex_t hc_phone_mutex;
     98
     99        /** Number of active transfers over the pipe. */
     100        int refcount;
     101
     102        /** Whether to automatically reset halt on the endpoint.
     103         * Valid only for control endpoint zero.
     104         */
     105        bool auto_reset_halt;
    82106} usb_pipe_t;
    83107
     
    134158int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
    135159    size_t, uint8_t *, size_t, usb_device_connection_t *);
     160int usb_pipe_register_with_speed(usb_pipe_t *, usb_speed_t,
     161    unsigned int, usb_hc_connection_t *);
    136162int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *);
    137163int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
     
    140166int usb_pipe_end_session(usb_pipe_t *);
    141167bool usb_pipe_is_session_started(usb_pipe_t *);
     168
     169int usb_pipe_start_long_transfer(usb_pipe_t *);
     170void usb_pipe_end_long_transfer(usb_pipe_t *);
    142171
    143172int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
  • uspace/lib/usb/include/usb/request.h

    ref354b6 re50cd7f  
    5050/** USB endpoint status - endpoint is halted (stalled). */
    5151#define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
     52
     53/** USB feature selector - endpoint halt (stall). */
     54#define USB_FEATURE_SELECTOR_ENDPOINT_HALT (0)
     55
     56/** USB feature selector - device remote wake-up. */
     57#define USB_FEATURE_SELECTOR_REMOTE_WAKEUP (1)
    5258
    5359/** Standard device request. */
     
    135141    char **);
    136142
     143int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
     144
    137145#endif
    138146/**
  • uspace/lib/usb/include/usb/usb.h

    ref354b6 re50cd7f  
    7777        USB_SPEED_FULL,
    7878        /** USB 2.0 high speed (480Mbits/s). */
    79         USB_SPEED_HIGH
     79        USB_SPEED_HIGH,
     80        /** Psuedo-speed serving as a boundary. */
     81        USB_SPEED_MAX
    8082} usb_speed_t;
    8183
Note: See TracChangeset for help on using the changeset viewer.