2004-04-21 06:05:59

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 0/15] New set of input patches

Hi,

Here is a new set of my input patches, would love to hear comments and/or
suggestions. The patches can also be found at:

http://www.geocities.com/dt_or/input/2_6_6-rc2/
bk pull bk://dtor.bkbits.net/input

01-synaptics-cleanup.patch
Adjust the way we extract button data; do not announce BTN_BACK/BTN_FORWARD
unless touchpad has SYN_CAP_FOUR_BUTTON; adjust querying extended
capailities according to the latest Synaptics documentation addendum

02-synaptics-middle-button.patch
Support for touchpads that have middle button.

03-dont-change-max-proto.patch
Do not mangle global parameter when probing for protocol extensions.

04-lkkbd-whitespace.patch

05-lkkbd-simplify.patch
Drop some duplicate checks.

06-atkbd-soften-xfree-warning.patch
Soften accusations against XFree when we get spurios ACK/NAK from the KBC.

07-atkbd-trailing-whitespace.patch

08-atkbd-bitfields.patch
Cleanup, convert some essentialy boolean fields ino bitfields.

09-atkbd-timeout-complaints.patch
Do not complain about surious NAK in cases when keyboard controller's
timeout is bigger then in atkbd and NAK to our probe comes too late.

10-psmouse-rescan-on-hotplug.patch
When we get 0xAA 0x00 froma device do reconnect and not rescan in case
it's an old device that just reset for some reason (KVM switch?)

11-psmouse-reconnect-after-error.patch
Move psmouse_reconnectafter handling from synaptocs to psmouse-base so
it can later be used by other protocols.

12-psmouse-protocol-handler.patch
Add protocol_handler funtion pointer to the psmouse structure so we
won't have unsighly if/switch constructs in psmouse-base when we add
support for more protocols.

13-psmouse-sliced-command.patch
Synaptics and logips2pp noth implemented their own routines of sening
extended PS/2 commands to the mouse; consolidate the code.

14-atkbd-reconnect-probe.patch
Do not alter psmouse structure when probing for supported protocols
at reconnect. Cures an OOPS when Synaptics is not detected at first
(USB legacy emulation problem, etc) but is detected after resume.

15-psaux-config.patch
Allow disabling legacy psaux device even for non-embedded systems;
not everyone wants/needs it.

--
Dmitry


2004-04-21 06:06:56

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 1/15] New set of input patches: synaptics cleanup


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


[email protected], 2004-04-20 22:22:49-05:00, [email protected]
Input: synaptics driver cleanup
- pack all button data in 2 bytes instead of 48
- adjust the way we extract button data
- query extended capabilities if SYN_EXT_CAP_REQUESTS >= 1
(was == 1) according to Synaptics' addendum to the interfacing
guide
- do not announce or report BTN_BACK/BTN_FORWARD unless touchpad
has SYN_CAP_FOUR_BUTTON in its capability flags


synaptics.c | 137 +++++++++++++++++++++++++-----------------------------------
synaptics.h | 19 ++------
2 files changed, 65 insertions(+), 91 deletions(-)


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



diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c Tue Apr 20 22:55:50 2004
+++ b/drivers/input/mouse/synaptics.c Tue Apr 20 22:55:50 2004
@@ -118,17 +118,31 @@

if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap))
return -1;
- priv->capabilities = (cap[0]<<16) | (cap[1]<<8) | cap[2];
+ priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
priv->ext_cap = 0;
if (!SYN_CAP_VALID(priv->capabilities))
return -1;

- if (SYN_EXT_CAP_REQUESTS(priv->capabilities)) {
+ /*
+ * Unless capExtended is set the rest of the flags should be ignored
+ */
+ if (!SYN_CAP_EXTENDED(priv->capabilities))
+ priv->capabilities = 0;
+
+ if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) {
if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) {
printk(KERN_ERR "Synaptics claims to have extended capabilities,"
" but I'm not able to read them.");
- } else
- priv->ext_cap = (cap[0]<<16) | (cap[1]<<8) | cap[2];
+ } else {
+ priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
+
+ /*
+ * if nExtBtn is greater than 8 it should be considered
+ * invalid and treated as 0
+ */
+ if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) > 8)
+ priv->ext_cap &= 0xff0fff;
+ }
}
return 0;
}
@@ -167,11 +181,10 @@

if (SYN_CAP_EXTENDED(priv->capabilities)) {
printk(KERN_INFO " Touchpad has extended capability bits\n");
- if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) &&
- SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) <= 8)
+ if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap))
printk(KERN_INFO " -> %d multi-buttons, i.e. besides standard buttons\n",
(int)(SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)));
- else if (SYN_CAP_FOUR_BUTTON(priv->capabilities))
+ if (SYN_CAP_FOUR_BUTTON(priv->capabilities))
printk(KERN_INFO " -> four buttons\n");
if (SYN_CAP_MULTIFINGER(priv->capabilities))
printk(KERN_INFO " -> multifinger detection\n");
@@ -312,6 +325,8 @@

static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
{
+ int i;
+
set_bit(EV_ABS, dev->evbit);
set_abs_params(dev, ABS_X, XMIN_NOMINAL, XMAX_NOMINAL, 0, 0);
set_abs_params(dev, ABS_Y, YMIN_NOMINAL, YMAX_NOMINAL, 0, 0);
@@ -326,32 +341,15 @@

set_bit(BTN_LEFT, dev->keybit);
set_bit(BTN_RIGHT, dev->keybit);
- set_bit(BTN_FORWARD, dev->keybit);
- set_bit(BTN_BACK, dev->keybit);
- if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) {
- switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) {
- default:
- /*
- * if nExtBtn is greater than 8 it should be considered
- * invalid and treated as 0
- */
- break;
- case 8:
- set_bit(BTN_7, dev->keybit);
- set_bit(BTN_6, dev->keybit);
- case 6:
- set_bit(BTN_5, dev->keybit);
- set_bit(BTN_4, dev->keybit);
- case 4:
- set_bit(BTN_3, dev->keybit);
- set_bit(BTN_2, dev->keybit);
- case 2:
- set_bit(BTN_1, dev->keybit);
- set_bit(BTN_0, dev->keybit);
- break;
- }
+
+ if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
+ set_bit(BTN_FORWARD, dev->keybit);
+ set_bit(BTN_BACK, dev->keybit);
}

+ for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++)
+ set_bit(BTN_0 + i, dev->keybit);
+
clear_bit(EV_REL, dev->evbit);
clear_bit(REL_X, dev->relbit);
clear_bit(REL_Y, dev->relbit);
@@ -385,8 +383,8 @@
if (old_priv.identity != priv->identity ||
old_priv.model_id != priv->model_id ||
old_priv.capabilities != priv->capabilities ||
- old_priv.ext_cap != priv->ext_cap)
- return -1;
+ old_priv.ext_cap != priv->ext_cap)
+ return -1;

if (synaptics_set_mode(psmouse, 0)) {
printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
@@ -432,8 +430,8 @@

priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;

- if (SYN_CAP_EXTENDED(priv->capabilities) && SYN_CAP_PASS_THROUGH(priv->capabilities))
- synaptics_pt_create(psmouse);
+ if (SYN_CAP_PASS_THROUGH(priv->capabilities))
+ synaptics_pt_create(psmouse);

print_ident(priv);
set_input_params(&psmouse->dev, priv);
@@ -471,17 +469,14 @@

hw->left = (buf[0] & 0x01) ? 1 : 0;
hw->right = (buf[0] & 0x02) ? 1 : 0;
- if (SYN_CAP_EXTENDED(priv->capabilities) &&
- (SYN_CAP_FOUR_BUTTON(priv->capabilities))) {
- hw->up = ((buf[3] & 0x01)) ? 1 : 0;
- if (hw->left)
- hw->up = !hw->up;
- hw->down = ((buf[3] & 0x02)) ? 1 : 0;
- if (hw->right)
- hw->down = !hw->down;
+
+ if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
+ hw->up = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
+ hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0;
}
+
if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) &&
- ((buf[3] & 2) ? !hw->right : hw->right)) {
+ ((buf[0] ^ buf[3]) & 0x02)) {
switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) {
default:
/*
@@ -490,17 +485,17 @@
*/
break;
case 8:
- hw->b7 = ((buf[5] & 0x08)) ? 1 : 0;
- hw->b6 = ((buf[4] & 0x08)) ? 1 : 0;
+ hw->ext_buttons |= ((buf[5] & 0x08)) ? 0x80 : 0;
+ hw->ext_buttons |= ((buf[4] & 0x08)) ? 0x40 : 0;
case 6:
- hw->b5 = ((buf[5] & 0x04)) ? 1 : 0;
- hw->b4 = ((buf[4] & 0x04)) ? 1 : 0;
+ hw->ext_buttons |= ((buf[5] & 0x04)) ? 0x20 : 0;
+ hw->ext_buttons |= ((buf[4] & 0x04)) ? 0x10 : 0;
case 4:
- hw->b3 = ((buf[5] & 0x02)) ? 1 : 0;
- hw->b2 = ((buf[4] & 0x02)) ? 1 : 0;
+ hw->ext_buttons |= ((buf[5] & 0x02)) ? 0x08 : 0;
+ hw->ext_buttons |= ((buf[4] & 0x02)) ? 0x04 : 0;
case 2:
- hw->b1 = ((buf[5] & 0x01)) ? 1 : 0;
- hw->b0 = ((buf[4] & 0x01)) ? 1 : 0;
+ hw->ext_buttons |= ((buf[5] & 0x01)) ? 0x02 : 0;
+ hw->ext_buttons |= ((buf[4] & 0x01)) ? 0x01 : 0;
}
}
} else {
@@ -525,6 +520,7 @@
struct synaptics_hw_state hw;
int num_fingers;
int finger_width;
+ int i;

synaptics_parse_hw_state(psmouse->packet, priv, &hw);

@@ -570,32 +566,17 @@
input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2);
input_report_key(dev, BTN_TOOL_TRIPLETAP, num_fingers == 3);

- input_report_key(dev, BTN_LEFT, hw.left);
- input_report_key(dev, BTN_RIGHT, hw.right);
- input_report_key(dev, BTN_FORWARD, hw.up);
- input_report_key(dev, BTN_BACK, hw.down);
- if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap))
- switch(SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) {
- default:
- /*
- * if nExtBtn is greater than 8 it should be considered
- * invalid and treated as 0
- */
- break;
- case 8:
- input_report_key(dev, BTN_7, hw.b7);
- input_report_key(dev, BTN_6, hw.b6);
- case 6:
- input_report_key(dev, BTN_5, hw.b5);
- input_report_key(dev, BTN_4, hw.b4);
- case 4:
- input_report_key(dev, BTN_3, hw.b3);
- input_report_key(dev, BTN_2, hw.b2);
- case 2:
- input_report_key(dev, BTN_1, hw.b1);
- input_report_key(dev, BTN_0, hw.b0);
- break;
- }
+ input_report_key(dev, BTN_LEFT, hw.left);
+ input_report_key(dev, BTN_RIGHT, hw.right);
+
+ if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
+ input_report_key(dev, BTN_FORWARD, hw.up);
+ input_report_key(dev, BTN_BACK, hw.down);
+ }
+
+ for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++)
+ input_report_key(dev, BTN_0 + i, hw.ext_buttons & (1 << i));
+
input_sync(dev);
}

diff -Nru a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
--- a/drivers/input/mouse/synaptics.h Tue Apr 20 22:55:50 2004
+++ b/drivers/input/mouse/synaptics.h Tue Apr 20 22:55:50 2004
@@ -50,7 +50,7 @@
#define SYN_CAP_MULTIFINGER(c) ((c) & (1 << 1))
#define SYN_CAP_PALMDETECT(c) ((c) & (1 << 0))
#define SYN_CAP_VALID(c) ((((c) & 0x00ff00) >> 8) == 0x47)
-#define SYN_EXT_CAP_REQUESTS(c) ((((c) & 0x700000) >> 20) == 1)
+#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)

/* synaptics modes query bits */
@@ -86,18 +86,11 @@
int y;
int z;
int w;
- int left;
- int right;
- int up;
- int down;
- int b0;
- int b1;
- int b2;
- int b3;
- int b4;
- int b5;
- int b6;
- int b7;
+ unsigned int left:1;
+ unsigned int right:1;
+ unsigned int up:1;
+ unsigned int down:1;
+ unsigned char ext_buttons;
};

struct synaptics_data {

2004-04-21 06:09:57

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 11/15] New set of input patches: psmouse reconnect after error


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


[email protected], 2004-04-20 22:40:09-05:00, [email protected]
Input: move "reconnect after so many errors" handling from synaptics driver
to psmouse so it can be used by other PS/2 protcol drivers (but so far
only synaptics knows how to validate incoming data)


Documentation/kernel-parameters.txt | 4 +-
drivers/input/mouse/psmouse-base.c | 61 +++++++++++++++++++++++++-----------
drivers/input/mouse/psmouse.h | 9 ++++-
drivers/input/mouse/synaptics.c | 24 ++++----------
drivers/input/mouse/synaptics.h | 3 -
5 files changed, 62 insertions(+), 39 deletions(-)


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



