Changeset 2002595 in mainline
- Timestamp:
- 2011-05-29T19:41:35Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b9e3aa3
- Parents:
- 2f09dee
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/usbhid.c
r2f09dee r2002595 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; … … 216 226 } 217 227 218 usb_log_debug("Size of the input report: %zu B\n", size);228 usb_log_debug("Size of the input report: %zu\n", size); 219 229 usb_hid_report_path_free(usage_path); 220 230 … … 368 378 369 379 do { 380 usb_log_debug("Getting size of the report.\n"); 370 381 size = usb_hid_report_byte_size(hid_dev->report, report_id, 371 382 USB_HID_REPORT_TYPE_INPUT); 372 383 usb_log_debug("Report ID: %u, size: %zu\n", report_id, size); 373 384 max_size = (size > max_size) ? size : max_size; 385 usb_log_debug("Getting next report ID\n"); 374 386 report_id = usb_hid_get_next_report_id(hid_dev->report, 375 387 report_id, USB_HID_REPORT_TYPE_INPUT); … … 501 513 hid_dev->subdriver_count); 502 514 //usb_hid_free(&hid_dev); 515 503 516 } else { 504 517 bool ok = false; … … 527 540 } 528 541 529 // save max input report size and allocate space for the report 530 rc = usb_hid_init_report(hid_dev); 531 if (rc != EOK) { 532 usb_log_error("Failed to initialize input report buffer.\n"); 533 } 542 543 if (rc == EOK) { 544 // save max input report size and allocate space for the report 545 rc = usb_hid_init_report(hid_dev); 546 if (rc != EOK) { 547 usb_log_error("Failed to initialize input report buffer" 548 ".\n"); 549 } 550 } 551 534 552 535 553 return rc; … … 554 572 usb_log_debug("Max input report size: %zu, buffer size: %zu\n", 555 573 hid_dev->max_input_report_size, buffer_size); 556 assert(hid_dev->max_input_report_size >= buffer_size); 557 558 // if (/*!allocated*/ 559 // /*|| *//*hid_dev->input_report_size < buffer_size*/) { 560 // uint8_t *input_old = hid_dev->input_report; 561 // uint8_t *input_new = (uint8_t *)malloc(buffer_size); 562 563 // if (input_new == NULL) { 564 // usb_log_error("Failed to allocate space for input " 565 // "buffer. This event may not be reported\n"); 566 // memset(hid_dev->input_report, 0, 567 // hid_dev->input_report_size); 568 // } else { 569 // memcpy(input_new, input_old, 570 // hid_dev->input_report_size); 571 // hid_dev->input_report = input_new; 572 // if (allocated) { 573 // free(input_old); 574 // } 575 // usb_hid_new_report(); 576 // } 577 // } 578 579 /*! @todo This should probably be atomic. */ 580 memcpy(hid_dev->input_report, buffer, buffer_size); 581 hid_dev->input_report_size = buffer_size; 582 usb_hid_new_report(hid_dev); 574 //assert(hid_dev->max_input_report_size >= buffer_size); 575 if (hid_dev->max_input_report_size >= buffer_size) { 576 /*! @todo This should probably be atomic. */ 577 memcpy(hid_dev->input_report, buffer, buffer_size); 578 hid_dev->input_report_size = buffer_size; 579 usb_hid_new_report(hid_dev); 580 } 583 581 584 582 bool cont = false;
Note:
See TracChangeset
for help on using the changeset viewer.