Changes in / [1c6f4ff:a8a7063] in mainline
- Files:
-
- 17 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/amd64/Makefile.inc
r1c6f4ff ra8a7063 50 50 usbhub \ 51 51 usbkbd \ 52 usbhid \53 52 usbmid \ 54 53 usbmouse \ -
uspace/Makefile
r1c6f4ff ra8a7063 123 123 drv/usbflbk \ 124 124 drv/usbkbd \ 125 drv/usbhid \126 125 drv/usbhub \ 127 126 drv/usbmid \ … … 144 143 drv/usbflbk \ 145 144 drv/usbkbd \ 146 drv/usbhid \147 145 drv/usbhub \ 148 146 drv/usbmid \ -
uspace/drv/usbkbd/kbddev.c
r1c6f4ff ra8a7063 265 265 static void usb_kbd_set_led(usb_kbd_t *kbd_dev) 266 266 { 267 if (kbd_dev->output_size == 0) {268 return;269 }270 271 267 unsigned i = 0; 272 268 … … 292 288 293 289 int rc = usb_hid_report_output_translate(kbd_dev->parser, 294 kbd_dev->led_path, 295 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 296 kbd_dev->output_buffer, 290 kbd_dev->led_path, USB_HID_PATH_COMPARE_END, kbd_dev->output_buffer, 297 291 kbd_dev->output_size, kbd_dev->led_data, kbd_dev->led_output_size); 298 292 … … 545 539 * according to HID Usage Tables. 546 540 * @param count Number of key codes in report (size of the report). 547 * @param report_id541 * @param modifiers Bitmap of modifiers (Ctrl, Alt, Shift, GUI). 548 542 * @param arg User-specified argument. Expects pointer to the keyboard device 549 543 * structure representing the keyboard. … … 552 546 */ 553 547 static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count, 554 uint8_t report_id, void *arg)548 uint8_t modifiers, void *arg) 555 549 { 556 550 if (arg == NULL) { … … 563 557 assert(kbd_dev != NULL); 564 558 565 usb_log_debug("Got keys from parser (report id: %u): %s\n",566 report_id,usb_debug_str_buffer(key_codes, count, 0));559 usb_log_debug("Got keys from parser: %s\n", 560 usb_debug_str_buffer(key_codes, count, 0)); 567 561 568 562 if (count != kbd_dev->key_count) { … … 614 608 usb_hid_report_path_t *path = usb_hid_report_path(); 615 609 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 616 usb_hid_report_path_set_report_id(path, 0);617 610 618 611 int rc = usb_hid_parse_report(kbd_dev->parser, buffer, 619 actual_size, path, 620 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 621 callbacks, kbd_dev); 612 actual_size, path, USB_HID_PATH_COMPARE_STRICT, callbacks, kbd_dev); 622 613 623 614 usb_hid_report_path_free (path); … … 767 758 usb_hid_report_path_t *path = usb_hid_report_path(); 768 759 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 769 770 usb_hid_report_path_set_report_id(path, 0);771 772 760 kbd_dev->key_count = usb_hid_report_input_length( 773 kbd_dev->parser, path, 774 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 761 kbd_dev->parser, path, USB_HID_PATH_COMPARE_STRICT); 775 762 usb_hid_report_path_free (path); 776 763 … … 790 777 kbd_dev->output_buffer = usb_hid_report_output(kbd_dev->parser, 791 778 &kbd_dev->output_size); 792 if (kbd_dev->output_buffer == NULL && kbd_dev->output_size != 0) {779 if (kbd_dev->output_buffer == NULL) { 793 780 usb_log_warning("Error creating output report buffer.\n"); 794 781 free(kbd_dev->keys); … … 803 790 804 791 kbd_dev->led_output_size = usb_hid_report_output_size(kbd_dev->parser, 805 kbd_dev->led_path, 806 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 792 kbd_dev->led_path, USB_HID_PATH_COMPARE_END); 807 793 808 794 usb_log_debug("Output report size (in items): %zu\n", -
uspace/drv/usbkbd/main.c
r1c6f4ff ra8a7063 33 33 /** 34 34 * @file 35 * Main routines of USB KBD driver.35 * Main routines of USB HID driver. 36 36 */ 37 37 … … 75 75 * @sa usb_kbd_fibril(), usb_kbd_repeat_fibril() 76 76 */ 77 static int usb _kbd_try_add_device(usb_device_t *dev)77 static int usbhid_try_add_device(usb_device_t *dev) 78 78 { 79 79 /* Create the function exposed under /dev/devices. */ … … 105 105 usb_kbd_free(&kbd_dev); 106 106 return rc; 107 } 107 } 108 108 109 109 usb_log_debug("USB/HID KBD device structure initialized.\n"); … … 195 195 * @retval EREFUSED if the device is not supported. 196 196 */ 197 static int usb _kbd_add_device(usb_device_t *dev)197 static int usbhid_add_device(usb_device_t *dev) 198 198 { 199 usb_log_debug("usb _kbd_add_device()\n");199 usb_log_debug("usbhid_add_device()\n"); 200 200 201 201 if (dev->interface_no < 0) { 202 202 usb_log_warning("Device is not a supported keyboard.\n"); 203 usb_log_error("Failed to add USB KBD device: endpoint not"204 " found.\n");203 usb_log_error("Failed to add HID device: endpoint not found." 204 "\n"); 205 205 return ENOTSUP; 206 206 } 207 207 208 int rc = usb _kbd_try_add_device(dev);208 int rc = usbhid_try_add_device(dev); 209 209 210 210 if (rc != EOK) { 211 211 usb_log_warning("Device is not a supported keyboard.\n"); 212 usb_log_error("Failed to add KBD device: %s.\n",212 usb_log_error("Failed to add HID device: %s.\n", 213 213 str_error(rc)); 214 214 return rc; … … 224 224 /* Currently, the framework supports only device adding. Once the framework 225 225 * supports unplug, more callbacks will be added. */ 226 static usb_driver_ops_t usb _kbd_driver_ops = {227 .add_device = usb _kbd_add_device,226 static usb_driver_ops_t usbhid_driver_ops = { 227 .add_device = usbhid_add_device, 228 228 }; 229 229 230 230 231 231 /* The driver itself. */ 232 static usb_driver_t usb _kbd_driver = {232 static usb_driver_t usbhid_driver = { 233 233 .name = NAME, 234 .ops = &usb _kbd_driver_ops,234 .ops = &usbhid_driver_ops, 235 235 .endpoints = usb_kbd_endpoints 236 236 }; … … 238 238 /*----------------------------------------------------------------------------*/ 239 239 240 //static driver_ops_t kbd_driver_ops = { 241 // .add_device = usbhid_add_device, 242 //}; 243 244 ///*----------------------------------------------------------------------------*/ 245 246 //static driver_t kbd_driver = { 247 // .name = NAME, 248 // .driver_ops = &kbd_driver_ops 249 //}; 250 251 /*----------------------------------------------------------------------------*/ 252 240 253 int main(int argc, char *argv[]) 241 254 { 242 printf(NAME ": HelenOS USB KBD driver.\n");255 printf(NAME ": HelenOS USB HID driver.\n"); 243 256 244 257 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 245 258 246 return usb_driver_main(&usb _kbd_driver);259 return usb_driver_main(&usbhid_driver); 247 260 } 248 261 -
uspace/drv/usbkbd/usbkbd.ma
r1c6f4ff ra8a7063 1 10 usb&interface&class=HID&subclass=0x01&protocol=0x01 1 100 usb&interface&class=HID&subclass=0x01&protocol=0x01 2 10 usb&interface&class=HID -
uspace/lib/usb/include/usb/classes/hidparser.h
r1c6f4ff ra8a7063 88 88 /** */ 89 89 int depth; 90 uint8_t report_id;91 90 92 91 /** */ 93 92 link_t link; 94 95 93 } usb_hid_report_path_t; 96 94 … … 157 155 /** */ 158 156 link_t feature; 159 160 int use_report_id;161 162 /** */163 link_t stack;164 157 } usb_hid_report_parser_t; 165 158 … … 173 166 * @param arg Custom argument. 174 167 */ 175 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg);168 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t modifiers, void *arg); 176 169 } usb_hid_report_in_callbacks_t; 177 170 … … 276 269 277 270 /** */ 278 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, uint8_t report_id);279 280 /** */281 271 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, int32_t usage_page, int32_t usage); 282 272 -
uspace/lib/usb/src/devpoll.c
r1c6f4ff ra8a7063 66 66 usb_pipe_t *pipe 67 67 = polling_data->dev->pipes[polling_data->pipe_index].pipe; 68 69 usb_log_debug("Pipe interface number: %d, protocol: %d, subclass: %d, max packet size: %d\n",70 polling_data->dev->pipes[polling_data->pipe_index].interface_no,71 polling_data->dev->pipes[polling_data->pipe_index].description->interface_protocol,72 polling_data->dev->pipes[polling_data->pipe_index].description->interface_subclass,73 pipe->max_packet_size);74 68 75 69 size_t failed_attempts = 0; … … 89 83 /* Quit the session regardless of errors. */ 90 84 usb_pipe_end_session(pipe); 91 92 // if (rc == ESTALL) {93 // usb_log_debug("Seding clear feature...\n");94 // usb_request_clear_feature(pipe, USB_REQUEST_TYPE_STANDARD,95 // USB_REQUEST_RECIPIENT_ENDPOINT, 0, pipe->endpoint_no);96 // continue;97 // }98 85 99 86 if (rc != EOK) { -
uspace/lib/usb/src/hidparser.c
r1c6f4ff ra8a7063 64 64 int usb_hid_report_reset_local_items(); 65 65 void usb_hid_free_report_list(link_t *head); 66 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item); 66 67 67 /* 68 68 * Data translation private functions … … 106 106 list_initialize(&(parser->feature)); 107 107 108 list_initialize(&(parser->stack));109 110 parser->use_report_id = 0;111 108 return EOK; 112 109 } … … 189 186 tmp_usage_path = NULL; 190 187 191 usb_hid_report_path_set_report_id(report_item->usage_path, report_item->id);192 if(report_item->id != 0){193 parser->use_report_id = 1;194 }195 188 196 189 switch(tag) { … … 222 215 if(!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) { 223 216 return ENOMEM; 224 } 217 } 225 218 memcpy(new_report_item,report_item, sizeof(usb_hid_report_item_t)); 226 link_initialize(&(new_report_item->link));227 228 219 /* reset local items */ 229 220 new_report_item->usage_minimum = 0; 230 221 new_report_item->usage_maximum = 0; 231 new_report_item->designator_index = 0;232 new_report_item->designator_minimum = 0;233 new_report_item->designator_maximum = 0;234 new_report_item->string_index = 0;235 new_report_item->string_minimum = 0;236 new_report_item->string_maximum = 0;237 238 /* reset usage from current usage path */239 usb_hid_report_usage_path_t *path = list_get_instance(&usage_path->link, usb_hid_report_usage_path_t, link);240 path->usage = 0;241 222 223 link_initialize(&(new_report_item->link)); 242 224 report_item = new_report_item; 243 225 … … 245 227 case USB_HID_REPORT_TAG_PUSH: 246 228 // push current state to stack 247 new_report_item = usb_hid_report_item_clone(report_item); 248 list_prepend (&parser->stack, &new_report_item->link); 249 229 // not yet implemented 250 230 break; 251 231 case USB_HID_REPORT_TAG_POP: 252 232 // restore current state from stack 253 if(list_empty (&parser->stack)) { 254 return EINVAL; 255 } 256 257 report_item = list_get_instance(&parser->stack, usb_hid_report_item_t, link); 258 list_remove (parser->stack.next); 259 233 // not yet implemented 260 234 break; 261 235 … … 673 647 } 674 648 675 parser->use_report_id = 0;676 677 649 usb_hid_free_report_list(&parser->input); 678 650 usb_hid_free_report_list(&parser->output); … … 704 676 size_t i=0; 705 677 size_t j=0; 706 uint8_t report_id = 0;707 678 708 679 if(parser == NULL) { … … 715 686 if(!(keys = malloc(sizeof(uint8_t) * key_count))){ 716 687 return ENOMEM; 717 }718 719 if(parser->use_report_id != 0) {720 report_id = data[0];721 usb_hid_report_path_set_report_id(path, report_id);722 688 } 723 689 … … 727 693 728 694 item = list_get_instance(list_item, usb_hid_report_item_t, link); 729 730 695 if(!USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) && 731 696 (usb_hid_report_compare_usage_path(item->usage_path, path, flags) == EOK)) { … … 750 715 } 751 716 752 callbacks->keyboard(keys, key_count, report_id, arg);717 callbacks->keyboard(keys, key_count, 0, arg); 753 718 754 719 free(keys); … … 774 739 int32_t mask; 775 740 const uint8_t *foo; 776 741 777 742 // now only common numbers llowed 778 743 if(item->size > 32) { … … 793 758 (usb_pow(10,(item->unit_exponent)))); 794 759 } 795 796 760 offset = item->offset + (j * item->size); 797 if(item->id != 0) {798 offset += 8;799 usb_log_debug("MOVED OFFSET BY 1Byte, REPORT_ID(%d)\n", item->id);800 }801 761 802 762 // FIXME … … 982 942 983 943 int only_page; 984 985 if(report_path->report_id != path->report_id) {986 return 1;987 }988 944 989 945 if(path->depth == 0){ … … 1082 1038 else { 1083 1039 path->depth = 0; 1084 path->report_id = 0;1085 1040 list_initialize(&path->link); 1086 1041 return path; … … 1200 1155 return 0; 1201 1156 } 1202 1157 1203 1158 item = parser->output.next; 1204 1159 while(&parser->output != item) { … … 1240 1195 int length; 1241 1196 int32_t tmp_value; 1242 size_t offset_prefix = 0;1243 1197 1244 1198 if(parser == NULL) { 1245 1199 return EINVAL; 1246 }1247 1248 if(parser->use_report_id != 0) {1249 buffer[0] = path->report_id;1250 offset_prefix = 8;1251 1200 } 1252 1201 … … 1269 1218 // // variable item 1270 1219 value = usb_hid_translate_data_reverse(report_item, data[idx++]); 1271 offset = report_item->offset + (i * report_item->size) + offset_prefix;1220 offset = report_item->offset + (i * report_item->size); 1272 1221 length = report_item->size; 1273 1222 } … … 1275 1224 //bitmap 1276 1225 value += usb_hid_translate_data_reverse(report_item, data[idx++]); 1277 offset = report_item->offset + offset_prefix;1226 offset = report_item->offset; 1278 1227 length = report_item->size * report_item->count; 1279 1228 } … … 1374 1323 1375 1324 1376 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id)1377 {1378 if(path == NULL){1379 return EINVAL;1380 }1381 1382 path->report_id = report_id;1383 return EOK;1384 }1385 1386 1387 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item)1388 {1389 usb_hid_report_item_t *new_report_item;1390 1391 if(!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) {1392 return NULL;1393 }1394 memcpy(new_report_item,item, sizeof(usb_hid_report_item_t));1395 link_initialize(&(new_report_item->link));1396 1397 return new_report_item;1398 }1399 1400 1325 /** 1401 1326 * @} -
uspace/lib/usb/src/hidreport.c
r1c6f4ff ra8a7063 80 80 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 81 81 dev->descriptors.configuration, d); 82 ++i;83 82 } 84 83
Note:
See TracChangeset
for help on using the changeset viewer.