Changes in uspace/drv/usbhid/kbd/kbddev.c [4939490:faa44e58] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/kbd/kbddev.c
r4939490 rfaa44e58 252 252 sysarg_t method = IPC_GET_IMETHOD(*icall); 253 253 254 usb_kbd_t *kbd_dev = (usb_kbd_t *)fun->driver_data; 255 if (kbd_dev == NULL) { 254 usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data; 255 256 if (hid_dev == NULL || hid_dev->data == NULL) { 256 257 usb_log_debug("default_connection_handler: " 257 258 "Missing parameter.\n"); … … 259 260 return; 260 261 } 262 263 assert(hid_dev != NULL); 264 assert(hid_dev->data != NULL); 265 usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data; 261 266 262 267 if (method == IPC_M_CONNECT_TO_ME) { … … 308 313 usb_hid_report_field_t *field = usb_hid_report_get_sibling( 309 314 hid_dev->report, NULL, kbd_dev->led_path, 310 USB_HID_PATH_COMPARE_ END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,315 USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY | USB_HID_PATH_COMPARE_END, 311 316 USB_HID_REPORT_TYPE_OUTPUT); 312 317 313 while (field != NULL) { 314 318 while (field != NULL) { 319 315 320 if ((field->usage == USB_HID_LED_NUM_LOCK) 316 321 && (kbd_dev->mods & KM_NUM_LOCK)){ … … 329 334 330 335 field = usb_hid_report_get_sibling(hid_dev->report, field, 331 kbd_dev->led_path, 332 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 333 USB_HID_REPORT_TYPE_OUTPUT); 336 kbd_dev->led_path, USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 337 | USB_HID_PATH_COMPARE_END, USB_HID_REPORT_TYPE_OUTPUT); 334 338 } 335 339 … … 658 662 * usb_hid_parse_report(). 659 663 */ 660 static void usb_kbd_process_data(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev,664 static void usb_kbd_process_data(usb_hid_dev_t *hid_dev, 661 665 uint8_t *buffer, size_t actual_size) 662 666 { 663 667 assert(hid_dev->report != NULL); 664 668 assert(hid_dev != NULL); 665 assert(kbd_dev != NULL); 669 assert(hid_dev->data != NULL); 670 671 usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data; 666 672 667 673 usb_log_debug("Calling usb_hid_parse_report() with " … … 768 774 /*----------------------------------------------------------------------------*/ 769 775 770 static int usb_kbd_create_function(usb_hid_dev_t *hid_dev , usb_kbd_t *kbd_dev)776 static int usb_kbd_create_function(usb_hid_dev_t *hid_dev) 771 777 { 772 778 assert(hid_dev != NULL); 773 779 assert(hid_dev->usb_dev != NULL); 774 assert(kbd_dev != NULL);775 780 776 781 /* Create the function exposed under /dev/devices. */ … … 787 792 * to the DDF function. 788 793 */ 789 fun->ops = & kbd_dev->ops;790 fun->driver_data = kbd_dev;794 fun->ops = &hid_dev->ops; 795 fun->driver_data = hid_dev; // TODO: maybe change to hid_dev->data 791 796 792 797 int rc = ddf_fun_bind(fun); … … 797 802 return rc; 798 803 } 799 800 usb_log_debug("%s function created. Handle: %d\n", HID_KBD_FUN_NAME,801 fun->handle);802 804 803 805 usb_log_debug("Adding DDF function to class %s...\n", … … 838 840 * @return Other value inherited from function usbhid_dev_init(). 839 841 */ 840 int usb_kbd_init(usb_hid_dev_t *hid_dev , void **data)842 int usb_kbd_init(usb_hid_dev_t *hid_dev) 841 843 { 842 844 usb_log_debug("Initializing HID/KBD structure...\n"); … … 863 865 usb_hid_report_path_set_report_id(path, 0); 864 866 865 kbd_dev->key_count = usb_hid_report_size( 866 hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT); 867 kbd_dev->key_count = usb_hid_report_input_length( 868 hid_dev->report, path, 869 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 867 870 usb_hid_report_path_free(path); 868 871 … … 905 908 kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0); 906 909 907 kbd_dev->led_output_size = usb_hid_report_size(hid_dev->report, 908 0, USB_HID_REPORT_TYPE_OUTPUT); 910 kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->report, 911 kbd_dev->led_path, 912 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 909 913 910 914 usb_log_debug("Output report size (in items): %zu\n", … … 951 955 952 956 // save the KBD device structure into the HID device structure 953 //hid_dev->data = kbd_dev; 954 *data = kbd_dev; 957 hid_dev->data = kbd_dev; 955 958 956 959 // set handler for incoming calls 957 kbd_dev->ops.default_handler = default_connection_handler;960 hid_dev->ops.default_handler = default_connection_handler; 958 961 959 962 /* … … 980 983 981 984 usb_log_debug("Creating KBD function...\n"); 982 int rc = usb_kbd_create_function(hid_dev , kbd_dev);985 int rc = usb_kbd_create_function(hid_dev); 983 986 if (rc != EOK) { 984 987 usb_kbd_free(&kbd_dev); … … 991 994 /*----------------------------------------------------------------------------*/ 992 995 993 bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, void *data,994 uint8_t *buffer,size_t buffer_size)995 { 996 if (hid_dev == NULL || buffer == NULL || data == NULL) {996 bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, uint8_t *buffer, 997 size_t buffer_size) 998 { 999 if (hid_dev == NULL || buffer == NULL) { 997 1000 // do not continue polling (???) 998 1001 return false; 999 1002 } 1000 1003 1001 usb_kbd_t *kbd_dev = (usb_kbd_t *)data;1002 assert(kbd_dev != NULL);1003 1004 1004 // TODO: add return value from this function 1005 usb_kbd_process_data(hid_dev, kbd_dev,buffer, buffer_size);1005 usb_kbd_process_data(hid_dev, buffer, buffer_size); 1006 1006 1007 1007 return true; … … 1066 1066 /*----------------------------------------------------------------------------*/ 1067 1067 1068 void usb_kbd_deinit(usb_hid_dev_t *hid_dev , void *data)1068 void usb_kbd_deinit(usb_hid_dev_t *hid_dev) 1069 1069 { 1070 1070 if (hid_dev == NULL) { … … 1072 1072 } 1073 1073 1074 if ( data != NULL) {1075 usb_kbd_t *kbd_dev = (usb_kbd_t *) data;1074 if (hid_dev->data != NULL) { 1075 usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data; 1076 1076 if (usb_kbd_is_initialized(kbd_dev)) { 1077 1077 usb_kbd_mark_unusable(kbd_dev); 1078 1078 } else { 1079 1079 usb_kbd_free(&kbd_dev); 1080 hid_dev->data = NULL; 1080 1081 } 1081 1082 }
Note:
See TracChangeset
for help on using the changeset viewer.