Skip to content

Commit 3b164a0

Browse files
PinglinuxJiri Kosina
authored andcommitted
HID: wacom: Cleanup unsupported device_type for BAMBOO_PT
Not all Bamboo support both pen and touch. Make sure we deal with pen only and touch only devices properly. Signed-off-by: Ping Cheng <[email protected]> Tested-By: Aaron Skomra <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 851328f commit 3b164a0

File tree

3 files changed

+54
-30
lines changed

3 files changed

+54
-30
lines changed

drivers/hid/wacom_sys.c

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static void wacom_usage_mapping(struct hid_device *hdev,
211211
* Bamboo models do not support HID_DG_CONTACTMAX.
212212
* And, Bamboo Pen only descriptor contains touch.
213213
*/
214-
if (features->type != BAMBOO_PT) {
214+
if (features->type > BAMBOO_PT) {
215215
/* ISDv4 touch devices at least supports one touch point */
216216
if (finger && !features->touch_max)
217217
features->touch_max = 1;
@@ -222,7 +222,8 @@ static void wacom_usage_mapping(struct hid_device *hdev,
222222
features->x_max = field->logical_maximum;
223223
if (finger) {
224224
features->x_phy = field->physical_maximum;
225-
if (features->type != BAMBOO_PT) {
225+
if ((features->type != BAMBOO_PT) &&
226+
(features->type != BAMBOO_TOUCH)) {
226227
features->unit = field->unit;
227228
features->unitExpo = field->unit_exponent;
228229
}
@@ -232,7 +233,8 @@ static void wacom_usage_mapping(struct hid_device *hdev,
232233
features->y_max = field->logical_maximum;
233234
if (finger) {
234235
features->y_phy = field->physical_maximum;
235-
if (features->type != BAMBOO_PT) {
236+
if ((features->type != BAMBOO_PT) &&
237+
(features->type != BAMBOO_TOUCH)) {
236238
features->unit = field->unit;
237239
features->unitExpo = field->unit_exponent;
238240
}
@@ -1547,15 +1549,16 @@ static void wacom_wireless_work(struct work_struct *work)
15471549
wacom_wac1->features =
15481550
*((struct wacom_features *)id->driver_data);
15491551
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PEN;
1550-
if (wacom_wac1->features.type != INTUOSHT &&
1551-
wacom_wac1->features.type != BAMBOO_PT)
1552-
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
15531552
wacom_set_default_phy(&wacom_wac1->features);
15541553
wacom_calculate_res(&wacom_wac1->features);
15551554
snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
15561555
wacom_wac1->features.name);
1557-
snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
1558-
wacom_wac1->features.name);
1556+
if (wacom_wac1->features.type < BAMBOO_PEN ||
1557+
wacom_wac1->features.type > BAMBOO_PT) {
1558+
snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
1559+
wacom_wac1->features.name);
1560+
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
1561+
}
15591562
wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
15601563
wacom_wac1->shared->type = wacom_wac1->features.type;
15611564
wacom_wac1->pid = wacom_wac->pid;
@@ -1575,13 +1578,14 @@ static void wacom_wireless_work(struct work_struct *work)
15751578
wacom_calculate_res(&wacom_wac2->features);
15761579
snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
15771580
"%s (WL) Finger",wacom_wac2->features.name);
1578-
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
1579-
"%s (WL) Pad",wacom_wac2->features.name);
15801581
if (wacom_wac1->features.touch_max)
15811582
wacom_wac2->features.device_type |= WACOM_DEVICETYPE_TOUCH;
1582-
if (wacom_wac1->features.type == INTUOSHT ||
1583-
wacom_wac1->features.type == BAMBOO_PT)
1583+
if (wacom_wac1->features.type >= INTUOSHT &&
1584+
wacom_wac1->features.type <= BAMBOO_PT) {
1585+
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
1586+
"%s (WL) Pad",wacom_wac2->features.name);
15841587
wacom_wac2->features.device_type |= WACOM_DEVICETYPE_PAD;
1588+
}
15851589
wacom_wac2->pid = wacom_wac->pid;
15861590
error = wacom_allocate_inputs(wacom2) ||
15871591
wacom_register_inputs(wacom2);
@@ -1772,6 +1776,24 @@ static int wacom_probe(struct hid_device *hdev,
17721776
features->device_type |= WACOM_DEVICETYPE_PEN;
17731777
}
17741778

1779+
/* Note that if query fails it is not a hard failure */
1780+
wacom_query_tablet_data(hdev, features);
1781+
1782+
/* touch only Bamboo doesn't support pen */
1783+
if ((features->type == BAMBOO_TOUCH) &&
1784+
(features->device_type & WACOM_DEVICETYPE_PEN)) {
1785+
error = -ENODEV;
1786+
goto fail_shared_data;
1787+
}
1788+
1789+
/* pen only Bamboo neither support touch nor pad */
1790+
if ((features->type == BAMBOO_PEN) &&
1791+
((features->device_type & WACOM_DEVICETYPE_TOUCH) ||
1792+
(features->device_type & WACOM_DEVICETYPE_PAD))) {
1793+
error = -ENODEV;
1794+
goto fail_shared_data;
1795+
}
1796+
17751797
wacom_calculate_res(features);
17761798

17771799
wacom_update_name(wacom);
@@ -1809,9 +1831,6 @@ static int wacom_probe(struct hid_device *hdev,
18091831
goto fail_hw_start;
18101832
}
18111833

1812-
/* Note that if query fails it is not a hard failure */
1813-
wacom_query_tablet_data(hdev, features);
1814-
18151834
if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR)
18161835
error = hid_hw_open(hdev);
18171836

drivers/hid/wacom_wac.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,8 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
23002300
break;
23012301

23022302
case BAMBOO_PT:
2303+
case BAMBOO_PEN:
2304+
case BAMBOO_TOUCH:
23032305
case INTUOSHT:
23042306
if (wacom_wac->data[0] == WACOM_REPORT_USB)
23052307
sync = wacom_status_irq(wacom_wac, len);
@@ -2387,9 +2389,8 @@ void wacom_setup_device_quirks(struct wacom *wacom)
23872389

23882390
/* The pen and pad share the same interface on most devices */
23892391
if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
2390-
features->type == DTUS || features->type == WACOM_MO ||
2391-
(features->type >= INTUOS3S && features->type <= WACOM_13HD &&
2392-
features->type != INTUOSHT)) {
2392+
features->type == DTUS ||
2393+
(features->type >= INTUOS3S && features->type <= WACOM_MO)) {
23932394
if (features->device_type & WACOM_DEVICETYPE_PEN)
23942395
features->device_type |= WACOM_DEVICETYPE_PAD;
23952396
}
@@ -2406,12 +2407,12 @@ void wacom_setup_device_quirks(struct wacom *wacom)
24062407
* interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
24072408
* tablet values.
24082409
*/
2409-
if ((features->type >= INTUOS5S && features->type <= INTUOSHT) ||
2410-
(features->type == BAMBOO_PT)) {
2410+
if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
2411+
(features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
24112412
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
24122413
if (features->touch_max)
24132414
features->device_type |= WACOM_DEVICETYPE_TOUCH;
2414-
if (features->type == BAMBOO_PT || features->type == INTUOSHT)
2415+
if (features->type >= INTUOSHT || features->type <= BAMBOO_PT)
24152416
features->device_type |= WACOM_DEVICETYPE_PAD;
24162417

24172418
features->x_max = 4096;
@@ -2598,6 +2599,7 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
25982599

25992600
case INTUOSHT:
26002601
case BAMBOO_PT:
2602+
case BAMBOO_PEN:
26012603
__clear_bit(ABS_MISC, input_dev->absbit);
26022604

26032605
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
@@ -2693,6 +2695,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
26932695
/* fall through */
26942696

26952697
case BAMBOO_PT:
2698+
case BAMBOO_TOUCH:
26962699
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
26972700
input_set_abs_params(input_dev,
26982701
ABS_MT_TOUCH_MAJOR,
@@ -2845,6 +2848,7 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
28452848

28462849
case INTUOSHT:
28472850
case BAMBOO_PT:
2851+
case BAMBOO_TOUCH:
28482852
__clear_bit(ABS_MISC, input_dev->absbit);
28492853

28502854
__set_bit(BTN_LEFT, input_dev->keybit);
@@ -3235,11 +3239,10 @@ static const struct wacom_features wacom_features_0x47 =
32353239
{ "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
32363240
INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
32373241
static const struct wacom_features wacom_features_0x84 =
3238-
{ "Wacom Wireless Receiver", 0, 0, 0, 0,
3239-
WIRELESS, 0, 0, .touch_max = 16 };
3242+
{ "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
32403243
static const struct wacom_features wacom_features_0xD0 =
32413244
{ "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
3242-
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
3245+
BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
32433246
static const struct wacom_features wacom_features_0xD1 =
32443247
{ "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
32453248
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
@@ -3251,10 +3254,10 @@ static const struct wacom_features wacom_features_0xD3 =
32513254
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
32523255
static const struct wacom_features wacom_features_0xD4 =
32533256
{ "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
3254-
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3257+
BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
32553258
static const struct wacom_features wacom_features_0xD5 =
32563259
{ "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
3257-
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3260+
BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
32583261
static const struct wacom_features wacom_features_0xD6 =
32593262
{ "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
32603263
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
@@ -3281,7 +3284,7 @@ static const struct wacom_features wacom_features_0xDF =
32813284
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
32823285
static const struct wacom_features wacom_features_0x300 =
32833286
{ "Wacom Bamboo One S", 14720, 9225, 1023, 31,
3284-
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3287+
BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
32853288
static const struct wacom_features wacom_features_0x301 =
32863289
{ "Wacom Bamboo One M", 21648, 13530, 1023, 31,
32873290
BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -3329,8 +3332,8 @@ static const struct wacom_features wacom_features_0x323 =
33293332
INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
33303333
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
33313334
static const struct wacom_features wacom_features_0x331 =
3332-
{ "Wacom Express Key Remote", 0, 0, 0, 0,
3333-
REMOTE, 0, 0, 18, .check_for_hid_type = true,
3335+
{ "Wacom Express Key Remote", .type = REMOTE,
3336+
.numbered_buttons = 18, .check_for_hid_type = true,
33343337
.hid_type = HID_TYPE_USBNONE };
33353338

33363339
static const struct wacom_features wacom_features_HID_ANY_ID =

drivers/hid/wacom_wac.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ enum {
117117
INTUOSPS,
118118
INTUOSPM,
119119
INTUOSPL,
120-
INTUOSHT,
121120
WACOM_21UX2,
122121
WACOM_22HD,
123122
DTK,
@@ -129,6 +128,9 @@ enum {
129128
WACOM_13HD,
130129
WACOM_MO,
131130
WIRELESS,
131+
BAMBOO_PEN,
132+
INTUOSHT,
133+
BAMBOO_TOUCH,
132134
BAMBOO_PT,
133135
WACOM_24HDT,
134136
WACOM_27QHDT,

0 commit comments

Comments
 (0)