diff -Nru a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
--- a/Documentation/kernel-parameters.txt Tue Apr 20 23:11:25 2004
+++ b/Documentation/kernel-parameters.txt Tue Apr 20 23:11:25 2004
@@ -879,8 +879,8 @@
psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports
per second.
psmouse.resetafter=
- [HW,MOUSE] Try to reset Synaptics Touchpad after so many
- bad packets (0 = never).
+ [HW,MOUSE] Try to reset the device after so many bad packets
+ (0 = never).
psmouse.resolution=
[HW,MOUSE] Set desired mouse resolution, in dpi.
psmouse.smartscroll=
diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:11:25 2004
+++ b/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:11:25 2004
@@ -43,9 +43,9 @@
module_param_named(smartscroll, psmouse_smartscroll, bool, 0);
MODULE_PARM_DESC(smartscroll, "Logitech Smartscroll autorepeat, 1 = enabled (default), 0 = disabled.");

-unsigned int psmouse_resetafter;
+static unsigned int psmouse_resetafter;
module_param_named(resetafter, psmouse_resetafter, uint, 0);
-MODULE_PARM_DESC(resetafter, "Reset Synaptics Touchpad after so many bad packets (0 = never).");
+MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never).");

__obsolete_setup("psmouse_noext");
__obsolete_setup("psmouse_resolution=");
@@ -56,15 +56,22 @@
static char *psmouse_protocols[] = { "None", "PS/2", "PS2++", "PS2T++", "GenPS/2", "ImPS/2", "ImExPS/2", "SynPS/2"};

/*
- * psmouse_process_packet() analyzes the PS/2 mouse packet contents and
- * reports relevant events to the input module.
+ * psmouse_process_byte() analyzes the PS/2 data stream and reports
+ * relevant events to the input module once full packet has arrived.
*/

-static void psmouse_process_packet(struct psmouse *psmouse, struct pt_regs *regs)
+static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
{
struct input_dev *dev = &psmouse->dev;
unsigned char *packet = psmouse->packet;

+ if (psmouse->pktcnt < 3 + (psmouse->type >= PSMOUSE_GENPS))
+ return PSMOUSE_GOOD_DATA;
+
+/*
+ * Full packet accumulated, process it
+ */
+
input_regs(dev, regs);

/*
@@ -112,6 +119,8 @@
input_report_rel(dev, REL_Y, packet[2] ? (int) ((packet[0] << 3) & 0x100) - (int) packet[2] : 0);

input_sync(dev);
+
+ return PSMOUSE_FULL_PACKET;
}

/*
@@ -123,6 +132,7 @@
unsigned char data, unsigned int flags, struct pt_regs *regs)
{
struct psmouse *psmouse = serio->private;
+ psmouse_ret_t rc;

if (psmouse->state == PSMOUSE_IGNORE)
goto out;
@@ -193,19 +203,33 @@
}
}

- if (psmouse->type == PSMOUSE_SYNAPTICS) {
- /*
- * The synaptics driver has its own resync logic,
- * so it needs to receive all bytes one at a time.
- */
- synaptics_process_byte(psmouse, regs);
- goto out;
- }
+ rc = psmouse->type == PSMOUSE_SYNAPTICS ?
+ synaptics_process_byte(psmouse, regs) : psmouse_process_byte(psmouse, regs);

- if (psmouse->pktcnt == 3 + (psmouse->type >= PSMOUSE_GENPS)) {
- psmouse_process_packet(psmouse, regs);
- psmouse->pktcnt = 0;
- goto out;
+ switch (rc) {
+ case PSMOUSE_BAD_DATA:
+ printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n",
+ psmouse->name, psmouse->phys, psmouse->pktcnt);
+ psmouse->pktcnt = 0;
+
+ if (++psmouse->out_of_sync == psmouse_resetafter) {
+ psmouse->state = PSMOUSE_IGNORE;
+ printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n");
+ serio_reconnect(psmouse->serio);
+ }
+ break;
+
+ case PSMOUSE_FULL_PACKET:
+ psmouse->pktcnt = 0;
+ if (psmouse->out_of_sync) {
+ psmouse->out_of_sync = 0;
+ printk(KERN_NOTICE "psmouse.c: %s at %s - driver resynched.\n",
+ psmouse->name, psmouse->phys);
+ }
+ break;
+
+ case PSMOUSE_GOOD_DATA:
+ break;
}
out:
return IRQ_HANDLED;
@@ -677,7 +701,8 @@
old_type = psmouse->type;

psmouse->state = PSMOUSE_CMD_MODE;
- psmouse->type = psmouse->acking = psmouse->cmdcnt = psmouse->pktcnt = 0;
+ psmouse->type = psmouse->acking = 0;
+ psmouse->cmdcnt = psmouse->pktcnt = psmouse->out_of_sync = 0;
if (psmouse->reconnect) {
if (psmouse->reconnect(psmouse))
return -1;
diff -Nru a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
--- a/drivers/input/mouse/psmouse.h Tue Apr 20 23:11:25 2004
+++ b/drivers/input/mouse/psmouse.h Tue Apr 20 23:11:25 2004
@@ -22,6 +22,13 @@
#define PSMOUSE_ACTIVATED 1
#define PSMOUSE_IGNORE 2

+/* psmouse protocol handler return codes */
+typedef enum {
+ PSMOUSE_BAD_DATA,
+ PSMOUSE_GOOD_DATA,
+ PSMOUSE_FULL_PACKET
+} psmouse_ret_t;
+
struct psmouse;

struct psmouse_ptport {
@@ -45,6 +52,7 @@
unsigned char type;
unsigned char model;
unsigned long last;
+ unsigned long out_of_sync;
unsigned char state;
char acking;
volatile char ack;
@@ -69,6 +77,5 @@

extern int psmouse_smartscroll;
extern unsigned int psmouse_rate;
-extern unsigned int psmouse_resetafter;

#endif /* _PSMOUSE_H */
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c Tue Apr 20 23:11:25 2004
+++ b/drivers/input/mouse/synaptics.c Tue Apr 20 23:11:25 2004
@@ -599,6 +599,9 @@
static unsigned char oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
static unsigned char oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 };

+ if (idx < 0 || idx > 4)
+ return 0;
+
switch (pkt_type) {
case SYN_NEWABS:
case SYN_NEWABS_RELAXED:
@@ -629,7 +632,7 @@
return SYN_NEWABS_STRICT;
}

-void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
+psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
{
struct input_dev *dev = &psmouse->dev;
struct synaptics_data *priv = psmouse->private;
@@ -637,11 +640,6 @@
input_regs(dev, regs);

if (psmouse->pktcnt >= 6) { /* Full packet received */
- if (priv->out_of_sync) {
- priv->out_of_sync = 0;
- printk(KERN_NOTICE "Synaptics driver resynced.\n");
- }
-
if (unlikely(priv->pkt_type == SYN_NEWABS))
priv->pkt_type = synaptics_detect_pkt_type(psmouse);

@@ -649,16 +647,10 @@
synaptics_pass_pt_packet(&psmouse->ptport->serio, psmouse->packet);
else
synaptics_process_packet(psmouse);
- psmouse->pktcnt = 0;

- } else if (psmouse->pktcnt &&
- !synaptics_validate_byte(psmouse->packet, psmouse->pktcnt - 1, priv->pkt_type)) {
- printk(KERN_WARNING "Synaptics driver lost sync at byte %d\n", psmouse->pktcnt);
- psmouse->pktcnt = 0;
- if (++priv->out_of_sync == psmouse_resetafter) {
- psmouse->state = PSMOUSE_IGNORE;
- printk(KERN_NOTICE "synaptics: issuing reconnect request\n");
- serio_reconnect(psmouse->serio);
- }
+ return PSMOUSE_FULL_PACKET;
}
+
+ return synaptics_validate_byte(psmouse->packet, psmouse->pktcnt - 1, priv->pkt_type) ?
+ PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA;
}
diff -Nru a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
--- a/drivers/input/mouse/synaptics.h Tue Apr 20 23:11:25 2004
+++ b/drivers/input/mouse/synaptics.h Tue Apr 20 23:11:25 2004
@@ -9,7 +9,7 @@
#ifndef _SYNAPTICS_H
#define _SYNAPTICS_H

-extern void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs);
+extern psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs);
extern int synaptics_detect(struct psmouse *psmouse);
extern int synaptics_init(struct psmouse *psmouse);
extern void synaptics_reset(struct psmouse *psmouse);
@@ -103,7 +103,6 @@
unsigned long int identity; /* Identification */

/* Data for normal processing */
- unsigned int out_of_sync; /* # of packets out of sync */
int old_w; /* Previous w value */
unsigned char pkt_type; /* packet type - old, new, etc */
};

2004-04-21 06:08:48

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 10/15] New set of input patches: psmouse rescan on hotplug


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


[email protected], 2004-04-20 22:33:23-05:00, [email protected]
Input: when getting a new device announce (0xAA 0x00) in psmouse
try reconnecting instead of rescanning to preserve (if possible)
the same input device.


psmouse-base.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)


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



diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:10:23 2004
+++ b/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:10:23 2004
@@ -180,7 +180,7 @@
if (psmouse->pktcnt == 2) {
if (psmouse->packet[1] == PSMOUSE_RET_ID) {
psmouse->state = PSMOUSE_IGNORE;
- serio_rescan(serio);
+ serio_reconnect(serio);
goto out;
}
if (psmouse->type == PSMOUSE_SYNAPTICS) {

2004-04-21 06:13:35

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 14/15] New set of input patches: atkbd reconnect probe


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


[email protected], 2004-04-20 23:59:48-05:00, [email protected]
Input: do not modify device's properties when probing for protocol
extensions on reconnect as it may interfere with reconnect
process


logips2pp.c | 168 ++++++++++++++++++++++++++++++---------------------------
logips2pp.h | 5 +
psmouse-base.c | 78 ++++++++++++++------------
3 files changed, 137 insertions(+), 114 deletions(-)


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



diff -Nru a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
--- a/drivers/input/mouse/logips2pp.c Wed Apr 21 00:06:21 2004
+++ b/drivers/input/mouse/logips2pp.c Wed Apr 21 00:06:21 2004
@@ -89,7 +89,7 @@
* enabled if we do nothing to it. Of course I put this in because I want it
* disabled :P
* 1 - enabled (if previously disabled, also default)
- * 0/2 - disabled
+ * 0/2 - disabled
*/

static void ps2pp_set_smartscroll(struct psmouse *psmouse)
@@ -103,14 +103,11 @@
psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);

- if (psmouse_smartscroll == 1)
- param[0] = 1;
- else
- if (psmouse_smartscroll > 2)
- return;
-
- /* else leave param[0] == 0 to disable */
- psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
+ if (psmouse_smartscroll < 2) {
+ /* 0 - disabled, 1 - enabled */
+ param[0] = psmouse_smartscroll;
+ psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
+ }
}

/*
@@ -128,111 +125,128 @@
psmouse_command(psmouse, &param, PSMOUSE_CMD_SETRES);
}

+
+static int is_model_in_list(unsigned char model, int *model_list)
+{
+ int i;
+
+ for (i = 0; model_list[i] != -1; i++)
+ if (model == model_list[i])
+ return 1;
+ return 0;
+}
+
/*
- * Detect the exact model and features of a PS2++ or PS2T++ Logitech mouse or
- * touchpad.
+ * Set up input device's properties based on the detected mouse model.
*/

-static int ps2pp_detect_model(struct psmouse *psmouse, unsigned char *param)
+static void ps2pp_set_properties(struct psmouse *psmouse, unsigned char protocol,
+ unsigned char model, unsigned char buttons)
{
- int i;
static int logitech_4btn[] = { 12, 40, 41, 42, 43, 52, 73, 80, -1 };
static int logitech_wheel[] = { 52, 53, 75, 76, 80, 81, 83, 88, 112, -1 };
- static int logitech_ps2pp[] = { 12, 13, 40, 41, 42, 43, 50, 51, 52, 53, 73, 75,
- 76, 80, 81, 83, 88, 96, 97, 112, -1 };
static int logitech_mx[] = { 61, 112, -1 };

psmouse->vendor = "Logitech";
- psmouse->model = ((param[0] >> 4) & 0x07) | ((param[0] << 3) & 0x78);
+ psmouse->model = model;

- if (param[1] < 3)
+ if (buttons < 3)
clear_bit(BTN_MIDDLE, psmouse->dev.keybit);
- if (param[1] < 2)
+ if (buttons < 2)
clear_bit(BTN_RIGHT, psmouse->dev.keybit);

- psmouse->type = PSMOUSE_PS2;
+ if (protocol == PSMOUSE_PS2PP) {

- for (i = 0; logitech_ps2pp[i] != -1; i++)
- if (logitech_ps2pp[i] == psmouse->model)
- psmouse->type = PSMOUSE_PS2PP;
-
- if (psmouse->type == PSMOUSE_PS2PP) {
-
- for (i = 0; logitech_4btn[i] != -1; i++)
- if (logitech_4btn[i] == psmouse->model)
- set_bit(BTN_SIDE, psmouse->dev.keybit);
-
- for (i = 0; logitech_wheel[i] != -1; i++)
- if (logitech_wheel[i] == psmouse->model) {
- set_bit(REL_WHEEL, psmouse->dev.relbit);
- psmouse->name = "Wheel Mouse";
- }
+ if (is_model_in_list(model, logitech_4btn))
+ set_bit(BTN_SIDE, psmouse->dev.keybit);
+
+ if (is_model_in_list(model, logitech_wheel)) {
+ set_bit(REL_WHEEL, psmouse->dev.relbit);
+ psmouse->name = "Wheel Mouse";
+ }
+
+ if (is_model_in_list(model, logitech_mx)) {
+ set_bit(BTN_SIDE, psmouse->dev.keybit);
+ set_bit(BTN_EXTRA, psmouse->dev.keybit);
+ set_bit(BTN_BACK, psmouse->dev.keybit);
+ set_bit(BTN_FORWARD, psmouse->dev.keybit);
+ set_bit(BTN_TASK, psmouse->dev.keybit);
+ psmouse->name = "MX Mouse";
+ }
+ }
+
+ if (protocol == PSMOUSE_PS2TPP) {
+ set_bit(REL_WHEEL, psmouse->dev.relbit);
+ set_bit(REL_HWHEEL, psmouse->dev.relbit);
+ psmouse->name = "TouchPad 3";
+ }
+}

- for (i = 0; logitech_mx[i] != -1; i++)
- if (logitech_mx[i] == psmouse->model) {
- set_bit(BTN_SIDE, psmouse->dev.keybit);
- set_bit(BTN_EXTRA, psmouse->dev.keybit);
- set_bit(BTN_BACK, psmouse->dev.keybit);
- set_bit(BTN_FORWARD, psmouse->dev.keybit);
- set_bit(BTN_TASK, psmouse->dev.keybit);
- psmouse->name = "MX Mouse";
- }

/*
- * Do Logitech PS2++ / PS2T++ magic init.
+ * Logitech magic init. Detect whether the mouse is a Logitech one
+ * and its exact model and try turning on extended protocol for ones
+ * that support it.
*/

- if (psmouse->model == 97) { /* TouchPad 3 */
+int ps2pp_init(struct psmouse *psmouse, int set_properties)
+{
+ static int logitech_ps2pp[] = { 12, 13, 40, 41, 42, 43, 50, 51, 52, 53, 73, 75,
+ 76, 80, 81, 83, 88, 96, 97, 112, -1 };
+ unsigned char param[4];
+ unsigned char protocol = PSMOUSE_PS2;
+ unsigned char model, buttons;

- set_bit(REL_WHEEL, psmouse->dev.relbit);
- set_bit(REL_HWHEEL, psmouse->dev.relbit);
+ param[0] = 0;
+ psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11);
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11);
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11);
+ param[1] = 0;
+ psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO);

