Skip to contentSkip to conversation

mkbp: Fix problems with backslash

PATCH In review Doug Anderson 2 participants 4 messages Dec 19, 2013 – Dec 20, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mkbp: Fix problems with backslash

The mkbp code (post 3.4) has an issue where it can't deal with two keys on the keyboard having the same keycode. When this happens it will get confused about whether the key is down or up and will cause some screwy behavior.

We need to have two keys on the keyboard with the same keycode for UK keyboards. Specifically:
* On the US keyboard the backslash key (above enter) is r3 c11 and is supposed to be reported as BACKSLASH.
* On the UK keyboard the # key (left of enter) is r4 c10 and is supposed to be reported as BACKSLASH.
* On the UK keyboard the \ key (left of Z) is r2 c7 and is supposed to be reported as KEY_102ND.

The above may be crazy, but that's how it's supposed to work so we need to handle two KEY_BACKSLASH keycodes. Luckily this is easy to handle.

(cherry picked from commit 3c56a5a6c1c69306371a4d5f37762044c87e4216)
---
 drivers/input/keyboard/cros_ec_keyb.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/input/keyboard/cros_ec_keyb.c +9 -1
index 7e8b0a5..65f6e52 100644
@@ -38,6 +38,7 @@
  * @row_shift: log2 or number of rows, rounded up
  * @keymap_data: Matrix keymap data used to convert to keyscan values
  * @ghost_filter: true to enable the matrix key-ghosting filter
+ * @old_kb_state: bitmap of keys pressed last scan
  * @dev: Device pointer
  * @idev: Input device
  * @ec: Top level ChromeOS device to use to talk to EC
@@ -49,6 +50,7 @@ struct cros_ec_keyb {
 	int row_shift;
 	const struct matrix_keymap_data *keymap_data;
 	bool ghost_filter;
+	uint8_t *old_kb_state;
 
 	struct device *dev;
 	struct input_dev *idev;
@@ -135,6 +137,7 @@ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev,
 	struct input_dev *idev = ckdev->idev;
 	int col, row;
 	int new_state;
+	int old_state;
 	int num_cols;
 
 	num_cols = len;
@@ -157,7 +160,8 @@ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev,
 
 			code = keycodes[pos];
 			new_state = kb_state[col] & (1 << row);
-			if (!!new_state != test_bit(code, idev->key)) {
+			old_state = ckdev->old_kb_state[col] & (1 << row);
+			if (new_state != old_state) {
 				dev_dbg(ckdev->dev,
 					"changed: [r%d c%d]: byte %02x\n",
 					row, col, new_state);
@@ -165,6 +169,7 @@ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev,
 				input_report_key(idev, code, new_state);
 			}
 		}
+		ckdev->old_kb_state[col] = kb_state[col];
 	}
 	input_sync(ckdev->idev);
 }
@@ -226,6 +231,9 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
 					    &ckdev->cols);
 	if (err)
 		return err;
+	ckdev->old_kb_state = devm_kzalloc(&pdev->dev, ckdev->cols, GFP_KERNEL);
+	if (!ckdev->old_kb_state)
+		return -ENOMEM;
 
 	idev = devm_input_allocate_device(&pdev->dev);
 	if (!idev)
Signature · 1 line
1.8.5.1
#1 lore raw

PATCH 2/3 ARM: dts: Add the missing "\" key in non-US keyboards for exynos5250-snow

When the exynos5250 device tree was sent upstream the keyboard mapping was missing the 2nd instance of the "\" key. There are two copies of the "\" because it simply has a different row and column on US and non-US keyboards.

For more details, see the previous patch in this series: (mkbp: Fix problems with backslash).

---
 arch/arm/boot/dts/exynos5250-snow.dts | 1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/exynos5250-snow.dts +1 -0
index fd711e2..28fe2e2 100644
@@ -130,6 +130,7 @@
 							0x04060024	/* J */
 							0x04080027	/* ; */
 							0x04090026	/* L */
+							0x040a002b	/* \ */
 							0x040b001c	/* ENTER */
 
 							0x0501002c	/* Z */
Signature · 1 line
1.8.5.1
#3 lore raw

PATCH 3/3 ARM: dts: Fix exynos5250-snow's search key to be L_META

In reply to Doug Anderson

The device tree sent upstream for exynos5250-snow encoded the search key as CAPSLK. However in all ChromeOS kernels it is L_META. One can certainly have long debates about which it ought to be, but I'm proposing setting it to L_META because:
* That's how _all_ ChromeOS kernels do it and will do it.
* There is no L_META key on the board, so it's nice to have.
* For those people who really want it to be caps lock, they can use xmodmap or somesuch.

---
 arch/arm/boot/dts/exynos5250-snow.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/exynos5250-snow.dts +1 -1
index 28fe2e2..c65f52a 100644
@@ -85,7 +85,7 @@
 				        keypad,num-rows = <8>;
 				        keypad,num-columns = <13>;
 				        google,needs-ghost-filter;
-					linux,keymap = <0x0001003a	/* CAPSLK */
+					linux,keymap = <0x0001007d	/* L_META */
 							0x0002003b	/* F1 */
 							0x00030030	/* B */
 							0x00040044	/* F10 */
Signature · 1 line
1.8.5.1
#2 lore raw

Re: [PATCH 2/3] ARM: dts: Add the missing "\" key in non-US keyboards for exynos5250-snow

In reply to Doug Anderson
Quoted 18 lines · Doug Anderson

When the exynos5250 device tree was sent upstream the keyboard mapping was missing the 2nd instance of the "\" key. There are two copies of the "\" because it simply has a different row and column on US and non-US keyboards.

For more details, see the previous patch in this series: (mkbp: Fix problems with backslash).

---
  arch/arm/boot/dts/exynos5250-snow.dts | 1 +
  1 file changed, 1 insertion(+)
arch/arm/boot/dts/exynos5250-snow.dts +0 -0
index fd711e2..28fe2e2 100644

arch/arm/boot/dts/exynos5250-snow.dts line 136

Quoted 7 lines
arch/arm/boot/dts/exynos5250-snow.dts +1 -0
@@ -130,6 +130,7 @@
  							0x04060024	/* J */
  							0x04080027	/* ; */
  							0x04090026	/* L */
+							0x040a002b	/* \ */
  							0x040b001c	/* ENTER */
 
  							0x0501002c	/* Z */

OK, Applied this(2/3) and next one(3/3) into fixes for v3.14.

If these patches should be sent for 3.13 or before, please let me know.

Thanks and Merry Christmas ;-)

- Kukjin