From ca94ec43540ce5d93fd30a3bf88321b6f11ed51a Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Thu, 11 Nov 2010 22:19:57 -0800 Subject: Input: hgpk - support GlideSensor and PenTablet modes Add a "hgpk_mode" sysfs attribute that allows selection between 3 options: Mouse (the existing option), GlideSensor and PenTablet. GlideSensor is an enhanced protocol for the regular touchpad mode that additionally reports pressure and uses absolute coordinates. We suspect that it may be more reliable than mouse mode in some environments. PenTablet mode puts the touchpad into resistive mode, you must then use a stylus as an input. We suspect this is the most reliable way to drive the touchpad. The GlideSensor and PenTablet devices expose themselves with the intention of being combined with the synaptics X11 input driver. Based on earlier work by Paul Fox. Signed-off-by: Daniel Drake Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/hgpk.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/input/mouse/hgpk.h') diff --git a/drivers/input/mouse/hgpk.h b/drivers/input/mouse/hgpk.h index d61cfd3..01c983b 100644 --- a/drivers/input/mouse/hgpk.h +++ b/drivers/input/mouse/hgpk.h @@ -5,6 +5,9 @@ #ifndef _HGPK_H #define _HGPK_H +#define HGPK_GS 0xff /* The GlideSensor */ +#define HGPK_PT 0xcf /* The PenTablet */ + enum hgpk_model_t { HGPK_MODEL_PREA = 0x0a, /* pre-B1s */ HGPK_MODEL_A = 0x14, /* found on B1s, PT disabled in hardware */ @@ -13,12 +16,21 @@ enum hgpk_model_t { HGPK_MODEL_D = 0x50, /* C1, mass production */ }; +enum hgpk_mode { + HGPK_MODE_MOUSE, + HGPK_MODE_GLIDESENSOR, + HGPK_MODE_PENTABLET, + HGPK_MODE_INVALID +}; + struct hgpk_data { struct psmouse *psmouse; + enum hgpk_mode mode; bool powered; int count, x_tally, y_tally; /* hardware workaround stuff */ unsigned long recalib_window; struct delayed_work recalib_wq; + int abs_x, abs_y; }; #define hgpk_dbg(psmouse, format, arg...) \ @@ -33,9 +45,13 @@ struct hgpk_data { dev_notice(&(psmouse)->ps2dev.serio->dev, format, ## arg) #ifdef CONFIG_MOUSE_PS2_OLPC +void hgpk_module_init(void); int hgpk_detect(struct psmouse *psmouse, bool set_properties); int hgpk_init(struct psmouse *psmouse); #else +static inline void hgpk_module_init(void) +{ +} static inline int hgpk_detect(struct psmouse *psmouse, bool set_properties) { return -ENODEV; -- cgit v1.1 From c0dc8342656a1425c31dcc505072f2387f0f0c92 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Thu, 11 Nov 2010 22:20:02 -0800 Subject: Input: hgpk - rework spew detection The old implementation of spew detection simply tracked the overall position delta of the cursor over every 100 packets. We found that this causes occasional false positives in spew detection, and also that the conditions of the spewy packets are perhaps more fixed than we once thought. Rework the spew detection to look for packets of specific small delta, and only recalibrating if the overall movement delta stays within expected bounds. Also discard duplicate packets in the advanced mode, which appear to be very common. If we don't, the spew detection kicks in far too early. If we get a large spew of duplicates, request a recalibration straight up. Based on earlier work by Paul Fox. Signed-off-by: Daniel Drake Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/hgpk.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'drivers/input/mouse/hgpk.h') diff --git a/drivers/input/mouse/hgpk.h b/drivers/input/mouse/hgpk.h index 01c983b..bccdb26 100644 --- a/drivers/input/mouse/hgpk.h +++ b/drivers/input/mouse/hgpk.h @@ -16,6 +16,15 @@ enum hgpk_model_t { HGPK_MODEL_D = 0x50, /* C1, mass production */ }; +enum hgpk_spew_flag { + NO_SPEW, + MAYBE_SPEWING, + SPEW_DETECTED, + RECALIBRATING, +}; + +#define SPEW_WATCH_COUNT 42 /* at 12ms/packet, this is 1/2 second */ + enum hgpk_mode { HGPK_MODE_MOUSE, HGPK_MODE_GLIDESENSOR, @@ -27,10 +36,12 @@ struct hgpk_data { struct psmouse *psmouse; enum hgpk_mode mode; bool powered; - int count, x_tally, y_tally; /* hardware workaround stuff */ + enum hgpk_spew_flag spew_flag; + int spew_count, x_tally, y_tally; /* spew detection */ unsigned long recalib_window; struct delayed_work recalib_wq; int abs_x, abs_y; + int dupe_count; }; #define hgpk_dbg(psmouse, format, arg...) \ -- cgit v1.1 From a309cdc778b9eece59b34e9e1c26e41476dbbcd6 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Thu, 11 Nov 2010 22:20:03 -0800 Subject: Input: hgpk - extend jumpiness detection In addition to forcing recalibrations upon detection of cursor jumps (and performing them quicker than before), detect and discard errant 'jump' packets caused by a firmware bug, which are then repeated with each one being approximately half the delta of the one previously (as if it is averaging out) Based on original work by Paul Fox. Signed-off-by: Daniel Drake Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/hgpk.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/input/mouse/hgpk.h') diff --git a/drivers/input/mouse/hgpk.h b/drivers/input/mouse/hgpk.h index bccdb26..311c0e8 100644 --- a/drivers/input/mouse/hgpk.h +++ b/drivers/input/mouse/hgpk.h @@ -42,6 +42,8 @@ struct hgpk_data { struct delayed_work recalib_wq; int abs_x, abs_y; int dupe_count; + int xbigj, ybigj, xlast, ylast; /* jumpiness detection */ + int xsaw_secondary, ysaw_secondary; /* jumpiness detection */ }; #define hgpk_dbg(psmouse, format, arg...) \ -- cgit v1.1