Skip to content

Commit be51818

Browse files
Pinglinuxjigpu
authored andcommitted
backport: HID: wacom: Don't register pad_input for touch switch
Touch switch state is received through WACOM_PAD_FIELD. However, it is reported by touch_input. Don't register pad_input if no other pad events require the interface. Cc: [email protected] Signed-off-by: Ping Cheng <[email protected]> Reviewed-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> [[email protected]: Imported into input-wacom (d6b675687a)] Signed-off-by: Jason Gerecke <[email protected]> [[email protected]: Backported from input-wacom (5c56b3e)] Signed-off-by: Jason Gerecke <[email protected]>
1 parent 2b9a520 commit be51818

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

3.17/wacom_sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ static int wacom_register_inputs(struct wacom *wacom)
20142014

20152015
error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
20162016
if (error) {
2017-
/* no pad in use on this interface */
2017+
/* no pad events using this interface */
20182018
input_free_device(pad_input_dev);
20192019
wacom_wac->pad_input = NULL;
20202020
pad_input_dev = NULL;

3.17/wacom_wac.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,6 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
20362036
wacom_wac->has_mute_touch_switch = true;
20372037
usage->type = EV_SW;
20382038
usage->code = SW_MUTE_DEVICE;
2039-
features->device_type |= WACOM_DEVICETYPE_PAD;
20402039
break;
20412040
case WACOM_HID_WD_TOUCHSTRIP:
20422041
wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
@@ -2114,6 +2113,30 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21142113
wacom_wac->hid_data.inrange_state |= value;
21152114
}
21162115

2116+
/* Process touch switch state first since it is reported through touch interface,
2117+
* which is indepentent of pad interface. In the case when there are no other pad
2118+
* events, the pad interface will not even be created.
2119+
*/
2120+
if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2121+
(equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
2122+
if (wacom_wac->shared->touch_input) {
2123+
bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2124+
2125+
if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2126+
*is_touch_on = !(*is_touch_on);
2127+
else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2128+
*is_touch_on = value;
2129+
2130+
input_report_switch(wacom_wac->shared->touch_input,
2131+
SW_MUTE_DEVICE, !(*is_touch_on));
2132+
input_sync(wacom_wac->shared->touch_input);
2133+
}
2134+
return;
2135+
}
2136+
2137+
if (!input)
2138+
return;
2139+
21172140
switch (equivalent_usage) {
21182141
case WACOM_HID_WD_TOUCHRING:
21192142
/*
@@ -2149,22 +2172,6 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21492172
input_event(input, usage->type, usage->code, 0);
21502173
break;
21512174

2152-
case WACOM_HID_WD_MUTE_DEVICE:
2153-
case WACOM_HID_WD_TOUCHONOFF:
2154-
if (wacom_wac->shared->touch_input) {
2155-
bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2156-
2157-
if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2158-
*is_touch_on = !(*is_touch_on);
2159-
else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2160-
*is_touch_on = value;
2161-
2162-
input_report_switch(wacom_wac->shared->touch_input,
2163-
SW_MUTE_DEVICE, !(*is_touch_on));
2164-
input_sync(wacom_wac->shared->touch_input);
2165-
}
2166-
break;
2167-
21682175
case WACOM_HID_WD_MODE_CHANGE:
21692176
if (wacom_wac->is_direct_mode != value) {
21702177
wacom_wac->is_direct_mode = value;
@@ -2851,7 +2858,7 @@ void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
28512858
/* usage tests must precede field tests */
28522859
if (WACOM_BATTERY_USAGE(usage))
28532860
wacom_wac_battery_event(hdev, field, usage, value);
2854-
else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
2861+
else if (WACOM_PAD_FIELD(field))
28552862
wacom_wac_pad_event(hdev, field, usage, value);
28562863
else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
28572864
wacom_wac_pen_event(hdev, field, usage, value);

0 commit comments

Comments
 (0)