lkml.org 
[lkml]   [2004]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[New-PATCH] lkkbd: Current version
On Wed, 2004-04-21 13:39:47 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de>
wrote in message <20040421113947.GA12700@lug-owl.de>:
> On Wed, 2004-04-21 00:52:25 -0500, Dmitry Torokhov <dtor_core@ameritech.net>
> wrote in message <200404210052.28755.dtor_core@ameritech.net>:
> > diff -Nru a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
> > --- a/drivers/input/keyboard/lkkbd.c Tue Apr 20 23:00:57 2004
> > +++ b/drivers/input/keyboard/lkkbd.c Tue Apr 20 23:00:57 2004
> > @@ -12,7 +12,7 @@
> > * adaptor).
> > *
> > * DISCLAUNER: This works for _me_. If you break anything by using the
> ^--- If you had only caught this one :)
>
> I'll take this patch into my tree, too.

Here we are. Linus, please apply this patch. It incorporated Dmitry's
changes and also updates the lkkbd driver to it's current version (which
I use on my Athlon).


#
# This patch updates the lkkbd driver to it's current version.
# It also incorporates two patches suggested on LKML (fixing
# some leading whitespace and an unneccessary check).
#

Index: linux-2.6.6-rc2/drivers/input/keyboard/lkkbd.c
===================================================================
--- linux-2.6.6-rc2.orig/drivers/input/keyboard/lkkbd.c 2004-04-04 05:36:25.000000000 +0200
+++ linux-2.6.6-rc2/drivers/input/keyboard/lkkbd.c 2004-04-21 14:33:59.000000000 +0200
@@ -11,8 +11,8 @@
* and VAXstations, but can also be used on any standard RS232 with an
* adaptor).
*
- * DISCLAUNER: This works for _me_. If you break anything by using the
- * information given below, I will _not_ be lieable!
+ * DISCLAIMER: This works for _me_. If you break anything by using the
+ * information given below, I will _not_ be liable!
*
* RJ11 pinout: To DB9: Or DB25:
* 1 - RxD <----> Pin 3 (TxD) <-> Pin 2 (TxD)
@@ -34,23 +34,32 @@
* Additionally, you have to get +12V from somewhere.
* Most easily, you'll get that from a floppy or HDD power connector.
* It's the yellow cable there (black is ground and red is +5V).
+ *
+ * The keyboard and all the commands it understands are documented in
+ * "VCB02 Video Subsystem - Technical Manual", EK-104AA-TM-001. This
+ * document is LK201 specific, but LK401 is mostly compatible. It comes
+ * up in LK201 mode and doesn't report any of the additional keys it
+ * has. These need to be switched on with the LK_CMD_ENABLE_LK401
+ * command. You'll find this document (scanned .pdf file) on MANX,
+ * a search engine specific to DEC documentation. Try
+ * http://www.vt100.net/manx/details?pn=EK-104AA-TM-001;id=21;cp=1
*/

/*
* 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
+ * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ *
* Should you need to contact me, the author, you can do so either by
* email or by paper mail:
* Jan-Benedict Glaw, Lilienstraße 16, 33790 Hörste (near Halle/Westf.),
@@ -67,8 +76,7 @@
#include <linux/serio.h>
#include <linux/workqueue.h>

-
-MODULE_AUTHOR ("Jan-Benedict Glaw <jblaw@lug-owl.de>");
+MODULE_AUTHOR ("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
MODULE_DESCRIPTION ("LK keyboard driver");
MODULE_LICENSE ("GPL");

@@ -92,6 +100,11 @@
module_param (ctrlclick_volume, int, 0);
MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%");

+static int lk201_compose_is_alt = 0;
+module_param (lk201_compose_is_alt, int, 0);
+MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key "
+ "will act as an Alt key");
+


#undef LKKBD_DEBUG
@@ -126,8 +139,11 @@
#define LK_CMD_SET_DEFAULTS 0xd3
#define LK_CMD_POWERCYCLE_RESET 0xfd
#define LK_CMD_ENABLE_LK401 0xe9
+#define LK_CMD_REQUEST_ID 0xab

/* Misc responses from keyboard */
+#define LK_STUCK_KEY 0x3d
+#define LK_SELFTEST_FAILED 0x3e
#define LK_ALL_KEYS_UP 0xb3
#define LK_METRONOME 0xb4
#define LK_OUTPUT_ERROR 0xb5
@@ -139,6 +155,7 @@
#define LK_RESPONSE_RESERVED 0xbb

#define LK_NUM_KEYCODES 256
+#define LK_NUM_IGNORE_BYTES 6
typedef u_int16_t lk_keycode_t;


@@ -267,6 +284,7 @@
struct lkkbd {
lk_keycode_t keycode[LK_NUM_KEYCODES];
int ignore_bytes;
+ unsigned char id[LK_NUM_IGNORE_BYTES];
struct input_dev dev;
struct serio *serio;
struct work_struct tq;
@@ -313,6 +331,82 @@
return ret;
}

