Skip to content

Commit 497ab1f

Browse files
Pinglinuxdtor
authored andcommitted
Input: wacom - add support for DTU-1031
Signed-off-by: Ping Cheng <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 7134816 commit 497ab1f

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

drivers/input/tablet/wacom_wac.c

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,62 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
210210
return 1;
211211
}
212212

213+
static int wacom_dtus_irq(struct wacom_wac *wacom)
214+
{
215+
char *data = wacom->data;
216+
struct input_dev *input = wacom->input;
217+
unsigned short prox, pressure = 0;
218+
219+
if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
220+
dev_dbg(input->dev.parent,
221+
"%s: received unknown report #%d", __func__, data[0]);
222+
return 0;
223+
} else if (data[0] == WACOM_REPORT_DTUSPAD) {
224+
input_report_key(input, BTN_0, (data[1] & 0x01));
225+
input_report_key(input, BTN_1, (data[1] & 0x02));
226+
input_report_key(input, BTN_2, (data[1] & 0x04));
227+
input_report_key(input, BTN_3, (data[1] & 0x08));
228+
input_report_abs(input, ABS_MISC,
229+
data[1] & 0x0f ? PAD_DEVICE_ID : 0);
230+
/*
231+
* Serial number is required when expresskeys are
232+
* reported through pen interface.
233+
*/
234+
input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
235+
return 1;
236+
} else {
237+
prox = data[1] & 0x80;
238+
if (prox) {
239+
switch ((data[1] >> 3) & 3) {
240+
case 1: /* Rubber */
241+
wacom->tool[0] = BTN_TOOL_RUBBER;
242+
wacom->id[0] = ERASER_DEVICE_ID;
243+
break;
244+
245+
case 2: /* Pen */
246+
wacom->tool[0] = BTN_TOOL_PEN;
247+
wacom->id[0] = STYLUS_DEVICE_ID;
248+
break;
249+
}
250+
}
251+
252+
input_report_key(input, BTN_STYLUS, data[1] & 0x20);
253+
input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
254+
input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
255+
input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
256+
pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
257+
input_report_abs(input, ABS_PRESSURE, pressure);
258+
input_report_key(input, BTN_TOUCH, pressure > 10);
259+
260+
if (!prox) /* out-prox */
261+
wacom->id[0] = 0;
262+
input_report_key(input, wacom->tool[0], prox);
263+
input_report_abs(input, ABS_MISC, wacom->id[0]);
264+
input_event(input, EV_MSC, MSC_SERIAL, 1);
265+
return 1;
266+
}
267+
}
268+
213269
static int wacom_graphire_irq(struct wacom_wac *wacom)
214270
{
215271
struct wacom_features *features = &wacom->features;
@@ -1371,6 +1427,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
13711427
sync = wacom_dtu_irq(wacom_wac);
13721428
break;
13731429

1430+
case DTUS:
1431+
sync = wacom_dtus_irq(wacom_wac);
1432+
break;
1433+
13741434
case INTUOS:
13751435
case INTUOS3S:
13761436
case INTUOS3:
@@ -1562,7 +1622,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
15621622

15631623
wacom_abs_set_axis(input_dev, wacom_wac);
15641624

1565-
switch (wacom_wac->features.type) {
1625+
switch (features->type) {
15661626
case WACOM_MO:
15671627
input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
15681628
/* fall through */
@@ -1773,8 +1833,14 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
17731833

17741834
/* fall through */
17751835

1836+
case DTUS:
17761837
case PL:
17771838
case DTU:
1839+
if (features->type == DTUS) {
1840+
input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1841+
for (i = 0; i < 3; i++)
1842+
__set_bit(BTN_0 + i, input_dev->keybit);
1843+
}
17781844
__set_bit(BTN_TOOL_PEN, input_dev->keybit);
17791845
__set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
17801846
__set_bit(BTN_STYLUS, input_dev->keybit);
@@ -2096,6 +2162,9 @@ static const struct wacom_features wacom_features_0xCE =
20962162
static const struct wacom_features wacom_features_0xF0 =
20972163
{ "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
20982164
0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2165+
static const struct wacom_features wacom_features_0xFB =
2166+
{ "Wacom DTU1031", WACOM_PKGLEN_DTUS, 22096, 13960, 511,
2167+
0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
20992168
static const struct wacom_features wacom_features_0x57 =
21002169
{ "Wacom DTK2241", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047,
21012170
63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES};
@@ -2402,6 +2471,7 @@ const struct usb_device_id wacom_ids[] = {
24022471
{ USB_DEVICE_WACOM(0xF8) },
24032472
{ USB_DEVICE_DETAILED(0xF6, USB_CLASS_HID, 0, 0) },
24042473
{ USB_DEVICE_WACOM(0xFA) },
2474+
{ USB_DEVICE_WACOM(0xFB) },
24052475
{ USB_DEVICE_WACOM(0x0307) },
24062476
{ USB_DEVICE_DETAILED(0x0309, USB_CLASS_HID, 0, 0) },
24072477
{ USB_DEVICE_LENOVO(0x6004) },

drivers/input/tablet/wacom_wac.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <linux/types.h>
1313

1414
/* maximum packet length for USB devices */
15-
#define WACOM_PKGLEN_MAX 64
15+
#define WACOM_PKGLEN_MAX 68
1616

1717
#define WACOM_NAME_MAX 64
1818

@@ -29,6 +29,7 @@
2929
#define WACOM_PKGLEN_WIRELESS 32
3030
#define WACOM_PKGLEN_MTOUCH 62
3131
#define WACOM_PKGLEN_MTTPC 40
32+
#define WACOM_PKGLEN_DTUS 68
3233

3334
/* wacom data size per MT contact */
3435
#define WACOM_BYTES_PER_MT_PACKET 11
@@ -47,11 +48,13 @@
4748
#define WACOM_REPORT_INTUOSWRITE 6
4849
#define WACOM_REPORT_INTUOSPAD 12
4950
#define WACOM_REPORT_INTUOS5PAD 3
51+
#define WACOM_REPORT_DTUSPAD 21
5052
#define WACOM_REPORT_TPC1FG 6
5153
#define WACOM_REPORT_TPC2FG 13
5254
#define WACOM_REPORT_TPCMT 13
5355
#define WACOM_REPORT_TPCHID 15
5456
#define WACOM_REPORT_TPCST 16
57+
#define WACOM_REPORT_DTUS 17
5558
#define WACOM_REPORT_TPC1FGE 18
5659
#define WACOM_REPORT_24HDT 1
5760
#define WACOM_REPORT_WL 128
@@ -70,6 +73,7 @@ enum {
7073
PTU,
7174
PL,
7275
DTU,
76+
DTUS,
7377
INTUOS,
7478
INTUOS3S,
7579
INTUOS3,

0 commit comments

Comments
 (0)