aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2017-09-07 20:44:12 -0400
committerJiri Kosina <jkosina@suse.cz>2017-09-13 13:14:48 -0400
commit993f0d93f8538c15bd5c12a1a9fd74c777efea1b (patch)
tree37077326f2af2b15120daa0afdaea067324f94b7
parent8320caeeffdefec3b58b9d4a7ed8e1079492fe7b (diff)
HID: wacom: generic: Send MSC_SERIAL and ABS_MISC when leaving prox
The latest generation of pro devices (MobileStudio Pro, 2nd-gen Intuos Pro, Cintiq Pro) send a serial number of '0' whenever the pen is too far away for reliable communication. Userspace defines that a serial number of '0' is invalid, so we need to be careful not to actually forward this value. Additionally, since EMR ISDv4 devices do not support serial numbers or tool IDs, we'd like to not send these events if they aren't necessary. The existing code achieves these goals by adding a check for a non-zero serial number within the wacom_wac_pen_report function. The MSC_SERIAL and ABS_MISC events are only sent if the serial number is non-zero. This code fails, however when the pen for a pro device leaves proximity. When the pen leaves prox and the tablet sends a serial of 0, wacom_wac_pen_event dutifully clears the serial number. When wacom_wac_pen_report is called, it does not send either the MSC_SERIAL of the exiting tool nor an ABS_MISC event. This patch prevents the wacom_wac_pen_event function from clearing an already-set serial number. This ensures that we have the serial number handy when exiting proximity, but requires us to manually clear it afterwards to ensure the driver does not send stale data (e.g. when switching between AES pens that report a serial nubmer of 0 for the first few fully in-proximity packets). Fixes: f85c9dc678 ("HID: wacom: generic: Support tool ID and additional tool types") Cc: stable # v4.10 <stable@vger.kernel.org> Signed-off-by: Ping Cheng <ping.cheng@wacom.com> Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/wacom_wac.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 78d0398904dc..e2ba36da6e20 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2141,8 +2141,10 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
2141 wacom_wac->hid_data.tipswitch |= value; 2141 wacom_wac->hid_data.tipswitch |= value;
2142 return; 2142 return;
2143 case HID_DG_TOOLSERIALNUMBER: 2143 case HID_DG_TOOLSERIALNUMBER:
2144 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); 2144 if (value) {
2145 wacom_wac->serial[0] |= (__u32)value; 2145 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
2146 wacom_wac->serial[0] |= (__u32)value;
2147 }
2146 return; 2148 return;
2147 case HID_DG_TWIST: 2149 case HID_DG_TWIST:
2148 /* 2150 /*
@@ -2156,15 +2158,17 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
2156 wacom_wac->hid_data.sense_state = value; 2158 wacom_wac->hid_data.sense_state = value;
2157 return; 2159 return;
2158 case WACOM_HID_WD_SERIALHI: 2160 case WACOM_HID_WD_SERIALHI:
2159 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF); 2161 if (value) {
2160 wacom_wac->serial[0] |= ((__u64)value) << 32; 2162 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2161 /* 2163 wacom_wac->serial[0] |= ((__u64)value) << 32;
2162 * Non-USI EMR devices may contain additional tool type 2164 /*
2163 * information here. See WACOM_HID_WD_TOOLTYPE case for 2165 * Non-USI EMR devices may contain additional tool type
2164 * more details. 2166 * information here. See WACOM_HID_WD_TOOLTYPE case for
2165 */ 2167 * more details.
2166 if (value >> 20 == 1) { 2168 */
2167 wacom_wac->id[0] |= value & 0xFFFFF; 2169 if (value >> 20 == 1) {
2170 wacom_wac->id[0] |= value & 0xFFFFF;
2171 }
2168 } 2172 }
2169 return; 2173 return;
2170 case WACOM_HID_WD_TOOLTYPE: 2174 case WACOM_HID_WD_TOOLTYPE:
@@ -2279,6 +2283,7 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
2279 if (!prox) { 2283 if (!prox) {
2280 wacom_wac->tool[0] = 0; 2284 wacom_wac->tool[0] = 0;
2281 wacom_wac->id[0] = 0; 2285 wacom_wac->id[0] = 0;
2286 wacom_wac->serial[0] = 0;
2282 } 2287 }
2283} 2288}
2284 2289