Changeset e50cd7f in mainline for uspace/lib/usb/include
- Timestamp:
- 2011-04-17T19:17:55Z (14 years ago)
- 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. - 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 317 317 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path); 318 318 319 usb_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); 319 320 320 321 /* -
uspace/lib/usb/include/usb/classes/hub.h
ref354b6 re50cd7f 43 43 */ 44 44 typedef enum { 45 USB_HUB_FEATURE_HUB_LOCAL_POWER = 0, 46 USB_HUB_FEATURE_HUB_OVER_CURRENT = 1, 45 47 USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0, 46 48 USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1, … … 59 61 /* USB_HUB_FEATURE_ = , */ 60 62 } usb_hub_class_feature_t; 63 61 64 62 65 /** Header of standard hub descriptor without the "variadic" part. */ … … 149 152 maximum of 255 ports). 150 153 */ 151 uint8_t * devices_removable;154 uint8_t devices_removable[32]; 152 155 153 156 /** -
uspace/lib/usb/include/usb/devdrv.h
ref354b6 re50cd7f 162 162 usb_endpoint_description_t **); 163 163 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 *); 164 int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *); 165 int 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 *); 168 int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t); 169 int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **); 167 170 168 int usb_device_auto_poll(usb_device_t *, size_t, 169 usb_polling_callback_t, size_t, usb_polling_terminted_callback_t, void *); 171 size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t); 172 int usb_alternate_interfaces_create(uint8_t *, size_t, int, 173 usb_alternate_interfaces_t **); 170 174 171 175 #endif -
uspace/lib/usb/include/usb/host/batch.h
ref354b6 re50cd7f 43 43 typedef struct usb_transfer_batch usb_transfer_batch_t; 44 44 struct usb_transfer_batch { 45 endpoint_t *ep; 45 46 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;50 47 usbhc_iface_transfer_in_callback_t callback_in; 51 48 usbhc_iface_transfer_out_callback_t callback_out; 49 void *arg; 52 50 char *buffer; 53 char * transport_buffer;51 char *data_buffer; 54 52 size_t buffer_size; 55 53 char *setup_buffer; 56 54 size_t setup_size; 57 size_t max_packet_size;58 55 size_t transfered_size; 59 56 void (*next_step)(usb_transfer_batch_t *); 60 57 int error; 61 58 ddf_fun_t *fun; 62 void *arg;63 endpoint_t *ep;64 59 void *private_data; 60 void (*private_data_dtor)(void *p_data); 65 61 }; 66 62 67 63 void usb_transfer_batch_init( 68 64 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, 73 66 char *buffer, 74 char * transport_buffer,67 char *data_buffer, 75 68 size_t buffer_size, 76 69 char *setup_buffer, … … 80 73 void *arg, 81 74 ddf_fun_t *fun, 82 endpoint_t *ep,83 void *private_data75 void *private_data, 76 void (*private_data_dtor)(void *p_data) 84 77 ); 78 79 void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance); 80 void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance); 81 void usb_transfer_batch_finish(usb_transfer_batch_t *instance); 82 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance); 83 84 static 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 } 85 91 86 92 static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l) … … 90 96 } 91 97 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 96 98 #endif 97 99 /** -
uspace/lib/usb/include/usb/host/device_keeper.h
ref354b6 re50cd7f 54 54 usb_speed_t speed; 55 55 bool occupied; 56 link_t endpoints;57 uint16_t control_used;58 56 devman_handle_t handle; 59 57 }; … … 65 63 struct usb_device_info devices[USB_ADDRESS_COUNT]; 66 64 fibril_mutex_t guard; 67 fibril_condvar_t change;68 65 usb_address_t last_address; 69 66 } usb_device_keeper_t; 70 67 71 68 void 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);83 69 84 70 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance, … … 96 82 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 97 83 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 105 84 #endif 106 85 /** -
uspace/lib/usb/include/usb/host/endpoint.h
ref354b6 re50cd7f 39 39 #include <bool.h> 40 40 #include <adt/list.h> 41 #include <fibril_synch.h> 42 41 43 #include <usb/usb.h> 42 44 … … 48 50 usb_speed_t speed; 49 51 size_t max_packet_size; 50 bool active;51 52 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; 53 61 } endpoint_t; 54 62 … … 59 67 void endpoint_destroy(endpoint_t *instance); 60 68 69 void endpoint_set_hc_data(endpoint_t *instance, 70 void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int)); 71 72 void endpoint_clear_hc_data(endpoint_t *instance); 73 74 void endpoint_use(endpoint_t *instance); 75 76 void endpoint_release(endpoint_t *instance); 77 61 78 int endpoint_toggle_get(endpoint_t *instance); 62 79 63 80 void endpoint_toggle_set(endpoint_t *instance, int toggle); 64 81 65 void endpoint_toggle_reset(link_t *ep); 66 67 void endpoint_toggle_reset_filtered(link_t *ep, usb_endpoint_t epn); 68 82 void endpoint_toggle_reset_filtered(endpoint_t *instance, usb_target_t target); 69 83 #endif 70 84 /** -
uspace/lib/usb/include/usb/host/usb_endpoint_manager.h
ref354b6 re50cd7f 66 66 endpoint_t *ep, size_t data_size); 67 67 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 73 68 int usb_endpoint_manager_unregister_ep(usb_endpoint_manager_t *instance, 74 69 usb_address_t address, usb_endpoint_t ep, usb_direction_t direction); … … 78 73 size_t *bw); 79 74 75 void usb_endpoint_manager_reset_if_need( 76 usb_endpoint_manager_t *instance, usb_target_t target, const uint8_t *data); 77 78 static 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 } 80 101 #endif 81 102 /** -
uspace/lib/usb/include/usb/hub.h
ref354b6 re50cd7f 59 59 } usb_hc_attached_device_t; 60 60 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 64 61 usb_address_t usb_hc_request_address(usb_hc_connection_t *, usb_speed_t); 65 62 int usb_hc_register_device(usb_hc_connection_t *, -
uspace/lib/usb/include/usb/pipes.h
ref354b6 re50cd7f 42 42 #include <ipc/devman.h> 43 43 #include <ddf/driver.h> 44 #include <fibril_synch.h> 44 45 45 46 /** Abstraction of a physical connection to the device. … … 59 60 * This endpoint must be bound with existing usb_device_connection_t 60 61 * (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. 61 67 */ 62 68 typedef struct { 69 /** Guard of the whole pipe. */ 70 fibril_mutex_t guard; 71 63 72 /** The connection used for sending the data. */ 64 73 usb_device_connection_t *wire; … … 78 87 /** Phone to the host controller. 79 88 * 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]. 80 93 */ 81 94 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; 82 106 } usb_pipe_t; 83 107 … … 134 158 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *, 135 159 size_t, uint8_t *, size_t, usb_device_connection_t *); 160 int usb_pipe_register_with_speed(usb_pipe_t *, usb_speed_t, 161 unsigned int, usb_hc_connection_t *); 136 162 int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *); 137 163 int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *); … … 140 166 int usb_pipe_end_session(usb_pipe_t *); 141 167 bool usb_pipe_is_session_started(usb_pipe_t *); 168 169 int usb_pipe_start_long_transfer(usb_pipe_t *); 170 void usb_pipe_end_long_transfer(usb_pipe_t *); 142 171 143 172 int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *); -
uspace/lib/usb/include/usb/request.h
ref354b6 re50cd7f 50 50 /** USB endpoint status - endpoint is halted (stalled). */ 51 51 #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) 52 58 53 59 /** Standard device request. */ … … 135 141 char **); 136 142 143 int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t); 144 137 145 #endif 138 146 /** -
uspace/lib/usb/include/usb/usb.h
ref354b6 re50cd7f 77 77 USB_SPEED_FULL, 78 78 /** 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 80 82 } usb_speed_t; 81 83
Note:
See TracChangeset
for help on using the changeset viewer.