Skip to content

Commit 37a5b5f

Browse files
Pinglinuxgregkh
authored andcommitted
Input: wacom - add reporting of SW_MUTE_DEVICE events
commit 961794a upstream. New Intuos series models added a hardware switch to turn touch data on/off. The state of the switch is reported periodically from the tablet. To report the state the driver will emit SW_MUTE_DEVICE events. Reviewed_by: Chris Bagwell <chris@cnpbagwell.com> Acked-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Jason Gerecke <killertofu@gmail.com> Signed-off-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Josh Boyer <jwboyer@fedoraproject.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0606105 commit 37a5b5f

3 files changed

Lines changed: 44 additions & 3 deletions

File tree

‎drivers/input/tablet/wacom_sys.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,8 @@ static void wacom_wireless_work(struct work_struct *work)
11971197
wacom_wac1->features.device_type = BTN_TOOL_PEN;
11981198
snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen",
11991199
wacom_wac1->features.name);
1200+
wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
1201+
wacom_wac1->shared->type = wacom_wac1->features.type;
12001202
error = wacom_register_input(wacom1);
12011203
if (error)
12021204
goto fail;
@@ -1218,6 +1220,10 @@ static void wacom_wireless_work(struct work_struct *work)
12181220
error = wacom_register_input(wacom2);
12191221
if (error)
12201222
goto fail;
1223+
1224+
if (wacom_wac1->features.type == INTUOSHT &&
1225+
wacom_wac1->features.touch_max)
1226+
wacom_wac->shared->touch_input = wacom_wac2->input;
12211227
}
12221228

12231229
error = wacom_initialize_battery(wacom);
@@ -1396,6 +1402,12 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
13961402
goto fail5;
13971403
}
13981404
}
1405+
1406+
if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) {
1407+
if (wacom_wac->features.device_type == BTN_TOOL_FINGER)
1408+
wacom_wac->shared->touch_input = wacom_wac->input;
1409+
}
1410+
13991411
return 0;
14001412

14011413
fail5: wacom_destroy_leds(wacom);

‎drivers/input/tablet/wacom_wac.c‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,13 +1219,23 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
12191219

12201220
static int wacom_bpt_pen(struct wacom_wac *wacom)
12211221
{
1222+
struct wacom_features *features = &wacom->features;
12221223
struct input_dev *input = wacom->input;
12231224
unsigned char *data = wacom->data;
12241225
int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
12251226

1226-
if (data[0] != WACOM_REPORT_PENABLED)
1227+
if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
12271228
return 0;
12281229

1230+
if (data[0] == WACOM_REPORT_USB) {
1231+
if (features->type == INTUOSHT && features->touch_max) {
1232+
input_report_switch(wacom->shared->touch_input,
1233+
SW_MUTE_DEVICE, data[8] & 0x40);
1234+
input_sync(wacom->shared->touch_input);
1235+
}
1236+
return 0;
1237+
}
1238+
12291239
prox = (data[1] & 0x20) == 0x20;
12301240

12311241
/*
@@ -1258,8 +1268,8 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
12581268
* touching and applying pressure; do not report negative
12591269
* distance.
12601270
*/
1261-
if (data[8] <= wacom->features.distance_max)
1262-
d = wacom->features.distance_max - data[8];
1271+
if (data[8] <= features->distance_max)
1272+
d = features->distance_max - data[8];
12631273

12641274
pen = data[1] & 0x01;
12651275
btn1 = data[1] & 0x02;
@@ -1310,6 +1320,13 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
13101320
if (connected) {
13111321
int pid, battery;
13121322

1323+
if ((wacom->shared->type == INTUOSHT) &&
1324+
wacom->shared->touch_max) {
1325+
input_report_switch(wacom->shared->touch_input,
1326+
SW_MUTE_DEVICE, data[5] & 0x40);
1327+
input_sync(wacom->shared->touch_input);
1328+
}
1329+
13131330
pid = get_unaligned_be16(&data[6]);
13141331
battery = data[5] & 0x3f;
13151332
if (wacom->pid != pid) {
@@ -1779,6 +1796,13 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
17791796
break;
17801797

17811798
case INTUOSHT:
1799+
if (features->touch_max &&
1800+
features->device_type == BTN_TOOL_FINGER) {
1801+
input_dev->evbit[0] |= BIT_MASK(EV_SW);
1802+
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
1803+
}
1804+
/* fall through */
1805+
17821806
case BAMBOO_PT:
17831807
__clear_bit(ABS_MISC, input_dev->absbit);
17841808

‎drivers/input/tablet/wacom_wac.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define WACOM_REPORT_TPC1FGE 18
5656
#define WACOM_REPORT_24HDT 1
5757
#define WACOM_REPORT_WL 128
58+
#define WACOM_REPORT_USB 192
5859

5960
/* device quirks */
6061
#define WACOM_QUIRK_MULTI_INPUT 0x0001
@@ -131,6 +132,10 @@ struct wacom_features {
131132
struct wacom_shared {
132133
bool stylus_in_proximity;
133134
bool touch_down;
135+
/* for wireless device to access USB interfaces */
136+
unsigned touch_max;
137+
int type;
138+
struct input_dev *touch_input;
134139
};
135140

136141
struct wacom_wac {

0 commit comments

Comments
 (0)