Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/kbd/kbddev.c

    r4939490 rfaa44e58  
    252252        sysarg_t method = IPC_GET_IMETHOD(*icall);
    253253       
    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) {
    256257                usb_log_debug("default_connection_handler: "
    257258                    "Missing parameter.\n");
     
    259260                return;
    260261        }
     262       
     263        assert(hid_dev != NULL);
     264        assert(hid_dev->data != NULL);
     265        usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
    261266
    262267        if (method == IPC_M_CONNECT_TO_ME) {
     
    308313        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    309314            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,
    311316            USB_HID_REPORT_TYPE_OUTPUT);
    312317       
    313         while (field != NULL) {         
    314                
     318        while (field != NULL) {
     319
    315320                if ((field->usage == USB_HID_LED_NUM_LOCK)
    316321                    && (kbd_dev->mods & KM_NUM_LOCK)){
     
    329334               
    330335                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);
    334338        }
    335339       
     
    658662 *     usb_hid_parse_report().
    659663 */
    660 static void usb_kbd_process_data(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev,
     664static void usb_kbd_process_data(usb_hid_dev_t *hid_dev,
    661665                                 uint8_t *buffer, size_t actual_size)
    662666{
    663667        assert(hid_dev->report != NULL);
    664668        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;
    666672
    667673        usb_log_debug("Calling usb_hid_parse_report() with "
     
    768774/*----------------------------------------------------------------------------*/
    769775
    770 static int usb_kbd_create_function(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
     776static int usb_kbd_create_function(usb_hid_dev_t *hid_dev)
    771777{
    772778        assert(hid_dev != NULL);
    773779        assert(hid_dev->usb_dev != NULL);
    774         assert(kbd_dev != NULL);
    775780       
    776781        /* Create the function exposed under /dev/devices. */
     
    787792         * to the DDF function.
    788793         */
    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
    791796
    792797        int rc = ddf_fun_bind(fun);
     
    797802                return rc;
    798803        }
    799        
    800         usb_log_debug("%s function created. Handle: %d\n", HID_KBD_FUN_NAME,
    801             fun->handle);
    802804       
    803805        usb_log_debug("Adding DDF function to class %s...\n",
     
    838840 * @return Other value inherited from function usbhid_dev_init().
    839841 */
    840 int usb_kbd_init(usb_hid_dev_t *hid_dev, void **data)
     842int usb_kbd_init(usb_hid_dev_t *hid_dev)
    841843{
    842844        usb_log_debug("Initializing HID/KBD structure...\n");
     
    863865        usb_hid_report_path_set_report_id(path, 0);
    864866       
    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);
    867870        usb_hid_report_path_free(path);
    868871       
     
    905908            kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
    906909       
    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);
    909913       
    910914        usb_log_debug("Output report size (in items): %zu\n",
     
    951955       
    952956        // 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;
    955958       
    956959        // set handler for incoming calls
    957         kbd_dev->ops.default_handler = default_connection_handler;
     960        hid_dev->ops.default_handler = default_connection_handler;
    958961       
    959962        /*
     
    980983       
    981984        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);
    983986        if (rc != EOK) {
    984987                usb_kbd_free(&kbd_dev);
     
    991994/*----------------------------------------------------------------------------*/
    992995
    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) {
     996bool 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) {
    9971000                // do not continue polling (???)
    9981001                return false;
    9991002        }
    10001003       
    1001         usb_kbd_t *kbd_dev = (usb_kbd_t *)data;
    1002         assert(kbd_dev != NULL);
    1003        
    10041004        // 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);
    10061006       
    10071007        return true;
     
    10661066/*----------------------------------------------------------------------------*/
    10671067
    1068 void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data)
     1068void usb_kbd_deinit(usb_hid_dev_t *hid_dev)
    10691069{
    10701070        if (hid_dev == NULL) {
     
    10721072        }
    10731073       
    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;
    10761076                if (usb_kbd_is_initialized(kbd_dev)) {
    10771077                        usb_kbd_mark_unusable(kbd_dev);
    10781078                } else {
    10791079                        usb_kbd_free(&kbd_dev);
     1080                        hid_dev->data = NULL;
    10801081                }
    10811082        }
Note: See TracChangeset for help on using the changeset viewer.