Skip to contentSkip to conversation

keypad: platform_data and 24xx support -exp

PATCH In review Komal Shah 3 participants 5 messages Dec 10, 2005 – Jan 20, 2006

Subsystems (9)
lore
Share & tools
lore

Komal Shah

author
#0 lore raw

PATCH 1/1 keypad: platform_data and 24xx support -exp

Tony/Brian,

I have attached patch which includes:

o Modification suggested by Brian Swetland
o Added platform_data structure
- keymap is moved to appropriate board files.
- rows and cols fields are not used in the driver yet.
- rep bit is added.
o IRQ resource
o Added 24xx+menelaus keypad support - tested.

TODO/FIXME:
o appropriate place for test_keymap.

o Removing NUM_COLS/ROWS #defines and replacing with platform_data->rows/cols.

o Moving request_gpio/free_gpio to board specific file, by introducing one function in platform_data ? Is this ok? e.g get/put_gpios. As driver should work as module too.

o How to handle row_/col_gpio_num array and set_/get_gpio_val functions ? I want to keep them out of this keypad.c. Any suggestions?

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

arch/arm/mach-omap1/board-h2.c +66 -0
index 0fc2e0f..371a704 100644
@@ -37,10 +37,50 @@
 #include <asm/arch/mux.h>
 #include <asm/arch/tc.h>
 #include <asm/arch/usb.h>
+#include <asm/arch/keypad.h>
 #include <asm/arch/common.h>
 
 extern int omap_gpio_init(void);
 
