Changeset e1dbcbc in mainline for uspace/lib/usb/include
- Timestamp:
- 2011-04-29T13:43:01Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a81a1d09
- Parents:
- 380e0364 (diff), f19f1b7 (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:
-
- 2 added
- 13 edited
-
classes/hid.h (modified) (1 diff)
-
classes/hid/iface.h (added)
-
classes/hidparser.h (modified) (11 diffs)
-
classes/hidreport.h (modified) (1 diff)
-
classes/hidut.h (modified) (1 diff)
-
classes/hub.h (modified) (1 diff)
-
debug.h (modified) (2 diffs)
-
devdrv.h (modified) (1 diff)
-
devpoll.h (added)
-
host/batch.h (modified) (3 diffs)
-
host/device_keeper.h (modified) (2 diffs)
-
host/endpoint.h (modified) (2 diffs)
-
host/usb_endpoint_manager.h (modified) (2 diffs)
-
pipes.h (modified) (2 diffs)
-
usb.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/classes/hid.h
r380e0364 re1dbcbc 50 50 USB_HIDREQ_SET_PROTOCOL = 11 51 51 } usb_hid_request_t; 52 53 typedef enum {54 USB_HID_REPORT_TYPE_INPUT = 1,55 USB_HID_REPORT_TYPE_OUTPUT = 2,56 USB_HID_REPORT_TYPE_FEATURE = 357 } usb_hid_report_type_t;58 52 59 53 typedef enum { -
uspace/lib/usb/include/usb/classes/hidparser.h
r380e0364 re1dbcbc 73 73 #define USB_HID_PATH_COMPARE_END 1 74 74 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 4 75 76 /** */ 77 typedef struct { 78 /** */ 79 int32_t usage_page; 80 /** */ 81 int32_t usage; 75 #define USB_HID_PATH_COMPARE_COLLECTION_ONLY 2 /* porovnava jenom cestu z Kolekci */ 76 77 78 #define USB_HID_MAX_USAGES 20 79 80 typedef enum { 81 USB_HID_REPORT_TYPE_INPUT = 1, 82 USB_HID_REPORT_TYPE_OUTPUT = 2, 83 USB_HID_REPORT_TYPE_FEATURE = 3 84 } usb_hid_report_type_t; 85 86 /** Collection usage path structure */ 87 typedef struct { 88 /** */ 89 uint32_t usage_page; 90 /** */ 91 uint32_t usage; 92 93 uint8_t flags; 82 94 /** */ 83 95 link_t link; … … 91 103 92 104 /** */ 105 link_t link; /* list */ 106 107 link_t head; /* head of list of usage paths */ 108 109 } usb_hid_report_path_t; 110 111 112 typedef struct { 113 /** */ 114 int report_count; 115 link_t reports; /** list of usb_hid_report_description_t */ 116 117 link_t collection_paths; 118 int collection_paths_count; 119 120 int use_report_ids; 121 uint8_t last_report_id; 122 123 } usb_hid_report_t; 124 125 typedef struct { 126 uint8_t report_id; 127 usb_hid_report_type_t type; 128 129 size_t bit_length; 130 size_t item_length; 131 132 link_t report_items; /** list of report items (fields) */ 133 93 134 link_t link; 94 95 } usb_hid_report_path_t; 96 97 /** 98 * Description of report items 99 */ 100 typedef struct { 101 /** */ 135 } usb_hid_report_description_t; 136 137 typedef struct { 138 139 int offset; 140 size_t size; 141 142 uint16_t usage_page; 143 uint16_t usage; 144 145 uint8_t item_flags; 146 usb_hid_report_path_t *collection_path; 147 148 int32_t logical_minimum; 149 int32_t logical_maximum; 150 int32_t physical_minimum; 151 int32_t physical_maximum; 152 uint32_t usage_minimum; 153 uint32_t usage_maximum; 154 uint32_t unit; 155 uint32_t unit_exponent; 156 157 158 int32_t value; 159 160 link_t link; 161 } usb_hid_report_field_t; 162 163 164 165 /** 166 * state table 167 */ 168 typedef struct { 169 /** report id */ 102 170 int32_t id; 103 /** */ 104 int32_t usage_minimum; 105 /** */ 106 int32_t usage_maximum; 171 172 /** */ 173 uint16_t extended_usage_page; 174 uint32_t usages[USB_HID_MAX_USAGES]; 175 int usages_count; 176 177 /** */ 178 uint32_t usage_page; 179 180 /** */ 181 uint32_t usage_minimum; 182 /** */ 183 uint32_t usage_maximum; 107 184 /** */ 108 185 int32_t logical_minimum; … … 116 193 size_t offset; 117 194 /** */ 118 int32_t delimiter;119 /** */120 195 int32_t unit_exponent; 121 196 /** */ … … 123 198 124 199 /** */ 125 int32_t string_index;126 /** */ 127 int32_t string_minimum;128 /** */ 129 int32_t string_maximum;130 /** */ 131 int32_t designator_index;132 /** */ 133 int32_t designator_minimum;134 /** */ 135 int32_t designator_maximum;200 uint32_t string_index; 201 /** */ 202 uint32_t string_minimum; 203 /** */ 204 uint32_t string_maximum; 205 /** */ 206 uint32_t designator_index; 207 /** */ 208 uint32_t designator_minimum; 209 /** */ 210 uint32_t designator_maximum; 136 211 /** */ 137 212 int32_t physical_minimum; … … 142 217 uint8_t item_flags; 143 218 144 /** */ 219 usb_hid_report_type_t type; 220 221 /** current collection path*/ 145 222 usb_hid_report_path_t *usage_path; 146 223 /** */ 147 224 link_t link; 148 225 } usb_hid_report_item_t; 149 150 151 /** HID report parser structure. */152 typedef struct {153 /** */154 link_t input;155 /** */156 link_t output;157 /** */158 link_t feature;159 160 int use_report_id;161 162 /** */163 link_t stack;164 } usb_hid_report_parser_t;165 166 226 167 227 /** HID parser callbacks for IN items. */ … … 189 249 } usb_hid_modifiers_t; 190 250 191 //typedef enum {192 // USB_HID_LED_NUM_LOCK = 0x1,193 // USB_HID_LED_CAPS_LOCK = 0x2,194 // USB_HID_LED_SCROLL_LOCK = 0x4,195 // USB_HID_LED_COMPOSE = 0x8,196 // USB_HID_LED_KANA = 0x10,197 // USB_HID_LED_COUNT = 5198 //} usb_hid_led_t;199 200 251 static const usb_hid_modifiers_t 201 252 usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = { … … 210 261 }; 211 262 212 //static const usb_hid_led_t usb_hid_led_consts[USB_HID_LED_COUNT] = {213 // USB_HID_LED_NUM_LOCK,214 // USB_HID_LED_CAPS_LOCK,215 // USB_HID_LED_SCROLL_LOCK,216 // USB_HID_LED_COMPOSE,217 // USB_HID_LED_KANA218 //};219 220 //#define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01221 //#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02222 //#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04223 //#define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08224 //#define USB_HID_BOOT_KEYBOARD_KANA 0x10225 226 263 /* 227 264 * Descriptor parser functions 228 265 */ 229 /** */ 230 int usb_hid_parser_init(usb_hid_report_parser_t *parser); 231 232 /** */ 233 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 266 267 /** */ 268 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 234 269 const uint8_t *data, size_t size); 235 270 236 271 /** */ 237 void usb_hid_free_report_parser(usb_hid_report_parser_t *parser); 238 239 /** */ 240 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser); 241 242 /* 243 * Boot protocol functions 244 */ 245 /** */ 246 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size, 247 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 248 249 /** */ 250 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size); 272 void usb_hid_free_report(usb_hid_report_t *report); 273 274 /** */ 275 void usb_hid_descriptor_print(usb_hid_report_t *report); 251 276 252 277 … … 255 280 */ 256 281 /** */ 257 int usb_hid_parse_report(const usb_hid_report_parser_t *parser, 258 const uint8_t *data, size_t size, 259 usb_hid_report_path_t *path, int flags, 260 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 261 262 /** */ 263 size_t usb_hid_report_input_length(const usb_hid_report_parser_t *parser, 282 int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, size_t size, uint8_t *report_id); 283 284 /** */ 285 size_t usb_hid_report_input_length(const usb_hid_report_t *report, 264 286 usb_hid_report_path_t *path, int flags); 265 287 … … 296 318 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path); 297 319 320 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); 321 322 uint8_t usb_hid_report_get_report_id(usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type); 323 298 324 299 325 /* … … 301 327 */ 302 328 /** Allocates output report buffer*/ 303 uint8_t *usb_hid_report_output(usb_hid_report_ parser_t *parser, size_t *size);329 uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, uint8_t report_id); 304 330 305 331 /** Frees output report buffer*/ … … 307 333 308 334 /** Returns size of output for given usage path */ 309 size_t usb_hid_report_output_size(usb_hid_report_ parser_t *parser,335 size_t usb_hid_report_output_size(usb_hid_report_t *report, 310 336 usb_hid_report_path_t *path, int flags); 311 337 312 /** Updates the output report buffer by translated given data */ 313 int usb_hid_report_output_translate(usb_hid_report_parser_t *parser, 314 usb_hid_report_path_t *path, int flags, 315 uint8_t *buffer, size_t size, 316 int32_t *data, size_t data_size); 338 /** Sets data in report structure */ 339 int usb_hid_report_output_set_data(usb_hid_report_t *report, 340 usb_hid_report_path_t *path, int flags, 341 int *data, size_t data_size); 342 343 /** Makes the output report buffer by translated given data */ 344 int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, uint8_t *buffer, size_t size); 317 345 #endif 318 346 /** -
uspace/lib/usb/include/usb/classes/hidreport.h
r380e0364 re1dbcbc 57 57 */ 58 58 int usb_hid_process_report_descriptor(usb_device_t *dev, 59 usb_hid_report_ parser_t *parser);59 usb_hid_report_t *report); 60 60 61 61 #endif /* LIBUSB_HIDREPORT_H_ */ -
uspace/lib/usb/include/usb/classes/hidut.h
r380e0364 re1dbcbc 46 46 USB_HIDUT_PAGE_KEYBOARD = 7, 47 47 USB_HIDUT_PAGE_LED = 8, 48 USB_HIDUT_PAGE_BUTTON = 9 49 /* USB_HIDUT_PAGE_ = , */ 48 USB_HIDUT_PAGE_BUTTON = 9, 49 USB_HIDUT_PAGE_ORDINAL = 0x0a, 50 USB_HIDUT_PAGE_TELEPHONY_DEVICE = 0x0b, 51 USB_HIDUT_PAGE_CONSUMER = 0x0c 50 52 } usb_hidut_usage_page_t; 51 53 -
uspace/lib/usb/include/usb/classes/hub.h
r380e0364 re1dbcbc 152 152 maximum of 255 ports). 153 153 */ 154 uint8_t * devices_removable;154 uint8_t devices_removable[32]; 155 155 156 156 /** -
uspace/lib/usb/include/usb/debug.h
r380e0364 re1dbcbc 36 36 #define LIBUSB_DEBUG_H_ 37 37 #include <stdio.h> 38 #include <inttypes.h> 38 39 #include <usb/usb.h> 39 40 #include <assert.h> … … 85 86 void usb_log_enable(usb_log_level_t, const char *); 86 87 87 void usb_log_printf(usb_log_level_t, const char *, ...); 88 void usb_log_printf(usb_log_level_t, const char *, ...) 89 PRINTF_ATTRIBUTE(2, 3); 88 90 89 91 /** Log fatal error. */ -
uspace/lib/usb/include/usb/devdrv.h
r380e0364 re1dbcbc 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 *);167 168 int usb_device_auto_poll(usb_device_t *, size_t,169 usb_polling_callback_t, size_t, usb_polling_terminted_callback_t, void *);170 171 164 int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *); 172 165 int usb_device_create_pipes(ddf_dev_t *, usb_device_connection_t *, -
uspace/lib/usb/include/usb/host/batch.h
r380e0364 re1dbcbc 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 ); 85 78 86 static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l) 87 { 88 assert(l); 89 return list_get_instance(l, usb_transfer_batch_t, link); 90 } 91 92 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance); 93 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance); 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); 94 81 void usb_transfer_batch_finish(usb_transfer_batch_t *instance); 82 void usb_transfer_batch_dispose(usb_transfer_batch_t *instance); 95 83 96 84 static inline void usb_transfer_batch_finish_error( … … 102 90 } 103 91 92 static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l) 93 { 94 assert(l); 95 return list_get_instance(l, usb_transfer_batch_t, link); 96 } 97 104 98 #endif 105 99 /** -
uspace/lib/usb/include/usb/host/device_keeper.h
r380e0364 re1dbcbc 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_reserve_default_address(74 usb_device_keeper_t *instance, usb_speed_t speed);75 76 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance);77 78 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance,79 usb_target_t target, const uint8_t *setup_data);80 69 81 70 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance, -
uspace/lib/usb/include/usb/host/endpoint.h
r380e0364 re1dbcbc 54 54 fibril_condvar_t avail; 55 55 volatile bool active; 56 struct { 57 void *data; 58 int (*toggle_get)(void *); 59 void (*toggle_set)(void *, int); 60 } hc_data; 56 61 } endpoint_t; 57 62 … … 61 66 62 67 void endpoint_destroy(endpoint_t *instance); 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); 63 73 64 74 void endpoint_use(endpoint_t *instance); -
uspace/lib/usb/include/usb/host/usb_endpoint_manager.h
r380e0364 re1dbcbc 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); … … 80 75 void usb_endpoint_manager_reset_if_need( 81 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 } 82 101 #endif 83 102 /** -
uspace/lib/usb/include/usb/pipes.h
r380e0364 re1dbcbc 99 99 /** Number of active transfers over the pipe. */ 100 100 int refcount; 101 /** Number of failed attempts to open the HC phone. 102 * When user requests usb_pipe_start_long_transfer() and the operation 103 * fails, there is no way to report this to the user. 104 * That the soft reference counter is increased to record the attempt. 105 * When the user then request e.g. usb_pipe_read(), it will try to 106 * add reference as well. 107 * If that fails, it is reported to the user. If it is okay, the 108 * real reference counter is incremented. 109 * The problem might arise when ending the long transfer (since 110 * the number of references would be only 1, but logically it shall be 111 * two). 112 * Decrementing the soft counter first shall solve this. 113 */ 114 int refcount_soft; 115 116 /** Whether to automatically reset halt on the endpoint. 117 * Valid only for control endpoint zero. 118 */ 119 bool auto_reset_halt; 101 120 } usb_pipe_t; 102 121 … … 158 177 int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *); 159 178 160 int usb_pipe_start_session(usb_pipe_t *); 161 int usb_pipe_end_session(usb_pipe_t *); 162 bool usb_pipe_is_session_started(usb_pipe_t *); 163 164 int usb_pipe_start_long_transfer(usb_pipe_t *); 179 void usb_pipe_start_long_transfer(usb_pipe_t *); 165 180 void usb_pipe_end_long_transfer(usb_pipe_t *); 166 181 -
uspace/lib/usb/include/usb/usb.h
r380e0364 re1dbcbc 96 96 USB_REQUEST_RECIPIENT_DEVICE = 0, 97 97 USB_REQUEST_RECIPIENT_INTERFACE = 1, 98 USB_REQUEST_RECIPIENT_ENDPOINT = 2 98 USB_REQUEST_RECIPIENT_ENDPOINT = 2, 99 USB_REQUEST_RECIPIENT_OTHER = 3 99 100 } usb_request_recipient_t; 100 101
Note:
See TracChangeset
for help on using the changeset viewer.
