Ignore:
File:
1 edited

Legend:

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

    re0a5d4c rb7fd2a0  
    11/*
    22 * Copyright (c) 2011 Lubos Slovak
    3  * Copyright (c) 2018 Ondrej Hlavaty
    43 * All rights reserved.
    54 *
     
    186185                if (kbd_dev->client_sess == NULL) {
    187186                        kbd_dev->client_sess = sess;
    188                         usb_log_debug("%s: OK", __FUNCTION__);
     187                        usb_log_debug("%s: OK\n", __FUNCTION__);
    189188                        async_answer_0(icallid, EOK);
    190189                } else {
    191                         usb_log_error("%s: console session already set",
     190                        usb_log_error("%s: console session already set\n",
    192191                           __FUNCTION__);
    193192                        async_answer_0(icallid, ELIMIT);
     
    196195        }
    197196        default:
    198                         usb_log_error("%s: Unknown method: %d.",
     197                        usb_log_error("%s: Unknown method: %d.\n",
    199198                            __FUNCTION__, (int) method);
    200199                        async_answer_0(icallid, EINVAL);
     
    227226        /* Reset the LED data. */
    228227        memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t));
    229         usb_log_debug("Creating output report:");
     228        usb_log_debug("Creating output report:\n");
    230229
    231230        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
     
    267266        }
    268267
    269         usb_log_debug("Output report buffer: %s",
     268        usb_log_debug("Output report buffer: %s\n",
    270269            usb_debug_str_buffer(kbd_dev->output_buffer, kbd_dev->output_size,
    271270                0));
     
    277276            kbd_dev->output_buffer, kbd_dev->output_size);
    278277        if (rc != EOK) {
    279                 usb_log_warning("Failed to set kbd indicators.");
     278                usb_log_warning("Failed to set kbd indicators.\n");
    280279        }
    281280}
     
    290289void usb_kbd_push_ev(usb_kbd_t *kbd_dev, int type, unsigned key)
    291290{
    292         usb_log_debug2("Sending kbdev event %d/%d to the console", type, key);
     291        usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key);
    293292        if (kbd_dev->client_sess == NULL) {
    294293                usb_log_warning(
     
    302301                async_exchange_end(exch);
    303302        } else {
    304                 usb_log_warning("Failed to send key to console.");
     303                usb_log_warning("Failed to send key to console.\n");
    305304        }
    306305}
     
    329328 * An event is created only when key is pressed or released. Besides handling
    330329 * the events (usb_kbd_push_ev()), the auto-repeat fibril is notified about
    331  * key presses and releases (see usb_kbd_repeat_start() and
     330 * key presses and releases (see usb_kbd_repeat_start() and 
    332331 * usb_kbd_repeat_stop()).
    333332 *
    334333 * @param kbd_dev Keyboard device structure.
    335  * @param key_codes Parsed keyboard report - codes of currently pressed keys
     334 * @param key_codes Parsed keyboard report - codes of currently pressed keys 
    336335 *                  according to HID Usage Tables.
    337336 * @param count Number of key codes in report (size of the report).
     
    354353            kbd_dev->key_count);
    355354        if (i != (size_t) -1) {
    356                 usb_log_error("Detected phantom state.");
     355                usb_log_error("Detected phantom state.\n");
    357356                return;
    358357        }
     
    404403        ddf_dump_buffer(key_buffer, 512,
    405404            kbd_dev->keys_old, 4, kbd_dev->key_count, 0);
    406         usb_log_debug2("Stored keys %s.", key_buffer);
     405        usb_log_debug2("Stored keys %s.\n", key_buffer);
    407406}
    408407
     
    432431        usb_hid_report_path_t *path = usb_hid_report_path();
    433432        if (path == NULL) {
    434                 usb_log_error("Failed to create hid/kbd report path.");
     433                usb_log_error("Failed to create hid/kbd report path.\n");
    435434                return;
    436435        }
     
    439438           usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    440439        if (ret != EOK) {
    441                 usb_log_error("Failed to append to hid/kbd report path.");
     440                usb_log_error("Failed to append to hid/kbd report path.\n");
    442441                return;
    443442        }
     
    453452
    454453        while (field != NULL) {
    455                 usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)",
     454                usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n",
    456455                    field, field->value, field->usage);
    457456
     
    465464                        kbd_dev->keys[i] = 0;
    466465                }
    467                 usb_log_debug2("Saved %u. key usage %d", i, kbd_dev->keys[i]);
     466                usb_log_debug2("Saved %u. key usage %d\n", i, kbd_dev->keys[i]);
    468467
    469468                ++i;
     
    503502        usb_hid_report_path_t *path = usb_hid_report_path();
    504503        if (path == NULL) {
    505                 usb_log_error("Failed to create kbd report path.");
     504                usb_log_error("Failed to create kbd report path.\n");
    506505                usb_kbd_destroy(kbd_dev);
    507506                return ENOMEM;
     
    511510            usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    512511        if (ret != EOK) {
    513                 usb_log_error("Failed to append item to kbd report path.");
     512                usb_log_error("Failed to append item to kbd report path.\n");
    514513                usb_hid_report_path_free(path);
    515514                usb_kbd_destroy(kbd_dev);
     
    524523        usb_hid_report_path_free(path);
    525524
    526         usb_log_debug("Size of the input report: %zu", kbd_dev->key_count);
     525        usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
    527526
    528527        kbd_dev->keys = calloc(kbd_dev->key_count, sizeof(int32_t));
    529528        if (kbd_dev->keys == NULL) {
    530                 usb_log_error("Failed to allocate key buffer.");
     529                usb_log_error("Failed to allocate key buffer.\n");
    531530                usb_kbd_destroy(kbd_dev);
    532531                return ENOMEM;
     
    535534        kbd_dev->keys_old = calloc(kbd_dev->key_count, sizeof(int32_t));
    536535        if (kbd_dev->keys_old == NULL) {
    537                 usb_log_error("Failed to allocate old_key buffer.");
     536                usb_log_error("Failed to allocate old_key buffer.\n");
    538537                usb_kbd_destroy(kbd_dev);
    539538                return ENOMEM;
     
    545544            &kbd_dev->output_size, 0);
    546545        if (kbd_dev->output_buffer == NULL) {
    547                 usb_log_error("Error creating output report buffer.");
     546                usb_log_error("Error creating output report buffer.\n");
    548547                usb_kbd_destroy(kbd_dev);
    549548                return ENOMEM;
    550549        }
    551550
    552         usb_log_debug("Output buffer size: %zu", kbd_dev->output_size);
     551        usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size);
    553552
    554553        kbd_dev->led_path = usb_hid_report_path();
    555554        if (kbd_dev->led_path == NULL) {
    556                 usb_log_error("Failed to create kbd led report path.");
     555                usb_log_error("Failed to create kbd led report path.\n");
    557556                usb_kbd_destroy(kbd_dev);
    558557                return ENOMEM;
     
    562561            kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
    563562        if (ret != EOK) {
    564                 usb_log_error("Failed to append to kbd/led report path.");
     563                usb_log_error("Failed to append to kbd/led report path.\n");
    565564                usb_kbd_destroy(kbd_dev);
    566565                return ret;
     
    570569            &hid_dev->report, 0, USB_HID_REPORT_TYPE_OUTPUT);
    571570
    572         usb_log_debug("Output report size (in items): %zu",
     571        usb_log_debug("Output report size (in items): %zu\n",
    573572            kbd_dev->led_output_size);
    574573
    575574        kbd_dev->led_data = calloc(kbd_dev->led_output_size, sizeof(int32_t));
    576575        if (kbd_dev->led_data == NULL) {
    577                 usb_log_error("Error creating buffer for LED output report.");
     576                usb_log_error("Error creating buffer for LED output report.\n");
    578577                usb_kbd_destroy(kbd_dev);
    579578                return ENOMEM;
     
    589588
    590589        kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED;
    591         usb_log_debug("HID/KBD device structure initialized.");
     590        usb_log_debug("HID/KBD device structure initialized.\n");
    592591
    593592        return EOK;
     
    619618errno_t usb_kbd_init(usb_hid_dev_t *hid_dev, void **data)
    620619{
    621         usb_log_debug("Initializing HID/KBD structure...");
     620        usb_log_debug("Initializing HID/KBD structure...\n");
    622621
    623622        if (hid_dev == NULL) {
     
    628627
    629628        /* Create the exposed function. */
    630         usb_log_debug("Creating DDF function %s...", HID_KBD_FUN_NAME);
     629        usb_log_debug("Creating DDF function %s...\n", HID_KBD_FUN_NAME);
    631630        ddf_fun_t *fun = usb_device_ddf_fun_create(hid_dev->usb_dev,
    632631            fun_exposed, HID_KBD_FUN_NAME);
    633632        if (fun == NULL) {
    634                 usb_log_error("Could not create DDF function node.");
     633                usb_log_error("Could not create DDF function node.\n");
    635634                return ENOMEM;
    636635        }
     
    638637        usb_kbd_t *kbd_dev = ddf_fun_data_alloc(fun, sizeof(usb_kbd_t));
    639638        if (kbd_dev == NULL) {
    640                 usb_log_error("Failed to allocate KBD device structure.");
     639                usb_log_error("Failed to allocate KBD device structure.\n");
    641640                ddf_fun_destroy(fun);
    642641                return ENOMEM;
     
    645644        errno_t ret = kbd_dev_init(kbd_dev, hid_dev);
    646645        if (ret != EOK) {
    647                 usb_log_error("Failed to initialize KBD device  structure.");
     646                usb_log_error("Failed to initialize KBD device  structure.\n");
    648647                ddf_fun_destroy(fun);
    649648                return ret;
     
    656655        ret = ddf_fun_bind(fun);
    657656        if (ret != EOK) {
    658                 usb_log_error("Could not bind DDF function: %s.",
     657                usb_log_error("Could not bind DDF function: %s.\n",
    659658                    str_error(ret));
    660659                usb_kbd_destroy(kbd_dev);
     
    663662        }
    664663
    665         usb_log_debug("%s function created. Handle: %" PRIun "",
     664        usb_log_debug("%s function created. Handle: %" PRIun "\n",
    666665            HID_KBD_FUN_NAME, ddf_fun_get_handle(fun));
    667666
    668         usb_log_debug("Adding DDF function to category %s...",
     667        usb_log_debug("Adding DDF function to category %s...\n",
    669668            HID_KBD_CATEGORY_NAME);
    670669        ret = ddf_fun_add_to_category(fun, HID_KBD_CATEGORY_NAME);
     
    710709        usb_kbd_process_data(hid_dev, kbd_dev);
    711710
    712         /* Continue polling until the device is about to be removed. */
    713711        return true;
    714712}
     
    754752        if (kbd_dev->fun) {
    755753                if (ddf_fun_unbind(kbd_dev->fun) != EOK) {
    756                         usb_log_warning("Failed to unbind %s.",
     754                        usb_log_warning("Failed to unbind %s.\n",
    757755                            ddf_fun_get_name(kbd_dev->fun));
    758756                } else {
    759                         usb_log_debug2("%s unbound.",
     757                        usb_log_debug2("%s unbound.\n",
    760758                            ddf_fun_get_name(kbd_dev->fun));
    761759                        ddf_fun_destroy(kbd_dev->fun);
     
    785783
    786784        if (rc != EOK) {
    787                 usb_log_error("Failed to parse boot report descriptor: %s",
     785                usb_log_error("Failed to parse boot report descriptor: %s\n",
    788786                    str_error(rc));
    789787                return rc;
Note: See TracChangeset for help on using the changeset viewer.