All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 01/12] input: Support the German keymap
Date: Thu, 12 Nov 2015 11:51:25 +0800	[thread overview]
Message-ID: <CAEUhbmUGggAarXUPWiueYM2f7UPy47QOX=AT-6psh9QFdwtZiQ@mail.gmail.com> (raw)
In-Reply-To: <1447261548-14304-2-git-send-email-sjg@chromium.org>

Hi Simon,

On Thu, Nov 12, 2015 at 1:05 AM, Simon Glass <sjg@chromium.org> wrote:
> Add support for the German keymap, taken from i8042.c. This can be selected
> when the input library it initialised.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Please check one nits below.

> Changes in v3:
> - Refactor the German keyboard code to use data rather than code
>
> Changes in v2:
> - Update input_add_tables() to add error checking
>
>  board/kosagi/novena/novena.c |   2 +-
>  drivers/input/cros_ec_keyb.c |   2 +-
>  drivers/input/input.c        | 109 ++++++++++++++++++++++++++++++++++++++-----
>  drivers/input/tegra-kbc.c    |   2 +-
>  include/input.h              |   3 +-
>  5 files changed, 102 insertions(+), 16 deletions(-)
>
> diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
> index 4a9f724..babba85 100644
> --- a/board/kosagi/novena/novena.c
> +++ b/board/kosagi/novena/novena.c
> @@ -88,7 +88,7 @@ int drv_keyboard_init(void)
>                 debug("%s: Cannot set up input\n", __func__);
>                 return -1;
>         }
> -       input_add_tables(&button_input);
> +       input_add_tables(&button_input, false);
>         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 fe5caea..9bc4555 100644
> --- a/drivers/input/cros_ec_keyb.c
> +++ b/drivers/input/cros_ec_keyb.c
> @@ -211,7 +211,7 @@ static int cros_ec_kbd_probe(struct udevice *dev)
>
>         priv->input = input;
>         input->dev = dev;
> -       input_add_tables(input);
> +       input_add_tables(input, false);
>         input->read_keys = cros_ec_kbc_check;
>         strcpy(sdev->name, "cros-ec-keyb");
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 9e552f3..96fc195 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -79,6 +79,88 @@ static unsigned char kbd_ctrl_xlate[] = {
>         '\r', 0xff, '/',  '*',
>  };
>
> +static const uchar kbd_plain_xlate_german[] = {
> +       0xff, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
> +        '7',  '8',  '9',  '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
> +        'q',  'w',  'e',  'r',  't',  'z',  'u',  'i', /* scan 10-17 */
> +        'o',  'p', 0x81,  '+', '\r', 0xff,  'a',  's', /* scan 18-1F */
> +        'd',  'f',  'g',  'h',  'j',  'k',  'l', 0x94, /* scan 20-27 */
> +       0x84,  '^', 0xff,  '#',  'y',  'x',  'c',  'v', /* scan 28-2F */
> +        'b',  'n',  'm',  ',',  '.',  '-', 0xff,  '*', /* scan 30-37 */
> +        ' ',  ' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7', /* scan 40-47 */
> +        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
> +        '2',  '3',  '0',  ',', 0xff, 0xff,  '<', 0xff, /* scan 50-57 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
> +       '\r', 0xff,  '/',  '*',
> +};
> +
> +static unsigned char kbd_shift_xlate_german[] = {
> +          0xff, 0x1b,  '!',  '"', 0x15,  '$',  '%',  '&', /* scan 00-07 */
> +        '/',  '(',  ')',  '=',  '?',  '`', 0x08, '\t', /* scan 08-0F */
> +        'Q',  'W',  'E',  'R',  'T',  'Z',  'U',  'I', /* scan 10-17 */
> +        'O',  'P', 0x9a,  '*', '\r', 0xff,  'A',  'S', /* scan 18-1F */
> +        'D',  'F',  'G',  'H',  'J',  'K',  'L', 0x99, /* scan 20-27 */
> +       0x8e, 0xf8, 0xff, '\'',  'Y',  'X',  'C',  'V', /* scan 28-2F */
> +        'B',  'N',  'M',  ';',  ':',  '_', 0xff,  '*', /* scan 30-37 */
> +        ' ',  ' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7', /* scan 40-47 */
> +        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
> +        '2',  '3',  '0',  ',', 0xff, 0xff,  '>', 0xff, /* scan 50-57 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
> +       '\r', 0xff,  '/',  '*',
> +};
> +
> +static unsigned char kbd_right_alt_xlate_german[] = {
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
> +        '{',  '[',  ']',  '}', '\\', 0xff, 0xff, 0xff, /* scan 08-0F */
> +        '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
> +       0xff, 0xff, 0xff,  '~', 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
> +       0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '|', 0xff, /* scan 50-57 */
> +};
> +
> +enum kbd_mask {
> +       KBD_ENGLISH     = 1 << 0,
> +       KBD_GERMAN      = 1 << 1,
> +};
> +
> +static struct kbd_entry {
> +       int kbd_mask;           /* Which languages this is for */
> +       int left_keycode;       /* Left keycode to select this map */
> +       int right_keycode;      /* Right keycode to select this map */
> +       const uchar *xlate;     /* Ascii code for each keycode */
> +       int num_entries;        /* Number of entries in xlate */
> +} kbd_entry[] = {
> +       { KBD_ENGLISH, -1, -1,
> +               kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate) },
> +       { KBD_GERMAN, -1, -1,
> +               kbd_plain_xlate_german, ARRAY_SIZE(kbd_plain_xlate_german) },
> +       { KBD_ENGLISH, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
> +               kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate) },
> +       { KBD_GERMAN, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
> +               kbd_shift_xlate_german, ARRAY_SIZE(kbd_shift_xlate_german) },
> +       { KBD_ENGLISH | KBD_GERMAN, KEY_LEFTCTRL, KEY_RIGHTCTRL,
> +               kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate) },
> +       { KBD_GERMAN, -1, KEY_RIGHTALT,
> +               kbd_right_alt_xlate_german,
> +               ARRAY_SIZE(kbd_right_alt_xlate_german) },
> +       {},
> +};
> +
>  /*
>   * Scan key code to ANSI 3.64 escape sequence table.  This table is
>   * incomplete in that it does not include all possible extra keys.
> @@ -501,21 +583,24 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats)
>         config->allow_repeats = allow_repeats;
>  }
>
> -int input_add_tables(struct input_config *config)
> +int input_add_tables(struct input_config *config, bool german)
>  {
> +       struct kbd_entry *entry;
> +       int mask;
>         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));
> +       mask = german ? KBD_GERMAN : KBD_ENGLISH;
> +       for (entry = kbd_entry; entry->kbd_mask; entry++) {
> +               if (!(mask & entry->kbd_mask))
> +                       continue;
> +               ret = input_add_table(config, entry->left_keycode,
> +                                     entry->right_keycode, entry->xlate,
> +                       entry->num_entries);

Nits: looks the indention of the above line is wrong.

> +               if (ret)
> +                       return ret;
> +       }
> +
> +       return 0;
>  }
>
>  int input_init(struct input_config *config, int leds)
> diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
> index a7137f1..951cbb4 100644
> --- a/drivers/input/tegra-kbc.c
> +++ b/drivers/input/tegra-kbc.c
> @@ -326,7 +326,7 @@ static int tegra_kbd_probe(struct udevice *dev)
>         priv->input = input;
>         input->dev = dev;
>         input->read_keys = tegra_kbc_check;
> -       input_add_tables(input);
> +       input_add_tables(input, false);
>         strcpy(sdev->name, "tegra-kbc");
>         ret = input_stdio_register(sdev);
>         if (ret) {
> diff --git a/include/input.h b/include/input.h
> index e56f500..c1af259 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -167,9 +167,10 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats);
>   * This must be called after input_init() or keycode decoding will not work.
>   *
>   * @param config       Input state
> + * @param german       true to use German keyboard layout, false for US
>   * @return 0 if ok, -1 on error
>   */
> -int input_add_tables(struct input_config *config);
> +int input_add_tables(struct input_config *config, bool german);
>
>  /**
>   * Set up the input handler with basic key maps.
> --

Regards,
Bin

  reply	other threads:[~2015-11-12  3:51 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 17:05 [U-Boot] [PATCH v3 00/12] dm: input: Move keyboard drivers to driver model Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 01/12] input: Support the German keymap Simon Glass
2015-11-12  3:51   ` Bin Meng [this message]
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 02/12] input: Adjust structure of code in process_modifier() Simon Glass
2015-11-12 13:39   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 03/12] input: Handle caps lock Simon Glass
2015-11-12 13:50   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 04/12] input: Allow updating of keyboard LEDs Simon Glass
2015-11-12 13:50   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 05/12] input: i8042: Convert to use the input library Simon Glass
2015-11-12 13:50   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 06/12] input: Add a Kconfig option for the i8042 keyboard Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 07/12] x86: Add an i8042 device for boards that have it Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 08/12] Drop CONFIG_ISA_KEYBOARD Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 09/12] input: Convert i8042 to driver model Simon Glass
2015-11-12 13:50   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 10/12] i8042: Handle a duplicate power-on-reset response Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 11/12] video: input: Clean up after i8042 conversion Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 12/12] input: Convert 'keyboard' driver to use input library Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 21:56 ` [U-Boot] [PATCH v3 00/12] dm: input: Move keyboard drivers to driver model Simon Glass
2015-11-12  3:56   ` Bin Meng
2015-11-12 13:33     ` Bin Meng
2015-11-12 19:57       ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEUhbmUGggAarXUPWiueYM2f7UPy47QOX=AT-6psh9QFdwtZiQ@mail.gmail.com' \
    --to=bmeng.cn@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.