Changeset 1824609b in mainline for uspace/lib/usb
- Timestamp:
- 2011-02-11T18:16:03Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 345ea18
- Parents:
- 8f198c9 (diff), d321cd7 (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
- Files:
-
- 2 added
- 5 edited
-
Makefile (modified) (1 diff)
-
include/usb/pipes.h (modified) (4 diffs)
-
include/usb/recognise.h (added)
-
include/usb/usbdrv.h (modified) (1 diff)
-
src/pipes.c (modified) (4 diffs)
-
src/pipesinit.c (added)
-
src/recognise.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/Makefile
r8f198c9 r1824609b 44 44 src/localdrv.c \ 45 45 src/pipes.c \ 46 src/pipesinit.c \ 46 47 src/recognise.c \ 47 48 src/remotedrv.c \ -
uspace/lib/usb/include/usb/pipes.h
r8f198c9 r1824609b 38 38 #include <sys/types.h> 39 39 #include <usb/usb.h> 40 #include <usb/descriptor.h> 40 41 #include <ipc/devman.h> 41 42 #include <driver.h> … … 73 74 usb_direction_t direction; 74 75 76 /** Maximum packet size for the endpoint. */ 77 size_t max_packet_size; 78 75 79 /** Phone to the host controller. 76 80 * Negative when no session is active. … … 79 83 } usb_endpoint_pipe_t; 80 84 85 86 /** Description of endpoint characteristics. */ 87 typedef struct { 88 /** Transfer type (e.g. control or interrupt). */ 89 usb_transfer_type_t transfer_type; 90 /** Transfer direction (to or from a device). */ 91 usb_direction_t direction; 92 /** Interface class this endpoint belongs to (-1 for any). */ 93 int interface_class; 94 /** Interface subclass this endpoint belongs to (-1 for any). */ 95 int interface_subclass; 96 /** Interface protocol this endpoint belongs to (-1 for any). */ 97 int interface_protocol; 98 /** Extra endpoint flags. */ 99 unsigned int flags; 100 } usb_endpoint_description_t; 101 102 /** Mapping of endpoint pipes and endpoint descriptions. */ 103 typedef struct { 104 /** Endpoint pipe. */ 105 usb_endpoint_pipe_t *pipe; 106 /** Endpoint description. */ 107 const usb_endpoint_description_t *description; 108 /** Found descriptor fitting the description. */ 109 usb_standard_endpoint_descriptor_t *descriptor; 110 /** Interface the endpoint belongs to. */ 111 usb_standard_interface_descriptor_t *interface; 112 /** Whether the endpoint was actually found. */ 113 bool present; 114 } usb_endpoint_mapping_t; 81 115 82 116 int usb_device_connection_initialize_from_device(usb_device_connection_t *, … … 87 121 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *, 88 122 usb_device_connection_t *, 89 usb_endpoint_t, usb_transfer_type_t, usb_direction_t);123 usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t); 90 124 int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *, 91 125 usb_device_connection_t *); 126 int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *, 127 size_t, uint8_t *, size_t, usb_device_connection_t *); 92 128 93 129 -
uspace/lib/usb/include/usb/usbdrv.h
r8f198c9 r1824609b 106 106 const void *, size_t); 107 107 108 int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t);109 int usb_drv_register_child_in_devman(int, device_t *, usb_address_t,110 devman_handle_t *);111 112 108 113 109 #endif -
uspace/lib/usb/src/pipes.c
r8f198c9 r1824609b 123 123 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15). 124 124 * @param transfer_type Transfer type (e.g. interrupt or bulk). 125 * @param max_packet_size Maximum packet size in bytes. 125 126 * @param direction Endpoint direction (in/out). 126 127 * @return Error code. … … 128 129 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *pipe, 129 130 usb_device_connection_t *connection, usb_endpoint_t endpoint_no, 130 usb_transfer_type_t transfer_type, usb_direction_t direction) 131 usb_transfer_type_t transfer_type, size_t max_packet_size, 132 usb_direction_t direction) 131 133 { 132 134 assert(pipe); … … 137 139 pipe->endpoint_no = endpoint_no; 138 140 pipe->transfer_type = transfer_type; 141 pipe->max_packet_size = max_packet_size; 139 142 pipe->direction = direction; 140 143 … … 156 159 157 160 int rc = usb_endpoint_pipe_initialize(pipe, connection, 158 0, USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH);161 0, USB_TRANSFER_CONTROL, 8, USB_DIRECTION_BOTH); 159 162 160 163 return rc; -
uspace/lib/usb/src/recognise.c
r8f198c9 r1824609b 36 36 #include <usb_iface.h> 37 37 #include <usb/usbdrv.h> 38 #include <usb/pipes.h> 39 #include <usb/recognise.h> 40 #include <usb/request.h> 38 41 #include <usb/classes/classes.h> 39 42 #include <stdio.h> 40 43 #include <errno.h> 44 45 static size_t device_name_index = 0; 46 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex); 41 47 42 48 /** Callback for getting host controller handle. … … 241 247 /** Add match ids based on configuration descriptor. 242 248 * 243 * @param hc Open phone to host controller.249 * @param pipe Control pipe to the device. 244 250 * @param matches Match ids list to add matches to. 245 * @param address USB address of the attached device.246 251 * @param config_count Number of configurations the device has. 247 252 * @return Error code. 248 253 */ 249 static int usb_add_config_descriptor_match_ids(int hc, 250 match_id_list_t *matches, usb_address_t address, 251 int config_count) 254 static int usb_add_config_descriptor_match_ids(usb_endpoint_pipe_t *pipe, 255 match_id_list_t *matches, int config_count) 252 256 { 253 257 int final_rc = EOK; … … 257 261 int rc; 258 262 usb_standard_configuration_descriptor_t config_descriptor; 259 rc = usb_ drv_req_get_bare_configuration_descriptor(hc,260 address,config_index, &config_descriptor);263 rc = usb_request_get_bare_configuration_descriptor(pipe, 264 config_index, &config_descriptor); 261 265 if (rc != EOK) { 262 266 final_rc = rc; … … 267 271 void *full_config_descriptor 268 272 = malloc(config_descriptor.total_length); 269 rc = usb_ drv_req_get_full_configuration_descriptor(hc,270 address,config_index,273 rc = usb_request_get_full_configuration_descriptor(pipe, 274 config_index, 271 275 full_config_descriptor, config_descriptor.total_length, 272 276 &full_config_descriptor_size); … … 299 303 * function exits with error. 300 304 * 301 * @param hc Open phone to host controller. 305 * @param ctrl_pipe Control pipe to given device (session must be already 306 * started). 302 307 * @param matches Initialized list of match ids. 303 * @param address USB address of the attached device. 304 * @return Error code. 305 */ 306 int usb_drv_create_device_match_ids(int hc, match_id_list_t *matches, 307 usb_address_t address) 308 * @return Error code. 309 */ 310 int usb_device_create_match_ids(usb_endpoint_pipe_t *ctrl_pipe, 311 match_id_list_t *matches) 308 312 { 309 313 int rc; 310 311 314 /* 312 315 * Retrieve device descriptor and add matches from it. … … 314 317 usb_standard_device_descriptor_t device_descriptor; 315 318 316 rc = usb_drv_req_get_device_descriptor(hc, address, 317 &device_descriptor); 319 rc = usb_request_get_device_descriptor(ctrl_pipe, &device_descriptor); 318 320 if (rc != EOK) { 319 321 return rc; 320 322 } 321 323 322 324 rc = usb_drv_create_match_ids_from_device_descriptor(matches, 323 325 &device_descriptor); … … 325 327 return rc; 326 328 } 327 329 328 330 /* 329 331 * Go through all configurations and add matches 330 332 * based on interface class. 331 333 */ 332 rc = usb_add_config_descriptor_match_ids( hc, matches,333 address,device_descriptor.configuration_count);334 rc = usb_add_config_descriptor_match_ids(ctrl_pipe, matches, 335 device_descriptor.configuration_count); 334 336 if (rc != EOK) { 335 337 return rc; … … 347 349 } 348 350 349 350 351 /** Probe for device kind and register it in devman. 351 352 * 352 * @param[in] hc Open phone to the host controller. 353 * @param[in] address Address of the (unknown) attached device. 354 * @param[in] hc_handle Handle of the host controller. 353 355 * @param[in] parent Parent device. 354 * @param[in] address Address of the (unknown) attached device.355 356 * @param[out] child_handle Handle of the child device. 356 357 * @return Error code. 357 358 */ 358 int usb_drv_register_child_in_devman(int hc, device_t *parent, 359 usb_address_t address, devman_handle_t *child_handle) 360 { 361 static size_t device_name_index = 0; 362 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex); 363 359 int usb_device_register_child_in_devman(usb_address_t address, 360 devman_handle_t hc_handle, 361 device_t *parent, devman_handle_t *child_handle) 362 { 364 363 size_t this_device_name_index; 365 364 … … 369 368 fibril_mutex_unlock(&device_name_index_mutex); 370 369 371 372 370 device_t *child = NULL; 373 371 char *child_name = NULL; 374 372 int rc; 373 usb_device_connection_t dev_connection; 374 usb_endpoint_pipe_t ctrl_pipe; 375 376 rc = usb_device_connection_initialize(&dev_connection, hc_handle, address); 377 if (rc != EOK) { 378 goto failure; 379 } 380 381 rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe, 382 &dev_connection); 383 if (rc != EOK) { 384 goto failure; 385 } 375 386 376 387 child = create_device(); … … 391 402 child->name = child_name; 392 403 child->ops = &child_ops; 393 394 rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address); 404 405 rc = usb_endpoint_pipe_start_session(&ctrl_pipe); 406 if (rc != EOK) { 407 goto failure; 408 } 409 410 rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids); 411 if (rc != EOK) { 412 goto failure; 413 } 414 415 rc = usb_endpoint_pipe_end_session(&ctrl_pipe); 395 416 if (rc != EOK) { 396 417 goto failure; … … 405 426 *child_handle = child->handle; 406 427 } 407 428 408 429 return EOK; 409 430 … … 419 440 420 441 return rc; 421 422 442 } 423 443
Note:
See TracChangeset
for help on using the changeset viewer.
