• Linus Walleij's avatar
    Input: zinitix - do not report shadow fingers · e941dc13
    Linus Walleij authored
    I observed the following problem with the BT404 touch pad
    running the Phosh UI:
    
    When e.g. typing on the virtual keyboard pressing "g" would
    produce "ggg".
    
    After some analysis it turns out the firmware reports that three
    fingers hit that coordinate at the same time, finger 0, 2 and
    4 (of the five available 0,1,2,3,4).
    
    DOWN
      Zinitix-TS 3-0020: finger 0 down (246, 395)
      Zinitix-TS 3-0020: finger 1 up (0, 0)
      Zinitix-TS 3-0020: finger 2 down (246, 395)
      Zinitix-TS 3-0020: finger 3 up (0, 0)
      Zinitix-TS 3-0020: finger 4 down (246, 395)
    UP
      Zinitix-TS 3-0020: finger 0 up (246, 395)
      Zinitix-TS 3-0020: finger 2 up (246, 395)
      Zinitix-TS 3-0020: finger 4 up (246, 395)
    
    This is one touch and release: i.e. this is all reported on
    touch (down) and release.
    
    There is a field in the struct touch_event called finger_cnt
    which is actually a bitmask of the fingers active in the
    event.
    
    Rename this field finger_mask as this matches the use contents
    better, then use for_each_set_bit() to iterate over just the
    fingers that are actally active.
    
    Factor out a finger reporting function zinitix_report_fingers()
    to handle all fingers.
    
    Also be more careful in reporting finger down/up: we were
    reporting every event with input_mt_report_slot_state(..., true);
    but this should only be reported on finger down or move,
    not on finger up, so also add code to check p->sub_status
    to see what is happening and report correctly.
    
    After this my Zinitix BT404 touchscreen report fingers
    flawlessly.
    
    The vendor drive I have notably does not use the "finger_cnt"
    and contains obviously incorrect code like this:
    
      if (touch_dev->touch_info.finger_cnt > MAX_SUPPORTED_FINGER_NUM)
          touch_dev->touch_info.finger_cnt = MAX_SUPPORTED_FINGER_NUM;
    
    As MAX_SUPPORTED_FINGER_NUM is an ordinal and the field is
    a bitmask this seems quite confused.
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Link: https://lore.kernel.org/r/20220228233017.2270599-1-linus.walleij@linaro.orgSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
    e941dc13
zinitix.c 15.1 KB