- param[0] = 0x11; param[1] = 0x04; param[2] = 0x68; /* Unprotect RAM */
+ if (param[1] != 0) {
+ model = ((param[0] >> 4) & 0x07) | ((param[0] << 3) & 0x78);
+ buttons = param[1];
+/*
+ * Do Logitech PS2++ / PS2T++ magic init.
+ */
+ if (model == 97) { /* Touch Pad 3 */
+
+ /* Unprotect RAM */
+ param[0] = 0x11; param[1] = 0x04; param[2] = 0x68;
psmouse_command(psmouse, param, 0x30d1);
- param[0] = 0x11; param[1] = 0x05; param[2] = 0x0b; /* Enable features */
+ /* Enable features */
+ param[0] = 0x11; param[1] = 0x05; param[2] = 0x0b;
psmouse_command(psmouse, param, 0x30d1);
- param[0] = 0x11; param[1] = 0x09; param[2] = 0xc3; /* Enable PS2++ */
+ /* Enable PS2++ */
+ param[0] = 0x11; param[1] = 0x09; param[2] = 0xc3;
psmouse_command(psmouse, param, 0x30d1);

param[0] = 0;
if (!psmouse_command(psmouse, param, 0x13d1) &&
- param[0] == 0x06 && param[1] == 0x00 && param[2] == 0x14) {
- psmouse->name = "TouchPad 3";
- return PSMOUSE_PS2TPP;
+ param[0] == 0x06 && param[1] == 0x00 && param[2] == 0x14) {
+ protocol = PSMOUSE_PS2TPP;
}

- } else {
+ } else if (is_model_in_list(model, logitech_ps2pp)) {

param[0] = param[1] = param[2] = 0;
ps2pp_cmd(psmouse, param, 0x39); /* Magic knock */
ps2pp_cmd(psmouse, param, 0xDB);

- if ((param[0] & 0x78) == 0x48 && (param[1] & 0xf3) == 0xc2 &&
- (param[2] & 3) == ((param[1] >> 2) & 3)) {
- ps2pp_set_smartscroll(psmouse);
- return PSMOUSE_PS2PP;
+ if ((param[0] & 0x78) == 0x48 &&
+ (param[1] & 0xf3) == 0xc2 &&
+ (param[2] & 0x03) == ((param[1] >> 2) & 3)) {
+ ps2pp_set_smartscroll(psmouse);
+ protocol = PSMOUSE_PS2PP;
}
}
- }
-
- return 0;
-}

-/*
- * Logitech magic init.
- */
-int ps2pp_detect(struct psmouse *psmouse)
-{
- unsigned char param[4];
-
- param[0] = 0;
- psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
- psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11);
- psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11);
- psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11);
- param[1] = 0;
- psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO);
+ if (set_properties)
+ ps2pp_set_properties(psmouse, protocol, model, buttons);
+ }

- return param[1] != 0 ? ps2pp_detect_model(psmouse, param) : 0;
+ return protocol;
}

diff -Nru a/drivers/input/mouse/logips2pp.h b/drivers/input/mouse/logips2pp.h
--- a/drivers/input/mouse/logips2pp.h Wed Apr 21 00:06:21 2004
+++ b/drivers/input/mouse/logips2pp.h Wed Apr 21 00:06:21 2004
@@ -10,8 +10,9 @@

#ifndef _LOGIPS2PP_H
#define _LOGIPS2PP_H
-struct psmouse;
+
void ps2pp_process_packet(struct psmouse *psmouse);
void ps2pp_set_800dpi(struct psmouse *psmouse);
-int ps2pp_detect(struct psmouse *psmouse);
+int ps2pp_init(struct psmouse *psmouse, int set_properties);
+
#endif
diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c Wed Apr 21 00:06:21 2004
+++ b/drivers/input/mouse/psmouse-base.c Wed Apr 21 00:06:21 2004
@@ -410,22 +410,21 @@
* the mouse may have.
*/

-static int psmouse_extensions(struct psmouse *psmouse, unsigned int max_proto)
+static int psmouse_extensions(struct psmouse *psmouse,
+ unsigned int max_proto, int set_properties)
{
int synaptics_hardware = 0;

- psmouse->vendor = "Generic";
- psmouse->name = "Mouse";
- psmouse->model = 0;
- psmouse->protocol_handler = psmouse_process_byte;
-
/*
* Try Synaptics TouchPad
*/
if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse)) {
synaptics_hardware = 1;
- psmouse->vendor = "Synaptics";
- psmouse->name = "TouchPad";
+
+ if (set_properties) {
+ psmouse->vendor = "Synaptics";
+ psmouse->name = "TouchPad";
+ }

if (max_proto > PSMOUSE_IMEX) {
if (synaptics_init(psmouse) == 0)
@@ -444,33 +443,44 @@
}

if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse)) {
- set_bit(BTN_EXTRA, psmouse->dev.keybit);
- set_bit(BTN_SIDE, psmouse->dev.keybit);
- set_bit(REL_WHEEL, psmouse->dev.relbit);

- psmouse->vendor = "Genius";
- psmouse->name = "Wheel Mouse";
+ if (set_properties) {
+ set_bit(BTN_EXTRA, psmouse->dev.keybit);
+ set_bit(BTN_SIDE, psmouse->dev.keybit);
+ set_bit(REL_WHEEL, psmouse->dev.relbit);
+ psmouse->vendor = "Genius";
+ psmouse->name = "Wheel Mouse";
+ }
+
return PSMOUSE_GENPS;
}

if (max_proto > PSMOUSE_IMEX) {
- int type = ps2pp_detect(psmouse);
- if (type)
+ int type = ps2pp_init(psmouse, set_properties);
+ if (type > PSMOUSE_PS2)
return type;
}

if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse)) {
- set_bit(REL_WHEEL, psmouse->dev.relbit);
+
+ if (set_properties) {
+ set_bit(REL_WHEEL, psmouse->dev.relbit);
+ if (!psmouse->name)
+ psmouse->name = "Wheel Mouse";
+ }

if (max_proto >= PSMOUSE_IMEX && im_explorer_detect(psmouse)) {
- set_bit(BTN_SIDE, psmouse->dev.keybit);
- set_bit(BTN_EXTRA, psmouse->dev.keybit);

- psmouse->name = "Explorer Mouse";
+ if (!set_properties) {
+ set_bit(BTN_SIDE, psmouse->dev.keybit);
+ set_bit(BTN_EXTRA, psmouse->dev.keybit);
+ if (!psmouse->name)
+ psmouse->name = "Explorer Mouse";
+ }
+
return PSMOUSE_IMEX;
}

- psmouse->name = "Wheel Mouse";
return PSMOUSE_IMPS;
}

@@ -520,12 +530,7 @@
if (psmouse_command(psmouse, NULL, PSMOUSE_CMD_RESET_DIS))
printk(KERN_WARNING "psmouse.c: Failed to reset mouse on %s\n", psmouse->serio->phys);

-/*
- * And here we try to determine if it has any extensions over the
- * basic PS/2 3-button mouse.
- */
-
- return psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto);
+ return 0;
}

/*
@@ -663,7 +668,6 @@
psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
-
psmouse->state = PSMOUSE_CMD_MODE;
psmouse->serio = serio;
psmouse->dev.private = psmouse;
@@ -675,13 +679,21 @@
return;
}

- if (psmouse_probe(psmouse) <= 0) {
+ if (psmouse_probe(psmouse) < 0) {
serio_close(serio);
kfree(psmouse);
serio->private = NULL;
return;
}

+ psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto, 1);
+ if (!psmouse->vendor)
+ psmouse->vendor = "Generic";
+ if (!psmouse->name)
+ psmouse->name = "Mouse";
+ if (!psmouse->protocol_handler)
+ psmouse->protocol_handler = psmouse_process_byte;
+
sprintf(psmouse->devname, "%s %s %s",
psmouse_protocols[psmouse->type], psmouse->vendor, psmouse->name);
sprintf(psmouse->phys, "%s/input0",
@@ -715,28 +727,24 @@
{
struct psmouse *psmouse = serio->private;
struct serio_dev *dev = serio->dev;
- int old_type;

if (!dev || !psmouse) {
printk(KERN_DEBUG "psmouse: reconnect request, but serio is disconnected, ignoring...\n");
return -1;
}

- old_type = psmouse->type;
-
psmouse->state = PSMOUSE_CMD_MODE;
- psmouse->type = psmouse->acking = 0;
- psmouse->cmdcnt = psmouse->pktcnt = psmouse->out_of_sync = 0;
+ psmouse->acking = psmouse->cmdcnt = psmouse->pktcnt = psmouse->out_of_sync = 0;
if (psmouse->reconnect) {
if (psmouse->reconnect(psmouse))
return -1;
- } else if (psmouse_probe(psmouse) != old_type)
+ } else if (psmouse_probe(psmouse) < 0 ||
+ psmouse->type != psmouse_extensions(psmouse, psmouse_max_proto, 0))
return -1;

/* ok, the device type (and capabilities) match the old one,
* we can continue using it, complete intialization
*/
- psmouse->type = old_type;
psmouse_initialize(psmouse);

if (psmouse->ptport) {

2004-04-21 06:12:20

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 13/15] New set of input patches: psmouse sliced commands


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


[email protected], 2004-04-20 22:42:22-05:00, [email protected]
Input: add psmouse_sliced_command (passes extended commands encoded
with 0xE8 to the mouse) and use it in Synaptics and Logitech
drivers


logips2pp.c | 12 +-----------
psmouse-base.c | 24 ++++++++++++++++++++++++
psmouse.h | 1 +
synaptics.c | 28 +++-------------------------
4 files changed, 29 insertions(+), 36 deletions(-)


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



diff -Nru a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
--- a/drivers/input/mouse/logips2pp.c Tue Apr 20 23:12:25 2004
+++ b/drivers/input/mouse/logips2pp.c Tue Apr 20 23:12:25 2004
@@ -63,7 +63,6 @@
packet[0] &= 0x0f;
packet[1] = 0;
packet[2] = 0;
-
}
}

@@ -76,17 +75,8 @@

static int ps2pp_cmd(struct psmouse *psmouse, unsigned char *param, unsigned char command)
{
- unsigned char d;
- int i;
-
- if (psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11))
+ if (psmouse_sliced_command(psmouse, command))
return -1;
-
- for (i = 6; i >= 0; i -= 2) {
- d = (command >> i) & 3;
- if(psmouse_command(psmouse, &d, PSMOUSE_CMD_SETRES))
- return -1;
- }

if (psmouse_command(psmouse, param, PSMOUSE_CMD_POLL))
return -1;
diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:12:25 2004
+++ b/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:12:25 2004
@@ -312,6 +312,30 @@


/*
+ * psmouse_sliced_command() sends an extended PS/2 command to the mouse
+ * using sliced syntax, understood by advanced devices, such as Logitech
+ * or Synaptics touchpads. The command is encoded as:
+ * 0xE6 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu
+ * is the command.
+ */
+int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command)
+{
+ int i;
+
+ if (psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11))
+ return -1;
+
+ for (i = 6; i >= 0; i -= 2) {
+ unsigned char d = (command >> i) & 3;
+ if (psmouse_command(psmouse, &d, PSMOUSE_CMD_SETRES))
+ return -1;
+ }
+
+ return 0;
+}
+
+
+/*
* psmouse_reset() resets the mouse into power-on state.
*/
int psmouse_reset(struct psmouse *psmouse)
diff -Nru a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
--- a/drivers/input/mouse/psmouse.h Tue Apr 20 23:12:25 2004
+++ b/drivers/input/mouse/psmouse.h Tue Apr 20 23:12:25 2004
@@ -74,6 +74,7 @@
#define PSMOUSE_SYNAPTICS 7

