Skip to content
  • Paul Cercueil's avatar
    Input: goodix - poll the 'buffer status' bit before reading data · 9b5db7aa
    Paul Cercueil authored
    The Goodix panel triggers an interrupt on touch events. However, its
    registers will contain the valid values a short time after the
    interrupt, and not when it's raised. At that moment, the 'buffer status'
    bit is set.
    
    Previously, if the 'buffer status' bit was not set when the registers
    were read, the data was discarded and no input event was emitted,
    causing "finger down" or "finger up" events to be missed sometimes.
    
    This went unnoticed until v4.9, as the DesignWare I2C driver commonly
    used with this driver had enough latency for that bug to never trigger
    until commit 2702ea7d
    
     ("i2c: designware: wait for disable/enable only
    if necessary").
    
    Now, in the IRQ handler we will poll (with a timeout) the 'buffer status'
    bit and process the data of the panel as soon as this bit gets set.
    
    Note that the Goodix panel will send a few spurious interrupts after the
    'finger up' event, in which the 'buffer status' bit will never be set.
    
    Cc: Bastien Nocera <hadess@hadess.net>
    Cc: russianneuromancer@ya.ru
    Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
    [hdegoede@redhat.com: Change poll loop to use jiffies,
                          add comment about typical poll time]
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    [dtor: rearranged control flow a bit to avoid explicit goto and double
    check]
    Reviewed-by: default avatarBastien Nocera <hadess@hadess.net>
    Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
    9b5db7aa