Example #1
0
static void keyboard_early_suspend(struct early_suspend *early_sus)
{
    //caps lock led off
    dock_keyboard_tx(0xcb);
    msleep(100);
    dock_keyboard_tx(0x10);
}
Example #2
0
static int dock_keyboard_suspend(struct platform_device *pdev, pm_message_t state)
{
    //caps lock led off
    dock_keyboard_tx(0xcb);
    msleep(100);
    dock_keyboard_tx(0x10);
    return 0;
}
static void led_work(struct work_struct *work)
{
    struct dock_keyboard_data *data = container_of(work,
                struct dock_keyboard_data, work_led);

    if(data->led_on)
    {
        //caps lock led on
        dock_keyboard_tx(0xca);
        msleep(100);
        dock_keyboard_tx(0xca);
    }
    else
    {
        //caps lock led off
        dock_keyboard_tx(0xcb);
        msleep(100);
        dock_keyboard_tx(0xcb);
    }
}
static void key_event_work(struct work_struct *work)
{
    bool press;
    static int release_cnt = 0;
    unsigned int keycode;
    unsigned char scan_code;
    struct dock_keyboard_data *data = container_of(work,
                struct dock_keyboard_data, work_msg);

    while(buf_front != buf_rear)
    {
        buf_front = (1+buf_front)%MAX_BUF;
        scan_code = key_buf[buf_front];

        /* keyboard driver need the contry code*/
        if(data->kl == UNKOWN_KEYLAYOUT)
        {
            switch(scan_code)
            {
                case US_KEYBOARD:
                    data->kl = US_KEYLAYOUT;
                    dock_keycodes[49].keycode = KEY_BACKSLASH;
                    /* for the wakeup state*/
                    pre_kl = data->kl;
                    printk(KERN_DEBUG "[Keyboard] US keyboard is attacted.\n");
                    break;

                case UK_KEYBOARD:
                    data->kl = UK_KEYLAYOUT;
                    dock_keycodes[49].keycode = KEY_NUMERIC_POUND;
                    /* for the wakeup state*/
                    pre_kl = data->kl;
                    printk(KERN_DEBUG "[Keyboard] UK keyboard is attacted.\n");
                    break;

                default:
                    printk(KERN_DEBUG "[Keyboard] Unkown key layout : %x\n", scan_code);
                    break;
            }
        }
        else
        {
            /* Do not send the key_event durring the handshake time */
            if(handshaking)
            {
                /* Caps lock led on/off */
                if(scan_code == 0xca || scan_code == 0xcb)
                {
                    // Ignore
                    //dock_keyboard_tx(scan_code);
                }
                else if(scan_code == 0x0)
                {
                    release_all_keys();
                    release_cnt = 16;
                }
                else
                {
                    press = ((scan_code & 0x80) != 0x80);
                    keycode = (scan_code & 0x7f);

                    if(keycode >= KEYBOARD_MIN || keycode <= KEYBOARD_MAX)
                    {
                        if(press)
                        {
                            // workaround keyboard issue
                            if(dock_keycodes[keycode].pressed)
                            {
                                input_report_key(data->input_dev, dock_keycodes[keycode].keycode, 0);
                                msleep(1);
                            }
                            dock_keycodes[keycode].pressed = true;
                            printk(KERN_DEBUG "[Keyboard] %d key is pressed.\n", dock_keycodes[keycode].keycode);
                        }
                        else
                        {
                            dock_keycodes[keycode].pressed = false;
                            printk(KERN_DEBUG "[Keyboard] %d key is released.\n", dock_keycodes[keycode].keycode);
                        }

                        /* for the remap keys*/
                        if(keycode == 0x45 || keycode == 0x48)
                        {
                            if(press)
                            {
                                data->key_timer.data = (unsigned long) keycode;
                                mod_timer(&data->key_timer, jiffies + HZ/3);
                            }
                            else
                            {
                                if(remap_state == REMAPKEY_PRESSED)
                                {
                                    remap_state = REMAPKEY_RELEASED;
                                    input_report_key(data->input_dev, dock_keycodes[keycode].keycode, press);
                                    input_sync(data->input_dev);
                                }
                            }
                        }
                        else
                        {
                            input_report_key(data->input_dev, dock_keycodes[keycode].keycode, press);
                            input_sync(data->input_dev);
                        }
                    }
/* This is not working */
#if 0
                    else
                    {
                        /* request last scancode again*/
                        dock_keyboard_tx(0xaa);
                        printk(KERN_DEBUG "[Keyboard] wrong key_code : 0x%x\n", scan_code);
                    }
#endif
                    if(release_cnt >0)
                    {
                        if(press)
                        {
                            input_report_key(data->input_dev, dock_keycodes[keycode].keycode, 0);
                            printk(KERN_DEBUG "[Keyboard] forced release %d key.\n", dock_keycodes[keycode].keycode);
                        }
                        release_cnt--;
                    }
                }
            }
            else
            {
                /* device don't send the key_event durring the handshaking */
                if((jiffies_to_msecs(jiffies) - connected_time) >= 500)
                {
                    handshaking =true;
                }
            }
        }
    }

}
static int dock_keyboard_suspend(struct platform_device *pdev, pm_message_t state)
{
    suspend = true;
    dock_keyboard_tx(0x10);
    return 0;
}