int psmouse_command(struct psmouse *psmouse, unsigned char *param, int command);
+int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
int psmouse_reset(struct psmouse *psmouse);

extern int psmouse_smartscroll;
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c Tue Apr 20 23:12:25 2004
+++ b/drivers/input/mouse/synaptics.c Tue Apr 20 23:12:25 2004
@@ -44,33 +44,11 @@
****************************************************************************/

/*
- * Use the Synaptics extended ps/2 syntax to write a special command byte.
- * special command: 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu
- * is the command. A 0xF3 or 0xE9 must follow (see synaptics_send_cmd
- * and synaptics_mode_cmd)
- */
-static int synaptics_special_cmd(struct psmouse *psmouse, unsigned char command)
-{
- int i;
-
- if (psmouse_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11))
- return -1;
-
- for (i = 6; i >= 0; i -= 2) {
- unsigned char d = (command >> i) & 3;
- if (psmouse_command(psmouse, &d, PSMOUSE_CMD_SETRES))
- return -1;
- }
-
- return 0;
-}
-
-/*
* Send a command to the synpatics touchpad by special commands
*/
static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param)
{
- if (synaptics_special_cmd(psmouse, c))
+ if (psmouse_sliced_command(psmouse, c))
return -1;
if (psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO))
return -1;
@@ -84,7 +62,7 @@
{
unsigned char param[1];

- if (synaptics_special_cmd(psmouse, mode))
+ if (psmouse_sliced_command(psmouse, mode))
return -1;
param[0] = SYN_PS_SET_MODE2;
if (psmouse_command(psmouse, param, PSMOUSE_CMD_SETRATE))
@@ -248,7 +226,7 @@
struct psmouse *parent = port->driver;
char rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */

- if (synaptics_special_cmd(parent, c))
+ if (psmouse_sliced_command(parent, c))
return -1;
if (psmouse_command(parent, &rate_param, PSMOUSE_CMD_SETRATE))
return -1;

2004-04-21 06:08:48

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 9/15] New set of input patches: atkbd timeout complaints


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


[email protected], 2004-04-20 22:32:46-05:00, [email protected]
Input: Do not generate events from atkbd until keyboard is completely
initialized. It should suppress messages about suprious NAKs
when controller's timeout is longer than one in atkbd


atkbd.c | 6 ++++++
1 files changed, 6 insertions(+)


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



diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c Tue Apr 20 23:09:40 2004
+++ b/drivers/input/keyboard/atkbd.c Tue Apr 20 23:09:40 2004
@@ -188,6 +188,7 @@
unsigned int resend:1;
unsigned int release:1;
unsigned int bat_xl:1;
+ unsigned int enabled:1;

unsigned int last;
unsigned long time;
@@ -248,6 +249,9 @@
goto out;
}

+ if (!atkbd->enabled)
+ goto out;
+
if (atkbd->translated) {

if (atkbd->emul ||
@@ -749,6 +753,8 @@
atkbd->set = 2;
atkbd->id = 0xab00;
}
+
+ atkbd->enabled = 1;

if (atkbd->extra) {
atkbd->dev.ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) | BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC);

2004-04-21 06:15:22

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 15/15] New set of input patches: allow disabling psaux


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


[email protected], 2004-04-21 00:02:58-05:00, [email protected]
Input: allow disabling legacy psaux device even for non-embedded systems


Kconfig | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletion(-)


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



diff -Nru a/drivers/input/Kconfig b/drivers/input/Kconfig
--- a/drivers/input/Kconfig Wed Apr 21 00:06:52 2004
+++ b/drivers/input/Kconfig Wed Apr 21 00:06:52 2004
@@ -41,9 +41,16 @@
module will be called mousedev.

config INPUT_MOUSEDEV_PSAUX
- bool "Provide legacy /dev/psaux device" if EMBEDDED
+ bool "Provide legacy /dev/psaux device"
default y
depends on INPUT_MOUSEDEV
+ ---help---
+ Say Y here if you want your mouse also be accessible as char device
+ 10:1 - /dev/psaux. The data available through /dev/psaux is exactly
+ the same as the data from /dev/input/mice.
+
+ If unsure, say Y.
+

config INPUT_MOUSEDEV_SCREEN_X
int "Horizontal screen resolution"

2004-04-21 06:08:48

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 8/15] New set of input patches: atkbd - use bitfields


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


[email protected], 2004-04-20 22:29:12-05:00, [email protected]
Input: remove unneeded fields in atkbd structure, convert to bitfields


atkbd.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)


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



diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c Tue Apr 20 23:08:14 2004
+++ b/drivers/input/keyboard/atkbd.c Tue Apr 20 23:08:14 2004
@@ -26,7 +26,6 @@
#include <linux/input.h>
#include <linux/serio.h>
#include <linux/workqueue.h>
-#include <linux/timer.h>

MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
MODULE_DESCRIPTION("AT and PS/2 keyboard driver");
@@ -173,22 +172,23 @@
unsigned char keycode[512];
struct input_dev dev;
struct serio *serio;
- struct timer_list timer;
+
char name[64];
char phys[32];
+ unsigned short id;
+ unsigned char set;
+ unsigned int translated:1;
+ unsigned int extra:1;
+ unsigned int write:1;
+
unsigned char cmdbuf[4];
unsigned char cmdcnt;
- unsigned char set;
- unsigned char extra;
- unsigned char release;
- int lastkey;
volatile signed char ack;
unsigned char emul;
- unsigned short id;
- unsigned char write;
- unsigned char translated;
- unsigned char resend;
- unsigned char bat_xl;
+ unsigned int resend:1;
+ unsigned int release:1;
+ unsigned int bat_xl:1;
+
unsigned int last;
unsigned long time;
};

2004-04-21 06:16:58

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 12/15] New set of input patches: psmouse add protocol_handler


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


[email protected], 2004-04-20 22:41:52-05:00, [email protected]
Input: add protocol_handler to psmouse structure to ease adding
new protocols to psmouse module


psmouse-base.c | 4
psmouse.h | 1
synaptics.c | 285 ++++++++++++++++++++++++++++-----------------------------
synaptics.h | 1
4 files changed, 147 insertions(+), 144 deletions(-)


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



diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:12:01 2004
+++ b/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:12:01 2004
@@ -203,8 +203,7 @@
}
}

- rc = psmouse->type == PSMOUSE_SYNAPTICS ?
- synaptics_process_byte(psmouse, regs) : psmouse_process_byte(psmouse, regs);
+ rc = psmouse->protocol_handler(psmouse, regs);

switch (rc) {
case PSMOUSE_BAD_DATA:
@@ -394,6 +393,7 @@
psmouse->vendor = "Generic";
psmouse->name = "Mouse";
psmouse->model = 0;
+ psmouse->protocol_handler = psmouse_process_byte;

/*
* Try Synaptics TouchPad
diff -Nru a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
--- a/drivers/input/mouse/psmouse.h Tue Apr 20 23:12:01 2004
+++ b/drivers/input/mouse/psmouse.h Tue Apr 20 23:12:01 2004
@@ -60,6 +60,7 @@
char devname[64];
char phys[32];

+ psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse, struct pt_regs *regs);
int (*reconnect)(struct psmouse *psmouse);
void (*disconnect)(struct psmouse *psmouse);
};
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c Tue Apr 20 23:12:01 2004
+++ b/drivers/input/mouse/synaptics.c Tue Apr 20 23:12:01 2004
@@ -312,146 +312,6 @@
}

/*****************************************************************************
- * Driver initialization/cleanup functions
- ****************************************************************************/
-
-static inline void set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
-{
- dev->absmin[axis] = min;
- dev->absmax[axis] = max;
- dev->absfuzz[axis] = fuzz;
- dev->absflat[axis] = flat;
-
- set_bit(axis, dev->absbit);
-}
-
-static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
-{
- int i;
-
- set_bit(EV_ABS, dev->evbit);
- set_abs_params(dev, ABS_X, XMIN_NOMINAL, XMAX_NOMINAL, 0, 0);
- set_abs_params(dev, ABS_Y, YMIN_NOMINAL, YMAX_NOMINAL, 0, 0);
- set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
- set_bit(ABS_TOOL_WIDTH, dev->absbit);
-
- set_bit(EV_KEY, dev->evbit);
- set_bit(BTN_TOUCH, dev->keybit);
- set_bit(BTN_TOOL_FINGER, dev->keybit);
- set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
- set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
-
- set_bit(BTN_LEFT, dev->keybit);
- set_bit(BTN_RIGHT, dev->keybit);
-
- if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
- set_bit(BTN_MIDDLE, dev->keybit);
-
- if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
- set_bit(BTN_FORWARD, dev->keybit);
- set_bit(BTN_BACK, dev->keybit);
- }
-
- for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++)
- set_bit(BTN_0 + i, dev->keybit);
-
- clear_bit(EV_REL, dev->evbit);
- clear_bit(REL_X, dev->relbit);
- clear_bit(REL_Y, dev->relbit);
-}
-
-void synaptics_reset(struct psmouse *psmouse)
-{
- /* reset touchpad back to relative mode, gestures enabled */
- synaptics_mode_cmd(psmouse, 0);
-}
-
-static void synaptics_disconnect(struct psmouse *psmouse)
-{
- synaptics_reset(psmouse);
- kfree(psmouse->private);
-}
-
-static int synaptics_reconnect(struct psmouse *psmouse)
-{
- struct synaptics_data *priv = psmouse->private;
- struct synaptics_data old_priv = *priv;
-
- if (!synaptics_detect(psmouse))
- return -1;
-
- if (synaptics_query_hardware(psmouse)) {
- printk(KERN_ERR "Unable to query Synaptics hardware.\n");
- return -1;
- }
-
- if (old_priv.identity != priv->identity ||
- old_priv.model_id != priv->model_id ||
- old_priv.capabilities != priv->capabilities ||
- old_priv.ext_cap != priv->ext_cap)
- return -1;
-
- if (synaptics_set_mode(psmouse, 0)) {
- printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
- return -1;
- }
-
- return 0;
-}
-
-int synaptics_detect(struct psmouse *psmouse)
-{
- unsigned char param[4];
-
- param[0] = 0;
-
- psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
- psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
- psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
- psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
- psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO);
-
- return param[1] == 0x47;
-}
-
-int synaptics_init(struct psmouse *psmouse)
-{
- struct synaptics_data *priv;
-
- psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL);
- if (!priv)
- return -1;
- memset(priv, 0, sizeof(struct synaptics_data));
-
- if (synaptics_query_hardware(psmouse)) {
- printk(KERN_ERR "Unable to query Synaptics hardware.\n");
- goto init_fail;
- }
-
- if (synaptics_set_mode(psmouse, 0)) {
- printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
- goto init_fail;
- }
-
- priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
-
- if (SYN_CAP_PASS_THROUGH(priv->capabilities))
- synaptics_pt_create(psmouse);
-
- print_ident(priv);
- set_input_params(&psmouse->dev, priv);
-
- psmouse->disconnect = synaptics_disconnect;
- psmouse->reconnect = synaptics_reconnect;
-
- return 0;
-
- init_fail:
- kfree(priv);
- return -1;
-}
-
-/*****************************************************************************
* Functions to interpret the absolute mode packets
****************************************************************************/

@@ -632,7 +492,7 @@
return SYN_NEWABS_STRICT;
}

-psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
+static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
{
struct input_dev *dev = &psmouse->dev;
struct synaptics_data *priv = psmouse->private;
@@ -654,3 +514,146 @@
return synaptics_validate_byte(psmouse->packet, psmouse->pktcnt - 1, priv->pkt_type) ?
PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA;
}
+
+/*****************************************************************************
+ * Driver initialization/cleanup functions
+ ****************************************************************************/
+
+static inline void set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
+{
+ dev->absmin[axis] = min;
+ dev->absmax[axis] = max;
+ dev->absfuzz[axis] = fuzz;
+ dev->absflat[axis] = flat;
+
+ set_bit(axis, dev->absbit);
+}
+
+static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
+{
+ int i;
+
+ set_bit(EV_ABS, dev->evbit);
+ set_abs_params(dev, ABS_X, XMIN_NOMINAL, XMAX_NOMINAL, 0, 0);
+ set_abs_params(dev, ABS_Y, YMIN_NOMINAL, YMAX_NOMINAL, 0, 0);
+ set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
+ set_bit(ABS_TOOL_WIDTH, dev->absbit);
+
+ set_bit(EV_KEY, dev->evbit);
+ set_bit(BTN_TOUCH, dev->keybit);
+ set_bit(BTN_TOOL_FINGER, dev->keybit);
+ set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
+ set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
+
+ set_bit(BTN_LEFT, dev->keybit);
+ set_bit(BTN_RIGHT, dev->keybit);
+
+ if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
+ set_bit(BTN_MIDDLE, dev->keybit);
+
+ if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
+ set_bit(BTN_FORWARD, dev->keybit);
+ set_bit(BTN_BACK, dev->keybit);
+ }
+
+ for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++)
+ set_bit(BTN_0 + i, dev->keybit);
+
+ clear_bit(EV_REL, dev->evbit);
+ clear_bit(REL_X, dev->relbit);
+ clear_bit(REL_Y, dev->relbit);
+}
+
+void synaptics_reset(struct psmouse *psmouse)
+{
+ /* reset touchpad back to relative mode, gestures enabled */
+ synaptics_mode_cmd(psmouse, 0);
+}
+
+static void synaptics_disconnect(struct psmouse *psmouse)
+{
+ synaptics_reset(psmouse);
+ kfree(psmouse->private);
+}
+
+static int synaptics_reconnect(struct psmouse *psmouse)
+{
+ struct synaptics_data *priv = psmouse->private;
+ struct synaptics_data old_priv = *priv;
+
+ if (!synaptics_detect(psmouse))
+ return -1;
+
+ if (synaptics_query_hardware(psmouse)) {
+ printk(KERN_ERR "Unable to query Synaptics hardware.\n");
+ return -1;
+ }
+
+ if (old_priv.identity != priv->identity ||
+ old_priv.model_id != priv->model_id ||
+ old_priv.capabilities != priv->capabilities ||
+ old_priv.ext_cap != priv->ext_cap)
+ return -1;
+
+ if (synaptics_set_mode(psmouse, 0)) {
+ printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int synaptics_detect(struct psmouse *psmouse)
+{
+ unsigned char param[4];
+
+ param[0] = 0;
+
+ psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
+ psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
+ psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
+ psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
+ psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO);
+
+ return param[1] == 0x47;
+}
+
+int synaptics_init(struct psmouse *psmouse)
+{
+ struct synaptics_data *priv;
+
+ psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL);
+ if (!priv)
+ return -1;
+ memset(priv, 0, sizeof(struct synaptics_data));
+
+ if (synaptics_query_hardware(psmouse)) {
+ printk(KERN_ERR "Unable to query Synaptics hardware.\n");
+ goto init_fail;
+ }
+
+ if (synaptics_set_mode(psmouse, 0)) {
+ printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
+ goto init_fail;
+ }
+
+ priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
+
+ if (SYN_CAP_PASS_THROUGH(priv->capabilities))
+ synaptics_pt_create(psmouse);
+
+ print_ident(priv);
+ set_input_params(&psmouse->dev, priv);
+
+ psmouse->protocol_handler = synaptics_process_byte;
+ psmouse->disconnect = synaptics_disconnect;
+ psmouse->reconnect = synaptics_reconnect;
+
+ return 0;
+
+ init_fail:
+ kfree(priv);
+ return -1;
+}
+
+
diff -Nru a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
--- a/drivers/input/mouse/synaptics.h Tue Apr 20 23:12:01 2004
+++ b/drivers/input/mouse/synaptics.h Tue Apr 20 23:12:01 2004
@@ -9,7 +9,6 @@
#ifndef _SYNAPTICS_H
#define _SYNAPTICS_H

-extern psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs);
extern int synaptics_detect(struct psmouse *psmouse);
extern int synaptics_init(struct psmouse *psmouse);
extern void synaptics_reset(struct psmouse *psmouse);

2004-04-21 06:21:36

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 4/15] New set of input patches: lkkbd whitespace


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


[email protected], 2004-04-20 22:25:18-05:00, [email protected]
Input: fix spelling and trailing whitespaces in lkkbd


lkkbd.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)


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



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
- * information given below, I will _not_ be lieable!
+ * information given below, I will _not_ be liable!
*
* RJ11 pinout: To DB9: Or DB25:
* 1 - RxD <----> Pin 3 (TxD) <-> Pin 2 (TxD)
@@ -39,18 +39,18 @@
/*
* 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.),

2004-04-21 06:21:37

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 3/15] New set of input patches: dont change max proto


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


[email protected], 2004-04-20 22:24:21-05:00, [email protected]
Input: pass maximum allowed protocol to psmouse_extensions instead of
accessing psmouse_max_proto directly allowing to avoid changing
the global parameter when synaptics initialization fails


psmouse-base.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)


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



diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:00:21 2004
+++ b/drivers/input/mouse/psmouse-base.c Tue Apr 20 23:00:21 2004
@@ -363,7 +363,7 @@
* the mouse may have.
*/

-static int psmouse_extensions(struct psmouse *psmouse)
+static int psmouse_extensions(struct psmouse *psmouse, unsigned int max_proto)
{
int synaptics_hardware = 0;

@@ -374,12 +374,12 @@
/*
* Try Synaptics TouchPad
*/
- if (psmouse_max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse)) {
+ if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse)) {
synaptics_hardware = 1;
psmouse->vendor = "Synaptics";
psmouse->name = "TouchPad";

- if (psmouse_max_proto > PSMOUSE_IMEX) {
+ if (max_proto > PSMOUSE_IMEX) {
if (synaptics_init(psmouse) == 0)
return PSMOUSE_SYNAPTICS;
/*
@@ -387,7 +387,7 @@
* Unfortunately Logitech/Genius probes confuse some firmware versions so
* we'll have to skip them.
*/
- psmouse_max_proto = PSMOUSE_IMEX;
+ max_proto = PSMOUSE_IMEX;
}
/*
* Make sure that touchpad is in relative mode, gestures (taps) are enabled
@@ -395,7 +395,7 @@
synaptics_reset(psmouse);
}

- if (psmouse_max_proto > PSMOUSE_IMEX && genius_detect(psmouse)) {
+ if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse)) {
set_bit(BTN_EXTRA, psmouse->dev.keybit);
set_bit(BTN_SIDE, psmouse->dev.keybit);
set_bit(REL_WHEEL, psmouse->dev.relbit);
@@ -405,17 +405,16 @@
return PSMOUSE_GENPS;
}

- if (psmouse_max_proto > PSMOUSE_IMEX) {
+ if (max_proto > PSMOUSE_IMEX) {
int type = ps2pp_detect(psmouse);
if (type)
return type;
}

- if (psmouse_max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse)) {
+ if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse)) {
set_bit(REL_WHEEL, psmouse->dev.relbit);

- if (psmouse_max_proto >= PSMOUSE_IMEX &&
- im_explorer_detect(psmouse)) {
+ if (max_proto >= PSMOUSE_IMEX && im_explorer_detect(psmouse)) {
set_bit(BTN_SIDE, psmouse->dev.keybit);
set_bit(BTN_EXTRA, psmouse->dev.keybit);

@@ -478,7 +477,7 @@
* basic PS/2 3-button mouse.
*/

- return psmouse->type = psmouse_extensions(psmouse);
+ return psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto);
}

/*

2004-04-21 06:21:36

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 5/15] New set of input patches: lkkbd simplify checks


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


[email protected], 2004-04-20 22:26:58-05:00, [email protected]
Input: simplify checks for supported serio port in lkkbd


lkkbd.c | 4 +---
1 files changed, 1 insertion(+), 3 deletions(-)


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



diff -Nru a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
--- a/drivers/input/keyboard/lkkbd.c Tue Apr 20 23:01:41 2004
+++ b/drivers/input/keyboard/lkkbd.c Tue Apr 20 23:01:41 2004
@@ -527,9 +527,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)))

2004-04-21 06:21:35

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 7/15] New set of input patches: atkbd trailing whitespace


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


[email protected], 2004-04-20 22:28:38-05:00, [email protected]
Input: fix trailing whitespace in atkbd


atkbd.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)


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



diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c Tue Apr 20 23:07:43 2004
+++ b/drivers/input/keyboard/atkbd.c Tue Apr 20 23:07:43 2004
@@ -814,12 +814,12 @@
param[0] = (test_bit(LED_SCROLLL, atkbd->dev.led) ? 1 : 0)
| (test_bit(LED_NUML, atkbd->dev.led) ? 2 : 0)
| (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0);
-
+
if (atkbd_probe(atkbd))
return -1;
if (atkbd->set != atkbd_set_3(atkbd))
return -1;
-
+
atkbd_enable(atkbd);

if (atkbd_command(atkbd, param, ATKBD_CMD_SETLEDS))

2004-04-21 06:21:36

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 6/15] New set of input patches: atkbd soften accusation


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


[email protected], 2004-04-20 22:27:51-05:00, [email protected]
Input: Change spurious ACK warning in atkbd to soften accusation
against XFree86


atkbd.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)


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



diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
--- a/drivers/input/keyboard/atkbd.c Tue Apr 20 23:04:41 2004
+++ b/drivers/input/keyboard/atkbd.c Tue Apr 20 23:04:41 2004
@@ -300,15 +300,20 @@
case ATKBD_KEY_NULL:
break;
case ATKBD_KEY_UNKNOWN:
- printk(KERN_WARNING "atkbd.c: Unknown key %s (%s set %d, code %#x on %s).\n",
- atkbd->release ? "released" : "pressed",
- atkbd->translated ? "translated" : "raw",
- atkbd->set, code, serio->phys);
- if (atkbd->translated && atkbd->set == 2 && code == 0x7a)
- printk(KERN_WARNING "atkbd.c: This is an XFree86 bug. It shouldn't access"
- " hardware directly.\n");
- else
- printk(KERN_WARNING "atkbd.c: Use 'setkeycodes %s%02x <keycode>' to make it known.\n", code & 0x80 ? "e0" : "", code & 0x7f);
+ if (data == ATKBD_RET_ACK || data == ATKBD_RET_NAK) {
+ printk(KERN_WARNING "atkbd.c: Spurious %s on %s. Some program, "
+ "like XFree86, might be trying access hardware directly.\n",
+ data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys);
+ } else {
+ printk(KERN_WARNING "atkbd.c: Unknown key %s "
+ "(%s set %d, code %#x on %s).\n",
+ atkbd->release ? "released" : "pressed",
+ atkbd->translated ? "translated" : "raw",
+ atkbd->set, code, serio->phys);
+ printk(KERN_WARNING "atkbd.c: Use 'setkeycodes %s%02x <keycode>' "
+ "to make it known.\n",
+ code & 0x80 ? "e0" : "", code & 0x7f);
+ }
break;
case ATKBD_SCR_1:
scroll = 1 - atkbd->release * 2;

2004-04-21 06:31:04

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 2/15] New set of input patches: synaptics middle button support


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


[email protected], 2004-04-20 22:23:47-05:00, [email protected]
Input: support Synaptics touchpads that have separate middle button


synaptics.c | 11 +++++++++++
synaptics.h | 2 ++
2 files changed, 13 insertions(+)


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



diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c Tue Apr 20 22:57:07 2004
+++ b/drivers/input/mouse/synaptics.c Tue Apr 20 22:57:07 2004
@@ -184,6 +184,8 @@
if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap))
printk(KERN_INFO " -> %d multi-buttons, i.e. besides standard buttons\n",
(int)(SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)));
+ if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
+ printk(KERN_INFO " -> middle button\n");
if (SYN_CAP_FOUR_BUTTON(priv->capabilities))
printk(KERN_INFO " -> four buttons\n");
if (SYN_CAP_MULTIFINGER(priv->capabilities))
@@ -342,6 +344,9 @@
set_bit(BTN_LEFT, dev->keybit);
set_bit(BTN_RIGHT, dev->keybit);

+ if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
+ set_bit(BTN_MIDDLE, dev->keybit);
+
if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
set_bit(BTN_FORWARD, dev->keybit);
set_bit(BTN_BACK, dev->keybit);
@@ -470,6 +475,9 @@
hw->left = (buf[0] & 0x01) ? 1 : 0;
hw->right = (buf[0] & 0x02) ? 1 : 0;

+ if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
+ hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
+
if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
hw->up = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0;
@@ -568,6 +576,9 @@

input_report_key(dev, BTN_LEFT, hw.left);
input_report_key(dev, BTN_RIGHT, hw.right);
+
+ if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
+ input_report_key(dev, BTN_MIDDLE, hw.middle);

if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
input_report_key(dev, BTN_FORWARD, hw.up);
diff -Nru a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
--- a/drivers/input/mouse/synaptics.h Tue Apr 20 22:57:07 2004
+++ b/drivers/input/mouse/synaptics.h Tue Apr 20 22:57:07 2004
@@ -44,6 +44,7 @@

/* synaptics capability bits */
#define SYN_CAP_EXTENDED(c) ((c) & (1 << 23))
+#define SYN_CAP_MIDDLE_BUTTON(c) ((c) & (1 << 18))
#define SYN_CAP_PASS_THROUGH(c) ((c) & (1 << 7))
#define SYN_CAP_SLEEP(c) ((c) & (1 << 4))
#define SYN_CAP_FOUR_BUTTON(c) ((c) & (1 << 3))
@@ -88,6 +89,7 @@
int w;
unsigned int left:1;
unsigned int right:1;
+ unsigned int middle:1;
unsigned int up:1;
unsigned int down:1;
unsigned char ext_buttons;

2004-04-21 11:34:10

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [PATCH 5/15] New set of input patches: lkkbd simplify checks

On Wed, 2004-04-21 00:53:07 -0500, Dmitry Torokhov <[email protected]>
wrote in message <[email protected]>:
> --- a/drivers/input/keyboard/lkkbd.c Tue Apr 20 23:01:41 2004
> +++ b/drivers/input/keyboard/lkkbd.c Tue Apr 20 23:01:41 2004
> @@ -527,9 +527,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)))

Looks good. I'll take this patch inty my "master" version.

MfG, JBG

--
Jan-Benedict Glaw [email protected] . +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));


Attachments:
(No filename) (995.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-04-21 11:39:51

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [PATCH 4/15] New set of input patches: lkkbd whitespace

On Wed, 2004-04-21 00:52:25 -0500, Dmitry Torokhov <[email protected]>
wrote in message <[email protected]>:
> 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.

MfG, JBG

--
Jan-Benedict Glaw [email protected] . +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));


