Ignore:
Timestamp:
2012-08-14T18:16:39Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
669f5cae
Parents:
76d92db1 (diff), 4802dd7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    r76d92db1 rcddcc4a3  
    7171#include "../usbhid.h"
    7272
    73 /*----------------------------------------------------------------------------*/
     73static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
     74static ddf_dev_ops_t kbdops = { .default_handler = default_connection_handler };
     75
    7476
    7577static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK;
     
    8688static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000;
    8789
    88 /*----------------------------------------------------------------------------*/
     90
    8991/** Keyboard polling endpoint description for boot protocol class. */
    9092const usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description = {
     
    101103
    102104static void usb_kbd_set_led(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev);
    103 /*----------------------------------------------------------------------------*/
     105
    104106static const uint8_t USB_KBD_BOOT_REPORT_DESCRIPTOR[] = {
    105107        0x05, 0x01,  /* Usage Page (Generic Desktop), */
     
    136138        0xC0         /* End Collection */
    137139};
    138 /*----------------------------------------------------------------------------*/
     140
    139141typedef enum usb_kbd_flags {
    140142        USB_KBD_STATUS_UNINITIALIZED = 0,
     
    142144        USB_KBD_STATUS_TO_DESTROY = -1
    143145} usb_kbd_flags;
    144 /*----------------------------------------------------------------------------*/
     146
    145147/* IPC method handler                                                         */
    146 /*----------------------------------------------------------------------------*/
     148
    147149/**
    148150 * Default handler for IPC methods not handled by DDF.
     
    187189                        break;
    188190                }
    189                 if (kbd_dev->console_sess == NULL) {
    190                         kbd_dev->console_sess = sess;
     191                if (kbd_dev->client_sess == NULL) {
     192                        kbd_dev->client_sess = sess;
    191193                        usb_log_debug("%s: OK\n", __FUNCTION__);
    192194                        async_answer_0(icallid, EOK);
     
    206208
    207209}
    208 /*----------------------------------------------------------------------------*/
     210
    209211/* Key processing functions                                                   */
    210 /*----------------------------------------------------------------------------*/
     212
    211213/**
    212214 * Handles turning of LED lights on and off.
     
    281283        }
    282284}
    283 /*----------------------------------------------------------------------------*/
     285
    284286/** Send key event.
    285287 *
     
    292294{
    293295        usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key);
    294         if (kbd_dev->console_sess == NULL) {
     296        if (kbd_dev->client_sess == NULL) {
    295297                usb_log_warning(
    296298                    "Connection to console not ready, key discarded.\n");
     
    298300        }
    299301
    300         async_exch_t *exch = async_exchange_begin(kbd_dev->console_sess);
     302        async_exch_t *exch = async_exchange_begin(kbd_dev->client_sess);
    301303        if (exch != NULL) {
    302304                async_msg_2(exch, KBDEV_EVENT, type, key);
     
    306308        }
    307309}
    308 /*----------------------------------------------------------------------------*/
     310
    309311static inline int usb_kbd_is_lock(unsigned int key_code)
    310312{
     
    313315            || key_code == KC_CAPS_LOCK);
    314316}
    315 /*----------------------------------------------------------------------------*/
     317
    316318static size_t find_in_array_int32(int32_t val, int32_t *arr, size_t arr_size)
    317319{
     
    324326        return (size_t) -1;
    325327}
    326 /*----------------------------------------------------------------------------*/
     328
    327329/**
    328330 * Checks if some keys were pressed or released and generates key events.
     
    407409        usb_log_debug2("Stored keys %s.\n", key_buffer);
    408410}
    409 /*----------------------------------------------------------------------------*/
     411
    410412/* General kbd functions                                                      */
    411 /*----------------------------------------------------------------------------*/
     413
    412414/**
    413415 * Processes data received from the device in form of report.
     
    479481        usb_kbd_check_key_changes(hid_dev, kbd_dev);
    480482}
    481 /*----------------------------------------------------------------------------*/
     483
    482484/* HID/KBD structure manipulation                                             */
    483 /*----------------------------------------------------------------------------*/
     485
    484486static int usb_kbd_create_function(usb_kbd_t *kbd_dev)
    485487{
     
    499501        /* Store the initialized HID device and HID ops
    500502         * to the DDF function. */
    501         fun->ops = &kbd_dev->ops;
     503        fun->ops = &kbdops;
    502504        fun->driver_data = kbd_dev;
    503505
     
    535537        return EOK;
    536538}
    537 /*----------------------------------------------------------------------------*/
     539
    538540/* API functions                                                              */
    539 /*----------------------------------------------------------------------------*/
     541
    540542/**
    541543 * Initialization of the USB/HID keyboard structure.
     
    576578        fibril_mutex_initialize(&kbd_dev->repeat_mtx);
    577579        kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
    578         kbd_dev->ops.default_handler = default_connection_handler;
    579580
    580581        /* Store link to HID device */
     
    700701        return EOK;
    701702}
    702 /*----------------------------------------------------------------------------*/
     703
    703704bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, void *data)
    704705{
     
    714715        return true;
    715716}
    716 /*----------------------------------------------------------------------------*/
     717
    717718int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev)
    718719{
    719720        return (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED);
    720721}
    721 /*----------------------------------------------------------------------------*/
     722
    722723int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev)
    723724{
    724725        return (kbd_dev->initialized == USB_KBD_STATUS_TO_DESTROY);
    725726}
    726 /*----------------------------------------------------------------------------*/
     727
    727728/**
    728729 * Properly destroys the USB/HID keyboard structure.
     
    737738
    738739        /* Hangup session to the console. */
    739         if (kbd_dev->console_sess)
    740                 async_hangup(kbd_dev->console_sess);
     740        if (kbd_dev->client_sess)
     741                async_hangup(kbd_dev->client_sess);
    741742
    742743        //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));
     
    765766        free(kbd_dev);
    766767}
    767 /*----------------------------------------------------------------------------*/
     768
    768769void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data)
    769770{
     
    778779        }
    779780}
    780 /*----------------------------------------------------------------------------*/
     781
    781782int usb_kbd_set_boot_protocol(usb_hid_dev_t *hid_dev)
    782783{
Note: See TracChangeset for help on using the changeset viewer.