Skip to content

Commit 8ca06d6

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.4/wacom' into for-linus
- MobileStudio Pro 13 support, from Ping Cheng - a few other assorted fixes Signed-off-by: Jiri Kosina <[email protected]>
2 parents 7af0f83 + bbbe3ac commit 8ca06d6

File tree

2 files changed

+81
-20
lines changed

2 files changed

+81
-20
lines changed

drivers/hid/wacom_sys.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
8888
}
8989

9090
static int wacom_wac_pen_serial_enforce(struct hid_device *hdev,
91-
struct hid_report *report, u8 *raw_data, int size)
91+
struct hid_report *report, u8 *raw_data, int report_size)
9292
{
9393
struct wacom *wacom = hid_get_drvdata(hdev);
9494
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
@@ -149,7 +149,8 @@ static int wacom_wac_pen_serial_enforce(struct hid_device *hdev,
149149
if (flush)
150150
wacom_wac_queue_flush(hdev, &wacom_wac->pen_fifo);
151151
else if (insert)
152-
wacom_wac_queue_insert(hdev, &wacom_wac->pen_fifo, raw_data, size);
152+
wacom_wac_queue_insert(hdev, &wacom_wac->pen_fifo,
153+
raw_data, report_size);
153154

154155
return insert && !flush;
155156
}
@@ -2176,7 +2177,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
21762177
{
21772178
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
21782179
struct wacom_features *features = &wacom_wac->features;
2179-
char name[WACOM_NAME_MAX];
2180+
char name[WACOM_NAME_MAX - 20]; /* Leave some room for suffixes */
21802181

21812182
/* Generic devices name unspecified */
21822183
if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) {
@@ -2718,14 +2719,12 @@ static int wacom_probe(struct hid_device *hdev,
27182719
wacom_wac->features = *((struct wacom_features *)id->driver_data);
27192720
features = &wacom_wac->features;
27202721

2721-
if (features->check_for_hid_type && features->hid_type != hdev->type) {
2722-
error = -ENODEV;
2723-
goto fail;
2724-
}
2722+
if (features->check_for_hid_type && features->hid_type != hdev->type)
2723+
return -ENODEV;
27252724

27262725
error = kfifo_alloc(&wacom_wac->pen_fifo, WACOM_PKGLEN_MAX, GFP_KERNEL);
27272726
if (error)
2728-
goto fail;
2727+
return error;
27292728

27302729
wacom_wac->hid_data.inputmode = -1;
27312730
wacom_wac->mode_report = -1;
@@ -2743,12 +2742,12 @@ static int wacom_probe(struct hid_device *hdev,
27432742
error = hid_parse(hdev);
27442743
if (error) {
27452744
hid_err(hdev, "parse failed\n");
2746-
goto fail;
2745+
return error;
27472746
}
27482747

27492748
error = wacom_parse_and_register(wacom, false);
27502749
if (error)
2751-
goto fail;
2750+
return error;
27522751

27532752
if (hdev->bus == BUS_BLUETOOTH) {
27542753
error = device_create_file(&hdev->dev, &dev_attr_speed);
@@ -2759,10 +2758,6 @@ static int wacom_probe(struct hid_device *hdev,
27592758
}
27602759

27612760
return 0;
2762-
2763-
fail:
2764-
hid_set_drvdata(hdev, NULL);
2765-
return error;
27662761
}
27672762

27682763
static void wacom_remove(struct hid_device *hdev)
@@ -2791,8 +2786,6 @@ static void wacom_remove(struct hid_device *hdev)
27912786
wacom_release_resources(wacom);
27922787

27932788
kfifo_free(&wacom_wac->pen_fifo);
2794-
2795-
hid_set_drvdata(hdev, NULL);
27962789
}
27972790

27982791
#ifdef CONFIG_PM

drivers/hid/wacom_wac.c

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
251251

252252
static int wacom_dtus_irq(struct wacom_wac *wacom)
253253
{
254-
char *data = wacom->data;
254+
unsigned char *data = wacom->data;
255255
struct input_dev *input = wacom->pen_input;
256256
unsigned short prox, pressure = 0;
257257

@@ -483,6 +483,8 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
483483
int ring1 = 0, ring2 = 0;
484484
int strip1 = 0, strip2 = 0;
485485
bool prox = false;
486+
bool wrench = false, keyboard = false, mute_touch = false, menu = false,
487+
info = false;
486488

487489
/* pad packets. Works as a second tool and is always in prox */
488490
if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
@@ -512,10 +514,32 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
512514
keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
513515
((data[4] & 0xE0) ? 1<<1 : 0) |
514516
((data[4] & 0x07) ? 1<<0 : 0);
517+
keyboard = !!(data[4] & 0xE0);
518+
info = !!(data[3] & 0x1C);
519+
520+
if (features->oPid) {
521+
mute_touch = !!(data[4] & 0x07);
522+
if (mute_touch)
523+
wacom->shared->is_touch_on =
524+
!wacom->shared->is_touch_on;
525+
} else {
526+
wrench = !!(data[4] & 0x07);
527+
}
515528
} else if (features->type == WACOM_27QHD) {
516529
nkeys = 3;
517530
keys = data[2] & 0x07;
518531

532+
wrench = !!(data[2] & 0x01);
533+
keyboard = !!(data[2] & 0x02);
534+
535+
if (features->oPid) {
536+
mute_touch = !!(data[2] & 0x04);
537+
if (mute_touch)
538+
wacom->shared->is_touch_on =
539+
!wacom->shared->is_touch_on;
540+
} else {
541+
menu = !!(data[2] & 0x04);
542+
}
519543
input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
520544
input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
521545
input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
@@ -561,6 +585,9 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
561585
if (features->type == WACOM_22HD) {
562586
nkeys = 3;
563587
keys = data[9] & 0x07;
588+
589+
info = !!(data[9] & 0x01);
590+
wrench = !!(data[9] & 0x02);
564591
}
565592
} else {
566593
buttons = ((data[6] & 0x10) << 5) |
@@ -572,14 +599,26 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
572599
strip2 = ((data[3] & 0x1f) << 8) | data[4];
573600
}
574601

575-
prox = (buttons & ~(~0 << nbuttons)) | (keys & ~(~0 << nkeys)) |
602+
prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
576603
(ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
577604

578605
wacom_report_numbered_buttons(input, nbuttons, buttons);
579606

580607
for (i = 0; i < nkeys; i++)
581608
input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
582609

610+
input_report_key(input, KEY_BUTTONCONFIG, wrench);
611+
input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
612+
input_report_key(input, KEY_CONTROLPANEL, menu);
613+
input_report_key(input, KEY_INFO, info);
614+
615+
if (wacom->shared && wacom->shared->touch_input) {
616+
input_report_switch(wacom->shared->touch_input,
617+
SW_MUTE_DEVICE,
618+
!wacom->shared->is_touch_on);
619+
input_sync(wacom->shared->touch_input);
620+
}
621+
583622
input_report_abs(input, ABS_RX, strip1);
584623
input_report_abs(input, ABS_RY, strip2);
585624

@@ -1483,6 +1522,12 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
14831522
int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
14841523
int y_offset = 2;
14851524

1525+
if (wacom->shared->has_mute_touch_switch &&
1526+
!wacom->shared->is_touch_on) {
1527+
if (!wacom->shared->touch_down)
1528+
return 0;
1529+
}
1530+
14861531
if (wacom->features.type == WACOM_27QHDT) {
14871532
current_num_contacts = data[63];
14881533
num_contacts_left = 10;
@@ -2051,14 +2096,14 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
20512096
(hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
20522097
hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */
20532098
hdev->product == 0x392 || /* Intuos Pro 2 */
2054-
hdev->product == 0x399)) { /* MobileStudio Pro */
2099+
hdev->product == 0x398 || hdev->product == 0x399)) { /* MobileStudio Pro */
20552100
value = (field->logical_maximum - value);
20562101

20572102
if (hdev->product == 0x357 || hdev->product == 0x358 ||
20582103
hdev->product == 0x392)
20592104
value = wacom_offset_rotation(input, usage, value, 3, 16);
20602105
else if (hdev->product == 0x34d || hdev->product == 0x34e ||
2061-
hdev->product == 0x399)
2106+
hdev->product == 0x398 || hdev->product == 0x399)
20622107
value = wacom_offset_rotation(input, usage, value, 1, 2);
20632108
}
20642109
else {
@@ -3815,6 +3860,14 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
38153860
/* fall through */
38163861

38173862
case WACOM_27QHDT:
3863+
if (wacom_wac->shared->touch->product == 0x32C ||
3864+
wacom_wac->shared->touch->product == 0xF6) {
3865+
input_dev->evbit[0] |= BIT_MASK(EV_SW);
3866+
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3867+
wacom_wac->shared->has_mute_touch_switch = true;
3868+
}
3869+
/* fall through */
3870+
38183871
case MTSCREEN:
38193872
case MTTPC:
38203873
case MTTPC_B:
@@ -4050,6 +4103,12 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
40504103
__set_bit(KEY_PROG2, input_dev->keybit);
40514104
__set_bit(KEY_PROG3, input_dev->keybit);
40524105

4106+
__set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4107+
__set_bit(KEY_INFO, input_dev->keybit);
4108+
4109+
if (!features->oPid)
4110+
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4111+
40534112
input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
40544113
input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
40554114
break;
@@ -4058,6 +4117,12 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
40584117
__set_bit(KEY_PROG1, input_dev->keybit);
40594118
__set_bit(KEY_PROG2, input_dev->keybit);
40604119
__set_bit(KEY_PROG3, input_dev->keybit);
4120+
4121+
__set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4122+
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4123+
4124+
if (!features->oPid)
4125+
__set_bit(KEY_CONTROLPANEL, input_dev->keybit);
40614126
input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
40624127
input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
40634128
input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
@@ -4071,6 +4136,9 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
40714136
__set_bit(KEY_PROG1, input_dev->keybit);
40724137
__set_bit(KEY_PROG2, input_dev->keybit);
40734138
__set_bit(KEY_PROG3, input_dev->keybit);
4139+
4140+
__set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4141+
__set_bit(KEY_INFO, input_dev->keybit);
40744142
/* fall through */
40754143

40764144
case WACOM_21UX2:

0 commit comments

Comments
 (0)