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