mousedev_packet() incorrectly clears list->ready when called with
"tail == head - 1". The effect is that the last mouse event from the
hardware isn't reported to user space until another hardware mouse
event arrives. This can make the left mouse button get stuck when
tapping on a touchpad. When this happens, the button doesn't unstick
until the next time you interact with the touchpad.
Signed-off-by: Peter Osterlund <[email protected]>
---
linux-petero/drivers/input/mousedev.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff -puN drivers/input/mousedev.c~mousedev-ready-fix drivers/input/mousedev.c
--- linux/drivers/input/mousedev.c~mousedev-ready-fix 2005-01-30 03:06:49.000000000 +0100
+++ linux-petero/drivers/input/mousedev.c 2005-01-30 03:06:49.000000000 +0100
@@ -467,10 +467,10 @@ static void mousedev_packet(struct mouse
}
if (!p->dx && !p->dy && !p->dz) {
- if (list->tail != list->head)
- list->tail = (list->tail + 1) % PACKET_QUEUE_LEN;
if (list->tail == list->head)
list->ready = 0;
+ else
+ list->tail = (list->tail + 1) % PACKET_QUEUE_LEN;
}
spin_unlock_irqrestore(&list->packet_lock, flags);
_
--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
When hardware tapping is disabled on an ALPS touchpad, the touchpad
generates exactly the same data for a single tap and a fast double
tap. The effect is that the second tap in the double tap sequence is
lost.
To fix this problem, this patch enables hardware tapping and converts
the resulting tap and gesture bits to standard finger pressure values
(z), which is what mousedev.c and the userspace X driver expects.
Signed-off-by: Peter Osterlund <[email protected]>
---
linux-petero/drivers/input/mouse/alps.c | 53 +++++++++++++++++++++++++-------
linux-petero/drivers/input/mouse/alps.h | 4 ++
2 files changed, 47 insertions(+), 10 deletions(-)
diff -puN drivers/input/mouse/alps.c~alps-hwtaps drivers/input/mouse/alps.c
--- linux/drivers/input/mouse/alps.c~alps-hwtaps 2005-01-30 11:22:30.000000000 +0100
+++ linux-petero/drivers/input/mouse/alps.c 2005-01-30 11:22:30.000000000 +0100
@@ -78,10 +78,12 @@ struct alps_model_info {
static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs)
{
+ struct alps_data *priv = psmouse->private;
unsigned char *packet = psmouse->packet;
struct input_dev *dev = &psmouse->dev;
int x, y, z;
int left = 0, right = 0, middle = 0;
+ int ges, fin;
input_regs(dev, regs);
@@ -123,6 +125,27 @@ static void alps_process_packet(struct p
return;
}
+ ges = packet[2] & 1; /* gesture bit */
+ fin = packet[2] & 2; /* finger bit */
+
+ /* Convert hardware tap to a reasonable Z value */
+ if (ges && !fin)
+ z = 40;
+
+ /*
+ * A "tap and drag" operation is reported by the hardware as a transition
+ * from (!fin && ges) to (fin && ges). This should be translated to the
+ * sequence Z>0, Z==0, Z>0, so the Z==0 event has to be generated manually.
+ */
+ if (ges && fin && !priv->prev_fin) {
+ input_report_abs(dev, ABS_X, x);
+ input_report_abs(dev, ABS_Y, y);
+ input_report_abs(dev, ABS_PRESSURE, 0);
+ input_report_key(dev, BTN_TOOL_FINGER, 0);
+ input_sync(dev);
+ }
+ priv->prev_fin = fin;
+
if (z > 30) input_report_key(dev, BTN_TOUCH, 1);
if (z < 25) input_report_key(dev, BTN_TOUCH, 0);
@@ -133,7 +156,6 @@ static void alps_process_packet(struct p
input_report_abs(dev, ABS_PRESSURE, z);
input_report_key(dev, BTN_TOOL_FINGER, z > 0);
- left |= (packet[2] ) & 1;
left |= (packet[3] ) & 1;
right |= (packet[3] >> 1) & 1;
if (packet[0] == 0xff) {
@@ -335,7 +357,7 @@ static int alps_reconnect(struct psmouse
return -1;
if (param[0] & 0x04)
- alps_tap_mode(psmouse, 0);
+ alps_tap_mode(psmouse, 1);
if (alps_absolute_mode(psmouse)) {
printk(KERN_ERR "alps.c: Failed to enable absolute mode\n");
@@ -351,40 +373,47 @@ static int alps_reconnect(struct psmouse
static void alps_disconnect(struct psmouse *psmouse)
{
psmouse_reset(psmouse);
+ kfree(psmouse->private);
}
int alps_init(struct psmouse *psmouse)
{
+ struct alps_data *priv;
unsigned char param[4];
int model;
+ psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL);
+ if (!priv)
+ goto init_fail;
+ memset(priv, 0, sizeof(struct alps_data));
+
if ((model = alps_get_model(psmouse)) < 0)
- return -1;
+ goto init_fail;
printk(KERN_INFO "ALPS Touchpad (%s) detected\n",
model == ALPS_MODEL_GLIDEPOINT ? "Glidepoint" : "Dualpoint");
if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
- return -1;
+ goto init_fail;
if (alps_get_status(psmouse, param)) {
printk(KERN_ERR "alps.c: touchpad status report request failed\n");
- return -1;
+ goto init_fail;
}
if (param[0] & 0x04) {
- printk(KERN_INFO " Disabling hardware tapping\n");
- if (alps_tap_mode(psmouse, 0))
- printk(KERN_WARNING "alps.c: Failed to disable hardware tapping\n");
+ printk(KERN_INFO " Enabling hardware tapping\n");
+ if (alps_tap_mode(psmouse, 1))
+ printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n");
}
if (alps_absolute_mode(psmouse)) {
printk(KERN_ERR "alps.c: Failed to enable absolute mode\n");
- return -1;
+ goto init_fail;
}
if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
- return -1;
+ goto init_fail;
psmouse->dev.evbit[LONG(EV_REL)] |= BIT(EV_REL);
psmouse->dev.relbit[LONG(REL_X)] |= BIT(REL_X);
@@ -408,6 +437,10 @@ int alps_init(struct psmouse *psmouse)
psmouse->pktsize = 6;
return 0;
+
+init_fail:
+ kfree(priv);
+ return -1;
}
int alps_detect(struct psmouse *psmouse, int set_properties)
diff -puN drivers/input/mouse/alps.h~alps-hwtaps drivers/input/mouse/alps.h
--- linux/drivers/input/mouse/alps.h~alps-hwtaps 2005-01-30 11:22:30.000000000 +0100
+++ linux-petero/drivers/input/mouse/alps.h 2005-01-30 11:22:30.000000000 +0100
@@ -14,4 +14,8 @@
int alps_detect(struct psmouse *psmouse, int set_properties);
int alps_init(struct psmouse *psmouse);
+struct alps_data {
+ int prev_fin; /* Finger bit from previous packet */
+};
+
#endif
_
--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
Only parse a "z == 127" packet as a relative Dualpoint stick packet if
the touchpad actually is a Dualpoint device. The Glidepoint models
don't have a stick, and can report z == 127 for a very wide finger. If
such a packet is parsed as a stick packet, the mouse pointer will
typically jump to one corner of the screen.
Signed-off-by: Peter Osterlund <[email protected]>
---
linux-petero/drivers/input/mouse/alps.c | 20 ++++++++++----------
linux-petero/drivers/input/mouse/alps.h | 1 +
2 files changed, 11 insertions(+), 10 deletions(-)
diff -puN drivers/input/mouse/alps.c~alps-glidepoint-has-no-stick drivers/input/mouse/alps.c
--- linux/drivers/input/mouse/alps.c~alps-glidepoint-has-no-stick 2005-01-30 11:22:32.000000000 +0100
+++ linux-petero/drivers/input/mouse/alps.c 2005-01-30 11:22:32.000000000 +0100
@@ -109,7 +109,8 @@ static void alps_process_packet(struct p
y = (packet[4] & 0x7f) | ((packet[3] & 0x70)<<(7-4));
z = packet[5];
- if (z == 127) { /* DualPoint stick is relative, not absolute */
+ if ((priv->model == ALPS_MODEL_DUALPOINT) && (z == 127)) {
+ /* DualPoint stick, relative packet */
if (x > 383)
x = x - 768;
if (y > 255)
@@ -344,13 +345,13 @@ static int alps_tap_mode(struct psmouse
static int alps_reconnect(struct psmouse *psmouse)
{
- int model;
+ struct alps_data *priv = psmouse->private;
unsigned char param[4];
- if ((model = alps_get_model(psmouse)) < 0)
+ if ((priv->model = alps_get_model(psmouse)) < 0)
return -1;
- if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
+ if (priv->model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
return -1;
if (alps_get_status(psmouse, param))
@@ -364,7 +365,7 @@ static int alps_reconnect(struct psmouse
return -1;
}
- if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
+ if (priv->model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
return -1;
return 0;
@@ -380,20 +381,19 @@ int alps_init(struct psmouse *psmouse)
{
struct alps_data *priv;
unsigned char param[4];
- int model;
psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL);
if (!priv)
goto init_fail;
memset(priv, 0, sizeof(struct alps_data));
- if ((model = alps_get_model(psmouse)) < 0)
+ if ((priv->model = alps_get_model(psmouse)) < 0)
goto init_fail;
printk(KERN_INFO "ALPS Touchpad (%s) detected\n",
- model == ALPS_MODEL_GLIDEPOINT ? "Glidepoint" : "Dualpoint");
+ priv->model == ALPS_MODEL_GLIDEPOINT ? "Glidepoint" : "Dualpoint");
- if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
+ if (priv->model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
goto init_fail;
if (alps_get_status(psmouse, param)) {
@@ -412,7 +412,7 @@ int alps_init(struct psmouse *psmouse)
goto init_fail;
}
- if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
+ if (priv->model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
goto init_fail;
psmouse->dev.evbit[LONG(EV_REL)] |= BIT(EV_REL);
diff -puN drivers/input/mouse/alps.h~alps-glidepoint-has-no-stick drivers/input/mouse/alps.h
--- linux/drivers/input/mouse/alps.h~alps-glidepoint-has-no-stick 2005-01-30 11:22:32.000000000 +0100
+++ linux-petero/drivers/input/mouse/alps.h 2005-01-30 11:22:32.000000000 +0100
@@ -15,6 +15,7 @@ int alps_detect(struct psmouse *psmouse,
int alps_init(struct psmouse *psmouse);
struct alps_data {
+ int model; /* Glidepoint or Dualpoint */
int prev_fin; /* Finger bit from previous packet */
};
_
--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
Some Synaptics touchpads have a middle mouse button that also works as
a scroll wheel. Scroll data is reported as packets with w == 2 and
the scroll amount in byte 1, treated as a signed character. For some
reason, the smallest possible wheel movement is reported as a scroll
amount of 4 units. This amount is typically spread out over more than
one packet, so the driver has to accumulate scroll delta values to
correctly deal with this.
Signed-off-by: Peter Osterlund <[email protected]>
---
linux-petero/drivers/input/mouse/synaptics.c | 28 +++++++++++++++++++++++++--
linux-petero/drivers/input/mouse/synaptics.h | 2 +
2 files changed, 28 insertions(+), 2 deletions(-)
diff -puN drivers/input/mouse/synaptics.c~synaptics-scroll-wheel drivers/input/mouse/synaptics.c
--- linux/drivers/input/mouse/synaptics.c~synaptics-scroll-wheel 2005-01-30 11:22:34.000000000 +0100
+++ linux-petero/drivers/input/mouse/synaptics.c 2005-01-30 11:22:34.000000000 +0100
@@ -322,8 +322,11 @@ static void synaptics_parse_hw_state(uns
hw->left = (buf[0] & 0x01) ? 1 : 0;
hw->right = (buf[0] & 0x02) ? 1 : 0;
- if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
+ if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
+ if (hw->w == 2)
+ hw->scroll = (signed char)(buf[1]);
+ }
if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
hw->up = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
@@ -379,6 +382,26 @@ static void synaptics_process_packet(str
synaptics_parse_hw_state(psmouse->packet, priv, &hw);
+ if (hw.scroll) {
+ priv->scroll += hw.scroll;
+
+ while (priv->scroll >= 4) {
+ input_report_key(dev, BTN_BACK, !hw.down);
+ input_sync(dev);
+ input_report_key(dev, BTN_BACK, hw.down);
+ input_sync(dev);
+ priv->scroll -= 4;
+ }
+ while (priv->scroll <= -4) {
+ input_report_key(dev, BTN_FORWARD, !hw.up);
+ input_sync(dev);
+ input_report_key(dev, BTN_FORWARD, hw.up);
+ input_sync(dev);
+ priv->scroll += 4;
+ }
+ return;
+ }
+
if (hw.z > 0) {
num_fingers = 1;
finger_width = 5;
@@ -528,7 +551,8 @@ static void set_input_params(struct inpu
if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
set_bit(BTN_MIDDLE, dev->keybit);
- if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
+ if (SYN_CAP_FOUR_BUTTON(priv->capabilities) ||
+ SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
set_bit(BTN_FORWARD, dev->keybit);
set_bit(BTN_BACK, dev->keybit);
}
diff -puN drivers/input/mouse/synaptics.h~synaptics-scroll-wheel drivers/input/mouse/synaptics.h
--- linux/drivers/input/mouse/synaptics.h~synaptics-scroll-wheel 2005-01-30 11:22:34.000000000 +0100
+++ linux-petero/drivers/input/mouse/synaptics.h 2005-01-30 11:22:34.000000000 +0100
@@ -92,6 +92,7 @@ struct synaptics_hw_state {
unsigned int up:1;
unsigned int down:1;
unsigned char ext_buttons;
+ signed char scroll;
};
struct synaptics_data {
@@ -103,6 +104,7 @@ struct synaptics_data {
unsigned char pkt_type; /* packet type - old, new, etc */
unsigned char mode; /* current mode byte */
+ int scroll;
};
#endif /* _SYNAPTICS_H */
_
--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
Peter Osterlund wrote:
> Only parse a "z == 127" packet as a relative Dualpoint stick packet if
> the touchpad actually is a Dualpoint device. The Glidepoint models
> don't have a stick, and can report z == 127 for a very wide finger. If
> such a packet is parsed as a stick packet, the mouse pointer will
> typically jump to one corner of the screen.
I remember reading specs of a touchpad (can't remember if it
was ALPS or Synaptics) (driver) which could do "palm
detection" (basically ignoring events when a large part of the
hand accidentally touched/pressed the pad, FWICS).
--
Giuseppe "Oblomov" Bilotta
Can't you see
It all makes perfect sense
Expressed in dollar and cents
Pounds shillings and pence
(Roger Waters)
Giuseppe Bilotta <[email protected]> writes:
> Peter Osterlund wrote:
> > Only parse a "z == 127" packet as a relative Dualpoint stick packet if
> > the touchpad actually is a Dualpoint device. The Glidepoint models
> > don't have a stick, and can report z == 127 for a very wide finger. If
> > such a packet is parsed as a stick packet, the mouse pointer will
> > typically jump to one corner of the screen.
>
> I remember reading specs of a touchpad (can't remember if it
> was ALPS or Synaptics) (driver) which could do "palm
> detection" (basically ignoring events when a large part of the
> hand accidentally touched/pressed the pad, FWICS).
Some synaptics touchpads can do palm detection in firmware, but the
software driver has to decide if the corresponding events shall be
ignored or not.
Anyway, this is unrelated to the patch. Without this patch, the packet
from the touchpad will be parsed incorrectly as a very big stick
motion, so a higher level driver (such as the X driver) can't really
see that there might be a palm touching the pad.
--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
On Sun, Jan 30, 2005 at 11:31:26AM +0100, Peter Osterlund wrote:
> mousedev_packet() incorrectly clears list->ready when called with
> "tail == head - 1". The effect is that the last mouse event from the
> hardware isn't reported to user space until another hardware mouse
> event arrives. This can make the left mouse button get stuck when
> tapping on a touchpad. When this happens, the button doesn't unstick
> until the next time you interact with the touchpad.
>
> Signed-off-by: Peter Osterlund <[email protected]>
Thanks, applied. Btw, I'm missing your patch 2/4 - it got lost somewhere.
--
Vojtech Pavlik
SuSE Labs, SuSE CR
On Sun, Jan 30, 2005 at 11:35:12AM +0100, Peter Osterlund wrote:
> Only parse a "z == 127" packet as a relative Dualpoint stick packet if
> the touchpad actually is a Dualpoint device. The Glidepoint models
> don't have a stick, and can report z == 127 for a very wide finger. If
> such a packet is parsed as a stick packet, the mouse pointer will
> typically jump to one corner of the screen.
>
> Signed-off-by: Peter Osterlund <[email protected]>
Doesn't apply without 2/4, sorry. Please resend it.
--
Vojtech Pavlik
SuSE Labs, SuSE CR
On Sun, Jan 30, 2005 at 11:36:48AM +0100, Peter Osterlund wrote:
> Some Synaptics touchpads have a middle mouse button that also works as
> a scroll wheel. Scroll data is reported as packets with w == 2 and
> the scroll amount in byte 1, treated as a signed character. For some
> reason, the smallest possible wheel movement is reported as a scroll
> amount of 4 units. This amount is typically spread out over more than
> one packet, so the driver has to accumulate scroll delta values to
> correctly deal with this.
>
> Signed-off-by: Peter Osterlund <[email protected]>
> ---
Thanks, applied.
--
Vojtech Pavlik
SuSE Labs, SuSE CR