Changeset 3ae26a8 in mainline
- Timestamp:
- 2011-05-30T17:23:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 55f324f, c060090
- Parents:
- 17d1542 (diff), 0dd3e49 (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. - Location:
- uspace
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkbd/main.c
r17d1542 r3ae26a8 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 } … … 213 213 214 214 char *devpath = argv[1]; 215 //const char *devpath = "/hw/pci0/00:06.0/ohci-rh/usb00_a2/HID1/hid";216 217 int rc;218 215 219 216 devman_handle_t dev_handle = 0; 220 rc = devman_device_get_handle(devpath, &dev_handle, 0); 221 if (rc != EOK) { 222 printf("Failed to get handle from devman: %s.\n", 217 218 int rc = usb_resolve_device_handle(devpath, NULL, NULL, &dev_handle); 219 if (rc != EOK) { 220 printf("Device not found or not of USB kind: %s.\n", 223 221 str_error(rc)); 224 222 return rc; -
uspace/drv/usbhid/usbhid.c
r17d1542 r3ae26a8 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; … … 196 206 } 197 207 198 if (mapping->report_id >= 0) {199 usb_hid_report_path_set_report_id(usage_path,200 mapping->report_id);201 }208 // if (mapping->report_id >= 0) { 209 // usb_hid_report_path_set_report_id(usage_path, 210 // mapping->report_id); 211 // } 202 212 203 213 assert(hid_dev->report != NULL); … … 206 216 // size_t size = usb_hid_report_size(hid_dev->report, 0, 207 217 // USB_HID_REPORT_TYPE_INPUT); 208 size_t size = 0; 209 usb_hid_report_field_t *field = usb_hid_report_get_sibling (hid_dev->report, 210 NULL, usage_path, mapping->compare, USB_HID_REPORT_TYPE_INPUT); 211 while(field != NULL) { 212 size++; 213 field = usb_hid_report_get_sibling (hid_dev->report, 214 field, usage_path, mapping->compare, 215 USB_HID_REPORT_TYPE_INPUT); 216 } 217 218 usb_log_debug("Size of the input report: %zuB\n", size); 218 // size_t size = 0; 219 220 bool matches = false; 221 222 // usb_hid_report_description_t *report_des = 223 // usb_hid_report_find_description(hid_dev->report, 224 // mapping->report_id, USB_HID_REPORT_TYPE_INPUT); 225 uint8_t report_id = mapping->report_id; 226 227 /*while(report_des != NULL)*/do { 228 229 // if((mapping->report_id) == 0 && (report_des->report_id != 0)) { 230 // usb_hid_report_path_set_report_id(usage_path, 231 // report_des->report_id); 232 // } 233 234 usb_log_debug("Trying report id %u\n", report_id); 235 236 if (report_id != 0) { 237 usb_hid_report_path_set_report_id(usage_path, 238 report_id); 239 } 240 241 usb_hid_report_field_t *field = usb_hid_report_get_sibling( 242 hid_dev->report, 243 NULL, usage_path, mapping->compare, 244 USB_HID_REPORT_TYPE_INPUT); 245 246 usb_log_debug("Field: %p\n", field); 247 248 if (field != NULL) { 249 // size++; 250 // field = usb_hid_report_get_sibling(hid_dev->report, 251 // field, usage_path, mapping->compare, 252 // USB_HID_REPORT_TYPE_INPUT); 253 matches = true; 254 break; 255 } 256 257 report_id = usb_hid_get_next_report_id( 258 hid_dev->report, report_id, 259 USB_HID_REPORT_TYPE_INPUT); 260 261 // if((mapping->report_id == 0) && (report_des->report_id != 0)) { 262 // uint8_t report_id = usb_hid_get_next_report_id( 263 // hid_dev->report, report_des->report_id, 264 // USB_HID_REPORT_TYPE_INPUT); 265 266 // if(report_id == 0) { 267 // break; 268 // } 269 270 // report_des = usb_hid_report_find_description( 271 // hid_dev->report, report_id, 272 // USB_HID_REPORT_TYPE_INPUT); 273 // } 274 // else { 275 // break; 276 // } 277 } while (!matches && report_id != 0); 278 279 // usb_log_debug("Size of the input report: %zu\n", size); 219 280 usb_hid_report_path_free(usage_path); 220 281 221 return (size > 0);282 return matches; 222 283 } 223 284 … … 368 429 369 430 do { 431 usb_log_debug("Getting size of the report.\n"); 370 432 size = usb_hid_report_byte_size(hid_dev->report, report_id, 371 433 USB_HID_REPORT_TYPE_INPUT); 372 434 usb_log_debug("Report ID: %u, size: %zu\n", report_id, size); 373 435 max_size = (size > max_size) ? size : max_size; 436 usb_log_debug("Getting next report ID\n"); 374 437 report_id = usb_hid_get_next_report_id(hid_dev->report, 375 438 report_id, USB_HID_REPORT_TYPE_INPUT); … … 501 564 hid_dev->subdriver_count); 502 565 //usb_hid_free(&hid_dev); 566 503 567 } else { 504 568 bool ok = false; … … 527 591 } 528 592 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 } 593 594 if (rc == EOK) { 595 // save max input report size and allocate space for the report 596 rc = usb_hid_init_report(hid_dev); 597 if (rc != EOK) { 598 usb_log_error("Failed to initialize input report buffer" 599 ".\n"); 600 } 601 } 602 534 603 535 604 return rc; … … 554 623 usb_log_debug("Max input report size: %zu, buffer size: %zu\n", 555 624 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); 625 //assert(hid_dev->max_input_report_size >= buffer_size); 626 if (hid_dev->max_input_report_size >= buffer_size) { 627 /*! @todo This should probably be atomic. */ 628 memcpy(hid_dev->input_report, buffer, buffer_size); 629 hid_dev->input_report_size = buffer_size; 630 usb_hid_new_report(hid_dev); 631 } 583 632 584 633 bool cont = false; -
uspace/lib/usbhid/src/hiddescriptor.c
r17d1542 r3ae26a8 329 329 usb_hid_report_type_t type) { 330 330 331 if(report == NULL) { 332 return NULL; 333 } 334 331 335 link_t *report_it = report->reports.next; 332 336 usb_hid_report_description_t *report_des = NULL; … … 336 340 usb_hid_report_description_t, link); 337 341 338 if((report_des->report_id == report_id) && 342 // if report id not set, return the first of the type 343 if(((report_des->report_id == report_id) || (report_id == 0)) && 339 344 (report_des->type == type)) { 340 345 return report_des; -
uspace/lib/usbhid/src/hidparser.c
r17d1542 r3ae26a8 605 605 606 606 if(report_id > 0) { 607 report_it = usb_hid_report_find_description(report, report_id, 608 type)->link.next; 607 report_des = usb_hid_report_find_description(report, report_id, 608 type); 609 if(report_des == NULL) { 610 return 0; 611 } 612 else { 613 report_it = report_des->link.next; 614 } 609 615 } 610 616 else { -
uspace/lib/usbhid/src/hidpath.c
r17d1542 r3ae26a8 211 211 212 212 if(report_path->report_id != path->report_id) { 213 return 1; 213 if(path->report_id != 0) { 214 return 1; 215 } 214 216 } 215 217
Note:
See TracChangeset
for help on using the changeset viewer.