linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kurt Garloff <garloff@suse.de>
To: Linus Torvalds <torvalds@transmeta.com>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Alessandro Rubini <rubini@vision.unipv.it>,
	Hubert Mantel <mantel@suse.de>,
	Linux kernel list <linux-kernel@vger.kernel.org>
Subject: [PATCH] make psaux reconnect adjustable
Date: Thu, 2 Aug 2001 04:21:00 +0200	[thread overview]
Message-ID: <20010802042100.B14010@pckurt.casa-etp.nl> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1453 bytes --]

Hi Linus Alan,

working on notebooks I got used to the touchpads.
Now, a lot of notebooks have a Synaptics touchpad.
It offers a few additional features, such as tossing or the third mouse
button (by a short click in the corner) ...

gpm -t synps2 does support those additional features and via the -R epeater
mode you also get it under X11.

Unfortunately, the synps2 generates nonstandard codes when in extended mode,
amongst which the reconnect (170) token.
The kernel (since 2.2.15) does interpret it as such and empties the queue.

This seems to appropriate for a real plug event. For a synps2, it's not, but
makes your mouse dead for a second. Instead the data should just be passed
to userspace (gpm).

So I made the behaviour switchable via a sysctl. 
/proc/sys/dev/ps2/psmouse_reconnect (defaults to 1 = the interpret behaviour)
Being at it, I also made the kbd error and unknown scancode reporting
switchable. (It used to be ifdefs.)

Please apply attached patch (against 2.4.7).

Allesandro, should I submit a patch for gpm to automatically handle this for
synps2 in case the kernel patch gets accepted?

Regards,
-- 
Kurt Garloff                   <kurt@garloff.de>         [Eindhoven, NL]
Physics: Plasma simulations  <K.Garloff@Phys.TUE.NL>  [TU Eindhoven, NL]
Linux: SCSI, Security          <garloff@suse.de>    [SuSE Nuernberg, DE]
 (See mail header or public key servers for PGP2 and GPG public keys.)

[-- Attachment #1.2: 247-psaux-reconnect-sysctl.diff --]
[-- Type: text/plain, Size: 5729 bytes --]

--- linux/include/linux/sysctl.h.orig	Tue Jul 31 23:49:42 2001
+++ linux/include/linux/sysctl.h	Thu Aug  2 03:41:34 2001
@@ -594,7 +594,8 @@
 	DEV_HWMON=2,
 	DEV_PARPORT=3,
 	DEV_RAID=4,
-	DEV_MAC_HID=5
+	DEV_MAC_HID=5,
+	DEV_PSAUX=6,
 };
 
 /* /proc/sys/dev/cdrom */
@@ -653,6 +654,13 @@
 	DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE=4,
 	DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE=5,
 	DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6
+};
+
+/* /proc/sys/dev/psaux */
+enum {
+	DEV_PSMOUSE_RECONNECT=1,
+	DEV_KBD_REPORT_UNKN=2,
+	DEV_KBD_REPORT_TO=3,
 };
 
 #ifdef __KERNEL__
--- linux/drivers/char/pc_keyb.c.orig	Fri Apr  6 19:42:55 2001
+++ linux/drivers/char/pc_keyb.c	Thu Aug  2 04:01:15 2001
@@ -92,8 +92,83 @@
 #define AUX_INTS_ON  (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT)
 
 #define MAX_RETRIES	60		/* some aux operations take long time*/
+
 #endif /* CONFIG_PSMOUSE */
 