Attachments:
(No filename) (868.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-04-21 12:41:40

by Jan-Benedict Glaw

[permalink] [raw]
Subject: [New-PATCH] lkkbd: Current version

On Wed, 2004-04-21 13:39:47 +0200, Jan-Benedict Glaw <[email protected]>
wrote in message <[email protected]>:
> On Wed, 2004-04-21 00:52:25 -0500, Dmitry Torokhov <[email protected]>
> wrote in message <[email protected]>:
> > 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 <[email protected]>");
+MODULE_AUTHOR ("Jan-Benedict Glaw <[email protected]>");
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 "
+ "<[email protected]>\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 [email protected] . +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));


Attachments:
(No filename) (9.66 kB)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-04-21 12:46:33

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: [PATCH 0/15] New set of input patches

On Wed, 2004-04-21 00:49:17 -0500, Dmitry Torokhov <[email protected]>
wrote in message <[email protected]>:

...and while we are at it, here's a patch to bring vsxxxaa.c to current
version. I'm running this for daily use on my Athlon (right, the
hardware was developed some 20 years ago for DECstations and
VAXstations).

It also correctly supports the VSXXX-AB digitizer tablet :)


#
# This patch updates the vsxxx driver to it's current version.
# Even DEC tablet support (VSXXX-AB) is now tested - it works:)
# You can even hotplug between mouse and digitizer...
#

Index: linux-2.6.6-rc2/drivers/input/mouse/vsxxxaa.c
===================================================================
--- linux-2.6.6-rc2.orig/drivers/input/mouse/vsxxxaa.c 2004-04-04 05:38:27.000000000 +0200
+++ linux-2.6.6-rc2/drivers/input/mouse/vsxxxaa.c 2004-04-21 14:27:03.000000000 +0200
@@ -11,14 +11,14 @@
/*
* 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
@@ -45,32 +45,32 @@
*
* DEC socket DB9 DB25 Note
* 1 (GND) 5 7 -
- * 2 (RxD) 3 3 -
- * 3 (TxD) 2 2 -
+ * 2 (RxD) 2 3 -
+ * 3 (TxD) 3 2 -
* 4 (-12V) - - Somewhere from the PSU. At ATX, it's
- * the blue wire at pin 12 of the ATX
- * power connector. Please note that the
- * docs say this should be +12V! However,
- * I measured -12V...
- * 5 (+5V) - - PSU (red wire of ATX power connector
+ * the thin blue wire at pin 12 of the
+ * ATX power connector. Only required for
+ * VSXXX-AA/-GA mice.
+ * 5 (+5V) - - PSU (red wires of ATX power connector
* on pin 4, 6, 19 or 20) or HDD power
- * connector (also red wire)
- * 6 (not conn.) - - -
+ * connector (also red wire).
+ * 6 (+12V) - - HDD power connector, yellow wire. Only
+ * required for VSXXX-AB digitizer.
* 7 (dev. avail.) - - The mouse shorts this one to pin 1.
* This way, the host computer can detect
* the mouse. To use it with the adaptor,
* simply don't connect this pin.
*
* So to get a working adaptor, you need to connect the mouse with three
- * wires to a RS232 port and two additional wires for +5V and -12V to the
- * PSU.
+ * wires to a RS232 port and two or three additional wires for +5V, +12V and
+ * -12V to the PSU.
*
* Flow specification for the link is 4800, 8o1.
- */
-
-/*
- * TODO list:
- * - Automatically attach to a given serial port (no need for inputattach).
+ *
+ * The mice and tablet are described in "VCB02 Video Subsystem - Technical
+ * Manual", DEC EK-104AA-TM-001. You'll find it at MANX, a search engine
+ * specific for DEC documentation. Try
+ * http://www.vt100.net/manx/details?pn=EK-104AA-TM-001;id=21;cp=1
*/

#include <linux/delay.h>
@@ -115,6 +115,7 @@
unsigned char version;
unsigned char country;
unsigned char type;
+ char name[64];
char phys[32];
};

@@ -134,27 +135,34 @@
{
if (mouse->count == BUFLEN) {
printk (KERN_ERR "%s on %s: Dropping a byte of full buffer.\n",
- mouse->dev.name, mouse->dev.phys);
+ mouse->name, mouse->phys);
vsxxxaa_drop_bytes (mouse, 1);
}
+ DBG (KERN_INFO "Queueing byte 0x%02x\n", byte);

mouse->buf[mouse->count++] = byte;
}

static void
-vsxxxaa_report_mouse (struct vsxxxaa *mouse)
+vsxxxaa_detection_done (struct vsxxxaa *mouse)
{
- char *devtype;
-
switch (mouse->type) {
- case 0x02: devtype = "DEC mouse"; break;
- case 0x04: devtype = "DEC tablet"; break;
- default: devtype = "unknown DEC device"; break;
+ case 0x02:
+ sprintf (mouse->name, "DEC VSXXX-AA/GA mouse");
+ break;
+
+ case 0x04:
+ sprintf (mouse->name, "DEC VSXXX-AB digitizer");
+ break;
+
+ default:
+ sprintf (mouse->name, "unknown DEC pointer device");
+ break;
}

- printk (KERN_INFO "Found %s version 0x%x from country 0x%x "
- "on port %s\n", devtype, mouse->version,
- mouse->country, mouse->dev.phys);
+ printk (KERN_INFO "Found %s version 0x%02x from country 0x%02x "
+ "on port %s\n", mouse->name, mouse->version,
+ mouse->country, mouse->phys);
}

/*
@@ -216,7 +224,7 @@
* 0, bit 4 of byte 0 is direction.
*/
dx = buf[1] & 0x7f;
- dx *= ((buf[0] >> 4) & 0x01)? -1: 1;
+ dx *= ((buf[0] >> 4) & 0x01)? 1: -1;

/*
* Low 7 bit of byte 2 are abs(dy), bit 7 is
@@ -236,7 +244,7 @@
vsxxxaa_drop_bytes (mouse, 3);

DBG (KERN_INFO "%s on %s: dx=%d, dy=%d, buttons=%s%s%s\n",
- mouse->dev.name, mouse->dev.phys, dx, dy,
+ mouse->name, mouse->phys, dx, dy,
left? "L": "l", middle? "M": "m", right? "R": "r");

/*
@@ -246,6 +254,7 @@
input_report_key (dev, BTN_LEFT, left);
input_report_key (dev, BTN_MIDDLE, middle);
input_report_key (dev, BTN_RIGHT, right);
+ input_report_key (dev, BTN_TOUCH, 0);
input_report_rel (dev, REL_X, dx);
input_report_rel (dev, REL_Y, dy);
input_sync (dev);
@@ -256,7 +265,7 @@
{
struct input_dev *dev = &mouse->dev;
unsigned char *buf = mouse->buf;
- int left, middle, right, extra;
+ int left, middle, right, touch;
int x, y;

/*
@@ -270,10 +279,12 @@
*/

/*
- * Get X/Y position
+ * Get X/Y position. Y axis needs to be inverted since VSXXX-AB
+ * counts down->top while monitor counts top->bottom.
*/
x = ((buf[2] & 0x3f) << 6) | (buf[1] & 0x3f);
y = ((buf[4] & 0x3f) << 6) | (buf[3] & 0x3f);
+ y = 1023 - y;

/*
* Get button state. It's bits <4..1> of byte 0.
@@ -281,14 +292,14 @@
left = (buf[0] & 0x02)? 1: 0;
middle = (buf[0] & 0x04)? 1: 0;
right = (buf[0] & 0x08)? 1: 0;
- extra = (buf[0] & 0x10)? 1: 0;
+ touch = (buf[0] & 0x10)? 1: 0;

vsxxxaa_drop_bytes (mouse, 5);

DBG (KERN_INFO "%s on %s: x=%d, y=%d, buttons=%s%s%s%s\n",
- mouse->dev.name, mouse->dev.phys, x, y,
+ mouse->name, mouse->phys, x, y,
left? "L": "l", middle? "M": "m",
- right? "R": "r", extra? "E": "e");
+ right? "R": "r", touch? "T": "t");

/*
* Report what we've found so far...
@@ -297,7 +308,7 @@
input_report_key (dev, BTN_LEFT, left);
input_report_key (dev, BTN_MIDDLE, middle);
input_report_key (dev, BTN_RIGHT, right);
- input_report_key (dev, BTN_EXTRA, extra);
+ input_report_key (dev, BTN_TOUCH, touch);
input_report_abs (dev, ABS_X, x);
input_report_abs (dev, ABS_Y, y);
input_sync (dev);
@@ -334,7 +345,7 @@

mouse->version = buf[0] & 0x0f;
mouse->country = (buf[1] >> 4) & 0x07;
- mouse->type = buf[1] & 0x07;
+ mouse->type = buf[1] & 0x0f;
error = buf[2] & 0x7f;

/*
@@ -347,7 +358,7 @@
right = (buf[0] & 0x01)? 1: 0;

vsxxxaa_drop_bytes (mouse, 4);
- vsxxxaa_report_mouse (mouse);
+ vsxxxaa_detection_done (mouse);

if (error <= 0x1f) {
/* No error. Report buttons */
@@ -355,20 +366,22 @@
input_report_key (dev, BTN_LEFT, left);
input_report_key (dev, BTN_MIDDLE, middle);
input_report_key (dev, BTN_RIGHT, right);
+ input_report_key (dev, BTN_TOUCH, 0);
input_sync (dev);
} else {
printk (KERN_ERR "Your %s on %s reports an undefined error, "
- "please check it...\n", mouse->dev.name,
- mouse->dev.phys);
+ "please check it...\n", mouse->name,
+ mouse->phys);
}

/*
- * If the mouse was hot-plugged, we need to
- * force differential mode now...
+ * If the mouse was hot-plugged, we need to force differential mode
+ * now... However, give it a second to recover from it's reset.
*/
printk (KERN_NOTICE "%s on %s: Forceing standard packet format and "
- "streaming mode\n", mouse->dev.name, mouse->dev.phys);
+ "streaming mode\n", mouse->name, mouse->phys);
mouse->serio->write (mouse->serio, 'S');
+ mdelay (50);
mouse->serio->write (mouse->serio, 'R');
}

@@ -392,7 +405,7 @@
while (mouse->count > 0 && !IS_HDR_BYTE(buf[0])) {
printk (KERN_ERR "%s on %s: Dropping a byte to regain "
"sync with mouse data stream...\n",
- mouse->dev.name, mouse->dev.phys);
+ mouse->name, mouse->phys);
vsxxxaa_drop_bytes (mouse, 1);
}

@@ -475,7 +488,6 @@

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

@@ -486,14 +498,15 @@

init_input_dev (&mouse->dev);
set_bit (EV_KEY, mouse->dev.evbit); /* We have buttons */
- set_bit (EV_REL, mouse->dev.evbit); /* We can move */
+ set_bit (EV_REL, mouse->dev.evbit);
+ set_bit (EV_ABS, mouse->dev.evbit);
set_bit (BTN_LEFT, mouse->dev.keybit); /* We have 3 buttons */
set_bit (BTN_MIDDLE, mouse->dev.keybit);
set_bit (BTN_RIGHT, mouse->dev.keybit);
- set_bit (BTN_EXTRA, mouse->dev.keybit); /* ...and Tablet */
- set_bit (REL_X, mouse->dev.relbit); /* We can move in */
- set_bit (REL_Y, mouse->dev.relbit); /* two dimensions */
- set_bit (ABS_X, mouse->dev.absbit); /* DEC tablet support */
+ set_bit (BTN_TOUCH, mouse->dev.keybit); /* ...and Tablet */
+ set_bit (REL_X, mouse->dev.relbit);
+ set_bit (REL_Y, mouse->dev.relbit);
+ set_bit (ABS_X, mouse->dev.absbit);
set_bit (ABS_Y, mouse->dev.absbit);

mouse->dev.absmin[ABS_X] = 0;
@@ -504,9 +517,10 @@
mouse->dev.private = mouse;
serio->private = mouse;

+ sprintf (mouse->name, "DEC VSXXX-AA/GA mouse or VSXXX-AB digitizer");
sprintf (mouse->phys, "%s/input0", serio->phys);
+ mouse->dev.name = mouse->name;
mouse->dev.phys = mouse->phys;
- mouse->dev.name = "DEC VSXXX-AA/GA mouse or DEC tablet";
mouse->dev.id.bustype = BUS_RS232;
mouse->serio = serio;

@@ -516,20 +530,20 @@
}

/*
- * Request selftest and differential stream mode.
+ * Request selftest. Standard packet format and differential
+ * mode will be requested after the device ID'ed successfully.
*/
mouse->serio->write (mouse->serio, 'T'); /* Test */
- mouse->serio->write (mouse->serio, 'R'); /* Differential stream */

input_register_device (&mouse->dev);

- printk (KERN_INFO "input: %s on %s\n", mouse->dev.name, serio->phys);
+ printk (KERN_INFO "input: %s on %s\n", mouse->name, mouse->phys);
}

static struct serio_dev vsxxxaa_dev = {
- .interrupt = vsxxxaa_interrupt,
- .connect = vsxxxaa_connect,
- .disconnect = vsxxxaa_disconnect
+ .connect = vsxxxaa_connect,
+ .interrupt = vsxxxaa_interrupt,
+ .disconnect = vsxxxaa_disconnect,
};

int __init
Index: linux-2.6.6-rc2/drivers/input/mouse/Kconfig
===================================================================
--- linux-2.6.6-rc2.orig/drivers/input/mouse/Kconfig 2004-04-04 05:37:45.000000000 +0200
+++ linux-2.6.6-rc2/drivers/input/mouse/Kconfig 2004-04-21 14:27:03.000000000 +0200
@@ -119,7 +119,7 @@
module will be called rpcmouse.

config MOUSE_VSXXXAA
- tristate "DEC VSXXX-AA/GA mouse and tablet"
+ tristate "DEC VSXXX-AA/GA mouse and VSXXX-AB tablet"
depends on INPUT && INPUT_MOUSE
select SERIO
help

