Skip to contentSkip to conversation

Add support for keys setting multiple bits in the scan

PATCH In review Vivien Chappelier 1 participant 1 message Jun 9, 2007

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

PATCH 11/12 Add support for keys setting multiple bits in the scan

This patch adds support for keypads with keys setting multiple bits in the scan when they are pressed. An example of such keys is the HTC Typhoon stick for which scanning column zero will return the following bit patterns depending on the direction:

LEFT:  00000011  
RIGHT: 00001100
UP:    00000101
DOWN:  00001010

In this case, the key being pressed cannot be determined from a single bit.

---
 arch/arm/mach-omap1/board-ams-delta.c |    2 -
 arch/arm/mach-omap1/board-fsample.c   |    1 -
 arch/arm/mach-omap1/board-h2.c        |    3 +-
 arch/arm/mach-omap1/board-h3.c        |    3 +-
 arch/arm/mach-omap1/board-innovator.c |    3 +-
 arch/arm/mach-omap1/board-nokia770.c  |    1 -
 arch/arm/mach-omap1/board-osk.c       |    1 -
 arch/arm/mach-omap1/board-palmte.c    |    1 -
 arch/arm/mach-omap1/board-palmz71.c   |    1 -
 arch/arm/mach-omap1/board-perseus2.c  |    3 +-
 arch/arm/mach-omap1/board-sx1.c       |    1 -
 arch/arm/mach-omap1/board-typhoon.c   |   61 +++++++++++++++++
 arch/arm/mach-omap2/board-2430sdp.c   |    1 -
 arch/arm/mach-omap2/board-h4.c        |    3 +-
 drivers/input/keyboard/omap-keypad.c  |  117 +++++++++++++++++----------------
 include/asm-arm/arch-omap/keypad.h    |   12 +++-
 16 files changed, 134 insertions(+), 80 deletions(-)
arch/arm/mach-omap1/board-ams-delta.c +0 -2
index c73ca61..51c1778 100644
@@ -109,8 +109,6 @@ static int ams_delta_keymap[] = {
 
 	KEY(0, 7, KEY_LEFTSHIFT),	/* Vol up    */
 	KEY(3, 7, KEY_LEFTCTRL),	/* Vol down  */
-
-	0
 };
 
 void ams_delta_latch1_write(u8 mask, u8 value)
