Skip to content

Commit 862cf55

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Introduce a new WACOM_DEVICETYPE_PAD device_type
Historically, both the touch and pad tools would have shared the 'BTN_TOOL_FINGER' type. Any time you needed to distinguish the two, you had to use some other bit of knowledge (e.g. that the pad was on the same interface as the pen, and thus 'touch_max' would be zero). To make these checks more readable, we introduce WACOM_DEVICETYPE_PAD. Although we still have to rely on other bits of knowledge to set this bit on the right interface (since it cannot be detected from the HID descriptor), it can be done just once inside 'wacom_setup_device_quirks'. This patch introduces no functional changes. Signed-off-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent aa86b18 commit 862cf55

File tree

3 files changed

+73
-64
lines changed

3 files changed

+73
-64
lines changed

drivers/hid/wacom_sys.c

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,9 @@ static int wacom_initialize_leds(struct wacom *wacom)
859859
{
860860
int error;
861861

862+
if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD))
863+
return 0;
864+
862865
/* Initialize default values */
863866
switch (wacom->wacom_wac.features.type) {
864867
case INTUOS4S:
@@ -892,17 +895,14 @@ static int wacom_initialize_leds(struct wacom *wacom)
892895
case INTUOSPS:
893896
case INTUOSPM:
894897
case INTUOSPL:
895-
if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PEN) {
896-
wacom->led.select[0] = 0;
897-
wacom->led.select[1] = 0;
898-
wacom->led.llv = 32;
899-
wacom->led.hlv = 0;
900-
wacom->led.img_lum = 0;
901-
902-
error = sysfs_create_group(&wacom->hdev->dev.kobj,
903-
&intuos5_led_attr_group);
904-
} else
905-
return 0;
898+
wacom->led.select[0] = 0;
899+
wacom->led.select[1] = 0;
900+
wacom->led.llv = 32;
901+
wacom->led.hlv = 0;
902+
wacom->led.img_lum = 0;
903+
904+
error = sysfs_create_group(&wacom->hdev->dev.kobj,
905+
&intuos5_led_attr_group);
906906
break;
907907

908908
default:
@@ -925,6 +925,9 @@ static void wacom_destroy_leds(struct wacom *wacom)
925925
if (!wacom->led_initialized)
926926
return;
927927

928+
if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD))
929+
return;
930+
928931
wacom->led_initialized = false;
929932

930933
switch (wacom->wacom_wac.features.type) {
@@ -948,9 +951,8 @@ static void wacom_destroy_leds(struct wacom *wacom)
948951
case INTUOSPS:
949952
case INTUOSPM:
950953
case INTUOSPL:
951-
if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PEN)
952-
sysfs_remove_group(&wacom->hdev->dev.kobj,
953-
&intuos5_led_attr_group);
954+
sysfs_remove_group(&wacom->hdev->dev.kobj,
955+
&intuos5_led_attr_group);
954956
break;
955957
}
956958
}
@@ -1297,6 +1299,9 @@ static void wacom_wireless_work(struct work_struct *work)
12971299
wacom_wac1->features =
12981300
*((struct wacom_features *)id->driver_data);
12991301
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PEN;
1302+
if (wacom_wac1->features.type != INTUOSHT &&
1303+
wacom_wac1->features.type != BAMBOO_PT)
1304+
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
13001305
snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen",
13011306
wacom_wac1->features.name);
13021307
snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
@@ -1315,16 +1320,16 @@ static void wacom_wireless_work(struct work_struct *work)
13151320
wacom_wac2->features =
13161321
*((struct wacom_features *)id->driver_data);
13171322
wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1318-
wacom_wac2->features.device_type |= WACOM_DEVICETYPE_TOUCH;
13191323
wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1320-
if (wacom_wac2->features.touch_max)
1321-
snprintf(wacom_wac2->name, WACOM_NAME_MAX,
1322-
"%s (WL) Finger",wacom_wac2->features.name);
1323-
else
1324-
snprintf(wacom_wac2->name, WACOM_NAME_MAX,
1325-
"%s (WL) Pad",wacom_wac2->features.name);
1324+
snprintf(wacom_wac2->name, WACOM_NAME_MAX,
1325+
"%s (WL) Finger",wacom_wac2->features.name);
13261326
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
1327-
"%s (WL) Pad", wacom_wac2->features.name);
1327+
"%s (WL) Pad",wacom_wac2->features.name);
1328+
if (wacom_wac1->features.touch_max)
1329+
wacom_wac2->features.device_type |= WACOM_DEVICETYPE_TOUCH;
1330+
if (wacom_wac1->features.type == INTUOSHT ||
1331+
wacom_wac1->features.type == BAMBOO_PT)
1332+
wacom_wac2->features.device_type |= WACOM_DEVICETYPE_PAD;
13281333
wacom_wac2->pid = wacom_wac->pid;
13291334
error = wacom_allocate_inputs(wacom2) ||
13301335
wacom_register_inputs(wacom2);
@@ -1456,12 +1461,12 @@ static void wacom_update_name(struct wacom *wacom)
14561461
"%s Pen", name);
14571462
}
14581463
else if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
1459-
if (features->touch_max)
1460-
snprintf(wacom_wac->name, sizeof(wacom_wac->name),
1461-
"%s Finger", name);
1462-
else
1463-
snprintf(wacom_wac->name, sizeof(wacom_wac->name),
1464-
"%s Pad", name);
1464+
snprintf(wacom_wac->name, sizeof(wacom_wac->name),
1465+
"%s Finger", name);
1466+
}
1467+
else if (features->device_type & WACOM_DEVICETYPE_PAD) {
1468+
snprintf(wacom_wac->name, sizeof(wacom_wac->name),
1469+
"%s Pad", name);
14651470
}
14661471
}
14671472

@@ -1604,8 +1609,8 @@ static int wacom_probe(struct hid_device *hdev,
16041609
if (features->quirks & WACOM_QUIRK_MONITOR)
16051610
error = hid_hw_open(hdev);
16061611

1607-
if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) {
1608-
if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH)
1612+
if (wacom_wac->features.type == INTUOSHT &&
1613+
wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) {
16091614
wacom_wac->shared->touch_input = wacom_wac->input;
16101615
}
16111616

drivers/hid/wacom_wac.c

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,6 +2167,15 @@ void wacom_setup_device_quirks(struct wacom *wacom)
21672167
{
21682168
struct wacom_features *features = &wacom->wacom_wac.features;
21692169

2170+
/* The pen and pad share the same interface on most devices */
2171+
if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
2172+
features->type == DTUS || features->type == WACOM_MO ||
2173+
(features->type >= INTUOS3S && features->type <= WACOM_13HD &&
2174+
features->type != INTUOSHT)) {
2175+
if (features->device_type & WACOM_DEVICETYPE_PEN)
2176+
features->device_type |= WACOM_DEVICETYPE_PAD;
2177+
}
2178+
21702179
/* touch device found but size is not defined. use default */
21712180
if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
21722181
features->x_max = 1023;
@@ -2182,7 +2191,10 @@ void wacom_setup_device_quirks(struct wacom *wacom)
21822191
if ((features->type >= INTUOS5S && features->type <= INTUOSHT) ||
21832192
(features->type == BAMBOO_PT)) {
21842193
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
2185-
features->device_type |= WACOM_DEVICETYPE_TOUCH;
2194+
if (features->touch_max)
2195+
features->device_type |= WACOM_DEVICETYPE_TOUCH;
2196+
if (features->type == BAMBOO_PT || features->type == INTUOSHT)
2197+
features->device_type |= WACOM_DEVICETYPE_PAD;
21862198

21872199
features->x_max = 4096;
21882200
features->y_max = 4096;
@@ -2241,7 +2253,7 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,
22412253
/* penabled devices have fixed resolution for each model */
22422254
input_abs_set_res(input_dev, ABS_X, features->x_resolution);
22432255
input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
2244-
} else {
2256+
} else if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
22452257
if (features->touch_max == 1) {
22462258
input_set_abs_params(input_dev, ABS_X, 0,
22472259
features->x_max, features->x_fuzz, 0);
@@ -2423,8 +2435,7 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
24232435
break;
24242436

24252437
case INTUOSHT:
2426-
if (features->touch_max &&
2427-
features->device_type & WACOM_DEVICETYPE_TOUCH) {
2438+
if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
24282439
input_dev->evbit[0] |= BIT_MASK(EV_SW);
24292440
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
24302441
}
@@ -2434,27 +2445,26 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
24342445
__clear_bit(ABS_MISC, input_dev->absbit);
24352446

24362447
if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
2437-
2438-
if (features->touch_max) {
2439-
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
2440-
input_set_abs_params(input_dev,
2441-
ABS_MT_TOUCH_MAJOR,
2442-
0, features->x_max, 0, 0);
2443-
input_set_abs_params(input_dev,
2444-
ABS_MT_TOUCH_MINOR,
2445-
0, features->y_max, 0, 0);
2446-
}
2447-
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
2448-
} else {
2449-
/* buttons/keys only interface */
2450-
__clear_bit(ABS_X, input_dev->absbit);
2451-
__clear_bit(ABS_Y, input_dev->absbit);
2452-
__clear_bit(BTN_TOUCH, input_dev->keybit);
2453-
2454-
/* PAD is setup by wacom_setup_pad_input_capabilities later */
2455-
return 1;
2448+
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
2449+
input_set_abs_params(input_dev,
2450+
ABS_MT_TOUCH_MAJOR,
2451+
0, features->x_max, 0, 0);
2452+
input_set_abs_params(input_dev,
2453+
ABS_MT_TOUCH_MINOR,
2454+
0, features->y_max, 0, 0);
24562455
}
2457-
} else if (features->device_type & WACOM_DEVICETYPE_PEN) {
2456+
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
2457+
}
2458+
if (features->device_type & WACOM_DEVICETYPE_PAD) {
2459+
/* buttons/keys only interface */
2460+
__clear_bit(ABS_X, input_dev->absbit);
2461+
__clear_bit(ABS_Y, input_dev->absbit);
2462+
__clear_bit(BTN_TOUCH, input_dev->keybit);
2463+
2464+
/* PAD is setup by wacom_setup_pad_input_capabilities later */
2465+
return 1;
2466+
}
2467+
if (features->device_type & WACOM_DEVICETYPE_PEN) {
24582468
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
24592469
__set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
24602470
__set_bit(BTN_TOOL_PEN, input_dev->keybit);
@@ -2482,6 +2492,9 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
24822492
struct wacom_features *features = &wacom_wac->features;
24832493
int i;
24842494

2495+
if (!(features->device_type & WACOM_DEVICETYPE_PAD))
2496+
return -ENODEV;
2497+
24852498
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
24862499

24872500
/* kept for making legacy xf86-input-wacom working with the wheels */
@@ -2618,10 +2631,6 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
26182631

26192632
case INTUOS5S:
26202633
case INTUOSPS:
2621-
/* touch interface does not have the pad device */
2622-
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
2623-
return -ENODEV;
2624-
26252634
for (i = 0; i < 7; i++)
26262635
__set_bit(BTN_0 + i, input_dev->keybit);
26272636

@@ -2663,12 +2672,6 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
26632672

26642673
case INTUOSHT:
26652674
case BAMBOO_PT:
2666-
/* pad device is on the touch interface */
2667-
if (!(features->device_type & WACOM_DEVICETYPE_TOUCH) ||
2668-
/* Bamboo Pen only tablet does not have pad */
2669-
((features->type == BAMBOO_PT) && !features->touch_max))
2670-
return -ENODEV;
2671-
26722675
__clear_bit(ABS_MISC, input_dev->absbit);
26732676

26742677
__set_bit(BTN_LEFT, input_dev->keybit);

drivers/hid/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#define WACOM_DEVICETYPE_NONE 0x0000
7777
#define WACOM_DEVICETYPE_PEN 0x0001
7878
#define WACOM_DEVICETYPE_TOUCH 0x0002
79+
#define WACOM_DEVICETYPE_PAD 0x0004
7980

8081
#define WACOM_VENDORDEFINED_PEN 0xff0d0001
8182

0 commit comments

Comments
 (0)