make psaux reconnect adjustable
Subsystems (2)
From: Kurt Garloff <[email protected]>
> Not precisely - it is a boot parameter "psaux-reconnect". > That is better than a sysctl.
Why should that be better than a sysctl? Boot parameters are ugly. You need to reboot in order to change them ...
Of course I hope that we'll handle this correctly at some point, without any options or parameters. In my eyes a sysctl is heavier infrastructure than a boot parameter, so I prefer the latter when a temporary fix is needed.
Your other mail implies that we can fix the problem without manual intervention by parsing AA 00 instead of just AA. If it's true, I'd=20 consider that the best solution.=20
Maybe precisely one person reported this, and his address now bounces. If there exist people who need this "psaux-reconnect" they can report on the codes they see. Note that just like AA is a perfectly normal code, also the sequence AA 00 is perfectly normal. Testing for that only diminishes the probability of getting it by accident.
Instead of adding boot parameters or sysctls or heuristics, probably we should just transfer the codes seen to user space, e.g. to gpm. Then it is up to gpm to recognize an AA 00 sequence and decide whether that is something special.
Andries
Hi Andries,
Quoted 10 lines · Andries Brouwer
Your other mail implies that we can fix the problem without manual intervention by parsing AA 00 instead of just AA. If it's true, I'd=20 consider that the best solution.=20
Maybe precisely one person reported this, and his address now bounces. If there exist people who need this "psaux-reconnect" they can report on the codes they see. Note that just like AA is a perfectly normal code, also the sequence AA 00 is perfectly normal. Testing for that only diminishes the probability of getting it by accident.
I can confirm what you suggest: My mouse (Logitech wheel USB/PS2) sends indeed AA 00.
So, I extended my patch (which you will dislike even more, I know, as you're against sysctls unlike me):psmouse_reconnect = 0: Do nothing (just pass all to userspace) psmouse_reconnect = 1: Flush Q & ping mouse on AA 00 (default) psmouse_reconnect = 2: Flush Q & ping mouse on AA (old behaviour)
Quoted 4 lines
Instead of adding boot parameters or sysctls or heuristics, probably we should just transfer the codes seen to user space, e.g. to gpm. Then it is up to gpm to recognize an AA 00 sequence and decide whether that is something special.
With reconnect 1 or 2: After reconnecting, mouse behaves strange (jumping
around the screen)
With reconnect 0: Mouse is dead
In both cases restarting gpm gets the mouse back to work again. It seems the imps2 driver does some initialization to the mouse.
If I use the plain ps2 driver, then finally, I see the benefit of the reconnect code in the kernel:
With reconnect = 1 or 2: It works after replugging With reconnect = 0: Mouse is dead after replugging
In the latter case restarting gpm helps.
Patch is attached.
It adds the sysctls as the last patch did, but now the psmouse_reconnect has 3 possible values. Also, I added a printk, so the kernel logs detected mouse reconnect events.
Linus, Alan, I'd like to have your input:
Do you like the patch as is? Should I remove the sysctls and just look for AA 00 (as Andries may prefer)? Shouldn't the AA 00 be passed to userspace as well in any case (to allow e.g. the imps2 driver to do reinitialization)?
Regards,
Signature · 3 lines
Kurt Garloff <[email protected]> Eindhoven, NL GPG key: See mail header, key servers Linux kernel development SuSE GmbH, Nuernberg, DE SCSI, Security
drivers/char/pc_keyb.c +100 -21
@@ -81,8 +81,9 @@static int __init psaux_init (void ); -#define AUX_RECONNECT 170/* scancode when ps2 device is plugged (back) in */ - +#define AUX_RECONNECT1 170/* scancode when ps2 device is plugged (back) in */ +#define AUX_RECONNECT2 0/* scancode when ps2 device is plugged (back) in */ +static struct aux_queue *queue;/* Mouse data buffer. */ static int aux_count;/* used when we send commands to the mouse that expect an ACK. */
@@ -92,8 +93,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. [email protected], 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 > 2) + *valp = 2; + } + 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 +199,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" ); }/*
@@ -324,10 +399,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 ; }
@@ -352,11 +425,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 ; } }
@@ -374,11 +445,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 ; }
@@ -397,6 +466,7 @@return 0200 ; } +static unsigned char psaux_prev;static inline void handle_mouse_event (unsigned char scancode) {#ifdef CONFIG_PSMOUSE
@@ -407,13 +477,24 @@ } mouse_reply_expected =0 ; } -else if (scancode ==AUX_RECONNECT ){ +else if (scancode ==AUX_RECONNECT1 + && sysctl_psmouse_reconnect ==2 ) { +printk (KERN_DEBUG "PS2 mouse reconnect detected.\n" ); + queue->head = queue->tail =0 ;/* Flush input queue */ +__aux_write_ack (AUX_ENABLE_DEV );/* ping the mouse :) */ +return ; + } +else if (scancode ==AUX_RECONNECT2 && psaux_prev ==AUX_RECONNECT1 + && sysctl_psmouse_reconnect ==1 ) { +printk (KERN_DEBUG "PS2 mouse reconnect detected.\n" ); queue->head = queue->tail =0 ;/* Flush input queue */ __aux_write_ack (AUX_ENABLE_DEV );/* ping the mouse :) */ return ; }add_mouse_randomness (scancode); + psaux_prev = scancode; +if (aux_count) {int head = queue->head;
@@ -515,17 +596,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 ; }
@@ -755,6 +833,7 @@/* Ok, finally allocate the IRQ, and off we go.. */ kbd_request_irq (keyboard_interrupt); +psaux_sysctl_register (); }#if definedCONFIG_PSMOUSE
include/linux/sysctl.h +9 -1
@@ -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__
Quoted 3 lines · Kurt Garloff
Linus, Alan, I'd like to have your input:
Do you like the patch as is?
Well, probably not, as it contains a typo which lets machines without kbd hang. Fixed version attached. Sorry!
Regards,
Signature · 3 lines
Kurt Garloff <[email protected]> Eindhoven, NL GPG key: See mail header, key servers Linux kernel development SuSE GmbH, Nuernberg, DE SCSI, Security
drivers/char/pc_keyb.c +101 -21
@@ -81,8 +81,9 @@static int __init psaux_init (void ); -#define AUX_RECONNECT 170/* scancode when ps2 device is plugged (back) in */ - +#define AUX_RECONNECT1 170/* scancode when ps2 device is plugged (back) in */ +#define AUX_RECONNECT2 0/* scancode when ps2 device is plugged (back) in */ +static struct aux_queue *queue;/* Mouse data buffer. */ static int aux_count;/* used when we send commands to the mouse that expect an ACK. */
@@ -92,8 +93,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. [email protected], 2001-08-01 */ + +#ifdef CONFIG_SYSCTL +#include <linux/sysctl.h> +#ifdef CONFIG_PSMOUSE +int sysctl_psmouse_reconnect = 1; +#endif +int sysctl_kbd_report_unkn = 1; +int sysctl_kbd_report_to = 1; + +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 > 2) + *valp = 2; + } + 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 1 +#define sysctl_kbd_report_to 1 +#endif /* CONFIG_SYSCTL */ + /* * Wait for keyboard controller input buffer to drain. *
@@ -123,9 +199,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" ); }/*
@@ -324,10 +399,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 ; }
@@ -352,11 +425,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 ; } }
@@ -374,11 +445,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 ; }
@@ -397,6 +466,7 @@return 0200 ; } +static unsigned char psaux_prev;static inline void handle_mouse_event (unsigned char scancode) {#ifdef CONFIG_PSMOUSE
@@ -407,13 +477,24 @@ } mouse_reply_expected =0 ; } -else if (scancode ==AUX_RECONNECT ){ +else if (scancode ==AUX_RECONNECT1 + && sysctl_psmouse_reconnect ==2 ) { +printk (KERN_DEBUG "PS2 mouse reconnect detected.\n" ); + queue->head = queue->tail =0 ;/* Flush input queue */ +__aux_write_ack (AUX_ENABLE_DEV );/* ping the mouse :) */ +return ; + } +else if (scancode ==AUX_RECONNECT2 && psaux_prev ==AUX_RECONNECT1 + && sysctl_psmouse_reconnect ==1 ) { +printk (KERN_DEBUG "PS2 mouse reconnect detected.\n" ); queue->head = queue->tail =0 ;/* Flush input queue */ __aux_write_ack (AUX_ENABLE_DEV );/* ping the mouse :) */ return ; }add_mouse_randomness (scancode); + psaux_prev = scancode; +if (aux_count) {int head = queue->head;
@@ -516,16 +597,14 @@break ;mdelay (1 );if (!--timeout) { -#ifdef KBD_REPORT_TIMEOUTS -printk (KERN_WARNING "keyboard: Timeout - AT keyboard not present?\n" ); -#endif +if (sysctl_kbd_report_to) +printk (KERN_WARNING "keyboard: Timeout - AT keyboard not present?\n" );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 ; }
@@ -755,6 +834,7 @@/* Ok, finally allocate the IRQ, and off we go.. */ kbd_request_irq (keyboard_interrupt); +psaux_sysctl_register (); }#if definedCONFIG_PSMOUSE
include/linux/sysctl.h +9 -1
@@ -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__
Quoted 3 lines
Well, probably not, as it contains a typo which lets machines without kbd hang. Fixed version attached. Sorry!
Hmm..
I really have two comments, but I haven't followed the whole discussion, so feel free to just say that it's been hashed out already:
- sysconf entries are suspicious for stuff like this. If some code really requires this to work correctly, that's exactly the kind of code that would run automatically at bootup. A sysconf doesn't really help people in that case - we'd be much better off with just a bootup switch.
- do we actually need the config switch AT ALL, whether at bootup or not? What exactly breaks if we just always pass the AA 00 values through? Apparently nothing ever breaks, which makes me suspect that people are just being unnecessarily defensive.
In short, I'd prefer a patch that just unconditionally removes the code, unless somebody KNOWS that it could break something. That failing, a simple kernel command line option sounds better than more files in /proc.
Remember: the biggest mistake to do is to overdesign. The road to hell is paved with good intentions.
Linus
Hi Linus,
thanks for your comments.
Quoted 7 lines · Linus Torvalds
I really have two comments, but I haven't followed the whole discussion, so feel free to just say that it's been hashed out already:
- sysconf entries are suspicious for stuff like this. If some code really requires this to work correctly, that's exactly the kind of code that would run automatically at bootup. A sysconf doesn't really help people in that case - we'd be much better off with just a bootup switch.
Maybe that's the difference of whether you define the kernel behaviour by deciding what goes in and the one that tries to avoid a breakage without changing the default behaviour ...
Of course the sysctl is less intrusive (from a user's point of view).
Quoted 4 lines
- do we actually need the config switch AT ALL, whether at bootup or not? What exactly breaks if we just always pass the AA 00 values through? Apparently nothing ever breaks, which makes me suspect that people are just being unnecessarily defensive.
PS2 mouses need this ping thing to be operational after being plugged. But, there's no reason it needs to be done in the kernel.
* It works for plain PS2 only (not: imps2, synps2, ...)
* The userspace driver (gpm, X11) can do it as well, AFAICS
I guess the thing has been introduced because it was more convenient than fixing userspace.
Maybe the kernel does it a bit more efficient by throwing away the queue ...
Quoted 3 lines
In short, I'd prefer a patch that just unconditionally removes the code, unless somebody KNOWS that it could break something. That failing, a simple kernel command line option sounds better than more files in /proc.
I'd be happy with removing it.
Patch will follow!
Quoted 2 lines
Remember: the biggest mistake to do is to overdesign. The road to hell is paved with good intentions.
A few sysctls don't qualify as overdesign yet, I hope.
Regards,
Signature · 3 lines
Kurt Garloff <[email protected]> Eindhoven, NL GPG key: See mail header, key servers Linux kernel development SuSE GmbH, Nuernberg, DE SCSI, Security
Quoted 8 lines · Linus Torvalds
- do we actually need the config switch AT ALL, whether at bootup or not? What exactly breaks if we just always pass the AA 00 values through? Apparently nothing ever breaks, which makes me suspect that people are just being unnecessarily defensive.
In short, I'd prefer a patch that just unconditionally removes the code, unless somebody KNOWS that it could break something. That failing, a simple kernel command line option sounds better than more files in /proc.
OK, here come two patches. The first one removes the special PSAUX reconnect handling completely. So userspace should handle it. (Which is possible; just not implemented in gpm/X11 at this time AFAIK.)
Second patch reintroduces the special handling again, but does
* react on AA 00 instead of just AA, thus much less likely breaking other drivers (such as synps2). All PS/2 mouses I could access (about 5 different models) produced AA 00, so this seems OK.
* is disabled by default, and needs to be enabled by the psaux-reconnect boot parameter, like in 2.2.19.
Second patch depends on first. Please apply just the first or both.
(Current failure of gpm/X11 would make me choose for both, but then I'm
more the one thinking of customers of a distro than the one trying to keep the kernel clean. On the long term, I'd drop the second in any case.)
Regards,
Signature · 3 lines
Kurt Garloff <[email protected]> Eindhoven, NL GPG key: See mail header, key servers Linux kernel development SuSE GmbH, Nuernberg, DE SCSI, Security
drivers/char/pc_keyb.c +0 -7
@@ -81,8 +81,6 @@static int __init psaux_init (void ); -#define AUX_RECONNECT 170/* scancode when ps2 device is plugged (back) in */ -static struct aux_queue *queue;/* Mouse data buffer. */ static int aux_count;/* used when we send commands to the mouse that expect an ACK. */
@@ -406,11 +404,6 @@return ; } 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 ; }add_mouse_randomness (scancode);
drivers/char/pc_keyb.c +21 -0
@@ -63,6 +63,7 @@#ifdef CONFIG_PSMOUSE static void aux_write_ack (int val);static void __aux_write_ack (int val); +static int aux_reconnect =0 ;#endif static spinlock_t kbd_controller_lock =SPIN_LOCK_UNLOCKED ;
@@ -81,6 +82,9 @@static int __init psaux_init (void ); +#define AUX_RECONNECT1 0xaa/* scancode1 when ps2 device is plugged (back) in */ +#define AUX_RECONNECT2 0x00/* scancode2 when ps2 device is plugged (back) in */ +static struct aux_queue *queue;/* Mouse data buffer. */ static int aux_count;/* used when we send commands to the mouse that expect an ACK. */
@@ -398,6 +402,7 @@static inline void handle_mouse_event (unsigned char scancode) {#ifdef CONFIG_PSMOUSE +static unsigned char prev_code;if (mouse_reply_expected) {if (scancode ==AUX_ACK ) { mouse_reply_expected--;
@@ -405,7 +410,15 @@ } mouse_reply_expected =0 ; } +else if (scancode ==AUX_RECONNECT2 && prev_code ==AUX_RECONNECT1 + && aux_reconnect) { +printk (KERN_INFO "PS/2 mouse reconnect detected\n" ); + queue->head = queue->tail =0 ;/* Flush input queue */ +__aux_write_ack (AUX_ENABLE_DEV );/* ping the mouse :) */ +return ; + } + prev_code = scancode;add_mouse_randomness (scancode);if (aux_count) {int head = queue->head;
@@ -751,6 +764,14 @@ }#if definedCONFIG_PSMOUSE + +static int __init aux_reconnect_setup (char *str) +{ + aux_reconnect =1 ; +return 1 ; +} + +__setup ("psaux-reconnect" , aux_reconnect_setup);/* * Check if this is a dual port controller.
Quoted 10 lines · Kurt Garloff
Quoted 8 lines · Linus Torvalds
- do we actually need the config switch AT ALL, whether at bootup or not? What exactly breaks if we just always pass the AA 00 values through? Apparently nothing ever breaks, which makes me suspect that people are just being unnecessarily defensive.
In short, I'd prefer a patch that just unconditionally removes the code, unless somebody KNOWS that it could break something. That failing, a simple kernel command line option sounds better than more files in /proc.
Linus, no more boot options (and no more files in /proc), please.
Don't push policy on users when there is a perfect, simple and _user-friendly_ solution.
Quoted 11 lines
OK, here come two patches. The first one removes the special PSAUX reconnect handling completely. So userspace should handle it. (Which is possible; just not implemented in gpm/X11 at this time AFAIK.)
Second patch reintroduces the special handling again, but does
* react on AA 00 instead of just AA, thus much less likely breaking other drivers (such as synps2). All PS/2 mouses I could access (about 5 different models) produced AA 00, so this seems OK.
* is disabled by default, and needs to be enabled by the psaux-reconnect boot parameter, like in 2.2.19.
Your patch for "AA 00" is preferable over current state "AA" (<=2.4.8)
ioctl is preferable over sysctl. Aware drivers do "ioctl("/dev/psaux", PS2_TRANSPARENT)".
run-time configuration is preferable over a boot parameter (see above about user-friendliness).
Not breaking current behaviour ("reconnecting 3-byte protocol mice works perfectly") is preferable.