diff options
author | Yulay Rakhmangulov <yulayr@gmail.com> | 2010-12-08 00:28:02 -0800 |
---|---|---|
committer | Kristoffer Ericson <kristoffer.ericson@gmail.com> | 2011-12-10 15:47:25 +0100 |
commit | 8b6ad5f841bcfc5c461d04f9ef69699e76d84b62 (patch) | |
tree | a7b233cdc3ad041362dbd479b09cd872ebb3b548 | |
parent | ad18db3db615f37d1d8a1da8feec68be9ddf8cfe (diff) | |
download | linux-hpc-8b6ad5f841bcfc5c461d04f9ef69699e76d84b62.tar.gz |
ARM: Nec MobilePro900/c: Keyboard driver - fix for missing key presses
ARM: Nec MobilePro900/c: Keyboard driver - fix for missing key presses
Scan more often to prevent key press loss. Also simple code refactoring.
Signed-off-by: Yulay Rakhmangulov <yulayr@gmail.com>
Signed-off-by: Kristoffer Ericson <kristoffer.ericson@gmail.com>
-rw-r--r-- | drivers/input/keyboard/mp900_kbd.c | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/drivers/input/keyboard/mp900_kbd.c b/drivers/input/keyboard/mp900_kbd.c index 1feed4b653779a..0f5a8d66500713 100644 --- a/drivers/input/keyboard/mp900_kbd.c +++ b/drivers/input/keyboard/mp900_kbd.c @@ -26,7 +26,7 @@ /* We want to scan keyboard for changes each 100 mS * Note: scan happens only if at least one key is down */ -#define NEXT_KEYBOARD_SCAN_DELAY (msecs_to_jiffies(100)) +#define NEXT_KEYBOARD_SCAN_DELAY (msecs_to_jiffies(50)) static struct input_dev *dev_kb; @@ -172,16 +172,15 @@ static inline unsigned int get_key_code(unsigned char scan_code) * * takes 13 bytes buffer of key bit mask * and determines keyboard state, reports that to input layer - * check if all keys are released + * check if all keys released * */ static void keyboard_update(const unsigned char *buf) { int i, j; - unsigned char mask, keys_mask; + unsigned char mask, bits_changed; int keycount = 0; - unsigned char changed_keys[16]; - unsigned int key_code; + unsigned int scan_code, key_code; int hotkey_handled; static unsigned char last_buffer[KBD_SCAN_BITMASK_SIZE] = { @@ -191,41 +190,35 @@ static void keyboard_update(const unsigned char *buf) /* gather keys with changed state */ for (i = 0, mask = 0xff; i < KBD_SCAN_BITMASK_SIZE; ++i) { mask &= buf[i]; - keys_mask = buf[i] ^ last_buffer[i]; + bits_changed = buf[i] ^ last_buffer[i]; - for (j = 0; keys_mask && keycount < 16; ++j) { - if (keys_mask & 1) { /* key state has changed */ - changed_keys[keycount] = j * 16 + i; + if (bits_changed == 0) + continue; - if (!((1<<j) & buf[i])) /* if key down */ - changed_keys[keycount] |= 0x80; + for (j = 0; j < 8; ++j) { + if ((bits_changed & (1 << j)) == 0) + continue; + + scan_code = j * 16 + i; - ++keycount; + key_code = get_key_code(scan_code); + + hotkey_handled = 0; + if (keyboard_ops.notify_hot_key) + hotkey_handled = keyboard_ops.notify_hot_key(key_code, j); + + if (hotkey_handled == 0) { + input_event(dev_kb, EV_MSC, MSC_SCAN, scan_code); + input_report_key(dev_kb, key_code, !(buf[i] & (1 << j))); + input_sync(dev_kb); } - keys_mask >>= 1; + ++keycount; } } if (keycount) /* update keys state */ memcpy(last_buffer, buf, KBD_SCAN_BITMASK_SIZE); - for (i = 0; i < keycount; ++i) { - j = changed_keys[i] >> 7; /* is key down or up ? */ - changed_keys[i] &= 0x7f; /* remove value flag */ - - key_code = get_key_code(changed_keys[i]); - - hotkey_handled = 0; - if (keyboard_ops.notify_hot_key) - hotkey_handled = keyboard_ops.notify_hot_key(key_code, j); - - if (!hotkey_handled) { - input_event(dev_kb, EV_MSC, MSC_SCAN, changed_keys[i]); - input_report_key(dev_kb, key_code, j); - input_sync(dev_kb); - } - } - if (0xff == mask) /* stop scanning if all keys released */ keydown = 0; |