aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2018-08-20 12:12:42 -0400
committerJiri Kosina <jkosina@suse.cz>2018-08-20 12:12:42 -0400
commitffbeeaa460a500e640aeb0f4e91311d2ca02ba72 (patch)
tree4f1de195c8aa62908a2bfbda8dca70e92c20f434
parenta91ddf23e2400140382e08eca03786c6e948af86 (diff)
parent418b573b431310306db31e445594317ba62f5508 (diff)
Merge branch 'for-4.19/wacom' into for-linus
Wacom driver updates: - touch_max detection improvements - quirk handling cleanup - get rid of wacom custom usages
-rw-r--r--drivers/hid/wacom_sys.c105
-rw-r--r--drivers/hid/wacom_wac.c20
2 files changed, 66 insertions, 59 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index ffe59a19b3a3..0bdd85d486fe 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -210,6 +210,57 @@ static int wacom_calc_hid_res(int logical_extents, int physical_extents,
210 return hidinput_calc_abs_res(&field, ABS_X); 210 return hidinput_calc_abs_res(&field, ABS_X);
211} 211}
212 212
213static void wacom_hid_usage_quirk(struct hid_device *hdev,
214 struct hid_field *field, struct hid_usage *usage)
215{
216 struct wacom *wacom = hid_get_drvdata(hdev);
217 struct wacom_features *features = &wacom->wacom_wac.features;
218 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
219
220 /*
221 * The Dell Canvas 27 needs to be switched to its vendor-defined
222 * report to provide the best resolution.
223 */
224 if (hdev->vendor == USB_VENDOR_ID_WACOM &&
225 hdev->product == 0x4200 &&
226 field->application == HID_UP_MSVENDOR) {
227 wacom->wacom_wac.mode_report = field->report->id;
228 wacom->wacom_wac.mode_value = 2;
229 }
230
231 /*
232 * ISDv4 devices which predate HID's adoption of the
233 * HID_DG_BARELSWITCH2 usage use 0x000D0000 in its
234 * position instead. We can accurately detect if a
235 * usage with that value should be HID_DG_BARRELSWITCH2
236 * based on the surrounding usages, which have remained
237 * constant across generations.
238 */
239 if (features->type == HID_GENERIC &&
240 usage->hid == 0x000D0000 &&
241 field->application == HID_DG_PEN &&
242 field->physical == HID_DG_STYLUS) {
243 int i = usage->usage_index;
244
245 if (i-4 >= 0 && i+1 < field->maxusage &&
246 field->usage[i-4].hid == HID_DG_TIPSWITCH &&
247 field->usage[i-3].hid == HID_DG_BARRELSWITCH &&
248 field->usage[i-2].hid == HID_DG_ERASER &&
249 field->usage[i-1].hid == HID_DG_INVERT &&
250 field->usage[i+1].hid == HID_DG_INRANGE) {
251 usage->hid = HID_DG_BARRELSWITCH2;
252 }
253 }
254
255 /* 2nd-generation Intuos Pro Large has incorrect Y maximum */
256 if (hdev->vendor == USB_VENDOR_ID_WACOM &&
257 hdev->product == 0x0358 &&
258 WACOM_PEN_FIELD(field) &&
259 equivalent_usage == HID_GD_Y) {
260 field->logical_maximum = 43200;
261 }
262}
263
213static void wacom_feature_mapping(struct hid_device *hdev, 264static void wacom_feature_mapping(struct hid_device *hdev,
214 struct hid_field *field, struct hid_usage *usage) 265 struct hid_field *field, struct hid_usage *usage)
215{ 266{
@@ -221,6 +272,8 @@ static void wacom_feature_mapping(struct hid_device *hdev,
221 int ret; 272 int ret;
222 u32 n; 273 u32 n;
223 274
275 wacom_hid_usage_quirk(hdev, field, usage);
276
224 switch (equivalent_usage) { 277 switch (equivalent_usage) {
225 case HID_DG_CONTACTMAX: 278 case HID_DG_CONTACTMAX:
226 /* leave touch_max as is if predefined */ 279 /* leave touch_max as is if predefined */
@@ -300,13 +353,6 @@ static void wacom_feature_mapping(struct hid_device *hdev,
300 kfree(data); 353 kfree(data);
301 break; 354 break;
302 } 355 }
303
304 if (hdev->vendor == USB_VENDOR_ID_WACOM &&
305 hdev->product == 0x4200 /* Dell Canvas 27 */ &&
306 field->application == HID_UP_MSVENDOR) {
307 wacom->wacom_wac.mode_report = field->report->id;
308 wacom->wacom_wac.mode_value = 2;
309 }
310} 356}
311 357
312/* 358/*
@@ -348,6 +394,7 @@ static void wacom_usage_mapping(struct hid_device *hdev,
348 struct wacom_features *features = &wacom->wacom_wac.features; 394 struct wacom_features *features = &wacom->wacom_wac.features;
349 bool finger = WACOM_FINGER_FIELD(field); 395 bool finger = WACOM_FINGER_FIELD(field);
350 bool pen = WACOM_PEN_FIELD(field); 396 bool pen = WACOM_PEN_FIELD(field);
397 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
351 398
352 /* 399 /*
353 * Requiring Stylus Usage will ignore boot mouse 400 * Requiring Stylus Usage will ignore boot mouse
@@ -361,49 +408,9 @@ static void wacom_usage_mapping(struct hid_device *hdev,
361 else 408 else
362 return; 409 return;
363 410
364 /* 411 wacom_hid_usage_quirk(hdev, field, usage);
365 * Bamboo models do not support HID_DG_CONTACTMAX.
366 * And, Bamboo Pen only descriptor contains touch.
367 */
368 if (features->type > BAMBOO_PT) {
369 /* ISDv4 touch devices at least supports one touch point */
370 if (finger && !features->touch_max)
371 features->touch_max = 1;
372 }
373
374 /*
375 * ISDv4 devices which predate HID's adoption of the
376 * HID_DG_BARELSWITCH2 usage use 0x000D0000 in its
377 * position instead. We can accurately detect if a
378 * usage with that value should be HID_DG_BARRELSWITCH2
379 * based on the surrounding usages, which have remained
380 * constant across generations.
381 */
382 if (features->type == HID_GENERIC &&
383 usage->hid == 0x000D0000 &&
384 field->application == HID_DG_PEN &&
385 field->physical == HID_DG_STYLUS) {
386 int i = usage->usage_index;
387
388 if (i-4 >= 0 && i+1 < field->maxusage &&
389 field->usage[i-4].hid == HID_DG_TIPSWITCH &&
390 field->usage[i-3].hid == HID_DG_BARRELSWITCH &&
391 field->usage[i-2].hid == HID_DG_ERASER &&
392 field->usage[i-1].hid == HID_DG_INVERT &&
393 field->usage[i+1].hid == HID_DG_INRANGE) {
394 usage->hid = HID_DG_BARRELSWITCH2;
395 }
396 }
397
398 /* 2nd-generation Intuos Pro Large has incorrect Y maximum */
399 if (hdev->vendor == USB_VENDOR_ID_WACOM &&
400 hdev->product == 0x0358 &&
401 WACOM_PEN_FIELD(field) &&
402 wacom_equivalent_usage(usage->hid) == HID_GD_Y) {
403 field->logical_maximum = 43200;
404 }
405 412
406 switch (usage->hid) { 413 switch (equivalent_usage) {
407 case HID_GD_X: 414 case HID_GD_X:
408 features->x_max = field->logical_maximum; 415 features->x_max = field->logical_maximum;
409 if (finger) { 416 if (finger) {
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index ad7afa74d365..e0a06be5ef5c 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -4357,19 +4357,19 @@ static const struct wacom_features wacom_features_0x5E =
4357 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 4357 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4358static const struct wacom_features wacom_features_0x90 = 4358static const struct wacom_features wacom_features_0x90 =
4359 { "Wacom ISDv4 90", 26202, 16325, 255, 0, 4359 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4360 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4360 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4361static const struct wacom_features wacom_features_0x93 = 4361static const struct wacom_features wacom_features_0x93 =
4362 { "Wacom ISDv4 93", 26202, 16325, 255, 0, 4362 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4363 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4363 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4364static const struct wacom_features wacom_features_0x97 = 4364static const struct wacom_features wacom_features_0x97 =
4365 { "Wacom ISDv4 97", 26202, 16325, 511, 0, 4365 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4366 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4366 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4367static const struct wacom_features wacom_features_0x9A = 4367static const struct wacom_features wacom_features_0x9A =
4368 { "Wacom ISDv4 9A", 26202, 16325, 255, 0, 4368 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4369 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4369 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4370static const struct wacom_features wacom_features_0x9F = 4370static const struct wacom_features wacom_features_0x9F =
4371 { "Wacom ISDv4 9F", 26202, 16325, 255, 0, 4371 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4372 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4372 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4373static const struct wacom_features wacom_features_0xE2 = 4373static const struct wacom_features wacom_features_0xE2 =
4374 { "Wacom ISDv4 E2", 26202, 16325, 255, 0, 4374 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4375 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 4375 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
@@ -4384,13 +4384,13 @@ static const struct wacom_features wacom_features_0xE6 =
4384 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; 4384 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4385static const struct wacom_features wacom_features_0xEC = 4385static const struct wacom_features wacom_features_0xEC =
4386 { "Wacom ISDv4 EC", 25710, 14500, 255, 0, 4386 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4387 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4387 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4388static const struct wacom_features wacom_features_0xED = 4388static const struct wacom_features wacom_features_0xED =
4389 { "Wacom ISDv4 ED", 26202, 16325, 255, 0, 4389 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4390 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4390 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4391static const struct wacom_features wacom_features_0xEF = 4391static const struct wacom_features wacom_features_0xEF =
4392 { "Wacom ISDv4 EF", 26202, 16325, 255, 0, 4392 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4393 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4393 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4394static const struct wacom_features wacom_features_0x100 = 4394static const struct wacom_features wacom_features_0x100 =
4395 { "Wacom ISDv4 100", 26202, 16325, 255, 0, 4395 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4396 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4396 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -4408,10 +4408,10 @@ static const struct wacom_features wacom_features_0x10F =
4408 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4408 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4409static const struct wacom_features wacom_features_0x116 = 4409static const struct wacom_features wacom_features_0x116 =
4410 { "Wacom ISDv4 116", 26202, 16325, 255, 0, 4410 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4411 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4411 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4412static const struct wacom_features wacom_features_0x12C = 4412static const struct wacom_features wacom_features_0x12C =
4413 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0, 4413 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4414 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4414 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4415static const struct wacom_features wacom_features_0x4001 = 4415static const struct wacom_features wacom_features_0x4001 =
4416 { "Wacom ISDv4 4001", 26202, 16325, 255, 0, 4416 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4417 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 4417 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };