Skip to content

Commit 46011e9

Browse files
author
Jiri Kosina
committed
Merge branch 'for-4.20/multitouch' into for-linus
hid-multitouch driver cleanup
2 parents 5099bc8 + 7ffa13b commit 46011e9

File tree

1 file changed

+32
-40
lines changed

1 file changed

+32
-40
lines changed

drivers/hid/hid-multitouch.c

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,13 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
13191319
return mt_touch_input_mapping(hdev, hi, field, usage, bit, max,
13201320
application);
13211321

1322+
/*
1323+
* some egalax touchscreens have "application == DG_TOUCHSCREEN"
1324+
* for the stylus. Overwrite the hid_input application
1325+
*/
1326+
if (field->physical == HID_DG_STYLUS)
1327+
hi->application = HID_DG_STYLUS;
1328+
13221329
/* let hid-core decide for the others */
13231330
return 0;
13241331
}
@@ -1507,14 +1514,12 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
15071514
struct mt_device *td = hid_get_drvdata(hdev);
15081515
char *name;
15091516
const char *suffix = NULL;
1510-
unsigned int application = 0;
15111517
struct mt_report_data *rdata;
15121518
struct mt_application *mt_application = NULL;
15131519
struct hid_report *report;
15141520
int ret;
15151521

15161522
list_for_each_entry(report, &hi->reports, hidinput_list) {
1517-
application = report->application;
15181523
rdata = mt_find_report_data(td, report);
15191524
if (!rdata) {
15201525
hid_err(hdev, "failed to allocate data for report\n");
@@ -1529,46 +1534,33 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
15291534
if (ret)
15301535
return ret;
15311536
}
1532-
1533-
/*
1534-
* some egalax touchscreens have "application == DG_TOUCHSCREEN"
1535-
* for the stylus. Check this first, and then rely on
1536-
* the application field.
1537-
*/
1538-
if (report->field[0]->physical == HID_DG_STYLUS) {
1539-
suffix = "Pen";
1540-
/* force BTN_STYLUS to allow tablet matching in udev */
1541-
__set_bit(BTN_STYLUS, hi->input->keybit);
1542-
}
15431537
}
15441538

1545-
if (!suffix) {
1546-
switch (application) {
1547-
case HID_GD_KEYBOARD:
1548-
case HID_GD_KEYPAD:
1549-
case HID_GD_MOUSE:
1550-
case HID_DG_TOUCHPAD:
1551-
case HID_GD_SYSTEM_CONTROL:
1552-
case HID_CP_CONSUMER_CONTROL:
1553-
case HID_GD_WIRELESS_RADIO_CTLS:
1554-
case HID_GD_SYSTEM_MULTIAXIS:
1555-
/* already handled by hid core */
1556-
break;
1557-
case HID_DG_TOUCHSCREEN:
1558-
/* we do not set suffix = "Touchscreen" */
1559-
hi->input->name = hdev->name;
1560-
break;
1561-
case HID_DG_STYLUS:
1562-
/* force BTN_STYLUS to allow tablet matching in udev */
1563-
__set_bit(BTN_STYLUS, hi->input->keybit);
1564-
break;
1565-
case HID_VD_ASUS_CUSTOM_MEDIA_KEYS:
1566-
suffix = "Custom Media Keys";
1567-
break;
1568-
default:
1569-
suffix = "UNKNOWN";
1570-
break;
1571-
}
1539+
switch (hi->application) {
1540+
case HID_GD_KEYBOARD:
1541+
case HID_GD_KEYPAD:
1542+
case HID_GD_MOUSE:
1543+
case HID_DG_TOUCHPAD:
1544+
case HID_GD_SYSTEM_CONTROL:
1545+
case HID_CP_CONSUMER_CONTROL:
1546+
case HID_GD_WIRELESS_RADIO_CTLS:
1547+
case HID_GD_SYSTEM_MULTIAXIS:
1548+
/* already handled by hid core */
1549+
break;
1550+
case HID_DG_TOUCHSCREEN:
1551+
/* we do not set suffix = "Touchscreen" */
1552+
hi->input->name = hdev->name;
1553+
break;
1554+
case HID_DG_STYLUS:
1555+
/* force BTN_STYLUS to allow tablet matching in udev */
1556+
__set_bit(BTN_STYLUS, hi->input->keybit);
1557+
break;
1558+
case HID_VD_ASUS_CUSTOM_MEDIA_KEYS:
1559+
suffix = "Custom Media Keys";
1560+
break;
1561+
default:
1562+
suffix = "UNKNOWN";
1563+
break;
15721564
}
15731565

15741566
if (suffix) {

0 commit comments

Comments
 (0)