[parisc-linux-cvs] drivers/input/keyboard: hil_kbd.c hilkbd.c

Helge Deller deller@gmx.de
Thu, 29 May 2003 23:16:33 +0200


--Boundary-00=_xin1+HzGP6elZPO
Content-Type: text/plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Thursday 29 May 2003 11:12 pm, Helge Deller wrote:
> CVSROOT:	/var/cvs
> Module name:	linux-2.5
> Changes by:	deller	03/05/29 15:12:58
>
> Modified files:
> 	drivers/input/keyboard: hil_kbd.c hilkbd.c
>
> Log message:
> - fix scancodes & input-initialisation in new HIL driver hil_kbd.c,
> and remove old hacks which are not needed any longer
> - remove unneeded constants from old HIL driver and turn off interrupts at
> exit



--Boundary-00=_xin1+HzGP6elZPO
Content-Type: text/plain;
  charset="iso-8859-15";
  name="diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="diff"

Index: keyboard/hil_kbd.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/input/keyboard/hil_kbd.c,v
retrieving revision 1.4
diff -u -p -r1.4 hil_kbd.c
--- keyboard/hil_kbd.c	27 May 2003 23:22:59 -0000	1.4
+++ keyboard/hil_kbd.c	29 May 2003 21:09:21 -0000
@@ -38,14 +38,10 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-
-#ifdef DEBUG	/* DEBUG */
-#undef input_report_key
-#define input_report_key(a,b,c) { printk("input_report_key(%p, %d, %d)\n", a, b, !!(c)); input_event(a, EV_KEY, b, !!(c)); }
-#endif
+#include <linux/pci_ids.h>
 
 #define PREFIX "HIL KEYB: "
-#define HIL_GENERIC_NAME "generic HIL keyboard device"
+#define HIL_GENERIC_NAME "HIL keyboard"
 
 MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
 MODULE_DESCRIPTION(HIL_GENERIC_NAME " driver");
@@ -56,7 +52,8 @@ MODULE_LICENSE("Dual BSD/GPL");
 #define HIL_KBD_SET1_UPBIT 0x01
 #define HIL_KBD_SET1_SHIFT 1
 