MfG, JBG

--
Jan-Benedict Glaw [email protected] . +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));


Attachments:
(No filename) (11.37 kB)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-04-21 14:13:15

by Giuseppe Bilotta

[permalink] [raw]
Subject: Re: [PATCH 6/15] New set of input patches: atkbd soften accusation

Dmitry Torokhov wrote:
> + printk(KERN_WARNING "atkbd.c: Unknown key %s "
> + "(%s set %d, code %#x on %s).\n",
> + atkbd->release ? "released" : "pressed",
> + atkbd->translated ? "translated" : "raw",
> + atkbd->set, code, serio->phys);
> + printk(KERN_WARNING "atkbd.c: Use 'setkeycodes %s%02x <keycode>' "
> + "to make it known.\n",
> + code & 0x80 ? "e0" : "", code & 0x7f);

By the way, until the atkbd.c / keyboard.c interaction is fixed, using setkeycodes might
*not* make the keys known *properly*. (example: try setkeycodes e001 129: you'll notice
that a key whose raw code is 0x81 will not produce keycode 129, because the raw mode
emulation will actually turn the 0x81 in a 0x85.)

(See also the temporary patch I posted recently).

--
Giuseppe "Oblomov" Bilotta

Can't you see
It all makes perfect sense
Expressed in dollar and cents
Pounds shillings and pence
(Roger Waters)

2004-04-22 06:43:25

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 16/15] New set of input patches: serio whitespace

On Wednesday 21 April 2004 12:49 am, Dmitry Torokhov wrote:
> Hi,
>
> Here is a new set of my input patches, would love to hear comments and/or
> suggestions. The patches can also be found at:
>
I have 2 more:

01-serio-whitespace.patch
02-setop-openclose-optional.patch
- make open and close methods optional so drivers are not forced to supply
stubs.

--
Dmitry


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


[email protected], 2004-04-21 18:28:43-05:00, [email protected]
Input: serio trailing whitespace fixes


serio.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)


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



diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c Thu Apr 22 01:17:33 2004
+++ b/drivers/input/serio/serio.c Thu Apr 22 01:17:33 2004
@@ -11,18 +11,18 @@
/*
* 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
* e-mail - mail your message to <[email protected]>, or by paper mail:
* Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
@@ -108,7 +108,7 @@
struct serio_event *event;

list_for_each_safe(node, next, &serio_event_list) {
- event = container_of(node, struct serio_event, node);
+ event = container_of(node, struct serio_event, node);

down(&serio_sem);
if (event->serio == NULL)
@@ -152,7 +152,7 @@

do {
serio_handle_events();
- wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
+ wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
if (current->flags & PF_FREEZE)
refrigerator(PF_FREEZE);
} while (!signal_pending(current));

2004-04-22 06:56:59

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 17/15] New set of input patches: serio open/close optional


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


[email protected], 2004-04-22 01:55:04-05:00, [email protected]
Input: make open and close serio methods optional


mouse/lbtouch.c | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
mouse/lbtouch.h | 16 ++++
mouse/synaptics.c | 11 --
serio/parkbd.c | 11 --
serio/q40kbd.c | 11 --
serio/serio.c | 5 -
serio/serport.c | 10 --
7 files changed, 224 insertions(+), 43 deletions(-)


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



diff -Nru a/drivers/input/mouse/lbtouch.c b/drivers/input/mouse/lbtouch.c
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/input/mouse/lbtouch.c Thu Apr 22 01:55:34 2004
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2004 Dmitry Torokhov <[email protected]>
+ */
+
+/*
+ * Lifebook touchscreen driver for Linux
+ */
+
+/*
+ * 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
+ * (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
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/input.h>
+#include <linux/serio.h>
+
+#include "psmouse.h"
+#include "lbtouch.h"
+
+MODULE_AUTHOR("Dmitry Torokhov <[email protected]>");
+MODULE_DESCRIPTION("Fujitsu Lifebook touchscreen driver");
+MODULE_LICENSE("GPL");
+
+/* The default values are taken from Kenan Esau's driver */
+static int limits[4] = { 86, 955, 37, 937 };
+static int num_limits __initdata = 0;
+module_param_array_named(lbt_size, limits, int, num_limits, 0);
+MODULE_PARM_DESC(lbt_size, "Effective usable area of Lifebook touchscreen (left,right,bottom,up)");
+
+
+/*****************************************************************************
+ * Lifebook pass-through PS/2 port support
+ ****************************************************************************/
+static int lbtouch_pt_write(struct serio *port, unsigned char c)
+{
+ switch (c) {
+ case PSMOUSE_CMD_RESET_BAT & 0xff:
+ serio_interrupt(port, PSMOUSE_RET_ACK, 0, NULL);
+ serio_interrupt(port, PSMOUSE_RET_BAT, 0, NULL);
+ serio_interrupt(port, PSMOUSE_RET_ID, 0, NULL);
+ break;
+
+ case PSMOUSE_CMD_GETID & 0xff:
+ serio_interrupt(port, PSMOUSE_RET_ACK, 0, NULL);
+ serio_interrupt(port, 0x00, 0, NULL);
+ break;
+
+ case PSMOUSE_CMD_ENABLE & 0xff:
+ case PSMOUSE_CMD_RESET_DIS & 0xff:
+ serio_interrupt(port, PSMOUSE_RET_ACK, 0, NULL);
+ break;
+
+ default:
+ serio_interrupt(port, PSMOUSE_RET_NAK, 0, NULL);
+ break;
+ }
+
+ return 0;
+}
+
+static void lbtouch_pass_pt_packet(struct serio *ptport, unsigned char *packet)
+{
+ struct psmouse *child = ptport->private;
+
+ if (child && child->state == PSMOUSE_ACTIVATED) {
+ serio_interrupt(ptport, packet[0], 0, NULL);
+ serio_interrupt(ptport, packet[1], 0, NULL);
+ serio_interrupt(ptport, packet[2], 0, NULL);
+ }
+}
+
+static void lbtouch_pt_create(struct psmouse *psmouse)
+{
+ struct psmouse_ptport *port;
+
+ psmouse->ptport = port = kmalloc(sizeof(struct psmouse_ptport), GFP_KERNEL);
+ if (!port) {
+ printk(KERN_ERR "lbtouch: not enough memory to allocate pass-through port\n");
+ return;
+ }
+
+ memset(port, 0, sizeof(struct psmouse_ptport));
+
+ port->serio.type = SERIO_PS_PSTHRU;
+ port->serio.name = "Lifebook pass-through";
+ port->serio.phys = "lbtouch-pt/serio0";
+ port->serio.write = lbtouch_pt_write;
+ port->serio.driver = psmouse;
+}
+
+/*****************************************************************************
+ * Functions to interpret the absolute mode packets
+ ****************************************************************************/
+
+static psmouse_ret_t lbtouch_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
+{
+ struct input_dev *dev = &psmouse->dev;
+ unsigned char *p = psmouse->packet;
+ int x, y, touch;
+
+ input_regs(dev, regs);
+
+ if (psmouse->pktcnt < 3)
+ return PSMOUSE_GOOD_DATA;
+
+ if (p[0] & 0x80) {
+ x = ((unsigned int)(p[0] & 0x30) << 4) + p[1];
+ y = ((unsigned int)(p[0] & 0xc0) << 2) + p[2];
+ touch = p[0] & 0x04 ? 1 : 0;
+
+ input_report_key(dev, BTN_TOUCH, touch);
+ if (touch) {
+ input_report_abs(dev, ABS_X, x - limits[0]);
+ input_report_abs(dev, ABS_Y, limits[3] + limits[3] - y);
+ }
+
+ if ((p[0] &= 0x03) != 0 && psmouse->ptport && psmouse->ptport->serio.dev) {
+ p[1] = p[2] = 0;
+ lbtouch_pass_pt_packet(&psmouse->ptport->serio, p);
+ }
+ } else if (psmouse->ptport && psmouse->ptport->serio.dev) {
+ lbtouch_pass_pt_packet(&psmouse->ptport->serio, p);
+ }
+
+ return PSMOUSE_FULL_PACKET;
+}
+
+/*****************************************************************************
+ * Driver initialization/cleanup functions
+ ****************************************************************************/
+
+static inline void set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
+{
+ dev->absmin[axis] = min;
+ dev->absmax[axis] = max;
+ dev->absfuzz[axis] = fuzz;
+ dev->absflat[axis] = flat;
+
+ set_bit(axis, dev->absbit);
+}
+
+static void lbtouch_disconnect(struct psmouse *psmouse)
+{
+ unsigned char param[1];
+
+ param[0] = 0x06;
+
+ if (psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES) ||
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE) ||
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE) ||
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE))
+ printk(KERN_WARNING "lbtouch.c: Failed to restore touchscreen PS/2 emulation\n");
+}
+
+int lbtouch_init(struct psmouse *psmouse, int set_properties)
+{
+ unsigned char param[1];
+
+ if (psmouse->serio->type != SERIO_8042)
+ return 0;
+
+ param[0] = 0x07;
+ if (psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES) ||
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE) ||
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE) ||
+ psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE)) {
+ printk(KERN_ERR "lbtouch.c: Failed to enable touchscreen native mode\n");
+ return 0;
+ }
+
+ if (set_properties) {
+ set_bit(EV_ABS, psmouse->dev.evbit);
+ set_abs_params(&psmouse->dev, ABS_X, limits[0], limits[1], 0, 0);
+ set_abs_params(&psmouse->dev, ABS_Y, limits[2], limits[3], 0, 0);
+
+ set_bit(EV_KEY, psmouse->dev.evbit);
+ set_bit(BTN_TOUCH, psmouse->dev.keybit);
+
+ clear_bit(EV_REL, psmouse->dev.evbit);
+ clear_bit(REL_X, psmouse->dev.relbit);
+ clear_bit(REL_Y, psmouse->dev.relbit);
+
+ psmouse->protocol_handler = lbtouch_process_byte;
+ psmouse->disconnect = lbtouch_disconnect;
+
+ lbtouch_pt_create(psmouse);
+ }
+
+ return 1;
+}
diff -Nru a/drivers/input/mouse/lbtouch.h b/drivers/input/mouse/lbtouch.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/input/mouse/lbtouch.h Thu Apr 22 01:55:34 2004
@@ -0,0 +1,16 @@
+/*
+ * Fujistsu Lifebook PS/2 touchscreen driver header
+ *
+ * Copyright (c) 2004 Dmitry Torokhov <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef _LBTOUCH_H
+#define _LBTOUCH_H
+
+int lbtouch_init(struct psmouse *psmouse, int set_properties);
+
+#endif
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c Thu Apr 22 01:55:34 2004
+++ b/drivers/input/mouse/synaptics.c Thu Apr 22 01:55:34 2004
@@ -212,15 +212,6 @@
/*****************************************************************************
* Synaptics pass-through PS/2 port support
****************************************************************************/
-static int synaptics_pt_open(struct serio *port)
-{
- return 0;
-}
-
-static void synaptics_pt_close(struct serio *port)
-{
-}
-
static int synaptics_pt_write(struct serio *port, unsigned char c)
{
struct psmouse *parent = port->driver;
@@ -282,8 +273,6 @@
port->serio.name = "Synaptics pass-through";
port->serio.phys = "synaptics-pt/serio0";
port->serio.write = synaptics_pt_write;
- port->serio.open = synaptics_pt_open;
- port->serio.close = synaptics_pt_close;
port->serio.driver = psmouse;

port->activate = synaptics_pt_activate;
diff -Nru a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c
--- a/drivers/input/serio/parkbd.c Thu Apr 22 01:55:34 2004
+++ b/drivers/input/serio/parkbd.c Thu Apr 22 01:55:34 2004
@@ -86,20 +86,9 @@
return 0;
}

-static int parkbd_open(struct serio *port)
-{
- return 0;
-}
-
-static void parkbd_close(struct serio *port)
-{
-}
-
static struct serio parkbd_port =
{
.write = parkbd_write,
- .open = parkbd_open,
- .close = parkbd_close,
.name = parkbd_name,
.phys = parkbd_phys,
};
diff -Nru a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c
--- a/drivers/input/serio/q40kbd.c Thu Apr 22 01:55:34 2004
+++ b/drivers/input/serio/q40kbd.c Thu Apr 22 01:55:34 2004
@@ -47,23 +47,12 @@
MODULE_DESCRIPTION("Q40 PS/2 keyboard controller driver");
MODULE_LICENSE("GPL");

-
-static int q40kbd_open(struct serio *port)
-{
- return 0;
-}
-static void q40kbd_close(struct serio *port)
-{
-}
-
static struct serio q40kbd_port =
{
.type = SERIO_8042,
.name = "Q40 kbd port",
.phys = "Q40",
.write = NULL,
- .open = q40kbd_open,
- .close = q40kbd_close,
};