+static void
+lkkbd_detection_done (struct lkkbd *lk)
+{
+ int i;
+
+ /*
+ * Reset setting for Compose key. Let Compose be KEY_COMPOSE.
+ */
+ lk->keycode[0xb1] = KEY_COMPOSE;
+
+ /*
+ * Print keyboard name and modify Compose=Alt on user's request.
+ */
+ switch (lk->id[4]) {
+ case 1:
+ sprintf (lk->name, "DEC LK201 keyboard");
+
+ if (lk201_compose_is_alt)
+ lk->keycode[0xb1] = KEY_LEFTALT;
+ break;
+
+ case 2:
+ sprintf (lk->name, "DEC LK401 keyboard");
+ break;
+
+ default:
+ sprintf (lk->name, "Unknown DEC keyboard");
+ printk (KERN_ERR "lkkbd: keyboard on %s is unknown, "
+ "please report to Jan-Benedict Glaw "
+ "<jbglaw@lug-owl.de>\n", lk->phys);
+ printk (KERN_ERR "lkkbd: keyboard ID'ed as:");
+ for (i = 0; i < LK_NUM_IGNORE_BYTES; i++)
+ printk (" 0x%02x", lk->id[i]);
+ printk ("\n");
+ break;
+ }
+ printk (KERN_INFO "lkkbd: keyboard on %s identified as: %s\n",
+ lk->phys, lk->name);
+
+ /*
+ * Report errors during keyboard boot-up.
+ */
+ switch (lk->id[2]) {
+ case 0x00:
+ /* All okay */
+ break;
+
+ case LK_STUCK_KEY:
+ printk (KERN_ERR "lkkbd: Stuck key on keyboard at "
+ "%s\n", lk->phys);
+ break;
+
+ case LK_SELFTEST_FAILED:
+ printk (KERN_ERR "lkkbd: Selftest failed on keyboard "
+ "at %s, keyboard may not work "
+ "properly\n", lk->phys);
+ break;
+
+ default:
+ printk (KERN_ERR "lkkbd: Unknown error %02x on "
+ "keyboard at %s\n", lk->id[2],
+ lk->phys);
+ break;
+ }
+
+ /*
+ * Try to hint user if there's a stuck key.
+ */
+ if (lk->id[2] == LK_STUCK_KEY && lk->id[3] != 0)
+ printk (KERN_ERR "Scancode of stuck key is 0x%02x, keycode "
+ "is 0x%04x\n", lk->id[3],
+ lk->keycode[lk->id[3]]);
+
+ return;
+}
+
/*
* lkkbd_interrupt() is called by the low level driver when a character
* is received.
@@ -329,7 +423,11 @@
if (lk->ignore_bytes > 0) {
DBG (KERN_INFO "Ignoring a byte on %s\n",
lk->name);
- lk->ignore_bytes--;
+ lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
+
+ if (lk->ignore_bytes == 0)
+ lkkbd_detection_done (lk);
+
return IRQ_HANDLED;
}

@@ -375,7 +473,8 @@
break;
case 0x01:
DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
- lk->ignore_bytes = 3;
+ lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
+ lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
schedule_work (&lk->tq);
break;

@@ -389,7 +488,7 @@
input_sync (&lk->dev);
} else
printk (KERN_WARNING "%s: Unknown key with "
- "scancode %02x on %s.\n",
+ "scancode 0x%02x on %s.\n",
__FILE__, data, lk->name);
}

@@ -467,6 +566,9 @@
unsigned char leds_on = 0;
unsigned char leds_off = 0;

+ /* Ask for ID */
+ lk->serio->write (lk->serio, LK_CMD_REQUEST_ID);
+
/* Reset parameters */
lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS);

@@ -527,9 +629,7 @@

if ((serio->type & SERIO_TYPE) != SERIO_RS232)
return;
- if (!(serio->type & SERIO_PROTO))
- return;
- if ((serio->type & SERIO_PROTO) && (serio->type & SERIO_PROTO) != SERIO_LKKBD)
+ if ((serio->type & SERIO_PROTO) != SERIO_LKKBD)
return;

if (!(lk = kmalloc (sizeof (struct lkkbd), GFP_KERNEL)))
@@ -537,10 +637,16 @@
memset (lk, 0, sizeof (struct lkkbd));

init_input_dev (&lk->dev);
-
- lk->dev.evbit[0] = BIT (EV_KEY) | BIT (EV_LED) | BIT (EV_SND) | BIT (EV_REP);
- lk->dev.ledbit[0] = BIT (LED_CAPSL) | BIT (LED_COMPOSE) | BIT (LED_SCROLLL) | BIT (LED_SLEEP);
- lk->dev.sndbit[0] = BIT (SND_CLICK) | BIT (SND_BELL);
+ set_bit (EV_KEY, lk->dev.evbit);
+ set_bit (EV_LED, lk->dev.evbit);
+ set_bit (EV_SND, lk->dev.evbit);
+ set_bit (EV_REP, lk->dev.evbit);
+ set_bit (LED_CAPSL, lk->dev.ledbit);
+ set_bit (LED_SLEEP, lk->dev.ledbit);
+ set_bit (LED_COMPOSE, lk->dev.ledbit);
+ set_bit (LED_SCROLLL, lk->dev.ledbit);
+ set_bit (SND_BELL, lk->dev.sndbit);
+ set_bit (SND_CLICK, lk->dev.sndbit);

lk->serio = serio;

@@ -564,14 +670,13 @@
return;
}

- sprintf (lk->name, "LK keyboard");
+ sprintf (lk->name, "DEC LK keyboard");
+ sprintf (lk->phys, "%s/input0", serio->phys);

memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES);
for (i = 0; i < LK_NUM_KEYCODES; i++)
set_bit (lk->keycode[i], lk->dev.keybit);

- sprintf (lk->name, "%s/input0", serio->phys);
-
lk->dev.name = lk->name;
lk->dev.phys = lk->phys;
lk->dev.id.bustype = BUS_RS232;
@@ -599,9 +704,9 @@
}

static struct serio_dev lkkbd_dev = {
- .interrupt = lkkbd_interrupt,
.connect = lkkbd_connect,
.disconnect = lkkbd_disconnect,
+ .interrupt = lkkbd_interrupt,
};

/*
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak!
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 14:02    [W:0.123 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site