arch/arm/mach-omap1/board-fsample.c +0 -1
index f65baa9..ade0ebf 100644
@@ -66,7 +66,6 @@ static int fsample_keymap[] = {
 	KEY(4,3,KEY_7),
 	KEY(4,4,KEY_STAR),
 	KEY(4,5,KEY_POWER),
-	0
 };
 
 static struct resource smc91x_resources[] = {
arch/arm/mach-omap1/board-h2.c +1 -2
index d2214ad..2aac5d7 100644
@@ -50,7 +50,7 @@
 
 extern int omap_gpio_init(void);
 
-static int h2_keymap[] = {
+static struct kp_key h2_keymap[] = {
 	KEY(0, 0, KEY_LEFT),
 	KEY(0, 1, KEY_RIGHT),
 	KEY(0, 2, KEY_3),
@@ -86,7 +86,6 @@ static int h2_keymap[] = {
 	KEY(5, 2, KEY_F15),
 	KEY(5, 3, KEY_F16),
 	KEY(5, 4, KEY_SLEEP),
-	0
 };
 
 static struct mtd_partition h2_nor_partitions[] = {
arch/arm/mach-omap1/board-h3.c +1 -2
index df77cf5..2d1cbaa 100644
@@ -52,7 +52,7 @@
 
 extern int omap_gpio_init(void);
 
-static int h3_keymap[] = {
+static struct kp_key h3_keymap[] = {
 	KEY(0, 0, KEY_LEFT),
 	KEY(0, 1, KEY_RIGHT),
 	KEY(0, 2, KEY_3),
@@ -88,7 +88,6 @@ static int h3_keymap[] = {
 	KEY(5, 2, KEY_F15),
 	KEY(5, 3, KEY_F16),
 	KEY(5, 4, KEY_SLEEP),
-	0
 };
 
 
arch/arm/mach-omap1/board-innovator.c +1 -2
index 7e63a41..1f2d0ff 100644
@@ -40,7 +40,7 @@
 #include <asm/arch/mcbsp.h>
 #include <asm/arch/omap-alsa.h>
 
-static int innovator_keymap[] = {
+static struct kp_key innovator_keymap[] = {
 	KEY(0, 0, KEY_F1),
 	KEY(0, 3, KEY_DOWN),
 	KEY(1, 1, KEY_F2),
@@ -50,7 +50,6 @@ static int innovator_keymap[] = {
 	KEY(2, 2, KEY_UP),
 	KEY(3, 2, KEY_ENTER),
 	KEY(3, 3, KEY_LEFT),
-	0
 };
 
 static struct mtd_partition innovator_partitions[] = {
arch/arm/mach-omap1/board-nokia770.c +0 -1
index df5bda2..610bbe6 100644
@@ -68,7 +68,6 @@ static int nokia770_keymap[] = {
 	KEY(3, 0, GROUP_2 | KEY_F7),
 	KEY(3, 1, GROUP_2 | KEY_F8),
 	KEY(3, 2, GROUP_2 | KEY_F6),
-	0
 };
 
 static struct resource nokia770_kp_resources[] = {
arch/arm/mach-omap1/board-osk.c +0 -1
index 39bc977..100ffb6 100644
@@ -264,7 +264,6 @@ static const int osk_keymap[] = {
 	KEY(2, 2, KEY_DOWN),		/* (sw2/down) */
 	KEY(3, 2, KEY_ENTER),		/* (sw2/select) */
 	KEY(3, 3, KEY_RIGHT),		/* (sw2/right) */
-	0
 };
 
 static struct omap_kp_platform_data osk_kp_data = {
arch/arm/mach-omap1/board-palmte.c +0 -1
index e5e0957..587144a 100644
@@ -65,7 +65,6 @@ static const int palmte_keymap[] = {
 	KEY(1, 2, KEY_UP),
 	KEY(1, 3, KEY_RIGHT),
 	KEY(1, 4, KEY_CENTER),
-	0,
 };
 
 static struct omap_kp_platform_data palmte_kp_data = {
arch/arm/mach-omap1/board-palmz71.c +0 -1
index 6b49c71..240e3be 100644
@@ -68,7 +68,6 @@ static int palmz71_keymap[] = {
 	KEY(1, 3, KEY_RIGHT),
 	KEY(1, 4, KEY_CENTER),
 	KEY(2, 0, KEY_CAMERA),
-	0,
 };
 
 static struct omap_kp_platform_data palmz71_kp_data = {
arch/arm/mach-omap1/board-perseus2.c +1 -2
index 2dec048..62244ab 100644
@@ -34,7 +34,7 @@
 #include <asm/arch/common.h>
 #include <asm/arch/board.h>
 
-static int p2_keymap[] = {
+static struct kp_key p2_keymap[] = {
 	KEY(0,0,KEY_UP),
 	KEY(0,1,KEY_RIGHT),
 	KEY(0,2,KEY_LEFT),
@@ -65,7 +65,6 @@ static int p2_keymap[] = {
 	KEY(4,3,KEY_7),
 	KEY(4,4,KEY_STAR),
 	KEY(4,5,KEY_POWER),
-	0
 };
 
 static struct resource smc91x_resources[] = {
arch/arm/mach-omap1/board-sx1.c +0 -1
index f25ec6f..9c56d59 100644
@@ -202,7 +202,6 @@ static int sx1_keymap[] = {
 	KEY(2, 1, GROUP_1 | KEY_LEFTSHIFT), /* shift */
 	KEY(1, 1, GROUP_1 | KEY_BACKSPACE), /* C (clear) */
 	KEY(0, 2, GROUP_1 | KEY_F7),	/* menu Qt::Key_Menu */
-	0
 };
 
 static struct resource sx1_kp_resources[] = {
arch/arm/mach-omap1/board-typhoon.c +61 -0

75 lines not on this page · raw message

arch/arm/mach-omap2/board-2430sdp.c +0 -1
index 047a4e6..4be37fb 100644
@@ -167,7 +167,6 @@ static int sdp2430_keymap[] = {
 	KEY(5, 2, KEY_L),
 	KEY(5, 3, KEY_S),
 	KEY(5, 4, KEY_H),
-	0
 };
 
 static struct omap_kp_platform_data sdp2430_kp_data = {
arch/arm/mach-omap2/board-h4.c +1 -2
index f476c57..8431df0 100644
@@ -48,7 +48,7 @@
 static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
 static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
 
-static int h4_keymap[] = {
+static struct kp_key h4_keymap[] = {
 	KEY(0, 0, KEY_LEFT),
 	KEY(0, 1, KEY_RIGHT),
 	KEY(0, 2, KEY_A),
@@ -79,7 +79,6 @@ static int h4_keymap[] = {
 	KEY(5, 2, KEY_L),
 	KEY(5, 3, KEY_S),
 	KEY(5, 4, KEY_ENTER),
-	0
 };
 
 static struct mtd_partition h4_partitions[] = {
drivers/input/keyboard/omap-keypad.c +59 -58

191 lines not on this page · raw message

include/asm-arm/arch-omap/keypad.h +9 -3
index b7f8307..f976088 100644
@@ -10,10 +10,15 @@
 #ifndef ASMARM_ARCH_KEYPAD_H
 #define ASMARM_ARCH_KEYPAD_H
 
+struct kp_key {
+	u64 keycode;
+	unsigned int key;
+};
+
 struct omap_kp_platform_data {
 	int rows;
 	int cols;
-	int *keymap;
+	struct kp_key *keymap;
 	unsigned int keymapsize;
 	unsigned int rep:1;
 	unsigned long delay;
@@ -23,6 +28,9 @@ struct omap_kp_platform_data {
 	unsigned int *col_gpios;
 };
 
+#define MULTIKEY(mask, val) { .keycode = mask, .key = val }
+#define KEY(col, row, val) MULTIKEY(((u64) (1 << row)) << (8 * (col)), val)
+
 /* Group (0..3) -- when multiple keys are pressed, only the
  * keys pressed in the same group are considered as pressed. This is
  * in order to workaround certain crappy HW designs that produce ghost
@@ -33,7 +41,5 @@ struct omap_kp_platform_data {
 #define GROUP_3		(3 << 16)
 #define GROUP_MASK	GROUP_3
 
-#define KEY(col, row, val) (((col) << 28) | ((row) << 24) | (val))
-
 #endif
 
Signature · 1 line
1.5.1.3