Changeset 707ffcf in mainline
- Timestamp:
- 2011-01-30T22:34:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9753220
- Parents:
- c2772b8
- Location:
- uspace/drv/usbhid
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hid.h
rc2772b8 r707ffcf 39 39 #include <usb/classes/hid.h> 40 40 #include <driver.h> 41 #include <usb/pipes.h> 41 42 42 43 /** … … 69 70 usb_hid_configuration_t *conf; 70 71 usb_address_t address; 71 usb_endpoint_t poll_endpoint;72 72 usb_hid_report_parser_t *parser; 73 74 usb_device_connection_t wire; 75 usb_endpoint_pipe_t poll_pipe; 73 76 } usb_hid_dev_kbd_t; 74 77 -
uspace/drv/usbhid/main.c
rc2772b8 r707ffcf 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> … … 380 381 if (rc < 0) { 381 382 printf("Problem setting phone to HC.\n"); 382 free(kbd_dev); 383 return NULL; 383 goto error_leave; 384 384 } 385 385 … … 387 387 if (rc < 0) { 388 388 printf("Problem getting address of the device.\n"); 389 free(kbd_dev); 390 return NULL; 389 goto error_leave; 391 390 } 392 391 … … 398 397 // } 399 398 400 // default endpoint401 kbd_dev->poll_endpoint = GUESSED_POLL_ENDPOINT;402 403 399 /* 404 400 * will need all descriptors: … … 411 407 usbkbd_process_descriptors(kbd_dev); 412 408 409 410 411 /* 412 * Initialize the backing connection to the host controller. 413 */ 414 rc = usb_device_connection_initialize(&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 413 433 return kbd_dev; 434 435 error_leave: 436 free(kbd_dev); 437 return NULL; 414 438 } 415 439 … … 436 460 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 437 461 { 438 int rc; 439 usb_handle_t handle; 462 int rc, sess_rc; 440 463 uint8_t buffer[BUFFER_SIZE]; 441 464 size_t actual_size; 442 //usb_endpoint_t poll_endpoint = 1;443 444 // usb_address_t my_address = usb_drv_get_my_address(dev->parent_phone,445 // dev);446 // if (my_address < 0) {447 // return;448 // }449 450 usb_target_t poll_target = {451 .address = kbd_dev->address,452 .endpoint = kbd_dev->poll_endpoint453 };454 465 455 466 printf("Polling keyboard...\n"); … … 457 468 while (true) { 458 469 async_usleep(1000 * 1000 * 2); 459 rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone, 460 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); 461 481 462 482 if (rc != EOK) { 463 printf("Error in usb_drv_async_interrupt_in(): %d\n", rc); 483 printf("Error polling the keyboard: %s.\n", 484 str_error(rc)); 464 485 continue; 465 486 } 466 487 467 rc = usb_drv_async_wait_for(handle);468 if (rc != EOK) {469 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)); 470 491 continue; 471 492 }
Note:
See TracChangeset
for help on using the changeset viewer.