Ignore:
File:
1 edited

Legend:

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

    rfaa44e58 r4939490  
    252252        sysarg_t method = IPC_GET_IMETHOD(*icall);
    253253       
    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) {
    257256                usb_log_debug("default_connection_handler: "
    258257                    "Missing parameter.\n");
     
    260259                return;
    261260        }
    262        
    263         assert(hid_dev != NULL);
    264         assert(hid_dev->data != NULL);
    265         usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
    266261
    267262        if (method == IPC_M_CONNECT_TO_ME) {
     
    313308        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    314309            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,
    316311            USB_HID_REPORT_TYPE_OUTPUT);
    317312       
    318         while (field != NULL) {
    319 
     313        while (field != NULL) {         
     314               
    320315                if ((field->usage == USB_HID_LED_NUM_LOCK)
    321316                    && (kbd_dev->mods & KM_NUM_LOCK)){
     
    334329               
    335330                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);
    338334        }
    339335       
     
    662658 *     usb_hid_parse_report().
    663659 */
    664 static void usb_kbd_process_data(usb_hid_dev_t *hid_dev,
     660static void usb_kbd_process_data(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev,
    665661                                 uint8_t *buffer, size_t actual_size)
    666662{
    667663        assert(hid_dev->report != NULL);
    668664        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);
    672666
    673667        usb_log_debug("Calling usb_hid_parse_report() with "
     
    774768/*----------------------------------------------------------------------------*/
    775769
    776 static int usb_kbd_create_function(usb_hid_dev_t *hid_dev)
     770static int usb_kbd_create_function(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
    777771{
    778772        assert(hid_dev != NULL);
    779773        assert(hid_dev->usb_dev != NULL);
     774        assert(kbd_dev != NULL);
    780775       
    781776        /* Create the function exposed under /dev/devices. */
     
    792787         * to the DDF function.
    793788         */
    794         fun->ops = &hid_dev->ops;
    795         fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
     789        fun->ops = &kbd_dev->ops;
     790        fun->driver_data = kbd_dev;
    796791
    797792        int rc = ddf_fun_bind(fun);
     
    802797                return rc;
    803798        }
     799       
     800        usb_log_debug("%s function created. Handle: %d\n", HID_KBD_FUN_NAME,
     801            fun->handle);
    804802       
    805803        usb_log_debug("Adding DDF function to class %s...\n",
     
    840838 * @return Other value inherited from function usbhid_dev_init().
    841839 */
    842 int usb_kbd_init(usb_hid_dev_t *hid_dev)
     840int usb_kbd_init(usb_hid_dev_t *hid_dev, void **data)
    843841{
    844842        usb_log_debug("Initializing HID/KBD structure...\n");
     
    865863        usb_hid_report_path_set_report_id(path, 0);
    866864       
    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);
    870867        usb_hid_report_path_free(path);
    871868       
     
    908905            kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
    909906       
    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);
    913909       
    914910        usb_log_debug("Output report size (in items): %zu\n",
     
    955951       
    956952        // 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;
    958955       
    959956        // set handler for incoming calls
    960         hid_dev->ops.default_handler = default_connection_handler;
     957        kbd_dev->ops.default_handler = default_connection_handler;
    961958       
    962959        /*
     
    983980       
    984981        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);
    986983        if (rc != EOK) {
    987984                usb_kbd_free(&kbd_dev);
     
    994991/*----------------------------------------------------------------------------*/
    995992
    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) {
     993bool 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) {
    1000997                // do not continue polling (???)
    1001998                return false;
    1002999        }
    10031000       
     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, buffer, buffer_size);
     1005        usb_kbd_process_data(hid_dev, kbd_dev, buffer, buffer_size);
    10061006       
    10071007        return true;
     
    10661066/*----------------------------------------------------------------------------*/
    10671067
    1068 void usb_kbd_deinit(usb_hid_dev_t *hid_dev)
     1068void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data)
    10691069{
    10701070        if (hid_dev == NULL) {
     
    10721072        }
    10731073       
    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;
    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;
    10811080                }
    10821081        }
Note: See TracChangeset for help on using the changeset viewer.