Skip to content

Commit 1c50251

Browse files
Merge branch 'master' into for-6.0
2 parents d70ecfb + d9edf26 commit 1c50251

File tree

7 files changed

+296
-49
lines changed

7 files changed

+296
-49
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
- kernel: "4.1"
2323
compile_cflags: -Wno-error=format-truncation
2424
- kernel: "4.5"
25-
compile_cflags: -Wno-error=format-truncation
25+
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
2626
- kernel: "4.6"
27-
compile_cflags: -Wno-error=format-truncation
27+
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
2828
- kernel: "4.14"
29-
compile_cflags: -Wno-error=format-truncation
29+
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
3030
- kernel: "5.10"
31-
compile_cflags: -Wno-error=format-truncation
31+
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
3232
steps:
3333
- name: Checkout the repo
3434
uses: actions/checkout@v2

3.17/wacom.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#include <linux/kfifo.h>
9292
#include <linux/usb/input.h>
9393
#include <linux/power_supply.h>
94+
#include <linux/timer.h>
9495
#include <asm/unaligned.h>
9596
#include <linux/version.h>
9697

@@ -186,6 +187,7 @@ struct wacom {
186187
struct delayed_work init_work;
187188
struct wacom_remote *remote;
188189
struct work_struct mode_change_work;
190+
struct timer_list idleprox_timer;
189191
bool generic_has_leds;
190192
struct wacom_leds {
191193
struct wacom_group_leds *groups;
@@ -251,4 +253,5 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report);
251253
void wacom_battery_work(struct work_struct *work);
252254
int wacom_equivalent_usage(int usage);
253255
int wacom_initialize_leds(struct wacom *wacom);
256+
void wacom_idleprox_timeout(unsigned long data);
254257
#endif

3.17/wacom_sys.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ static int __wacom_initialize_battery(struct wacom *wacom,
16471647
bat_desc->get_property = wacom_battery_get_property;
16481648
sprintf(battery->bat_name, "wacom_battery_%ld", n);
16491649
bat_desc->name = battery->bat_name;
1650-
bat_desc->type = POWER_SUPPLY_TYPE_USB;
1650+
bat_desc->type = POWER_SUPPLY_TYPE_BATTERY;
16511651
bat_desc->use_for_apm = 0;
16521652

16531653
ps_bat = devm_power_supply_register(dev, bat_desc, &psy_cfg);
@@ -2014,7 +2014,7 @@ static int wacom_register_inputs(struct wacom *wacom)
20142014

20152015
error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
20162016
if (error) {
2017-
/* no pad in use on this interface */
2017+
/* no pad events using this interface */
20182018
input_free_device(pad_input_dev);
20192019
wacom_wac->pad_input = NULL;
20202020
pad_input_dev = NULL;
@@ -2700,6 +2700,7 @@ static int wacom_probe(struct hid_device *hdev,
27002700
INIT_WORK(&wacom->battery_work, wacom_battery_work);
27012701
INIT_WORK(&wacom->remote_work, wacom_remote_work);
27022702
INIT_WORK(&wacom->mode_change_work, wacom_mode_change_work);
2703+
setup_timer(&wacom->idleprox_timer, &wacom_idleprox_timeout, (unsigned long) wacom);
27032704

27042705
/* ask for the report descriptor to be loaded by HID */
27052706
error = hid_parse(hdev);
@@ -2744,6 +2745,7 @@ static void wacom_remove(struct hid_device *hdev)
27442745
cancel_work_sync(&wacom->battery_work);
27452746
cancel_work_sync(&wacom->remote_work);
27462747
cancel_work_sync(&wacom->mode_change_work);
2748+
del_timer_sync(&wacom->idleprox_timer);
27472749
if (hdev->bus == BUS_BLUETOOTH)
27482750
device_remove_file(&hdev->dev, &dev_attr_speed);
27492751
#ifndef WACOM_POWERSUPPLY_41

3.17/wacom_wac.c

Lines changed: 127 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "wacom_wac.h"
1212
#include "wacom.h"
1313
#include <linux/input/mt.h>
14+
#include <linux/jiffies.h>
1415

1516
#ifndef INPUT_PROP_ACCELEROMETER
1617
#define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */
@@ -55,6 +56,42 @@ static void wacom_report_numbered_buttons(struct input_dev *input_dev,
5556

5657
static int wacom_numbered_button_to_key(int n);
5758

59+
static void wacom_force_proxout(struct wacom_wac *wacom_wac)
60+
{
61+
struct input_dev *input = wacom_wac->pen_input;
62+
63+
wacom_wac->shared->stylus_in_proximity = 0;
64+
65+
input_report_key(input, BTN_TOUCH, 0);
66+
input_report_key(input, BTN_STYLUS, 0);
67+
input_report_key(input, BTN_STYLUS2, 0);
68+
input_report_key(input, BTN_STYLUS3, 0);
69+
input_report_key(input, wacom_wac->tool[0], 0);
70+
if (wacom_wac->serial[0]) {
71+
input_report_abs(input, ABS_MISC, 0);
72+
}
73+
input_report_abs(input, ABS_PRESSURE, 0);
74+
75+
wacom_wac->tool[0] = 0;
76+
wacom_wac->id[0] = 0;
77+
wacom_wac->serial[0] = 0;
78+
79+
input_sync(input);
80+
}
81+
82+
void wacom_idleprox_timeout(unsigned long data)
83+
{
84+
struct wacom *wacom = (struct wacom *)data;
85+
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
86+
87+
if (!wacom_wac->hid_data.sense_state) {
88+
return;
89+
}
90+
91+
hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n", __func__);
92+
wacom_force_proxout(wacom_wac);
93+
}
94+
5895
/*
5996
* Percent of battery capacity for Graphire.
6097
* 8th value means AC online and show 100% capacity.
@@ -654,9 +691,26 @@ static int wacom_intuos_id_mangle(int tool_id)
654691
return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
655692
}
656693

694+
static bool wacom_is_art_pen(int tool_id)
695+
{
696+
bool is_art_pen = false;
697+
698+
switch (tool_id) {
699+
case 0x885: /* Intuos3 Marker Pen */
700+
case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
701+
case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
702+
is_art_pen = true;
703+
break;
704+
}
705+
return is_art_pen;
706+
}
707+
657708
static int wacom_intuos_get_tool_type(int tool_id)
658709
{
659-
int tool_type;
710+
int tool_type = BTN_TOOL_PEN;
711+
712+
if (wacom_is_art_pen(tool_id))
713+
return tool_type;
660714

661715
switch (tool_id) {
662716
case 0x812: /* Inking pen */
@@ -671,17 +725,17 @@ static int wacom_intuos_get_tool_type(int tool_id)
671725
case 0x852:
672726
case 0x823: /* Intuos3 Grip Pen */
673727
case 0x813: /* Intuos3 Classic Pen */
674-
case 0x885: /* Intuos3 Marker Pen */
675728
case 0x802: /* Intuos4/5 13HD/24HD General Pen */
676-
case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
677729
case 0x8e2: /* IntuosHT2 pen */
678730
case 0x022:
679-
case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
731+
case 0x200: /* Pro Pen 3 */
732+
case 0x04200: /* Pro Pen 3 */
680733
case 0x10842: /* MobileStudio Pro Pro Pen slim */
681734
case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
682735
case 0x16802: /* Cintiq 13HD Pro Pen */
683736
case 0x18802: /* DTH2242 Pen */
684737
case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
738+
case 0x80842: /* Intuos Pro and Cintiq Pro 3D Pen */
685739
tool_type = BTN_TOOL_PEN;
686740
break;
687741

@@ -734,10 +788,6 @@ static int wacom_intuos_get_tool_type(int tool_id)
734788
case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
735789
tool_type = BTN_TOOL_AIRBRUSH;
736790
break;
737-
738-
default: /* Unknown tool */
739-
tool_type = BTN_TOOL_PEN;
740-
break;
741791
}
742792
return tool_type;
743793
}
@@ -1827,7 +1877,9 @@ int wacom_equivalent_usage(int usage)
18271877
usage == WACOM_HID_WD_TOUCHSTRIP2 ||
18281878
usage == WACOM_HID_WD_TOUCHRING ||
18291879
usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
1830-
usage == WACOM_HID_WD_REPORT_VALID) {
1880+
usage == WACOM_HID_WD_REPORT_VALID ||
1881+
usage == WACOM_HID_WD_BARRELSWITCH3 ||
1882+
usage == WACOM_HID_WD_SEQUENCENUMBER) {
18311883
return usage;
18321884
}
18331885

@@ -2024,7 +2076,6 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
20242076
wacom_wac->has_mute_touch_switch = true;
20252077
usage->type = EV_SW;
20262078
usage->code = SW_MUTE_DEVICE;
2027-
features->device_type |= WACOM_DEVICETYPE_PAD;
20282079
break;
20292080
case WACOM_HID_WD_TOUCHSTRIP:
20302081
wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
@@ -2102,6 +2153,30 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21022153
wacom_wac->hid_data.inrange_state |= value;
21032154
}
21042155

2156+
/* Process touch switch state first since it is reported through touch interface,
2157+
* which is indepentent of pad interface. In the case when there are no other pad
2158+
* events, the pad interface will not even be created.
2159+
*/
2160+
if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2161+
(equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
2162+
if (wacom_wac->shared->touch_input) {
2163+
bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2164+
2165+
if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2166+
*is_touch_on = !(*is_touch_on);
2167+
else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2168+
*is_touch_on = value;
2169+
2170+
input_report_switch(wacom_wac->shared->touch_input,
2171+
SW_MUTE_DEVICE, !(*is_touch_on));
2172+
input_sync(wacom_wac->shared->touch_input);
2173+
}
2174+
return;
2175+
}
2176+
2177+
if (!input)
2178+
return;
2179+
21052180
switch (equivalent_usage) {
21062181
case WACOM_HID_WD_TOUCHRING:
21072182
/*
@@ -2137,22 +2212,6 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21372212
input_event(input, usage->type, usage->code, 0);
21382213
break;
21392214

2140-
case WACOM_HID_WD_MUTE_DEVICE:
2141-
case WACOM_HID_WD_TOUCHONOFF:
2142-
if (wacom_wac->shared->touch_input) {
2143-
bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2144-
2145-
if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2146-
*is_touch_on = !(*is_touch_on);
2147-
else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2148-
*is_touch_on = value;
2149-
2150-
input_report_switch(wacom_wac->shared->touch_input,
2151-
SW_MUTE_DEVICE, !(*is_touch_on));
2152-
input_sync(wacom_wac->shared->touch_input);
2153-
}
2154-
break;
2155-
21562215
case WACOM_HID_WD_MODE_CHANGE:
21572216
if (wacom_wac->is_direct_mode != value) {
21582217
wacom_wac->is_direct_mode = value;
@@ -2212,8 +2271,11 @@ static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
22122271
if (!(features->quirks & WACOM_QUIRK_AESPEN) &&
22132272
wacom_wac->hid_data.barrelswitch &&
22142273
wacom_wac->hid_data.barrelswitch2 &&
2215-
wacom_wac->hid_data.serialhi)
2274+
wacom_wac->hid_data.serialhi &&
2275+
!wacom_wac->hid_data.barrelswitch3) {
22162276
input_set_capability(input, EV_KEY, BTN_STYLUS3);
2277+
features->quirks |= WACOM_QUIRK_PEN_BUTTON3;
2278+
}
22172279
}
22182280

22192281
static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
@@ -2277,6 +2339,9 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
22772339
features->quirks |= WACOM_QUIRK_TOOLSERIAL;
22782340
wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
22792341
break;
2342+
case HID_DG_SCANTIME:
2343+
wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
2344+
break;
22802345
case WACOM_HID_WD_SENSE:
22812346
features->quirks |= WACOM_QUIRK_SENSE;
22822347
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
@@ -2290,6 +2355,11 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
22902355
input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
22912356
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
22922357
break;
2358+
case WACOM_HID_WD_BARRELSWITCH3:
2359+
wacom_wac->hid_data.barrelswitch3 = true;
2360+
wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS3, 0);
2361+
features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3;
2362+
break;
22932363
}
22942364
}
22952365

@@ -2315,6 +2385,7 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
23152385
value = field->logical_maximum - value;
23162386
break;
23172387
case HID_DG_INRANGE:
2388+
mod_timer(&wacom->idleprox_timer, jiffies + msecs_to_jiffies(100));
23182389
wacom_wac->hid_data.inrange_state = value;
23192390
if (!(features->quirks & WACOM_QUIRK_SENSE))
23202391
wacom_wac->hid_data.sense_state = value;
@@ -2339,6 +2410,9 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
23392410
}
23402411
return;
23412412
case HID_DG_TWIST:
2413+
/* don't modify the value if the pen doesn't support the feature */
2414+
if (!wacom_is_art_pen(wacom_wac->id[0])) return;
2415+
23422416
/*
23432417
* Userspace expects pen twist to have its zero point when
23442418
* the buttons/finger is on the tablet's left. HID values
@@ -2406,6 +2480,14 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
24062480
case WACOM_HID_WD_REPORT_VALID:
24072481
wacom_wac->is_invalid_bt_frame = !value;
24082482
return;
2483+
case WACOM_HID_WD_BARRELSWITCH3:
2484+
wacom_wac->hid_data.barrelswitch3 = value;
2485+
return;
2486+
case WACOM_HID_WD_SEQUENCENUMBER:
2487+
if (wacom_wac->hid_data.sequence_number != value)
2488+
hid_warn(hdev, "Dropped %hu packets", (unsigned short)(value - wacom_wac->hid_data.sequence_number));
2489+
wacom_wac->hid_data.sequence_number = value + 1;
2490+
return;
24092491
}
24102492

24112493
/* send pen events only when touch is up or forced out
@@ -2458,12 +2540,15 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
24582540

24592541
if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
24602542
int id = wacom_wac->id[0];
2461-
int sw_state = wacom_wac->hid_data.barrelswitch |
2462-
(wacom_wac->hid_data.barrelswitch2 << 1);
2463-
2464-
input_report_key(input, BTN_STYLUS, sw_state == 1);
2465-
input_report_key(input, BTN_STYLUS2, sw_state == 2);
2466-
input_report_key(input, BTN_STYLUS3, sw_state == 3);
2543+
if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3 &&
2544+
wacom_wac->hid_data.barrelswitch & wacom_wac->hid_data.barrelswitch2) {
2545+
wacom_wac->hid_data.barrelswitch = 0;
2546+
wacom_wac->hid_data.barrelswitch2 = 0;
2547+
wacom_wac->hid_data.barrelswitch3 = 1;
2548+
}
2549+
input_report_key(input, BTN_STYLUS, wacom_wac->hid_data.barrelswitch);
2550+
input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2);
2551+
input_report_key(input, BTN_STYLUS3, wacom_wac->hid_data.barrelswitch3);
24672552

24682553
/*
24692554
* Non-USI EMR tools should have their IDs mangled to
@@ -2545,6 +2630,9 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
25452630
field->logical_maximum = 255;
25462631
}
25472632
break;
2633+
case HID_DG_SCANTIME:
2634+
wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
2635+
break;
25482636
}
25492637
}
25502638

@@ -2811,7 +2899,7 @@ void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
28112899
/* usage tests must precede field tests */
28122900
if (WACOM_BATTERY_USAGE(usage))
28132901
wacom_wac_battery_event(hdev, field, usage, value);
2814-
else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
2902+
else if (WACOM_PAD_FIELD(field))
28152903
wacom_wac_pad_event(hdev, field, usage, value);
28162904
else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
28172905
wacom_wac_pen_event(hdev, field, usage, value);
@@ -4714,6 +4802,10 @@ static const struct wacom_features wacom_features_0x3c6 =
47144802
static const struct wacom_features wacom_features_0x3c8 =
47154803
{ "Wacom Intuos BT M", 21600, 13500, 4095, 63,
47164804
INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4805+
static const struct wacom_features wacom_features_0x3dd =
4806+
{ "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4807+
INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4808+
.touch_max = 10 };
47174809

47184810
static const struct wacom_features wacom_features_HID_ANY_ID =
47194811
{ "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
@@ -4889,6 +4981,7 @@ const struct hid_device_id wacom_ids[] = {
48894981
{ BT_DEVICE_WACOM(0x393) },
48904982
{ BT_DEVICE_WACOM(0x3c6) },
48914983
{ BT_DEVICE_WACOM(0x3c8) },
4984+
{ BT_DEVICE_WACOM(0x3dd) },
48924985
{ USB_DEVICE_WACOM(0x4001) },
48934986
{ USB_DEVICE_WACOM(0x4004) },
48944987
{ USB_DEVICE_WACOM(0x5000) },

0 commit comments

Comments
 (0)