HID: wacom: Sync INTUOSP2_BT touch state after each frame if necessary [Linux 4.14.128]

HID: wacom: Sync INTUOSP2_BT touch state after each frame if necessary [Linux 4.14.128]

This Linux kernel change "HID: wacom: Sync INTUOSP2_BT touch state after each frame if necessary" is included in the Linux 4.14.128 release. This change is authored by Jason Gerecke <jason.gerecke [at] wacom.com> on Tue May 7 11:53:22 2019 -0700. The commit for this change in Linux stable tree is 3e5a7e1 (patch) which is from upstream commit 69dbdff. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 69dbdff.

HID: wacom: Sync INTUOSP2_BT touch state after each frame if necessary

commit 69dbdfffef20c715df9f381b2cee4e9e0a4efd93 upstream.

The Bluetooth interface of the 2nd-gen Intuos Pro batches together four
independent "frames" of finger data into a single report. Each frame
is essentially equivalent to a single USB report, with the up-to-10
fingers worth of information being spread across two frames. At the
moment the driver only calls `input_sync` after processing all four
frames have been processed, which can result in the driver sending
multiple updates for a single slot within the same SYN_REPORT. This
can confuse userspace, so modify the driver to sync more often if
necessary (i.e., after reporting the state of all fingers).

Fixes: 4922cd26f03c ("HID: wacom: Support 2nd-gen Intuos Pro's Bluetooth classic interface")
Cc: <stable@vger.kernel.org> # 4.11+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

There are 10 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/hid/wacom_wac.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index b6b39eb..22e8068 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1328,11 +1328,17 @@ static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
        if (wacom->num_contacts_left <= 0) {
            wacom->num_contacts_left = 0;
            wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
+           input_sync(touch_input);
        }
    }

-   input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
-   input_sync(touch_input);
+   if (wacom->num_contacts_left == 0) {
+       // Be careful that we don't accidentally call input_sync with
+       // only a partial set of fingers of processed
+       input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
+       input_sync(touch_input);
+   }
+
 }

 static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)

Leave a Reply

Your email address will not be published. Required fields are marked *