+/* We want to be able to handle the psmouse reconnect token; unfortunately the
+ * Synaptics touchpads (and probably others too) use it for their extented
+ * functionality and produce them in extended mode (as set by gpm -t synps2).
+ * So we make this adjustable via a sysctl.  garloff@suse.de, 2001-08-01 */
+
+#ifdef CONFIG_SYSCTL
+#include <linux/sysctl.h>
+#ifdef CONFIG_PSMOUSE
+int sysctl_psmouse_reconnect = 1;
+#endif
+int sysctl_kbd_report_unkn = 0;
+int sysctl_kbd_report_to = 0;
+
+static int psaux_sysctl_handler (ctl_table *ctl, int write, struct file *filp,
+				 void *buffer, size_t *lenp)
+{
+	int *valp = ctl->data;
+	int ret = proc_dointvec(ctl, write, filp, buffer, lenp); 
+	if (write) {
+		if (*valp)
+			*valp = 1;
+	}
+	return ret;
+}
+			
+
+ctl_table psaux_table[] = {
+#ifdef CONFIG_PSMOUSE   
+        {DEV_PSMOUSE_RECONNECT, "psmouse_reconnect", &sysctl_psmouse_reconnect,
+                sizeof(int), 0644, NULL, &psaux_sysctl_handler},
+#endif   
+	{DEV_KBD_REPORT_UNKN, "kbd_report_unknown", &sysctl_kbd_report_unkn,
+                sizeof(int), 0644, NULL, &psaux_sysctl_handler},
+        {DEV_KBD_REPORT_TO, "kbd_report_timeout", &sysctl_kbd_report_to,
+                sizeof(int), 0644, NULL, &psaux_sysctl_handler},
+	{0}
+};
+
+ctl_table psaux_psaux_table[] = {
+        {DEV_CDROM, "ps2", NULL, 0, 0555, psaux_table},
+        {0}
+        };
+
+ctl_table psaux_root_table[] = {
+#ifdef CONFIG_PROC_FS
+        {CTL_DEV, "dev", NULL, 0, 0555, psaux_psaux_table},
+#endif /* CONFIG_PROC_FS */
+        {0}
+        };
+static struct ctl_table_header *psaux_sysctl_header;
+
+static void psaux_sysctl_register (void)
+{
+	static int initialized;
+	if (initialized) return;
+	
+	psaux_sysctl_header = register_sysctl_table (psaux_root_table, 1);
+	/*psaux_root_table->child->de->owner = THIS_MODULE;*/
+	initialized++;
+}
+
+/*
+static void psaux_sysctl_unregister (void)
+{
+	if (psaux_sysctl_header)
+		unregister_sysctl_table (psaux_sysctl_header);
+}
+ */
+#else /* CONFIG_SYSCTL */
+#define sysctl_psmouse_reconnect 1
+#define sysctl_kbd_report_unkn 0
+#define sysctl_kbd_report_to 0
+#endif /* CONFIG_SYSCTL */
+
 /*
  * Wait for keyboard controller input buffer to drain.
  *
@@ -123,9 +198,8 @@
 		mdelay(1);
 		timeout--;
 	} while (timeout);
-#ifdef KBD_REPORT_TIMEOUTS
-	printk(KERN_WARNING "Keyboard timed out[1]\n");
-#endif
+	if (sysctl_kbd_report_to)
+		printk(KERN_WARNING "Keyboard timed out[1]\n");
 }
 
 /*
@@ -320,10 +394,8 @@
 		  *keycode = E1_PAUSE;
 		  prev_scancode = 0;
 	      } else {
-#ifdef KBD_REPORT_UNKN
-		  if (!raw_mode)
+		  if (!raw_mode && sysctl_kbd_report_unkn)
 		    printk(KERN_INFO "keyboard: unknown e1 escape sequence\n");
-#endif
 		  prev_scancode = 0;
 		  return 0;
 	      }
@@ -348,11 +420,9 @@
 	      if (e0_keys[scancode])
 		*keycode = e0_keys[scancode];
 	      else {
-#ifdef KBD_REPORT_UNKN
-		  if (!raw_mode)
+		  if (!raw_mode && sysctl_kbd_report_unkn)
 		    printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n",
 			   scancode);
-#endif
 		  return 0;
 	      }
 	  }
@@ -370,11 +440,9 @@
 	  *keycode = high_keys[scancode - SC_LIM];
 
 	  if (!*keycode) {
-	      if (!raw_mode) {
-#ifdef KBD_REPORT_UNKN
+	      if (!raw_mode && sysctl_kbd_report_unkn) {
 		  printk(KERN_INFO "keyboard: unrecognized scancode (%02x)"
 			 " - ignored\n", scancode);
-#endif
 	      }
 	      return 0;
 	  }
@@ -404,12 +472,15 @@
 		mouse_reply_expected = 0;
 	}
 	else if(scancode == AUX_RECONNECT){
-		queue->head = queue->tail = 0;  /* Flush input queue */
-		__aux_write_ack(AUX_ENABLE_DEV);  /* ping the mouse :) */
-		return;
+		if (sysctl_psmouse_reconnect) {
+			queue->head = queue->tail = 0;  /* Flush input queue */
+			__aux_write_ack(AUX_ENABLE_DEV);  /* ping the mouse :) */
+			return;
+		}
 	}
+	else
+		add_mouse_randomness(scancode);
 
-	add_mouse_randomness(scancode);
 	if (aux_count) {
 		int head = queue->head;
 
@@ -511,17 +582,14 @@
 			if (resend)
 				break;
 			mdelay(1);
-			if (!--timeout) {
-#ifdef KBD_REPORT_TIMEOUTS
+			if (!--timeout && sysctl_kbd_report_to) {
 				printk(KERN_WARNING "keyboard: Timeout - AT keyboard not present?\n");
-#endif
 				return 0;
 			}
 		}
 	} while (retries-- > 0);
-#ifdef KBD_REPORT_TIMEOUTS
-	printk(KERN_WARNING "keyboard: Too many NACKs -- noisy kbd cable?\n");
-#endif
+	if (sysctl_kbd_report_to)
+		printk(KERN_WARNING "keyboard: Too many NACKs -- noisy kbd cable?\n");
 	return 0;
 }
 
@@ -751,6 +819,7 @@
 
 	/* Ok, finally allocate the IRQ, and off we go.. */
 	kbd_request_irq(keyboard_interrupt);
+	psaux_sysctl_register ();
 }
 
 #if defined CONFIG_PSMOUSE

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

             reply	other threads:[~2001-08-02  2:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-02  2:21 Kurt Garloff [this message]
2001-08-02 11:55 [PATCH] make psaux reconnect adjustable Andries.Brouwer
     [not found] <no.id>
2001-08-02 15:03 ` Alan Cox
2001-08-02 17:34 ` Alan Cox
2001-08-02 16:02 Andries.Brouwer
2001-08-02 16:18 ` Kurt Garloff
2001-08-02 17:27 Andries.Brouwer
2001-08-14  9:57 ` Kurt Garloff
2001-08-14 15:03   ` Kurt Garloff
2001-08-14 16:58     ` Linus Torvalds
2001-08-14 17:35       ` Kurt Garloff
2001-08-14 21:29       ` Kurt Garloff
2001-08-15 15:50         ` Gunther Mayer
2001-08-14 11:12 Andries.Brouwer
2001-08-14 17:10 ` Gunther Mayer
2001-08-14 21:56   ` Kurt Garloff
2001-08-14 18:29 Andries.Brouwer
2001-08-14 19:35 ` Gunther Mayer
2001-08-14 21:26 Andries.Brouwer

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=20010802042100.B14010@pckurt.casa-etp.nl \
    --to=garloff@suse.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mantel@suse.de \
    --cc=rubini@vision.unipv.it \
    --cc=torvalds@transmeta.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).