diff options
author | Simon Glass <sjg@chromium.org> | 2015-10-18 21:17:13 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-11-19 20:13:40 -0700 |
commit | 66877b0f5fc96906d70f1264b3b8102d2156360f (patch) | |
tree | f8f031613a60f517294918d270803d99e2e72487 | |
parent | 92778b2784e15a1ac88d4cf64a12eee8163b221c (diff) | |
download | u-boot-imx-66877b0f5fc96906d70f1264b3b8102d2156360f.zip u-boot-imx-66877b0f5fc96906d70f1264b3b8102d2156360f.tar.gz u-boot-imx-66877b0f5fc96906d70f1264b3b8102d2156360f.tar.bz2 |
input: Add the keycode translation tables separately
Require the caller to add the keycode translation tables separately so that
it can select which ones to use. In a later patch we will add the option to
add German tables.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r-- | board/kosagi/novena/novena.c | 1 | ||||
-rw-r--r-- | drivers/input/cros_ec_keyb.c | 1 | ||||
-rw-r--r-- | drivers/input/input.c | 26 | ||||
-rw-r--r-- | drivers/input/tegra-kbc.c | 1 | ||||
-rw-r--r-- | include/input.h | 10 |
5 files changed, 30 insertions, 9 deletions
diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c index 919133b..4a9f724 100644 --- a/board/kosagi/novena/novena.c +++ b/board/kosagi/novena/novena.c @@ -88,6 +88,7 @@ int drv_keyboard_init(void) debug("%s: Cannot set up input\n", __func__); return -1; } + input_add_tables(&button_input); button_input.read_keys = novena_gpio_button_read_keys; error = input_stdio_register(&dev); diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c index dd150ee..41d8a6f 100644 --- a/drivers/input/cros_ec_keyb.c +++ b/drivers/input/cros_ec_keyb.c @@ -255,6 +255,7 @@ int drv_keyboard_init(void) return -1; } config.input.read_keys = cros_ec_kbc_check; + input_add_tables(&config.input); memset(&dev, '\0', sizeof(dev)); strcpy(dev.name, "cros-ec-keyb"); diff --git a/drivers/input/input.c b/drivers/input/input.c index 9033935..82e8381 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -457,19 +457,27 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms, config->repeat_rate_ms = repeat_rate_ms; } +int input_add_tables(struct input_config *config) +{ + int ret; + + ret = input_add_table(config, -1, -1, + kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate)); + if (ret) + return ret; + ret = input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT, + kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate)); + if (ret) + return ret; + + return input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL, + kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate)); +} + 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, - kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate)) || - input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL, - kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate))) { - debug("%s: Could not add modifier tables\n", __func__); - return -ENOSPC; - } return 0; } diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c index 6b88db4..818ed8c 100644 --- a/drivers/input/tegra-kbc.c +++ b/drivers/input/tegra-kbc.c @@ -355,6 +355,7 @@ int drv_keyboard_init(void) return -1; } config.input.read_keys = tegra_kbc_check; + input_add_tables(input); memset(&dev, '\0', sizeof(dev)); strcpy(dev.name, "tegra-kbc"); diff --git a/include/input.h b/include/input.h index 7bccc8e..71f3538 100644 --- a/include/input.h +++ b/include/input.h @@ -123,6 +123,16 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms, int repeat_rate_ms); /** + * Set up the key map tables + * + * This must be called after input_init() or keycode decoding will not work. + * + * @param config Input state + * @return 0 if ok, -1 on error + */ +int input_add_tables(struct input_config *config); + +/** * Set up the input handler with basic key maps. * * @param config Input state |