Input: synaptics - add support for ForcePads
Subsystems (2)
Dmitry Torokhov
maintainerPATCH 1/1 Input: synaptics - add support for ForcePads
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
For now we are using DMI matching to detect ForcePads, hopefully we'll be able to figure a better way down the road.
--- drivers/input/mouse/synaptics.c | 80 ++++++++++++++++++++++++++++++++--------- drivers/input/mouse/synaptics.h | 5 +++ 2 files changed, 69 insertions(+), 16 deletions(-)
drivers/input/mouse/synaptics.c +64 -16
@@ -618,6 +618,8 @@ static void synaptics_parse_agm(const unsigned char buf[], priv->agm_pending = true; } +static bool is_forcepad; +static int synaptics_parse_hw_state (const unsigned char buf[],struct synaptics_data *priv,struct synaptics_hw_state *hw)
@@ -629,10 +631,58 @@ static int synaptics_parse_hw_state(const unsigned char buf[], ((buf[0 ] &0x04 ) >>1 ) | ((buf[3] & 0x04) >> 2)); +if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || +SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && + hw->w ==2 ) { +synaptics_parse_agm (buf, priv, hw); +return 1 ; + } + + hw->x = (((buf[3 ] &0x10 ) <<8 ) | + ((buf[1 ] &0x0f ) <<8 ) | + buf[4 ]); + hw->y = (((buf[3 ] &0x20 ) <<7 ) | + ((buf[1 ] &0xf0 ) <<4 ) | + buf[5 ]); + hw->z = buf[2 ]; + hw->left = (buf[0 ] &0x01 ) ?1 :0 ; hw->right = (buf[0 ] &0x02 ) ?1 :0 ; -if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) { +if (is_forcepad) { +/* XXX is there a proper capability bit for this? */ +/* +* ForcePads, like Clickpads, use middle button +* bits to report primary button clicks. +* Unfortunately they report primary button not only +* when user presses on the pad above certain threshold, +* but also when there are more than one finger on the +* touchpad, which interferes with out multi-finger +* gestures. +*/ +if (hw->z ==0 ) { +/* No contacts */ + priv->press = priv->report_press = false; + }else if (hw->w >=4 && ((buf[0 ] ^ buf[3 ]) &0x01 )) { +/* +* Single-finger touch with pressure above +* the threshold. +*/ +if (!priv->press) { + priv->press_start = jiffies; + priv->press = true; + }else if (time_after (jiffies, + priv->press_start + +msecs_to_jiffies (50 ))) { + priv->report_press = true; + } + }else { + priv->press = false; + } + + hw->left = priv->report_press; + + }else if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) {/* * Clickpad's button is transmitted as middle button, * however, since it is primary button, we will report
@@ -651,21 +701,6 @@ static int synaptics_parse_hw_state(const unsigned char buf[], hw->down = ((buf[0 ] ^ buf[3 ]) &0x02 ) ?1 :0 ; } -if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || -SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && - hw->w ==2 ) { -synaptics_parse_agm (buf, priv, hw); -return 1 ; - } - - hw->x = (((buf[3 ] &0x10 ) <<8 ) | - ((buf[1 ] &0x0f ) <<8 ) | - buf[4 ]); - hw->y = (((buf[3 ] &0x20 ) <<7 ) | - ((buf[1 ] &0xf0 ) <<4 ) | - buf[5 ]); - hw->z = buf[2 ]; -if (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) && ((buf[0 ] ^ buf[3 ]) &0x02 )) {switch (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) & ~0x01 ) {
@@ -1642,11 +1677,24 @@ static const struct dmi_system_id __initconst cr48_dmi_table[] = { { } }; +static const struct dmi_system_id forcepad_dmi_table[]__initconst = { +#if defined(CONFIG_DMI) && defined(CONFIG_X86) + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Hewlett-Packard" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"HP EliteBook Folio 1040 G1" ), + }, + }, +#endif + { } +}; +void __init synaptics_module_init (void ) { impaired_toshiba_kbc =dmi_check_system (toshiba_dmi_table); broken_olpc_ec =dmi_check_system (olpc_dmi_table); cr48_profile_sensor =dmi_check_system (cr48_dmi_table); + is_forcepad =dmi_check_system (forcepad_dmi_table); }static int __synaptics_init (struct psmouse *psmouse,bool absolute_mode)
drivers/input/mouse/synaptics.h +5 -0
@@ -177,6 +177,11 @@ struct synaptics_data {*/ struct synaptics_hw_state agm;bool agm_pending;/* new AGM packet received */ + +/* ForcePad handling */ +unsigned long press_start; +bool press; +bool report_press; };void synaptics_module_init (void );
Signature · 5 lines
2.1.0.rc2.206.gedb03e5 -- Dmitry
Hi,
Quoted 11 lines · Dmitry Torokhov
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
For now we are using DMI matching to detect ForcePads, hopefully we'll be able to figure a better way down the road.
What about using the pnp-id, in my experience with the recent lenovo laptops that tends to be more reliable.
Christopher, Andrew (added to the CC), can one of you tell us if there is a capability bit to detect this, and if not can you perhaps provide a list of pnp-ids of devices which behave like this ?
Quoted 31 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/mouse/synaptics.c | 80 ++++++++++++++++++++++++++++++++--------- drivers/input/mouse/synaptics.h | 5 +++ 2 files changed, 69 insertions(+), 16 deletions(-)drivers/input/mouse/synaptics.c +10
-0@@ -618,6 +618,8 @@ static void synaptics_parse_agm(const unsigned char buf[], priv->agm_pending = true; } +static bool is_forcepad; +static int synaptics_parse_hw_state (const unsigned char buf[],struct synaptics_data *priv,struct synaptics_hw_state *hw)@@ -629,10 +631,58 @@ static int synaptics_parse_hw_state(const unsigned char buf[], ((buf[0 ] &0x04 ) >>1 ) | ((buf[3] & 0x04) >> 2)); +if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || +SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && + hw->w ==2 ) { +synaptics_parse_agm (buf, priv, hw); +return 1 ; + } + + hw->x = (((buf[3] & 0x10) << 8) |
drivers/input/mouse/synaptics.c static int synaptics_parse_hw_state(const unsigned char buf[], · line 651
Quoted 10 lines
drivers/input/mouse/synaptics.c +7
-0+ ((buf[1 ] &0x0f ) <<8 ) | + buf[4]); + hw->y = (((buf[3 ] &0x20 ) <<7 ) | + ((buf[1 ] &0xf0 ) <<4 ) | + buf[5 ]); + hw->z = buf[2 ]; + hw->left = (buf[0 ] &0x01 ) ?1 :0 ; hw->right = (buf[0 ] &0x02 ) ?1 :0 ;
Moving this up means that on clickpads the button will no longer be checked + set for hw->w == 2 packets. That seems like an unintended side effect. If this is intended then this should probably be in its own patch.
Quoted 18 lines
drivers/input/mouse/synaptics.c +17
-1-if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) { +if (is_forcepad) { +/* XXX is there a proper capability bit for this? */ +/* +* ForcePads, like Clickpads, use middle button +* bits to report primary button clicks. +* Unfortunately they report primary button not only +* when user presses on the pad above certain threshold, +* but also when there are more than one finger on the +* touchpad, which interferes with out multi-finger +* gestures. +*/ +if (hw->z ==0 ) { +/* No contacts */ + priv->press = priv->report_press = false; + }else if (hw->w >=4 && ((buf[0 ] ^ buf[3 ]) &0x01 )) { +/* +* Single-finger touch with pressure above
drivers/input/mouse/synaptics.c static int synaptics_parse_hw_state(const unsigned char buf[], · line 678
Quoted 10 lines
drivers/input/mouse/synaptics.c +10
-0+* the threshold. +*/ +if (!priv->press) { + priv->press_start = jiffies; + priv->press = true; + }else if (time_after (jiffies, + priv->press_start + +msecs_to_jiffies (50 ))) { + priv->report_press = true; + }
You're not setting a timer here, instead relying on there to be further events, that is probably ok, but maybe put a comment to that extent here ?
Quoted 64 lines
drivers/input/mouse/synaptics.c +20
-15+ }else { + priv->press = false; + } + + hw->left = priv->report_press; + + }else if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) {/* * Clickpad's button is transmitted as middle button, * however, since it is primary button, we will report @@ -651,21 +701,6 @@ static int synaptics_parse_hw_state(const unsigned char buf[], hw->down = ((buf[0 ] ^ buf[3 ]) &0x02 ) ?1 :0 ; } -if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || -SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && - hw->w ==2 ) { -synaptics_parse_agm (buf, priv, hw); -return 1 ; - } - - hw->x = (((buf[3 ] &0x10 ) <<8 ) | - ((buf[1 ] &0x0f ) <<8 ) | - buf[4 ]); - hw->y = (((buf[3 ] &0x20 ) <<7 ) | - ((buf[1 ] &0xf0 ) <<4 ) | - buf[5 ]); - hw->z = buf[2 ]; -if (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) && ((buf[0 ] ^ buf[3 ]) &0x02 )) {switch (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) & ~0x01 ) {@@ -1642,11 +1677,24 @@ static const struct dmi_system_id __initconst cr48_dmi_table[] = { { } }; +static const struct dmi_system_id forcepad_dmi_table[]__initconst = { +#if defined(CONFIG_DMI) && defined(CONFIG_X86) + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Hewlett-Packard" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"HP EliteBook Folio 1040 G1" ), + }, + }, +#endif + { } +}; +void __init synaptics_module_init (void ) { impaired_toshiba_kbc =dmi_check_system (toshiba_dmi_table); broken_olpc_ec =dmi_check_system (olpc_dmi_table); cr48_profile_sensor =dmi_check_system (cr48_dmi_table); + is_forcepad =dmi_check_system (forcepad_dmi_table); }static int __synaptics_init (struct psmouse *psmouse,bool absolute_mode)drivers/input/mouse/synaptics.h +0
-0@@ -177,6 +177,11 @@ struct synaptics_data {*/
drivers/input/mouse/synaptics.h struct synaptics_data { · line 187
Quoted 10 lines
drivers/input/mouse/synaptics.h +5
-0struct synaptics_hw_state agm;bool agm_pending;/* new AGM packet received */ + +/* ForcePad handling */ +unsigned long press_start; +bool press; +bool report_press; };void synaptics_module_init (void );
Regards,
Hans
Dmitry Torokhov
maintainerQuoted 12 lines · Hans de Goede
Hi,
Quoted 9 lines · Dmitry Torokhov
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
Quoted 5 lines
Quoted 2 lines
For now we are using DMI matching to detect ForcePads, hopefully we'll be able to figure a better way down the road.
What about using the pnp-id, in my experience with the recent lenovo laptops that tends to be more reliable.
Not sure. So far I only know of HP 1040 having it. FWIW:
dtor@dtor-glaptop:~$ cat /sys/bus/pnp/drivers/i8042\ aux/00\:07/id SYN300d SYN0100 SYN0002 PNP0f13
I think if we see generalities we can switch over later. I hope Chris/Andrew will come with a capability bit though :)
Quoted 42 lines
Christopher, Andrew (added to the CC), can one of you tell us if there is a capability bit to detect this, and if not can you perhaps provide a list of pnp-ids of devices which behave like this ?
Quoted 37 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/mouse/synaptics.c | 80 ++++++++++++++++++++++++++++++++--------- drivers/input/mouse/synaptics.h | 5 +++ 2 files changed, 69 insertions(+), 16 deletions(-)drivers/input/mouse/synaptics.c +16
-0@@ -618,6 +618,8 @@ static void synaptics_parse_agm(const unsigned char buf[], priv->agm_pending = true; } +static bool is_forcepad; +static int synaptics_parse_hw_state (const unsigned char buf[],struct synaptics_data *priv,struct synaptics_hw_state *hw)@@ -629,10 +631,58 @@ static int synaptics_parse_hw_state(const unsigned char buf[], ((buf[0 ] &0x04 ) >>1 ) | ((buf[3] & 0x04) >> 2)); +if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || +SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && + hw->w ==2 ) { +synaptics_parse_agm (buf, priv, hw); +return 1 ; + } + + hw->x = (((buf[3 ] &0x10 ) <<8 ) | + ((buf[1 ] &0x0f ) <<8 ) | + buf[4 ]); + hw->y = (((buf[3 ] &0x20 ) <<7 ) | + ((buf[1 ] &0xf0 ) <<4 ) | + buf[5 ]); + hw->z = buf[2 ];
Quoted 8 lines
drivers/input/mouse/synaptics.c static int synaptics_parse_hw_state(const unsigned char buf[], · line 651
Quoted 4 lines
drivers/input/mouse/synaptics.c +1
-0+ hw->left = (buf[0 ] &0x01 ) ?1 :0 ; hw->right = (buf[0 ] &0x02 ) ?1 :0 ;Moving this up means that on clickpads the button will no longer be checked + set for
hw->w== 2 packets. That seems like an unintended side effect.
I guess we can call it a side effect, but it is fine - we parse AGM and stash the data, then when 2nd packet comes we parse and act upon it. In the old code we'd parse x, y, z, in AGM etc. and then have it overwritten with the data from the 2nd packet, here we do not bother.
Quoted 2 lines
If this is intended then this should probably be in its own patch.
It does not make sense on its own as ForcePad support needs to know values of Z and W when deciding how to handle primary click, otherwise the old code was just fine.
Quoted 24 lines
Quoted 24 lines
drivers/input/mouse/synaptics.c +22
-1-if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) { +if (is_forcepad) { +/* XXX is there a proper capability bit for this? */ +/* +* ForcePads, like Clickpads, use middle button +* bits to report primary button clicks. +* Unfortunately they report primary button not only +* when user presses on the pad above certain threshold, +* but also when there are more than one finger on the +* touchpad, which interferes with out multi-finger +* gestures. +*/ +if (hw->z ==0 ) { +/* No contacts */ + priv->press = priv->report_press = false; + }else if (hw->w >=4 && ((buf[0 ] ^ buf[3 ]) &0x01 )) { +/* +* Single-finger touch with pressure above +* the threshold. +*/ +if (!priv->press) { + priv->press_start = jiffies; + priv->press = true;
Quoted 8 lines
drivers/input/mouse/synaptics.c static int synaptics_parse_hw_state(const unsigned char buf[], · line 678
Quoted 5 lines
drivers/input/mouse/synaptics.c +5
-0+ }else if (time_after (jiffies, + priv->press_start + +msecs_to_jiffies (50 ))) { + priv->report_press = true; + }You're not setting a timer here, instead relying on there to be further events, that is probably ok, but maybe put a comment to that extent here ?
I can, any suggestion on what you want me to say? "If single point contact held pressure long enough start reporting primary click"?
Thanks.
Signature · 1 line
Dmitry
Hi,
Quoted 19 lines · Dmitry Torokhov
Quoted 12 lines · Hans de Goede
Hi,
Quoted 9 lines · Dmitry Torokhov
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
Quoted 5 lines
Quoted 2 lines
For now we are using DMI matching to detect ForcePads, hopefully we'll be able to figure a better way down the road.
What about using the pnp-id, in my experience with the recent lenovo laptops that tends to be more reliable.
Quoted 7 lines
Not sure. So far I only know of HP 1040 having it. FWIW:
dtor@dtor-glaptop:~$ cat /sys/bus/pnp/drivers/i8042\ aux/00\:07/id SYN300d SYN0100 SYN0002 PNP0f13
Hmm, those look pretty generic. Maybe the 300d is specific.
Quoted 59 lines
I think if we see generalities we can switch over later. I hope Chris/Andrew will come with a capability bit though :)
Quoted 42 lines
Christopher, Andrew (added to the CC), can one of you tell us if there is a capability bit to detect this, and if not can you perhaps provide a list of pnp-ids of devices which behave like this ?
Quoted 37 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/mouse/synaptics.c | 80 ++++++++++++++++++++++++++++++++--------- drivers/input/mouse/synaptics.h | 5 +++ 2 files changed, 69 insertions(+), 16 deletions(-)drivers/input/mouse/synaptics.c +16
-0@@ -618,6 +618,8 @@ static void synaptics_parse_agm(const unsigned char buf[], priv->agm_pending = true; } +static bool is_forcepad; +static int synaptics_parse_hw_state (const unsigned char buf[],struct synaptics_data *priv,struct synaptics_hw_state *hw)@@ -629,10 +631,58 @@ static int synaptics_parse_hw_state(const unsigned char buf[], ((buf[0 ] &0x04 ) >>1 ) | ((buf[3] & 0x04) >> 2)); +if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || +SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && + hw->w ==2 ) { +synaptics_parse_agm (buf, priv, hw); +return 1 ; + } + + hw->x = (((buf[3 ] &0x10 ) <<8 ) | + ((buf[1 ] &0x0f ) <<8 ) | + buf[4 ]); + hw->y = (((buf[3 ] &0x20 ) <<7 ) | + ((buf[1 ] &0xf0 ) <<4 ) | + buf[5 ]); + hw->z = buf[2 ];Quoted 8 lines
drivers/input/mouse/synaptics.c static int synaptics_parse_hw_state(const unsigned char buf[], · line 651
Quoted 4 lines
drivers/input/mouse/synaptics.c +1
-0+ hw->left = (buf[0 ] &0x01 ) ?1 :0 ; hw->right = (buf[0 ] &0x02 ) ?1 :0 ;Moving this up means that on clickpads the button will no longer be checked + set for
hw->w== 2 packets. That seems like an unintended side effect.I guess we can call it a side effect, but it is fine - we parse AGM and stash the data, then when 2nd packet comes we parse and act upon it. In the old code we'd parse x, y, z, in AGM etc. and then have it overwritten with the data from the 2nd packet, here we do not bother.
Quoted 6 lines
Quoted 2 lines
If this is intended then this should probably be in its own patch.
It does not make sense on its own as ForcePad support needs to know values of Z and W when deciding how to handle primary click, otherwise the old code was just fine.
Ok.
Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
drivers/input/mouse/synaptics.c +22
-1-if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) { +if (is_forcepad) { +/* XXX is there a proper capability bit for this? */ +/* +* ForcePads, like Clickpads, use middle button +* bits to report primary button clicks. +* Unfortunately they report primary button not only +* when user presses on the pad above certain threshold, +* but also when there are more than one finger on the +* touchpad, which interferes with out multi-finger +* gestures. +*/ +if (hw->z ==0 ) { +/* No contacts */ + priv->press = priv->report_press = false; + }else if (hw->w >=4 && ((buf[0 ] ^ buf[3 ]) &0x01 )) { +/* +* Single-finger touch with pressure above +* the threshold. +*/ +if (!priv->press) { + priv->press_start = jiffies; + priv->press = true;Quoted 8 lines
drivers/input/mouse/synaptics.c static int synaptics_parse_hw_state(const unsigned char buf[], · line 678
Quoted 5 lines
drivers/input/mouse/synaptics.c +5
-0+ }else if (time_after (jiffies, + priv->press_start + +msecs_to_jiffies (50 ))) { + priv->report_press = true; + }You're not setting a timer here, instead relying on there to be further events, that is probably ok, but maybe put a comment to that extent here ?
Quoted 2 lines
I can, any suggestion on what you want me to say? "If single point contact held pressure long enough start reporting primary click"?
What I mean is that this will not work if the finger is held perfectly still, at least AFAIK no more packets will be send in that case, but maybe that is me thinking too much in userspace terms where no evdev events will be generated in that case. If the touchpad will continue repeating events with exact the same location + pressure, then there is nothing to worry about and you can ignore my request for a comment.
Regards,
Hans
Quoted 19 lines · Dmitry Torokhov
Quoted 12 lines · Hans de Goede
Hi,
Quoted 9 lines · Dmitry Torokhov
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
Quoted 4 lines
Quoted 2 lines
For now we are using DMI matching to detect ForcePads, hopefully we'll be able to figure a better way down the road.
What about using the pnp-id, in my experience with the recent lenovo laptops that tends to be more reliable.
Not sure. So far I only know of HP 1040 having it. FWIW:
Quoted 8 lines
dtor@dtor-glaptop:~$ cat /sys/bus/pnp/drivers/i8042\ aux/00\:07/id SYN300d SYN0100 SYN0002 PNP0f13I think if we see generalities we can switch over later. I hope Chris/Andrew will come with a capability bit though :)
The ForcePad capabilities bit is 1 << 15.
Quoted 95 lines
Quoted 41 lines
Christopher, Andrew (added to the CC), can one of you tell us if there is a capability bit to detect this, and if not can you perhaps provide a list of pnp-ids of devices which behave like this ?
Quoted 36 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/mouse/synaptics.c | 80 ++++++++++++++++++++++++++++++++--------- drivers/input/mouse/synaptics.h | 5 +++ 2 files changed, 69 insertions(+), 16 deletions(-)drivers/input/mouse/synaptics.c +15
-0@@ -618,6 +618,8 @@ static void synaptics_parse_agm(const unsigned char buf[], priv->agm_pending = true; } +static bool is_forcepad; +static int synaptics_parse_hw_state (const unsigned char buf[],struct synaptics_data *priv,struct synaptics_hw_state *hw)@@ -629,10 +631,58 @@ static int synaptics_parse_hw_state(const unsigned char buf[], ((buf[0 ] &0x04 ) >>1 ) | ((buf[3] & 0x04) >> 2)); +if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || +SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && + hw->w ==2 ) { +synaptics_parse_agm (buf, priv, hw); +return 1 ; + } + + hw->x = (((buf[3 ] &0x10 ) <<8 ) | + ((buf[1 ] &0x0f ) <<8 ) | + buf[4 ]); + hw->y = (((buf[3 ] &0x20 ) <<7 ) | + ((buf[1 ] &0xf0 ) <<4 ) | + buf[5 ]);Quoted 8 lines
drivers/input/mouse/synaptics.c static int synaptics_parse_hw_state(const unsigned char buf[], · line 651
Quoted 5 lines
drivers/input/mouse/synaptics.c +2
-0+ hw->z = buf[2 ]; + hw->left = (buf[0 ] &0x01 ) ?1 :0 ; hw->right = (buf[0 ] &0x02 ) ?1 :0 ;Moving this up means that on clickpads the button will no longer be checked + set for
hw->w== 2 packets. That seems like an unintended side effect.I guess we can call it a side effect, but it is fine - we parse AGM and stash the data, then when 2nd packet comes we parse and act upon it. In the old code we'd parse x, y, z, in AGM etc. and then have it overwritten with the data from the 2nd packet, here we do not bother.
Quoted 2 lines
If this is intended then this should probably be in its own patch.
It does not make sense on its own as ForcePad support needs to know values of Z and W when deciding how to handle primary click, otherwise the old code was just fine.
Quoted 22 lines
Quoted 22 lines
drivers/input/mouse/synaptics.c +21
-1-if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) { +if (is_forcepad) { +/* XXX is there a proper capability bit for this? */ +/* +* ForcePads, like Clickpads, use middle button +* bits to report primary button clicks. +* Unfortunately they report primary button not only +* when user presses on the pad above certain threshold, +* but also when there are more than one finger on the +* touchpad, which interferes with out multi-finger +* gestures. +*/ +if (hw->z ==0 ) { +/* No contacts */ + priv->press = priv->report_press = false; + }else if (hw->w >=4 && ((buf[0 ] ^ buf[3 ]) &0x01 )) { +/* +* Single-finger touch with pressure above +* the threshold. +*/ +if (!priv->press) { + priv->press_start = jiffies;Quoted 8 lines
drivers/input/mouse/synaptics.c static int synaptics_parse_hw_state(const unsigned char buf[], · line 678
Quoted 6 lines
drivers/input/mouse/synaptics.c +6
-0+ priv->press = true; + }else if (time_after (jiffies, + priv->press_start + +msecs_to_jiffies (50 ))) { + priv->report_press = true; + }You're not setting a timer here, instead relying on there to be further events, that is probably ok, but maybe put a comment to that extent here ?
I can, any suggestion on what you want me to say? "If single point contact held pressure long enough start reporting primary click"?
Thanks.
Dmitry Torokhov
maintainerQuoted 26 lines · Andrew Duggan
Quoted 25 lines · Dmitry Torokhov
Quoted 12 lines · Hans de Goede
Hi,
Quoted 9 lines · Dmitry Torokhov
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
Quoted 4 lines
Quoted 2 lines
For now we are using DMI matching to detect ForcePads, hopefully we'll be able to figure a better way down the road.
What about using the pnp-id, in my experience with the recent lenovo laptops that tends to be more reliable.
Not sure. So far I only know of HP 1040 having it. FWIW:
dtor@dtor-glaptop:~$ cat /sys/bus/pnp/drivers/i8042\ aux/00\:07/id SYN300d SYN0100 SYN0002 PNP0f13
Quoted 4 lines
Quoted 2 lines
I think if we see generalities we can switch over later. I hope Chris/Andrew will come with a capability bit though :)
The ForcePad capabilities bit is 1 << 15.
Awesome, thanks!
Then I guess the patch below is what we'll be needing for these devices.
Thanks.
Signature · 20 lines
Dmitry Input: synaptics - add support for ForcePads From: Dmitry Torokhov <[email protected]> ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear. Signed-off-by: Dmitry Torokhov <[email protected]> --- drivers/input/mouse/synaptics.c | 68 ++++++++++++++++++++++++++++++--------- drivers/input/mouse/synaptics.h | 11 ++++++ 2 files changed, 63 insertions(+), 16 deletions(-)
drivers/input/mouse/synaptics.c +52 -16
@@ -629,10 +629,61 @@ static int synaptics_parse_hw_state(const unsigned char buf[], ((buf[0 ] &0x04 ) >>1 ) | ((buf[3] & 0x04) >> 2)); +if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || +SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && + hw->w ==2 ) { +synaptics_parse_agm (buf, priv, hw); +return 1 ; + } + + hw->x = (((buf[3 ] &0x10 ) <<8 ) | + ((buf[1 ] &0x0f ) <<8 ) | + buf[4 ]); + hw->y = (((buf[3 ] &0x20 ) <<7 ) | + ((buf[1 ] &0xf0 ) <<4 ) | + buf[5 ]); + hw->z = buf[2 ]; + hw->left = (buf[0 ] &0x01 ) ?1 :0 ; hw->right = (buf[0 ] &0x02 ) ?1 :0 ; -if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) { +if (SYN_CAP_FORCEPAD (priv->ext_cap_0c)) { +/* +* ForcePads, like Clickpads, use middle button +* bits to report primary button clicks. +* Unfortunately they report primary button not +* only when user presses on the pad above certain +* threshold, but also when there are more than one +* finger on the touchpad, which interferes with +* out multi-finger gestures. +*/ +if (hw->z ==0 ) { +/* No contacts */ + priv->press = priv->report_press = false; + }else if (hw->w >=4 && ((buf[0 ] ^ buf[3 ]) &0x01 )) { +/* +* Single-finger touch with pressure above +* the threshold. If pressure stays long +* enough, we'll start reporting primary +* button. We rely on the device continuing +* sending data even if finger does not +* move. +*/ +if (!priv->press) { + priv->press_start = jiffies; + priv->press = true; + }else if (time_after (jiffies, + priv->press_start + +msecs_to_jiffies (50 ))) { + priv->report_press = true; + } + }else { + priv->press = false; + } + + hw->left = priv->report_press; + + }else if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) {/* * Clickpad's button is transmitted as middle button, * however, since it is primary button, we will report
@@ -651,21 +702,6 @@ static int synaptics_parse_hw_state(const unsigned char buf[], hw->down = ((buf[0 ] ^ buf[3 ]) &0x02 ) ?1 :0 ; } -if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || -SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && - hw->w ==2 ) { -synaptics_parse_agm (buf, priv, hw); -return 1 ; - } - - hw->x = (((buf[3 ] &0x10 ) <<8 ) | - ((buf[1 ] &0x0f ) <<8 ) | - buf[4 ]); - hw->y = (((buf[3 ] &0x20 ) <<7 ) | - ((buf[1 ] &0xf0 ) <<4 ) | - buf[5 ]); - hw->z = buf[2 ]; -if (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) && ((buf[0 ] ^ buf[3 ]) &0x02 )) {switch (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) & ~0x01 ) {
drivers/input/mouse/synaptics.h +11 -0
@@ -78,6 +78,11 @@* 2 0x08 image sensor image sensor tracks 5 fingers, but only * reports 2. * 2 0x20 report min query 0x0f gives min coord reported +* 2 0x80 forcepad forcepad is a variant of clickpad that +* does not have physical buttons but rather +* uses pressure above certain threshold to +* report primary clicks. Forcepads also have +* clickpad bit set. */ #define SYN_CAP_CLICKPAD (ex0c) ((ex0c) & 0x100000)/* 1-button ClickPad */ #define SYN_CAP_CLICKPAD2BTN (ex0c) ((ex0c) & 0x000100)/* 2-button ClickPad */
@@ -86,6 +91,7 @@#define SYN_CAP_ADV_GESTURE (ex0c) ((ex0c) & 0x080000)#define SYN_CAP_REDUCED_FILTERING (ex0c) ((ex0c) & 0x000400)#define SYN_CAP_IMAGE_SENSOR (ex0c) ((ex0c) & 0x000800) +#define SYN_CAP_FORCEPAD (ex0c) ((ex0c) & 0x008000)/* synaptics modes query bits */ #define SYN_MODE_ABSOLUTE (m) ((m) & (1 << 7))
@@ -177,6 +183,11 @@ struct synaptics_data {*/ struct synaptics_hw_state agm;bool agm_pending;/* new AGM packet received */ + +/* ForcePad handling */ +unsigned long press_start; +bool press; +bool report_press; };void synaptics_module_init (void );
Hi,
Quoted 27 lines · Dmitry Torokhov
Quoted 26 lines · Andrew Duggan
Quoted 25 lines · Dmitry Torokhov
Quoted 12 lines · Hans de Goede
Hi,
Quoted 9 lines · Dmitry Torokhov
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
Quoted 4 lines
Quoted 2 lines
For now we are using DMI matching to detect ForcePads, hopefully we'll be able to figure a better way down the road.
What about using the pnp-id, in my experience with the recent lenovo laptops that tends to be more reliable.
Not sure. So far I only know of HP 1040 having it. FWIW:
dtor@dtor-glaptop:~$ cat /sys/bus/pnp/drivers/i8042\ aux/00\:07/id SYN300d SYN0100 SYN0002 PNP0f13
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I think if we see generalities we can switch over later. I hope Chris/Andrew will come with a capability bit though :)
The ForcePad capabilities bit is 1 << 15.
Awesome, thanks!
Then I guess the patch below is what we'll be needing for these devices.
Yep, the patch looks good to me.
Regards,
Hans
Dmitry Torokhov
maintainerQuoted 33 lines · Hans de Goede
Hi,
Quoted 30 lines · Dmitry Torokhov
Quoted 29 lines · Andrew Duggan
Quoted 27 lines · Dmitry Torokhov
Quoted 12 lines · Hans de Goede
Hi,
Quoted 9 lines · Dmitry Torokhov
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
Quoted 4 lines
Quoted 2 lines
For now we are using DMI matching to detect ForcePads, hopefully we'll be able to figure a better way down the road.
What about using the pnp-id, in my experience with the recent lenovo laptops that tends to be more reliable.
Not sure. So far I only know of HP 1040 having it. FWIW:
dtor@dtor-glaptop:~$ cat /sys/bus/pnp/drivers/i8042\ aux/00\:07/id SYN300d SYN0100 SYN0002 PNP0f13I think if we see generalities we can switch over later. I hope Chris/Andrew will come with a capability bit though :)
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
The ForcePad capabilities bit is 1 << 15.
Awesome, thanks!
Then I guess the patch below is what we'll be needing for these devices.
Yep, the patch looks good to me.
Thanks, I'll put you down as reviewed-by then.
Signature · 1 line
Dmitry
Quoted 10 lines · Dmitry Torokhov
From: Dmitry Torokhov <[email protected]>
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
can we assign INPUT_PROP_FORCEPAD to this? or PRESSUREPAD or something if we're worried about trademarks. This is something I'd like to know in userspace, we can then ignore clicks completely and do the rest ourselves.
Cheers,
Peter
Quoted 136 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/mouse/synaptics.c | 68 ++++++++++++++++++++++++++++++--------- drivers/input/mouse/synaptics.h | 11 ++++++ 2 files changed, 63 insertions(+), 16 deletions(-)drivers/input/mouse/synaptics.c +52
-16@@ -629,10 +629,61 @@ static int synaptics_parse_hw_state(const unsigned char buf[], ((buf[0 ] &0x04 ) >>1 ) | ((buf[3] & 0x04) >> 2)); +if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || +SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && + hw->w ==2 ) { +synaptics_parse_agm (buf, priv, hw); +return 1 ; + } + + hw->x = (((buf[3 ] &0x10 ) <<8 ) | + ((buf[1 ] &0x0f ) <<8 ) | + buf[4 ]); + hw->y = (((buf[3 ] &0x20 ) <<7 ) | + ((buf[1 ] &0xf0 ) <<4 ) | + buf[5 ]); + hw->z = buf[2 ]; + hw->left = (buf[0 ] &0x01 ) ?1 :0 ; hw->right = (buf[0 ] &0x02 ) ?1 :0 ; -if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) { +if (SYN_CAP_FORCEPAD (priv->ext_cap_0c)) { +/* +* ForcePads, like Clickpads, use middle button +* bits to report primary button clicks. +* Unfortunately they report primary button not +* only when user presses on the pad above certain +* threshold, but also when there are more than one +* finger on the touchpad, which interferes with +* out multi-finger gestures. +*/ +if (hw->z ==0 ) { +/* No contacts */ + priv->press = priv->report_press = false; + }else if (hw->w >=4 && ((buf[0 ] ^ buf[3 ]) &0x01 )) { +/* +* Single-finger touch with pressure above +* the threshold. If pressure stays long +* enough, we'll start reporting primary +* button. We rely on the device continuing +* sending data even if finger does not +* move. +*/ +if (!priv->press) { + priv->press_start = jiffies; + priv->press = true; + }else if (time_after (jiffies, + priv->press_start + +msecs_to_jiffies (50 ))) { + priv->report_press = true; + } + }else { + priv->press = false; + } + + hw->left = priv->report_press; + + }else if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) {/* * Clickpad's button is transmitted as middle button, * however, since it is primary button, we will report @@ -651,21 +702,6 @@ static int synaptics_parse_hw_state(const unsigned char buf[], hw->down = ((buf[0 ] ^ buf[3 ]) &0x02 ) ?1 :0 ; } -if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || -SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && - hw->w ==2 ) { -synaptics_parse_agm (buf, priv, hw); -return 1 ; - } - - hw->x = (((buf[3 ] &0x10 ) <<8 ) | - ((buf[1 ] &0x0f ) <<8 ) | - buf[4 ]); - hw->y = (((buf[3 ] &0x20 ) <<7 ) | - ((buf[1 ] &0xf0 ) <<4 ) | - buf[5 ]); - hw->z = buf[2 ]; -if (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) && ((buf[0 ] ^ buf[3 ]) &0x02 )) {switch (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) & ~0x01 ) {drivers/input/mouse/synaptics.h +11
-1@@ -78,6 +78,11 @@* 2 0x08 image sensor image sensor tracks 5 fingers, but only * reports 2. * 2 0x20 report min query 0x0f gives min coord reported +* 2 0x80 forcepad forcepad is a variant of clickpad that +* does not have physical buttons but rather +* uses pressure above certain threshold to +* report primary clicks. Forcepads also have +* clickpad bit set. */ #define SYN_CAP_CLICKPAD (ex0c) ((ex0c) & 0x100000)/* 1-button ClickPad */ #define SYN_CAP_CLICKPAD2BTN (ex0c) ((ex0c) & 0x000100)/* 2-button ClickPad */ @@ -86,6 +91,7 @@#define SYN_CAP_ADV_GESTURE (ex0c) ((ex0c) & 0x080000)#define SYN_CAP_REDUCED_FILTERING (ex0c) ((ex0c) & 0x000400)#define SYN_CAP_IMAGE_SENSOR (ex0c) ((ex0c) & 0x000800) +#define SYN_CAP_FORCEPAD (ex0c) ((ex0c) & 0x008000)/* synaptics modes query bits */ #define SYN_MODE_ABSOLUTE (m) ((m) & (1 << 7))@@ -177,6 +183,11 @@ struct synaptics_data {*/ struct synaptics_hw_state agm;bool agm_pending;/* new AGM packet received */ + +/* ForcePad handling */ +unsigned long press_start; +bool press; +bool report_press; };void synaptics_module_init (void ); --To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov
maintainerQuoted 12 lines · Peter Hutterer
Quoted 10 lines · Dmitry Torokhov
From: Dmitry Torokhov <[email protected]>
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
Quoted 3 lines
can we assign
INPUT_PROP_FORCEPADto this? or PRESSUREPAD or something if we're worried about trademarks. This is something I'd like to know in userspace, we can then ignore clicks completely and do the rest ourselves.
Hmm, I think we can, but I'd like to wait to see if there are more models with such touchpads (I sure hope there isn't; lack of tactile feedback on presses is not the best user experience so I hope this initiative dies a quick death).
Thanks.
Signature · 1 line
Dmitry