From: Jason Gerecke <hidden> Date: 2021-07-19 23:11:21
Commit 670e90924bfe ("HID: wacom: support named keys on older devices")
added support for sending named events from the soft buttons on the
24HDT and 27QHDT. In the process, however, it inadvertantly disabled the
touchscreen of the 24HDT and 27QHDT by default. The
`wacom_set_shared_values` function would normally enable touch by default
but because it checks the state of the non-shared `has_mute_touch_switch`
flag and `wacom_setup_touch_input_capabilities` sets the state of the
/shared/ version, touch ends up being disabled by default.
This patch sets the non-shared flag, letting `wacom_set_shared_values`
take care of copying the value over to the shared version and setting
the default touch state to "on".
Fixes: 670e90924bfe ("HID: wacom: support named keys on older devices")
CC: stable@vger.kernel.org # 5.4+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
---
drivers/hid/wacom_wac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Jason Gerecke <hidden> Date: 2021-07-19 23:38:10
Avoid doing unnecessary work when touch is disabled by detecting this
condition and returning early. Note that the probe process sends GET
FEATURE requests to discover e.g. HID_DG_CONTACTMAX, so we can't start
ignoring touch reports until probe finishes.
Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_sys.c | 1 +
drivers/hid/wacom_wac.c | 12 ++++++++++++
drivers/hid/wacom_wac.h | 1 +
3 files changed, 14 insertions(+)
@@ -2581,6 +2581,12 @@ static void wacom_wac_finger_event(struct hid_device *hdev,unsignedequivalent_usage=wacom_equivalent_usage(usage->hid);structwacom_features*features=&wacom->wacom_wac.features;+/* don't process touch events when touch is off */+if(wacom_wac->probe_complete&&+!wacom_wac->shared->is_touch_on&&+!wacom_wac->shared->touch_down)+return;+if(wacom_wac->is_invalid_bt_frame)return;
@@ -2630,6 +2636,12 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev,structhid_data*hid_data=&wacom_wac->hid_data;inti;+/* don't process touch events when touch is off */+if(wacom_wac->probe_complete&&+!wacom_wac->shared->is_touch_on&&+!wacom_wac->shared->touch_down)+return;+wacom_wac->is_invalid_bt_frame=false;for(i=0;i<report->maxfield;i++){
From: Jason Gerecke <hidden> Date: 2021-07-19 23:38:43
From: Ping Cheng <ping.cheng@wacom.com>
Wacom touch devices have two types of touch switches: softkey touch
toggle and hardware touch switch. For softkey toggle, we assume
touch is on by default in the driver. However the hardware touch
switch is controlled by end users. We don't know if it's on or off
before getting the status event.
This patch sets touch off for devices with a hardware switch until we
get the status. This is a bit safer for users who leave the switch "off"
and don't want any accidental touches. The tradeoff is a slight delay
between device connection and touch becoming enabled for users who
leave the switch "on".
Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_sys.c | 8 +++++++-
drivers/hid/wacom_wac.c | 12 ++++++++----
drivers/hid/wacom_wac.h | 1 +
3 files changed, 16 insertions(+), 5 deletions(-)
From: Jason Gerecke <hidden> Date: 2021-07-19 23:38:49
The `input_mt_get_slot_by_key` function may return a negative value
if an error occurs (e.g. running out of slots). If this occurs we
should really avoid reporting any data for the slot.
Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 3 +++
1 file changed, 3 insertions(+)
From: Jason Gerecke <hidden> Date: 2021-07-19 23:39:08
We perform this same set of tests to see if touch input is muted in
several places. We might as well replace these independent copies with
an inline function.
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
@@ -2593,10 +2596,7 @@ static void wacom_wac_finger_event(struct hid_device *hdev,unsignedequivalent_usage=wacom_equivalent_usage(usage->hid);structwacom_features*features=&wacom->wacom_wac.features;-/* don't process touch events when touch is off */-if(wacom_wac->probe_complete&&-!wacom_wac->shared->is_touch_on&&-!wacom_wac->shared->touch_down)+if(touch_is_muted(wacom_wac)&&!wacom_wac->shared->touch_down)return;if(wacom_wac->is_invalid_bt_frame)
@@ -2648,10 +2648,7 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev,structhid_data*hid_data=&wacom_wac->hid_data;inti;-/* don't process touch events when touch is off */-if(wacom_wac->probe_complete&&-!wacom_wac->shared->is_touch_on&&-!wacom_wac->shared->touch_down)+if(touch_is_muted(wacom_wac)&&!wacom_wac->shared->touch_down)return;wacom_wac->is_invalid_bt_frame=false;
From: Jason Gerecke <hidden> Date: 2021-07-19 23:39:40
Empty sync events clutter up logs and are a waste of CPU cycles. We can
avoid sending mt_sync events if touch is disabled or a specific slot is
unused. We can avoid sending full sync events if no events were generated.
Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
@@ -2551,8 +2551,17 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,intslot;slot=input_mt_get_slot_by_key(input,hid_data->id);-if(slot<0)+if(slot<0){return;+}else{+structinput_mt_slot*ps=&input->mt->slots[slot];+intmt_id=input_mt_get_value(ps,ABS_MT_TRACKING_ID);++if(!prox&&mt_id<0){+// No data to send for this slot; short-circuit+return;+}+}input_mt_slot(input,slot);input_mt_report_slot_state(input,MT_TOOL_FINGER,prox);
@@ -2696,6 +2705,10 @@ static void wacom_wac_finger_report(struct hid_device *hdev,structinput_dev*input=wacom_wac->touch_input;unsignedtouch_max=wacom_wac->features.touch_max;+/* if there was nothing to process, don't send an empty sync */+if(wacom_wac->hid_data.num_expected==0)+return;+/* If more packets of data are expected, give us a chance to*processthemratherthanimmediatelysyncingapartial*update.
Commit 670e90924bfe ("HID: wacom: support named keys on older devices")
added support for sending named events from the soft buttons on the
24HDT and 27QHDT. In the process, however, it inadvertantly disabled the
touchscreen of the 24HDT and 27QHDT by default. The
`wacom_set_shared_values` function would normally enable touch by default
but because it checks the state of the non-shared `has_mute_touch_switch`
flag and `wacom_setup_touch_input_capabilities` sets the state of the
/shared/ version, touch ends up being disabled by default.
This patch sets the non-shared flag, letting `wacom_set_shared_values`
take care of copying the value over to the shared version and setting
the default touch state to "on".
Fixes: 670e90924bfe ("HID: wacom: support named keys on older devices")
CC: stable@vger.kernel.org # 5.4+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
---
drivers/hid/wacom_wac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -3831,7 +3831,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,wacom_wac->shared->touch->product==0xF6){input_dev->evbit[0]|=BIT_MASK(EV_SW);__set_bit(SW_MUTE_DEVICE,input_dev->swbit);-wacom_wac->shared->has_mute_touch_switch=true;+wacom_wac->has_mute_touch_switch=true;}fallthrough;
This patch series looks strangely like not really a series at all :) I am
applying 1/6 and 4/6 for 5.14 and queuing the rest for 5.15. Please shout
if you disagree with that. Thanks,
--
Jiri Kosina
SUSE Labs