Ignore:
Timestamp:
2011-10-14T12:40:31Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e5024111
Parents:
3002434
Message:

usbhid: Remove tabs on empty lines. diff -w shows no changes.

File:
1 edited

Legend:

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

    r3002434 rcc29622  
    174174{
    175175        sysarg_t method = IPC_GET_IMETHOD(*icall);
    176        
     176
    177177        usb_kbd_t *kbd_dev = (usb_kbd_t *) fun->driver_data;
    178178        if (kbd_dev == NULL) {
     
    182182                return;
    183183        }
    184        
     184
    185185        async_sess_t *sess =
    186186            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
     
    240240            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    241241            USB_HID_REPORT_TYPE_OUTPUT);
    242        
     242
    243243        while (field != NULL) {
    244244               
     
    263263                        USB_HID_REPORT_TYPE_OUTPUT);
    264264        }
    265        
     265
    266266        // TODO: what about the Report ID?
    267267        int rc = usb_hid_report_output_translate(hid_dev->report, 0,
    268268            kbd_dev->output_buffer, kbd_dev->output_size);
    269        
     269
    270270        if (rc != EOK) {
    271271                usb_log_warning("Error translating LED output to output report"
     
    273273                return;
    274274        }
    275        
     275
    276276        usb_log_debug("Output report buffer: %s\n",
    277277            usb_debug_str_buffer(kbd_dev->output_buffer, kbd_dev->output_size,
    278278                0));
    279        
     279
    280280        usbhid_req_set_report(&hid_dev->usb_dev->ctrl_pipe,
    281281            hid_dev->usb_dev->interface_no, USB_HID_REPORT_TYPE_OUTPUT,
     
    300300                return;
    301301        }
    302        
     302
    303303        async_exch_t *exch = async_exchange_begin(kbd_dev->console_sess);
    304304        async_msg_2(exch, KBDEV_EVENT, type, key);
     
    347347        unsigned int key;
    348348        size_t i;
    349        
     349
    350350        /*
    351351         * First of all, check if the kbd have reported phantom state.
     
    362362                return;
    363363        }
    364        
     364
    365365        /*
    366366         * Key releases
     
    382382                }
    383383        }
    384        
     384
    385385        /*
    386386         * Key presses
     
    402402                }
    403403        }
    404        
     404
    405405        memcpy(kbd_dev->keys_old, kbd_dev->keys, kbd_dev->key_count * 4);
    406        
     406
    407407        char key_buffer[512];
    408408        ddf_dump_buffer(key_buffer, 512,
     
    435435        assert(hid_dev != NULL);
    436436        assert(kbd_dev != NULL);
    437        
     437
    438438        usb_hid_report_path_t *path = usb_hid_report_path();
    439439        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    440440
    441441        usb_hid_report_path_set_report_id (path, hid_dev->report_id);
    442        
     442
    443443        // fill in the currently pressed keys
    444        
     444
    445445        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    446446            hid_dev->report, NULL, path,
     
    448448            USB_HID_REPORT_TYPE_INPUT);
    449449        unsigned i = 0;
    450        
     450
    451451        while (field != NULL) {
    452452                usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n",
     
    470470                    USB_HID_REPORT_TYPE_INPUT);
    471471        }
    472        
     472
    473473        usb_hid_report_path_free(path);
    474        
     474
    475475        usb_kbd_check_key_changes(hid_dev, kbd_dev);
    476476}
     
    505505                return NULL;
    506506        }
    507        
     507
    508508        kbd_dev->console_sess = NULL;
    509509        kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
    510        
     510
    511511        return kbd_dev;
    512512}
     
    519519        assert(hid_dev->usb_dev != NULL);
    520520        assert(kbd_dev != NULL);
    521        
     521
    522522        /* Create the exposed function. */
    523523        usb_log_debug("Creating DDF function %s...\n", HID_KBD_FUN_NAME);
     
    528528                return ENOMEM;
    529529        }
    530        
     530
    531531        /*
    532532         * Store the initialized HID device and HID ops
     
    543543                return rc;
    544544        }
    545        
     545
    546546        usb_log_debug("%s function created. Handle: %" PRIun "\n",
    547547            HID_KBD_FUN_NAME, fun->handle);
    548        
     548
    549549        usb_log_debug("Adding DDF function to category %s...\n",
    550550            HID_KBD_CLASS_NAME);
     
    557557                return rc;
    558558        }
    559        
     559
    560560        return EOK;
    561561}
     
    587587{
    588588        usb_log_debug("Initializing HID/KBD structure...\n");
    589        
     589
    590590        if (hid_dev == NULL) {
    591591                usb_log_error("Failed to init keyboard structure: no structure"
     
    593593                return EINVAL;
    594594        }
    595        
     595
    596596        usb_kbd_t *kbd_dev = usb_kbd_new();
    597597        if (kbd_dev == NULL) {
     
    603603        /* Store link to HID device */
    604604        kbd_dev->hid_dev = hid_dev;
    605        
     605
    606606        /*
    607607         * TODO: make more general
     
    609609        usb_hid_report_path_t *path = usb_hid_report_path();
    610610        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    611        
     611
    612612        usb_hid_report_path_set_report_id(path, 0);
    613        
     613
    614614        kbd_dev->key_count = usb_hid_report_size(
    615615            hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT);
    616616        usb_hid_report_path_free(path);
    617        
     617
    618618        usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
    619        
     619
    620620        kbd_dev->keys = (int32_t *)calloc(kbd_dev->key_count, sizeof(int32_t));
    621        
     621
    622622        if (kbd_dev->keys == NULL) {
    623623                usb_log_fatal("No memory!\n");
     
    625625                return ENOMEM;
    626626        }
    627        
     627
    628628        kbd_dev->keys_old =
    629629                (int32_t *)calloc(kbd_dev->key_count, sizeof(int32_t));
    630        
     630
    631631        if (kbd_dev->keys_old == NULL) {
    632632                usb_log_fatal("No memory!\n");
     
    635635                return ENOMEM;
    636636        }
    637        
     637
    638638        /*
    639639         * Output report
     
    647647                return ENOMEM;
    648648        }
    649        
     649
    650650        usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size);
    651        
     651
    652652        kbd_dev->led_path = usb_hid_report_path();
    653653        usb_hid_report_path_append_item(
    654654            kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
    655        
     655
    656656        kbd_dev->led_output_size = usb_hid_report_size(hid_dev->report,
    657657            0, USB_HID_REPORT_TYPE_OUTPUT);
    658        
     658
    659659        usb_log_debug("Output report size (in items): %zu\n",
    660660            kbd_dev->led_output_size);
    661        
     661
    662662        kbd_dev->led_data = (int32_t *)calloc(
    663663            kbd_dev->led_output_size, sizeof(int32_t));
    664        
     664
    665665        if (kbd_dev->led_data == NULL) {
    666666                usb_log_warning("Error creating buffer for LED output report."
     
    671671                return ENOMEM;
    672672        }
    673        
     673
    674674        /*
    675675         * Modifiers and locks
     
    678678        kbd_dev->mods = DEFAULT_ACTIVE_MODS;
    679679        kbd_dev->lock_keys = 0;
    680        
     680
    681681        /*
    682682         * Autorepeat
     
    686686        kbd_dev->repeat.delay_before = DEFAULT_DELAY_BEFORE_FIRST_REPEAT;
    687687        kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY;
    688        
     688
    689689        kbd_dev->repeat_mtx = (fibril_mutex_t *)(
    690690            malloc(sizeof(fibril_mutex_t)));
     
    696696                return ENOMEM;
    697697        }
    698        
     698
    699699        fibril_mutex_initialize(kbd_dev->repeat_mtx);
    700        
     700
    701701        // save the KBD device structure into the HID device structure
    702702        *data = kbd_dev;
    703        
     703
    704704        // set handler for incoming calls
    705705        kbd_dev->ops.default_handler = default_connection_handler;
    706        
     706
    707707        /*
    708708         * Set LEDs according to initial setup.
     
    710710         */
    711711        usb_kbd_set_led(hid_dev, kbd_dev);
    712        
     712
    713713        usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe,
    714714            hid_dev->usb_dev->interface_no, IDLE_RATE);
    715        
     715
    716716        /*
    717717         * Create new fibril for auto-repeat
     
    723723        }
    724724        fibril_add_ready(fid);
    725        
     725
    726726        kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED;
    727727        usb_log_debug("HID/KBD device structure initialized.\n");
    728        
     728
    729729        usb_log_debug("Creating KBD function...\n");
    730730        int rc = usb_kbd_create_function(hid_dev, kbd_dev);
     
    733733                return rc;
    734734        }
    735        
     735
    736736        return EOK;
    737737}
     
    745745                return false;
    746746        }
    747        
     747
    748748        usb_kbd_t *kbd_dev = (usb_kbd_t *)data;
    749749        assert(kbd_dev != NULL);
    750        
     750
    751751        // TODO: add return value from this function
    752752        usb_kbd_process_data(hid_dev, kbd_dev);
    753        
     753
    754754        return true;
    755755}
     
    780780                return;
    781781        }
    782        
     782
    783783        // hangup session to the console
    784784        async_hangup(kbd_dev->console_sess);
    785        
     785
    786786        if (kbd_dev->repeat_mtx != NULL) {
    787787                //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
     
    791791                free(kbd_dev->repeat_mtx);
    792792        }
    793        
     793
    794794        // free all buffers
    795795        if (kbd_dev->keys != NULL) {
     
    817817                return;
    818818        }
    819        
     819
    820820        if (data != NULL) {
    821821                usb_kbd_t *kbd_dev = (usb_kbd_t *)data;
     
    835835            USB_KBD_BOOT_REPORT_DESCRIPTOR,
    836836            USB_KBD_BOOT_REPORT_DESCRIPTOR_SIZE);
    837        
     837
    838838        if (rc != EOK) {
    839839                usb_log_error("Failed to parse boot report descriptor: %s\n",
     
    841841                return rc;
    842842        }
    843        
     843
    844844        rc = usbhid_req_set_protocol(&hid_dev->usb_dev->ctrl_pipe,
    845845            hid_dev->usb_dev->interface_no, USB_HID_PROTOCOL_BOOT);
    846        
     846
    847847        if (rc != EOK) {
    848848                usb_log_warning("Failed to set boot protocol to the device: "
     
    850850                return rc;
    851851        }
    852        
     852
    853853        return EOK;
    854854}
Note: See TracChangeset for help on using the changeset viewer.