public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] mkbp: Fix problems with backslash
@ 2013-12-19 22:36 Doug Anderson
  2013-12-19 22:36 ` [PATCH 2/3] ARM: dts: Add the missing "\" key in non-US keyboards for exynos5250-snow Doug Anderson
  2013-12-19 22:36 ` [PATCH 3/3] ARM: dts: Fix exynos5250-snow's search key to be L_META Doug Anderson
  0 siblings, 2 replies; 4+ messages in thread
From: Doug Anderson @ 2013-12-19 22:36 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Simon Glass, Samuel Ortiz, Olof Johansson, Kukjin Kim,
	Doug Anderson, Vincent Palatin, Luigi Semenzato, linux-input,
	linux-kernel

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.

Signed-off-by: Doug Anderson <dianders@chromium.org>
(cherry picked from commit 3c56a5a6c1c69306371a4d5f37762044c87e4216)
---
 drivers/input/keyboard/cros_ec_keyb.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 7e8b0a5..65f6e52 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -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)
-- 
1.8.5.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] ARM: dts: Add the missing "\" key in non-US keyboards for exynos5250-snow
  2013-12-19 22:36 [PATCH 1/3] mkbp: Fix problems with backslash Doug Anderson
@ 2013-12-19 22:36 ` Doug Anderson
  2013-12-20 21:08   ` Kukjin Kim
  2013-12-19 22:36 ` [PATCH 3/3] ARM: dts: Fix exynos5250-snow's search key to be L_META Doug Anderson
  1 sibling, 1 reply; 4+ messages in thread
From: Doug Anderson @ 2013-12-19 22:36 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Simon Glass, Samuel Ortiz, Olof Johansson, Kukjin Kim,
	Doug Anderson, Ben Dooks, Russell King, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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).

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 arch/arm/boot/dts/exynos5250-snow.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/exynos5250-snow.dts b/arch/arm/boot/dts/exynos5250-snow.dts
index fd711e2..28fe2e2 100644
--- a/arch/arm/boot/dts/exynos5250-snow.dts
+++ b/arch/arm/boot/dts/exynos5250-snow.dts
@@ -130,6 +130,7 @@
 							0x04060024	/* J */
 							0x04080027	/* ; */
 							0x04090026	/* L */
+							0x040a002b	/* \ */
 							0x040b001c	/* ENTER */
 
 							0x0501002c	/* Z */
-- 
1.8.5.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] ARM: dts: Fix exynos5250-snow's search key to be L_META
  2013-12-19 22:36 [PATCH 1/3] mkbp: Fix problems with backslash Doug Anderson
  2013-12-19 22:36 ` [PATCH 2/3] ARM: dts: Add the missing "\" key in non-US keyboards for exynos5250-snow Doug Anderson
@ 2013-12-19 22:36 ` Doug Anderson
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Anderson @ 2013-12-19 22:36 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Simon Glass, Samuel Ortiz, Olof Johansson, Kukjin Kim,
	Doug Anderson, Ben Dooks, Russell King, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

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.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 arch/arm/boot/dts/exynos5250-snow.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos5250-snow.dts b/arch/arm/boot/dts/exynos5250-snow.dts
index 28fe2e2..c65f52a 100644
--- a/arch/arm/boot/dts/exynos5250-snow.dts
+++ b/arch/arm/boot/dts/exynos5250-snow.dts
@@ -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 */
-- 
1.8.5.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/3] ARM: dts: Add the missing "\" key in non-US keyboards for exynos5250-snow
  2013-12-19 22:36 ` [PATCH 2/3] ARM: dts: Add the missing "\" key in non-US keyboards for exynos5250-snow Doug Anderson
@ 2013-12-20 21:08   ` Kukjin Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Kukjin Kim @ 2013-12-20 21:08 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Dmitry Torokhov, Simon Glass, Samuel Ortiz, Olof Johansson,
	Kukjin Kim, Ben Dooks, Russell King, linux-arm-kernel,
	linux-samsung-soc, linux-kernel

On 12/20/13 07:36, Doug Anderson wrote:
> 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).
>
> Signed-off-by: Doug Anderson<dianders@chromium.org>
> ---
>   arch/arm/boot/dts/exynos5250-snow.dts | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/boot/dts/exynos5250-snow.dts b/arch/arm/boot/dts/exynos5250-snow.dts
> index fd711e2..28fe2e2 100644
> --- a/arch/arm/boot/dts/exynos5250-snow.dts
> +++ b/arch/arm/boot/dts/exynos5250-snow.dts
> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-20 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-19 22:36 [PATCH 1/3] mkbp: Fix problems with backslash Doug Anderson
2013-12-19 22:36 ` [PATCH 2/3] ARM: dts: Add the missing "\" key in non-US keyboards for exynos5250-snow Doug Anderson
2013-12-20 21:08   ` Kukjin Kim
2013-12-19 22:36 ` [PATCH 3/3] ARM: dts: Fix exynos5250-snow's search key to be L_META Doug Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox