Changes in uspace/drv/usbhid/main.c [707ffcf:66d5062] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/main.c
r707ffcf r66d5062 43 43 #include <io/console.h> 44 44 #include <errno.h> 45 #include <str_error.h>46 45 #include <fibril.h> 47 46 #include <usb/classes/hid.h> … … 50 49 #include <usb/descriptor.h> 51 50 #include <io/console.h> 52 #include "hid.h"53 51 #include "descparser.h" 54 52 #include "descdump.h" … … 381 379 if (rc < 0) { 382 380 printf("Problem setting phone to HC.\n"); 383 goto error_leave; 381 free(kbd_dev); 382 return NULL; 384 383 } 385 384 … … 387 386 if (rc < 0) { 388 387 printf("Problem getting address of the device.\n"); 389 goto error_leave; 388 free(kbd_dev); 389 return NULL; 390 390 } 391 391 … … 397 397 // } 398 398 399 // default endpoint 400 kbd_dev->poll_endpoint = GUESSED_POLL_ENDPOINT; 401 399 402 /* 400 403 * will need all descriptors: … … 407 410 usbkbd_process_descriptors(kbd_dev); 408 411 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 433 412 return kbd_dev; 434 435 error_leave:436 free(kbd_dev);437 return NULL;438 413 } 439 414 … … 460 435 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 461 436 { 462 int rc, sess_rc; 437 int rc; 438 usb_handle_t handle; 463 439 uint8_t buffer[BUFFER_SIZE]; 464 440 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_endpoint 452 }; 465 453 466 454 printf("Polling keyboard...\n"); … … 468 456 while (true) { 469 457 async_usleep(1000 * 1000 * 2); 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));458 rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone, 459 poll_target, buffer, BUFFER_SIZE, &actual_size, &handle); 460 461 if (rc != EOK) { 462 printf("Error in usb_drv_async_interrupt_in(): %d\n", rc); 475 463 continue; 476 464 } 477 465 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); 481 466 rc = usb_drv_async_wait_for(handle); 482 467 if (rc != EOK) { 483 printf("Error polling the keyboard: %s.\n", 484 str_error(rc)); 485 continue; 486 } 487 488 if (sess_rc != EOK) { 489 printf("Error closing session: %s.\n", 490 str_error(sess_rc)); 468 printf("Error in usb_drv_async_wait_for(): %d\n", rc); 491 469 continue; 492 470 }
Note:
See TracChangeset
for help on using the changeset viewer.