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