-static uint8_t hil_kbd_set1[128] = {
+#define KBD_TBLSIZE             128
+static unsigned int hil_kbd_set1[KBD_TBLSIZE] = {	/* set1 keycodes */
    KEY_5,		KEY_RESERVED,	KEY_RIGHTALT,	KEY_LEFTALT, 
    KEY_RIGHTSHIFT,	KEY_LEFTSHIFT,	KEY_LEFTCTRL,	KEY_SYSRQ,
    KEY_KP4,		KEY_KP8,	KEY_KP5,	KEY_KP9,
@@ -64,7 +61,7 @@ static uint8_t hil_kbd_set1[128] = {
    KEY_KP1,		KEY_KPSLASH,	KEY_KP2,	KEY_KPPLUS,
    KEY_KP3,		KEY_KPASTERISK,	KEY_KP0,	KEY_KPMINUS,
    KEY_B,		KEY_V,		KEY_C,		KEY_X,
-   KEY_Z,		KEY_UNKNOWN,	KEY_RESERVED,   KEY_ESC,
+   KEY_Z,		KEY_RESERVED,	KEY_RESERVED,   KEY_ESC,
    KEY_6,		KEY_F10,	KEY_3,		KEY_F11,
    KEY_KPDOT,		KEY_F9,		KEY_TAB /*KP*/,	KEY_F12,
    KEY_H,		KEY_G,		KEY_F,		KEY_D,
@@ -86,8 +83,8 @@ static uint8_t hil_kbd_set1[128] = {
    KEY_J,		KEY_K,		KEY_L,		KEY_SEMICOLON,
    KEY_APOSTROPHE,	KEY_ENTER,	KEY_HOME,	KEY_SCROLLUP,
    KEY_M,		KEY_COMMA,	KEY_DOT,	KEY_SLASH,
-   KEY_RESERVED,	KEY_OPEN/*Select*/,KEY_RESERVED,KEY_SCROLLDOWN/*KPNEXT*/,
-   KEY_N,		KEY_SPACE,	KEY_SCROLLDOWN/*Next*/, KEY_UNKNOWN,
+   KEY_RESERVED,	KEY_SELECT,	KEY_RESERVED,	KEY_NEXT,
+   KEY_N,		KEY_SPACE,	KEY_NEXT,	KEY_RESERVED,
    KEY_LEFT,		KEY_DOWN,	KEY_UP,		KEY_RIGHT
 };
 
@@ -99,7 +96,7 @@ static uint8_t hil_kbd_set1[128] = {
 #define HIL_KBD_SET3_UPBIT 0x80
 #define HIL_KBD_SET3_SHIFT 0
 
-static uint8_t hil_kbd_set3[128] = {
+static unsigned int hil_kbd_set3[KBD_TBLSIZE] = {
   KEY_RESERVED,	KEY_ESC,	KEY_1,		KEY_2,
   KEY_3,	KEY_4,		KEY_5,		KEY_6,
   KEY_7,	KEY_8,		KEY_9,		KEY_0,
@@ -123,7 +120,7 @@ static uint8_t hil_kbd_set3[128] = {
   KEY_KP2,	KEY_KP3,	KEY_KP0,	KEY_KPDOT,
   KEY_SYSRQ,	KEY_RESERVED,	KEY_RESERVED,	KEY_RESERVED,
   KEY_RESERVED,	KEY_RESERVED,	KEY_RESERVED,	KEY_RESERVED,
-  KEY_RESERVED,	KEY_RESERVED,	KEY_UNKNOWN,	KEY_UNKNOWN,
+  KEY_RESERVED,	KEY_RESERVED,	KEY_RESERVED,	KEY_RESERVED,
   KEY_UP,	KEY_LEFT,	KEY_DOWN,	KEY_RIGHT,
   KEY_HOME,	KEY_PAGEUP,	KEY_END,	KEY_PAGEDOWN,
   KEY_INSERT,	KEY_DELETE,	KEY_102ND,	KEY_RESERVED,
@@ -228,7 +225,7 @@ static void hil_kbd_process_record(struc
 			up = key & HIL_KBD_SET1_UPBIT;
 			key &= (~HIL_KBD_SET1_UPBIT & 0xff);
 			key = key >> HIL_KBD_SET1_SHIFT;
-			if (key != KEY_RESERVED && key != KEY_UNKNOWN)
+			if (key != KEY_RESERVED)
 				input_report_key(dev, hil_kbd_set1[key], !up);
 		}
 		break;
@@ -240,7 +237,7 @@ static void hil_kbd_process_record(struc
 			up = key & HIL_KBD_SET2_UPBIT;
 			key &= (~HIL_KBD_SET1_UPBIT & 0xff);
 			key = key >> HIL_KBD_SET2_SHIFT;
-			if (key != KEY_RESERVED && key != KEY_UNKNOWN)
+			if (key != KEY_RESERVED)
 				input_report_key(dev, key, !up);
 		}
 		break;
@@ -252,7 +249,7 @@ static void hil_kbd_process_record(struc
 			up = key & HIL_KBD_SET3_UPBIT;
 			key &= (~HIL_KBD_SET1_UPBIT & 0xff);
 			key = key >> HIL_KBD_SET3_SHIFT;
-			if (key != KEY_RESERVED && key != KEY_UNKNOWN)
+			if (key != KEY_RESERVED)
 				input_report_key(dev, hil_kbd_set3[key], !up);
 		}
 		break;
@@ -381,38 +378,29 @@ static void hil_kbd_connect(struct serio
 		goto bail1;
 	}
 
-	kbd->dev.name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME;
+
+	kbd->dev.evbit[0]	= BIT(EV_KEY);
+	kbd->dev.ledbit[0]	= BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
+	kbd->dev.keycodemax	= KBD_TBLSIZE;
+	kbd->dev.keycodesize	= sizeof(hil_kbd_set1[0]);
+	kbd->dev.keycode	= hil_kbd_set1;
+	kbd->dev.name		= strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME;
+	kbd->dev.phys		= "hpkbd/input0";	/* XXX */
 
 	kbd->dev.id.bustype	= BUS_HIL;
-	kbd->dev.id.vendor	= SERIO_HIL;
+	kbd->dev.id.vendor	= PCI_VENDOR_ID_HP;
 	kbd->dev.id.product	= 0x0001; /* TODO: get from kbd->rsc */
 	kbd->dev.id.version	= 0x0100; /* TODO: get from kbd->rsc */
 
-	kbd->dev.evbit[0] |= BIT(EV_KEY);
-
 	for (i = 0; i < 128; i++) {
 		set_bit(hil_kbd_set1[i], kbd->dev.keybit);
 		set_bit(hil_kbd_set3[i], kbd->dev.keybit);
 	}
 	clear_bit(0, kbd->dev.keybit);
 
-#if 0
-	/* XXX: HACK !!!
-	 * remove this call if hp_psaux.c/hp_keyb.c is converted
-	 * to the input layer... */
-	register_ps2_keybfuncs();
-#endif
-	
 	input_register_device(&kbd->dev);
-#warning TODO Boottime printk needs update, as well as dev.name.
-	printk(KERN_INFO "input: %s, %s on hil%d\n",
-		kbd->dev.name, "HIL keyboard", 0);
-
-	/* HIL keyboards don't have a numlock key,
-	 * simulate a up-down sequence of numlock to 
-	 * make the keypad work at expected. */
-	input_report_key(&kbd->dev, KEY_NUMLOCK, 1);
-/*	input_report_key(&kbd->dev, KEY_NUMLOCK, 0); */
+	printk(KERN_INFO "input: %s, ID: %d\n",
+		kbd->dev.name, did);
 
 	serio->write(serio, 0);
 	serio->write(serio, 0);
@@ -444,12 +432,6 @@ static int __init hil_kbd_init(void)
 static void __exit hil_kbd_exit(void)
 {
 	serio_unregister_device(&hil_kbd_serio_dev);
-#if 0
-	/* XXX: HACK !!!
-	 * remove this call if hp_psaux.c/hp_keyb.c is converted
-	 * to the input layer... */
-	unregister_kbd_ops();
-#endif
 }
                         
 module_init(hil_kbd_init);
Index: keyboard/hilkbd.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/input/keyboard/hilkbd.c,v
retrieving revision 1.2
diff -u -p -r1.2 hilkbd.c
--- keyboard/hilkbd.c	29 May 2003 17:21:53 -0000	1.2
+++ keyboard/hilkbd.c	29 May 2003 21:09:21 -0000
@@ -81,19 +81,9 @@ MODULE_LICENSE("GPL v2");
 #define	HIL_CNMT		0xB2		/* clear nmi */
 #define	HIL_INTON		0x5C		/* Turn on interrupts. */
 #define	HIL_INTOFF		0x5D		/* Turn off interrupts. */
-#define	HIL_TRIGGER		0xC5		/* trigger command */
-#define	HIL_STARTCMD		0xE0		/* start loop command */
-#define	HIL_TIMEOUT		0xFE		/* timeout */
-#define	HIL_READTIME		0x13		/* Read real time register */
 
-#define	HIL_READBUSY		0x02		/* internal "busy" register */
-#define	HIL_READKBDLANG		0x12		/* read keyboard language code */
 #define	HIL_READKBDSADR	 	0xF9
 #define	HIL_WRITEKBDSADR 	0xE9
-#define	HIL_READLPSTAT  	0xFA
-#define	HIL_WRITELPSTAT 	0xEA
-#define	HIL_READLPCTRL  	0xFB
-#define	HIL_WRITELPCTRL 	0xEB
 
 
 #define KBD_TBLSIZE             128
@@ -161,7 +151,7 @@ static void poll_finished(void)
 	case 0x40:
 		down = (hil_dev.data[1] & 1) == 0;
 		scode = hil_dev.data[1] >> 1;
-		key = hphilkeyb_keycode[scode & (KBD_TBLSIZE-1)];
+		key = hphilkeyb_keycode[scode];
 		input_report_key(&hil_dev.dev, key, down);
 		break;
 	}
@@ -370,6 +360,9 @@ static void __exit hil_exit(void)
 		disable_irq(HIL_IRQ);
 		free_irq(HIL_IRQ, hil_dev.dev_id);
 	}
+
+	/* Turn off interrupts */
+	hil_do(HIL_INTOFF, NULL, 0);
 
 	input_unregister_device(&hil_dev.dev);
 

--Boundary-00=_xin1+HzGP6elZPO--