diff options
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/input.c | 13 | ||||
-rw-r--r-- | drivers/input/key_matrix.c | 22 | ||||
-rw-r--r-- | drivers/input/tegra-kbc.c | 9 |
3 files changed, 30 insertions, 14 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index 4eadd773b4f..5b2b4b0714d 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -356,7 +356,8 @@ int input_send_keycodes(struct input_config *config, * insert another character if we later realise that we * have missed a repeat slot. */ - is_repeat = (int)get_timer(config->next_repeat_ms) >= 0; + is_repeat = config->repeat_rate_ms && + (int)get_timer(config->next_repeat_ms) >= 0; if (!is_repeat) return 0; } @@ -392,13 +393,17 @@ int input_add_table(struct input_config *config, int left_keycode, return 0; } -int input_init(struct input_config *config, int leds, int repeat_delay_ms, +void input_set_delays(struct input_config *config, int repeat_delay_ms, int repeat_rate_ms) { - memset(config, '\0', sizeof(*config)); - config->leds = leds; config->repeat_delay_ms = repeat_delay_ms; config->repeat_rate_ms = repeat_rate_ms; +} + +int input_init(struct input_config *config, int leds) +{ + memset(config, '\0', sizeof(*config)); + config->leds = leds; if (input_add_table(config, -1, -1, kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate)) || input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT, diff --git a/drivers/input/key_matrix.c b/drivers/input/key_matrix.c index 715e57a2af3..946a186a1ff 100644 --- a/drivers/input/key_matrix.c +++ b/drivers/input/key_matrix.c @@ -46,6 +46,9 @@ static int has_ghosting(struct key_matrix *config, struct key_matrix_key *keys, int key_in_same_col = 0, key_in_same_row = 0; int i, j; + if (!config->ghost_filter || valid < 3) + return 0; + for (i = 0; i < valid; i++) { /* * Find 2 keys such that one key is in the same row @@ -92,7 +95,7 @@ int key_matrix_decode(struct key_matrix *config, struct key_matrix_key keys[], } /* For a ghost key config, ignore the keypresses for this iteration. */ - if (valid >= 3 && has_ghosting(config, keys, valid)) { + if (has_ghosting(config, keys, valid)) { valid = 0; debug(" ghosting detected!\n"); } @@ -142,6 +145,8 @@ static uchar *create_keymap(struct key_matrix *config, u32 *data, int len, key_code = tmp & 0xffff; entry = row * config->num_cols + col; map[entry] = key_code; + debug(" map %d, %d: pos=%d, keycode=%d\n", row, col, + entry, key_code); if (pos && map_keycode == key_code) *pos = entry; } @@ -153,6 +158,8 @@ int key_matrix_decode_fdt(struct key_matrix *config, const void *blob, int node) { const struct fdt_property *prop; + const char prefix[] = "linux,"; + int plen = sizeof(prefix) - 1; int offset; /* Check each property name for ones that we understand */ @@ -168,16 +175,17 @@ int key_matrix_decode_fdt(struct key_matrix *config, const void *blob, /* Name needs to match "1,<type>keymap" */ debug("%s: property '%s'\n", __func__, name); - if (strncmp(name, "1,", 2) || len < 8 || - strcmp(name + len - 6, "keymap")) + if (strncmp(name, prefix, plen) || + len < plen + 6 || + strcmp(name + len - 6, "keymap")) continue; - len -= 8; + len -= plen + 6; if (len == 0) { config->plain_keycode = create_keymap(config, (u32 *)prop->data, fdt32_to_cpu(prop->len), KEY_FN, &config->fn_pos); - } else if (0 == strncmp(name + 2, "fn-", len)) { + } else if (0 == strncmp(name + plen, "fn-", len)) { config->fn_keycode = create_keymap(config, (u32 *)prop->data, fdt32_to_cpu(prop->len), -1, NULL); @@ -197,12 +205,14 @@ int key_matrix_decode_fdt(struct key_matrix *config, const void *blob, return 0; } -int key_matrix_init(struct key_matrix *config, int rows, int cols) +int key_matrix_init(struct key_matrix *config, int rows, int cols, + int ghost_filter) { memset(config, '\0', sizeof(*config)); config->num_rows = rows; config->num_cols = cols; config->key_count = rows * cols; + config->ghost_filter = ghost_filter; assert(config->key_count > 0); return 0; diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c index f164791bee6..ab7a9e33ee0 100644 --- a/drivers/input/tegra-kbc.c +++ b/drivers/input/tegra-kbc.c @@ -30,7 +30,7 @@ #include <asm/io.h> #include <asm/arch/clock.h> #include <asm/arch/funcmux.h> -#include <asm/arch/timer.h> +#include <asm/arch-tegra/timer.h> #include <linux/input.h> DECLARE_GLOBAL_DATA_PTR; @@ -321,9 +321,11 @@ static int init_tegra_keyboard(void) debug("%s: No keyboard register found\n", __func__); return -1; } + input_set_delays(&config.input, KBC_REPEAT_DELAY_MS, + KBC_REPEAT_RATE_MS); /* Decode the keyboard matrix information (16 rows, 8 columns) */ - if (key_matrix_init(&config.matrix, 16, 8)) { + if (key_matrix_init(&config.matrix, 16, 8, 1)) { debug("%s: Could not init key matrix\n", __func__); return -1; } @@ -356,8 +358,7 @@ int drv_keyboard_init(void) { struct stdio_dev dev; - if (input_init(&config.input, 0, KBC_REPEAT_DELAY_MS, - KBC_REPEAT_RATE_MS)) { + if (input_init(&config.input, 0)) { debug("%s: Cannot set up input\n", __func__); return -1; } |