Changes in / [8357fc9:b9e3aa3] in mainline
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkbd/main.c
r8357fc9 rb9e3aa3 71 71 usb_hid_free_report(*report); 72 72 *report = NULL; 73 printf("usb_hid_report_init() failed.\n");73 //printf("usb_hid_report_init() failed.\n"); 74 74 return rc; 75 75 } … … 82 82 usb_hid_free_report(*report); 83 83 *report = NULL; 84 printf("usbhid_dev_get_report_descriptor_length() failed.\n");84 //printf("usbhid_dev_get_report_descriptor_length() failed.\n"); 85 85 return rc; 86 86 } … … 89 89 usb_hid_free_report(*report); 90 90 *report = NULL; 91 printf("usbhid_dev_get_report_descriptor_length() returned 0.\n");91 //printf("usbhid_dev_get_report_descriptor_length() returned 0.\n"); 92 92 return EINVAL; // TODO: other error code? 93 93 } … … 108 108 *report = NULL; 109 109 free(desc); 110 printf("usbhid_dev_get_report_descriptor() failed.\n");110 //printf("usbhid_dev_get_report_descriptor() failed.\n"); 111 111 return rc; 112 112 } … … 116 116 *report = NULL; 117 117 free(desc); 118 printf("usbhid_dev_get_report_descriptor() returned wrong size:"119 " %zu, expected: %zu.\n", actual_size, report_desc_size);118 // printf("usbhid_dev_get_report_descriptor() returned wrong size:" 119 // " %zu, expected: %zu.\n", actual_size, report_desc_size); 120 120 return EINVAL; // TODO: other error code? 121 121 } … … 128 128 if (rc != EOK) { 129 129 free(desc); 130 printf("usb_hid_parse_report_descriptor() failed.\n");130 // printf("usb_hid_parse_report_descriptor() failed.\n"); 131 131 return rc; 132 132 } -
uspace/drv/usbhid/usbhid.c
r8357fc9 rb9e3aa3 78 78 } 79 79 80 assert(hid_dev->subdriver_count >= 0); 81 80 82 // set the init callback 81 hid_dev->subdrivers[ 0].init = usb_kbd_init;83 hid_dev->subdrivers[hid_dev->subdriver_count].init = usb_kbd_init; 82 84 83 85 // set the polling callback 84 hid_dev->subdrivers[0].poll = usb_kbd_polling_callback; 86 hid_dev->subdrivers[hid_dev->subdriver_count].poll = 87 usb_kbd_polling_callback; 85 88 86 89 // set the polling ended callback 87 hid_dev->subdrivers[ 0].poll_end = NULL;90 hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL; 88 91 89 92 // set the deinit callback 90 hid_dev->subdrivers[ 0].deinit = usb_kbd_deinit;93 hid_dev->subdrivers[hid_dev->subdriver_count].deinit = usb_kbd_deinit; 91 94 92 95 // set subdriver count 93 hid_dev->subdriver_count = 1;96 ++hid_dev->subdriver_count; 94 97 95 98 return EOK; … … 108 111 } 109 112 113 assert(hid_dev->subdriver_count >= 0); 114 110 115 // set the init callback 111 hid_dev->subdrivers[ 0].init = usb_mouse_init;116 hid_dev->subdrivers[hid_dev->subdriver_count].init = usb_mouse_init; 112 117 113 118 // set the polling callback 114 hid_dev->subdrivers[0].poll = usb_mouse_polling_callback; 119 hid_dev->subdrivers[hid_dev->subdriver_count].poll = 120 usb_mouse_polling_callback; 115 121 116 122 // set the polling ended callback 117 hid_dev->subdrivers[ 0].poll_end = NULL;123 hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL; 118 124 119 125 // set the deinit callback 120 hid_dev->subdrivers[ 0].deinit = usb_mouse_deinit;126 hid_dev->subdrivers[hid_dev->subdriver_count].deinit = usb_mouse_deinit; 121 127 122 128 // set subdriver count 123 hid_dev->subdriver_count = 1;129 ++hid_dev->subdriver_count; 124 130 125 131 return EOK; … … 138 144 } 139 145 146 assert(hid_dev->subdriver_count >= 0); 147 140 148 // set the init callback 141 hid_dev->subdrivers[0].init = usb_generic_hid_init; 149 hid_dev->subdrivers[hid_dev->subdriver_count].init = 150 usb_generic_hid_init; 142 151 143 152 // set the polling callback 144 hid_dev->subdrivers[0].poll = usb_generic_hid_polling_callback; 153 hid_dev->subdrivers[hid_dev->subdriver_count].poll = 154 usb_generic_hid_polling_callback; 145 155 146 156 // set the polling ended callback 147 hid_dev->subdrivers[ 0].poll_end = NULL;157 hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL; 148 158 149 159 // set the deinit callback 150 hid_dev->subdrivers[ 0].deinit = NULL;160 hid_dev->subdrivers[hid_dev->subdriver_count].deinit = NULL; 151 161 152 162 // set subdriver count 153 hid_dev->subdriver_count = 1;163 ++hid_dev->subdriver_count; 154 164 155 165 return EOK; … … 249 259 } 250 260 251 usb_log_debug("Size of the input report: %zu B\n", size);261 usb_log_debug("Size of the input report: %zu\n", size); 252 262 usb_hid_report_path_free(usage_path); 253 263 … … 401 411 402 412 do { 413 usb_log_debug("Getting size of the report.\n"); 403 414 size = usb_hid_report_byte_size(hid_dev->report, report_id, 404 415 USB_HID_REPORT_TYPE_INPUT); 405 416 usb_log_debug("Report ID: %u, size: %zu\n", report_id, size); 406 417 max_size = (size > max_size) ? size : max_size; 418 usb_log_debug("Getting next report ID\n"); 407 419 report_id = usb_hid_get_next_report_id(hid_dev->report, 408 420 report_id, USB_HID_REPORT_TYPE_INPUT); … … 534 546 hid_dev->subdriver_count); 535 547 //usb_hid_free(&hid_dev); 548 536 549 } else { 537 550 bool ok = false; … … 560 573 } 561 574 562 // save max input report size and allocate space for the report 563 rc = usb_hid_init_report(hid_dev); 564 if (rc != EOK) { 565 usb_log_error("Failed to initialize input report buffer.\n"); 566 } 575 576 if (rc == EOK) { 577 // save max input report size and allocate space for the report 578 rc = usb_hid_init_report(hid_dev); 579 if (rc != EOK) { 580 usb_log_error("Failed to initialize input report buffer" 581 ".\n"); 582 } 583 } 584 567 585 568 586 return rc; … … 587 605 usb_log_debug("Max input report size: %zu, buffer size: %zu\n", 588 606 hid_dev->max_input_report_size, buffer_size); 589 assert(hid_dev->max_input_report_size >= buffer_size); 590 591 // if (/*!allocated*/ 592 // /*|| *//*hid_dev->input_report_size < buffer_size*/) { 593 // uint8_t *input_old = hid_dev->input_report; 594 // uint8_t *input_new = (uint8_t *)malloc(buffer_size); 595 596 // if (input_new == NULL) { 597 // usb_log_error("Failed to allocate space for input " 598 // "buffer. This event may not be reported\n"); 599 // memset(hid_dev->input_report, 0, 600 // hid_dev->input_report_size); 601 // } else { 602 // memcpy(input_new, input_old, 603 // hid_dev->input_report_size); 604 // hid_dev->input_report = input_new; 605 // if (allocated) { 606 // free(input_old); 607 // } 608 // usb_hid_new_report(); 609 // } 610 // } 611 612 /*! @todo This should probably be atomic. */ 613 memcpy(hid_dev->input_report, buffer, buffer_size); 614 hid_dev->input_report_size = buffer_size; 615 usb_hid_new_report(hid_dev); 607 //assert(hid_dev->max_input_report_size >= buffer_size); 608 if (hid_dev->max_input_report_size >= buffer_size) { 609 /*! @todo This should probably be atomic. */ 610 memcpy(hid_dev->input_report, buffer, buffer_size); 611 hid_dev->input_report_size = buffer_size; 612 usb_hid_new_report(hid_dev); 613 } 616 614 617 615 bool cont = false;
Note:
See TracChangeset
for help on using the changeset viewer.