Skip to content

Commit 5c56b3e

Browse files
Pinglinuxjigpu
authored andcommitted
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]>
1 parent 9c59843 commit 5c56b3e

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

4.5/wacom_sys.c

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

21822182
error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
21832183
if (error) {
2184-
/* no pad in use on this interface */
2184+
/* no pad events using this interface */
21852185
input_free_device(pad_input_dev);
21862186
wacom_wac->pad_input = NULL;
21872187
pad_input_dev = NULL;

4.5/wacom_wac.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,6 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
20282028
wacom_wac->has_mute_touch_switch = true;
20292029
usage->type = EV_SW;
20302030
usage->code = SW_MUTE_DEVICE;
2031-
features->device_type |= WACOM_DEVICETYPE_PAD;
20322031
break;
20332032
case WACOM_HID_WD_TOUCHSTRIP:
20342033
wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
@@ -2108,6 +2107,30 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21082107
wacom_wac->hid_data.inrange_state |= value;
21092108
}
21102109

2110+
/* Process touch switch state first since it is reported through touch interface,
2111+
* which is indepentent of pad interface. In the case when there are no other pad
2112+
* events, the pad interface will not even be created.
2113+
*/
2114+
if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2115+
(equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
2116+
if (wacom_wac->shared->touch_input) {
2117+
bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2118+
2119+
if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2120+
*is_touch_on = !(*is_touch_on);
2121+
else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2122+
*is_touch_on = value;
2123+
2124+
input_report_switch(wacom_wac->shared->touch_input,
2125+
SW_MUTE_DEVICE, !(*is_touch_on));
2126+
input_sync(wacom_wac->shared->touch_input);
2127+
}
2128+
return;
2129+
}
2130+
2131+
if (!input)
2132+
return;
2133+
21112134
switch (equivalent_usage) {
21122135
case WACOM_HID_WD_TOUCHRING:
21132136
/*
@@ -2143,22 +2166,6 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
21432166
input_event(input, usage->type, usage->code, 0);
21442167
break;
21452168

2146-
case WACOM_HID_WD_MUTE_DEVICE:
2147-
case WACOM_HID_WD_TOUCHONOFF:
2148-
if (wacom_wac->shared->touch_input) {
2149-
bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2150-
2151-
if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2152-
*is_touch_on = !(*is_touch_on);
2153-
else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2154-
*is_touch_on = value;
2155-
2156-
input_report_switch(wacom_wac->shared->touch_input,
2157-
SW_MUTE_DEVICE, !(*is_touch_on));
2158-
input_sync(wacom_wac->shared->touch_input);
2159-
}
2160-
break;
2161-
21622169
case WACOM_HID_WD_MODE_CHANGE:
21632170
if (wacom_wac->is_direct_mode != value) {
21642171
wacom_wac->is_direct_mode = value;
@@ -2844,7 +2851,7 @@ void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
28442851
/* usage tests must precede field tests */
28452852
if (WACOM_BATTERY_USAGE(usage))
28462853
wacom_wac_battery_event(hdev, field, usage, value);
2847-
else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
2854+
else if (WACOM_PAD_FIELD(field))
28482855
wacom_wac_pad_event(hdev, field, usage, value);
28492856
else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
28502857
wacom_wac_pen_event(hdev, field, usage, value);

0 commit comments

Comments
 (0)