Changes in / [109d55c:d754f59] in mainline
- Location:
- uspace
- Files:
-
- 2 added
- 3 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/generic/hiddev.c
r109d55c rd754f59 126 126 } 127 127 128 /*! @todo This should probably be atomic. */ 129 // if (usb_hid_report_ready()) { 130 // usb_log_debug2("Report ready, size: %zu\n", 131 // hid_dev->input_report_size); 132 133 // usb_hid_report_received(); 134 // } else { 135 // memset(buffer, 0, hid_dev->input_report_size); 136 // } 128 /*! @todo This should probably be somehow atomic. */ 137 129 memcpy(buffer, hid_dev->input_report, 138 130 hid_dev->input_report_size); … … 140 132 *event_nr = usb_hid_report_number(hid_dev); 141 133 142 // clear the buffer so that it will not be received twice143 //memset(hid_dev->input_report, 0, hid_dev->input_report_size);144 145 // note that we already received this report146 // report_received = true;147 134 usb_log_debug2("OK\n"); 148 135 … … 184 171 185 172 if (hid_dev->report_desc_size > size) { 186 return EINVAL; // TODO: other error code173 return EINVAL; 187 174 } 188 175 -
uspace/drv/usbhid/kbd/kbddev.c
r109d55c rd754f59 72 72 static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK; 73 73 74 ///** Boot protocol report size (key part). */75 //static const size_t BOOTP_REPORT_SIZE = 6;76 77 ///** Boot protocol total report size. */78 //static const size_t BOOTP_BUFFER_SIZE = 8;79 80 ///** Boot protocol output report size. */81 //static const size_t BOOTP_BUFFER_OUT_SIZE = 1;82 83 ///** Boot protocol error key code. */84 //static const uint8_t BOOTP_ERROR_ROLLOVER = 1;85 74 static const uint8_t ERROR_ROLLOVER = 1; 86 75 … … 105 94 .flags = 0 106 95 }; 107 108 //static usb_endpoint_description_t hid_poll_endpoint_description = {109 // .transfer_type = USB_TRANSFER_INTERRUPT,110 // .direction = USB_DIRECTION_IN,111 // .interface_class = USB_CLASS_HID,112 // .flags = 0113 //};114 115 ///* Array of endpoints expected on the device, NULL terminated. */116 //usb_endpoint_description_t117 // *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1] = {118 // &boot_poll_endpoint_description,119 // &hid_poll_endpoint_description,120 // NULL121 //};122 96 123 97 const char *HID_KBD_FUN_NAME = "keyboard"; … … 176 150 177 151 /*----------------------------------------------------------------------------*/ 178 179 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,180 // uint8_t report_id, void *arg);181 182 //static const usb_hid_report_in_callbacks_t usb_kbd_parser_callbacks = {183 // .keyboard = usb_kbd_process_keycodes184 //};185 186 /*----------------------------------------------------------------------------*/187 152 /* Keyboard layouts */ 188 153 /*----------------------------------------------------------------------------*/ … … 200 165 201 166 /*----------------------------------------------------------------------------*/ 202 /* Modifier constants */203 /*----------------------------------------------------------------------------*/204 /** Mapping of USB modifier key codes to generic modifier key codes. */205 //static const keycode_t usbhid_modifiers_keycodes[USB_HID_MOD_COUNT] = {206 // KC_LCTRL, /* USB_HID_MOD_LCTRL */207 // KC_LSHIFT, /* USB_HID_MOD_LSHIFT */208 // KC_LALT, /* USB_HID_MOD_LALT */209 // 0, /* USB_HID_MOD_LGUI */210 // KC_RCTRL, /* USB_HID_MOD_RCTRL */211 // KC_RSHIFT, /* USB_HID_MOD_RSHIFT */212 // KC_RALT, /* USB_HID_MOD_RALT */213 // 0, /* USB_HID_MOD_RGUI */214 //};215 216 //typedef enum usbhid_lock_code {217 // USB_KBD_LOCK_NUM = 0x53,218 // USB_KBD_LOCK_CAPS = 0x39,219 // USB_KBD_LOCK_SCROLL = 0x47,220 // USB_KBD_LOCK_COUNT = 3221 //} usbhid_lock_code;222 223 //static const usbhid_lock_code usbhid_lock_codes[USB_KBD_LOCK_COUNT] = {224 // USB_KBD_LOCK_NUM,225 // USB_KBD_LOCK_CAPS,226 // USB_KBD_LOCK_SCROLL227 //};228 229 /*----------------------------------------------------------------------------*/230 167 /* IPC method handler */ 231 168 /*----------------------------------------------------------------------------*/ 232 169 233 170 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 234 //ddf_dev_ops_t keyboard_ops = {235 // .default_handler = default_connection_handler236 //};237 171 238 172 /** … … 301 235 return; 302 236 } 303 237 304 238 /* Reset the LED data. */ 305 239 memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t)); … … 495 429 */ 496 430 static void usb_kbd_check_key_changes(usb_hid_dev_t *hid_dev, 497 usb_kbd_t *kbd_dev /*, const uint8_t *key_codes, size_t count*/)431 usb_kbd_t *kbd_dev) 498 432 { 499 433 unsigned int key; … … 567 501 } 568 502 569 // usb_log_debug("Old keys: ");570 // for (i = 0; i < kbd_dev->key_count; ++i) {571 // usb_log_debug("%d ", kbd_dev->keys_old[i]);572 // }573 // usb_log_debug("\n");574 575 576 // usb_log_debug("New keys: ");577 // for (i = 0; i < kbd_dev->key_count; ++i) {578 // usb_log_debug("%d ", kbd_dev->keys[i]);579 // }580 // usb_log_debug("\n");581 582 503 memcpy(kbd_dev->keys_old, kbd_dev->keys, kbd_dev->key_count * 4); 583 504 … … 590 511 591 512 /*----------------------------------------------------------------------------*/ 592 /* Callbacks for parser */593 /*----------------------------------------------------------------------------*/594 /**595 * Callback function for the HID report parser.596 *597 * This function is called by the HID report parser with the parsed report.598 * The parsed report is used to check if any events occured (key was pressed or599 * released, modifier was pressed or released).600 *601 * @param key_codes Parsed keyboard report - codes of currently pressed keys602 * according to HID Usage Tables.603 * @param count Number of key codes in report (size of the report).604 * @param report_id605 * @param arg User-specified argument. Expects pointer to the keyboard device606 * structure representing the keyboard.607 *608 * @sa usb_kbd_check_key_changes(), usb_kbd_check_modifier_changes()609 */610 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,611 // uint8_t report_id, void *arg)612 //{613 // if (arg == NULL) {614 // usb_log_warning("Missing argument in callback "615 // "usbhid_process_keycodes().\n");616 // return;617 // }618 619 // usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;620 621 // if (hid_dev->data == NULL) {622 // usb_log_warning("Missing KBD device structure in callback.\n");623 // return;624 // }625 626 // usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;627 628 // usb_log_debug("Got keys from parser (report id: %u): %s\n",629 // report_id, usb_debug_str_buffer(key_codes, count, 0));630 631 // if (count != kbd_dev->key_count) {632 // usb_log_warning("Number of received keycodes (%zu) differs from"633 // " expected (%zu).\n", count, kbd_dev->key_count);634 // return;635 // }636 637 // ///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);638 // usb_kbd_check_key_changes(hid_dev, kbd_dev, key_codes, count);639 //}640 641 /*----------------------------------------------------------------------------*/642 513 /* General kbd functions */ 643 514 /*----------------------------------------------------------------------------*/ … … 668 539 "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0)); 669 540 670 // int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size,671 // callbacks, kbd_dev);672 541 usb_hid_report_path_t *path = usb_hid_report_path(); 673 542 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 674 //usb_hid_report_path_set_report_id(path, 0);675 543 676 544 uint8_t report_id; … … 698 566 699 567 assert(i < kbd_dev->key_count); 700 // if (i == kbd_dev->key_count) {701 // break;702 // }703 568 704 569 // save the key usage 705 /* TODO: maybe it's not good to save value, nor usage706 * as the value may be e.g. 1 for LEDs and usage may be707 * value of the LED. On the other hand, in case of normal708 * keys, the usage is more important and we must check709 * that. One possible solution: distinguish between those710 * two parts of the Report somehow.711 */712 570 if (field->value != 0) { 713 571 kbd_dev->keys[i] = field->usage; … … 896 754 usb_log_warning("Error creating output report buffer.\n"); 897 755 free(kbd_dev->keys); 898 return ENOMEM; /* TODO: other error code */756 return ENOMEM; 899 757 } 900 758 … … 951 809 952 810 // save the KBD device structure into the HID device structure 953 //hid_dev->data = kbd_dev;954 811 *data = kbd_dev; 955 812 … … 1038 895 1039 896 if ((*kbd_dev)->repeat_mtx != NULL) { 1040 / * TODO: replace by some check and wait */1041 assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));897 //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)); 898 while (fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)) {} 1042 899 free((*kbd_dev)->repeat_mtx); 1043 900 } -
uspace/drv/usbhid/kbd/main.c
r109d55c rd754f59 131 131 "Could not add DDF function to class 'keyboard': %s.\n", 132 132 str_error(rc)); 133 // TODO: Can / should I destroy the DDF function?134 133 ddf_fun_destroy(kbd_fun); 135 134 usb_kbd_free(&kbd_dev); 136 135 return rc; 137 136 } 138 139 /*140 * Create new fibril for handling this keyboard141 */142 //fid_t fid = fibril_create(usb_kbd_fibril, kbd_dev);143 137 144 138 /* Start automated polling function. … … 164 158 return rc; 165 159 } 166 //fibril_add_ready(fid);167 160 168 161 /* -
uspace/drv/usbhid/mouse/mousedev.c
r109d55c rd754f59 394 394 395 395 fun->ops = &mouse->ops; 396 fun->driver_data = mouse; // TODO: maybe change to hid_dev->data396 fun->driver_data = mouse; 397 397 398 398 int rc = ddf_fun_bind(fun); … … 432 432 */ 433 433 fun->ops = &mouse->ops; 434 fun->driver_data = mouse; // TODO: maybe change to hid_dev->data434 fun->driver_data = mouse; 435 435 436 436 rc = ddf_fun_bind(fun); … … 488 488 489 489 // set handler for incoming calls 490 // TODO: must be one for each subdriver!!491 490 mouse_dev->ops.default_handler = default_connection_handler; 492 491 493 492 // TODO: how to know if the device supports the request??? 494 //usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe,495 //hid_dev->usb_dev->interface_no, IDLE_RATE);493 usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe, 494 hid_dev->usb_dev->interface_no, IDLE_RATE); 496 495 497 496 int rc = usb_mouse_create_function(hid_dev, mouse_dev); -
uspace/drv/usbhid/mouse/mousedev.h
r109d55c rd754f59 45 45 /** Container for USB mouse device. */ 46 46 typedef struct { 47 ///** Polling interval in microseconds. */48 //suseconds_t poll_interval_us;49 47 /** IPC phone to console (consumer). */ 50 48 int mouse_phone; -
uspace/drv/usbhid/multimedia/multimedia.c
r109d55c rd754f59 143 143 assert(multim_dev != NULL); 144 144 145 // usb_multimedia_t *multim_dev = (usb_multimedia_t *)hid_dev->data;146 147 145 console_event_t ev; 148 146 … … 173 171 // hangup phone to the console 174 172 async_hangup((*multim_dev)->console_phone); 175 176 // free all buffers177 // if ((*multim_dev)->keys != NULL) {178 // free((*multim_dev)->keys);179 // }180 // if ((*multim_dev)->keys_old != NULL) {181 // free((*multim_dev)->keys_old);182 // }183 173 184 174 free(*multim_dev); … … 245 235 multim_dev->console_phone = -1; 246 236 247 // usb_hid_report_path_t *path = usb_hid_report_path();248 // usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0);249 250 // usb_hid_report_path_set_report_id(path, 1);251 252 // multim_dev->key_count = usb_hid_report_size(253 // hid_dev->report, 1, USB_HID_REPORT_TYPE_INPUT);254 255 // usb_hid_report_path_free(path);256 257 // usb_log_debug(NAME " Size of the input report: %zu\n",258 // multim_dev->key_count);259 260 // multim_dev->keys = (int32_t *)calloc(multim_dev->key_count,261 // sizeof(int32_t));262 263 // if (multim_dev->keys == NULL) {264 // usb_log_fatal("No memory!\n");265 // free(multim_dev);266 // return ENOMEM;267 // }268 269 // multim_dev->keys_old =270 // (int32_t *)calloc(multim_dev->key_count, sizeof(int32_t));271 272 // if (multim_dev->keys_old == NULL) {273 // usb_log_fatal("No memory!\n");274 // free(multim_dev->keys);275 // free(multim_dev);276 // return ENOMEM;277 // }278 279 237 /*! @todo Autorepeat */ 280 238 … … 315 273 { 316 274 // TODO: checks 275 if (hid_dev == NULL || data == NULL || buffer == NULL) { 276 return false; 277 } 317 278 318 279 usb_log_debug(NAME " usb_lgtch_polling_callback(%p, %p, %zu)\n", 319 280 hid_dev, buffer, buffer_size); 320 321 if (data == NULL) {322 return EINVAL; // TODO: other error code?323 }324 281 325 282 usb_multimedia_t *multim_dev = (usb_multimedia_t *)data; … … 348 305 | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 349 306 USB_HID_REPORT_TYPE_INPUT); 350 351 // unsigned int key; 352 307 353 308 /*! @todo Is this iterating OK if done multiple times? 354 309 * @todo The parsing is not OK -
uspace/drv/usbhid/subdrivers.c
r109d55c rd754f59 58 58 }; 59 59 60 //static usb_hid_subdriver_usage_t generic_hid_key_path[] = {61 // {0, 0}62 //};63 64 60 const usb_hid_subdriver_mapping_t usb_hid_subdrivers[] = { 65 61 { … … 103 99 } 104 100 }, 105 // {106 // generic_hid_key_path,107 // 0,108 // USB_HID_PATH_COMPARE_ANYWHERE,109 // -1,110 // -1,111 // {112 // .init = usb_generic_hid_init,113 // .deinit = NULL,114 // .poll = usb_generic_hid_polling_callback,115 // .poll_end = NULL116 // }117 // },118 101 {NULL, -1, 0, -1, -1, {NULL, NULL, NULL, NULL, NULL}} 119 102 }; -
uspace/drv/usbhid/usbhid.c
r109d55c rd754f59 63 63 static const int USB_HID_MAX_SUBDRIVERS = 10; 64 64 65 /** @todo What happens if this is not fibril local? */66 //static fibril_local bool report_number;67 68 65 /*----------------------------------------------------------------------------*/ 69 66 … … 206 203 } 207 204 208 // if (mapping->report_id >= 0) {209 // usb_hid_report_path_set_report_id(usage_path,210 // mapping->report_id);211 // }212 213 205 assert(hid_dev->report != NULL); 214 206 215 207 usb_log_debug("Compare flags: %d\n", mapping->compare); 216 // size_t size = usb_hid_report_size(hid_dev->report, 0,217 // USB_HID_REPORT_TYPE_INPUT);218 // size_t size = 0;219 208 220 209 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 210 uint8_t report_id = mapping->report_id; 226 211 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 212 do { 234 213 usb_log_debug("Trying report id %u\n", report_id); 235 214 … … 247 226 248 227 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 228 matches = true; 254 229 break; … … 258 233 hid_dev->report, report_id, 259 234 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 235 } while (!matches && report_id != 0); 278 236 279 // usb_log_debug("Size of the input report: %zu\n", size);280 237 usb_hid_report_path_free(usage_path); 281 238 … … 423 380 424 381 uint8_t report_id = 0; 425 size_t size;/* = usb_hid_report_byte_size(hid_dev->report, report_id, 426 USB_HID_REPORT_TYPE_INPUT);*/ 382 size_t size; 427 383 428 384 size_t max_size = 0; … … 503 459 rc = usb_hid_check_pipes(hid_dev, dev); 504 460 if (rc != EOK) { 505 //usb_hid_free(&hid_dev);506 461 return rc; 507 462 } … … 551 506 == USB_HID_GENERIC_POLL_EP_NO); 552 507 553 /* TODO: this has no meaning if the report descriptor554 is not parsed */555 508 usb_log_info("Falling back to generic HID driver.\n"); 556 509 rc = usb_hid_set_generic_hid_subdriver(hid_dev); … … 563 516 usb_log_debug("Subdriver count: %d\n", 564 517 hid_dev->subdriver_count); 565 //usb_hid_free(&hid_dev);566 518 567 519 } else { … … 619 571 usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg; 620 572 621 // int allocated = (hid_dev->input_report != NULL);622 573 assert(hid_dev->input_report != NULL); 623 574 usb_log_debug("Max input report size: %zu, buffer size: %zu\n", 624 575 hid_dev->max_input_report_size, buffer_size); 625 //assert(hid_dev->max_input_report_size >= buffer_size); 576 626 577 if (hid_dev->max_input_report_size >= buffer_size) { 627 578 /*! @todo This should probably be atomic. */ … … 670 621 /*----------------------------------------------------------------------------*/ 671 622 672 //const char *usb_hid_get_function_name(const usb_hid_dev_t *hid_dev)673 //{674 // switch (hid_dev->poll_pipe_index) {675 // case USB_HID_KBD_POLL_EP_NO:676 // return HID_KBD_FUN_NAME;677 // break;678 // case USB_HID_MOUSE_POLL_EP_NO:679 // return HID_MOUSE_FUN_NAME;680 // break;681 // default:682 // return HID_GENERIC_FUN_NAME;683 // }684 //}685 686 /*----------------------------------------------------------------------------*/687 688 //const char *usb_hid_get_class_name(const usb_hid_dev_t *hid_dev)689 //{690 // // this means that only boot protocol keyboards will be connected691 // // to the console; there is probably no better way to do this692 693 // switch (hid_dev->poll_pipe_index) {694 // case USB_HID_KBD_POLL_EP_NO:695 // return HID_KBD_CLASS_NAME;696 // break;697 // case USB_HID_MOUSE_POLL_EP_NO:698 // return HID_MOUSE_CLASS_NAME;699 // break;700 // default:701 // return HID_GENERIC_CLASS_NAME;702 // }703 //}704 705 /*----------------------------------------------------------------------------*/706 707 623 void usb_hid_new_report(usb_hid_dev_t *hid_dev) 708 624 { … … 716 632 return hid_dev->report_nr; 717 633 } 718 719 /*----------------------------------------------------------------------------*/720 721 //void usb_hid_report_received(void)722 //{723 // ++report_number;724 //}725 726 /*----------------------------------------------------------------------------*/727 728 //bool usb_hid_report_ready(void)729 //{730 // return !report_received;731 //}732 634 733 635 /*----------------------------------------------------------------------------*/ -
uspace/drv/usbhid/usbhid.h
r109d55c rd754f59 55 55 bool reason); 56 56 57 // TODO: add function and class name??58 57 typedef struct usb_hid_subdriver { 59 58 /** Function to be called when initializing HID device. */ … … 126 125 void *arg); 127 126 128 //const char *usb_hid_get_function_name(const usb_hid_dev_t *hid_dev);129 130 //const char *usb_hid_get_class_name(const usb_hid_dev_t *hid_dev);131 132 127 void usb_hid_new_report(usb_hid_dev_t *hid_dev); 133 128 134 129 int usb_hid_report_number(usb_hid_dev_t *hid_dev); 135 136 //void usb_hid_report_received(void);137 138 //bool usb_hid_report_ready(void);139 130 140 131 void usb_hid_free(usb_hid_dev_t **hid_dev); -
uspace/drv/usbhub/ports.c
r109d55c rd754f59 95 95 * @param port port number, starting from 1 96 96 */ 97 void usb_hub_process_ interrupt(usb_hub_info_t *hub,97 void usb_hub_process_port_interrupt(usb_hub_info_t *hub, 98 98 uint16_t port) { 99 99 usb_log_debug("Interrupt at port %zu\n", (size_t) port); -
uspace/drv/usbhub/ports.h
r109d55c rd754f59 70 70 71 71 72 void usb_hub_process_ interrupt(usb_hub_info_t *hub,72 void usb_hub_process_port_interrupt(usb_hub_info_t *hub, 73 73 uint16_t port); 74 74 -
uspace/drv/usbhub/usbhub.c
r109d55c rd754f59 168 168 bool change = (change_bitmap[port / 8] >> (port % 8)) % 2; 169 169 if (change) { 170 usb_hub_process_ interrupt(hub, port);170 usb_hub_process_port_interrupt(hub, port); 171 171 } 172 172 } … … 266 266 267 267 if (!has_individual_port_powering) { 268 usb_log_debug("Has_global powering\n"); 269 opResult = usb_hub_set_feature(hub_info->control_pipe, 270 USB_HUB_FEATURE_C_HUB_LOCAL_POWER); 271 if (opResult != EOK) { 272 usb_log_error("Cannot power hub: %s\n", 273 str_error(opResult)); 274 } 268 //this setting actually makes no difference 269 usb_log_debug("Hub has global powering\n"); 275 270 } 276 271 … … 280 275 port, USB_HUB_FEATURE_PORT_POWER); 281 276 if (opResult != EOK) { 282 usb_log_error(" cannot power on port %zu: %s.\n",277 usb_log_error("Cannot power on port %zu: %s.\n", 283 278 port, str_error(opResult)); 284 279 }
Note:
See TracChangeset
for help on using the changeset viewer.