Changes in uspace/drv/usbhub/usbhub.c [6986418:f40a1e2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r6986418 rf40a1e2 46 46 #include "usbhub_private.h" 47 47 #include "port_status.h" 48 #include "usb/usb.h" 48 49 49 50 static usb_iface_t hub_usb_iface = { … … 75 76 //get some hub info 76 77 usb_address_t addr = usb_drv_get_my_address(hc, device); 77 dprintf(1,"[usb_hub] addres of newly created hub = %d", addr);78 dprintf(1,"[usb_hub] address of newly created hub = %d", addr); 78 79 /*if(addr<0){ 79 80 //return result; … … 85 86 86 87 // get hub descriptor 87 usb_target_t target;88 target.address = addr;89 target.endpoint = 0;90 usb_device_request_setup_packet_t request;91 //printf("[usb_hub] creating descriptor request\n");92 usb_hub_set_descriptor_request(&request);93 88 94 89 //printf("[usb_hub] creating serialized descriptor\n"); … … 98 93 int opResult; 99 94 //printf("[usb_hub] starting control transaction\n"); 100 opResult = usb_drv_sync_control_read( 101 hc, target, &request, serialized_descriptor, 95 96 opResult = usb_drv_req_get_descriptor(hc, addr, 97 USB_REQUEST_TYPE_CLASS, 98 USB_DESCTYPE_HUB, 0, 0, serialized_descriptor, 102 99 USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size); 100 103 101 if (opResult != EOK) { 104 102 dprintf(1,"[usb_hub] failed when receiving hub descriptor, badcode = %d",opResult); … … 155 153 int port; 156 154 int opResult; 157 usb_device_request_setup_packet_t request;158 155 usb_target_t target; 159 156 target.address = hub_info->usb_device->address; … … 173 170 if(std_descriptor.configuration_count<1){ 174 171 dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE"); 175 } 172 //shouldn`t I return? 173 } 174 /// \TODO check other configurations 176 175 usb_standard_configuration_descriptor_t config_descriptor; 177 176 opResult = usb_drv_req_get_bare_configuration_descriptor(hc, … … 183 182 } 184 183 //set configuration 185 request.request_type = 0; 186 request.request = USB_DEVREQ_SET_CONFIGURATION; 187 request.index=0; 188 request.length=0; 189 request.value_high=0; 190 request.value_low = config_descriptor.configuration_number; 191 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0); 184 opResult = usb_drv_req_set_configuration(hc, target.address, 185 config_descriptor.configuration_number); 186 192 187 if (opResult != EOK) { 193 188 dprintf(1,"[usb_hub]something went wrong when setting hub`s configuration, %d", opResult); 194 189 } 195 190 196 191 usb_device_request_setup_packet_t request; 197 192 for (port = 1; port < hub_info->port_count+1; ++port) { 198 193 usb_hub_set_power_port_request(&request, port); … … 205 200 //ports powered, hub seems to be enabled 206 201 207 208 202 ipc_hangup(hc); 209 203 210 204 //add the hub to list 205 futex_down(&usb_hub_list_lock); 211 206 usb_lst_append(&usb_hub_list, hub_info); 207 futex_up(&usb_hub_list_lock); 208 212 209 dprintf(1,"[usb_hub] hub info added to list"); 213 210 //(void)hub_info; … … 227 224 228 225 229 230 226 //********************************************* 231 227 // … … 235 231 236 232 /** 237 * reset the port with new device and reserve the default address 233 * Convenience function for releasing default address and writing debug info 234 * (these few lines are used too often to be written again and again). 235 * @param hc 236 * @return 237 */ 238 inline static int usb_hub_release_default_address(int hc){ 239 int opResult; 240 dprintf(1,"[usb_hub] releasing default address"); 241 opResult = usb_drv_release_default_address(hc); 242 if (opResult != EOK) { 243 dprintf(1,"[usb_hub] failed to release default address"); 244 } 245 return opResult; 246 } 247 248 /** 249 * Reset the port with new device and reserve the default address. 238 250 * @param hc 239 251 * @param port … … 259 271 if (opResult != EOK) { 260 272 dprintf(1,"[usb_hub] something went wrong when reseting a port"); 261 } 262 } 263 264 /** 265 * convenience function for releasing default address and writing debug info 266 * (these few lines are used too often to be written again and again) 267 * @param hc 268 * @return 269 */ 270 inline static int usb_hub_release_default_address(int hc){ 271 int opResult; 272 dprintf(1,"[usb_hub] releasing default address"); 273 opResult = usb_drv_release_default_address(hc); 274 if (opResult != EOK) { 275 dprintf(1,"[usb_hub] failed to release default address"); 276 } 277 return opResult; 278 } 279 280 281 /** 282 * finalize adding new device after port reset 273 usb_hub_release_default_address(hc); 274 } 275 } 276 277 /** 278 * Finalize adding new device after port reset 283 279 * @param hc 284 280 * @param port … … 343 339 344 340 /** 345 * unregister device address in hc, close the port341 * Unregister device address in hc 346 342 * @param hc 347 343 * @param port … … 352 348 //usb_device_request_setup_packet_t request; 353 349 int opResult; 354 //disable port 355 /*usb_hub_set_disable_port_request(&request, port); 356 opResult = usb_drv_sync_control_write( 357 hc, target, 358 &request, 359 NULL, 0 360 ); 361 if (opResult != EOK) { 362 //continue; 363 printf("[usb_hub] something went wrong when disabling a port\n"); 364 }*/ 365 /// \TODO remove device 350 351 /** \TODO remove device from device manager - not yet implemented in 352 * devide manager 353 */ 366 354 367 355 hub->attached_devs[port].devman_handle=0; … … 384 372 385 373 /** 386 * process interrupts on given hub port374 * Process interrupts on given hub port 387 375 * @param hc 388 376 * @param port … … 442 430 usb_port_set_reset_completed(&status, false); 443 431 usb_port_set_dev_connected(&status, false); 444 if (status) { 445 dprintf(1,"[usb_hub]there was some unsupported change on port %d",port); 432 if (status>>16) { 433 dprintf(1,"[usb_hub]there was some unsupported change on port %d: %X",port,status); 434 446 435 } 447 436 /// \TODO handle other changes … … 450 439 } 451 440 452 /* Check changes on all known hubs. 441 /** 442 * Check changes on all known hubs. 453 443 */ 454 444 void usb_hub_check_hub_changes(void) { … … 457 447 */ 458 448 usb_general_list_t * lst_item; 449 futex_down(&usb_hub_list_lock); 459 450 for (lst_item = usb_hub_list.next; 460 451 lst_item != &usb_hub_list; 461 452 lst_item = lst_item->next) { 453 futex_up(&usb_hub_list_lock); 462 454 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 463 455 /* … … 468 460 target.address = hub_info->usb_device->address; 469 461 target.endpoint = 1;/// \TODO get from endpoint descriptor 470 /*dprintf(1,"[usb_hub] checking changes for hub at addr %d",471 target.address); */462 dprintf(1,"[usb_hub] checking changes for hub at addr %d", 463 target.address); 472 464 473 465 size_t port_count = hub_info->port_count; … … 510 502 } 511 503 } 504 free(change_bitmap); 512 505 513 506 ipc_hangup(hc); 514 } 507 futex_down(&usb_hub_list_lock); 508 } 509 futex_up(&usb_hub_list_lock); 515 510 } 516 511
Note:
See TracChangeset
for help on using the changeset viewer.