linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: akpm@osdl.org, dtor_core@ameritech.net, petero2@telia.com,
	Andries.Brouwer@cwi.nl, linux-kernel@vger.kernel.org
Subject: [PATCH 6/8] Extend KD?BENT to handle > 256 keycodes.
Date: Thu, 25 Sep 2003 18:50:12 +0200	[thread overview]
Message-ID: <1064508612197@twilight.ucw.cz> (raw)
In-Reply-To: <10645086121089@twilight.ucw.cz>

You can pull this changeset from:
	bk://kernel.bkbits.net/vojtech/input

===================================================================

ChangeSet@1.1346, 2003-09-25 18:28:12+02:00, hirofumi@mail.parknet.co.jp
  input: Create new KD?BENT ioctls with a bigger key range (int), so that
         it's posible to recompile kbdutils on 2.6 and load keymaps for
         keys beyond 128. kbdutils compiled on 2.4 will keep working on
         2.6, unfortunately not vice versa, without changing kbdutils.


 arch/mips/kernel/ioctl32.c   |    2 +
 drivers/char/vt_ioctl.c      |   51 +++++++++++++++++++++++++++++--------------
 include/linux/compat_ioctl.h |    2 +
 include/linux/kd.h           |   14 +++++++++--
 4 files changed, 50 insertions(+), 19 deletions(-)

===================================================================

diff -Nru a/arch/mips/kernel/ioctl32.c b/arch/mips/kernel/ioctl32.c
--- a/arch/mips/kernel/ioctl32.c	Thu Sep 25 18:37:13 2003
+++ b/arch/mips/kernel/ioctl32.c	Thu Sep 25 18:37:13 2003
@@ -884,6 +884,8 @@
 COMPATIBLE_IOCTL(KDGKBMODE)
 COMPATIBLE_IOCTL(KDSKBMETA)
 COMPATIBLE_IOCTL(KDGKBMETA)
+COMPATIBLE_IOCTL(KDGKBENT_OLD)
+COMPATIBLE_IOCTL(KDSKBENT_OLD)
 COMPATIBLE_IOCTL(KDGKBENT)
 COMPATIBLE_IOCTL(KDSKBENT)
 COMPATIBLE_IOCTL(KDGKBSENT)
diff -Nru a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
--- a/drivers/char/vt_ioctl.c	Thu Sep 25 18:37:13 2003
+++ b/drivers/char/vt_ioctl.c	Thu Sep 25 18:37:13 2003
@@ -75,24 +75,41 @@
 #define s (tmp.kb_table)
 #define v (tmp.kb_value)
 static inline int
