diff options
Diffstat (limited to 'drivers/input/key_matrix.c')
-rw-r--r-- | drivers/input/key_matrix.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/input/key_matrix.c b/drivers/input/key_matrix.c index 715e57a2af..946a186a1f 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; |