Message ID | 29ad484c1b357fd7fd670a6f252d097677b808f8.1530402641.git.joeypabalinas@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Joey, On Sun, Jul 1, 2018 at 2:19 AM, Joey Pabalinas <joeypabalinas@gmail.com> wrote: > Avoid processing reports containing invalid values to reduce > multitouch input stutter. > > Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com> > > 1 file changed, 9 insertions(+) > > diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c > index c0654db0b736543ca0..08b50e5908cecdda66 100644 > --- a/drivers/hid/hid-multitouch.c > +++ b/drivers/hid/hid-multitouch.c > @@ -694,10 +694,19 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) > { > if ((td->mtclass.quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && > td->num_received >= td->num_expected) > return; > > + /* drop invalid values after counting them */ > + if (td->curdata.x == 0xffff && > + td->curdata.y == 0xffff && > + td->curdata.w == 0xffff && > + td->curdata.h == 0xffff) { You can't really use plain values like that. There is a tiny chance these values are valid on an other device. IIRC, MS spec says that we should ignore out of band values if they are tagged as such. Such input are tagged with NULL values (http://www.usb.org/developers/hidpage/HID1_11.pdf page 31) and MS spec mentioned this. All in all, if you have this bit set, you need to compare the value with the logical_max/min for each field. I never encountered a device that required this, so you are probably the lucky one :) Cheers, Benjamin > + td->num_received++; > + return; > + } > + > if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { > int active; > int slotnum = mt_compute_slot(td, input); > struct mt_slot *s = &td->curdata; > struct input_mt *mt = input->mt; > -- > 2.18.0 > -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Jul 03, 2018 at 10:13:54AM +0200, Benjamin Tissoires wrote: > Hi Joey, > You can't really use plain values like that. There is a tiny chance > these values are valid on an other device. > IIRC, MS spec says that we should ignore out of band values if they > are tagged as such. Such input are tagged with NULL values > (http://www.usb.org/developers/hidpage/HID1_11.pdf page 31) and MS > spec mentioned this. > > All in all, if you have this bit set, you need to compare the value > with the logical_max/min for each field. > > I never encountered a device that required this, so you are probably > the lucky one :) Ah, you are completely right. After giving that pdf a read over I will definitely be dropping this patch from the v2.
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index c0654db0b736543ca0..08b50e5908cecdda66 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -694,10 +694,19 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) { if ((td->mtclass.quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && td->num_received >= td->num_expected) return; + /* drop invalid values after counting them */ + if (td->curdata.x == 0xffff && + td->curdata.y == 0xffff && + td->curdata.w == 0xffff && + td->curdata.h == 0xffff) { + td->num_received++; + return; + } + if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { int active; int slotnum = mt_compute_slot(td, input); struct mt_slot *s = &td->curdata; struct input_mt *mt = input->mt;
Avoid processing reports containing invalid values to reduce multitouch input stutter. Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com> 1 file changed, 9 insertions(+)