Changeset 74d6e90 in mainline for uspace/drv/usbhid/main.c
- Timestamp:
- 2011-02-04T13:07:32Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 97e87de
- Parents:
- 621afdb (diff), ff244e6 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/main.c
r621afdb r74d6e90 43 43 #include <io/console.h> 44 44 #include <errno.h> 45 #include <str_error.h> 45 46 #include <fibril.h> 46 47 #include <usb/classes/hid.h> … … 49 50 #include <usb/descriptor.h> 50 51 #include <io/console.h> 52 #include "hid.h" 51 53 #include "descparser.h" 52 54 #include "descdump.h" … … 379 381 if (rc < 0) { 380 382 printf("Problem setting phone to HC.\n"); 381 free(kbd_dev); 382 return NULL; 383 goto error_leave; 383 384 } 384 385 … … 386 387 if (rc < 0) { 387 388 printf("Problem getting address of the device.\n"); 388 free(kbd_dev); 389 return NULL; 389 goto error_leave; 390 390 } 391 391 … … 397 397 // } 398 398 399 // default endpoint400 kbd_dev->poll_endpoint = GUESSED_POLL_ENDPOINT;401 402 399 /* 403 400 * will need all descriptors: … … 410 407 usbkbd_process_descriptors(kbd_dev); 411 408 409 410 411 /* 412 * Initialize the backing connection to the host controller. 413 */ 414 rc = usb_device_connection_initialize_from_device(&kbd_dev->wire, dev); 415 if (rc != EOK) { 416 printf("Problem initializing connection to device: %s.\n", 417 str_error(rc)); 418 goto error_leave; 419 } 420 421 /* 422 * Initialize device pipes. 423 */ 424 rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire, 425 GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN); 426 if (rc != EOK) { 427 printf("Failed to initialize interrupt in pipe: %s.\n", 428 str_error(rc)); 429 goto error_leave; 430 } 431 432 412 433 return kbd_dev; 434 435 error_leave: 436 free(kbd_dev); 437 return NULL; 413 438 } 414 439 … … 435 460 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 436 461 { 437 int rc; 438 usb_handle_t handle; 462 int rc, sess_rc; 439 463 uint8_t buffer[BUFFER_SIZE]; 440 464 size_t actual_size; 441 //usb_endpoint_t poll_endpoint = 1;442 443 // usb_address_t my_address = usb_drv_get_my_address(dev->parent_phone,444 // dev);445 // if (my_address < 0) {446 // return;447 // }448 449 usb_target_t poll_target = {450 .address = kbd_dev->address,451 .endpoint = kbd_dev->poll_endpoint452 };453 465 454 466 printf("Polling keyboard...\n"); … … 456 468 while (true) { 457 469 async_usleep(1000 * 1000 * 2); 458 rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone, 459 poll_target, buffer, BUFFER_SIZE, &actual_size, &handle); 470 471 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->poll_pipe); 472 if (sess_rc != EOK) { 473 printf("Failed to start a session: %s.\n", 474 str_error(sess_rc)); 475 continue; 476 } 477 478 rc = usb_endpoint_pipe_read(&kbd_dev->poll_pipe, buffer, 479 BUFFER_SIZE, &actual_size); 480 sess_rc = usb_endpoint_pipe_end_session(&kbd_dev->poll_pipe); 460 481 461 482 if (rc != EOK) { 462 printf("Error in usb_drv_async_interrupt_in(): %d\n", rc); 483 printf("Error polling the keyboard: %s.\n", 484 str_error(rc)); 463 485 continue; 464 486 } 465 487 466 rc = usb_drv_async_wait_for(handle);467 if (rc != EOK) {468 printf("Error in usb_drv_async_wait_for(): %d\n", rc);488 if (sess_rc != EOK) { 489 printf("Error closing session: %s.\n", 490 str_error(sess_rc)); 469 491 continue; 470 492 }
Note:
See TracChangeset
for help on using the changeset viewer.