Skip to contentSkip to conversation

input: Save keyboard's LED state to correct place

PATCH New Bin Meng 2 participants 18 messages Nov 12, 2015 – Nov 14, 2015

Subsystems (2)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/6 input: Save keyboard's LED state to correct place

Currently keyboard's LED state is wrongly saved to config->leds in process_modifier(). It should really be config->flags.

---

 drivers/input/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/input.c +1 -1
index bf1acdc..79edda5 100644
@@ -268,7 +268,7 @@ static struct input_key_xlate *process_modifier(struct input_config *config,
 		if (flip != -1) {
 			int leds = 0;
 
-			config->leds ^= flip;
+			config->flags ^= flip;
 			if (config->flags & FLAG_NUM_LOCK)
 				leds |= INPUT_LED_NUM;
 			if (config->flags & FLAG_CAPS_LOCK)
Signature · 1 line
1.8.2.1
author
#1 lore raw

PATCH 2/6 input: Call keyboard's update_leds() method when the LEDs change

We should request keyboard to turn on/off its LED when detecting any changes on the LEDs.

---

 drivers/input/input.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/input/input.c +9 -0
index 79edda5..0926de5 100644
@@ -9,9 +9,11 @@
 
 #include <common.h>
 #include <console.h>
+#include <dm.h>
 #include <errno.h>
 #include <stdio_dev.h>
 #include <input.h>
+#include <keyboard.h>
 #include <linux/input.h>
 
 enum {
@@ -236,6 +238,8 @@ int input_getc(struct input_config *config)
 static struct input_key_xlate *process_modifier(struct input_config *config,
 						int key, int release)
 {
+	struct udevice *dev = config->dev;
+	struct keyboard_ops *ops = keyboard_get_ops(dev);
 	struct input_key_xlate *table;
 	int i;
 
@@ -277,6 +281,11 @@ static struct input_key_xlate *process_modifier(struct input_config *config,
 				leds |= INPUT_LED_SCROLL;
 			config->leds = leds;
 			config->leds_changed = flip;
+
+			if (ops->update_leds) {
+				if (ops->update_leds(dev, config->leds))
+					debug("Update keyboard's LED failed\n");
+			}
 		}
 	}
 
Signature · 1 line
1.8.2.1
#3 lore raw

PATCH 2/6 input: Call keyboard's update_leds() method when the LEDs change

Updated to fix build errors when CONFIG_DM_KEYBOARD is not enabled, and

Applied to u-boot-dm, thanks!

author
#4 lore raw

PATCH 3/6 input: Change LED state bits to conform i8042 compatible keyboard

In reply to Bin Meng

When sending LED update command to an i8042 compatible keyboard, bit1 is 'Num Lock' and bit2 is 'Caps Lock' in the data byte. But input library defines bit1 as 'Caps Lock' and bit2 as 'Num Lock'. This causes a wrong LED to be set on an i8042 compatible keyboard. Change the LED state bits to be i8042 compatible, and change the keyboard flags as well.

---

 drivers/input/input.c | 6 +++---
 include/input.h       | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/input/input.c +3 -3
index 0926de5..5c3fad9 100644
@@ -18,9 +18,9 @@
 
 enum {
 	/* These correspond to the lights on the keyboard */
-	FLAG_NUM_LOCK		= 1 << 0,
-	FLAG_CAPS_LOCK		= 1 << 1,
-	FLAG_SCROLL_LOCK	= 1 << 2,
+	FLAG_SCROLL_LOCK	= 1 << 0,
+	FLAG_NUM_LOCK		= 1 << 1,
+	FLAG_CAPS_LOCK		= 1 << 2,
 
 	/* Special flag ORed with key code to indicate release */
 	KEY_RELEASE		= 1 << 15,
include/input.h +2 -2
index ad120e4..2902b07 100644
@@ -17,8 +17,8 @@ enum {
 enum {
 	/* Keyboard LEDs */
 	INPUT_LED_SCROLL	= 1 << 0,
-	INPUT_LED_CAPS		= 1 << 1,
-	INPUT_LED_NUM		= 1 << 2,
+	INPUT_LED_NUM		= 1 << 1,
+	INPUT_LED_CAPS		= 1 << 2,
 };
 
 /*
Signature · 1 line
1.8.2.1
#5 lore raw

PATCH 3/6 input: Change LED state bits to conform i8042 compatible keyboard

Quoted 7 lines · Bin Meng

When sending LED update command to an i8042 compatible keyboard, bit1 is 'Num Lock' and bit2 is 'Caps Lock' in the data byte. But input library defines bit1 as 'Caps Lock' and bit2 as 'Num Lock'. This causes a wrong LED to be set on an i8042 compatible keyboard. Change the LED state bits to be i8042 compatible, and change the keyboard flags as well.

Quoted 6 lines

---

 drivers/input/input.c | 6 +++---
 include/input.h       | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
#6 lore raw

PATCH 3/6 input: Change LED state bits to conform i8042 compatible keyboard

Applied to u-boot-dm, thanks!

author
#7 lore raw

PATCH 4/6 input: Ban digit numbers if 'Num Lock' is not on

In reply to Bin Meng

When 'Num Lock' is not on, we should not send these digit numbers (0-9 and dot) to the output buffer.

---

 drivers/input/input.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/input/input.c +6 -0
index 5c3fad9..23afd06 100644
@@ -474,6 +474,12 @@ static int input_keycodes_to_ascii(struct input_config *config,
 			if ((config->flags & FLAG_CAPS_LOCK) &&
 			    ch >= 'a' && ch <= 'z')
 				ch -= 'a' - 'A';
+			/* ban digit numbers if 'Num Lock' is not on */
+			if (!(config->flags & FLAG_NUM_LOCK)) {
+				if (key >= KEY_KP7 && key <= KEY_KPDOT &&
+				    key != KEY_KPMINUS && key != KEY_KPPLUS)
+					ch = 0xff;
+			}
 			if (ch_count < max_chars && ch != 0xff)
 				output_ch[ch_count++] = (uchar)ch;
 		} else {
Signature · 1 line
1.8.2.1
#9 lore raw

PATCH 4/6 input: Ban digit numbers if 'Num Lock' is not on

Applied to u-boot-dm, thanks!

author
#10 lore raw

PATCH 5/6 x86: crownbay: Convert to use driver model keyboard

In reply to Bin Meng

Convert to use driver model keyboard on Intel Crown Bay.

---

 arch/x86/dts/crownbay.dts  | 1 +
 include/configs/crownbay.h | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/dts/crownbay.dts +1 -0
index 3e354c4..eb8421c 100644
@@ -10,6 +10,7 @@
 
 /include/ "skeleton.dtsi"
 /include/ "serial.dtsi"
+/include/ "keyboard.dtsi"
 /include/ "rtc.dtsi"
 
 / {
include/configs/crownbay.h +1 -1
index 7f91fff..334a487 100644
@@ -35,7 +35,7 @@
 #define CONFIG_SYS_EARLY_PCI_INIT
 #define CONFIG_PCI_PNP
 
-#define CONFIG_STD_DEVICES_SETTINGS	"stdin=serial,vga,usbkbd\0" \
+#define CONFIG_STD_DEVICES_SETTINGS	"stdin=serial,i8042-kbd,usbkbd\0" \
 					"stdout=serial,vga\0" \
 					"stderr=serial,vga\0"
 
Signature · 1 line
1.8.2.1
#12 lore raw

PATCH 5/6 x86: crownbay: Convert to use driver model keyboard

Applied to u-boot-dm, thanks!

author
#13 lore raw

PATCH 6/6 x86: qemu: Convert to use driver model keyboard

In reply to Bin Meng

Convert to use driver model keyboard on QEMU.

---

 arch/x86/dts/qemu-x86_i440fx.dts | 1 +
 arch/x86/dts/qemu-x86_q35.dts    | 1 +
 include/configs/qemu-x86.h       | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/dts/qemu-x86_i440fx.dts +1 -0
index fc74cd0..8da7e52 100644
@@ -10,6 +10,7 @@
 
 /include/ "skeleton.dtsi"
 /include/ "serial.dtsi"
+/include/ "keyboard.dtsi"
 /include/ "rtc.dtsi"
 
 / {
arch/x86/dts/qemu-x86_q35.dts +1 -0
index 7f16971..df30c89 100644
@@ -20,6 +20,7 @@
 
 /include/ "skeleton.dtsi"
 /include/ "serial.dtsi"
+/include/ "keyboard.dtsi"
 /include/ "rtc.dtsi"
 
 / {
include/configs/qemu-x86.h +1 -1
index 1b544c1..9daf943 100644
@@ -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"
 
Signature · 1 line
1.8.2.1
#14 lore raw

PATCH 6/6 x86: qemu: Convert to use driver model keyboard

Quoted 9 lines · Bin Meng

Convert to use driver model keyboard on QEMU.

---

 arch/x86/dts/qemu-x86_i440fx.dts | 1 +
 arch/x86/dts/qemu-x86_q35.dts    | 1 +
 include/configs/qemu-x86.h       | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)
#15 lore raw

PATCH 6/6 x86: qemu: Convert to use driver model keyboard

Applied to u-boot-dm, thanks!

#17 lore raw

PATCH 1/6 input: Save keyboard's LED state to correct place

Applied to u-boot-dm, thanks!