-do_kdsk_ioctl(int cmd, struct kbentry *user_kbe, int perm, struct kbd_struct *kbd)
+do_kdsk_ioctl(int cmd, void *user_kbe, int perm, struct kbd_struct *kbd)
 {
-	struct kbentry tmp;
+	struct kbentry tmp, *kbe = user_kbe;;
+	struct kbentry_old old, *old_kbe = user_kbe;
 	ushort *key_map, val, ov;
 
-	if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
-		return -EFAULT;
-
+	if (cmd == KDGKBENT_OLD || cmd == KDSKBENT_OLD) {
+		/* backward compatibility */
+		if (copy_from_user(&old, old_kbe, sizeof(struct kbentry_old)))
+			return -EFAULT;
+ 
+		tmp.kb_index = old.kb_index;
+		tmp.kb_table = old.kb_table;
+		tmp.kb_value = old.kb_value;
+	} else {
+		if (copy_from_user(&tmp, kbe, sizeof(struct kbentry)))
+			return -EFAULT;
+	}
+ 
 	switch (cmd) {
+	case KDGKBENT_OLD:
 	case KDGKBENT:
 		key_map = key_maps[s];
 		if (key_map) {
-		    val = U(key_map[i]);
-		    if (kbd->kbdmode != VC_UNICODE && KTYP(val) >= NR_TYPES)
-			val = K_HOLE;
+			val = U(key_map[i]);
+			if (kbd->kbdmode != VC_UNICODE && KTYP(val) >= NR_TYPES)
+				val = K_HOLE;
 		} else
-		    val = (i ? K_HOLE : K_NOSUCHMAP);
-		return put_user(val, &user_kbe->kb_value);
+			val = (i ? K_HOLE : K_NOSUCHMAP);
+ 
+		if (cmd == KDGKBENT_OLD)
+			return put_user(val, &old_kbe->kb_value);
+		return put_user(val, &kbe->kb_value);
+
+	case KDSKBENT_OLD:
 	case KDSKBENT:
 		if (!perm)
 			return -EPERM;
@@ -100,20 +117,20 @@
 			/* disallocate map */
 			key_map = key_maps[s];
 			if (s && key_map) {
-			    key_maps[s] = 0;
-			    if (key_map[0] == U(K_ALLOCATED)) {
+				key_maps[s] = 0;
+				if (key_map[0] == U(K_ALLOCATED)) {
 					kfree(key_map);
 					keymap_count--;
-			    }
+				}
 			}
 			break;
 		}
 
 		if (KTYP(v) < NR_TYPES) {
-		    if (KVAL(v) > max_vals[KTYP(v)])
+			if (KVAL(v) > max_vals[KTYP(v)])
 				return -EINVAL;
 		} else
-		    if (kbd->kbdmode != VC_UNICODE)
+			if (kbd->kbdmode != VC_UNICODE)
 				return -EINVAL;
 
 		/* ++Geert: non-PC keyboards may generate keycode zero */
@@ -566,9 +583,11 @@
 			perm=0;
 		return do_kbkeycode_ioctl(cmd, (struct kbkeycode *)arg, perm);
 
+	case KDGKBENT_OLD:
+	case KDSKBENT_OLD:
 	case KDGKBENT:
 	case KDSKBENT:
-		return do_kdsk_ioctl(cmd, (struct kbentry *)arg, perm, kbd);
+		return do_kdsk_ioctl(cmd, (void *)arg, perm, kbd);
 
 	case KDGKBSENT:
 	case KDSKBSENT:
diff -Nru a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
--- a/include/linux/compat_ioctl.h	Thu Sep 25 18:37:13 2003
+++ b/include/linux/compat_ioctl.h	Thu Sep 25 18:37:13 2003
@@ -161,6 +161,8 @@
 COMPATIBLE_IOCTL(KDGKBMODE)
 COMPATIBLE_IOCTL(KDSKBMETA)
 COMPATIBLE_IOCTL(KDGKBMETA)
+COMPATIBLE_IOCTL(KDGKBENT_OLD)
+COMPATIBLE_IOCTL(KDSKBENT_OLD)
 COMPATIBLE_IOCTL(KDGKBENT)
 COMPATIBLE_IOCTL(KDSKBENT)
 COMPATIBLE_IOCTL(KDGKBSENT)
diff -Nru a/include/linux/kd.h b/include/linux/kd.h
--- a/include/linux/kd.h	Thu Sep 25 18:37:13 2003
+++ b/include/linux/kd.h	Thu Sep 25 18:37:13 2003
@@ -94,18 +94,26 @@
 #define	KDGKBLED	0x4B64	/* get led flags (not lights) */
 #define	KDSKBLED	0x4B65	/* set led flags (not lights) */
 
-struct kbentry {
+struct kbentry_old {
 	unsigned char kb_table;
 	unsigned char kb_index;
 	unsigned short kb_value;
 };
+#define KDGKBENT_OLD	0x4B46	/* gets one entry in translation table (old) */
+#define KDSKBENT_OLD	0x4B47	/* sets one entry in translation table (old) */
+
+struct kbentry {
+	unsigned int kb_table;
+	unsigned int kb_index;
+	unsigned short kb_value;
+};
 #define		K_NORMTAB	0x00
 #define		K_SHIFTTAB	0x01
 #define		K_ALTTAB	0x02
 #define		K_ALTSHIFTTAB	0x03
 
-#define KDGKBENT	0x4B46	/* gets one entry in translation table */
-#define KDSKBENT	0x4B47	/* sets one entry in translation table */
+#define KDGKBENT	0x4B73	/* gets one entry in translation table */
+#define KDSKBENT	0x4B74	/* sets one entry in translation table */
 
 struct kbsentry {
 	unsigned char kb_func;


  reply	other threads:[~2003-09-25 16:56 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-25 16:48 My current patches Vojtech Pavlik
2003-09-25 16:50 ` [PATCH 1/8] Revert synaptics->pktcnt change Vojtech Pavlik
2003-09-25 16:50   ` [PATCH 2/8] Fix multibutton handling in synaptics.c Vojtech Pavlik
2003-09-25 16:50     ` [PATCH 3/8] Synaptics code cleanups Vojtech Pavlik
2003-09-25 16:50       ` [PATCH 4/8] Add touchpad support to mousedev.c Vojtech Pavlik
2003-09-25 16:50         ` [PATCH 5/8] Rely less on sanity of AT keyboards Vojtech Pavlik
2003-09-25 16:50           ` Vojtech Pavlik [this message]
2003-09-25 16:50             ` [PATCH 7/8] Fix handling of rotated Synaptics touchpads Vojtech Pavlik
2003-09-25 16:50               ` [PATCH 8/8] Add BTN_TOUCH to Synaptics driver. Update mousedev Vojtech Pavlik
2003-09-25 18:23                 ` Dmitry Torokhov
2003-09-25 22:30                   ` Vojtech Pavlik
2003-09-26  5:24                     ` Peter Osterlund
2003-09-26  7:24                     ` Dmitry Torokhov
2003-09-26  7:54                       ` Vojtech Pavlik
2003-09-27  1:58                         ` Dmitry Torokhov
2003-09-27 20:19                         ` Pavel Machek
2003-09-27 21:05                           ` Vojtech Pavlik
2003-09-27 21:09                             ` Pavel Machek
2003-09-27 21:16                               ` Vojtech Pavlik
2003-09-27 21:18                                 ` Pavel Machek
2003-09-27 21:21                                   ` Vojtech Pavlik
2003-09-27 21:58                                     ` Matt Gibson
2003-09-28  9:49                                       ` Vojtech Pavlik
2003-09-25 22:57             ` [PATCH 6/8] Extend KD?BENT to handle > 256 keycodes Andrew Morton
2003-09-25 23:21               ` Vojtech Pavlik
2003-09-25 23:38             ` Andries Brouwer
2003-09-26  6:20               ` Vojtech Pavlik
2003-10-05 15:12           ` [PATCH 5/8] Rely less on sanity of AT keyboards Martin Josefsson
2003-09-25 18:13 ` My current patches Peter Osterlund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1064508612197@twilight.ucw.cz \
    --to=vojtech@suse.cz \
    --cc=Andries.Brouwer@cwi.nl \
    --cc=akpm@osdl.org \
    --cc=dtor_core@ameritech.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petero2@telia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).