static irqreturn_t q40kbd_interrupt(int irq, void *dev_id,
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c Thu Apr 22 01:55:34 2004
+++ b/drivers/input/serio/serio.c Thu Apr 22 01:55:34 2004
@@ -293,7 +293,7 @@
int serio_open(struct serio *serio, struct serio_dev *dev)
{
serio->dev = dev;
- if (serio->open(serio)) {
+ if (serio->open && serio->open(serio)) {
serio->dev = NULL;
return -1;
}
@@ -303,7 +303,8 @@
/* called from serio_dev->connect/disconnect methods under serio_sem */
void serio_close(struct serio *serio)
{
- serio->close(serio);
+ if (serio->close)
+ serio->close(serio);
serio->dev = NULL;
}

diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c Thu Apr 22 01:55:34 2004
+++ b/drivers/input/serio/serport.c Thu Apr 22 01:55:34 2004
@@ -48,11 +48,6 @@
return -(serport->tty->driver->write(serport->tty, 0, &data, 1) != 1);
}

-static int serport_serio_open(struct serio *serio)
-{
- return 0;
-}
-
static void serport_serio_close(struct serio *serio)
{
struct serport *serport = serio->driver;
@@ -87,7 +82,6 @@

serport->serio.type = SERIO_RS232;
serport->serio.write = serport_serio_write;
- serport->serio.open = serport_serio_open;
serport->serio.close = serport_serio_close;
serport->serio.driver = serport;

@@ -135,7 +129,7 @@
}

/*
- * serport_ldisc_read() just waits indefinitely if everything goes well.
+ * serport_ldisc_read() just waits indefinitely if everything goes well.
* However, when the serio driver closes the serio port, it finishes,
* returning 0 characters.
*/
@@ -165,7 +159,7 @@
static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsigned int cmd, unsigned long arg)
{
struct serport *serport = (struct serport*) tty->disc_data;
-
+
if (cmd == SPIOCSTYPE)
return get_user(serport->serio.type, (unsigned long *) arg);

2004-04-22 07:37:22

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: [PATCH 8/15] New set of input patches: atkbd - use bitfields

On Wed, Apr 21, 2004 at 12:57:51AM -0500, Dmitry Torokhov wrote:
>
> ===================================================================
>
>
> [email protected], 2004-04-20 22:29:12-05:00, [email protected]
> Input: remove unneeded fields in atkbd structure, convert to bitfields

I think this is incorrect. We cannot set the bits in bitfields
atomically, which we need in some cases. We probably need to add
volatiles to some of them, too.


> diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
> --- a/drivers/input/keyboard/atkbd.c Tue Apr 20 23:08:14 2004
> +++ b/drivers/input/keyboard/atkbd.c Tue Apr 20 23:08:14 2004
> @@ -26,7 +26,6 @@
> #include <linux/input.h>
> #include <linux/serio.h>
> #include <linux/workqueue.h>
> -#include <linux/timer.h>
>
> MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
> MODULE_DESCRIPTION("AT and PS/2 keyboard driver");
> @@ -173,22 +172,23 @@
> unsigned char keycode[512];
> struct input_dev dev;
> struct serio *serio;
> - struct timer_list timer;
> +
> char name[64];
> char phys[32];
> + unsigned short id;
> + unsigned char set;
> + unsigned int translated:1;
> + unsigned int extra:1;
> + unsigned int write:1;
> +
> unsigned char cmdbuf[4];
> unsigned char cmdcnt;
> - unsigned char set;
> - unsigned char extra;
> - unsigned char release;
> - int lastkey;
> volatile signed char ack;
> unsigned char emul;
> - unsigned short id;
> - unsigned char write;
> - unsigned char translated;
> - unsigned char resend;
> - unsigned char bat_xl;
> + unsigned int resend:1;
> + unsigned int release:1;
> + unsigned int bat_xl:1;
> +
> unsigned int last;
> unsigned long time;
> };
>

--
Vojtech Pavlik
SuSE Labs, SuSE CR

2004-04-22 07:37:23

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: [PATCH 9/15] New set of input patches: atkbd timeout complaints

On Wed, Apr 21, 2004 at 12:58:42AM -0500, Dmitry Torokhov wrote:
>
> ===================================================================
>
>
> [email protected], 2004-04-20 22:32:46-05:00, [email protected]
> Input: Do not generate events from atkbd until keyboard is completely
> initialized. It should suppress messages about suprious NAKs
> when controller's timeout is longer than one in atkbd

We may need to protect ourselves against this - it may confuse the probe
in addition to just generating spurious messages.

>
>
> atkbd.c | 6 ++++++
> 1 files changed, 6 insertions(+)
>
>
> ===================================================================
>
>
>
> diff -Nru a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
> --- a/drivers/input/keyboard/atkbd.c Tue Apr 20 23:09:40 2004
> +++ b/drivers/input/keyboard/atkbd.c Tue Apr 20 23:09:40 2004
> @@ -188,6 +188,7 @@
> unsigned int resend:1;
> unsigned int release:1;
> unsigned int bat_xl:1;
> + unsigned int enabled:1;
>
> unsigned int last;
> unsigned long time;
> @@ -248,6 +249,9 @@
> goto out;
> }
>
> + if (!atkbd->enabled)
> + goto out;
> +
> if (atkbd->translated) {
>
> if (atkbd->emul ||
> @@ -749,6 +753,8 @@
> atkbd->set = 2;
> atkbd->id = 0xab00;
> }
> +
> + atkbd->enabled = 1;
>
> if (atkbd->extra) {
> atkbd->dev.ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) | BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC);
>

--
Vojtech Pavlik
SuSE Labs, SuSE CR

2004-04-22 07:40:58

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 17/15] New set of input patches: serio open/close optional

Extra stuff slipped into the previous patch, this one better...


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


[email protected], 2004-04-22 02:26:37-05:00, [email protected]
Input: make serio open and close methods optional


mouse/synaptics.c | 11 -----------
serio/parkbd.c | 11 -----------
serio/q40kbd.c | 11 -----------
serio/serio.c | 5 +++--
serio/serport.c | 10 ++--------
5 files changed, 5 insertions(+), 43 deletions(-)


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



diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c Thu Apr 22 02:27:22 2004
+++ b/drivers/input/mouse/synaptics.c Thu Apr 22 02:27:22 2004
@@ -212,15 +212,6 @@
/*****************************************************************************
* Synaptics pass-through PS/2 port support
****************************************************************************/
-static int synaptics_pt_open(struct serio *port)
-{
- return 0;
-}
-
-static void synaptics_pt_close(struct serio *port)
-{
-}
-
static int synaptics_pt_write(struct serio *port, unsigned char c)
{
struct psmouse *parent = port->driver;
@@ -282,8 +273,6 @@
port->serio.name = "Synaptics pass-through";
port->serio.phys = "synaptics-pt/serio0";
port->serio.write = synaptics_pt_write;
- port->serio.open = synaptics_pt_open;
- port->serio.close = synaptics_pt_close;
port->serio.driver = psmouse;

port->activate = synaptics_pt_activate;
diff -Nru a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c
--- a/drivers/input/serio/parkbd.c Thu Apr 22 02:27:22 2004
+++ b/drivers/input/serio/parkbd.c Thu Apr 22 02:27:22 2004
@@ -86,20 +86,9 @@
return 0;
}

-static int parkbd_open(struct serio *port)
-{
- return 0;
-}
-
-static void parkbd_close(struct serio *port)
-{
-}
-
static struct serio parkbd_port =
{
.write = parkbd_write,
- .open = parkbd_open,
- .close = parkbd_close,
.name = parkbd_name,
.phys = parkbd_phys,
};
diff -Nru a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c
--- a/drivers/input/serio/q40kbd.c Thu Apr 22 02:27:22 2004
+++ b/drivers/input/serio/q40kbd.c Thu Apr 22 02:27:22 2004
@@ -47,23 +47,12 @@
MODULE_DESCRIPTION("Q40 PS/2 keyboard controller driver");
MODULE_LICENSE("GPL");

-
-static int q40kbd_open(struct serio *port)
-{
- return 0;
-}
-static void q40kbd_close(struct serio *port)
-{
-}
-
static struct serio q40kbd_port =
{
.type = SERIO_8042,
.name = "Q40 kbd port",
.phys = "Q40",
.write = NULL,
- .open = q40kbd_open,
- .close = q40kbd_close,
};

static irqreturn_t q40kbd_interrupt(int irq, void *dev_id,
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c Thu Apr 22 02:27:22 2004
+++ b/drivers/input/serio/serio.c Thu Apr 22 02:27:22 2004
@@ -293,7 +293,7 @@
int serio_open(struct serio *serio, struct serio_dev *dev)
{
serio->dev = dev;
- if (serio->open(serio)) {
+ if (serio->open && serio->open(serio)) {
serio->dev = NULL;
return -1;
}
@@ -303,7 +303,8 @@
/* called from serio_dev->connect/disconnect methods under serio_sem */
void serio_close(struct serio *serio)
{
- serio->close(serio);
+ if (serio->close)
+ serio->close(serio);
serio->dev = NULL;
}

diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
--- a/drivers/input/serio/serport.c Thu Apr 22 02:27:22 2004
+++ b/drivers/input/serio/serport.c Thu Apr 22 02:27:22 2004
@@ -48,11 +48,6 @@
return -(serport->tty->driver->write(serport->tty, 0, &data, 1) != 1);
}

-static int serport_serio_open(struct serio *serio)
-{
- return 0;
-}
-
static void serport_serio_close(struct serio *serio)
{
struct serport *serport = serio->driver;
@@ -87,7 +82,6 @@

serport->serio.type = SERIO_RS232;
serport->serio.write = serport_serio_write;
- serport->serio.open = serport_serio_open;
serport->serio.close = serport_serio_close;
serport->serio.driver = serport;

@@ -135,7 +129,7 @@
}

/*
- * serport_ldisc_read() just waits indefinitely if everything goes well.
+ * serport_ldisc_read() just waits indefinitely if everything goes well.
* However, when the serio driver closes the serio port, it finishes,
* returning 0 characters.
*/
@@ -165,7 +159,7 @@
static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsigned int cmd, unsigned long arg)
{
struct serport *serport = (struct serport*) tty->disc_data;
-
+
if (cmd == SPIOCSTYPE)
return get_user(serport->serio.type, (unsigned long *) arg);

2004-04-22 07:45:37

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 9/15] New set of input patches: atkbd timeout complaints

On Thursday 22 April 2004 02:32 am, Vojtech Pavlik wrote:
> On Wed, Apr 21, 2004 at 12:58:42AM -0500, Dmitry Torokhov wrote:
> >
> > ===================================================================
> >
> >
> > [email protected], 2004-04-20 22:32:46-05:00, [email protected]
> > Input: Do not generate events from atkbd until keyboard is completely
> > initialized. It should suppress messages about suprious NAKs
> > when controller's timeout is longer than one in atkbd
>
> We may need to protect ourselves against this - it may confuse the probe
> in addition to just generating spurious messages.
>

Hmm.. you were against extending timeout in atkbd_command as it would prolong
probing. It should not interfere with probing as we only kill data when we not
expecting a response to a command.

--
Dmitry

2004-04-22 07:44:16

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 8/15] New set of input patches: atkbd - use bitfields

On Thursday 22 April 2004 02:31 am, Vojtech Pavlik wrote:
> On Wed, Apr 21, 2004 at 12:57:51AM -0500, Dmitry Torokhov wrote:
> >
> > ===================================================================
> >
> >
> > [email protected], 2004-04-20 22:29:12-05:00, [email protected]
> > Input: remove unneeded fields in atkbd structure, convert to bitfields
>
> I think this is incorrect. We cannot set the bits in bitfields
> atomically, which we need in some cases. We probably need to add
> volatiles to some of them, too.
>
>

I don't think we have a problem with concurrent access here... One group is set
exclusively in atkbd_interrupt, other one is pretty mich static.

--
Dmitry

2004-04-22 07:49:07

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: [PATCH 4/15] New set of input patches: lkkbd whitespace

On Wed, Apr 21, 2004 at 12:52:25AM -0500, Dmitry Torokhov wrote:
>
> ===================================================================
>
>
> [email protected], 2004-04-20 22:25:18-05:00, [email protected]
> Input: fix spelling and trailing whitespaces in lkkbd
>
>
> lkkbd.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
>
> ===================================================================
>
>
>
> 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're fixing typos, you should also fix the DISCLAUNER. ;)

> - * information given below, I will _not_ be lieable!
> + * information given below, I will _not_ be liable!
> *
> * RJ11 pinout: To DB9: Or DB25:
> * 1 - RxD <----> Pin 3 (TxD) <-> Pin 2 (TxD)
> @@ -39,18 +39,18 @@
> /*
> * 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.

--
Vojtech Pavlik
SuSE Labs, SuSE CR

2004-04-22 07:58:48

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: [PATCH 8/15] New set of input patches: atkbd - use bitfields

On Thu, Apr 22, 2004 at 02:41:11AM -0500, Dmitry Torokhov wrote:
> On Thursday 22 April 2004 02:31 am, Vojtech Pavlik wrote:
> > On Wed, Apr 21, 2004 at 12:57:51AM -0500, Dmitry Torokhov wrote:
> > >
> > > ===================================================================
> > >
> > >
> > > [email protected], 2004-04-20 22:29:12-05:00, [email protected]
> > > Input: remove unneeded fields in atkbd structure, convert to bitfields
> >
> > I think this is incorrect. We cannot set the bits in bitfields
> > atomically, which we need in some cases. We probably need to add
> > volatiles to some of them, too.
> >
> >
>
> I don't think we have a problem with concurrent access here... One group is set
> exclusively in atkbd_interrupt, other one is pretty mich static.

Ok, then. I'll check them one by one anyway.

--
Vojtech Pavlik
SuSE Labs, SuSE CR

2004-04-25 06:53:23

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 8/15] New set of input patches: atkbd - use bitfields

Hi!

> >
> > [email protected], 2004-04-20 22:29:12-05:00, [email protected]
> > Input: remove unneeded fields in atkbd structure, convert to bitfields
>
> I think this is incorrect. We cannot set the bits in bitfields
> atomically, which we need in some cases. We probably need to add
> volatiles to some of them, too.

If you need volatile in the driver, then the driver is probably buggy.
Pavel
--
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms