Skip to content

Commit bac03b4

Browse files
Merge pull request linuxwacom#328 from Joshua-Dickens/27Support
backport: HID: wacom: Adding Support for new usages
2 parents 085ccdf + ead11e4 commit bac03b4

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed

3.7/wacom_wac.c

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2121,18 +2121,126 @@ static int wacom_mspro_pen_irq(struct wacom_wac *wacom)
21212121
return 1;
21222122
}
21232123

2124-
static int wacom_mspro_irq(struct wacom_wac *wacom)
2124+
static int wacom_Pro2022_pen_irq(struct wacom_wac *wacom)
21252125
{
21262126
unsigned char *data = wacom->data;
21272127
struct input_dev *input = wacom->input;
2128+
struct wacom_features *features = &wacom->features;
2129+
bool tip, sw1, sw2, sw3, range, proximity;
2130+
unsigned int x, y;
2131+
unsigned int pressure;
2132+
int tilt_x, tilt_y;
2133+
int rotation;
2134+
unsigned int fingerwheel;
2135+
unsigned int height;
2136+
u64 tool_uid;
2137+
unsigned int tool_type;
2138+
unsigned int timestamp;
2139+
unsigned short sequence_number;
2140+
2141+
if (delay_pen_events(wacom))
2142+
return 1;
2143+
2144+
tip = data[2] & 0x01;
2145+
sw1 = data[2] & 0x02;
2146+
sw2 = data[2] & 0x04;
2147+
sw3 = data[2] & 0x08;
2148+
/* eraser = data[2] & 0x10; */
2149+
/* invert = data[2] & 0x20; */
2150+
range = data[2] & 0x40;
2151+
proximity = data[2] & 0x80;
2152+
x = le32_to_cpup((__le32 *)&data[3]) & 0xFFFFFF;
2153+
y = le32_to_cpup((__le32 *)&data[6]) & 0xFFFFFF;
2154+
pressure = le16_to_cpup((__le16 *)&data[9]);
2155+
tilt_x = (char)le16_to_cpup((__le16 *)&data[11]);
2156+
tilt_y = (char)le16_to_cpup((__le16 *)&data[13]);
2157+
rotation = (int16_t)le16_to_cpup((__le16 *)&data[15]);
2158+
fingerwheel = le16_to_cpup((__le16 *)&data[17]);
2159+
height = data[19];
2160+
tool_uid = le64_to_cpup((__le64 *)&data[20]);
2161+
tool_type = le16_to_cpup((__le16 *)&data[28]);
2162+
timestamp = le16_to_cpup((__le16 *)&data[30]);
2163+
sequence_number = le16_to_cpup((__le16 *)&data[32]);
2164+
2165+
if (range) {
2166+
wacom->serial[0] = (tool_uid & 0xFFFFFFFF);
2167+
wacom->id[0] = ((tool_uid >> 32) & 0xFFFFF) | tool_type;
2168+
wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0] & 0xFFFFF);
2169+
}
2170+
2171+
/* pointer going from fully "in range" to merely "in proximity" */
2172+
if (!range && wacom->tool[0])
2173+
height = wacom->features.distance_max;
2174+
2175+
2176+
/*
2177+
* only report data if there's a tool for userspace to associate
2178+
* the events with.
2179+
*/
2180+
if (wacom->tool[0]) {
2181+
2182+
/* Fix rotation alignment: userspace expects zero at left */
2183+
rotation += 1800/4;
2184+
if (rotation > 899)
2185+
rotation -= 1800;
2186+
2187+
/* Fix tilt zero-point: wacom_setup_cintiq declares 0..127, not -63..+64 */
2188+
tilt_x += 64;
2189+
tilt_y += 64;
21282190

2191+
input_report_key(input, BTN_TOUCH, proximity ? tip : 0);
2192+
input_report_key(input, BTN_STYLUS, proximity ? sw1 : 0);
2193+
input_report_key(input, BTN_STYLUS2, proximity ? sw2 : 0);
2194+
input_report_key(input, BTN_STYLUS3, proximity ? sw3 : 0);
2195+
input_report_abs(input, ABS_X, proximity ? x : 0);
2196+
input_report_abs(input, ABS_Y, proximity ? y : 0);
2197+
input_report_abs(input, ABS_PRESSURE, proximity ? pressure : 0);
2198+
input_report_abs(input, ABS_TILT_X, proximity ? tilt_x : 0);
2199+
input_report_abs(input, ABS_TILT_Y, proximity ? tilt_y : 0);
2200+
input_report_abs(input, ABS_Z, proximity ? rotation : 0);
2201+
input_report_abs(input, ABS_WHEEL, proximity ? fingerwheel : 0);
2202+
input_report_abs(input, ABS_DISTANCE, proximity ? height : 0);
2203+
input_event(input, EV_MSC, MSC_TIMESTAMP, timestamp);
2204+
2205+
if (wacom->features.type != WACOM_ONE) {
2206+
input_event(input, EV_MSC, MSC_SERIAL,
2207+
wacom->serial[0]);
2208+
input_report_abs(input, ABS_MISC, proximity ?
2209+
wacom_intuos_id_mangle(wacom->id[0])
2210+
: 0);
2211+
} else {
2212+
input_report_abs(input, ABS_MISC, proximity ?
2213+
STYLUS_DEVICE_ID : 0);
2214+
}
2215+
input_report_key(input, wacom->tool[0], proximity ? 1 : 0);
2216+
2217+
if (features->sequence_number != sequence_number)
2218+
hid_warn(wacom->input, "dropped %hu packets", sequence_number - features->sequence_number);
2219+
2220+
features->sequence_number = sequence_number + 1;
2221+
2222+
if (!proximity)
2223+
wacom->tool[0] = 0;
2224+
}
2225+
2226+
wacom->shared->stylus_in_proximity = proximity;
2227+
2228+
return 1;
2229+
}
2230+
2231+
static int wacom_mspro_irq(struct wacom_wac *wacom)
2232+
{
2233+
unsigned char *data = wacom->data;
2234+
struct input_dev *input = wacom->input;
21292235
switch (data[0]) {
21302236
case WACOM_REPORT_MSPRO:
21312237
return wacom_mspro_pen_irq(wacom);
21322238
case WACOM_REPORT_MSPROPAD:
21332239
return wacom_mspro_pad_irq(wacom);
21342240
case WACOM_REPORT_MSPRODEVICE:
21352241
return wacom_mspro_device_irq(wacom);
2242+
case WACOM_REPORT_PRO2022:
2243+
return wacom_Pro2022_pen_irq(wacom);
21362244
default:
21372245
dev_dbg(input->dev.parent,
21382246
"%s: received unknown report #%d\n", __func__, data[0]);
@@ -2203,6 +2311,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
22032311
case WACOM_MSPRO:
22042312
case INTUOSP2:
22052313
case INTUOSP2S:
2314+
case WACOM_PRO2022:
22062315
case CINTIQ_16:
22072316
if (len == WACOM_PKGLEN_INTUOSP2T &&
22082317
wacom_wac->data[0] == WACOM_REPORT_VENDOR_DEF_TOUCH)
@@ -2554,6 +2663,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
25542663
break;
25552664

25562665
case WACOM_MSPRO:
2666+
case WACOM_PRO2022:
25572667
case CINTIQ_16:
25582668
input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
25592669
__set_bit(BTN_STYLUS3, input_dev->keybit);
@@ -3557,6 +3667,11 @@ static const struct wacom_features wacom_features_0x3B3 =
35573667
{ "Wacom Cintiq Pro 16 Touch", WACOM_PKGLEN_MSPROT, /* Touch */
35583668
.type = WACOM_MSPROT, .touch_max = 10,
35593669
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x3B2 };
3670+
static const struct wacom_features wacom_features_0x3C0 =
3671+
{ "Wacom Cintiq Pro 27", WACOM_PKGLEN_MSPRO, 120032, 67868, 8191, 63,
3672+
WACOM_PRO2022, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8,
3673+
WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3674+
WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
35603675
static const struct wacom_features wacom_features_0x3c5 =
35613676
{ "Intuos BT S", WACOM_PKGLEN_INTUOSP2, 15200, 9500, 4095,
35623677
63, INTUOSHT3, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
@@ -3771,6 +3886,7 @@ const struct usb_device_id wacom_ids[] = {
37713886
{ USB_DEVICE_WACOM(0x3B2) },
37723887
{ USB_DEVICE_WACOM(0x3B3) },
37733888
{ USB_DEVICE_WACOM(0x3BD) },
3889+
{ USB_DEVICE_WACOM(0x3C0) },
37743890
{ USB_DEVICE_WACOM(0x3c5) },
37753891
{ USB_DEVICE_WACOM(0x3c7) },
37763892
{ USB_DEVICE_WACOM(0x3dc) },

3.7/wacom_wac.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#define WACOM_REPORT_TPCHID 15
6666
#define WACOM_REPORT_CINTIQ 16
6767
#define WACOM_REPORT_MSPRO 16
68+
#define WACOM_REPORT_PRO2022 30
6869
#define WACOM_REPORT_INTUOS_PEN 16
6970
#define WACOM_REPORT_CINTIQPAD 17
7071
#define WACOM_REPORT_TPCST 16
@@ -91,6 +92,10 @@
9192
#define BTN_STYLUS3 0x149
9293
#endif
9394

95+
#ifndef MSC_TIMESTAMP
96+
#define MSC_TIMESTAMP 0x05
97+
#endif
98+
9499
#define WACOM_INTUOSP2_RING_UNTOUCHED 0x7f
95100
#define WACOM_POWER_SUPPLY_STATUS_AUTO -1
96101
enum {
@@ -127,6 +132,7 @@ enum {
127132
CINTIQ_COMPANION_2,
128133
WACOM_MSPRO,
129134
CINTIQ_16,
135+
WACOM_PRO2022,
130136
WACOM_ONE,
131137
CINTIQ,
132138
WACOM_BEE,
@@ -184,6 +190,7 @@ struct wacom_features {
184190
unsigned touch_max;
185191
int oVid;
186192
int oPid;
193+
unsigned short sequence_number;
187194
};
188195

189196
struct wacom_shared {

0 commit comments

Comments
 (0)