dm: input: Move keyboard drivers to driver model
Subsystems (9)
cover dm: input: Move keyboard drivers to driver model
This series adds a new uclass for keyboards and converts some drivers over to use it.
This series includes some work to remove code duplication in the keyboard drivers by updating them to use the input library (input.c). This unifies the keycode decoding logic in one place. In order to do this some enhancements are needed to the input library and these are also included.
The cros_ec and tegra_kbc drivers are converted to use driver model.
The i8042 driver is converted also, after various tidy-ups. The driver has some strange interactions with the cfb_console driver. This is removed in this series which is possible because the only user is x86. Some i8042 features have been dropped (the only deliberate one is the flashing cursor which does not seem to be used by any board).
Also the i8042 driver currently has its own keycode decoding logic. This series removes it in favour of the input library. Therefore testing of this new driver would be appreciated. So far I have only been able to test on link, which does not have a full keyboard. Also, while German keyboard support is implemented, I am unable to test that either.
These changes can be considered the first step towards moving stdio to driver model. For that to be useful we need to convert LCD and video also.
Note: This series is missing the code to call the update_leds() method when the LEDs change. This needs to be added to keyboard_tstc() and keyboard_getc(). If someone is able to test this I can send a patch for that also.
Simon Glass (28):
dm: input: Create a keyboard uclass
input: Add a device pointer to the input config
input: Return -ENOSPC when there is not space
input: Add the keycode translation tables separately
cros_ec: Use udevice instead of cros_ec_dev for keyboard functions
dm: stdio: Plumb in the new keyboard uclass
dm: tegra: Convert keyboard driver to driver model
dm: cros_ec: Convert cros_ec keyboard driver to driver model
video: Drop unused console functions
i8042: Use functions to handle register access
i8042: Handle a duplicate power-on-reset response
i8042: Adjust kbd_reset() to collect all failures
i8042: Adjust keyboard init to assume success
input: Correct keycode for Ctrl-Y
input: Add a few more keyboard keycodes
input: Add a function to add a keycode to the existing set
input: Allow repeat filtering to be disabled
input: Support the German keymap
input: Adjust structure of code in process_modifier()
input: Handle caps lock
input: Allow updating of keyboard LEDs
input: i8042: Convert to use the input library
input: Add a Kconfig option for the i8042 keyboard
x86: Add an i8042 device for boards that have it
Drop CONFIG_ISA_KEYBOARD
input: Convert i8042 to driver model
video: input: Clean up after i8042 conversion
input: Convert 'keyboard' driver to use input library
README | 42 +-- arch/arm/Kconfig | 1 + arch/arm/mach-tegra/Kconfig | 1 + arch/sandbox/Kconfig | 3 + arch/x86/Kconfig | 6 + arch/x86/dts/bayleybay.dts | 1 + arch/x86/dts/chromebook_link.dts | 1 + arch/x86/dts/keyboard.dtsi | 5 + board/kosagi/novena/novena.c | 1 + board/mpl/pip405/README | 4 - common/stdio.c | 31 +- common/usb_kbd.c | 6 - drivers/input/Kconfig | 19 ++ drivers/input/Makefile | 4 +- drivers/input/cros_ec_keyb.c | 147 ++++----- drivers/input/i8042.c | 632 ++++++++++----------------------------- drivers/input/input.c | 202 ++++++++++--- drivers/input/keyboard-uclass.c | 84 ++++++ drivers/input/keyboard.c | 290 +++--------------- drivers/input/tegra-kbc.c | 242 +++++++-------- drivers/misc/cros_ec.c | 14 +- drivers/video/cfb_console.c | 82 +---- include/configs/MIP405.h | 5 - include/configs/MPC8536DS.h | 1 - include/configs/MPC8544DS.h | 1 - include/configs/MPC8572DS.h | 1 - include/configs/MPC8641HPCN.h | 1 - include/configs/PIP405.h | 5 - include/configs/x86-chromebook.h | 2 +- include/configs/x86-common.h | 2 +- include/cros_ec.h | 4 +- include/fdtdec.h | 1 - include/i8042.h | 6 - include/input.h | 65 +++- include/keyboard.h | 83 +++++ lib/fdtdec.c | 1 - 36 files changed, 866 insertions(+), 1130 deletions(-) create mode 100644 arch/x86/dts/keyboard.dtsi create mode 100644 drivers/input/keyboard-uclass.c
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 1/28 dm: input: Create a keyboard uclass
Add a uclass for keyboard input, mirroring the existing stdio methods. This is enabled by a new CONFIG_DM_KEYBOARD option.
---
common/usb_kbd.c | 6 --- drivers/input/Kconfig | 9 +++++ drivers/input/Makefile | 2 + drivers/input/keyboard-uclass.c | 84 +++++++++++++++++++++++++++++++++++++++++ include/keyboard.h | 78 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+), 6 deletions(-) create mode 100644 drivers/input/keyboard-uclass.c
common/usb_kbd.c +0 -6
@@ -648,12 +648,6 @@ U_BOOT_DRIVER(usb_kbd) = { .probe = usb_kbd_probe, }; -/* TODO(sjg at chromium.org): Move this into a common location */ -UCLASS_DRIVER (keyboard) = { - .id =UCLASS_KEYBOARD , - .name ="keyboard" , -}; -static const struct usb_device_id kbd_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
drivers/input/Kconfig +9 -0
@@ -1,3 +1,12 @@ +config DM_KEYBOARD + bool "Enable driver model keyboard support" + depends on DM + help + This adds a uclass for keyboards and implements keyboard support + using driver model. The API is implemented by keyboard.h and + includes methods to start/stop the device, check for available + input and update LEDs if the keyboard has them. + config CROS_EC_KEYB bool "Enable Chrome OS EC keyboard support" help
drivers/input/Makefile +2 -0
@@ -5,6 +5,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o + obj-$(CONFIG_I8042_KBD) += i8042.o obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
drivers/input/keyboard-uclass.c new file +84 -0
84 lines not on this page · raw message
include/keyboard.h +78 -0
89 lines not on this page · raw message
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 1/28 dm: input: Create a keyboard uclass
Quoted 5 lines · Simon Glass
Add a uclass for keyboard input, mirroring the existing stdio methods. This is enabled by a new
CONFIG_DM_KEYBOARDoption.Signed-off-by Simon Glass <[email protected]>---
[...]
Quoted 6 lines
drivers/input/keyboard-uclass.c new file +6
-0+static int keyboard_pre_probe (struct udevice *dev) +{ +struct keyboard_priv *priv =dev_get_uclass_priv (dev); +struct stdio_dev *sdev = &priv->sdev; +int ret; +
drivers/input/keyboard-uclass.c line 72
Quoted 10 lines
drivers/input/keyboard-uclass.c new file +10
-0+strlcpy (sdev->name, dev->name,sizeof (sdev->name)); + sdev->flags =DEV_FLAGS_INPUT |DEV_FLAGS_SYSTEM ; + sdev->getc = keyboard_getc; + sdev->tstc = keyboard_tstc; + sdev->start = keyboard_start; + sdev->stop = keyboard_stop; + sdev->priv = dev; + ret =input_init (&priv->input,0 ); +if (ret) { +debug ("%s: Cannot set up input\n" , __func__);
Some better identification of the failing input here would be nice.
drivers/input/keyboard-uclass.c line 77
Quoted 5 lines
drivers/input/keyboard-uclass.c new file +5
-0+return ret; + } + +return 0 ; +}
Otherwise,
Best regards,
Marek Vasut
PATCH 1/28 dm: input: Create a keyboard uclass
In reply to Simon GlassHi Simon,
Quoted 76 lines · Simon Glass
Add a uclass for keyboard input, mirroring the existing stdio methods. This is enabled by a new
CONFIG_DM_KEYBOARDoption.Signed-off-by Simon Glass <[email protected]>---
common/usb_kbd.c | 6 --- drivers/input/Kconfig | 9 +++++ drivers/input/Makefile | 2 + drivers/input/keyboard-uclass.c | 84 +++++++++++++++++++++++++++++++++++++++++ include/keyboard.h | 78 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+), 6 deletions(-) create mode 100644 drivers/input/keyboard-uclass.ccommon/usb_kbd.c +0
-6@@ -648,12 +648,6 @@ U_BOOT_DRIVER(usb_kbd) = { .probe = usb_kbd_probe, }; -/* TODO(sjg at chromium.org): Move this into a common location */ -UCLASS_DRIVER (keyboard) = { - .id =UCLASS_KEYBOARD , - .name ="keyboard" , -}; -static const struct usb_device_id kbd_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |drivers/input/Kconfig +9
-0@@ -1,3 +1,12 @@ +config DM_KEYBOARD + bool "Enable driver model keyboard support" + depends on DM + help + This adds a uclass for keyboards and implements keyboard support + using driver model. The API is implemented by keyboard.h and + includes methods to start/stop the device, check for available + input and update LEDs if the keyboard has them. + config CROS_EC_KEYB bool "Enable Chrome OS EC keyboard support" helpdrivers/input/Makefile +2
-0@@ -5,6 +5,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o + obj-$(CONFIG_I8042_KBD) += i8042.o obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o obj-$(CONFIG_TWL4030_INPUT) += twl4030.odrivers/input/keyboard-uclass.c new file +9
-0@@ -0,0 +1,84 @@ +/* +* Copyright (c) 2015 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <keyboard.h>
drivers/input/keyboard-uclass.c line 19
Quoted 10 lines
drivers/input/keyboard-uclass.c new file +10
-0+ +static int keyboard_start (struct stdio_dev *sdev) +{ +struct udevice *dev = sdev->priv; +struct keyboard_ops *ops =keyboard_get_ops (dev); + +if (ops->start) +return ops->start (dev); + +return 0 ;
Should we return -ENOSYS here?
drivers/input/keyboard-uclass.c line 30
Quoted 11 lines
drivers/input/keyboard-uclass.c new file +11
-0+} + +static int keyboard_stop (struct stdio_dev *sdev) +{ +struct udevice *dev = sdev->priv; +struct keyboard_ops *ops =keyboard_get_ops (dev); + +if (ops->stop) +return ops->stop (dev); + +return 0 ;
Ditto.
drivers/input/keyboard-uclass.c line 40
Quoted 10 lines
drivers/input/keyboard-uclass.c new file +10
-0+} + +static int keyboard_tstc (struct stdio_dev *sdev) +{ +struct udevice *dev = sdev->priv; +struct keyboard_priv *priv =dev_get_uclass_priv (dev); + +/* Just get input to do this for us if we can */ +if (priv->input.dev) +return input_tstc (&priv->input);
else if (op->tstc)
return ops->tstc(dev);
?
drivers/input/keyboard-uclass.c line 52
Quoted 12 lines
drivers/input/keyboard-uclass.c new file +12
-0+ +return -ENOSYS ; +} + +static int keyboard_getc (struct stdio_dev *sdev) +{ +struct udevice *dev = sdev->priv; +struct keyboard_priv *priv =dev_get_uclass_priv (dev); + +/* Just get input to do this for us if we can */ +if (priv->input.dev) +return input_getc (&priv->input);
Ditto.
Quoted 75 lines
drivers/input/keyboard-uclass.c new file +32
-0+ +return -ENOSYS ; +} + +static int keyboard_pre_probe (struct udevice *dev) +{ +struct keyboard_priv *priv =dev_get_uclass_priv (dev); +struct stdio_dev *sdev = &priv->sdev; +int ret; + +strlcpy (sdev->name, dev->name,sizeof (sdev->name)); + sdev->flags =DEV_FLAGS_INPUT |DEV_FLAGS_SYSTEM ; + sdev->getc = keyboard_getc; + sdev->tstc = keyboard_tstc; + sdev->start = keyboard_start; + sdev->stop = keyboard_stop; + sdev->priv = dev; + ret =input_init (&priv->input,0 ); +if (ret) { +debug ("%s: Cannot set up input\n" , __func__); +return ret; + } + +return 0 ; +} + +UCLASS_DRIVER (keyboard) = { + .id =UCLASS_KEYBOARD , + .name ="keyboard" , + .pre_probe = keyboard_pre_probe, + .per_device_auto_alloc_size =sizeof (struct keyboard_priv ), +};include/keyboard.h +35
-0@@ -1,6 +1,83 @@ #ifndef __KEYBOARD_H #define __KEYBOARD_H +#ifdef CONFIG_DM_KEYBOARD +#include <input.h> +#include <stdio_dev.h> + +/** + * struct keyboard_priv - information about a keyboard, for the uclass + * + * @sdev: stdio device + * @input: input configuration (the driver may use this if desired) + */ +struct keyboard_priv { + struct stdio_dev sdev; + + /* + * This is set up by the uclass but will only be used if the driver + * sets input.dev to its device pointer (it is initially NULL). + */ + struct input_config input; +}; + +/** + * struct keyboard_ops - keyboard device operations + */ +struct keyboard_ops { + /** + * start() - enable the keyboard ready for use + * + * @dev: Device to enable + * @return 0 if OK, -ve on error + */ + int (*start)(struct udevice *dev); + + /** + * stop() - disable the keyboard when no-longer needed + *
include/keyboard.h line 48
Quoted 10 lines
include/keyboard.h +10
-0+* @dev: Device to disable +* @return 0 if OK, -ve on error +*/ +int (*stop)(struct udevice *dev); + +/** +* tstc() - check if a key is available +* +* @dev: Device to check +* @return 0 if no key is available, 1 if a key is available
Should we change the return value to bool?
Quoted 36 lines
include/keyboard.h +32
-0+*/ +int (*tstc)(struct udevice *dev); + +/** +* getc() - get a key +* +* TODO(sjg at chromium.org): At present this method may wait if it calls +* input_getc(). +* +* @dev: Device to read from +* @return -EAGAIN if no key is available, otherwise key value read +* (as ASCII). +*/ +int (*getc)(struct udevice *dev); + +/** +* update_leds() - update keyboard LEDs +* +* This is called when the LEDs have changed and need to be updated. +* For example, if 'caps lock' is pressed then this method will be +* called with the new LED value. +* +* @dev: Device to update +* @leds: New LED mask (see INPUT_LED_... in input.h) +*/ + int (*update_leds)(struct udevice *dev, int leds); +}; + +#define keyboard_get_ops (dev) ((struct keyboard_ops *)(dev)->driver->ops) + +#else +#ifdef CONFIG_PS2MULT #include <ps2mult.h> #endif
include/keyboard.h extern int kbd_init (void);
Quoted 7 lines
include/keyboard.h +1
-1@@ -18,5 +95,6 @@ extern int kbd_init (void);extern void handle_scancode (unsigned char scancode);extern int kbd_init_hw (void );extern void pckbd_leds (unsigned char leds); +#endif /* !CONFIG_DM_KEYBOARD */ #endif /* __KEYBOARD_H */ --
Regards,
Bin
PATCH 1/28 dm: input: Create a keyboard uclass
Hi Bin,
Quoted 83 lines · Bin Meng
Hi Simon,
Quoted 80 lines · Simon Glass
Add a uclass for keyboard input, mirroring the existing stdio methods. This is enabled by a new
CONFIG_DM_KEYBOARDoption.Signed-off-by Simon Glass <[email protected]>---
common/usb_kbd.c | 6 --- drivers/input/Kconfig | 9 +++++ drivers/input/Makefile | 2 + drivers/input/keyboard-uclass.c | 84 +++++++++++++++++++++++++++++++++++++++++ include/keyboard.h | 78 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+), 6 deletions(-) create mode 100644 drivers/input/keyboard-uclass.ccommon/usb_kbd.c +0
-6@@ -648,12 +648,6 @@ U_BOOT_DRIVER(usb_kbd) = { .probe = usb_kbd_probe, }; -/* TODO(sjg at chromium.org): Move this into a common location */ -UCLASS_DRIVER (keyboard) = { - .id =UCLASS_KEYBOARD , - .name ="keyboard" , -}; -static const struct usb_device_id kbd_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |drivers/input/Kconfig +9
-0@@ -1,3 +1,12 @@ +config DM_KEYBOARD + bool "Enable driver model keyboard support" + depends on DM + help + This adds a uclass for keyboards and implements keyboard support + using driver model. The API is implemented by keyboard.h and + includes methods to start/stop the device, check for available + input and update LEDs if the keyboard has them. + config CROS_EC_KEYB bool "Enable Chrome OS EC keyboard support" helpdrivers/input/Makefile +2
-0@@ -5,6 +5,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o + obj-$(CONFIG_I8042_KBD) += i8042.o obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o obj-$(CONFIG_TWL4030_INPUT) += twl4030.odrivers/input/keyboard-uclass.c new file +13
-0@@ -0,0 +1,84 @@ +/* +* Copyright (c) 2015 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <keyboard.h> + +static int keyboard_start (struct stdio_dev *sdev) +{ +struct udevice *dev = sdev->priv;
Quoted 8 lines
drivers/input/keyboard-uclass.c line 19
Quoted 6 lines
drivers/input/keyboard-uclass.c new file +6
-0+struct keyboard_ops *ops =keyboard_get_ops (dev); + +if (ops->start) +return ops->start (dev); + +return 0 ;Should we return
-ENOSYShere?
No, several keyboards don't need to do do anything here.
Quoted 27 lines
drivers/input/keyboard-uclass.c line 30
Quoted 12 lines
drivers/input/keyboard-uclass.c new file +11
-0+} + +static int keyboard_stop (struct stdio_dev *sdev) +{ +struct udevice *dev = sdev->priv; +struct keyboard_ops *ops =keyboard_get_ops (dev); + +if (ops->stop) +return ops->stop (dev); + +return 0 ;Ditto.
drivers/input/keyboard-uclass.c line 40
Quoted 10 lines
drivers/input/keyboard-uclass.c new file +10
-0+} + +static int keyboard_tstc (struct stdio_dev *sdev) +{ +struct udevice *dev = sdev->priv; +struct keyboard_priv *priv =dev_get_uclass_priv (dev); + +/* Just get input to do this for us if we can */ +if (priv->input.dev) +return input_tstc (&priv->input);else if (
op->tstc)
Quoted 3 lines
return ops->tstc(dev);?
Well nothing uses it yet, and I'm hoping they won't, but OK.
Quoted 95 lines
drivers/input/keyboard-uclass.c line 52
Quoted 13 lines
drivers/input/keyboard-uclass.c new file +12
-0+ +return -ENOSYS ; +} + +static int keyboard_getc (struct stdio_dev *sdev) +{ +struct udevice *dev = sdev->priv; +struct keyboard_priv *priv =dev_get_uclass_priv (dev); + +/* Just get input to do this for us if we can */ +if (priv->input.dev) +return input_getc (&priv->input);Ditto.
Quoted 79 lines
drivers/input/keyboard-uclass.c new file +32
-0+ +return -ENOSYS ; +} + +static int keyboard_pre_probe (struct udevice *dev) +{ +struct keyboard_priv *priv =dev_get_uclass_priv (dev); +struct stdio_dev *sdev = &priv->sdev; +int ret; + +strlcpy (sdev->name, dev->name,sizeof (sdev->name)); + sdev->flags =DEV_FLAGS_INPUT |DEV_FLAGS_SYSTEM ; + sdev->getc = keyboard_getc; + sdev->tstc = keyboard_tstc; + sdev->start = keyboard_start; + sdev->stop = keyboard_stop; + sdev->priv = dev; + ret =input_init (&priv->input,0 ); +if (ret) { +debug ("%s: Cannot set up input\n" , __func__); +return ret; + } + +return 0 ; +} + +UCLASS_DRIVER (keyboard) = { + .id =UCLASS_KEYBOARD , + .name ="keyboard" , + .pre_probe = keyboard_pre_probe, + .per_device_auto_alloc_size =sizeof (struct keyboard_priv ), +};include/keyboard.h +39
-0@@ -1,6 +1,83 @@ #ifndef __KEYBOARD_H #define __KEYBOARD_H +#ifdef CONFIG_DM_KEYBOARD +#include <input.h> +#include <stdio_dev.h> + +/** + * struct keyboard_priv - information about a keyboard, for the uclass + * + * @sdev: stdio device + * @input: input configuration (the driver may use this if desired) + */ +struct keyboard_priv { + struct stdio_dev sdev; + + /* + * This is set up by the uclass but will only be used if the driver + * sets input.dev to its device pointer (it is initially NULL). + */ + struct input_config input; +}; + +/** + * struct keyboard_ops - keyboard device operations + */ +struct keyboard_ops { + /** + * start() - enable the keyboard ready for use + * + * @dev: Device to enable + * @return 0 if OK, -ve on error + */ + int (*start)(struct udevice *dev); + + /** + * stop() - disable the keyboard when no-longer needed + * + * @dev: Device to disable + * @return 0 if OK, -ve on error + */ + int (*stop)(struct udevice *dev);
Quoted 8 lines
include/keyboard.h line 48
Quoted 6 lines
include/keyboard.h +6
-0+ +/** +* tstc() - check if a key is available +* +* @dev: Device to check +* @return 0 if no key is available, 1 if a key is available Should we change the return value to bool?
It can return an error - I'll update the comment.
Quoted 42 lines
Quoted 42 lines
include/keyboard.h +33
-0+*/ +int (*tstc)(struct udevice *dev); + +/** +* getc() - get a key +* +* TODO(sjg at chromium.org): At present this method may wait if it calls +* input_getc(). +* +* @dev: Device to read from +* @return -EAGAIN if no key is available, otherwise key value read +* (as ASCII). +*/ +int (*getc)(struct udevice *dev); + +/** +* update_leds() - update keyboard LEDs +* +* This is called when the LEDs have changed and need to be updated. +* For example, if 'caps lock' is pressed then this method will be +* called with the new LED value. +* +* @dev: Device to update +* @leds: New LED mask (see INPUT_LED_... in input.h) +*/ + int (*update_leds)(struct udevice *dev, int leds); +}; + +#define keyboard_get_ops (dev) ((struct keyboard_ops *)(dev)->driver->ops) + +#else +#ifdef CONFIG_PS2MULT #include <ps2mult.h> #endif @@ -18,5 +95,6 @@ extern int kbd_init (void);extern void handle_scancode (unsigned char scancode);extern int kbd_init_hw (void );extern void pckbd_leds (unsigned char leds); +#endif /* !CONFIG_DM_KEYBOARD */
Quoted 5 lines
include/keyboard.h extern int kbd_init (void);
Quoted 2 lines
include/keyboard.h +0
-1#endif /* __KEYBOARD_H */ --Regards,
Bin
Regards,
Simon
PATCH 2/28 input: Add a device pointer to the input config
In reply to Simon GlassThe read_keys() method in input is passed a struct input_config. Add a device pointer there so that we can find out the device that is referred to with driver model.
Once all drivers are converted we can update the input structure to use driver model instead.
---
include/input.h | 1 + 1 file changed, 1 insertion(+)
include/input.h +1 -0
@@ -36,6 +36,7 @@ struct input_key_xlate { };struct input_config { +struct udevice *dev;uchar fifo[INPUT_BUFFER_LEN ];int fifo_in, fifo_out;
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 2/28 input: Add a device pointer to the input config
Quoted 18 lines · Simon Glass
The
read_keys()method in input is passed a structinput_config. Add a device pointer there so that we can find out the device that is referred to with driver model.Once all drivers are converted we can update the input structure to use driver model instead.
Signed-off-by Simon Glass <[email protected]>---
include/input.h | 1 + 1 file changed, 1 insertion(+)include/input.h +0
-0
include/input.h struct input_key_xlate {
Quoted 8 lines
include/input.h +1
-1@@ -36,6 +36,7 @@ struct input_key_xlate { };struct input_config { +struct udevice *dev;uchar fifo[INPUT_BUFFER_LEN ];int fifo_in, fifo_out; --
PATCH 3/28 input: Return -ENOSPC when there is not space
In reply to Simon GlassReturn a useful error instead of -1 when something goes wrong.
---
drivers/input/input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/input/input.c +2 -1
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <errno.h> #include <stdio_dev.h> #include <input.h> #include <linux/input.h>
@@ -467,7 +468,7 @@ int input_init(struct input_config *config, int leds) 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 -1 ; +return -ENOSPC ; }return 0 ;
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 3/28 input: Return -ENOSPC when there is not space
Quoted 21 lines · Simon Glass
Return a useful error instead of -1 when something goes wrong.
Signed-off-by Simon Glass <[email protected]>---
drivers/input/input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/input/input.c +1
-0@@ -8,6 +8,7 @@*/ #include <common.h> +#include <errno.h> #include <stdio_dev.h> #include <input.h> #include <linux/input.h>
drivers/input/input.c int input_init(struct input_config *config, int leds)
Quoted 9 lines
drivers/input/input.c +1
-2@@ -467,7 +468,7 @@ int input_init(struct input_config *config, int leds) 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 -1 ; +return -ENOSPC ; }return 0 ; --
PATCH 4/28 input: Add the keycode translation tables separately
In reply to Simon GlassRequire 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.
---
board/kosagi/novena/novena.c | 1 + drivers/input/cros_ec_keyb.c | 1 + drivers/input/input.c | 21 ++++++++++++--------- drivers/input/tegra-kbc.c | 1 + include/input.h | 10 ++++++++++ 5 files changed, 25 insertions(+), 9 deletions(-)
board/kosagi/novena/novena.c +1 -0
@@ -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);
drivers/input/cros_ec_keyb.c +1 -0
@@ -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" );
drivers/input/input.c +12 -9
@@ -457,19 +457,22 @@ 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) +{ +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)); + +return 0 ; +} +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 ; }
drivers/input/tegra-kbc.c +1 -0
@@ -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" );
include/input.h +10 -0
@@ -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
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 4/28 input: Add the keycode translation tables separately
Hi Simon,
Quoted 44 lines · Simon Glass
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 <[email protected]>---
board/kosagi/novena/novena.c | 1 + drivers/input/cros_ec_keyb.c | 1 + drivers/input/input.c | 21 ++++++++++++--------- drivers/input/tegra-kbc.c | 1 + include/input.h | 10 ++++++++++ 5 files changed, 25 insertions(+), 9 deletions(-)board/kosagi/novena/novena.c +1
-0@@ -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);drivers/input/cros_ec_keyb.c +1
-0@@ -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" );drivers/input/input.c +0
-0@@ -457,19 +457,22 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms, config->repeat_rate_ms = repeat_rate_ms;
drivers/input/input.c void input_set_delays(struct input_config *config, int repeat_delay_ms, · line 467
Quoted 10 lines
drivers/input/input.c +8
-0} +int input_add_tables (struct input_config *config) +{ +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));
Should we return error codes here? In previous patch, we've added -ENOSPC.
Quoted 44 lines
drivers/input/input.c +4
-9+ +return 0 ; +} +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 ; }drivers/input/tegra-kbc.c +1
-0@@ -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" );include/input.h +4
-0@@ -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. +*
include/input.h void input_set_delays(struct input_config *config, int repeat_delay_ms,
Quoted 10 lines
include/input.h +6
-1+* @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 --
Regards,
Bin
PATCH 4/28 input: Add the keycode translation tables separately
Hi Bin,
Quoted 49 lines · Bin Meng
Hi Simon,
Quoted 46 lines · Simon Glass
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 <[email protected]>---
board/kosagi/novena/novena.c | 1 + drivers/input/cros_ec_keyb.c | 1 + drivers/input/input.c | 21 ++++++++++++--------- drivers/input/tegra-kbc.c | 1 + include/input.h | 10 ++++++++++ 5 files changed, 25 insertions(+), 9 deletions(-)board/kosagi/novena/novena.c +1
-0@@ -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);drivers/input/cros_ec_keyb.c +1
-0@@ -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" );drivers/input/input.c +0
-0@@ -457,19 +457,22 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms, config->repeat_rate_ms = repeat_rate_ms; }
Quoted 10 lines
drivers/input/input.c void input_set_delays(struct input_config *config, int repeat_delay_ms, · line 467
Quoted 8 lines
drivers/input/input.c +8
-0+int input_add_tables (struct input_config *config) +{ +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));Should we return error codes here? In previous patch, we've added
-ENOSPC.
It can't actually happen since there is always enough space for 3 items and this is called at the start. Still it looks strange to not check errors so I will add it.
[snip]
Regards,
Simon
PATCH 5/28 cros_ec: Use udevice instead of cros_ec_dev for keyboard functions
In reply to Simon GlassIn preparation for converting the cros_ec keyboard driver to driver model, adjust the cros_ec functions it will use to use a normal struct udevice.
---
drivers/input/cros_ec_keyb.c | 4 ++-- drivers/misc/cros_ec.c | 14 +++++++++----- include/cros_ec.h | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-)
drivers/input/cros_ec_keyb.c +2 -2
@@ -54,7 +54,7 @@ static int check_for_keys(struct keyb *config,unsigned int row, col, bit, data;int num_keys; -if (cros_ec_scan_keyboard (config->dev, &scan)) { +if (cros_ec_scan_keyboard (config->dev->dev, &scan)) {debug ("%s: keyboard scan failed\n" , __func__);return -EIO ; }
@@ -139,7 +139,7 @@ int cros_ec_kbc_check(struct input_config *input)* may return 0 before all keys have been read from the EC. */ do { - irq_pending = cros_ec_interrupt_pending(config.dev); + irq_pending = cros_ec_interrupt_pending(config.dev->dev); if (irq_pending) { num_keys = check_for_keys(&config, keys, KBC_MAX_KEYS, &same);
drivers/misc/cros_ec.c +9 -5
@@ -358,9 +358,11 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,return len; } -int cros_ec_scan_keyboard (struct cros_ec_dev *dev,struct mbkp_keyscan *scan) +int cros_ec_scan_keyboard (struct udevice *dev,struct mbkp_keyscan *scan) { -if (ec_command (dev,EC_CMD_MKBP_STATE ,0 ,NULL ,0 , scan, +struct cros_ec_dev *cdev =dev_get_uclass_priv (dev); + +if (ec_command (cdev,EC_CMD_MKBP_STATE ,0 ,NULL ,0 , scan,sizeof (scan->data)) !=sizeof (scan->data))return -1 ;
@@ -549,13 +551,15 @@ int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,return 0 ; } -int cros_ec_interrupt_pending (struct cros_ec_dev *dev) +int cros_ec_interrupt_pending (struct udevice *dev) { +struct cros_ec_dev *cdev =dev_get_uclass_priv (dev); +/* no interrupt support : always poll */ -if (!dm_gpio_is_valid (&dev->ec_int)) +if (!dm_gpio_is_valid (&cdev->ec_int))return -ENOENT ; -return dm_gpio_get_value (&dev->ec_int); +return dm_gpio_get_value (&cdev->ec_int); }int cros_ec_info (struct cros_ec_dev *dev,struct ec_response_mkbp_info *info)
include/cros_ec.h +2 -2
@@ -81,7 +81,7 @@ int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen);* @param scan Place to put the scan results * @return 0 if ok, -1 on error */ -int cros_ec_scan_keyboard (struct cros_ec_dev *dev,struct mbkp_keyscan *scan); +int cros_ec_scan_keyboard (struct udevice *dev,struct mbkp_keyscan *scan);/** * Read which image is currently running on the CROS-EC device.
@@ -125,7 +125,7 @@ int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,* @param dev CROS-EC device * @return 0 if no interrupt is pending */ -int cros_ec_interrupt_pending (struct cros_ec_dev *dev); +int cros_ec_interrupt_pending (struct udevice *dev);enum {CROS_EC_OK ,
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 6/28 dm: stdio: Plumb in the new keyboard uclass
In reply to Simon GlassWhen driver model is used for keyboards we must scan the available keyboards and register them with stdio. Add code to do this.
At some point (once LCD/video is converted) we should be able to convert stdio to driver model and avoid these dual data structures.
---
common/stdio.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
common/stdio.c +30 -1
@@ -11,6 +11,7 @@#include <config.h> #include <common.h> +#include <dm.h> #include <errno.h> #include <stdarg.h> #include <malloc.h>
@@ -24,6 +25,8 @@#include <i2c.h> #endif +#include <dm/device-internal.h> +DECLARE_GLOBAL_DATA_PTR ;static struct stdio_dev devs;
@@ -245,6 +248,32 @@ int stdio_init_tables(void)int stdio_add_devices (void ) { +#ifdef CONFIG_DM_KEYBOARD +struct udevice *dev; +struct uclass *uc; +int ret; + +/* +* For now we probe all the devices here. At some point this should be +* done only when the devices are required - e.g. we have a list of +* input devices to start up in the stdin environment variable. That +* work probably makes more sense when stdio itself is converted to +* driver model. +* +* TODO(sjg at chromium.org): Convert changing uclass_first_device() etc. +* to return the device even on error. Then we could use that here. +*/ + ret =uclass_get (UCLASS_KEYBOARD , &uc); +if (ret) +return ret; + +/* Don't report errors to the caller - assume that they are non-fatal */ + uclass_foreach_dev(dev, uc) { + ret =device_probe (dev); +if (ret) +printf ("Failed to probe keyboard '%s'\n" , dev->name); + } +#endif #ifdef CONFIG_SYS_I2C i2c_init_all ();#else
@@ -258,7 +287,7 @@ int stdio_add_devices(void)#if defined(CONFIG_VIDEO ) || defined(CONFIG_CFB_CONSOLE )drv_video_init ();#endif -#ifdef CONFIG_KEYBOARD +#if defined(CONFIG_KEYBOARD ) && !defined(CONFIG_DM_KEYBOARD )drv_keyboard_init ();#endif #ifdef CONFIG_LOGBUFFER
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 6/28 dm: stdio: Plumb in the new keyboard uclass
Hi Simon,
Quoted 9 lines · Simon Glass
When driver model is used for keyboards we must scan the available keyboards and register them with stdio. Add code to do this.
At some point (once LCD/video is converted) we should be able to convert stdio to driver model and avoid these dual data structures.
Signed-off-by Simon Glass <[email protected]>---
Please see one question below.
Quoted 58 lines
common/stdio.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)common/stdio.c +29
-0@@ -11,6 +11,7 @@#include <config.h> #include <common.h> +#include <dm.h> #include <errno.h> #include <stdarg.h> #include <malloc.h> @@ -24,6 +25,8 @@#include <i2c.h> #endif +#include <dm/device-internal.h> +DECLARE_GLOBAL_DATA_PTR ;static struct stdio_dev devs;@@ -245,6 +248,32 @@ int stdio_init_tables(void)int stdio_add_devices (void ) { +#ifdef CONFIG_DM_KEYBOARD +struct udevice *dev; +struct uclass *uc; +int ret; + +/* +* For now we probe all the devices here. At some point this should be +* done only when the devices are required - e.g. we have a list of +* input devices to start up in the stdin environment variable. That +* work probably makes more sense when stdio itself is converted to +* driver model. +* +* TODO(sjg at chromium.org): Convert changing uclass_first_device() etc. +* to return the device even on error. Then we could use that here. +*/ + ret =uclass_get (UCLASS_KEYBOARD , &uc); +if (ret) +return ret; + +/* Don't report errors to the caller - assume that they are non-fatal */ + uclass_foreach_dev(dev, uc) { + ret =device_probe (dev); +if (ret) +printf ("Failed to probe keyboard '%s'\n" , dev->name); + } +#endif #ifdef CONFIG_SYS_I2C i2c_init_all ();#else
common/stdio.c int stdio_add_devices(void) · line 290
Quoted 5 lines
common/stdio.c +1
-1@@ -258,7 +287,7 @@ int stdio_add_devices(void)#if defined(CONFIG_VIDEO ) || defined(CONFIG_CFB_CONSOLE )drv_video_init ();#endif -#ifdef CONFIG_KEYBOARD +#if defined(CONFIG_KEYBOARD ) && !defined(CONFIG_DM_KEYBOARD )
Should we remove this non-dm driver call completely?
common/stdio.c int stdio_add_devices(void)
Quoted 4 lines
common/stdio.c +0
-1drv_keyboard_init ();#endif #ifdef CONFIG_LOGBUFFER --
Regards,
Bin
PATCH 6/28 dm: stdio: Plumb in the new keyboard uclass
Hi Bin,
Quoted 74 lines · Bin Meng
Hi Simon,
Quoted 9 lines · Simon Glass
When driver model is used for keyboards we must scan the available keyboards and register them with stdio. Add code to do this.
At some point (once LCD/video is converted) we should be able to convert stdio to driver model and avoid these dual data structures.
Signed-off-by Simon Glass <[email protected]>---
Reviewed-by Bin Meng <[email protected]>Please see one question below.
Quoted 57 lines
common/stdio.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)common/stdio.c +29
-0@@ -11,6 +11,7 @@#include <config.h> #include <common.h> +#include <dm.h> #include <errno.h> #include <stdarg.h> #include <malloc.h> @@ -24,6 +25,8 @@#include <i2c.h> #endif +#include <dm/device-internal.h> +DECLARE_GLOBAL_DATA_PTR ;static struct stdio_dev devs;@@ -245,6 +248,32 @@ int stdio_init_tables(void)int stdio_add_devices (void ) { +#ifdef CONFIG_DM_KEYBOARD +struct udevice *dev; +struct uclass *uc; +int ret; + +/* +* For now we probe all the devices here. At some point this should be +* done only when the devices are required - e.g. we have a list of +* input devices to start up in the stdin environment variable. That +* work probably makes more sense when stdio itself is converted to +* driver model. +* +* TODO(sjg at chromium.org): Convert changing uclass_first_device() etc. +* to return the device even on error. Then we could use that here. +*/ + ret =uclass_get (UCLASS_KEYBOARD , &uc); +if (ret) +return ret; + +/* Don't report errors to the caller - assume that they are non-fatal */ + uclass_foreach_dev(dev, uc) { + ret =device_probe (dev); +if (ret) +printf ("Failed to probe keyboard '%s'\n" , dev->name); + } +#endif #ifdef CONFIG_SYS_I2C i2c_init_all ();#else
Quoted 8 lines
common/stdio.c int stdio_add_devices(void) · line 290
Quoted 6 lines
common/stdio.c +1
-1@@ -258,7 +287,7 @@ int stdio_add_devices(void)#if defined(CONFIG_VIDEO ) || defined(CONFIG_CFB_CONSOLE )drv_video_init ();#endif -#ifdef CONFIG_KEYBOARD +#if defined(CONFIG_KEYBOARD ) && !defined(CONFIG_DM_KEYBOARD )Should we remove this non-dm driver call completely?
We can once 'novena' is converted over.
Quoted 5 lines
common/stdio.c int stdio_add_devices(void)
Quoted 5 lines
common/stdio.c +0
-1drv_keyboard_init ();#endif #ifdef CONFIG_LOGBUFFER --
Regards,
Simon
PATCH 6/28 dm: stdio: Plumb in the new keyboard uclass
In reply to Simon GlassApplied to u-boot-dm.
PATCH 7/28 dm: tegra: Convert keyboard driver to driver model
In reply to Simon GlassAdjust the tegra keyboard driver to support driver model, using the new uclass. Make this the default for all Tegra boards so that those that use a keyboard will build correctly with this driver.
---
arch/arm/mach-tegra/Kconfig | 1 + drivers/input/tegra-kbc.c | 243 ++++++++++++++++++++------------------------ include/fdtdec.h | 1 - lib/fdtdec.c | 1 - 4 files changed, 112 insertions(+), 134 deletions(-)
arch/arm/mach-tegra/Kconfig +1 -0
@@ -12,6 +12,7 @@ config TEGRA_ARMV7_COMMON select DM_I2C select DM_SPI select DM_GPIO + select DM_KEYBOARD choice prompt "Tegra SoC select"
drivers/input/tegra-kbc.c +111 -132
391 lines not on this page · raw message
include/fdtdec.h +0 -1
@@ -118,7 +118,6 @@ enum fdt_compat_id {COMPAT_UNKNOWN ,COMPAT_NVIDIA_TEGRA20_EMC ,/* Tegra20 memory controller */ COMPAT_NVIDIA_TEGRA20_EMC_TABLE ,/* Tegra20 memory timing table */ -COMPAT_NVIDIA_TEGRA20_KBC ,/* Tegra20 Keyboard */ COMPAT_NVIDIA_TEGRA20_NAND ,/* Tegra2 NAND controller */ COMPAT_NVIDIA_TEGRA20_PWM ,/* Tegra 2 PWM controller */ COMPAT_NVIDIA_TEGRA124_DC, /* Tegra 124 Display controller */
lib/fdtdec.c +0 -1
@@ -24,7 +24,6 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (UNKNOWN ,"<none>" ),COMPAT (NVIDIA_TEGRA20_EMC ,"nvidia,tegra20-emc" ),COMPAT (NVIDIA_TEGRA20_EMC_TABLE ,"nvidia,tegra20-emc-table" ), -COMPAT (NVIDIA_TEGRA20_KBC ,"nvidia,tegra20-kbc" ),COMPAT (NVIDIA_TEGRA20_NAND ,"nvidia,tegra20-nand" ),COMPAT (NVIDIA_TEGRA20_PWM ,"nvidia,tegra20-pwm" ), COMPAT(NVIDIA_TEGRA124_DC, "nvidia,tegra124-dc"),
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 8/28 dm: cros_ec: Convert cros_ec keyboard driver to driver model
In reply to Simon GlassAdjust the cros_ec keyboard driver to support driver model. Make this the default for all Exynos boards so that those that use a keyboard will build correctly with this driver.
---
README | 5 -- arch/arm/Kconfig | 1 + arch/sandbox/Kconfig | 3 + drivers/input/cros_ec_keyb.c | 148 +++++++++++++++++-------------------------- 4 files changed, 62 insertions(+), 95 deletions(-)
README +0 -5
@@ -1803,11 +1803,6 @@ CBFS (Coreboot Filesystem) support Export function i8042_kbd_init, i8042_tstc and i8042_getc for cfb_console. Supports cursor blinking. - CONFIG_CROS_EC_KEYB - Enables a Chrome OS keyboard using the CROS_EC interface. - This uses CROS_EC to communicate with a second microcontroller - which provides key scans on request. - - Video support: CONFIG_VIDEO
arch/arm/Kconfig +1 -0
@@ -450,6 +450,7 @@ config ARCH_EXYNOS select DM_SERIAL select DM_SPI select DM_GPIO + select DM_KEYBOARD config ARCH_S5PC1XX bool "Samsung S5PC1XX"
arch/sandbox/Kconfig +3 -0
@@ -17,4 +17,7 @@ config PCI used on some devices to allow the CPU to communicate with its peripherals. +config DM_KEYBOARD + default y + endmenu
drivers/input/cros_ec_keyb.c +58 -90
239 lines not on this page · raw message
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 9/28 video: Drop unused console functions
In reply to Simon GlassCONFIG_CONSOLE_CURSOR, CONFIG_SYS_CONSOLE_BLINK_COUNT and CONFIG_CONSOLE_TIME are not used by any board. The implementation is not great and stands in the way of a refactor of i8042. Drop these for now. They can be re-introduced quite easily later, perhaps with driver model RTC support.
When reintroducing, it might be useful to make a few changes:
- Blink time would be more useful than blink count
- The confusing #ifdefs should be avoided
- The time functions should support driver model
- It would be best keyed off console_tstc() or some similar idle loop rather than a particular input driver (i8042 in this case)
---
README | 7 ----- drivers/input/i8042.c | 23 ---------------- drivers/video/cfb_console.c | 62 +++++++------------------------------------ include/configs/MPC8536DS.h | 1 - include/configs/MPC8544DS.h | 1 - include/configs/MPC8572DS.h | 1 - include/configs/MPC8641HPCN.h | 1 - 7 files changed, 9 insertions(+), 87 deletions(-)
README +0 -7
@@ -890,13 +890,6 @@ The following options need to be configured: (i.e. i8042_tstc) VIDEO_GETC_FCT get char fct (i.e. i8042_getc) - CONFIG_CONSOLE_CURSOR cursor drawing on/off - (requires blink timer - cf. i8042.c) - CONFIG_SYS_CONSOLE_BLINK_COUNT blink interval (cf. i8042.c) - CONFIG_CONSOLE_TIME display time/date info in - upper right corner - (requires CONFIG_CMD_DATE) CONFIG_VIDEO_LOGO display Linux logo in upper left corner CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead of
drivers/input/i8042.c +0 -23
@@ -17,12 +17,6 @@#define in8 (p) inb(p)#define out8 (p, v) outb(v, p) -#ifdef CONFIG_CONSOLE_CURSOR -extern void console_cursor (int state); -static int blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; -static int cursor_state; -#endif -/* locals */ static int kbd_input =-1 ;/* no input yet */
@@ -598,15 +592,6 @@ int i8042_tstc(struct stdio_dev *dev) {unsigned char scan_code =0 ; -#ifdef CONFIG_CONSOLE_CURSOR -if (--blink_count ==0 ) { - cursor_state ^=1 ; -console_cursor (cursor_state); - blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; -udelay (10 ); - } -#endif -if ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) {return 0 ; }else {
@@ -635,14 +620,6 @@ int i8042_getc(struct stdio_dev *dev)while (kbd_input ==-1 ) {while ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { -#ifdef CONFIG_CONSOLE_CURSOR -if (--blink_count ==0 ) { - cursor_state ^=1 ; -console_cursor (cursor_state); - blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; - } -udelay (10 ); -#endif } scan_code =in8 (I8042_DATA_REG );if (scan_code !=0xfa )
drivers/video/cfb_console.c +9 -53
107 lines not on this page · raw message
include/configs/MPC8536DS.h +0 -1
@@ -533,7 +533,6 @@#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_ATI_RADEON_FB #define CONFIG_VIDEO_LOGO -/*#define CONFIG_CONSOLE_CURSOR*/ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE3_IO_VIRT#endif
include/configs/MPC8544DS.h +0 -1
@@ -298,7 +298,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_ATI_RADEON_FB #define CONFIG_VIDEO_LOGO -/*#define CONFIG_CONSOLE_CURSOR*/ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET#endif
include/configs/MPC8572DS.h +0 -1
@@ -496,7 +496,6 @@#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_ATI_RADEON_FB #define CONFIG_VIDEO_LOGO -/*#define CONFIG_CONSOLE_CURSOR*/ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET#endif
include/configs/MPC8641HPCN.h +0 -1
@@ -404,7 +404,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_ATI_RADEON_FB #define CONFIG_VIDEO_LOGO -/*#define CONFIG_CONSOLE_CURSOR*/ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE2_IO_VIRT#endif
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 9/28 video: Drop unused console functions
Hi Simon,
Quoted 5 lines · Simon Glass
CONFIG_CONSOLE_CURSOR,CONFIG_SYS_CONSOLE_BLINK_COUNTandCONFIG_CONSOLE_TIMEare not used by any board. The implementation is not great and stands in the way of a refactor of i8042. Drop these for now. They can be re-introduced quite easily later, perhaps with driver model RTC support.
RTC?
Quoted 125 lines
When reintroducing, it might be useful to make a few changes:
- Blink time would be more useful than blink count
- The confusing #ifdefs should be avoided
- The time functions should support driver model
- It would be best keyed offconsole_tstc()or some similar idle loop rather than a particular input driver (i8042 in this case)Signed-off-by Simon Glass <[email protected]>---
README | 7 ----- drivers/input/i8042.c | 23 ---------------- drivers/video/cfb_console.c | 62 +++++++------------------------------------ include/configs/MPC8536DS.h | 1 - include/configs/MPC8544DS.h | 1 - include/configs/MPC8572DS.h | 1 - include/configs/MPC8641HPCN.h | 1 - 7 files changed, 9 insertions(+), 87 deletions(-)README +0
-7@@ -890,13 +890,6 @@ The following options need to be configured: (i.e. i8042_tstc) VIDEO_GETC_FCT get char fct (i.e. i8042_getc) - CONFIG_CONSOLE_CURSOR cursor drawing on/off - (requires blink timer - cf. i8042.c) - CONFIG_SYS_CONSOLE_BLINK_COUNT blink interval (cf. i8042.c) - CONFIG_CONSOLE_TIME display time/date info in - upper right corner - (requires CONFIG_CMD_DATE) CONFIG_VIDEO_LOGO display Linux logo in upper left corner CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead ofdrivers/input/i8042.c +0
-23@@ -17,12 +17,6 @@#define in8 (p) inb(p)#define out8 (p, v) outb(v, p) -#ifdef CONFIG_CONSOLE_CURSOR -extern void console_cursor (int state); -static int blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; -static int cursor_state; -#endif -/* locals */ static int kbd_input =-1 ;/* no input yet */ @@ -598,15 +592,6 @@ int i8042_tstc(struct stdio_dev *dev) {unsigned char scan_code =0 ; -#ifdef CONFIG_CONSOLE_CURSOR -if (--blink_count ==0 ) { - cursor_state ^=1 ; -console_cursor (cursor_state); - blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; -udelay (10 ); - } -#endif -if ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) {return 0 ; }else {@@ -635,14 +620,6 @@ int i8042_getc(struct stdio_dev *dev)while (kbd_input ==-1 ) {while ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { -#ifdef CONFIG_CONSOLE_CURSOR -if (--blink_count ==0 ) { - cursor_state ^=1 ; -console_cursor (cursor_state); - blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; - } -udelay (10 ); -#endif } scan_code =in8 (I8042_DATA_REG );if (scan_code !=0xfa )drivers/video/cfb_console.c +1
-13@@ -43,13 +43,6 @@* VIDEO_TSTC_FCT - keyboard_tstc function * VIDEO_GETC_FCT - keyboard_getc function * -* CONFIG_CONSOLE_CURSOR - on/off drawing cursor is done with -* delay loop in VIDEO_TSTC_FCT (i8042) -* -* CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate -* CONFIG_CONSOLE_TIME - display time/date in upper right -* corner, needs CONFIG_CMD_DATE and -* CONFIG_CONSOLE_CURSOR * CONFIG_VIDEO_LOGO - display Linux Logo in upper left corner. * Use CONFIG_SPLASH_SCREEN_ALIGN with * environment variable "splashpos" to place @@ -198,9 +191,6 @@/* * Cursor definition: -* CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/input/i8042.c) -* to let the cursor blink. Uses the macros -* CURSOR_OFF and CURSOR_ON. * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No * blinking is provided. Uses the macros CURSOR_SET * and CURSOR_OFF. @@ -210,42 +200,29 @@* must disable the hardware register of the graphic * chip. Otherwise a blinking field is displayed */ -#if !defined(CONFIG_CONSOLE_CURSOR ) && \ - !defined(CONFIG_VIDEO_SW_CURSOR ) && \ - !defined(CONFIG_VIDEO_HW_CURSOR ) +#if !defined(CONFIG_VIDEO_SW_CURSOR ) && !defined(CONFIG_VIDEO_HW_CURSOR )/* no Cursor defined */ #define CURSOR_ON #define CURSOR_OFF
drivers/video/cfb_console.c line 211
Quoted 10 lines
drivers/video/cfb_console.c +2
-5#define CURSOR_SET #endif -#if defined(CONFIG_CONSOLE_CURSOR ) || defined(CONFIG_VIDEO_SW_CURSOR ) -#if defined(CURSOR_ON ) || \ - (defined(CONFIG_CONSOLE_CURSOR ) && defined(CONFIG_VIDEO_SW_CURSOR )) -#error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \ - or CONFIG_VIDEO_HW_CURSOR can be defined +#if defined(CONFIG_VIDEO_SW_CURSOR ) +#if defined(CONFIG_VIDEO_HW_CURSOR )
#if defined(CURSOR_ON) || defined(CONFIG_VIDEO_HW_CURSOR) ?
Quoted 108 lines
drivers/video/cfb_console.c +6
-35+#error only one of CONFIG_VIDEO_SW_CURSOR or CONFIG_VIDEO_HW_CURSOR can be \ + defined#endif void console_cursor (int state);#define CURSOR_ON console_cursor(1)#define CURSOR_OFF console_cursor(0)#define CURSOR_SET video_set_cursor() -#endif /* CONFIG_CONSOLE_CURSOR || CONFIG_VIDEO_SW_CURSOR */ - -#ifdef CONFIG_CONSOLE_CURSOR -#ifndef CONFIG_CONSOLE_TIME -#error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME -#endif -#ifndef CONFIG_I8042_KBD -#warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c -#endif -#endif /* CONFIG_CONSOLE_CURSOR */ - +#endif /* CONFIG_VIDEO_SW_CURSOR */ #ifdef CONFIG_VIDEO_HW_CURSOR #ifdef CURSOR_ON -#error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \ - or CONFIG_VIDEO_HW_CURSOR can be defined +#error only one of CONFIG_VIDEO_SW_CURSOR or CONFIG_VIDEO_HW_CURSOR can be \ + defined#endif #define CURSOR_ON #define CURSOR_OFF @@ -626,7 +603,7 @@ static void video_putchar(int xx, int yy, unsigned char c)video_drawchars (xx, yy + video_logo_height, &c,1 ); } -#if defined(CONFIG_CONSOLE_CURSOR ) || defined(CONFIG_VIDEO_SW_CURSOR ) +#if defined(CONFIG_VIDEO_SW_CURSOR )static void video_set_cursor (void ) {if (cursor_state)@@ -651,27 +628,6 @@ static void video_invertchar(int xx, int yy)void console_cursor (int state) { -#ifdef CONFIG_CONSOLE_TIME -struct rtc_time tm; -char info[16 ]; - -/* time update only if cursor is on (faster scroll) */ -if (state) { -rtc_get (&tm); - -sprintf (info," %02d:%02d:%02d " , tm.tm_hour, tm.tm_min, - tm.tm_sec); -video_drawstring (VIDEO_VISIBLE_COLS -10 *VIDEO_FONT_WIDTH , -VIDEO_INFO_Y , (uchar *) info); - -sprintf (info,"%02d.%02d.%04d" , tm.tm_mday, tm.tm_mon, - tm.tm_year); -video_drawstring (VIDEO_VISIBLE_COLS -10 *VIDEO_FONT_WIDTH , -VIDEO_INFO_Y +1 *VIDEO_FONT_HEIGHT , - (uchar *) info); - } -#endif -if (cursor_state != state) {if (cursor_state) {/* turn off the cursor */ include/configs/MPC8536DS.h +0
-1@@ -533,7 +533,6 @@#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_ATI_RADEON_FB #define CONFIG_VIDEO_LOGO -/*#define CONFIG_CONSOLE_CURSOR*/ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE3_IO_VIRT#endif include/configs/MPC8544DS.h +0
-1@@ -298,7 +298,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_ATI_RADEON_FB #define CONFIG_VIDEO_LOGO -/*#define CONFIG_CONSOLE_CURSOR*/ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET#endif include/configs/MPC8572DS.h +0
-1@@ -496,7 +496,6 @@#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_ATI_RADEON_FB #define CONFIG_VIDEO_LOGO -/*#define CONFIG_CONSOLE_CURSOR*/ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET#endif include/configs/MPC8641HPCN.h +0
-0
include/configs/MPC8641HPCN.h extern unsigned long get_board_sys_clk(unsigned long dummy);
Quoted 8 lines
include/configs/MPC8641HPCN.h +0
-2@@ -404,7 +404,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_ATI_RADEON_FB #define CONFIG_VIDEO_LOGO -/*#define CONFIG_CONSOLE_CURSOR*/ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE2_IO_VIRT#endif --
Regards,
Bin
PATCH 9/28 video: Drop unused console functions
Hi Bin,
Quoted 10 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Simon Glass
CONFIG_CONSOLE_CURSOR,CONFIG_SYS_CONSOLE_BLINK_COUNTandCONFIG_CONSOLE_TIMEare not used by any board. The implementation is not great and stands in the way of a refactor of i8042. Drop these for now. They can be re-introduced quite easily later, perhaps with driver model RTC support.RTC?
Yes - they use the real-time clock for this feature.
Quoted 129 lines
Quoted 129 lines
When reintroducing, it might be useful to make a few changes:
- Blink time would be more useful than blink count
- The confusing #ifdefs should be avoided
- The time functions should support driver model
- It would be best keyed offconsole_tstc()or some similar idle loop rather than a particular input driver (i8042 in this case)Signed-off-by Simon Glass <[email protected]>---
README | 7 ----- drivers/input/i8042.c | 23 ---------------- drivers/video/cfb_console.c | 62 +++++++------------------------------------ include/configs/MPC8536DS.h | 1 - include/configs/MPC8544DS.h | 1 - include/configs/MPC8572DS.h | 1 - include/configs/MPC8641HPCN.h | 1 - 7 files changed, 9 insertions(+), 87 deletions(-)README +0
-7@@ -890,13 +890,6 @@ The following options need to be configured: (i.e. i8042_tstc) VIDEO_GETC_FCT get char fct (i.e. i8042_getc) - CONFIG_CONSOLE_CURSOR cursor drawing on/off - (requires blink timer - cf. i8042.c) - CONFIG_SYS_CONSOLE_BLINK_COUNT blink interval (cf. i8042.c) - CONFIG_CONSOLE_TIME display time/date info in - upper right corner - (requires CONFIG_CMD_DATE) CONFIG_VIDEO_LOGO display Linux logo in upper left corner CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead ofdrivers/input/i8042.c +0
-23@@ -17,12 +17,6 @@#define in8 (p) inb(p)#define out8 (p, v) outb(v, p) -#ifdef CONFIG_CONSOLE_CURSOR -extern void console_cursor (int state); -static int blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; -static int cursor_state; -#endif -/* locals */ static int kbd_input =-1 ;/* no input yet */ @@ -598,15 +592,6 @@ int i8042_tstc(struct stdio_dev *dev) {unsigned char scan_code =0 ; -#ifdef CONFIG_CONSOLE_CURSOR -if (--blink_count ==0 ) { - cursor_state ^=1 ; -console_cursor (cursor_state); - blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; -udelay (10 ); - } -#endif -if ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) {return 0 ; }else {@@ -635,14 +620,6 @@ int i8042_getc(struct stdio_dev *dev)while (kbd_input ==-1 ) {while ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { -#ifdef CONFIG_CONSOLE_CURSOR -if (--blink_count ==0 ) { - cursor_state ^=1 ; -console_cursor (cursor_state); - blink_count =CONFIG_SYS_CONSOLE_BLINK_COUNT ; - } -udelay (10 ); -#endif } scan_code =in8 (I8042_DATA_REG );if (scan_code !=0xfa )drivers/video/cfb_console.c +1
-13@@ -43,13 +43,6 @@* VIDEO_TSTC_FCT - keyboard_tstc function * VIDEO_GETC_FCT - keyboard_getc function * -* CONFIG_CONSOLE_CURSOR - on/off drawing cursor is done with -* delay loop in VIDEO_TSTC_FCT (i8042) -* -* CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate -* CONFIG_CONSOLE_TIME - display time/date in upper right -* corner, needs CONFIG_CMD_DATE and -* CONFIG_CONSOLE_CURSOR * CONFIG_VIDEO_LOGO - display Linux Logo in upper left corner. * Use CONFIG_SPLASH_SCREEN_ALIGN with * environment variable "splashpos" to place @@ -198,9 +191,6 @@/* * Cursor definition: -* CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/input/i8042.c) -* to let the cursor blink. Uses the macros -* CURSOR_OFF and CURSOR_ON. * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No * blinking is provided. Uses the macros CURSOR_SET * and CURSOR_OFF. @@ -210,42 +200,29 @@* must disable the hardware register of the graphic * chip. Otherwise a blinking field is displayed */ -#if !defined(CONFIG_CONSOLE_CURSOR ) && \ - !defined(CONFIG_VIDEO_SW_CURSOR ) && \ - !defined(CONFIG_VIDEO_HW_CURSOR ) +#if !defined(CONFIG_VIDEO_SW_CURSOR ) && !defined(CONFIG_VIDEO_HW_CURSOR )/* no Cursor defined */ #define CURSOR_ON #define CURSOR_OFF #define CURSOR_SET #endif
Quoted 9 lines
drivers/video/cfb_console.c line 211
Quoted 7 lines
drivers/video/cfb_console.c +2
-5-#if defined(CONFIG_CONSOLE_CURSOR ) || defined(CONFIG_VIDEO_SW_CURSOR ) -#if defined(CURSOR_ON ) || \ - (defined(CONFIG_CONSOLE_CURSOR ) && defined(CONFIG_VIDEO_SW_CURSOR )) -#error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \ - or CONFIG_VIDEO_HW_CURSOR can be defined +#if defined(CONFIG_VIDEO_SW_CURSOR ) +#if defined(CONFIG_VIDEO_HW_CURSOR )#if
defined(CURSOR_ON)||defined(CONFIG_VIDEO_HW_CURSOR)?
I don't think so, but the whole thing is quite confusing.
Regards,
Simon
PATCH 10/28 i8042: Use functions to handle register access
In reply to Simon GlassAt present the register access in kbd_reset() is quite primitive. This makes it hard to follow.
Create functions to read and write data, both to a single register, and via the command/data approach.
---
drivers/input/i8042.c | 75 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 31 deletions(-)
drivers/input/i8042.c +44 -31
@@ -446,53 +446,66 @@ static void kbd_conv_char(unsigned char scan_code)return ; } -static int kbd_reset (void ) +static int kbd_write (int reg,int value) { -u8 config; - -/* controller self test */ -if (kbd_input_empty () ==0 ) -return -1 ; -out8 (I8042_CMD_REG ,CMD_SELF_TEST ); -if (kbd_output_full () ==0 ) -return -1 ; -if (in8 (I8042_DATA_REG ) !=KBC_TEST_OK ) +if (!kbd_input_empty ())return -1 ; +out8 (reg, value); -/* keyboard reset */ -if (kbd_input_empty () ==0 ) +return 0 ; +} + +static int kbd_read (int reg) +{ +if (!kbd_output_full ())return -1 ; -out8 (I8042_DATA_REG ,CMD_RESET_KBD ); -if (kbd_output_full () ==0 ) + +return in8 (reg); +} + +static int kbd_cmd_read (int cmd) +{ +if (kbd_write (I8042_CMD_REG , cmd))return -1 ; -if (in8 (I8042_DATA_REG ) !=KBD_ACK ) + +return kbd_read (I8042_DATA_REG ); +} + +static int kbd_cmd_write (int cmd,int data) +{ +if (kbd_write (I8042_CMD_REG , cmd))return -1 ; -if (kbd_output_full () ==0 ) + +return kbd_write (I8042_DATA_REG , data); +} + +static int kbd_reset (void ) +{ +int config; + +/* controller self test */ +if (kbd_cmd_read (CMD_SELF_TEST ) !=KBC_TEST_OK )return -1 ; -if (in8 (I8042_DATA_REG ) !=KBD_POR ) + +/* keyboard reset */ +if (kbd_write (I8042_DATA_REG ,CMD_RESET_KBD ) || +kbd_read (I8042_DATA_REG ) !=KBD_ACK || +kbd_read (I8042_DATA_REG ) !=KBD_POR )return -1 ;/* set AT translation and disable irq */ -if (kbd_input_empty () ==0 ) -return -1 ; -out8 (I8042_CMD_REG ,CMD_RD_CONFIG ); -if (kbd_output_full () ==0 ) + config =kbd_cmd_read (CMD_RD_CONFIG ); +if (config ==-1 )return -1 ; - config =in8 (I8042_DATA_REG ); + config |=CONFIG_AT_TRANS ; config &= ~(CONFIG_KIRQ_EN |CONFIG_MIRQ_EN ); -if (kbd_input_empty () ==0 ) +if (kbd_cmd_write (CMD_WR_CONFIG , config))return -1 ; -out8 (I8042_CMD_REG ,CMD_WR_CONFIG ); -if (kbd_input_empty () ==0 ) -return -1 ; -out8 (I8042_DATA_REG , config);/* enable keyboard */ -if (kbd_input_empty () ==0 ) -return -1 ; -out8 (I8042_CMD_REG ,CMD_KBD_EN ); -if (kbd_input_empty () ==0 ) +if (kbd_write (I8042_CMD_REG ,CMD_KBD_EN ) || + !kbd_input_empty ())return -1 ;return 0 ;
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 10/28 i8042: Use functions to handle register access
Quoted 105 lines · Simon Glass
At present the register access in
kbd_reset()is quite primitive. This makes it hard to follow.Create functions to read and write data, both to a single register, and via the command/data approach.
Signed-off-by Simon Glass <[email protected]>---
drivers/input/i8042.c | 75 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 31 deletions(-)drivers/input/i8042.c +42
-27@@ -446,53 +446,66 @@ static void kbd_conv_char(unsigned char scan_code)return ; } -static int kbd_reset (void ) +static int kbd_write (int reg,int value) { -u8 config; - -/* controller self test */ -if (kbd_input_empty () ==0 ) -return -1 ; -out8 (I8042_CMD_REG ,CMD_SELF_TEST ); -if (kbd_output_full () ==0 ) -return -1 ; -if (in8 (I8042_DATA_REG ) !=KBC_TEST_OK ) +if (!kbd_input_empty ())return -1 ; +out8 (reg, value); -/* keyboard reset */ -if (kbd_input_empty () ==0 ) +return 0 ; +} + +static int kbd_read (int reg) +{ +if (!kbd_output_full ())return -1 ; -out8 (I8042_DATA_REG ,CMD_RESET_KBD ); -if (kbd_output_full () ==0 ) + +return in8 (reg); +} + +static int kbd_cmd_read (int cmd) +{ +if (kbd_write (I8042_CMD_REG , cmd))return -1 ; -if (in8 (I8042_DATA_REG ) !=KBD_ACK ) + +return kbd_read (I8042_DATA_REG ); +} + +static int kbd_cmd_write (int cmd,int data) +{ +if (kbd_write (I8042_CMD_REG , cmd))return -1 ; -if (kbd_output_full () ==0 ) + +return kbd_write (I8042_DATA_REG , data); +} + +static int kbd_reset (void ) +{ +int config; + +/* controller self test */ +if (kbd_cmd_read (CMD_SELF_TEST ) !=KBC_TEST_OK )return -1 ; -if (in8 (I8042_DATA_REG ) !=KBD_POR ) + +/* keyboard reset */ +if (kbd_write (I8042_DATA_REG ,CMD_RESET_KBD ) || +kbd_read (I8042_DATA_REG ) !=KBD_ACK || +kbd_read (I8042_DATA_REG ) !=KBD_POR )return -1 ;/* set AT translation and disable irq */ -if (kbd_input_empty () ==0 ) -return -1 ; -out8 (I8042_CMD_REG ,CMD_RD_CONFIG ); -if (kbd_output_full () ==0 ) + config =kbd_cmd_read (CMD_RD_CONFIG ); +if (config ==-1 )return -1 ; - config =in8 (I8042_DATA_REG ); + config |=CONFIG_AT_TRANS ; config &= ~(CONFIG_KIRQ_EN |CONFIG_MIRQ_EN ); -if (kbd_input_empty () ==0 ) +if (kbd_cmd_write (CMD_WR_CONFIG , config))return -1 ; -out8 (I8042_CMD_REG ,CMD_WR_CONFIG ); -if (kbd_input_empty () ==0 ) -return -1 ; -out8 (I8042_DATA_REG , config);/* enable keyboard */
drivers/input/i8042.c static void kbd_conv_char(unsigned char scan_code)
Quoted 10 lines
drivers/input/i8042.c +2
-5-if (kbd_input_empty () ==0 ) -return -1 ; -out8 (I8042_CMD_REG ,CMD_KBD_EN ); -if (kbd_input_empty () ==0 ) +if (kbd_write (I8042_CMD_REG ,CMD_KBD_EN ) || + !kbd_input_empty ())return -1 ;return 0 ; --
Tested on Intel Crown Bay and QEMU
PATCH 11/28 i8042: Handle a duplicate power-on-reset response
In reply to Simon GlassSometimes we seem to get 0xaa twice which causes the config read to fail. This causes chromebook_link to fail to set up the keyboard.
Add a check for this and read the config again when detected.
---
drivers/input/i8042.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/input/i8042.c +2 -0
@@ -497,6 +497,8 @@ static int kbd_reset(void) config =kbd_cmd_read (CMD_RD_CONFIG );if (config ==-1 )return -1 ; +else if (config ==KBD_POR )/* Sometimes get a second byte */ + config =kbd_cmd_read (CMD_RD_CONFIG ); config |=CONFIG_AT_TRANS ; config &= ~(CONFIG_KIRQ_EN |CONFIG_MIRQ_EN );
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 11/28 i8042: Handle a duplicate power-on-reset response
Hi Simon,
Quoted 16 lines · Simon Glass
Sometimes we seem to get
0xaatwice which causes the config read to fail. This causeschromebook_linkto fail to set up the keyboard.Add a check for this and read the config again when detected.
Signed-off-by Simon Glass <[email protected]>---
drivers/input/i8042.c | 2 ++ 1 file changed, 2 insertions(+)drivers/input/i8042.c +0
-0
drivers/input/i8042.c static int kbd_reset(void)
Quoted 9 lines
drivers/input/i8042.c +2
-1@@ -497,6 +497,8 @@ static int kbd_reset(void) config =kbd_cmd_read (CMD_RD_CONFIG );if (config ==-1 )return -1 ; +else if (config ==KBD_POR )/* Sometimes get a second byte */ + config =kbd_cmd_read (CMD_RD_CONFIG ); config |=CONFIG_AT_TRANS ; config &= ~(CONFIG_KIRQ_EN |CONFIG_MIRQ_EN ); --
This unfortunately breaks QEMU, that sometimes (not every time) keyboard is not working. Maybe we should create a device tree property to control such quirk?
Regards,
Bin
PATCH 12/28 i8042: Adjust kbd_reset() to collect all failures
In reply to Simon GlassRather than lots of 'return' statements, use goto to a single return.
---
drivers/input/i8042.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/input/i8042.c +8 -5
@@ -485,32 +485,35 @@ static int kbd_reset(void)/* controller self test */ if (kbd_cmd_read (CMD_SELF_TEST ) !=KBC_TEST_OK ) -return -1 ; + goto err;/* keyboard reset */ if (kbd_write (I8042_DATA_REG ,CMD_RESET_KBD ) ||kbd_read (I8042_DATA_REG ) !=KBD_ACK ||kbd_read (I8042_DATA_REG ) !=KBD_POR ) -return -1 ; + goto err;/* set AT translation and disable irq */ config =kbd_cmd_read (CMD_RD_CONFIG );if (config ==-1 ) -return -1 ; + goto err;else if (config ==KBD_POR )/* Sometimes get a second byte */ config =kbd_cmd_read (CMD_RD_CONFIG ); config |=CONFIG_AT_TRANS ; config &= ~(CONFIG_KIRQ_EN |CONFIG_MIRQ_EN );if (kbd_cmd_write (CMD_WR_CONFIG , config)) -return -1 ; + goto err;/* enable keyboard */ if (kbd_write (I8042_CMD_REG ,CMD_KBD_EN ) || !kbd_input_empty ()) -return -1 ; + goto err;return 0 ; +err: +debug ("%s: Keyboard failure\n" , __func__); +return -1 ; }static int kbd_controller_present (void )
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 12/28 i8042: Adjust kbd_reset() to collect all failures
Quoted 44 lines · Simon Glass
Rather than lots of 'return' statements, use goto to a single return.
Signed-off-by Simon Glass <[email protected]>---
drivers/input/i8042.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/input/i8042.c +4
-5@@ -485,32 +485,35 @@ static int kbd_reset(void)/* controller self test */ if (kbd_cmd_read (CMD_SELF_TEST ) !=KBC_TEST_OK ) -return -1 ; + goto err;/* keyboard reset */ if (kbd_write (I8042_DATA_REG ,CMD_RESET_KBD ) ||kbd_read (I8042_DATA_REG ) !=KBD_ACK ||kbd_read (I8042_DATA_REG ) !=KBD_POR ) -return -1 ; + goto err;/* set AT translation and disable irq */ config =kbd_cmd_read (CMD_RD_CONFIG );if (config ==-1 ) -return -1 ; + goto err;else if (config ==KBD_POR )/* Sometimes get a second byte */ config =kbd_cmd_read (CMD_RD_CONFIG ); config |=CONFIG_AT_TRANS ; config &= ~(CONFIG_KIRQ_EN |CONFIG_MIRQ_EN );if (kbd_cmd_write (CMD_WR_CONFIG , config)) -return -1 ; + goto err;/* enable keyboard */ if (kbd_write (I8042_CMD_REG ,CMD_KBD_EN ) || !kbd_input_empty ()) -return -1 ;
drivers/input/i8042.c static int kbd_reset(void)
Quoted 10 lines
drivers/input/i8042.c +4
-1+ goto err;return 0 ; +err: +debug ("%s: Keyboard failure\n" , __func__); +return -1 ; }static int kbd_controller_present (void ) --
PATCH 13/28 i8042: Adjust keyboard init to assume success
In reply to Simon GlassModify i8042_kbd_init() so that the normal pass is sucessful init and failure exits early. This will make the code easier to extend and is easier to read.
---
drivers/input/i8042.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/input/i8042.c +9 -10
@@ -587,18 +587,17 @@ int i8042_kbd_init(void) keymap =KBD_GER ; } -for (try =0 ; try <KBD_RESET_TRIES ; try++) { -if (kbd_reset () ==0 ) { - kbd_mapping = keymap; - kbd_flags =NORMAL ; - kbd_state =0 ; -kbd_led_set (); - -return 0 ; - } +for (try =0 ;kbd_reset () !=0 ; try++) { +if (try >=KBD_RESET_TRIES ) +return -1 ; } -return -1 ; + kbd_mapping = keymap; + kbd_flags =NORMAL ; + kbd_state =0 ; +kbd_led_set (); + +return 0 ; }/*
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 13/28 i8042: Adjust keyboard init to assume success
Quoted 33 lines · Simon Glass
Modify
i8042_kbd_init()so that the normal pass is sucessful init and failure exits early. This will make the code easier to extend and is easier to read.Signed-off-by Simon Glass <[email protected]>---
drivers/input/i8042.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)drivers/input/i8042.c +3
-10@@ -587,18 +587,17 @@ int i8042_kbd_init(void) keymap =KBD_GER ; } -for (try =0 ; try <KBD_RESET_TRIES ; try++) { -if (kbd_reset () ==0 ) { - kbd_mapping = keymap; - kbd_flags =NORMAL ; - kbd_state =0 ; -kbd_led_set (); - -return 0 ; - } +for (try =0 ;kbd_reset () !=0 ; try++) { +if (try >=KBD_RESET_TRIES ) +return -1 ; } -return -1 ;
drivers/input/i8042.c int i8042_kbd_init(void)
Quoted 10 lines
drivers/input/i8042.c +6
-1+ kbd_mapping = keymap; + kbd_flags =NORMAL ; + kbd_state =0 ; +kbd_led_set (); + +return 0 ; }/* --
PATCH 14/28 input: Correct keycode for Ctrl-Y
In reply to Simon GlassThis code is currently incorrect, perhaps due to a typo. Fix it.
---
drivers/input/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/input.c +1 -1
@@ -65,7 +65,7 @@ static unsigned char kbd_shift_xlate[] = {static unsigned char kbd_ctrl_xlate[] = {0xff ,0x1b ,'1' ,0x00 ,'3' ,'4' ,'5' ,0x1E ,'7' ,'8' ,'9' ,'0' ,0x1F ,'=' ,'\b' ,'\t' ,/* 0x00 - 0x0f */ -0x11 ,0x17 ,0x05 ,0x12 ,0x14 ,0x18 ,0x15 ,0x09 , +0x11 ,0x17 ,0x05 ,0x12 ,0x14 ,0x19 ,0x15 ,0x09 ,0x0f ,0x10 ,0x1b ,0x1d ,'\n' ,0xff ,0x01 ,0x13 ,/* 0x10 - 0x1f */ 0x04 ,0x06 ,0x08 ,0x09 ,0x0a ,0x0b ,0x0c ,';' ,'\'' ,'~' ,0x00 ,0x1c ,0x1a ,0x18 ,0x03 ,0x16 ,/* 0x20 - 0x2f */
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 15/28 input: Add a few more keyboard keycodes
In reply to Simon GlassThe slash and * are missing from the keycode tables. Add these so that these keypad keys can be used.
---
drivers/input/input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/input/input.c +3 -3
@@ -43,7 +43,7 @@ static const uchar kbd_plain_xlate[] = {'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ '2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff + '\r', 0xff, '/', '*', }; static unsigned char kbd_shift_xlate[] = {
@@ -59,7 +59,7 @@ static unsigned char kbd_shift_xlate[] = {'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ '2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff + '\r', 0xff, '/', '*', }; static unsigned char kbd_ctrl_xlate[] = {
@@ -75,7 +75,7 @@ static unsigned char kbd_ctrl_xlate[] = {'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ '2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff + '\r', 0xff, '/', '*', };/*
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 15/28 input: Add a few more keyboard keycodes
Quoted 1 line · Simon Glass
The slash and * are missing from the keycode tables. Add these so that
nits: there are two spaces before 'slash'
Quoted 31 lines
these keypad keys can be used.
Signed-off-by Simon Glass <[email protected]>---
drivers/input/input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/input/input.c +2
-2@@ -43,7 +43,7 @@ static const uchar kbd_plain_xlate[] = {'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ '2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff + '\r', 0xff, '/', '*', }; static unsigned char kbd_shift_xlate[] = {@@ -59,7 +59,7 @@ static unsigned char kbd_shift_xlate[] = {'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ '2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff + '\r', 0xff, '/', '*', }; static unsigned char kbd_ctrl_xlate[] = {
drivers/input/input.c static unsigned char kbd_ctrl_xlate[] = {
Quoted 9 lines
drivers/input/input.c +1
-2@@ -75,7 +75,7 @@ static unsigned char kbd_ctrl_xlate[] = {'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ '2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff + '\r', 0xff, '/', '*', };/* --
Regards,
Bin
PATCH 16/28 input: Add a function to add a keycode to the existing set
In reply to Simon GlassMost keyboards can be scanned to produce a list of the keycodes which are depressed. With the i8042 keyboard this scanning is done internally and only the processed results are returned.
In this case, when a key is pressed, a 'make' code is sent. When the key is released an 'unmake' code is sent. This means that the driver needs to keep track of which keys are pressed. It also means that any protocol error can lead to stuck keys.
In order to support this type of keyboard, add a function when can be used to provide a single keycode and either add it to the list of what is pressed or remove it from the list. Then the normal input_send_keycodes() function can be used to actually do the decoding work.
Add debugging to display the ASCII characters written to the input queue also.
---
drivers/input/input.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- include/input.h | 20 ++++++++++++++++++++ 2 files changed, 62 insertions(+), 4 deletions(-)
drivers/input/input.c +42 -4
@@ -107,6 +107,7 @@ static int input_queue_ascii(struct input_config *config, int ch)return -1 ;/* buffer full */ config->fifo_in++; } +debug (" {%02x} " , ch); config->fifo[config->fifo_in] = (uchar )ch;return 0 ;
@@ -394,8 +395,8 @@ static int input_keycodes_to_ascii(struct input_config *config,return ch_count; } -int input_send_keycodes (struct input_config *config, -int keycode[],int num_keycodes) +static int _input_send_keycodes (struct input_config *config,int keycode[], +int num_keycodes,bool do_send) {char ch[num_keycodes *ANSI_CHAR_MAX ];int count, i, same =0 ;
@@ -420,8 +421,10 @@ int input_send_keycodes(struct input_config *config, count =input_keycodes_to_ascii (config, keycode, num_keycodes, ch,sizeof (ch), is_repeat ?0 : same); -for (i =0 ; i < count; i++) -input_queue_ascii (config, ch[i]); +if (do_send) { +for (i =0 ; i < count; i++) +input_queue_ascii (config, ch[i]); + } delay_ms = is_repeat ? config->repeat_rate_ms : config->repeat_delay_ms;
@@ -431,6 +434,41 @@ int input_send_keycodes(struct input_config *config,return count; } +int input_send_keycodes (struct input_config *config,int keycode[], +int num_keycodes) +{ +return _input_send_keycodes (config, keycode, num_keycodes, true); +} + +int input_add_keycode (struct input_config *config,int new_keycode, +bool release) +{ +int keycode[INPUT_MAX_MODIFIERS +1 ]; +int count, i; + +/* Add the old keycodes which are not removed by this new one */ +for (i =0 , count =0 ; i < config->num_prev_keycodes; i++) { +int code = config->prev_keycodes[i]; + +if (new_keycode == code) { +if (release) +continue ; + new_keycode =-1 ; + } + keycode[count++] = code; + } + +if (!release && new_keycode !=-1 ) + keycode[count++] = new_keycode; +debug ("\ncodes for %02x/%d: " , new_keycode, release); +for (i =0 ; i < count; i++) +debug ("%02x " , keycode[i]); +debug ("\n" ); + +/* Don't output any ASCII characters if this is a key release */ +return _input_send_keycodes (config, keycode, count, !release); +} +int input_add_table (struct input_config *config,int left_keycode,int right_keycode,const uchar *xlate,int num_entries) {
include/input.h +20 -0
@@ -76,6 +76,26 @@ struct stdio_dev;int input_send_keycodes (struct input_config *config,int keycode[],int count);/** +* Add a new keycode to an existing list of keycodes +* +* This can be used to handle keyboards which do their own scanning. An +* internal list of depressed keys is maintained by the input library. Then +* this function is called to add a new key to the list (when a 'make code' is +* received), or remove a key (when a 'break code' is received). +* +* This function looks after maintenance of the list of active keys, and calls +* input_send_keycodes() with its updated list. +* +* @param config Input state +* @param new_keycode New keycode to add/remove +* @param release true if this key was released, false if depressed +* @return number of ascii characters sent, or 0 if none, or -1 for an +* internal error +*/ +int input_add_keycode (struct input_config *config,int new_keycode, +bool release); + +/** * Add a new key translation table to the input * * @param config Input state
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 17/28 input: Allow repeat filtering to be disabled
In reply to Simon GlassGenerally the input library handles processing of a list of scanned keys. Repeated keys need to be generated based on a timer in this case, since all that is provided is a list of keys current depressed.
Keyboards which do their own scanning will resend codes when they want to inject a repeating key. Provide a function which tells the input library to accept repeating keys and not to try to second-guess the caller.
---
drivers/input/input.c | 9 +++++++-- include/input.h | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-)
drivers/input/input.c +7 -2
@@ -413,8 +413,8 @@ static int _input_send_keycodes(struct input_config *config, int keycode[],* insert another character if we later realise that we * have missed a repeat slot. */ - is_repeat = config->repeat_rate_ms && - (int )get_timer (config->next_repeat_ms) >=0 ; + is_repeat = config->allow_repeats || (config->repeat_rate_ms && + (int )get_timer (config->next_repeat_ms) >=0 );if (!is_repeat)return 0 ; }
@@ -495,6 +495,11 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms, config->repeat_rate_ms = repeat_rate_ms; } +void input_allow_repeats (struct input_config *config,bool allow_repeats) +{ + config->allow_repeats = allow_repeats; +} +int input_add_tables (struct input_config *config) { input_add_table(config, -1, -1,
include/input.h +19 -0
@@ -57,6 +57,7 @@ struct input_config {* unknown */ int (*read_keys)(struct input_config *config); +bool allow_repeats;/* Don't filter out repeats */ unsigned int next_repeat_ms;/* Next time we repeat a key */ unsigned int repeat_delay_ms;/* Time before autorepeat starts */ unsigned int repeat_rate_ms;/* Autorepeat rate in ms */
@@ -143,6 +144,24 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms, int repeat_rate_ms);/** +* Tell the input layer whether to allow the caller to determine repeats +* +* Generally the input library handles processing of a list of scanned keys. +* Repeated keys need to be generated based on a timer in this case, since all +* that is provided is a list of keys current depressed. +* +* Keyboards which do their own scanning will resend codes when they want to +* inject a repeating key. This function can be called at start-up to select +* this behaviour. +* +* @param config Input state +* @param allow_repeats true to repeat depressed keys every time +* input_send_keycodes() is called, false to do normal +* keyboard repeat processing with a timer. +*/ +void input_allow_repeats (struct input_config *config,bool allow_repeats); + +/** * Set up the key map tables * * This must be called after input_init() or keycode decoding will not work.
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 17/28 input: Allow repeat filtering to be disabled
Applied to u-boot-dm.
PATCH 18/28 input: Support the German keymap
In reply to Simon GlassAdd support for the German keymap, taken from i8042.c. This can be selected when the input library it initialised.
---
board/kosagi/novena/novena.c | 2 +- drivers/input/cros_ec_keyb.c | 2 +- drivers/input/input.c | 82 ++++++++++++++++++++++++++++++++++++++++---- drivers/input/tegra-kbc.c | 2 +- include/input.h | 3 +- 5 files changed, 80 insertions(+), 11 deletions(-)
board/kosagi/novena/novena.c +1 -1
@@ -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);
drivers/input/cros_ec_keyb.c +1 -1
@@ -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" );
drivers/input/input.c +75 -7
95 lines not on this page · raw message
drivers/input/tegra-kbc.c +1 -1
@@ -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) {
include/input.h +2 -1
@@ -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.
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 18/28 input: Support the German keymap
Hi Simon,
Quoted 158 lines · Simon Glass
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 <[email protected]>---
board/kosagi/novena/novena.c | 2 +- drivers/input/cros_ec_keyb.c | 2 +- drivers/input/input.c | 82 ++++++++++++++++++++++++++++++++++++++++---- drivers/input/tegra-kbc.c | 2 +- include/input.h | 3 +- 5 files changed, 80 insertions(+), 11 deletions(-)board/kosagi/novena/novena.c +1
-1@@ -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);drivers/input/cros_ec_keyb.c +1
-1@@ -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" );drivers/input/input.c +75
-7@@ -78,6 +78,60 @@ 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 */ +}; +/* * Scan key code to ANSI 3.64 escape sequence table. This table is * incomplete in that it does not include all possible extra keys. @@ -500,14 +554,28 @@ 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) { -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)); +if (german) { +input_add_table (config,-1 ,-1 , + kbd_plain_xlate_german, +ARRAY_SIZE (kbd_plain_xlate_german)); +input_add_table (config,KEY_LEFTSHIFT ,KEY_RIGHTSHIFT , + kbd_shift_xlate_german, +ARRAY_SIZE (kbd_shift_xlate_german)); +input_add_table (config,KEY_LEFTCTRL ,KEY_RIGHTCTRL , + kbd_ctrl_xlate,ARRAY_SIZE (kbd_ctrl_xlate)); + }else { +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)); +input_add_table (config,-1 ,KEY_RIGHTALT , + kbd_right_alt_xlate_german, +ARRAY_SIZE (kbd_right_alt_xlate_german)); + }return 0 ; }drivers/input/tegra-kbc.c +1
-1@@ -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) {include/input.h +0
-0
include/input.h void input_allow_repeats(struct input_config *config, bool allow_repeats); · line 173
Quoted 8 lines
include/input.h +2
-1@@ -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);
Can we create some extensible parameter for keyboard layout? What if in the future we add a 3rd layout?
include/input.h void input_allow_repeats(struct input_config *config, bool allow_repeats);
Quoted 4 lines
include/input.h +0
-1/** * Set up the input handler with basic key maps. --
Regards,
Bin
PATCH 18/28 input: Support the German keymap
Hi Bin,
Quoted 164 lines · Bin Meng
Hi Simon,
Quoted 161 lines · Simon Glass
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 <[email protected]>---
board/kosagi/novena/novena.c | 2 +- drivers/input/cros_ec_keyb.c | 2 +- drivers/input/input.c | 82 ++++++++++++++++++++++++++++++++++++++++---- drivers/input/tegra-kbc.c | 2 +- include/input.h | 3 +- 5 files changed, 80 insertions(+), 11 deletions(-)board/kosagi/novena/novena.c +1
-1@@ -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);drivers/input/cros_ec_keyb.c +1
-1@@ -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" );drivers/input/input.c +75
-7@@ -78,6 +78,60 @@ 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 */ +}; +/* * Scan key code to ANSI 3.64 escape sequence table. This table is * incomplete in that it does not include all possible extra keys. @@ -500,14 +554,28 @@ 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) { -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)); +if (german) { +input_add_table (config,-1 ,-1 , + kbd_plain_xlate_german, +ARRAY_SIZE (kbd_plain_xlate_german)); +input_add_table (config,KEY_LEFTSHIFT ,KEY_RIGHTSHIFT , + kbd_shift_xlate_german, +ARRAY_SIZE (kbd_shift_xlate_german)); +input_add_table (config,KEY_LEFTCTRL ,KEY_RIGHTCTRL , + kbd_ctrl_xlate,ARRAY_SIZE (kbd_ctrl_xlate)); + }else { +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)); +input_add_table (config,-1 ,KEY_RIGHTALT , + kbd_right_alt_xlate_german, +ARRAY_SIZE (kbd_right_alt_xlate_german)); + }return 0 ; }drivers/input/tegra-kbc.c +1
-1@@ -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) {include/input.h +0
-0@@ -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
Quoted 8 lines
include/input.h void input_allow_repeats(struct input_config *config, bool allow_repeats); · line 173
Quoted 5 lines
include/input.h +2
-1+* @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);Can we create some extensible parameter for keyboard layout? What if in the future we add a 3rd layout?
We could, but U-Boot has been running for >10 years with only two. So I think that would be a premature feature. Keyboards are quite rare and the need for special characters in U-Boot is even rarer.
Regards,
Simon
PATCH 19/28 input: Adjust structure of code in process_modifier()
In reply to Simon GlassMove all the '!release' code into one block so that it is clear that it only applies on key release.
---
drivers/input/input.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/input/input.c +14 -13
@@ -208,7 +208,6 @@ static struct input_key_xlate *process_modifier(struct input_config *config, int key, int release) {struct input_key_xlate *table; -int flip =-1 ;int i;/* Start with the main table, and see what modifiers change it */
@@ -223,6 +222,8 @@ static struct input_key_xlate *process_modifier(struct input_config *config,/* Handle the lighted keys */ if (!release) { +int flip =-1 ; +switch (key) {case KEY_SCROLLLOCK : flip =FLAG_SCROLL_LOCK ;
@@ -234,19 +235,19 @@ static struct input_key_xlate *process_modifier(struct input_config *config, flip =FLAG_CAPS_LOCK ;break ; } - } -if (flip !=-1 ) { -int leds =0 ; - - config->leds ^= flip; -if (config->flags &FLAG_NUM_LOCK ) - leds |=INPUT_LED_NUM ; -if (config->flags &FLAG_CAPS_LOCK ) - leds |=INPUT_LED_CAPS ; -if (config->flags &FLAG_SCROLL_LOCK ) - leds |=INPUT_LED_SCROLL ; - config->leds = leds; +if (flip !=-1 ) { +int leds =0 ; + + config->leds ^= flip; +if (config->flags &FLAG_NUM_LOCK ) + leds |=INPUT_LED_NUM ; +if (config->flags &FLAG_CAPS_LOCK ) + leds |=INPUT_LED_CAPS ; +if (config->flags &FLAG_SCROLL_LOCK ) + leds |=INPUT_LED_SCROLL ; + config->leds = leds; + } }return table;
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 20/28 input: Handle caps lock
In reply to Simon GlassWhen caps lock is enabled we should convert lower case to upper case. Add this to the input key processing so that caps lock works correctly.
---
drivers/input/input.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/input/input.c +8 -5
@@ -424,16 +424,19 @@ static int input_keycodes_to_ascii(struct input_config *config,/* Start conversion by looking for the first new keycode (by same). */ for (i = same; i < num_keycodes; i++) {int key = keycode[i]; -int ch = (key < table->num_entries) ? table->xlate[key] :0xff ; +int ch;/* * For a normal key (with an ASCII value), add it; otherwise * translate special key to escape sequence if possible. */ -if (ch !=0xff ) { -if (ch_count < max_chars) - output_ch[ch_count] = (uchar )ch; - ch_count++; +if (key < table->num_entries) { + ch = table->xlate[key]; +if ((config->flags &FLAG_CAPS_LOCK ) && + ch >='a' && ch <='z' ) + ch -='a' -'A' ; +if (ch_count < max_chars && ch !=0xff ) + output_ch[ch_count++] = (uchar )ch; }else { ch_count +=input_keycode_to_ansi364 (config, key, output_ch, max_chars);
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 21/28 input: Allow updating of keyboard LEDs
In reply to Simon GlassAdd a function which returns a new keyboard LED value when the LEDs need updating.
---
drivers/input/input.c | 9 +++++++++ include/input.h | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
drivers/input/input.c +9 -0
@@ -247,6 +247,7 @@ static struct input_key_xlate *process_modifier(struct input_config *config,if (config->flags &FLAG_SCROLL_LOCK ) leds |=INPUT_LED_SCROLL ; config->leds = leds; + config->leds_changed = flip; } }
@@ -558,6 +559,14 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats) config->allow_repeats = allow_repeats; } +int input_leds_changed (struct input_config *config) +{ +if (config->leds_changed) +return config->leds; + +return -1 ; +} +int input_add_tables (struct input_config *config,bool german) {if (german) {
include/input.h +13 -1
@@ -43,7 +43,8 @@ struct input_config {/* Which modifiers are active (1 bit for each MOD_... value) */ uchar modifiers;uchar flags;/* active state keys (FLAGS_...) */ -uchar leds;/* active LEDS (INPUT_LED_...) */ +uchar leds;/* active LEDs (INPUT_LED_...) */ +uchar leds_changed;/* LEDs that just changed */ uchar num_tables;/* number of modifier tables */ int prev_keycodes[INPUT_BUFFER_LEN ];/* keys held last time */ int num_prev_keycodes;/* number of prev keys */
@@ -162,6 +163,17 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,void input_allow_repeats (struct input_config *config,bool allow_repeats);/** +* Check if keyboard LEDs need to be updated +* +* This can be called after input_tstc() to see if keyboard LEDs need +* updating. +* +* @param config Input state +* @return -1 if no LEDs need updating, other value if they do +*/ +int input_leds_changed (struct input_config *config); + +/** * Set up the key map tables * * This must be called after input_init() or keycode decoding will not work.
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 22/28 input: i8042: Convert to use the input library
In reply to Simon GlassAt present the i8042 driver has its own logic and keymaps. In an effort to unify the code, move it over to use the input library. This changes most of the keycode-processing logic since it is now in that library. The main responsibilities of the driver are now to handle the LEDs, deal with the PS/2 extended keycodes and initialise the the keyboard.
---
drivers/input/i8042.c | 491 +++++++------------------------------------------- 1 file changed, 70 insertions(+), 421 deletions(-)
drivers/input/i8042.c +70 -421
@@ -7,251 +7,18 @@/* i8042.c - Intel 8042 keyboard driver routines */ -/* includes */ -#include <common.h> -#include <asm/io.h> #include <i8042.h> +#include <input.h> +#include <asm/io.h> /* defines */ #define in8 (p) inb(p)#define out8 (p, v) outb(v, p)/* locals */ - -static int kbd_input =-1 ;/* no input yet */ -static int kbd_mapping =KBD_US ;/* default US keyboard */ -static int kbd_flags =NORMAL ;/* after reset */ -static int kbd_state;/* unshift code */ - -static unsigned char kbd_fct_map[144 ] = { -/* kbd_fct_map table for scan code */ -0 ,AS ,AS ,AS ,AS ,AS ,AS ,AS ,/* scan 00-07 */ -AS ,AS ,AS ,AS ,AS ,AS ,AS ,AS ,/* scan 08-0F */ -AS ,AS ,AS ,AS ,AS ,AS ,AS ,AS ,/* scan 10-17 */ -AS ,AS ,AS ,AS ,AS ,CN ,AS ,AS ,/* scan 18-1F */ -AS ,AS ,AS ,AS ,AS ,AS ,AS ,AS ,/* scan 20-27 */ -AS ,AS ,SH ,AS ,AS ,AS ,AS ,AS ,/* scan 28-2F */ -AS ,AS ,AS ,AS ,AS ,AS ,SH ,AS ,/* scan 30-37 */ -AS ,AS ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,ES ,/* scan 40-47 */ -ES ,ES ,ES ,ES ,ES ,ES ,ES ,ES ,/* scan 48-4F */ -ES ,ES ,ES ,ES ,0 ,0 ,AS ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -AS ,0 ,0 ,AS ,0 ,0 ,AS ,0 ,/* scan 70-77 */ -0 ,AS ,0 ,0 ,0 ,AS ,0 ,0 ,/* scan 78-7F */ -AS ,CN ,AS ,AS ,AK ,ST ,EX ,EX ,/* enhanced */ -AS ,EX ,EX ,AS ,EX ,AS ,EX ,EX /* enhanced */ - }; - -static unsigned char kbd_key_map[2 ][5 ][144 ] = { - {/* US keyboard */ - {/* unshift code */ -0 ,0x1b ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,/* scan 00-07 */ -'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,0x08 ,'\t' ,/* scan 08-0F */ -'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,/* scan 10-17 */ -'o' ,'p' ,'[' ,']' ,'\r' ,CN ,'a' ,'s' ,/* scan 18-1F */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,/* scan 20-27 */ -'\'' ,'`' ,SH ,'\\' ,'z' ,'x' ,'c' ,'v' ,/* scan 28-2F */ -'b' ,'n' ,'m' ,',' ,'.' ,'/' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'7' ,/* scan 40-47 */ -'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* scan 48-4F */ -'2' ,'3' ,'0' ,'.' ,0 ,0 ,0 ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* shift code */ -0 ,0x1b ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,/* scan 00-07 */ -'&' ,'*' ,'(' ,')' ,'_' ,'+' ,0x08 ,'\t' ,/* scan 08-0F */ -'Q' ,'W' ,'E' ,'R' ,'T' ,'Y' ,'U' ,'I' ,/* scan 10-17 */ -'O' ,'P' ,'{' ,'}' ,'\r' ,CN ,'A' ,'S' ,/* scan 18-1F */ -'D' ,'F' ,'G' ,'H' ,'J' ,'K' ,'L' ,':' ,/* scan 20-27 */ -'"' ,'~' ,SH ,'|' ,'Z' ,'X' ,'C' ,'V' ,/* scan 28-2F */ -'B' ,'N' ,'M' ,'<' ,'>' ,'?' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'7' ,/* scan 40-47 */ -'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* scan 48-4F */ -'2' ,'3' ,'0' ,'.' ,0 ,0 ,0 ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* control code */ -0xff ,0x1b ,0xff ,0x00 ,0xff ,0xff ,0xff ,0xff ,/* scan 00-07 */ -0x1e ,0xff ,0xff ,0xff ,0x1f ,0xff ,0xff ,'\t' ,/* scan 08-0F */ -0x11 ,0x17 ,0x05 ,0x12 ,0x14 ,0x19 ,0x15 ,0x09 ,/* scan 10-17 */ -0x0f ,0x10 ,0x1b ,0x1d ,'\r' ,CN ,0x01 ,0x13 ,/* scan 18-1F */ -0x04 ,0x06 ,0x07 ,0x08 ,0x0a ,0x0b ,0x0c ,0xff ,/* scan 20-27 */ -0xff ,0x1c ,SH ,0xff ,0x1a ,0x18 ,0x03 ,0x16 ,/* scan 28-2F */ -0x02 ,0x0e ,0x0d ,0xff ,0xff ,0xff ,SH ,0xff ,/* scan 30-37 */ -0xff ,0xff ,CP ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 38-3F */ -0xff ,0xff ,0xff ,0xff ,0xff ,NM ,ST ,0xff ,/* scan 40-47 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 48-4F */ -0xff ,0xff ,0xff ,0xff ,0xff ,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' ,CN ,'/' ,'*' ,' ' ,ST ,0xff ,0xff ,/* extended */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff /* extended */ - }, - {/* non numeric code */ -0 ,0x1b ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,/* scan 00-07 */ -'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,0x08 ,'\t' ,/* scan 08-0F */ -'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,/* scan 10-17 */ -'o' ,'p' ,'[' ,']' ,'\r' ,CN ,'a' ,'s' ,/* scan 18-1F */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,/* scan 20-27 */ -'\'' ,'`' ,SH ,'\\' ,'z' ,'x' ,'c' ,'v' ,/* scan 28-2F */ -'b' ,'n' ,'m' ,',' ,'.' ,'/' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'w' ,/* scan 40-47 */ -'x' ,'y' ,'l' ,'t' ,'u' ,'v' ,'m' ,'q' ,/* scan 48-4F */ -'r' ,'s' ,'p' ,'n' ,0 ,0 ,0 ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* right alt mode - not used in US keyboard */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 00-07 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 08-0F */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 10-17 */ -0xff ,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 ,0xff ,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 ,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 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* extended */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff /* extended */ - } - }, - {/* German keyboard */ - {/* unshift code */ -0 ,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' ,CN ,'a' ,'s' ,/* scan 18-1F */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,0x94 ,/* scan 20-27 */ -0x84 ,'^' ,SH ,'#' ,'y' ,'x' ,'c' ,'v' ,/* scan 28-2F */ -'b' ,'n' ,'m' ,',' ,'.' ,'-' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'7' ,/* scan 40-47 */ -'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* scan 48-4F */ -'2' ,'3' ,'0' ,',' ,0 ,0 ,'<' ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* shift code */ -0 ,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' ,CN ,'A' ,'S' ,/* scan 18-1F */ -'D' ,'F' ,'G' ,'H' ,'J' ,'K' ,'L' ,0x99 ,/* scan 20-27 */ -0x8e ,0xf8 ,SH ,'\'' ,'Y' ,'X' ,'C' ,'V' ,/* scan 28-2F */ -'B' ,'N' ,'M' ,';' ,':' ,'_' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'7' ,/* scan 40-47 */ -'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* scan 48-4F */ -'2' ,'3' ,'0' ,',' ,0 ,0 ,'>' ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* control code */ -0xff ,0x1b ,0xff ,0x00 ,0xff ,0xff ,0xff ,0xff ,/* scan 00-07 */ -0x1e ,0xff ,0xff ,0xff ,0x1f ,0xff ,0xff ,'\t' ,/* scan 08-0F */ -0x11 ,0x17 ,0x05 ,0x12 ,0x14 ,0x19 ,0x15 ,0x09 ,/* scan 10-17 */ -0x0f ,0x10 ,0x1b ,0x1d ,'\r' ,CN ,0x01 ,0x13 ,/* scan 18-1F */ -0x04 ,0x06 ,0x07 ,0x08 ,0x0a ,0x0b ,0x0c ,0xff ,/* scan 20-27 */ -0xff ,0x1c ,SH ,0xff ,0x1a ,0x18 ,0x03 ,0x16 ,/* scan 28-2F */ -0x02 ,0x0e ,0x0d ,0xff ,0xff ,0xff ,SH ,0xff ,/* scan 30-37 */ -0xff ,0xff ,CP ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 38-3F */ -0xff ,0xff ,0xff ,0xff ,0xff ,NM ,ST ,0xff ,/* scan 40-47 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 48-4F */ -0xff ,0xff ,0xff ,0xff ,0xff ,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' ,CN ,'/' ,'*' ,' ' ,ST ,0xff ,0xff ,/* extended */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff /* extended */ - }, - {/* non numeric code */ -0 ,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' ,CN ,'a' ,'s' ,/* scan 18-1F */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,0x94 ,/* scan 20-27 */ -0x84 ,'^' ,SH ,0 ,'y' ,'x' ,'c' ,'v' ,/* scan 28-2F */ -'b' ,'n' ,'m' ,',' ,'.' ,'-' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'w' ,/* scan 40-47 */ -'x' ,'y' ,'l' ,'t' ,'u' ,'v' ,'m' ,'q' ,/* scan 48-4F */ -'r' ,'s' ,'p' ,'n' ,0 ,0 ,'<' ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* right alt mode - is used in German keyboard */ -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 */ -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 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* extended */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff /* extended */ - } - } - }; +static struct input_config config; +static bool extended;static unsigned char ext_key_map[] = {0x1c ,/* keypad enter */
@@ -293,157 +60,12 @@ static int kbd_output_full(void)return kbd_timeout !=-1 ; } -static void kbd_led_set (void ) +static void kbd_led_set (int flags) {kbd_input_empty ();out8 (I8042_DATA_REG ,CMD_SET_KBD_LED );kbd_input_empty (); -out8 (I8042_DATA_REG , (kbd_flags &0x7 )); -} - -static void kbd_normal (unsigned char scan_code) -{ -unsigned char chr; - -if ((kbd_flags &BRK ) ==NORMAL ) { - chr = kbd_key_map[kbd_mapping][kbd_state][scan_code]; -if ((chr ==0xff ) || (chr ==0x00 )) -return ; - -/* if caps lock convert upper to lower */ -if (((kbd_flags &CAPS ) ==CAPS ) && - (chr >='a' && chr <='z' )) { - chr -='a' -'A' ; - } - kbd_input = chr; - } -} - -static void kbd_shift (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==BRK ) { - kbd_state =AS ; - kbd_flags &= (~SHIFT ); - }else { - kbd_state =SH ; - kbd_flags |=SHIFT ; - } -} - -static void kbd_ctrl (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==BRK ) { - kbd_state =AS ; - kbd_flags &= (~CTRL ); - }else { - kbd_state =CN ; - kbd_flags |=CTRL ; - } -} - -static void kbd_num (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==NORMAL ) { - kbd_flags ^=NUM ; - kbd_state = (kbd_flags &NUM ) ?AS :NM ; -kbd_led_set (); - } -} - -static void kbd_alt (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==BRK ) { - kbd_state =AS ; - kbd_flags &= (~ALT ); - }else { - kbd_state =AK ; - kbd_flags &=ALT ; - } -} - -static void kbd_caps (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==NORMAL ) { - kbd_flags ^=CAPS ; -kbd_led_set (); - } -} - -static void kbd_scroll (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==NORMAL ) { - kbd_flags ^=STP ; -kbd_led_set (); -if (kbd_flags &STP ) - kbd_input =0x13 ; -else - kbd_input =0x11 ; - } -} - -static void kbd_conv_char (unsigned char scan_code) -{ -if (scan_code ==0xe0 ) { - kbd_flags |=EXT ; -return ; - } - -/* if high bit of scan_code, set break flag */ -if (scan_code &0x80 ) - kbd_flags |=BRK ; -else - kbd_flags &= ~BRK ; - -if ((scan_code ==0xe1 ) || (kbd_flags &E1 )) { -if (scan_code ==0xe1 ) { - kbd_flags ^=BRK ;/* reset the break flag */ - kbd_flags ^=E1 ;/* bitwise EXOR with E1 flag */ - } -return ; - } - - scan_code &=0x7f ; - -if (kbd_flags &EXT ) { -int i; - - kbd_flags ^=EXT ; -for (i =0 ; ext_key_map[i]; i++) { -if (ext_key_map[i] == scan_code) { - scan_code =0x80 + i; -break ; - } - } -/* not found ? */ -if (!ext_key_map[i]) -return ; - } - -switch (kbd_fct_map[scan_code]) { -case AS : -kbd_normal (scan_code); -break ; -case SH : -kbd_shift (scan_code); -break ; -case CN : -kbd_ctrl (scan_code); -break ; -case NM : -kbd_num (scan_code); -break ; -case AK : -kbd_alt (scan_code); -break ; -case CP : -kbd_caps (scan_code); -break ; -case ST : -kbd_scroll (scan_code); -break ; - } - -return ; +out8 (I8042_DATA_REG , flags &0x7 ); }static int kbd_write (int reg,int value)
@@ -568,11 +190,50 @@ int i8042_disable(void)return 0 ; } +static int i8042_kbd_check (struct input_config *input) +{ +if ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { +return 0 ; + }else { +bool release = false; +int scan_code; +int i; + + scan_code =in8 (I8042_DATA_REG ); +if (scan_code ==0xfa ) { +return 0 ; + }else if (scan_code ==0xe0 ) { + extended = true; +return 0 ; + } +if (scan_code &0x80 ) { + scan_code &=0x7f ; + release = true; + } +if (extended) { + extended = false; +for (i =0 ; ext_key_map[i]; i++) { +if (ext_key_map[i] == scan_code) { + scan_code =0x60 + i; +break ; + } + } +/* not found ? */ +if (!ext_key_map[i]) +return 0 ; + } + +input_add_keycode (&config, scan_code, release); +return 1 ; + } +} +/* i8042_kbd_init - reset keyboard and init state flags */ int i8042_kbd_init (void ) {int keymap, try;char *penv; +int ret;if (!kbd_controller_present () ||board_i8042_skip ()) {debug ("i8042 keyboard controller is not present\n" );
@@ -592,58 +253,46 @@ int i8042_kbd_init(void)return -1 ; } - kbd_mapping = keymap; - kbd_flags =NORMAL ; - kbd_state =0 ; -kbd_led_set (); + ret =input_init (&config,0 , keymap ==KBD_GER ); +if (ret) +return ret; + config.read_keys = i8042_kbd_check; +input_allow_repeats (&config, true); + +kbd_led_set (NORMAL );return 0 ; } -/* -* i8042_tstc - test if keyboard input is available +/** +* check_leds() - Check the keyboard LEDs and update them it needed * -* option: cursor blinking if called in a loop +* @ret: Value to return +* @return value of @ret */ -int i8042_tstc (struct stdio_dev *dev) +static int check_leds (int ret) { -unsigned char scan_code =0 ; +int leds; -if ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { -return 0 ; - }else { - scan_code =in8 (I8042_DATA_REG ); -if (scan_code ==0xfa ) -return 0 ; - -kbd_conv_char (scan_code); + leds =input_leds_changed (&config); +if (leds >=0 ) +kbd_led_set (leds); -if (kbd_input !=-1 ) -return 1 ; - } +return ret; +} -return 0 ; +/* +* i8042_tstc - test if keyboard input is available +*/ +int i8042_tstc (struct stdio_dev *dev) +{ +return check_leds (input_tstc (&config)); }/* * i8042_getc - wait till keyboard input is available -* -* option: turn on/off cursor while waiting */ int i8042_getc (struct stdio_dev *dev) { -int ret_chr; -unsigned char scan_code; - -while (kbd_input ==-1 ) { -while ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { - } - scan_code =in8 (I8042_DATA_REG ); -if (scan_code !=0xfa ) -kbd_conv_char (scan_code); - } - ret_chr = kbd_input; - kbd_input =-1 ; - -return ret_chr; +return check_leds (input_getc (&config)); }
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 22/28 input: i8042: Convert to use the input library
Hi Simon,
Quoted 484 lines · Simon Glass
At present the i8042 driver has its own logic and keymaps. In an effort to unify the code, move it over to use the input library. This changes most of the keycode-processing logic since it is now in that library. The main responsibilities of the driver are now to handle the LEDs, deal with the PS/2 extended keycodes and initialise the the keyboard.
Signed-off-by Simon Glass <[email protected]>---
drivers/input/i8042.c | 491 +++++++------------------------------------------- 1 file changed, 70 insertions(+), 421 deletions(-)drivers/input/i8042.c +45
-384@@ -7,251 +7,18 @@/* i8042.c - Intel 8042 keyboard driver routines */ -/* includes */ -#include <common.h> -#include <asm/io.h> #include <i8042.h> +#include <input.h> +#include <asm/io.h> /* defines */ #define in8 (p) inb(p)#define out8 (p, v) outb(v, p)/* locals */ - -static int kbd_input =-1 ;/* no input yet */ -static int kbd_mapping =KBD_US ;/* default US keyboard */ -static int kbd_flags =NORMAL ;/* after reset */ -static int kbd_state;/* unshift code */ - -static unsigned char kbd_fct_map[144 ] = { -/* kbd_fct_map table for scan code */ -0 ,AS ,AS ,AS ,AS ,AS ,AS ,AS ,/* scan 00-07 */ -AS ,AS ,AS ,AS ,AS ,AS ,AS ,AS ,/* scan 08-0F */ -AS ,AS ,AS ,AS ,AS ,AS ,AS ,AS ,/* scan 10-17 */ -AS ,AS ,AS ,AS ,AS ,CN ,AS ,AS ,/* scan 18-1F */ -AS ,AS ,AS ,AS ,AS ,AS ,AS ,AS ,/* scan 20-27 */ -AS ,AS ,SH ,AS ,AS ,AS ,AS ,AS ,/* scan 28-2F */ -AS ,AS ,AS ,AS ,AS ,AS ,SH ,AS ,/* scan 30-37 */ -AS ,AS ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,ES ,/* scan 40-47 */ -ES ,ES ,ES ,ES ,ES ,ES ,ES ,ES ,/* scan 48-4F */ -ES ,ES ,ES ,ES ,0 ,0 ,AS ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -AS ,0 ,0 ,AS ,0 ,0 ,AS ,0 ,/* scan 70-77 */ -0 ,AS ,0 ,0 ,0 ,AS ,0 ,0 ,/* scan 78-7F */ -AS ,CN ,AS ,AS ,AK ,ST ,EX ,EX ,/* enhanced */ -AS ,EX ,EX ,AS ,EX ,AS ,EX ,EX /* enhanced */ - }; - -static unsigned char kbd_key_map[2 ][5 ][144 ] = { - {/* US keyboard */ - {/* unshift code */ -0 ,0x1b ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,/* scan 00-07 */ -'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,0x08 ,'\t' ,/* scan 08-0F */ -'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,/* scan 10-17 */ -'o' ,'p' ,'[' ,']' ,'\r' ,CN ,'a' ,'s' ,/* scan 18-1F */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,/* scan 20-27 */ -'\'' ,'`' ,SH ,'\\' ,'z' ,'x' ,'c' ,'v' ,/* scan 28-2F */ -'b' ,'n' ,'m' ,',' ,'.' ,'/' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'7' ,/* scan 40-47 */ -'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* scan 48-4F */ -'2' ,'3' ,'0' ,'.' ,0 ,0 ,0 ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* shift code */ -0 ,0x1b ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,/* scan 00-07 */ -'&' ,'*' ,'(' ,')' ,'_' ,'+' ,0x08 ,'\t' ,/* scan 08-0F */ -'Q' ,'W' ,'E' ,'R' ,'T' ,'Y' ,'U' ,'I' ,/* scan 10-17 */ -'O' ,'P' ,'{' ,'}' ,'\r' ,CN ,'A' ,'S' ,/* scan 18-1F */ -'D' ,'F' ,'G' ,'H' ,'J' ,'K' ,'L' ,':' ,/* scan 20-27 */ -'"' ,'~' ,SH ,'|' ,'Z' ,'X' ,'C' ,'V' ,/* scan 28-2F */ -'B' ,'N' ,'M' ,'<' ,'>' ,'?' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'7' ,/* scan 40-47 */ -'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* scan 48-4F */ -'2' ,'3' ,'0' ,'.' ,0 ,0 ,0 ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* control code */ -0xff ,0x1b ,0xff ,0x00 ,0xff ,0xff ,0xff ,0xff ,/* scan 00-07 */ -0x1e ,0xff ,0xff ,0xff ,0x1f ,0xff ,0xff ,'\t' ,/* scan 08-0F */ -0x11 ,0x17 ,0x05 ,0x12 ,0x14 ,0x19 ,0x15 ,0x09 ,/* scan 10-17 */ -0x0f ,0x10 ,0x1b ,0x1d ,'\r' ,CN ,0x01 ,0x13 ,/* scan 18-1F */ -0x04 ,0x06 ,0x07 ,0x08 ,0x0a ,0x0b ,0x0c ,0xff ,/* scan 20-27 */ -0xff ,0x1c ,SH ,0xff ,0x1a ,0x18 ,0x03 ,0x16 ,/* scan 28-2F */ -0x02 ,0x0e ,0x0d ,0xff ,0xff ,0xff ,SH ,0xff ,/* scan 30-37 */ -0xff ,0xff ,CP ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 38-3F */ -0xff ,0xff ,0xff ,0xff ,0xff ,NM ,ST ,0xff ,/* scan 40-47 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 48-4F */ -0xff ,0xff ,0xff ,0xff ,0xff ,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' ,CN ,'/' ,'*' ,' ' ,ST ,0xff ,0xff ,/* extended */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff /* extended */ - }, - {/* non numeric code */ -0 ,0x1b ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,/* scan 00-07 */ -'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,0x08 ,'\t' ,/* scan 08-0F */ -'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,/* scan 10-17 */ -'o' ,'p' ,'[' ,']' ,'\r' ,CN ,'a' ,'s' ,/* scan 18-1F */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,/* scan 20-27 */ -'\'' ,'`' ,SH ,'\\' ,'z' ,'x' ,'c' ,'v' ,/* scan 28-2F */ -'b' ,'n' ,'m' ,',' ,'.' ,'/' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'w' ,/* scan 40-47 */ -'x' ,'y' ,'l' ,'t' ,'u' ,'v' ,'m' ,'q' ,/* scan 48-4F */ -'r' ,'s' ,'p' ,'n' ,0 ,0 ,0 ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* right alt mode - not used in US keyboard */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 00-07 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 08-0F */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 10-17 */ -0xff ,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 ,0xff ,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 ,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 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* extended */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff /* extended */ - } - }, - {/* German keyboard */ - {/* unshift code */ -0 ,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' ,CN ,'a' ,'s' ,/* scan 18-1F */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,0x94 ,/* scan 20-27 */ -0x84 ,'^' ,SH ,'#' ,'y' ,'x' ,'c' ,'v' ,/* scan 28-2F */ -'b' ,'n' ,'m' ,',' ,'.' ,'-' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'7' ,/* scan 40-47 */ -'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* scan 48-4F */ -'2' ,'3' ,'0' ,',' ,0 ,0 ,'<' ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* shift code */ -0 ,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' ,CN ,'A' ,'S' ,/* scan 18-1F */ -'D' ,'F' ,'G' ,'H' ,'J' ,'K' ,'L' ,0x99 ,/* scan 20-27 */ -0x8e ,0xf8 ,SH ,'\'' ,'Y' ,'X' ,'C' ,'V' ,/* scan 28-2F */ -'B' ,'N' ,'M' ,';' ,':' ,'_' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'7' ,/* scan 40-47 */ -'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* scan 48-4F */ -'2' ,'3' ,'0' ,',' ,0 ,0 ,'>' ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* control code */ -0xff ,0x1b ,0xff ,0x00 ,0xff ,0xff ,0xff ,0xff ,/* scan 00-07 */ -0x1e ,0xff ,0xff ,0xff ,0x1f ,0xff ,0xff ,'\t' ,/* scan 08-0F */ -0x11 ,0x17 ,0x05 ,0x12 ,0x14 ,0x19 ,0x15 ,0x09 ,/* scan 10-17 */ -0x0f ,0x10 ,0x1b ,0x1d ,'\r' ,CN ,0x01 ,0x13 ,/* scan 18-1F */ -0x04 ,0x06 ,0x07 ,0x08 ,0x0a ,0x0b ,0x0c ,0xff ,/* scan 20-27 */ -0xff ,0x1c ,SH ,0xff ,0x1a ,0x18 ,0x03 ,0x16 ,/* scan 28-2F */ -0x02 ,0x0e ,0x0d ,0xff ,0xff ,0xff ,SH ,0xff ,/* scan 30-37 */ -0xff ,0xff ,CP ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 38-3F */ -0xff ,0xff ,0xff ,0xff ,0xff ,NM ,ST ,0xff ,/* scan 40-47 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* scan 48-4F */ -0xff ,0xff ,0xff ,0xff ,0xff ,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' ,CN ,'/' ,'*' ,' ' ,ST ,0xff ,0xff ,/* extended */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff /* extended */ - }, - {/* non numeric code */ -0 ,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' ,CN ,'a' ,'s' ,/* scan 18-1F */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,0x94 ,/* scan 20-27 */ -0x84 ,'^' ,SH ,0 ,'y' ,'x' ,'c' ,'v' ,/* scan 28-2F */ -'b' ,'n' ,'m' ,',' ,'.' ,'-' ,SH ,'*' ,/* scan 30-37 */ -' ' ,' ' ,CP ,0 ,0 ,0 ,0 ,0 ,/* scan 38-3F */ -0 ,0 ,0 ,0 ,0 ,NM ,ST ,'w' ,/* scan 40-47 */ -'x' ,'y' ,'l' ,'t' ,'u' ,'v' ,'m' ,'q' ,/* scan 48-4F */ -'r' ,'s' ,'p' ,'n' ,0 ,0 ,'<' ,0 ,/* scan 50-57 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 58-5F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 60-67 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 68-6F */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 70-77 */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* scan 78-7F */ -'\r' ,CN ,'/' ,'*' ,' ' ,ST ,'F' ,'A' ,/* extended */ -0 ,'D' ,'C' ,0 ,'B' ,0 ,'@' ,'P' /* extended */ - }, - {/* right alt mode - is used in German keyboard */ -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 */ -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 */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* extended */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff /* extended */ - } - } - }; +static struct input_config config; +static bool extended;static unsigned char ext_key_map[] = {0x1c ,/* keypad enter */ @@ -293,157 +60,12 @@ static int kbd_output_full(void)return kbd_timeout !=-1 ; } -static void kbd_led_set (void ) +static void kbd_led_set (int flags) {kbd_input_empty ();out8 (I8042_DATA_REG ,CMD_SET_KBD_LED );kbd_input_empty (); -out8 (I8042_DATA_REG , (kbd_flags &0x7 )); -} - -static void kbd_normal (unsigned char scan_code) -{ -unsigned char chr; - -if ((kbd_flags &BRK ) ==NORMAL ) { - chr = kbd_key_map[kbd_mapping][kbd_state][scan_code]; -if ((chr ==0xff ) || (chr ==0x00 )) -return ; - -/* if caps lock convert upper to lower */ -if (((kbd_flags &CAPS ) ==CAPS ) && - (chr >='a' && chr <='z' )) { - chr -='a' -'A' ; - } - kbd_input = chr; - } -} - -static void kbd_shift (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==BRK ) { - kbd_state =AS ; - kbd_flags &= (~SHIFT ); - }else { - kbd_state =SH ; - kbd_flags |=SHIFT ; - } -} - -static void kbd_ctrl (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==BRK ) { - kbd_state =AS ; - kbd_flags &= (~CTRL ); - }else { - kbd_state =CN ; - kbd_flags |=CTRL ; - } -} - -static void kbd_num (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==NORMAL ) { - kbd_flags ^=NUM ; - kbd_state = (kbd_flags &NUM ) ?AS :NM ; -kbd_led_set (); - } -} - -static void kbd_alt (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==BRK ) { - kbd_state =AS ; - kbd_flags &= (~ALT ); - }else { - kbd_state =AK ; - kbd_flags &=ALT ; - } -} - -static void kbd_caps (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==NORMAL ) { - kbd_flags ^=CAPS ; -kbd_led_set (); - } -} - -static void kbd_scroll (unsigned char scan_code) -{ -if ((kbd_flags &BRK ) ==NORMAL ) { - kbd_flags ^=STP ; -kbd_led_set (); -if (kbd_flags &STP ) - kbd_input =0x13 ; -else - kbd_input =0x11 ; - } -} - -static void kbd_conv_char (unsigned char scan_code) -{ -if (scan_code ==0xe0 ) { - kbd_flags |=EXT ; -return ; - } - -/* if high bit of scan_code, set break flag */ -if (scan_code &0x80 ) - kbd_flags |=BRK ; -else - kbd_flags &= ~BRK ; - -if ((scan_code ==0xe1 ) || (kbd_flags &E1 )) { -if (scan_code ==0xe1 ) { - kbd_flags ^=BRK ;/* reset the break flag */ - kbd_flags ^=E1 ;/* bitwise EXOR with E1 flag */ - } -return ; - } - - scan_code &=0x7f ; - -if (kbd_flags &EXT ) { -int i; - - kbd_flags ^=EXT ; -for (i =0 ; ext_key_map[i]; i++) { -if (ext_key_map[i] == scan_code) { - scan_code =0x80 + i; -break ; - } - } -/* not found ? */ -if (!ext_key_map[i]) -return ; - } - -switch (kbd_fct_map[scan_code]) { -case AS : -kbd_normal (scan_code); -break ; -case SH : -kbd_shift (scan_code); -break ; -case CN : -kbd_ctrl (scan_code); -break ; -case NM : -kbd_num (scan_code); -break ; -case AK : -kbd_alt (scan_code); -break ; -case CP : -kbd_caps (scan_code); -break ; -case ST : -kbd_scroll (scan_code); -break ; - } - -return ; +out8 (I8042_DATA_REG , flags &0x7 ); }static int kbd_write (int reg,int value)@@ -568,11 +190,50 @@ int i8042_disable(void)return 0 ; } +static int i8042_kbd_check (struct input_config *input) +{ +if ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { +return 0 ; + }else { +bool release = false; +int scan_code; +int i; + + scan_code =in8 (I8042_DATA_REG ); +if (scan_code ==0xfa ) { +return 0 ; + }else if (scan_code ==0xe0 ) { + extended = true; +return 0 ; + } +if (scan_code &0x80 ) { + scan_code &=0x7f ; + release = true; + } +if (extended) { + extended = false; +for (i =0 ; ext_key_map[i]; i++) { +if (ext_key_map[i] == scan_code) { + scan_code =0x60 + i; +break ; + } + } +/* not found ? */ +if (!ext_key_map[i]) +return 0 ; + } + +input_add_keycode (&config, scan_code, release); +return 1 ; + } +} +/* i8042_kbd_init - reset keyboard and init state flags */ int i8042_kbd_init (void ) {int keymap, try;char *penv; +int ret;if (!kbd_controller_present () ||board_i8042_skip ()) {debug ("i8042 keyboard controller is not present\n" );
drivers/input/i8042.c int i8042_kbd_init(void) · line 256
Quoted 8 lines
drivers/input/i8042.c +1
-4@@ -592,58 +253,46 @@ int i8042_kbd_init(void)return -1 ; } - kbd_mapping = keymap; - kbd_flags =NORMAL ; - kbd_state =0 ; -kbd_led_set (); + ret =input_init (&config,0 , keymap ==KBD_GER );
I think this should be: input_add_tables(&config, keymap == KBD_GER).
Quoted 37 lines
drivers/input/i8042.c +15
-13+if (ret) +return ret; + config.read_keys = i8042_kbd_check; +input_allow_repeats (&config, true); + +kbd_led_set (NORMAL );return 0 ; } -/* -* i8042_tstc - test if keyboard input is available +/** +* check_leds() - Check the keyboard LEDs and update them it needed * -* option: cursor blinking if called in a loop +* @ret: Value to return +* @return value of @ret */ -int i8042_tstc (struct stdio_dev *dev) +static int check_leds (int ret) { -unsigned char scan_code =0 ; +int leds; -if ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { -return 0 ; - }else { - scan_code =in8 (I8042_DATA_REG ); -if (scan_code ==0xfa ) -return 0 ; - -kbd_conv_char (scan_code); + leds =input_leds_changed (&config); +if (leds >=0 ) +kbd_led_set (leds);
drivers/input/i8042.c int i8042_kbd_init(void) · line 286
Quoted 10 lines
drivers/input/i8042.c +5
-4-if (kbd_input !=-1 ) -return 1 ; - } +return ret; +} -return 0 ; +/* +* i8042_tstc - test if keyboard input is available +*/
Please use single line comment instead.
drivers/input/i8042.c int i8042_kbd_init(void) · line 294
Quoted 10 lines
drivers/input/i8042.c +3
-2+int i8042_tstc (struct stdio_dev *dev) +{ +return check_leds (input_tstc (&config)); }/* * i8042_getc - wait till keyboard input is available -* -* option: turn on/off cursor while waiting */
Please use single line comment instead.
Quoted 9 lines
drivers/input/i8042.c +0
-7int i8042_getc (struct stdio_dev *dev) { -int ret_chr; -unsigned char scan_code; - -while (kbd_input ==-1 ) { -while ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) { - } - scan_code =in8 (I8042_DATA_REG );
drivers/input/i8042.c int i8042_kbd_init(void)
Quoted 10 lines
drivers/input/i8042.c +1
-8-if (scan_code !=0xfa ) -kbd_conv_char (scan_code); - } - ret_chr = kbd_input; - kbd_input =-1 ; - -return ret_chr; +return check_leds (input_getc (&config)); } --
With this commit (plus the input_add_tables fix above), i8042 LED does not work any more on Intel Crown Bay. When pressing 'Caps Lock' or 'Num Lock', U-Boot just hangs.
Regards,
Bin
PATCH 23/28 input: Add a Kconfig option for the i8042 keyboard
In reply to Simon GlassAdd a new option CONFIG_I8042_KEYB which will replace the current CONFIG_I8042_KBD. This new name fits better with existing drivers.
---
drivers/input/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/input/Kconfig +10 -0
@@ -13,3 +13,13 @@ config CROS_EC_KEYB Most ARM Chromebooks use an EC to provide access to the keyboard. Messages are used to request key scans from the EC and these are then decoded into keys by this driver. + +config I8042_KEYB + bool "Enable Intel i8042 keyboard support" + depends on DM_KEYBOARD + help + This adds a driver for the i8042 keyboard controller, allowing the + keyboard to be used on devices which support this controller. The + driver handles English and German keyboards - set the environment + variable 'keymap' to "de" to select German. Keyboard repeat is + handled by the keyboard itself.
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 23/28 input: Add a Kconfig option for the i8042 keyboard
Quoted 18 lines · Simon Glass
Add a new option
CONFIG_I8042_KEYBwhich will replace the currentCONFIG_I8042_KBD. This new name fits better with existing drivers.Signed-off-by Simon Glass <[email protected]>---
drivers/input/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/input/Kconfig +1
-0@@ -13,3 +13,13 @@ config CROS_EC_KEYB Most ARM Chromebooks use an EC to provide access to the keyboard. Messages are used to request key scans from the EC and these are then decoded into keys by this driver. +
drivers/input/Kconfig config CROS_EC_KEYB
Quoted 10 lines
drivers/input/Kconfig +9
-1+config I8042_KEYB + bool "Enable Intel i8042 keyboard support" + depends on DM_KEYBOARD + help + This adds a driver for the i8042 keyboard controller, allowing the + keyboard to be used on devices which support this controller. The + driver handles English and German keyboards - set the environment + variable 'keymap' to "de" to select German. Keyboard repeat is + handled by the keyboard itself. --
PATCH 24/28 x86: Add an i8042 device for boards that have it
In reply to Simon GlassSome boards have an i8042 device. Enable the driver for all x86 boards, and add a device tree node for those which may have this keyboard.
Also adjust the configuration so that i8042 is always separate from the VGA, and rename the stdin driver accordingly. With this commit the keyboard will not work, but it is fixed in the next commit.
---
arch/x86/Kconfig | 6 ++++++ arch/x86/dts/bayleybay.dts | 1 + arch/x86/dts/chromebook_link.dts | 1 + arch/x86/dts/keyboard.dtsi | 5 +++++ include/configs/x86-chromebook.h | 2 +- include/configs/x86-common.h | 2 +- 6 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 arch/x86/dts/keyboard.dtsi
arch/x86/Kconfig +6 -0
@@ -401,6 +401,12 @@ config PCIE_ECAM_SIZE so a default 0x10000000 size covers all of the 256 buses which is the maximum number of PCI buses as defined by the PCI specification. +config I8042_KEYB + default y + +config DM_KEYBOARD + default y + source "arch/x86/lib/efi/Kconfig" endmenu
arch/x86/dts/bayleybay.dts +1 -0
@@ -10,6 +10,7 @@ #include <dt-bindings/interrupt-router/intel-irq.h> /include/ "skeleton.dtsi" +/include/ "keyboard.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi"
arch/x86/dts/chromebook_link.dts +1 -0
@@ -1,6 +1,7 @@ /dts-v1/; /include/ "skeleton.dtsi" +/include/ "keyboard.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi"
arch/x86/dts/keyboard.dtsi new file +5 -0
@@ -0,0 +1,5 @@ +/ { + keyboard { + compatible = "intel,i8042-keyboard"; + }; +};
include/configs/x86-chromebook.h +1 -1
@@ -51,7 +51,7 @@#define CONFIG_ENV_IS_IN_SPI_FLASH #define CONFIG_ENV_OFFSET 0x003f8000 -#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,vga,serial\0" \ +#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,i8042-kbd,serial\0" \ "stdout=vga,serial\0" \ "stderr=vga,serial\0"
include/configs/x86-common.h +1 -1
@@ -147,7 +147,7 @@#define CONFIG_VIDEO #define CONFIG_VIDEO_SW_CURSOR #define VIDEO_FB_16BPP_WORD_SWAP -#define CONFIG_I8042_KBD +#define CONFIG_VGA_AS_SINGLE_DEVICE #define CONFIG_CFB_CONSOLE #define CONFIG_CONSOLE_SCROLL_LINES 5
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 24/28 x86: Add an i8042 device for boards that have it
Hi Simon,
Quoted 24 lines · Simon Glass
Some boards have an i8042 device. Enable the driver for all x86 boards, and add a device tree node for those which may have this keyboard.
Also adjust the configuration so that i8042 is always separate from the VGA, and rename the stdin driver accordingly. With this commit the keyboard will not work, but it is fixed in the next commit.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/Kconfig | 6 ++++++ arch/x86/dts/bayleybay.dts | 1 + arch/x86/dts/chromebook_link.dts | 1 + arch/x86/dts/keyboard.dtsi | 5 +++++ include/configs/x86-chromebook.h | 2 +- include/configs/x86-common.h | 2 +- 6 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 arch/x86/dts/keyboard.dtsiarch/x86/Kconfig +0
-0
arch/x86/Kconfig config PCIE_ECAM_SIZE · line 409
Quoted 9 lines
arch/x86/Kconfig +6
-0@@ -401,6 +401,12 @@ config PCIE_ECAM_SIZE so a default 0x10000000 size covers all of the 256 buses which is the maximum number of PCI buses as defined by the PCI specification. +config I8042_KEYB + default y + +config DM_KEYBOARD + default y +
I am not in favor of adding driver options in the arch Kconfig. We specify other drivers in the boards' defconfig files. Can we move these two to defconfig too?
Quoted 56 lines
arch/x86/Kconfig +0
-0source "arch/x86/lib/efi/Kconfig" endmenuarch/x86/dts/bayleybay.dts +1
-0@@ -10,6 +10,7 @@ #include <dt-bindings/interrupt-router/intel-irq.h> /include/ "skeleton.dtsi" +/include/ "keyboard.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi"arch/x86/dts/chromebook_link.dts +1
-0@@ -1,6 +1,7 @@ /dts-v1/; /include/ "skeleton.dtsi" +/include/ "keyboard.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi"arch/x86/dts/keyboard.dtsi new file +5
-0@@ -0,0 +1,5 @@ +/ { + keyboard { + compatible = "intel,i8042-keyboard"; + }; +};include/configs/x86-chromebook.h +1
-1@@ -51,7 +51,7 @@#define CONFIG_ENV_IS_IN_SPI_FLASH #define CONFIG_ENV_OFFSET 0x003f8000 -#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,vga,serial\0" \ +#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,i8042-kbd,serial\0" \ "stdout=vga,serial\0" \ "stderr=vga,serial\0"include/configs/x86-common.h +0
-0
include/configs/x86-common.h line 150
Quoted 5 lines
include/configs/x86-common.h +1
-1@@ -147,7 +147,7 @@#define CONFIG_VIDEO #define CONFIG_VIDEO_SW_CURSOR #define VIDEO_FB_16BPP_WORD_SWAP -#define CONFIG_I8042_KBD +#define CONFIG_VGA_AS_SINGLE_DEVICE
Can we remove CONFIG_VGA_AS_SINGLE_DEVICE from all x86 board config.h files to avoid duplication?
include/configs/x86-common.h
Quoted 4 lines
include/configs/x86-common.h +0
-1#define CONFIG_CFB_CONSOLE #define CONFIG_CONSOLE_SCROLL_LINES 5 --
Regards,
Bin
PATCH 24/28 x86: Add an i8042 device for boards that have it
Hi Bin,
Quoted 30 lines · Bin Meng
Hi Simon,
Quoted 27 lines · Simon Glass
Some boards have an i8042 device. Enable the driver for all x86 boards, and add a device tree node for those which may have this keyboard.
Also adjust the configuration so that i8042 is always separate from the VGA, and rename the stdin driver accordingly. With this commit the keyboard will not work, but it is fixed in the next commit.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/Kconfig | 6 ++++++ arch/x86/dts/bayleybay.dts | 1 + arch/x86/dts/chromebook_link.dts | 1 + arch/x86/dts/keyboard.dtsi | 5 +++++ include/configs/x86-chromebook.h | 2 +- include/configs/x86-common.h | 2 +- 6 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 arch/x86/dts/keyboard.dtsiarch/x86/Kconfig +0
-0@@ -401,6 +401,12 @@ config PCIE_ECAM_SIZE so a default 0x10000000 size covers all of the 256 buses which is the maximum number of PCI buses as defined by the PCI specification.
Quoted 10 lines
arch/x86/Kconfig config PCIE_ECAM_SIZE · line 409
Quoted 6 lines
arch/x86/Kconfig +6
-0+config I8042_KEYB + default y + +config DM_KEYBOARD + default y +I am not in favor of adding driver options in the arch
Kconfig. We specify other drivers in the boards' defconfig files. Can we move these two to defconfig too?
The idea is that x86 has moved to use driver model for keyboard. Any new boards should also. This option will be removed when everything is converted so I don't think it should be exposed too widely.
Quoted 52 lines
Quoted 52 lines
arch/x86/Kconfig +0
-0source "arch/x86/lib/efi/Kconfig" endmenuarch/x86/dts/bayleybay.dts +1
-0@@ -10,6 +10,7 @@ #include <dt-bindings/interrupt-router/intel-irq.h> /include/ "skeleton.dtsi" +/include/ "keyboard.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi"arch/x86/dts/chromebook_link.dts +1
-0@@ -1,6 +1,7 @@ /dts-v1/; /include/ "skeleton.dtsi" +/include/ "keyboard.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi"arch/x86/dts/keyboard.dtsi new file +5
-0@@ -0,0 +1,5 @@ +/ { + keyboard { + compatible = "intel,i8042-keyboard"; + }; +};include/configs/x86-chromebook.h +1
-1@@ -51,7 +51,7 @@#define CONFIG_ENV_IS_IN_SPI_FLASH #define CONFIG_ENV_OFFSET 0x003f8000 -#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,vga,serial\0" \ +#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,i8042-kbd,serial\0" \ "stdout=vga,serial\0" \ "stderr=vga,serial\0"
Quoted 13 lines
include/configs/x86-common.h line 150
Quoted 10 lines
include/configs/x86-common.h +1
-1@@ -147,7 +147,7 @@#define CONFIG_VIDEO #define CONFIG_VIDEO_SW_CURSOR #define VIDEO_FB_16BPP_WORD_SWAP -#define CONFIG_I8042_KBD +#define CONFIG_VGA_AS_SINGLE_DEVICE Can we remove
CONFIG_VGA_AS_SINGLE_DEVICEfrom all x86 boardconfig.hfiles to avoid duplication?
Will do.
Quoted 3 lines
include/configs/x86-common.h line 152
Quoted 3 lines
include/configs/x86-common.h +0
-0#define CONFIG_CFB_CONSOLE #define CONFIG_CONSOLE_SCROLL_LINES 5
Regards,
Simon
PATCH 25/28 Drop CONFIG_ISA_KEYBOARD
In reply to Simon GlassThis option is mentioned but does not do anything. Drop it.
---
README | 11 ++++++----- board/mpl/pip405/README | 4 ---- include/configs/MIP405.h | 5 ----- include/configs/PIP405.h | 5 ----- 4 files changed, 6 insertions(+), 19 deletions(-)
README +6 -5
@@ -1785,17 +1785,18 @@ CBFS (Coreboot Filesystem) support a default value of 65536 will be defined. - Keyboard Support: - CONFIG_ISA_KEYBOARD - - Define this to enable standard (PC-Style) keyboard - support - CONFIG_I8042_KBD Standard PC keyboard driver with US (is default) and GERMAN key layout (switch via environment 'keymap=de') support. Export function i8042_kbd_init, i8042_tstc and i8042_getc for cfb_console. Supports cursor blinking. + CONFIG_CROS_EC_KEYB + Enables a Chrome OS keyboard using the CROS_EC interface. + This uses CROS_EC to communicate with a second microcontroller + which provides key scans on request. + See Kconfig help for available keyboard drivers. + - Video support: CONFIG_VIDEO
board/mpl/pip405/README +0 -4
@@ -114,10 +114,6 @@ RTC ---- CONFIG_RTC_MC146818 MC146818 RTC support -Keyboard: ---------- -CONFIG_ISA_KEYBOARD Standard (PC-Style) Keyboard support - Video: ------ CONFIG_VIDEO_CT69000 Enable Chips & Technologies 69000 Video chip
include/configs/MIP405.h +0 -5
@@ -364,11 +364,6 @@#define CONFIG_ISO_PARTITION /* Experimental */ /************************************************************ -* Keyboard support -************************************************************/ -#undef CONFIG_ISA_KEYBOARD - -/************************************************************ * Video support ************************************************************/ #define CONFIG_VIDEO /*To enable video controller support */
include/configs/PIP405.h +0 -5
@@ -321,11 +321,6 @@#define CONFIG_ISO_PARTITION /* Experimental */ /************************************************************ -* Keyboard support -************************************************************/ -#define CONFIG_ISA_KEYBOARD - -/************************************************************ * Video support ************************************************************/ #define CONFIG_VIDEO /*To enable video controller support */
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 25/28 Drop CONFIG_ISA_KEYBOARD
Quoted 77 lines · Simon Glass
This option is mentioned but does not do anything. Drop it.
Signed-off-by Simon Glass <[email protected]>---
README | 11 ++++++----- board/mpl/pip405/README | 4 ---- include/configs/MIP405.h | 5 ----- include/configs/PIP405.h | 5 ----- 4 files changed, 6 insertions(+), 19 deletions(-)README +6
-5@@ -1785,17 +1785,18 @@ CBFS (Coreboot Filesystem) support a default value of 65536 will be defined. - Keyboard Support: - CONFIG_ISA_KEYBOARD - - Define this to enable standard (PC-Style) keyboard - support - CONFIG_I8042_KBD Standard PC keyboard driver with US (is default) and GERMAN key layout (switch via environment 'keymap=de') support. Export function i8042_kbd_init, i8042_tstc and i8042_getc for cfb_console. Supports cursor blinking. + CONFIG_CROS_EC_KEYB + Enables a Chrome OS keyboard using the CROS_EC interface. + This uses CROS_EC to communicate with a second microcontroller + which provides key scans on request. + See Kconfig help for available keyboard drivers. + - Video support: CONFIG_VIDEOboard/mpl/pip405/README +0
-4@@ -114,10 +114,6 @@ RTC ---- CONFIG_RTC_MC146818 MC146818 RTC support -Keyboard: ---------- -CONFIG_ISA_KEYBOARD Standard (PC-Style) Keyboard support - Video: ------ CONFIG_VIDEO_CT69000 Enable Chips & Technologies 69000 Video chipinclude/configs/MIP405.h +0
-5@@ -364,11 +364,6 @@#define CONFIG_ISO_PARTITION /* Experimental */ /************************************************************ -* Keyboard support -************************************************************/ -#undef CONFIG_ISA_KEYBOARD - -/************************************************************ * Video support ************************************************************/ #define CONFIG_VIDEO /*To enable video controller support */ include/configs/PIP405.h +0
-0@@ -321,11 +321,6 @@#define CONFIG_ISO_PARTITION /* Experimental */
include/configs/PIP405.h
Quoted 10 lines
include/configs/PIP405.h +0
-6/************************************************************ -* Keyboard support -************************************************************/ -#define CONFIG_ISA_KEYBOARD - -/************************************************************ * Video support ************************************************************/ #define CONFIG_VIDEO /*To enable video controller support */ --
PATCH 26/28 input: Convert i8042 to driver model
In reply to Simon GlassAdjust this driver to support driver model. The only users are x86 boards so this should be safe.
---
drivers/input/Makefile | 2 +- drivers/input/i8042.c | 113 ++++++++++++++++++++++++++++++++----------------- include/i8042.h | 6 --- 3 files changed, 76 insertions(+), 45 deletions(-)
drivers/input/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o -obj-$(CONFIG_I8042_KBD) += i8042.o +obj-$(CONFIG_I8042_KEYB) += i8042.o obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o obj-$(CONFIG_TWL4030_INPUT) += twl4030.o obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o
drivers/input/i8042.c +75 -38
197 lines not on this page · raw message
include/i8042.h +0 -6
@@ -87,10 +87,4 @@ void i8042_flush(void);*/ int i8042_disable (void ); -struct stdio_dev ; - -int i8042_kbd_init (void ); -int i8042_tstc (struct stdio_dev *dev); -int i8042_getc (struct stdio_dev *dev); -#endif /* _I8042_H_ */
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 26/28 input: Convert i8042 to driver model
Hi Simon,
Quoted 5 lines · Simon Glass
Adjust this driver to support driver model. The only users are x86 boards so this should be safe.
Signed-off-by Simon Glass <[email protected]>---
After updating QEMU to use the DM i8042 driver below:
arch/x86/dts/qemu-x86_i440fx.dts +1 -0
@@ -11,6 +11,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi" +/include/ "keyboard.dtsi" / { model = "QEMU x86 (I440FX)";
include/configs/qemu-x86.h +1 -1
@@ -30,7 +30,7 @@#define CONFIG_PCI_PNP -#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,vga\0" \ +#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,i8042-kbd\0" \ "stdout=serial,vga\0" \ "stderr=serial,vga\0"
The i8042 still does not work. I've applied the same changes to Crown Bay. i8042 does not work either. Could you please have a look?
Quoted 234 lines
drivers/input/Makefile | 2 +- drivers/input/i8042.c | 113 ++++++++++++++++++++++++++++++++----------------- include/i8042.h | 6 --- 3 files changed, 76 insertions(+), 45 deletions(-)drivers/input/Makefile +1
-1@@ -7,7 +7,7 @@ obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o -obj-$(CONFIG_I8042_KBD) += i8042.o +obj-$(CONFIG_I8042_KEYB) += i8042.o obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o obj-$(CONFIG_TWL4030_INPUT) += twl4030.o obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.odrivers/input/i8042.c +75
-38@@ -8,8 +8,11 @@/* i8042.c - Intel 8042 keyboard driver routines */ #include <common.h> +#include <dm.h> +#include <errno.h> #include <i8042.h> #include <input.h> +#include <keyboard.h> #include <asm/io.h> /* defines */ @@ -17,8 +20,9 @@#define out8 (p, v) outb(v, p)/* locals */ -static struct input_config config; -static bool extended; +struct i8042_kbd_priv { +bool extended;/* true if an extended keycode is expected next */ +};static unsigned char ext_key_map[] = {0x1c ,/* keypad enter */ @@ -60,12 +64,20 @@ static int kbd_output_full(void)return kbd_timeout !=-1 ; } -static void kbd_led_set (int flags) +/** +* check_leds() - Check the keyboard LEDs and update them it needed +* +* @ret: Value to return +* @return value of @ret +*/ +static int i8042_kbd_update_leds (struct udevice *dev,int leds) {kbd_input_empty ();out8 (I8042_DATA_REG ,CMD_SET_KBD_LED );kbd_input_empty (); -out8 (I8042_DATA_REG , flags &0x7 ); +out8 (I8042_DATA_REG , leds &0x7 ); + +return 0 ; }static int kbd_write (int reg,int value)@@ -146,6 +158,8 @@ static int kbd_controller_present(void)/* * Implement a weak default function for boards that optionally * need to skip the i8042 initialization. +* +* TODO(sjg at chromium.org): Use device tree for this? */ int __weak board_i8042_skip (void ) {@@ -192,6 +206,8 @@ int i8042_disable(void)static int i8042_kbd_check (struct input_config *input) { +struct i8042_kbd_priv *priv =dev_get_priv (input->dev); +if ((in8 (I8042_STS_REG ) &STATUS_OBF ) ==0 ) {return 0 ; }else {@@ -203,15 +219,15 @@ static int i8042_kbd_check(struct input_config *input)if (scan_code ==0xfa ) {return 0 ; }else if (scan_code ==0xe0 ) { - extended = true; + priv->extended = true;return 0 ; }if (scan_code &0x80 ) { scan_code &=0x7f ; release = true; } -if (extended) { - extended = false; +if (priv->extended) { + priv->extended = false;for (i =0 ; ext_key_map[i]; i++) {if (ext_key_map[i] == scan_code) { scan_code =0x60 + i;@@ -223,21 +239,23 @@ static int i8042_kbd_check(struct input_config *input)return 0 ; } -input_add_keycode (&config, scan_code, release); +input_add_keycode (input, scan_code, release);return 1 ; } }/* i8042_kbd_init - reset keyboard and init state flags */ -int i8042_kbd_init (void ) +static int i8042_start (struct udevice *dev) { +struct keyboard_priv *uc_priv =dev_get_uclass_priv (dev); +struct input_config *input = &uc_priv->input;int keymap, try;char *penv;int ret;if (!kbd_controller_present () ||board_i8042_skip ()) {debug ("i8042 keyboard controller is not present\n" ); -return -1 ; +return -ENOENT ; }/* Init keyboard device (default US layout) */ @@ -253,46 +271,65 @@ int i8042_kbd_init(void)return -1 ; } - ret =input_init (&config,0 , keymap ==KBD_GER ); + ret =input_add_tables (input, keymap ==KBD_GER );if (ret)return ret; - config.read_keys = i8042_kbd_check; -input_allow_repeats (&config, true); -kbd_led_set (NORMAL ); +i8042_kbd_update_leds (dev,NORMAL ); +debug ("%s: started\n" , __func__);return 0 ; }/** -* check_leds() - Check the keyboard LEDs and update them it needed +* Set up the i8042 keyboard. This is called by the stdio device handler * -* @ret: Value to return -* @return value of @ret +* We want to do this init when the keyboard is actually used rather than +* at start-up, since keyboard input may not currently be selected. +* +* Once the keyboard starts there will be a period during which we must +* wait for the keyboard to init. We do this only when a key is first +* read - see kbd_wait_for_fifo_init(). +* +* @return 0 if ok, -ve on error */ -static int check_leds (int ret) +static int i8042_kbd_probe (struct udevice *dev) { -int leds; - - leds =input_leds_changed (&config); -if (leds >=0 ) -kbd_led_set (leds); +struct keyboard_priv *uc_priv =dev_get_uclass_priv (dev); +struct stdio_dev *sdev = &uc_priv->sdev; +struct input_config *input = &uc_priv->input; +int ret; -return ret; -} +/* Register the device. i8042_start() will be called soon */ + input->dev = dev; + input->read_keys = i8042_kbd_check; +input_allow_repeats (input, true); +strcpy (sdev->name,"i8042-kbd" ); + ret =input_stdio_register (sdev); +if (ret) { +debug ("%s: input_stdio_register() failed\n" , __func__); +return ret; + } +debug ("%s: ready\n" , __func__); -/* -* i8042_tstc - test if keyboard input is available -*/ -int i8042_tstc (struct stdio_dev *dev) -{ -return check_leds (input_tstc (&config)); +return 0 ; } -/* -* i8042_getc - wait till keyboard input is available -*/ -int i8042_getc (struct stdio_dev *dev) -{ -return check_leds (input_getc (&config)); -} +static const struct keyboard_ops i8042_kbd_ops = { + .start = i8042_start, + .update_leds = i8042_kbd_update_leds, +}; + +static const struct udevice_id i8042_kbd_ids[] = { + { .compatible ="intel,i8042-keyboard" }, + { } +}; + +U_BOOT_DRIVER (i8042_kbd) = { + .name ="i8042_kbd" , + .id =UCLASS_KEYBOARD , + .of_match = i8042_kbd_ids, + .probe = i8042_kbd_probe, + .ops = &i8042_kbd_ops, + .priv_auto_alloc_size =sizeof (struct i8042_kbd_priv ), +};include/i8042.h +0
-0@@ -87,10 +87,4 @@ void i8042_flush(void);*/
include/i8042.h void i8042_flush(void);
Quoted 10 lines
include/i8042.h +0
-7int i8042_disable (void ); -struct stdio_dev ; - -int i8042_kbd_init (void ); -int i8042_tstc (struct stdio_dev *dev); -int i8042_getc (struct stdio_dev *dev); -#endif /* _I8042_H_ */ --
Regards,
Bin
PATCH 26/28 input: Convert i8042 to driver model
Hi Bin,
Quoted 37 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Simon Glass
Adjust this driver to support driver model. The only users are x86 boards so this should be safe.
Signed-off-by Simon Glass <[email protected]>---
After updating QEMU to use the DM i8042 driver below:
arch/x86/dts/qemu-x86_i440fx.dts +1
-0@@ -11,6 +11,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi" +/include/ "keyboard.dtsi" / { model = "QEMU x86 (I440FX)";include/configs/qemu-x86.h +1
-1@@ -30,7 +30,7 @@#define CONFIG_PCI_PNP -#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,vga\0" \ +#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,i8042-kbd\0" \ "stdout=serial,vga\0" \ "stderr=serial,vga\0"
Quoted 3 lines
The i8042 still does not work. I've applied the same changes to Crown Bay. i8042 does not work either. Could you please have a look?
It's hard for me to debug this on hardware. I should be able to use qemu though. Is there anything special needed to make it use that keyboard?
Regards,
Simon
PATCH 26/28 input: Convert i8042 to driver model
Hi Bin,
Quoted 40 lines · Simon Glass
Hi Bin,
Quoted 37 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Simon Glass
Adjust this driver to support driver model. The only users are x86 boards so this should be safe.
Signed-off-by Simon Glass <[email protected]>---
After updating QEMU to use the DM i8042 driver below:
arch/x86/dts/qemu-x86_i440fx.dts +1
-0@@ -11,6 +11,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi" +/include/ "keyboard.dtsi" / { model = "QEMU x86 (I440FX)";include/configs/qemu-x86.h +1
-1@@ -30,7 +30,7 @@#define CONFIG_PCI_PNP -#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,vga\0" \ +#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,i8042-kbd\0" \ "stdout=serial,vga\0" \ "stderr=serial,vga\0"
Quoted 7 lines
Quoted 3 lines
The i8042 still does not work. I've applied the same changes to Crown Bay. i8042 does not work either. Could you please have a look?
It's hard for me to debug this on hardware. I should be able to use qemu though. Is there anything special needed to make it use that keyboard?
Actually it works for me with qemu.
However it is intermittent, as it was before my series. So there is something else going on.
Regards,
Simon
PATCH 26/28 input: Convert i8042 to driver model
In reply to Simon GlassHi Simon,
Quoted 40 lines · Simon Glass
Hi Bin,
Quoted 37 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Simon Glass
Adjust this driver to support driver model. The only users are x86 boards so this should be safe.
Signed-off-by Simon Glass <[email protected]>---
After updating QEMU to use the DM i8042 driver below:
arch/x86/dts/qemu-x86_i440fx.dts +1
-0@@ -11,6 +11,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi" +/include/ "keyboard.dtsi" / { model = "QEMU x86 (I440FX)";include/configs/qemu-x86.h +1
-1@@ -30,7 +30,7 @@#define CONFIG_PCI_PNP -#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,vga\0" \ +#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,i8042-kbd\0" \ "stdout=serial,vga\0" \ "stderr=serial,vga\0"
Quoted 8 lines
Quoted 3 lines
The i8042 still does not work. I've applied the same changes to Crown Bay. i8042 does not work either. Could you please have a look?
It's hard for me to debug this on hardware. I should be able to use qemu though. Is there anything special needed to make it use that keyboard?
I will have another try (and debug if it is needed) on Crown Bay when you send the v2 series.
Regards,
Bin
PATCH 26/28 input: Convert i8042 to driver model
Hi Bin,
Quoted 52 lines · Bin Meng
Hi Simon,
Quoted 40 lines · Simon Glass
Hi Bin,
Quoted 37 lines · Bin Meng
Hi Simon,
Quoted 5 lines · Simon Glass
Adjust this driver to support driver model. The only users are x86 boards so this should be safe.
Signed-off-by Simon Glass <[email protected]>---
After updating QEMU to use the DM i8042 driver below:
arch/x86/dts/qemu-x86_i440fx.dts +1
-0@@ -11,6 +11,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" /include/ "rtc.dtsi" +/include/ "keyboard.dtsi" / { model = "QEMU x86 (I440FX)";include/configs/qemu-x86.h +1
-1@@ -30,7 +30,7 @@#define CONFIG_PCI_PNP -#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,vga\0" \ +#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,i8042-kbd\0" \ "stdout=serial,vga\0" \ "stderr=serial,vga\0"Quoted 8 lines
Quoted 3 lines
The i8042 still does not work. I've applied the same changes to Crown Bay. i8042 does not work either. Could you please have a look?
It's hard for me to debug this on hardware. I should be able to use qemu though. Is there anything special needed to make it use that keyboard?
Quoted 2 lines
I will have another try (and debug if it is needed) on Crown Bay when you send the v2 series.
Thanks - also note that I have not fixed the hang on caps lock that you reported.
Regards,
Simon
PATCH 27/28 video: input: Clean up after i8042 conversion
In reply to Simon GlassNow that i8042 uses driver model, adjust other mentions of it and remove old code that is no-longer used. Update the README and unify the keyboard text into one place.
---
README | 33 +++++++++++---------------------- drivers/video/cfb_console.c | 20 ++++---------------- 2 files changed, 15 insertions(+), 38 deletions(-)
README +11 -22
@@ -885,11 +885,11 @@ The following options need to be configured: (0-5, cf. cfb_console.c) VIDEO_FB_ADRS framebuffer address VIDEO_KBD_INIT_FCT keyboard int fct - (i.e. i8042_kbd_init()) + (i.e. rx51_kp_init()) VIDEO_TSTC_FCT test char fct - (i.e. i8042_tstc) + (i.e. rx51_kp_tstc) VIDEO_GETC_FCT get char fct - (i.e. i8042_getc) + (i.e. rx51_kp_getc) CONFIG_VIDEO_LOGO display Linux logo in upper left corner CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead of
@@ -1785,18 +1785,16 @@ CBFS (Coreboot Filesystem) support a default value of 65536 will be defined. - Keyboard Support: - CONFIG_I8042_KBD - Standard PC keyboard driver with US (is default) and - GERMAN key layout (switch via environment 'keymap=de') support. - Export function i8042_kbd_init, i8042_tstc and i8042_getc - for cfb_console. Supports cursor blinking. - - CONFIG_CROS_EC_KEYB - Enables a Chrome OS keyboard using the CROS_EC interface. - This uses CROS_EC to communicate with a second microcontroller - which provides key scans on request. See Kconfig help for available keyboard drivers. + CONFIG_KEYBOARD + + Define this to enable a custom keyboard support. + This simply calls drv_keyboard_init() which must be + defined in your board-specific files. This option is deprecated + and is only used by novena. For new boards, driver model + instead. + - Video support: CONFIG_VIDEO
@@ -1856,15 +1854,6 @@ CBFS (Coreboot Filesystem) support boot. See the documentation file README.video for a description of this variable. - -- Keyboard Support: - CONFIG_KEYBOARD - - Define this to enable a custom keyboard support. - This simply calls drv_keyboard_init() which must be - defined in your board-specific files. - The only board using this so far is RBC823. - - LCD Support: CONFIG_LCD Define this to enable LCD support (for output to LCD
drivers/video/cfb_console.c +4 -16
@@ -15,8 +15,10 @@* logo can be placed in the upper left corner and additional board * information strings (that normally goes to serial port) can be drawn. * -* The console driver can use the standard PC keyboard interface (i8042) -* for character input. Character output goes to a memory mapped video +* The console driver can use a keyboard interface for character input +* but this is deprecated. Only rk51 uses it. +* +* Character output goes to a memory-mapped video * framebuffer with little or big-endian organisation. * With environment setting 'console=serial' the console i/o can be * forced to serial port.
@@ -38,7 +40,6 @@* VIDEO_DATA_FORMAT - graphical data format GDF * VIDEO_FB_ADRS - start of video memory * -* CONFIG_I8042_KBD - AT Keyboard driver for i8042 * VIDEO_KBD_INIT_FCT - init function for keyboard * VIDEO_TSTC_FCT - keyboard_tstc function * VIDEO_GETC_FCT - keyboard_getc function
@@ -158,19 +159,6 @@#define VIDEO_FB_ADRS (pGD->frameAdrs)/* -* Console device defines with i8042 keyboard controller -* Any other keyboard controller must change this section -*/ - -#ifdef CONFIG_I8042_KBD -#include <i8042.h> - -#define VIDEO_KBD_INIT_FCT i8042_kbd_init() -#define VIDEO_TSTC_FCT i8042_tstc -#define VIDEO_GETC_FCT i8042_getc -#endif - -/* * Console device */
Signature · 1 line
2.6.0.rc0.131.gf624c3d
PATCH 27/28 video: input: Clean up after i8042 conversion
Quoted 109 lines · Simon Glass
Now that i8042 uses driver model, adjust other mentions of it and remove old code that is no-longer used. Update the README and unify the keyboard text into one place.
Signed-off-by Simon Glass <[email protected]>---
README | 33 +++++++++++---------------------- drivers/video/cfb_console.c | 20 ++++---------------- 2 files changed, 15 insertions(+), 38 deletions(-)README +11
-22@@ -885,11 +885,11 @@ The following options need to be configured: (0-5, cf. cfb_console.c) VIDEO_FB_ADRS framebuffer address VIDEO_KBD_INIT_FCT keyboard int fct - (i.e. i8042_kbd_init()) + (i.e. rx51_kp_init()) VIDEO_TSTC_FCT test char fct - (i.e. i8042_tstc) + (i.e. rx51_kp_tstc) VIDEO_GETC_FCT get char fct - (i.e. i8042_getc) + (i.e. rx51_kp_getc) CONFIG_VIDEO_LOGO display Linux logo in upper left corner CONFIG_VIDEO_BMP_LOGO use bmp_logo.h instead of@@ -1785,18 +1785,16 @@ CBFS (Coreboot Filesystem) support a default value of 65536 will be defined. - Keyboard Support: - CONFIG_I8042_KBD - Standard PC keyboard driver with US (is default) and - GERMAN key layout (switch via environment 'keymap=de') support. - Export function i8042_kbd_init, i8042_tstc and i8042_getc - for cfb_console. Supports cursor blinking. - - CONFIG_CROS_EC_KEYB - Enables a Chrome OS keyboard using the CROS_EC interface. - This uses CROS_EC to communicate with a second microcontroller - which provides key scans on request. See Kconfig help for available keyboard drivers. + CONFIG_KEYBOARD + + Define this to enable a custom keyboard support. + This simply calls drv_keyboard_init() which must be + defined in your board-specific files. This option is deprecated + and is only used by novena. For new boards, driver model + instead. + - Video support: CONFIG_VIDEO@@ -1856,15 +1854,6 @@ CBFS (Coreboot Filesystem) support boot. See the documentation file README.video for a description of this variable. - -- Keyboard Support: - CONFIG_KEYBOARD - - Define this to enable a custom keyboard support. - This simply calls drv_keyboard_init() which must be - defined in your board-specific files. - The only board using this so far is RBC823. - - LCD Support: CONFIG_LCD Define this to enable LCD support (for output to LCDdrivers/video/cfb_console.c +4
-10@@ -15,8 +15,10 @@* logo can be placed in the upper left corner and additional board * information strings (that normally goes to serial port) can be drawn. * -* The console driver can use the standard PC keyboard interface (i8042) -* for character input. Character output goes to a memory mapped video +* The console driver can use a keyboard interface for character input +* but this is deprecated. Only rk51 uses it. +* +* Character output goes to a memory-mapped video * framebuffer with little or big-endian organisation. * With environment setting 'console=serial' the console i/o can be * forced to serial port. @@ -38,7 +40,6 @@* VIDEO_DATA_FORMAT - graphical data format GDF * VIDEO_FB_ADRS - start of video memory * -* CONFIG_I8042_KBD - AT Keyboard driver for i8042 * VIDEO_KBD_INIT_FCT - init function for keyboard * VIDEO_TSTC_FCT - keyboard_tstc function * VIDEO_GETC_FCT - keyboard_getc function @@ -158,19 +159,6 @@#define VIDEO_FB_ADRS (pGD->frameAdrs)/* -* Console device defines with i8042 keyboard controller -* Any other keyboard controller must change this section -*/ - -#ifdef CONFIG_I8042_KBD -#include <i8042.h> -
drivers/video/cfb_console.c
Quoted 10 lines
drivers/video/cfb_console.c +0
-7-#define VIDEO_KBD_INIT_FCT i8042_kbd_init() -#define VIDEO_TSTC_FCT i8042_tstc -#define VIDEO_GETC_FCT i8042_getc -#endif - -/* * Console device */ --
PATCH 28/28 input: Convert 'keyboard' driver to use input library
In reply to Simon GlassThis has duplicated scan code tables and logic. We can use the input library to implement most of the features here.
This needs testing. The only supported board appears to be TQM5200. Unfortunately no maintainer is listed for this board.
---
drivers/input/keyboard.c | 290 +++++++---------------------------------------- include/keyboard.h | 5 + 2 files changed, 43 insertions(+), 252 deletions(-)
drivers/input/keyboard.c +38 -252
@@ -9,290 +9,76 @@***********************************************************************/ #include <common.h> - -#include <stdio_dev.h> +#include <input.h> #include <keyboard.h> +#include <stdio_dev.h> -#undef KBG_DEBUG - -#ifdef KBG_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - - -#define DEVNAME "kbd" - -#define LED_SCR 0x01/* scroll lock led */ -#define LED_CAP 0x04/* caps lock led */ -#define LED_NUM 0x02/* num lock led */ - -#define KBD_BUFFER_LEN 0x20/* size of the keyboardbuffer */ +static struct input_config config; -#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540 ) || defined(CONFIG_MPC8541 ) || defined(CONFIG_MPC8555 ) -int ps2ser_check (void ); +static int kbd_read_keys (struct input_config *config) +{ +#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540 ) || \ + defined(CONFIG_MPC8541 ) || defined(CONFIG_MPC8555 ) +/* no ISR is used, so received chars must be polled */ +ps2ser_check ();#endif -static volatile char kbd_buffer[KBD_BUFFER_LEN ]; -static volatile int in_pointer =0 ; -static volatile int out_pointer =0 ; +return 1 ; +} -static unsigned char leds =0 ; -static unsigned char num_lock =0 ; -static unsigned char caps_lock =0 ; -static unsigned char scroll_lock =0 ; -static unsigned char shift =0 ; -static unsigned char ctrl =0 ; -static unsigned char alt =0 ; -static unsigned char e0 =0 ; +static int check_leds (int ret) +{ +int leds; -/****************************************************************** -* Queue handling -******************************************************************/ + leds =input_leds_changed (&config); +if (leds >=0 ) +pckbd_leds (leds); -/* puts character in the queue and sets up the in and out pointer */ -static void kbd_put_queue (char data) -{ -if ((in_pointer+1 )==KBD_BUFFER_LEN ) { -if (out_pointer==0 ) { -return ;/* buffer full */ - }else { - in_pointer=0 ; - } - }else { -if ((in_pointer+1 )==out_pointer) -return ;/* buffer full */ - in_pointer++; - } - kbd_buffer[in_pointer]=data; -return ; +return ret; }/* test if a character is in the queue */ static int kbd_testc (struct stdio_dev *dev) { -#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540 ) || defined(CONFIG_MPC8541 ) || defined(CONFIG_MPC8555 ) -/* no ISR is used, so received chars must be polled */ -ps2ser_check (); -#endif -if (in_pointer==out_pointer) -return (0 );/* no data */ -else -return (1 ); +return check_leds (input_tstc (&config)); }/* gets the character from the queue */ static int kbd_getc (struct stdio_dev *dev) { -char c; -while (in_pointer==out_pointer) { -#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540 ) || defined(CONFIG_MPC8541 ) || defined(CONFIG_MPC8555 ) -/* no ISR is used, so received chars must be polled */ -ps2ser_check (); -#endif - ;} -if ((out_pointer+1 )==KBD_BUFFER_LEN ) - out_pointer=0 ; -else - out_pointer++; - c=kbd_buffer[out_pointer]; -return (int )c; - +return check_leds (input_getc (&config)); } -/* Simple translation table for the keys */ - -static unsigned char kbd_plain_xlate[] = { -0xff ,0x1b ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,'\b' ,'\t' ,/* 0x00 - 0x0f */ -'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,'o' ,'p' ,'[' ,']' ,'\r' ,0xff ,'a' ,'s' ,/* 0x10 - 0x1f */ -'d' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,'\'' ,'`' ,0xff ,'\\' ,'z' ,'x' ,'c' ,'v' ,/* 0x20 - 0x2f */ -'b' ,'n' ,'m' ,',' ,'.' ,'/' ,0xff ,0xff ,0xff ,' ' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x30 - 0x3f */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,'7' ,'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ -'2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff - }; - -static unsigned char kbd_shift_xlate[] = { -0xff ,0x1b ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'_' ,'+' ,'\b' ,'\t' ,/* 0x00 - 0x0f */ -'Q' ,'W' ,'E' ,'R' ,'T' ,'Y' ,'U' ,'I' ,'O' ,'P' ,'{' ,'}' ,'\r' ,0xff ,'A' ,'S' ,/* 0x10 - 0x1f */ -'D' ,'F' ,'G' ,'H' ,'J' ,'K' ,'L' ,':' ,'"' ,'~' ,0xff ,'|' ,'Z' ,'X' ,'C' ,'V' ,/* 0x20 - 0x2f */ -'B' ,'N' ,'M' ,'<' ,'>' ,'?' ,0xff ,0xff ,0xff ,' ' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x30 - 0x3f */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,'7' ,'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ -'2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff - }; - -static unsigned char kbd_ctrl_xlate[] = { -0xff ,0x1b ,'1' ,0x00 ,'3' ,'4' ,'5' ,0x1E ,'7' ,'8' ,'9' ,'0' ,0x1F ,'=' ,'\b' ,'\t' ,/* 0x00 - 0x0f */ -0x11 ,0x17 ,0x05 ,0x12 ,0x14 ,0x18 ,0x15 ,0x09 ,0x0f ,0x10 ,0x1b ,0x1d ,'\n' ,0xff ,0x01 ,0x13 ,/* 0x10 - 0x1f */ -0x04 ,0x06 ,0x08 ,0x09 ,0x0a ,0x0b ,0x0c ,';' ,'\'' ,'~' ,0x00 ,0x1c ,0x1a ,0x18 ,0x03 ,0x16 ,/* 0x20 - 0x2f */ -0x02 ,0x0e ,0x0d ,'<' ,'>' ,'?' ,0xff ,0xff ,0xff ,0x00 ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x30 - 0x3f */ -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,'7' ,'8' ,'9' ,'-' ,'4' ,'5' ,'6' ,'+' ,'1' ,/* 0x40 - 0x4f */ -'2' ,'3' ,'0' ,'.' ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,/* 0x50 - 0x5F */ -'\r' ,0xff ,0xff - }; - - -void handle_scancode (unsigned char scancode) +void handle_scancode (unsigned char scan_code) { -unsigned char keycode; +bool release = false; -/* Convert scancode to keycode */ -PRINTF ("scancode %x\n" ,scancode); -if (scancode==0xe0 ) { - e0=1 ;/* special charakters */ -return ; - } -if (e0==1 ) { - e0=0 ;/* delete flag */ -if (!( ((scancode&0x7F )==0x38 )||/* the right ctrl key */ - ((scancode&0x7F )==0x1D )||/* the right alt key */ - ((scancode&0x7F )==0x35 )||/* the right '/' key */ - ((scancode&0x7F )==0x1C ) ))/* the right enter key */ -/* we swallow unknown e0 codes */ -return ; - } -/* special cntrl keys */ -switch (scancode) { -case 0x2A : -case 0x36 :/* shift pressed */ - shift=1 ; -return ;/* do nothing else */ -case 0xAA : -case 0xB6 :/* shift released */ - shift=0 ; -return ;/* do nothing else */ -case 0x38 :/* alt pressed */ - alt=1 ; -return ;/* do nothing else */ -case 0xB8 :/* alt released */ - alt=0 ; -return ;/* do nothing else */ -case 0x1d :/* ctrl pressed */ - ctrl=1 ; -return ;/* do nothing else */ -case 0x9d :/* ctrl released */ - ctrl=0 ; -return ;/* do nothing else */ -case 0x46 :/* scrollock pressed */ - scroll_lock=~scroll_lock; -if (scroll_lock==0 ) - leds&=~LED_SCR ;/* switch LED off */ -else - leds|=LED_SCR ;/* switch on LED */ -pckbd_leds (leds); -return ;/* do nothing else */ -case 0x3A :/* capslock pressed */ - caps_lock=~caps_lock; -if (caps_lock==0 ) - leds&=~LED_CAP ;/* switch caps_lock off */ -else - leds|=LED_CAP ;/* switch on LED */ -pckbd_leds (leds); -return ; -case 0x45 :/* numlock pressed */ - num_lock=~num_lock; -if (num_lock==0 ) - leds&=~LED_NUM ;/* switch LED off */ -else - leds|=LED_NUM ;/* switch on LED */ -pckbd_leds (leds); -return ; -case 0xC6 :/* scroll lock released */ -case 0xC5 :/* num lock released */ -case 0xBA :/* caps lock released */ -return ;/* just swallow */ - } -#if 1 -if ((scancode&0x80 )==0x80 )/* key released */ -return ; -#else -if ((scancode&0x80 )==0x00 )/* key pressed */ -return ; - scancode &= ~0x80 ; -#endif -/* now, decide which table we need */ -if (scancode > (sizeof (kbd_plain_xlate)/sizeof (kbd_plain_xlate[0 ]))) {/* scancode not in list */ -PRINTF ("unkown scancode %X\n" ,scancode); -return ;/* swallow it */ - } -/* setup plain code first */ - keycode=kbd_plain_xlate[scancode]; -if (caps_lock==1 ) {/* caps_lock is pressed, overwrite plain code */ -if (scancode > (sizeof (kbd_shift_xlate)/sizeof (kbd_shift_xlate[0 ]))) {/* scancode not in list */ -PRINTF ("unkown caps-locked scancode %X\n" ,scancode); -return ;/* swallow it */ - } - keycode=kbd_shift_xlate[scancode]; -if (keycode<'A' ) {/* we only want the alphas capital */ - keycode=kbd_plain_xlate[scancode]; - } - } -if (shift==1 ) {/* shift overwrites caps_lock */ -if (scancode > (sizeof (kbd_shift_xlate)/sizeof (kbd_shift_xlate[0 ]))) {/* scancode not in list */ -PRINTF ("unkown shifted scancode %X\n" ,scancode); -return ;/* swallow it */ - } - keycode=kbd_shift_xlate[scancode]; - } -if (ctrl==1 ) {/* ctrl overwrites caps_lock and shift */ -if (scancode > (sizeof (kbd_ctrl_xlate)/sizeof (kbd_ctrl_xlate[0 ]))) {/* scancode not in list */ -PRINTF ("unkown ctrl scancode %X\n" ,scancode); -return ;/* swallow it */ - } - keycode=kbd_ctrl_xlate[scancode]; - } -/* check if valid keycode */ -if (keycode==0xff ) { -PRINTF ("unkown scancode %X\n" ,scancode); -return ;/* swallow unknown codes */ +/* Compare with i8042_kbd_check() in i8042.c if some logic is missing */ +if (scan_code &0x80 ) { + scan_code &=0x7f ; + release = true; } -kbd_put_queue (keycode); -PRINTF ("%x\n" ,keycode); +input_add_keycode (&config, scan_code, release); } -/****************************************************************** -* Init -******************************************************************/ - -#ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE -extern int overwrite_console (void ); -#define OVERWRITE_CONSOLE overwrite_console () -#else -#define OVERWRITE_CONSOLE 0 -#endif /* CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE */ - +/* TODO: convert to driver model */ int kbd_init (void ) { -int error; -struct stdio_dev kbddev ; -char *stdinname =getenv ("stdin" ); +struct stdio_dev kbddev; +struct input_config *input = &config;if (kbd_init_hw ()==-1 )return -1 ;memset (&kbddev,0 ,sizeof (kbddev)); -strcpy (kbddev.name,DEVNAME ); +strcpy (kbddev.name,"kbd" ); kbddev.flags =DEV_FLAGS_INPUT |DEV_FLAGS_SYSTEM ; - kbddev.getc = kbd_getc ; - kbddev.tstc = kbd_testc ; + kbddev.getc = kbd_getc; + kbddev.tstc = kbd_testc; - error =stdio_register (&kbddev); -if (error==0 ) { -/* check if this is the standard input device */ -if (strcmp (stdinname,DEVNAME )==0 ) { -/* reassign the console */ -if (OVERWRITE_CONSOLE ) { -return 1 ; - } - error=console_assign (stdin,DEVNAME ); -if (error==0 ) -return 1 ; -else -return error; - } -return 1 ; - } -return error; +input_init (input,0 ); + input->read_keys = kbd_read_keys; +input_add_tables (input, true); + +return input_stdio_register (&kbddev); }
include/keyboard.h +5 -0
@@ -97,4 +97,9 @@ extern int kbd_init_hw(void);extern void pckbd_leds (unsigned char leds);#endif /* !CONFIG_DM_KEYBOARD */ +#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540 ) || \ + defined(CONFIG_MPC8541 ) || defined(CONFIG_MPC8555 ) +int ps2ser_check (void ); +#endif +#endif /* __KEYBOARD_H */
Signature · 1 line
2.6.0.rc0.131.gf624c3d