hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/hid/wacom_sys.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * drivers/input/tablet/wacom_sys.c
34 *
....@@ -5,10 +6,6 @@
56 */
67
78 /*
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
129 */
1310
1411 #include "wacom_wac.h"
....@@ -250,6 +247,38 @@
250247 field->usage[i-1].hid == HID_DG_INVERT &&
251248 field->usage[i+1].hid == HID_DG_INRANGE) {
252249 usage->hid = HID_DG_BARRELSWITCH2;
250
+ }
251
+ }
252
+
253
+ /*
254
+ * Wacom's AES devices use different vendor-defined usages to
255
+ * report serial number information compared to their branded
256
+ * hardware. The usages are also sometimes ill-defined and do
257
+ * not have the correct logical min/max values set. Lets patch
258
+ * the descriptor to use the branded usage convention and fix
259
+ * the errors.
260
+ */
261
+ if (usage->hid == WACOM_HID_WT_SERIALNUMBER &&
262
+ field->report_size == 16 &&
263
+ field->index + 2 < field->report->maxfield) {
264
+ struct hid_field *a = field->report->field[field->index + 1];
265
+ struct hid_field *b = field->report->field[field->index + 2];
266
+
267
+ if (a->maxusage > 0 &&
268
+ a->usage[0].hid == HID_DG_TOOLSERIALNUMBER &&
269
+ a->report_size == 32 &&
270
+ b->maxusage > 0 &&
271
+ b->usage[0].hid == 0xFF000000 &&
272
+ b->report_size == 8) {
273
+ features->quirks |= WACOM_QUIRK_AESPEN;
274
+ usage->hid = WACOM_HID_WD_TOOLTYPE;
275
+ field->logical_minimum = S16_MIN;
276
+ field->logical_maximum = S16_MAX;
277
+ a->logical_minimum = S32_MIN;
278
+ a->logical_maximum = S32_MAX;
279
+ b->usage[0].hid = WACOM_HID_WD_SERIALHI;
280
+ b->logical_minimum = 0;
281
+ b->logical_maximum = U8_MAX;
253282 }
254283 }
255284
....@@ -2095,7 +2124,7 @@
20952124
20962125 error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
20972126 if (error) {
2098
- /* no pad in use on this interface */
2127
+ /* no pad events using this interface */
20992128 input_free_device(pad_input_dev);
21002129 wacom_wac->pad_input = NULL;
21012130 pad_input_dev = NULL;
....@@ -2725,14 +2754,12 @@
27252754 wacom_wac->features = *((struct wacom_features *)id->driver_data);
27262755 features = &wacom_wac->features;
27272756
2728
- if (features->check_for_hid_type && features->hid_type != hdev->type) {
2729
- error = -ENODEV;
2730
- goto fail;
2731
- }
2757
+ if (features->check_for_hid_type && features->hid_type != hdev->type)
2758
+ return -ENODEV;
27322759
27332760 error = wacom_devm_kfifo_alloc(wacom);
27342761 if (error)
2735
- goto fail;
2762
+ return error;
27362763
27372764 wacom_wac->hid_data.inputmode = -1;
27382765 wacom_wac->mode_report = -1;
....@@ -2756,12 +2783,12 @@
27562783 error = hid_parse(hdev);
27572784 if (error) {
27582785 hid_err(hdev, "parse failed\n");
2759
- goto fail;
2786
+ return error;
27602787 }
27612788
27622789 error = wacom_parse_and_register(wacom, false);
27632790 if (error)
2764
- goto fail;
2791
+ return error;
27652792
27662793 if (hdev->bus == BUS_BLUETOOTH) {
27672794 error = device_create_file(&hdev->dev, &dev_attr_speed);
....@@ -2772,10 +2799,6 @@
27722799 }
27732800
27742801 return 0;
2775
-
2776
-fail:
2777
- hid_set_drvdata(hdev, NULL);
2778
- return error;
27792802 }
27802803
27812804 static void wacom_remove(struct hid_device *hdev)
....@@ -2802,8 +2825,6 @@
28022825
28032826 if (wacom->wacom_wac.features.type != REMOTE)
28042827 wacom_release_resources(wacom);
2805
-
2806
- hid_set_drvdata(hdev, NULL);
28072828 }
28082829
28092830 #ifdef CONFIG_PM