Re: [PATCH libinput] touchpad: warn if we have invalid touchpad ranges

2016-06-01 Thread Peter Hutterer
On Wed, Jun 01, 2016 at 08:41:17AM -0500, Yong Bakos wrote:
> On May 31, 2016, at 7:42 PM, Peter Hutterer  wrote:
> > 
> > Quite a few bugs are caused by touchpad ranges being out of whack. If we get
> > input events significantly outside the expected range (5% width/height as
> > error margin) print a warning to the log.
> > 
> > And add a new doc page to explain what is happening and how to fix it.
> > 
> > Signed-off-by: Peter Hutterer 
> 
> Hi Peter,
> FWIW, one minor nit (whildcard) I noticed, inline below.

fixed, thanks.

Cheers,
   Peter

> > ---
> > doc/Makefile.am|   1 +
> > doc/absolute-coordinate-ranges.dox | 120 
> > +
> > doc/page-hierarchy.dox |   1 +
> > src/evdev-mt-touchpad.c|  59 ++
> > src/evdev-mt-touchpad.h|   5 ++
> > 5 files changed, 186 insertions(+)
> > create mode 100644 doc/absolute-coordinate-ranges.dox
> > 
> > diff --git a/doc/Makefile.am b/doc/Makefile.am
> > index f2a47cb..1e501a8 100644
> > --- a/doc/Makefile.am
> > +++ b/doc/Makefile.am
> > @@ -11,6 +11,7 @@ header_files = \
> > $(top_srcdir)/src/libinput.h \
> > $(top_srcdir)/README.txt \
> > $(srcdir)/absolute-axes.dox \
> > +   $(srcdir)/absolute-coordinate-ranges.dox \
> > $(srcdir)/clickpad-softbuttons.dox \
> > $(srcdir)/device-configuration-via-udev.dox \
> > $(srcdir)/faqs.dox \
> > diff --git a/doc/absolute-coordinate-ranges.dox 
> > b/doc/absolute-coordinate-ranges.dox
> > new file mode 100644
> > index 000..f9d9e98
> > --- /dev/null
> > +++ b/doc/absolute-coordinate-ranges.dox
> > @@ -0,0 +1,120 @@
> > +/**
> > +@page absolute_coordinate_ranges Coordinate ranges for absolute axes
> > +
> > +libinput requires that all touchpads provide a correct axis range and
> > +resolution. These are used to enable or disable certain features or adapt
> > +the interaction with the touchpad. For example, the software button area is
> > +narrower on small touchpads to avoid reducing the interactive surface too
> > +much. Likewise, palm detection works differently on small touchpads as palm
> > +interference is less likely to happen.
> > +
> > +Touchpads with incorrect axis ranges generate error messages
> > +in the form:
> > +
> > +Axis 0x35 value 4000 is outside expected range [0, 3000]
> > +
> > +
> > +This error message indicates that the ABS_MT_POSITION_X axis (i.e. the x
> > +axis) generated an event outside the expected range of 0-3000. In this case
> > +the value was 4000.
> > +This discrepancy between the coordinate range the kernels advertises vs.
> > +what the touchpad sends can be the source of a number of perceived
> > +bugs in libinput.
> > +
> > +@section absolute_coordinate_ranges_fix Measuring and fixing touchpad 
> > ranges
> > +
> > +To fix the touchpad you need to:
> > +-# measure the physical size of your touchpad in mm
> > +-# run touchpad-edge-detector
> > +-# trim the udev match rule to something sensible
> > +-# replace the resolution with the calculated resolution based on physical
> > +  settings
> > +-# test locally
> > +-# send a patch to the systemd project
> > +
> > +Detailed explanations are below.
> > +
> > +[libevdev](http://freedesktop.org/wiki/Software/libevdev/) provides a tool
> > +called **touchpad-edge-detector** that allows measuring the touchpad's 
> > input
> > +ranges. Run the tool as root against the device node of your touchpad 
> > device
> > +and repeatedly move a finger around the whole outside area of the
> > +touchpad. Then control+c the process and note the output.
> > +An example output is below:
> > +
> > +@code
> > +$> sudo touchpad-edge-detector /dev/input/event4
> > +Touchpad SynPS/2 Synaptics TouchPad on /dev/input/event4
> > +Move one finger around the touchpad to detect the actual edges
> > +Kernel says:   x [1024..3112], y [2024..4832]
> > +Touchpad sends:x [2445..4252], y [3464..4071]
> > +
> > +Touchpad size as listed by the kernel: 49x66mm
> > +Calculate resolution as:
> > +   x axis: 2088/
> > +   y axis: 2808/
> > +
> > +Suggested udev rule:
> > +# 
> > +evdev:name:SynPS/2 Synaptics 
> > TouchPad:dmi:bvnLENOVO:bvrGJET72WW(2.22):bd02/21/2014:svnLENOVO:pn20ARS25701:pvrThinkPadT440s:rvnLENOVO:rn20ARS25701:rvrSDK0E50512STD:cvnLENOVO:ct10:cvrNotAvailable:*
> > + EVDEV_ABS_00=2445:4252:
> > + EVDEV_ABS_01=3464:4071:
> > + EVDEV_ABS_35=2445:4252:
> > + EVDEV_ABS_36=3464:4071:
> > +
> > +@endcode
> > +
> > +Note the discrepancy between the coordinate range the kernels advertises 
> > vs.
> > +what the touchpad sends.
> > +To fix the advertised ranges, the udev rule should be taken and trimmed
> > +before being sent to the [systemd 
> > project](https://github.com/systemd/systemd).
> > +An example commit can be found
> > +[here](https://github.com/systemd/systemd/commit/26f667eac1c5e89b689aa0a1daef6a80f473e045).
> > +
> > +In most cases the match can and should be trimmed to the 

Re: [PATCH libinput] touchpad: warn if we have invalid touchpad ranges

2016-06-01 Thread Yong Bakos
On May 31, 2016, at 7:42 PM, Peter Hutterer  wrote:
> 
> Quite a few bugs are caused by touchpad ranges being out of whack. If we get
> input events significantly outside the expected range (5% width/height as
> error margin) print a warning to the log.
> 
> And add a new doc page to explain what is happening and how to fix it.
> 
> Signed-off-by: Peter Hutterer 

Hi Peter,
FWIW, one minor nit (whildcard) I noticed, inline below.


> ---
> doc/Makefile.am|   1 +
> doc/absolute-coordinate-ranges.dox | 120 +
> doc/page-hierarchy.dox |   1 +
> src/evdev-mt-touchpad.c|  59 ++
> src/evdev-mt-touchpad.h|   5 ++
> 5 files changed, 186 insertions(+)
> create mode 100644 doc/absolute-coordinate-ranges.dox
> 
> diff --git a/doc/Makefile.am b/doc/Makefile.am
> index f2a47cb..1e501a8 100644
> --- a/doc/Makefile.am
> +++ b/doc/Makefile.am
> @@ -11,6 +11,7 @@ header_files = \
>   $(top_srcdir)/src/libinput.h \
>   $(top_srcdir)/README.txt \
>   $(srcdir)/absolute-axes.dox \
> + $(srcdir)/absolute-coordinate-ranges.dox \
>   $(srcdir)/clickpad-softbuttons.dox \
>   $(srcdir)/device-configuration-via-udev.dox \
>   $(srcdir)/faqs.dox \
> diff --git a/doc/absolute-coordinate-ranges.dox 
> b/doc/absolute-coordinate-ranges.dox
> new file mode 100644
> index 000..f9d9e98
> --- /dev/null
> +++ b/doc/absolute-coordinate-ranges.dox
> @@ -0,0 +1,120 @@
> +/**
> +@page absolute_coordinate_ranges Coordinate ranges for absolute axes
> +
> +libinput requires that all touchpads provide a correct axis range and
> +resolution. These are used to enable or disable certain features or adapt
> +the interaction with the touchpad. For example, the software button area is
> +narrower on small touchpads to avoid reducing the interactive surface too
> +much. Likewise, palm detection works differently on small touchpads as palm
> +interference is less likely to happen.
> +
> +Touchpads with incorrect axis ranges generate error messages
> +in the form:
> +
> +Axis 0x35 value 4000 is outside expected range [0, 3000]
> +
> +
> +This error message indicates that the ABS_MT_POSITION_X axis (i.e. the x
> +axis) generated an event outside the expected range of 0-3000. In this case
> +the value was 4000.
> +This discrepancy between the coordinate range the kernels advertises vs.
> +what the touchpad sends can be the source of a number of perceived
> +bugs in libinput.
> +
> +@section absolute_coordinate_ranges_fix Measuring and fixing touchpad ranges
> +
> +To fix the touchpad you need to:
> +-# measure the physical size of your touchpad in mm
> +-# run touchpad-edge-detector
> +-# trim the udev match rule to something sensible
> +-# replace the resolution with the calculated resolution based on physical
> +  settings
> +-# test locally
> +-# send a patch to the systemd project
> +
> +Detailed explanations are below.
> +
> +[libevdev](http://freedesktop.org/wiki/Software/libevdev/) provides a tool
> +called **touchpad-edge-detector** that allows measuring the touchpad's input
> +ranges. Run the tool as root against the device node of your touchpad device
> +and repeatedly move a finger around the whole outside area of the
> +touchpad. Then control+c the process and note the output.
> +An example output is below:
> +
> +@code
> +$> sudo touchpad-edge-detector /dev/input/event4
> +Touchpad SynPS/2 Synaptics TouchPad on /dev/input/event4
> +Move one finger around the touchpad to detect the actual edges
> +Kernel says: x [1024..3112], y [2024..4832]
> +Touchpad sends:  x [2445..4252], y [3464..4071]
> +
> +Touchpad size as listed by the kernel: 49x66mm
> +Calculate resolution as:
> + x axis: 2088/
> + y axis: 2808/
> +
> +Suggested udev rule:
> +# 
> +evdev:name:SynPS/2 Synaptics 
> TouchPad:dmi:bvnLENOVO:bvrGJET72WW(2.22):bd02/21/2014:svnLENOVO:pn20ARS25701:pvrThinkPadT440s:rvnLENOVO:rn20ARS25701:rvrSDK0E50512STD:cvnLENOVO:ct10:cvrNotAvailable:*
> + EVDEV_ABS_00=2445:4252:
> + EVDEV_ABS_01=3464:4071:
> + EVDEV_ABS_35=2445:4252:
> + EVDEV_ABS_36=3464:4071:
> +
> +@endcode
> +
> +Note the discrepancy between the coordinate range the kernels advertises vs.
> +what the touchpad sends.
> +To fix the advertised ranges, the udev rule should be taken and trimmed
> +before being sent to the [systemd 
> project](https://github.com/systemd/systemd).
> +An example commit can be found
> +[here](https://github.com/systemd/systemd/commit/26f667eac1c5e89b689aa0a1daef6a80f473e045).
> +
> +In most cases the match can and should be trimmed to the system vendor (svn)
> +and the product version (pvr), with everything else replaced by a wildcard
> +(*). In this case, a Lenovo T440s, a suitable match string would be: @code
> +evdev:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*pvrThinkPadT440s*
> +@endcode
> +
> +@note hwdb match strings only allow for alphanumeric ascii 

Re: [PATCH libinput] touchpad: warn if we have invalid touchpad ranges

2016-06-01 Thread Hans de Goede

Hi,

On 01-06-16 02:42, Peter Hutterer wrote:

Quite a few bugs are caused by touchpad ranges being out of whack. If we get
input events significantly outside the expected range (5% width/height as
error margin) print a warning to the log.

And add a new doc page to explain what is happening and how to fix it.

Signed-off-by: Peter Hutterer 


Looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
 doc/Makefile.am|   1 +
 doc/absolute-coordinate-ranges.dox | 120 +
 doc/page-hierarchy.dox |   1 +
 src/evdev-mt-touchpad.c|  59 ++
 src/evdev-mt-touchpad.h|   5 ++
 5 files changed, 186 insertions(+)
 create mode 100644 doc/absolute-coordinate-ranges.dox

diff --git a/doc/Makefile.am b/doc/Makefile.am
index f2a47cb..1e501a8 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -11,6 +11,7 @@ header_files = \
$(top_srcdir)/src/libinput.h \
$(top_srcdir)/README.txt \
$(srcdir)/absolute-axes.dox \
+   $(srcdir)/absolute-coordinate-ranges.dox \
$(srcdir)/clickpad-softbuttons.dox \
$(srcdir)/device-configuration-via-udev.dox \
$(srcdir)/faqs.dox \
diff --git a/doc/absolute-coordinate-ranges.dox 
b/doc/absolute-coordinate-ranges.dox
new file mode 100644
index 000..f9d9e98
--- /dev/null
+++ b/doc/absolute-coordinate-ranges.dox
@@ -0,0 +1,120 @@
+/**
+@page absolute_coordinate_ranges Coordinate ranges for absolute axes
+
+libinput requires that all touchpads provide a correct axis range and
+resolution. These are used to enable or disable certain features or adapt
+the interaction with the touchpad. For example, the software button area is
+narrower on small touchpads to avoid reducing the interactive surface too
+much. Likewise, palm detection works differently on small touchpads as palm
+interference is less likely to happen.
+
+Touchpads with incorrect axis ranges generate error messages
+in the form:
+
+Axis 0x35 value 4000 is outside expected range [0, 3000]
+
+
+This error message indicates that the ABS_MT_POSITION_X axis (i.e. the x
+axis) generated an event outside the expected range of 0-3000. In this case
+the value was 4000.
+This discrepancy between the coordinate range the kernels advertises vs.
+what the touchpad sends can be the source of a number of perceived
+bugs in libinput.
+
+@section absolute_coordinate_ranges_fix Measuring and fixing touchpad ranges
+
+To fix the touchpad you need to:
+-# measure the physical size of your touchpad in mm
+-# run touchpad-edge-detector
+-# trim the udev match rule to something sensible
+-# replace the resolution with the calculated resolution based on physical
+  settings
+-# test locally
+-# send a patch to the systemd project
+
+Detailed explanations are below.
+
+[libevdev](http://freedesktop.org/wiki/Software/libevdev/) provides a tool
+called **touchpad-edge-detector** that allows measuring the touchpad's input
+ranges. Run the tool as root against the device node of your touchpad device
+and repeatedly move a finger around the whole outside area of the
+touchpad. Then control+c the process and note the output.
+An example output is below:
+
+@code
+$> sudo touchpad-edge-detector /dev/input/event4
+Touchpad SynPS/2 Synaptics TouchPad on /dev/input/event4
+Move one finger around the touchpad to detect the actual edges
+Kernel says:   x [1024..3112], y [2024..4832]
+Touchpad sends:x [2445..4252], y [3464..4071]
+
+Touchpad size as listed by the kernel: 49x66mm
+Calculate resolution as:
+   x axis: 2088/
+   y axis: 2808/
+
+Suggested udev rule:
+# 
+evdev:name:SynPS/2 Synaptics 
TouchPad:dmi:bvnLENOVO:bvrGJET72WW(2.22):bd02/21/2014:svnLENOVO:pn20ARS25701:pvrThinkPadT440s:rvnLENOVO:rn20ARS25701:rvrSDK0E50512STD:cvnLENOVO:ct10:cvrNotAvailable:*
+ EVDEV_ABS_00=2445:4252:
+ EVDEV_ABS_01=3464:4071:
+ EVDEV_ABS_35=2445:4252:
+ EVDEV_ABS_36=3464:4071:
+
+@endcode
+
+Note the discrepancy between the coordinate range the kernels advertises vs.
+what the touchpad sends.
+To fix the advertised ranges, the udev rule should be taken and trimmed
+before being sent to the [systemd project](https://github.com/systemd/systemd).
+An example commit can be found
+[here](https://github.com/systemd/systemd/commit/26f667eac1c5e89b689aa0a1daef6a80f473e045).
+
+In most cases the match can and should be trimmed to the system vendor (svn)
+and the product version (pvr), with everything else replaced by a wildcard
+(*). In this case, a Lenovo T440s, a suitable match string would be: @code
+evdev:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*pvrThinkPadT440s*
+@endcode
+
+@note hwdb match strings only allow for alphanumeric ascii characters. Use a
+whildcard (* or ?, whichever appropriate) for special characters.
+
+The actual axis overrides are in the form:
+@code
+# axis number=min:max:resolution
+ EVDEV_ABS_00=2445:4252:42
+@endcode
+or, if the 

[PATCH libinput] touchpad: warn if we have invalid touchpad ranges

2016-05-31 Thread Peter Hutterer
Quite a few bugs are caused by touchpad ranges being out of whack. If we get
input events significantly outside the expected range (5% width/height as
error margin) print a warning to the log.

And add a new doc page to explain what is happening and how to fix it.

Signed-off-by: Peter Hutterer 
---
 doc/Makefile.am|   1 +
 doc/absolute-coordinate-ranges.dox | 120 +
 doc/page-hierarchy.dox |   1 +
 src/evdev-mt-touchpad.c|  59 ++
 src/evdev-mt-touchpad.h|   5 ++
 5 files changed, 186 insertions(+)
 create mode 100644 doc/absolute-coordinate-ranges.dox

diff --git a/doc/Makefile.am b/doc/Makefile.am
index f2a47cb..1e501a8 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -11,6 +11,7 @@ header_files = \
$(top_srcdir)/src/libinput.h \
$(top_srcdir)/README.txt \
$(srcdir)/absolute-axes.dox \
+   $(srcdir)/absolute-coordinate-ranges.dox \
$(srcdir)/clickpad-softbuttons.dox \
$(srcdir)/device-configuration-via-udev.dox \
$(srcdir)/faqs.dox \
diff --git a/doc/absolute-coordinate-ranges.dox 
b/doc/absolute-coordinate-ranges.dox
new file mode 100644
index 000..f9d9e98
--- /dev/null
+++ b/doc/absolute-coordinate-ranges.dox
@@ -0,0 +1,120 @@
+/**
+@page absolute_coordinate_ranges Coordinate ranges for absolute axes
+
+libinput requires that all touchpads provide a correct axis range and
+resolution. These are used to enable or disable certain features or adapt
+the interaction with the touchpad. For example, the software button area is
+narrower on small touchpads to avoid reducing the interactive surface too
+much. Likewise, palm detection works differently on small touchpads as palm
+interference is less likely to happen.
+
+Touchpads with incorrect axis ranges generate error messages
+in the form:
+
+Axis 0x35 value 4000 is outside expected range [0, 3000]
+
+
+This error message indicates that the ABS_MT_POSITION_X axis (i.e. the x
+axis) generated an event outside the expected range of 0-3000. In this case
+the value was 4000.
+This discrepancy between the coordinate range the kernels advertises vs.
+what the touchpad sends can be the source of a number of perceived
+bugs in libinput.
+
+@section absolute_coordinate_ranges_fix Measuring and fixing touchpad ranges
+
+To fix the touchpad you need to:
+-# measure the physical size of your touchpad in mm
+-# run touchpad-edge-detector
+-# trim the udev match rule to something sensible
+-# replace the resolution with the calculated resolution based on physical
+  settings
+-# test locally
+-# send a patch to the systemd project
+
+Detailed explanations are below.
+
+[libevdev](http://freedesktop.org/wiki/Software/libevdev/) provides a tool
+called **touchpad-edge-detector** that allows measuring the touchpad's input
+ranges. Run the tool as root against the device node of your touchpad device
+and repeatedly move a finger around the whole outside area of the
+touchpad. Then control+c the process and note the output.
+An example output is below:
+
+@code
+$> sudo touchpad-edge-detector /dev/input/event4
+Touchpad SynPS/2 Synaptics TouchPad on /dev/input/event4
+Move one finger around the touchpad to detect the actual edges
+Kernel says:   x [1024..3112], y [2024..4832]
+Touchpad sends:x [2445..4252], y [3464..4071]
+
+Touchpad size as listed by the kernel: 49x66mm
+Calculate resolution as:
+   x axis: 2088/
+   y axis: 2808/
+
+Suggested udev rule:
+# 
+evdev:name:SynPS/2 Synaptics 
TouchPad:dmi:bvnLENOVO:bvrGJET72WW(2.22):bd02/21/2014:svnLENOVO:pn20ARS25701:pvrThinkPadT440s:rvnLENOVO:rn20ARS25701:rvrSDK0E50512STD:cvnLENOVO:ct10:cvrNotAvailable:*
+ EVDEV_ABS_00=2445:4252:
+ EVDEV_ABS_01=3464:4071:
+ EVDEV_ABS_35=2445:4252:
+ EVDEV_ABS_36=3464:4071:
+
+@endcode
+
+Note the discrepancy between the coordinate range the kernels advertises vs.
+what the touchpad sends.
+To fix the advertised ranges, the udev rule should be taken and trimmed
+before being sent to the [systemd project](https://github.com/systemd/systemd).
+An example commit can be found
+[here](https://github.com/systemd/systemd/commit/26f667eac1c5e89b689aa0a1daef6a80f473e045).
+
+In most cases the match can and should be trimmed to the system vendor (svn)
+and the product version (pvr), with everything else replaced by a wildcard
+(*). In this case, a Lenovo T440s, a suitable match string would be: @code
+evdev:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*pvrThinkPadT440s*
+@endcode
+
+@note hwdb match strings only allow for alphanumeric ascii characters. Use a
+whildcard (* or ?, whichever appropriate) for special characters.
+
+The actual axis overrides are in the form:
+@code
+# axis number=min:max:resolution
+ EVDEV_ABS_00=2445:4252:42
+@endcode
+or, if the range is correct but the resolution is wrong
+@code
+# axis number=::resolution
+ EVDEV_ABS_00=::42
+@endcode
+
+Note the leading single