diff options
-rw-r--r-- | common/fdt_decode.c | 3 | ||||
-rwxr-xr-x | drivers/input/tegra-kbc.c | 17 | ||||
-rw-r--r-- | include/fdt_decode.h | 2 | ||||
-rwxr-xr-x | include/tegra-kbc.h | 11 |
4 files changed, 28 insertions, 5 deletions
diff --git a/common/fdt_decode.c b/common/fdt_decode.c index 6a98e0c7515..12f4f00805e 100644 --- a/common/fdt_decode.c +++ b/common/fdt_decode.c @@ -590,5 +590,8 @@ int fdt_decode_kbc(const void *blob, int node, struct fdt_kbc *config) if (!err) err = get_byte_array(blob, node, "keycode-fn", config->fn_keycode, FDT_KBC_KEY_COUNT); + if (!err) + err = get_byte_array(blob, node, "keycode-ctrl", + config->ctrl_keycode, FDT_KBC_KEY_COUNT); return err; } diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c index db5bc289728..9a2740c3afb 100755 --- a/drivers/input/tegra-kbc.c +++ b/drivers/input/tegra-kbc.c @@ -68,6 +68,7 @@ int kbc_last_keypress; u8 *kbc_plain_keycode; u8 *kbc_fn_keycode; u8 *kbc_shift_keycode; +u8 *kbc_ctrl_keycode; #ifdef CONFIG_OF_CONTROL struct fdt_kbc config; /* Our keyboard config */ @@ -75,12 +76,19 @@ struct fdt_kbc config; /* Our keyboard config */ static int tegra_kbc_keycode(int r, int c, int modifier) { + int entry = r * KBC_MAX_COL + c; + if (modifier == KEY_FN) - return kbc_fn_keycode[(r * KBC_MAX_COL) + c]; + return kbc_fn_keycode[entry]; + + /* Put ctrl keys ahead of shift */ + else if ((modifier == KEY_LEFT_CTRL || modifier == KEY_RIGHT_CTRL) + && kbc_ctrl_keycode) + return kbc_ctrl_keycode[entry]; else if (modifier == KEY_SHIFT) - return kbc_shift_keycode[(r * KBC_MAX_COL) + c]; + return kbc_shift_keycode[entry]; else - return kbc_plain_keycode[(r * KBC_MAX_COL) + c]; + return kbc_plain_keycode[entry]; } /* determines if current keypress configuration can cause key ghosting */ @@ -139,7 +147,7 @@ static int tegra_kbc_find_keys(int *fifo) } for (i = 0; i < valid; i++) { k = tegra_kbc_keycode(rows_val[i], cols_val[i], 0); - if ((k == KEY_FN) || (k == KEY_SHIFT)) { + if (KEY_IS_MODIFIER(k)) { modifier = k; break; } @@ -418,6 +426,7 @@ int drv_keyboard_init(void) kbc_plain_keycode = config.plain_keycode; kbc_shift_keycode = config.shift_keycode; kbc_fn_keycode = config.fn_keycode; + kbc_ctrl_keycode = config.ctrl_keycode; #else kbc_plain_keycode = board_keyboard_config.plain_keycode; kbc_shift_keycode = board_keyboard_config.shift_keycode; diff --git a/include/fdt_decode.h b/include/fdt_decode.h index c4b78d73ffc..7089778e5d3 100644 --- a/include/fdt_decode.h +++ b/include/fdt_decode.h @@ -177,6 +177,7 @@ struct fdt_kbc { u8 plain_keycode[FDT_KBC_KEY_COUNT]; u8 shift_keycode[FDT_KBC_KEY_COUNT]; u8 fn_keycode[FDT_KBC_KEY_COUNT]; + u8 ctrl_keycode[FDT_KBC_KEY_COUNT]; }; /** @@ -380,6 +381,7 @@ char *fdt_decode_get_config_string(const void *blob, const char *prop_name); * keycode-plain * keycode-shift * keycode-fn + * keycode-ctrl * * @param blob FDT blob to use * @param node Node to read from diff --git a/include/tegra-kbc.h b/include/tegra-kbc.h index 9a2357a61fe..ddc6379cc36 100755 --- a/include/tegra-kbc.h +++ b/include/tegra-kbc.h @@ -9,7 +9,15 @@ #include <common.h> -enum KEYS { KEY_FN = 222, KEY_SHIFT = 223}; +enum KEYS { + KEY_FIRST_MODIFIER = 220, + KEY_RIGHT_CTRL = KEY_FIRST_MODIFIER, + KEY_LEFT_CTRL, + KEY_FN, + KEY_SHIFT, +}; + +#define KEY_IS_MODIFIER(key) ((key) >= KEY_FIRST_MODIFIER) enum { KBC_MAX_ROW = 16, @@ -22,6 +30,7 @@ struct tegra_keyboard_config { int plain_keycode[KBC_KEY_COUNT]; /* when no Shift or Fn */ int shift_keycode[KBC_KEY_COUNT]; /* Shift modifier key is pressed */ int fn_keycode[KBC_KEY_COUNT]; /* Fn modifier key is pressed */ + int ctrl_keycode[KBC_KEY_COUNT]; /* Ctrl modifier key is pressed */ }; struct kbc_tegra { |