Wacom Bluetooth reports contain multiple pen frames per report.
Each frame contains a flag indicating if the frame is valid.
Future Wacom devices with this type of report may contain HID
descriptors, add support for this usage to the generic codepath
of the Wacom driver.

Signed-off-by: Aaron Armstrong Skomra <sko...@gmail.com>
Reviewed-by: Ping Cheng <ping.ch...@wacom.com>
Reviewed-by: Jason Gerecke <jason.gere...@wacom.com>
Signed-off-by: Jiri Kosina <jkos...@suse.cz>
[aaron.sko...@wacom.com: Imported into input-wacom repository (b1f466a90c51)]
Signed-off-by: Aaron Armstrong Skomra <aaron.sko...@wacom.com>
---
 4.5/wacom_wac.c | 16 +++++++++++++++-
 4.5/wacom_wac.h |  3 ++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/4.5/wacom_wac.c b/4.5/wacom_wac.c
index af73965d15bf..6e06e583bd28 100644
--- a/4.5/wacom_wac.c
+++ b/4.5/wacom_wac.c
@@ -1719,7 +1719,8 @@ int wacom_equivalent_usage(int usage)
                    usage == WACOM_HID_WD_TOUCHSTRIP ||
                    usage == WACOM_HID_WD_TOUCHSTRIP2 ||
                    usage == WACOM_HID_WD_TOUCHRING ||
-                   usage == WACOM_HID_WD_TOUCHRINGSTATUS) {
+                   usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
+                   usage == WACOM_HID_WD_REPORT_VALID) {
                        return usage;
                }
 
@@ -2208,6 +2209,9 @@ static void wacom_wac_pen_event(struct hid_device *hdev, 
struct hid_field *field
        struct input_dev *input = wacom_wac->pen_input;
        unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
 
+       if (wacom_wac->is_invalid_bt_frame)
+               return;
+
        switch (equivalent_usage) {
        case HID_GD_Z:
                /*
@@ -2304,6 +2308,9 @@ static void wacom_wac_pen_event(struct hid_device *hdev, 
struct hid_field *field
                                 features->offset_bottom);
                features->offset_bottom = value;
                return;
+       case WACOM_HID_WD_REPORT_VALID:
+               wacom_wac->is_invalid_bt_frame = !value;
+               return;
        }
 
        /* send pen events only when touch is up or forced out
@@ -2322,6 +2329,10 @@ static void wacom_wac_pen_event(struct hid_device *hdev, 
struct hid_field *field
 static void wacom_wac_pen_pre_report(struct hid_device *hdev,
                struct hid_report *report)
 {
+       struct wacom *wacom = hid_get_drvdata(hdev);
+       struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+
+       wacom_wac->is_invalid_bt_frame = false;
        return;
 }
 
@@ -2334,6 +2345,9 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
        bool range = wacom_wac->hid_data.inrange_state;
        bool sense = wacom_wac->hid_data.sense_state;
 
+       if (wacom_wac->is_invalid_bt_frame)
+               return;
+
        if (!wacom_wac->tool[0] && range) { /* first in range */
                /* Going into range select tool */
                if (wacom_wac->hid_data.invert_state)
diff --git a/4.5/wacom_wac.h b/4.5/wacom_wac.h
index 6e86392b49dc..783c45ce53ac 100644
--- a/4.5/wacom_wac.h
+++ b/4.5/wacom_wac.h
@@ -138,6 +138,7 @@
 #define WACOM_HID_WD_TOUCHSTRIP2        (WACOM_HID_UP_WACOMDIGITIZER | 0x0137)
 #define WACOM_HID_WD_TOUCHRING          (WACOM_HID_UP_WACOMDIGITIZER | 0x0138)
 #define WACOM_HID_WD_TOUCHRINGSTATUS    (WACOM_HID_UP_WACOMDIGITIZER | 0x0139)
+#define WACOM_HID_WD_REPORT_VALID       (WACOM_HID_UP_WACOMDIGITIZER | 0x01d0)
 #define WACOM_HID_WD_ACCELEROMETER_X    (WACOM_HID_UP_WACOMDIGITIZER | 0x0401)
 #define WACOM_HID_WD_ACCELEROMETER_Y    (WACOM_HID_UP_WACOMDIGITIZER | 0x0402)
 #define WACOM_HID_WD_ACCELEROMETER_Z    (WACOM_HID_UP_WACOMDIGITIZER | 0x0403)
@@ -373,7 +374,7 @@ struct wacom_wac {
        bool has_mute_touch_switch;
        bool has_mode_change;
        bool is_direct_mode;
-
+       bool is_invalid_bt_frame;
 };
 
 #endif
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to