aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJiri Kosina2022-05-24 10:59:51 +0200
committerJiri Kosina2022-05-24 10:59:51 +0200
commit07d17217c668d5b9974572b2d69c6736f60b9925 (patch)
tree7ca1c06a76b2be32bc5addf9c4d7e9aad4a963af /drivers
parent2e688e654f48dde6e5899ff62cdf7b2d87f4ad89 (diff)
parentd88591a555325f6f0ec1f28c5fe2c7f2383a4366 (diff)
Merge branch 'for-5.19/wacom' into for-linus
- support for pens with 3 buttons (Joshua Dickens) - support for HID_DG_SCANTIME to report the timestamp for pen and touch events (Joshua Dickens)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/wacom_sys.c2
-rw-r--r--drivers/hid/wacom_wac.c43
-rw-r--r--drivers/hid/wacom_wac.h5
3 files changed, 41 insertions, 9 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 066c567dbaa2..620fe74f5676 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1777,7 +1777,7 @@ static int __wacom_initialize_battery(struct wacom *wacom,
bat_desc->get_property = wacom_battery_get_property;
sprintf(battery->bat_name, "wacom_battery_%ld", n);
bat_desc->name = battery->bat_name;
- bat_desc->type = POWER_SUPPLY_TYPE_USB;
+ bat_desc->type = POWER_SUPPLY_TYPE_BATTERY;
bat_desc->use_for_apm = 0;
ps_bat = devm_power_supply_register(dev, bat_desc, &psy_cfg);
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index a7176fc0635d..9470c2b0b529 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1811,7 +1811,9 @@ int wacom_equivalent_usage(int usage)
usage == WACOM_HID_WD_TOUCHSTRIP2 ||
usage == WACOM_HID_WD_TOUCHRING ||
usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
- usage == WACOM_HID_WD_REPORT_VALID) {
+ usage == WACOM_HID_WD_REPORT_VALID ||
+ usage == WACOM_HID_WD_BARRELSWITCH3 ||
+ usage == WACOM_HID_WD_SEQUENCENUMBER) {
return usage;
}
@@ -2196,8 +2198,11 @@ static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
if (!(features->quirks & WACOM_QUIRK_AESPEN) &&
wacom_wac->hid_data.barrelswitch &&
wacom_wac->hid_data.barrelswitch2 &&
- wacom_wac->hid_data.serialhi)
+ wacom_wac->hid_data.serialhi &&
+ !wacom_wac->hid_data.barrelswitch3) {
input_set_capability(input, EV_KEY, BTN_STYLUS3);
+ features->quirks |= WACOM_QUIRK_PEN_BUTTON3;
+ }
}
static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
@@ -2261,6 +2266,9 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
features->quirks |= WACOM_QUIRK_TOOLSERIAL;
wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
break;
+ case HID_DG_SCANTIME:
+ wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
+ break;
case WACOM_HID_WD_SENSE:
features->quirks |= WACOM_QUIRK_SENSE;
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
@@ -2274,6 +2282,11 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
break;
+ case WACOM_HID_WD_BARRELSWITCH3:
+ wacom_wac->hid_data.barrelswitch3 = true;
+ wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS3, 0);
+ features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3;
+ break;
}
}
@@ -2390,6 +2403,14 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
case WACOM_HID_WD_REPORT_VALID:
wacom_wac->is_invalid_bt_frame = !value;
return;
+ case WACOM_HID_WD_BARRELSWITCH3:
+ wacom_wac->hid_data.barrelswitch3 = value;
+ return;
+ case WACOM_HID_WD_SEQUENCENUMBER:
+ if (wacom_wac->hid_data.sequence_number != value)
+ hid_warn(hdev, "Dropped %hu packets", (unsigned short)(value - wacom_wac->hid_data.sequence_number));
+ wacom_wac->hid_data.sequence_number = value + 1;
+ return;
}
/* send pen events only when touch is up or forced out
@@ -2442,12 +2463,15 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
int id = wacom_wac->id[0];
- int sw_state = wacom_wac->hid_data.barrelswitch |
- (wacom_wac->hid_data.barrelswitch2 << 1);
-
- input_report_key(input, BTN_STYLUS, sw_state == 1);
- input_report_key(input, BTN_STYLUS2, sw_state == 2);
- input_report_key(input, BTN_STYLUS3, sw_state == 3);
+ if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3 &&
+ wacom_wac->hid_data.barrelswitch & wacom_wac->hid_data.barrelswitch2) {
+ wacom_wac->hid_data.barrelswitch = 0;
+ wacom_wac->hid_data.barrelswitch2 = 0;
+ wacom_wac->hid_data.barrelswitch3 = 1;
+ }
+ input_report_key(input, BTN_STYLUS, wacom_wac->hid_data.barrelswitch);
+ input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2);
+ input_report_key(input, BTN_STYLUS3, wacom_wac->hid_data.barrelswitch3);
/*
* Non-USI EMR tools should have their IDs mangled to
@@ -2529,6 +2553,9 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
field->logical_maximum = 255;
}
break;
+ case HID_DG_SCANTIME:
+ wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
+ break;
}
}
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 466b62cc16dc..fef1538005b5 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -86,6 +86,7 @@
#define WACOM_QUIRK_AESPEN 0x0004
#define WACOM_QUIRK_BATTERY 0x0008
#define WACOM_QUIRK_TOOLSERIAL 0x0010
+#define WACOM_QUIRK_PEN_BUTTON3 0x0020
/* device types */
#define WACOM_DEVICETYPE_NONE 0x0000
@@ -108,6 +109,7 @@
#define WACOM_HID_WD_DIGITIZERFNKEYS (WACOM_HID_UP_WACOMDIGITIZER | 0x39)
#define WACOM_HID_WD_SERIALNUMBER (WACOM_HID_UP_WACOMDIGITIZER | 0x5b)
#define WACOM_HID_WD_SERIALHI (WACOM_HID_UP_WACOMDIGITIZER | 0x5c)
+#define WACOM_HID_WD_BARRELSWITCH3 (WACOM_HID_UP_WACOMDIGITIZER | 0x5d)
#define WACOM_HID_WD_TOOLTYPE (WACOM_HID_UP_WACOMDIGITIZER | 0x77)
#define WACOM_HID_WD_DISTANCE (WACOM_HID_UP_WACOMDIGITIZER | 0x0132)
#define WACOM_HID_WD_TOUCHSTRIP (WACOM_HID_UP_WACOMDIGITIZER | 0x0136)
@@ -115,6 +117,7 @@
#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_SEQUENCENUMBER (WACOM_HID_UP_WACOMDIGITIZER | 0x0220)
#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)
@@ -300,6 +303,7 @@ struct hid_data {
bool tipswitch;
bool barrelswitch;
bool barrelswitch2;
+ bool barrelswitch3;
bool serialhi;
bool confidence;
int x;
@@ -320,6 +324,7 @@ struct hid_data {
int bat_connected;
int ps_connected;
bool pad_input_event_flag;
+ unsigned short sequence_number;
};
struct wacom_remote_data {