+static int h2_keymap[] = {
+	KEY(0, 0, KEY_LEFT),
+	KEY(0, 1, KEY_RIGHT),
+	KEY(0, 2, KEY_3),
+	KEY(0, 3, KEY_F10),
+	KEY(0, 4, KEY_F5),
+	KEY(0, 5, KEY_9),
+	KEY(1, 0, KEY_DOWN),
+	KEY(1, 1, KEY_UP),
+	KEY(1, 2, KEY_2),
+	KEY(1, 3, KEY_F9),
+	KEY(1, 4, KEY_F7),
+	KEY(1, 5, KEY_0),
+	KEY(2, 0, KEY_ENTER),
+	KEY(2, 1, KEY_6),
+	KEY(2, 2, KEY_1),
+	KEY(2, 3, KEY_F2),
+	KEY(2, 4, KEY_F6),
+	KEY(2, 5, KEY_HOME),
+	KEY(3, 0, KEY_8),
+	KEY(3, 1, KEY_5),
+	KEY(3, 2, KEY_F12),
+	KEY(3, 3, KEY_F3),
+	KEY(3, 4, KEY_F8),
+	KEY(3, 5, KEY_END),
+	KEY(4, 0, KEY_7),
+	KEY(4, 1, KEY_4),
+	KEY(4, 2, KEY_F11),
+	KEY(4, 3, KEY_F1),
+	KEY(4, 4, KEY_F4),
+	KEY(4, 5, KEY_ESC),
+	KEY(5, 0, KEY_F13),
+	KEY(5, 1, KEY_F14),
+	KEY(5, 2, KEY_F15),
+	KEY(5, 3, KEY_F16),
+	KEY(5, 4, KEY_SLEEP),
+	0
+};
+
 static struct mtd_partition h2_nor_partitions[] = {
 	/* bootloader (U-Boot, etc) in first sector */
 	{
@@ -171,10 +211,36 @@ static struct platform_device h2_smc91x_
 	.resource	= h2_smc91x_resources,
 };
 
+static struct resource h2_kp_resources[] = {
+	[0] = {
+		.start	= INT_KEYBOARD,
+		.end	= INT_KEYBOARD,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct omap_kp_platform_data h2_kp_data = {
+	.rows	= 8,
+	.cols	= 8,
+	.keymap = h2_keymap,
+	.rep	= 1,
+};
+
+static struct platform_device h2_kp_device = {
+	.name		= "omap-keypad",
+	.id		= -1,
+	.dev		= {
+		.platform_data = &h2_kp_data,
+	},
+	.num_resources	= ARRAY_SIZE(h2_kp_resources),
+	.resource	= h2_kp_resources,
+};
+
 static struct platform_device *h2_devices[] __initdata = {
 	&h2_nor_device,
 	&h2_nand_device,
 	&h2_smc91x_device,
+	&h2_kp_device,
 };
 
 static void __init h2_init_smc91x(void)
arch/arm/mach-omap1/board-h3.c +67 -0

94 lines not on this page · raw message

arch/arm/mach-omap1/board-innovator.c +41 -0

73 lines not on this page · raw message

arch/arm/mach-omap1/board-osk.c +40 -0
index e990e1b..013a4dd 100644
@@ -33,6 +33,7 @@
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/input.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -44,8 +45,22 @@
 #include <asm/arch/usb.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/tc.h>
+#include <asm/arch/keypad.h>
 #include <asm/arch/common.h>
 
+static int osk_keymap[] = {
+	KEY(0, 0, KEY_F1),
+	KEY(0, 3, KEY_UP),
+	KEY(1, 1, KEY_LEFTCTRL),
+	KEY(1, 2, KEY_LEFT),
+	KEY(2, 0, KEY_SPACE),
+	KEY(2, 1, KEY_ESC),
+	KEY(2, 2, KEY_DOWN),
+	KEY(3, 2, KEY_ENTER),
+	KEY(3, 3, KEY_RIGHT),
+	0 
+}; 
+
 static struct mtd_partition osk_partitions[] = {
 	/* bootloader (U-Boot, etc) in first sector */
 	{
@@ -138,11 +153,36 @@ static struct platform_device osk5912_mc
 	.id		= 1,
 };
 
+static struct resource osk5912_kp_resources[] = {
+	[0] = {
+		.start	= INT_KEYBOARD,
+		.end	= INT_KEYBOARD,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct omap_kp_platform_data osk_kp_data = {
+	.rows	= 8,
+	.cols	= 8,
+	.keymap = osk_keymap,
+};
+
+static struct platform_device osk5912_kp_device = {
+	.name		= "omap-keypad",
+	.id		= -1,
+	.dev		= {
+		.platform_data = &osk_kp_data,
+	},
+	.num_resources	= ARRAY_SIZE(osk5912_kp_resources),
+	.resource	= osk5912_kp_resources,
+};
+
 static struct platform_device *osk5912_devices[] __initdata = {
 	&osk5912_flash_device,
 	&osk5912_smc91x_device,
 	&osk5912_cf_device,
 	&osk5912_mcbsp1_device,
+	&osk5912_kp_device,
 };
 
 static void __init osk_init_smc91x(void)
arch/arm/mach-omap1/board-perseus2.c +61 -0

86 lines not on this page · raw message

arch/arm/mach-omap2/board-h4.c +52 -0

78 lines not on this page · raw message

arch/arm/mach-omap2/mux.c +20 -0
index ea46548..ab4eaae 100644
@@ -54,6 +54,26 @@ MUX_CFG_24XX("W19_24XX_SYS_NIRQ",	0x12c,
 MUX_CFG_24XX("Y20_24XX_GPIO60",		0x12c,	3,	0,	0,	1)
 MUX_CFG_24XX("M15_24XX_GPIO92",		0x10a,	3,	0,	0,	1)
 
+/* Keypad GPIO*/
+MUX_CFG_24XX("T19_24XX_KBR0",		0x106,	3,	1,	1,	1)
+MUX_CFG_24XX("R19_24XX_KBR1",		0x107,	3,	1,	1,	1)
+MUX_CFG_24XX("V18_24XX_KBR2",		0x139,	3,	1,	1,	1)
+MUX_CFG_24XX("M21_24XX_KBR3",		0xc9,	3,	1,	1,	1)
+MUX_CFG_24XX("E5__24XX_KBR4",		0x138,	3,	1,	1,	1)
+MUX_CFG_24XX("M18_24XX_KBR5",		0x10e,	3,	1,	1,	1)
+MUX_CFG_24XX("R20_24XX_KBC0",		0x108,	3,	0,	0,	1)
+MUX_CFG_24XX("M14_24XX_KBC1",		0x109,	3,	0,	0,	1)
+MUX_CFG_24XX("H19_24XX_KBC2",		0x114,	3,	0,	0,	1)
+MUX_CFG_24XX("V17_24XX_KBC3",		0x135,	3,	0,	0,	1)
+MUX_CFG_24XX("P21_24XX_KBC4",		0xca,	3,	0,	0,	1)
+MUX_CFG_24XX("L14_24XX_KBC5",		0x10f,	3,	0,	0,	1)
+MUX_CFG_24XX("N19_24XX_KBC6",		0x110,	3,	0,	0,	1)
+
+/* 24xx Meneluase Keypad GPIO */
+MUX_CFG_24XX("B3__24XX_KBR5",		0x30,	3,	1,	1,	1)
+MUX_CFG_24XX("AA4_24XX_KBC2",		0xe7,	3,	0,	0,	1)
+MUX_CFG_24XX("B13_24XX_KBC6",		0x110,	3,	0,	0,	1)
+
 };
 
 int __init omap2_mux_init(void)
arch/arm/plat-omap/devices.c +21 -0
index 1bb1058..cc22364 100644
@@ -24,6 +24,7 @@
 #include <asm/arch/board.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/menelaus.h>
 
 
 void omap_nop_release(struct device *dev)
@@ -126,6 +127,26 @@ static void omap_init_kp(void)
 		omap_cfg_reg(E4_730_KBC2);
 		omap_cfg_reg(F4_730_KBC3);
 		omap_cfg_reg(E3_730_KBC4);
+	} else if (machine_is_omap_h4()) {
+		omap_cfg_reg(T19_24XX_KBR0);
+		omap_cfg_reg(R19_24XX_KBR1);
+		omap_cfg_reg(V18_24XX_KBR2);
+		omap_cfg_reg(M21_24XX_KBR3);
+		omap_cfg_reg(E5__24XX_KBR4);
+		if (omap_has_menelaus()) {
+			omap_cfg_reg(B3__24XX_KBR5);
+			omap_cfg_reg(AA4_24XX_KBC2);
+			omap_cfg_reg(B13_24XX_KBC6);
+		} else {
+			omap_cfg_reg(M18_24XX_KBR5);
+			omap_cfg_reg(H19_24XX_KBC2);
+			omap_cfg_reg(N19_24XX_KBC6);
+		}
+		omap_cfg_reg(R20_24XX_KBC0);
+		omap_cfg_reg(M14_24XX_KBC1);
+		omap_cfg_reg(V17_24XX_KBC3);
+		omap_cfg_reg(P21_24XX_KBC4);
+		omap_cfg_reg(L14_24XX_KBC5);
 	}
 }
 #else
drivers/char/omap-rtc.c +0 -0
drivers/input/keyboard/Kconfig +1 -1
index a52757c..303915d 100644
@@ -196,7 +196,7 @@ config KEYBOARD_HIL
 
 config KEYBOARD_OMAP
 	tristate "TI OMAP keypad support"
-	depends on ARCH_OMAP1
+	depends on (ARCH_OMAP1 || ARCH_OMAP2)
 	help
 	  Say Y here if you want to use the OMAP keypad.
 
drivers/input/keyboard/omap-keypad.c +147 -138

387 lines not on this page · raw message

drivers/mmc/omap.c +0 -0
drivers/mtd/maps/omap_nor.c +0 -0
include/asm-arm/arch-omap/keypad.h new file +13 -0
new file mode 100644
index 0000000..5884529
@@ -0,0 +1,13 @@
+#ifndef ASMARM_ARCH_KEYPAD_H
+#define ASMARM_ARCH_KEYPAD_H
+
+struct omap_kp_platform_data {
+	int rows;
+	int cols;
+	int *keymap;
+	unsigned int rep:1;
+};
+
+#define KEY(col, row, val) (((col) << 28) | ((row) << 24) | (val))
+
+#endif
include/asm-arm/arch-omap/menelaus.h +0 -0
include/asm-arm/arch-omap/mux.h +21 -0
index 8d1c62e..a9ec625 100644
@@ -410,6 +410,27 @@ enum omap24xx_index {
 	/* 24xx GPIO */
 	Y20_24XX_GPIO60,
 	M15_24XX_GPIO92,
+
+
+	/* Keypad GPIO*/
+	T19_24XX_KBR0,
+	R19_24XX_KBR1,
+	V18_24XX_KBR2,
+	M21_24XX_KBR3,
+	E5__24XX_KBR4,
+	M18_24XX_KBR5,
+	R20_24XX_KBC0,
+	M14_24XX_KBC1,
+	H19_24XX_KBC2,
+	V17_24XX_KBC3,
+	P21_24XX_KBC4,
+	L14_24XX_KBC5,
+	N19_24XX_KBC6,
+
+	/* 24xx Meneluas Keypad GPIO */
+	B3__24XX_KBR5,
+	AA4_24XX_KBC2,
+	B13_24XX_KBC6,
 };
 
 #ifdef	CONFIG_OMAP_MUX
include/asm-arm/arch-pxa/mmc.h +0 -0
kernel/irq/manage.c +0 -0
maintainer
#1 lore raw
Quoted 18 lines · Komal Shah

Tony/Brian,

I have attached patch which includes:

o Modification suggested by Brian Swetland
o Added platform_data structure
- keymap is moved to appropriate board files.
- rows and cols fields are not used in the driver yet.
- rep bit is added.
o IRQ resource
o Added 24xx+menelaus keypad support - tested.

TODO/FIXME:
o appropriate place for test_keymap.

o Removing NUM_COLS/ROWS #defines and replacing with platform_data->rows/cols.

Quoted 6 lines

o Moving request_gpio/free_gpio to board specific file, by introducing one function in platform_data ? Is this ok? e.g get/put_gpios. As driver should work as module too.

o How to handle row_/col_gpio_num array and set_/get_gpio_val functions ? I want to keep them out of this keypad.c. Any suggestions?

I like this patch, takes care of the keypad mapping problems nicely. Can you please refresh it?

Tony

#2 lore raw

Has anybody needed a joypad driver for the omap-boards?
I have made changes to keypad driver so that it will support h6300 joypad ok, but I think my approach is a little bit hackish. The iPAQ h6300 joypad has 5 sensors that are located in following diagonal locations

UL - Up/Left
DL - Down/Left
DR - Down/Right
UR - Up/Right
CT - Center

If I press the key-pad for example to North, the joypad will generate 3 keydown events. (CT, UL and UR) Same logic applies to all 4 main directions both when the key is pressed down or released. Therefore I have put the driver to listen the real sensor events, but instead of sending them to userspace I will calculate a "virtual" key event (up, right, down or left) and send that to the userspace.

I am not yet proposing this patch to be applied to omap kernel, but would anyway like to hear some suggestions how to handle this kind of situation.

Mika

Quoted 11 lines

I like this patch, takes care of the keypad mapping problems nicely. Can you please refresh it?

Tony
_______________________________________________
Linux-omap-open-source mailing list
[email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

drivers/input/keyboard/omap-keypad.c +231 -6
index 7e851e2..157ef8d 100644
@@ -5,10 +5,11 @@
  *
  * Copyright (C) 2003 Nokia Corporation
  * Written by Timo Teräs <[email protected]>
+ * iPAQ h6300 key and joypad support added by Mika Laitio. (2005)
  *
  * Added support for H2 & H3 Keypad
  * Copyright (C) 2004 Texas Instruments
- *
+ * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -41,13 +42,16 @@
 #include <asm/arch/mux.h>
 
 #undef NEW_BOARD_LEARNING_MODE
+//#define NEW_BOARD_LEARNING_MODE 1
 
 static void omap_kp_tasklet(unsigned long);
-static void omap_kp_timer(unsigned long);
+static void omap_§kp_timer(unsigned long);
 
 static unsigned char keypad_state[8];
 static unsigned int keypad_irq = INT_KEYBOARD;
 
+static int prevJoypadKeycodePressEmulated;
+
 struct omap_kp {
 	struct input_dev *input;
 	struct timer_list timer;
@@ -169,6 +173,47 @@ static int p2_keymap[] = {
 	0
 };
 
+#define _h6300_KEY_CALENDAR	67 	// xmodmap 75 aka F9
+#define _H6300_KEY_TELEPHONE	68 	// xmodmap 76 aka F10
+#define _H6300_KEY_HOMEPAGE	87 	// xmodmap 87 aka Num_Lock
+#define _H6300_KEY_MAIL		88 	// xmodmap 88 aka Scroll_Lock
+
+/*
+ * Following 5 keypad events are not really sent to userspace. 
+ * Instead if the good combination of them is sent, then that is send.
+ * (up, right, down, left, enter)
+ */
+#define	_H6300_JOYPAD_UP_RIGHT		1	// 00001
+#define _H6300_JOYPAD_DOWN_RIGHT	2	// 00010
+#define _h6300_JOYPAD_DOWN_LEFT		4	// 00100
+#define _h6300_JOYPAD_UP_LEFT		8	// 01000
+#define _H6300_JOYPAD_KEY_OK		16	// 10000
+
+static int h6300_keymap[] = {
+	KEY(2, 0, _h6300_KEY_CALENDAR),		// address button in the bottom left	
+	KEY(2, 3, _H6300_KEY_TELEPHONE),	// start call button in the bottom
+	KEY(3, 1, _H6300_KEY_HOMEPAGE),		// stop call button in the bottom
+	KEY(3, 4, _H6300_KEY_MAIL),		// messaging button in the bottom right
+
+	KEY(0, 0, KEY_VOLUMEUP),	// volume up button in the right side
+	KEY(0, 1, KEY_VOLUMEDOWN),	// volume down button in the right side
+	KEY(3, 2, KEY_RECORD),		// record button in the left side
+	
+	KEY(1, 0, _h6300_JOYPAD_UP_LEFT),	
+	KEY(1, 1, _h6300_JOYPAD_DOWN_LEFT),	
+	KEY(1, 2, _H6300_JOYPAD_KEY_OK),		
+	KEY(1, 3, _H6300_JOYPAD_DOWN_RIGHT),
+	KEY(1, 4, _H6300_JOYPAD_UP_RIGHT),	
+	
+	KEY(5, 0, KEY_RIGHT),
+	KEY(5, 1, KEY_DOWN),
+	KEY(5, 2, KEY_LEFT),		
+	KEY(5, 3, KEY_UP),
+	KEY(5, 4, KEY_ENTER),
+
+	0
+};
+
 static int *keymap;
 
 static irqreturn_t omap_kp_interrupt(int irq, void *dev_id,
@@ -195,7 +240,8 @@ static void omap_kp_scan_keypad(unsigned
 	for (col = 0; col < 8; col++) {
 		omap_writew(~(1 << col) & 0xff, OMAP_MPUIO_BASE + OMAP_MPUIO_KBC);
 
-		if (machine_is_omap_osk() || machine_is_omap_h2() || machine_is_omap_h3()) {
+		if (machine_is_omap_osk() || machine_is_omap_h2() || machine_is_omap_h3()  || machine_is_h6300()) {
+			// makes keyboard act a little bit slower
 			udelay(9);
 		} else {
 			udelay(4);
@@ -218,17 +264,26 @@ static inline int omap_kp_find_key(int c
 	return -1;
 }
 
+int is_key_down(unsigned char new_state[],
+		int col,
+		int row)
+{
+	return (new_state[col] & (1 << row)) ? 1 : 0;
+}
+
 static void omap_kp_tasklet(unsigned long data)
 {
 	struct omap_kp *omap_kp_data = (struct omap_kp *) data;
 	unsigned char new_state[8], changed, key_down = 0;
 	int col, row;
 	int spurious = 0;
+	int report_key, report_col, report_row, joypad_checked;	// h6300-joypad specific variables
 
 	/* check for any changes */
 	omap_kp_scan_keypad(new_state);
 
 	/* check for changes and print those */
+	joypad_checked	= 0;
 	for (col = 0; col < 8; col++) {
 		changed = new_state[col] ^ keypad_state[col];
 		key_down |= new_state[col];
@@ -250,9 +305,173 @@ static void omap_kp_tasklet(unsigned lon
 				spurious = 1;
 				continue;
 			}
-
-			input_report_key(omap_kp_data->input, key,
-					 new_state[col] & (1 << row));
+ 			if (machine_is_h6300() && 
+ 			   ((col == 1) || (col == 5)))
+ 			{
+ 				if (col == 5)
+ 				{
+ 					continue;
+ 				}
+ 				if ((joypad_checked == 0) &&
+ 				    ((key == _H6300_JOYPAD_KEY_OK) ||
+ 				     (key == _h6300_JOYPAD_UP_LEFT) ||
+ 	    			     (key == _H6300_JOYPAD_UP_RIGHT) ||
+ 				     (key == _H6300_JOYPAD_DOWN_RIGHT) ||
+ 				     (key == _h6300_JOYPAD_DOWN_LEFT)))
+ 				{
+ 					if (is_key_down(new_state, col, row))
+ 					{
+ 						/*
+ 						 * only enter pressed
+ 						 * 1 0 0 _H6300_JOYPAD_KEY_OK 0 0
+ 						 * --> 100100 == 36
+ 						 */
+ 						 if (new_state[1] == 36)
+ 						 {
+ 						 	joypad_checked	= 1;
+ 							prevJoypadKeycodePressEmulated	= KEY_ENTER;
+ 							new_state[5]	= 48;	//110000
+ 							report_key	= prevJoypadKeycodePressEmulated;
+ 							report_col	= 5;
+ 							report_row	= 4;
+ 							input_report_key(omap_kp_data->input,
+ 									report_key,
+ 							 		new_state[report_col] & (1 << report_row));
+ 						 }						
+ 						/*
+ 						 * enter, up_left and up_right sensors pressed.
+ 						 * 1 _H6300_JOYPAD_UP_RIGHT 0 _H6300_JOYPAD_KEY_OK 0 _h6300_JOYPAD_UP_LEFT
+ 						 * --> 110101 == 53
+ 						 * OR
+ 						 * 1 KEY_UP_RIGHT 0 0 0 _h6300_JOYPAD_UP_LEFT
+ 						 * --> 110001 == 42
+ 						 * --> move to up
+ 						 */
+ 						else if ((new_state[1] == 53) ||
+ 						         (new_state[1] == 49))
+ 						{
+ 							joypad_checked	= 1;
+ 							prevJoypadKeycodePressEmulated	= KEY_UP;
+ 							new_state[5]	= 40;	//101000
+ 							report_key	= prevJoypadKeycodePressEmulated;
+ 							report_col	= 5;
+ 							report_row	= 3;
+ 							input_report_key(omap_kp_data->input,
+ 									report_key,
+ 							 		new_state[report_col] & (1 << report_row));
+ 						}
+ 						/*
+ 						 * enter, down_left and down_right sensors pressed
+ 						 * --> 101110 == 46
+ 						 * OR
+ 						 * down_left and down_right
+ 						 * -->101010 == 42
+ 						 * --> move to down
+ 						 */
+ 						else if ((new_state[1] == 46) ||
+ 							 (new_state[1] == 42))
+ 						{
+ 							joypad_checked	= 1;
+ 							prevJoypadKeycodePressEmulated	= KEY_DOWN;
+ 							new_state[5]	= 34;	//100010
+ 							report_key	= prevJoypadKeycodePressEmulated;
+ 							report_col	= 5;
+ 							report_row	= 1;
+ 							input_report_key(omap_kp_data->input,
+ 									report_key,
+ 							 		new_state[report_col] & (1 << report_row));
+ 						}												
+ 						/*
+ 						 * enter, up_right and down_right sensors pressed
+ 						 * --> 111100 == 60
+ 						 * or
+ 						 * down_right and up_right
+ 						 * --> 111000 == 56
+ 						 * --> move to right
+ 						 */
+ 						else if ((new_state[1] == 60) ||
+ 							 (new_state[1] == 56))
+ 						{
+ 							joypad_checked	= 1;
+ 							prevJoypadKeycodePressEmulated	= KEY_RIGHT;
+ 							new_state[5]	= 33;	//100001
+ 							report_key	= prevJoypadKeycodePressEmulated;
+ 							report_col	= 5;
+ 							report_row	= 0;
+ 							input_report_key(omap_kp_data->input,
+ 									report_key,
+ 							 		new_state[report_col] & (1 << report_row));
+ 						}
+ 						/*
+ 						 * enter, up_left and down_left sensors pressed
+ 						 * --> 100111 == 39
+ 						 * or up_left and down_left
+ 						 * --> 100011 == 35
+ 						 * --> move to left
+ 						 */
+ 						else if ((new_state[1] == 39) ||
+ 							 (new_state[1] == 35))
+ 						{
+ 							joypad_checked	= 1;
+ 							prevJoypadKeycodePressEmulated	= KEY_LEFT;
+ 							new_state[5]	= 36;	//100100
+ 							report_key	= prevJoypadKeycodePressEmulated;
+ 							report_col	= 5;
+ 							report_row	= 2;
+ 							input_report_key(omap_kp_data->input,
+ 									report_key,
+ 							 		new_state[report_col] & (1 << report_row));
+ 						}
+ 						else
+ 						{
+ 							//printk("missed new_state = %d\n", new_state[1]);
+ 						}
+ 					}
+ 					else
+ 					{
+ 						if (prevJoypadKeycodePressEmulated != 0)
+ 						{
+ 							// report key up event
+ 							joypad_checked	= 1;
+ 							new_state[5]	= 32;	//100000
+ 							report_key	= prevJoypadKeycodePressEmulated;
+ 							report_col	= 5;
+ 							switch(prevJoypadKeycodePressEmulated)
+ 							{
+ 								case KEY_RIGHT:
+									report_row	= 0;
+ 									break;
+ 								case KEY_DOWN:
+ 									report_row	= 1;
+ 									break;
+ 								case KEY_LEFT:
+ 									report_row	= 2;
+ 									break;
+ 								case KEY_UP:
+ 									report_row	= 3;
+ 									break;
+ 								case KEY_ENTER:
+ 									report_row	= 4;
+ 									break;
+ 								default:
+ 									printk(KERN_WARNING "Unknown iPAQ h6300 column 1 key = %d released. This should newer happen!\n",
+ 										key);
+ 									report_row	= 0;
+ 							}
+ 							input_report_key(omap_kp_data->input,
+ 									report_key,
+ 							 		new_state[report_col] & (1 << report_row));
+ 							prevJoypadKeycodePressEmulated	= 0;
+ 						}
+ 					}
+ 				}
+ 			}
+ 			else
+ 			{
+ 				input_report_key(omap_kp_data->input, // &omap_kp_dev, 
+ 						key,
+ 						new_state[col] & (1 << row));
+ 			}
 #endif
 		}
 	}
@@ -321,9 +540,15 @@ static int __init omap_kp_probe(struct p
 	} else if (machine_is_omap_perseus2()) {
 		keymap = p2_keymap;
 		keypad_irq = INT_730_MPUIO_KEYPAD;
+	} else if (machine_is_h6300()) {
+		keymap = h6300_keymap;
+		// set keyboard to send repeated key events if key is hold down
+		set_bit(EV_REP, §.evbit);
 	} else {
+		printk("omap_keypad.c, keyMap = test_keymap\n");
 		keymap = test_keymap;
 	}
+	prevJoypadKeycodePressEmulated		= 0;
 
 	init_timer(&omap_kp->timer);
 	omap_kp->timer.function = omap_kp_timer;
maintainer
#3 lore raw

Hi Mika,

Quoted 10 lines · lamikr

Has anybody needed a joypad driver for the omap-boards?
I have made changes to keypad driver so that it will support h6300 joypad ok, but I think my approach is a little bit hackish. The iPAQ h6300 joypad has 5 sensors that are located in following diagonal locations

UL - Up/Left
DL - Down/Left
DR - Down/Right
UR - Up/Right
CT - Center

Quoted 7 lines

If I press the key-pad for example to North, the joypad will generate 3 keydown events. (CT, UL and UR) Same logic applies to all 4 main directions both when the key is pressed down or released. Therefore I have put the driver to listen the real sensor events, but instead of sending them to userspace I will calculate a "virtual" key event (up, right, down or left) and send that to the userspace.

I am not yet proposing this patch to be applied to omap kernel, but would anyway like to hear some suggestions how to handle this kind of situation.

Maybe you could update it now against the current git tree?

Now that all the key mappings are done in board-*.c files it should be easy to add support for h6300 too.

Tony

#4 lore raw

Yes, I will to pull the latest changes from git and try to make the merge soon. There is still couple of issues we want to resolve before starting to submit h6300 patches.

Mika

Quoted 34 lines · Tony Lindgren

Hi Mika,

Quoted 10 lines · lamikr

Has anybody needed a joypad driver for the omap-boards?
I have made changes to keypad driver so that it will support h6300 joypad ok, but I think my approach is a little bit hackish. The iPAQ h6300 joypad has 5 sensors that are located in following diagonal locations

UL - Up/Left
DL - Down/Left
DR - Down/Right
UR - Up/Right
CT - Center

Quoted 9 lines

If I press the key-pad for example to North, the joypad will generate 3 keydown events. (CT, UL and UR) Same logic applies to all 4 main directions both when the key is pressed down or released. Therefore I have put the driver to listen the real sensor events, but instead of sending them to userspace I will calculate a "virtual" key event (up, right, down or left) and send that to the userspace.

I am not yet proposing this patch to be applied to omap kernel, but would anyway like to hear some suggestions how to handle this kind of situation.

Maybe you could update it now against the current git tree?

Now that all the key mappings are done in board-*.c files it should be easy to add support for h6300 too.

Tony