Changes in / [0c00dac:50ba203] in mainline
- Location:
- uspace/drv/usbhub
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r0c00dac r50ba203 43 43 #include <usb/recognise.h> 44 44 #include <usb/devreq.h> 45 #include <usb/request.h> 45 46 #include <usb/classes/hub.h> 46 47 … … 49 50 #include "port_status.h" 50 51 #include "usb/usb.h" 52 #include "usb/pipes.h" 51 53 52 54 static usb_iface_t hub_usb_iface = { … … 64 66 //********************************************* 65 67 66 usb_hub_info_t * usb_create_hub_info(device_t * device , int hc) {68 usb_hub_info_t * usb_create_hub_info(device_t * device) { 67 69 usb_hub_info_t* result = usb_new(usb_hub_info_t); 70 usb_device_connection_initialize_from_device(&result->connection, device); 71 usb_endpoint_pipe_initialize_default_control(&result->endpoints.control, 72 &result->connection); 73 74 68 75 //result->device = device; 69 76 result->port_count = -1; … … 71 78 result->device = device; 72 79 80 <<<<<<< TREE 81 result->usb_device = usb_new(usb_hcd_attached_device_info_t); 82 83 ======= 73 84 74 85 dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc); … … 86 97 result->address = addr; 87 98 99 >>>>>>> MERGE-SOURCE 88 100 // get hub descriptor 89 101 … … 94 106 int opResult; 95 107 dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction"); 96 97 opResult = usb_ drv_req_get_descriptor(hc, addr,108 usb_endpoint_pipe_start_session(&result->endpoints.control); 109 opResult = usb_request_get_descriptor(&result->endpoints.control, 98 110 USB_REQUEST_TYPE_CLASS, 99 111 USB_DESCTYPE_HUB, 0, 0, serialized_descriptor, 100 112 USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size); 113 usb_endpoint_pipe_end_session(&result->endpoints.control); 114 115 /* Initialize the interrupt endpoint. 116 usb_endpoint_pipe_initalize( 117 &hub_data->endpoints->status_change, 118 &endpiont_descriptor, &hub_data->connection); 119 120 */ /// \TODO add this call 101 121 102 122 if (opResult != EOK) { … … 143 163 dev->ops = &hub_device_ops; 144 164 145 //create the hub structure 146 //get hc connection 147 int hc = usb_drv_hc_connect_auto(dev, 0); 148 if (hc < 0) { 149 return hc; 150 } 151 152 usb_hub_info_t * hub_info = usb_create_hub_info(dev, hc); 165 166 usb_hub_info_t * hub_info = usb_create_hub_info(dev); 167 usb_endpoint_pipe_start_session(&hub_info->endpoints.control); 153 168 int port; 154 169 int opResult; 170 <<<<<<< TREE 171 //usb_target_t target; 172 //target.address = hub_info->usb_device->address; 173 //target.endpoint = 0; 174 ======= 155 175 usb_target_t target; 156 176 target.address = hub_info->address; 157 177 target.endpoint = 0; 178 >>>>>>> MERGE-SOURCE 158 179 159 180 //get configuration descriptor … … 161 182 // and all should be checked 162 183 usb_standard_device_descriptor_t std_descriptor; 163 opResult = usb_ drv_req_get_device_descriptor(hc, target.address,184 opResult = usb_request_get_device_descriptor(&hub_info->endpoints.control, 164 185 &std_descriptor); 165 186 if(opResult!=EOK){ … … 174 195 /// \TODO check other configurations 175 196 usb_standard_configuration_descriptor_t config_descriptor; 176 opResult = usb_ drv_req_get_bare_configuration_descriptor(hc,177 target.address, 0,197 opResult = usb_request_get_bare_configuration_descriptor( 198 &hub_info->endpoints.control, 0, 178 199 &config_descriptor); 179 200 if(opResult!=EOK){ … … 182 203 } 183 204 //set configuration 184 opResult = usb_ drv_req_set_configuration(hc, target.address,205 opResult = usb_request_set_configuration(&hub_info->endpoints.control, 185 206 config_descriptor.configuration_number); 186 207 … … 192 213 for (port = 1; port < hub_info->port_count+1; ++port) { 193 214 usb_hub_set_power_port_request(&request, port); 194 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0); 215 opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control, 216 &request,sizeof(usb_device_request_setup_packet_t), NULL, 0); 195 217 dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port); 196 218 if (opResult != EOK) { … … 200 222 //ports powered, hub seems to be enabled 201 223 202 async_hangup(hc); 224 usb_endpoint_pipe_end_session(&hub_info->endpoints.control); 225 //async_hangup(hc); 203 226 204 227 //add the hub to list … … 252 275 * @param target 253 276 */ 254 static void usb_hub_init_add_device( int hc, uint16_t port, usb_target_t target) {277 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port) { 255 278 usb_device_request_setup_packet_t request; 256 279 int opResult; 257 280 dprintf(USB_LOG_LEVEL_INFO, "some connection changed"); 258 281 //get default address 282 ///////////////here ended pipe api upgrading 283 gfdl;gfdgldglglkfgklfjfkld;sjgk;fgklsjgld 259 284 opResult = usb_drv_reserve_default_address(hc); 260 285 if (opResult != EOK) { … … 383 408 * @param target 384 409 */ 385 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,386 uint16_t port , usb_address_t address) {410 static void usb_hub_process_interrupt(usb_hub_info_t * hub, 411 uint16_t port) { 387 412 dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port); 388 413 //determine type of change 414 int opResult = usb_endpoint_pipe_start_session(&hub->endpoints.control); 415 usb_endpoint_pipe_t *pipe = &hub->endpoints.control; 416 if(opResult != EOK){ 417 continue; 418 } 419 420 /* 389 421 usb_target_t target; 390 422 target.address=address; 391 423 target.endpoint=0; 424 */ 425 392 426 usb_port_status_t status; 393 427 size_t rcvd_size; 394 428 usb_device_request_setup_packet_t request; 395 int opResult;429 //int opResult; 396 430 usb_hub_set_port_status_request(&request, port); 397 431 //endpoint 0 398 432 399 opResult = usb_ drv_sync_control_read(400 hc, target,401 &request, 433 opResult = usb_endpoint_pipe_control_read( 434 pipe, 435 &request, sizeof(usb_device_request_setup_packet_t), 402 436 &status, 4, &rcvd_size 403 437 ); … … 412 446 //something connected/disconnected 413 447 if (usb_port_connect_change(&status)) { 414 opResult = usb_hub_clear_port_feature( hc, target.address,448 opResult = usb_hub_clear_port_feature(&hub->endpoints.control, 415 449 port, USB_HUB_FEATURE_C_PORT_CONNECTION); 416 450 // TODO: check opResult 417 451 if (usb_port_dev_connected(&status)) { 418 452 dprintf(USB_LOG_LEVEL_INFO, "some connection changed"); 419 usb_hub_init_add_device(h c, port, target);453 usb_hub_init_add_device(hub, port); 420 454 } else { 421 usb_hub_removed_device(hub, hc, port, target);455 usb_hub_removed_device(hub, port); 422 456 } 423 457 } … … 426 460 dprintf(USB_LOG_LEVEL_INFO, "port reset complete"); 427 461 if (usb_port_enabled(&status)) { 428 usb_hub_finalize_add_device(hub, hc, port, target);462 usb_hub_finalize_add_device(hub, port); 429 463 } else { 430 464 dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled"); … … 442 476 /// \TODO handle other changes 443 477 /// \TODO debug log for various situations 478 usb_endpoint_pipe_end_session(&hub->endpoints.control); 479 444 480 445 481 } … … 459 495 fibril_mutex_unlock(&usb_hub_list_lock); 460 496 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 497 int opResult; 498 499 opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change); 500 if(opResult != EOK){ 501 continue; 502 } 461 503 /* 462 504 * Check status change pipe of this hub. 463 505 */ 464 506 /* 465 507 usb_target_t target; 466 508 target.address = hub_info->address; … … 468 510 dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d", 469 511 target.address); 470 512 */ 471 513 size_t port_count = hub_info->port_count; 472 514 473 515 /* 474 516 * Connect to respective HC. 475 * /517 * 476 518 int hc = usb_drv_hc_connect_auto(hub_info->device, 0); 477 519 if (hc < 0) { 478 520 continue; 479 } 521 }*/ 480 522 481 523 /// FIXME: count properly … … 489 531 * Send the request. 490 532 */ 491 int opResult = usb_drv_async_interrupt_in(hc, target, 533 opResult = usb_endpoint_pipe_read( 534 &hub_info->endpoints.status_change, 492 535 change_bitmap, byte_length, &actual_size, 493 &handle);536 ); 494 537 495 538 usb_drv_async_wait_for(handle); … … 506 549 if (interrupt) { 507 550 usb_hub_process_interrupt( 551 <<<<<<< TREE 552 hub_info, port); 553 ======= 508 554 hub_info, hc, port, hub_info->address); 555 >>>>>>> MERGE-SOURCE 509 556 } 510 557 } 558 usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change); 511 559 free(change_bitmap); 512 513 async_hangup(hc); 560 561 562 //async_hangup(hc); 514 563 fibril_mutex_lock(&usb_hub_list_lock); 515 564 } -
uspace/drv/usbhub/usbhub.h
r0c00dac r50ba203 42 42 #define NAME "usbhub" 43 43 44 <<<<<<< TREE 45 #include "usb/hcdhubd.h" 46 47 #include <usb/pipes.h> 48 49 ======= 50 >>>>>>> MERGE-SOURCE 44 51 /** basic information about device attached to hub */ 45 52 typedef struct{ … … 48 55 }usb_hub_attached_device_t; 49 56 57 /* Hub endpoints. */ 58 typedef struct { 59 usb_endpoint_pipe_t control; 60 usb_endpoint_pipe_t status_change; 61 } usb_hub_endpoints_t; 62 63 64 50 65 /** Information about attached hub. */ 51 66 typedef struct { 52 67 /** Number of ports. */ 53 68 int port_count; 54 /** attached device handles */69 /** attached device handles, for each port one */ 55 70 usb_hub_attached_device_t * attached_devs; 56 71 /** USB address of the hub. */ … … 58 73 /** General device info*/ 59 74 device_t * device; 75 <<<<<<< TREE 76 /** connection to hcd */ 77 usb_device_connection_t connection; 78 /** hub endpoints */ 79 usb_hub_endpoints_t endpoints; 80 81 ======= 82 >>>>>>> MERGE-SOURCE 60 83 } usb_hub_info_t; 61 84 -
uspace/drv/usbhub/usbhub_private.h
r0c00dac r50ba203 77 77 * @return 78 78 */ 79 usb_hub_info_t * usb_create_hub_info(device_t * device , int hc);79 usb_hub_info_t * usb_create_hub_info(device_t * device); 80 80 81 81 /** List of hubs maanged by this driver */ … … 98 98 * @return error code 99 99 */ 100 /* 100 101 int usb_drv_sync_control_read( 101 int phone, usb_target_t target,102 usb_endpoint_pipe_t *pipe, 102 103 usb_device_request_setup_packet_t * request, 103 104 void * rcvd_buffer, size_t rcvd_size, size_t * actual_size 104 ); 105 );*/ 105 106 106 107 /** … … 115 116 * @return error code 116 117 */ 117 int usb_drv_sync_control_write(118 int phone, usb_target_t target,118 /*int usb_drv_sync_control_write( 119 usb_endpoint_pipe_t *pipe, 119 120 usb_device_request_setup_packet_t * request, 120 121 void * sent_buffer, size_t sent_size 121 ); 122 );*/ 122 123 123 124 /** … … 147 148 * @return Operation result 148 149 */ 149 static inline int usb_hub_clear_port_feature( int hc, usb_address_t address,150 static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe, 150 151 int port_index, 151 152 usb_hub_class_feature_t feature) { 152 usb_target_t target = { 153 .address = address, 154 .endpoint = 0 155 }; 153 156 154 usb_device_request_setup_packet_t clear_request = { 157 155 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE, … … 161 159 }; 162 160 clear_request.value = feature; 163 return usb_ drv_psync_control_write(hc, target, &clear_request,161 return usb_endpoint_pipe_control_write(pipe, &clear_request, 164 162 sizeof(clear_request), NULL, 0); 165 163 }
Note:
See TracChangeset
for help on using the changeset viewer.