From patchwork Mon Jul 19 20:55:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 12387067 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C4E6C07E95 for ; Mon, 19 Jul 2021 23:39:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1456461029 for ; Mon, 19 Jul 2021 23:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243804AbhGSW6K (ORCPT ); Mon, 19 Jul 2021 18:58:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346539AbhGSUPS (ORCPT ); Mon, 19 Jul 2021 16:15:18 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B944BC061762; Mon, 19 Jul 2021 13:54:17 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id p4-20020a17090a9304b029016f3020d867so996093pjo.3; Mon, 19 Jul 2021 13:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u9XC1U01PZSZTEYtwmGzB+/FSp9gyv7FlSh+467nObk=; b=aG/6shL9LTqm2pl+TFGNYDVOdqwlnLv9VZlMQTjYjOx1n52kowKRgdRmtM5Xwb59U/ HURFdosEYqp8cnGqQQp2VRxXqmTM1bftN7g0nY/SOe8jCYaZDfNP4oWU9bfMtIlwKRi/ f8I2sYU7Q7eGJmsRzBmZLKULcHkIalnBa3zqbBP+5b1MJ2hlbhhuQsBOv6i28lmY1OSf elGsZMlZZqaT8UNo72PLH4wDpQQVu1/0NqpSFaUrTwk1RqXzfHLyT1S9wYelWCkQ2/n9 tCOF+Crhk+/iq/lmLsfwu8GHyuA6t3uA++GsvIyYqg9Q2tyDCqJrj5mSfgGIKEFpNisL tfbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u9XC1U01PZSZTEYtwmGzB+/FSp9gyv7FlSh+467nObk=; b=Um92DUOIQHkaUH9Zh4wChFx7ZD0dDwsXtAwPUzzU4gfhBsksrD1dPauA7tPeGdw1xe IhrzbD+2eepewIM3vz7p5HUc4Sm3myOWkYwDzUUObhjl4X30qfmTmQVD/QcSilqZPzIo qk0cMskA/9s+m66AkQIPhqluFe2qSs7i3dIsNBqyeJVOzCqcY/8qPHkLF5f8b96cWhTE vHtrwDyoJ5raPUQvO+iymCcN0ITSeE3kK+jhsa2tRfL/fNaTPsxei5hZ1ZH3Pp+ap3Za jZYJN0Tu1GTTEh+zjLShwgu5sJy4pGhzlLEXSkMBRoZqJMttvMeW3mouMiB7fwValRf9 rWzg== X-Gm-Message-State: AOAM532+DXT36tLgLGyVZVXo0EaLF8TDRio834xh6NVkUjVluhNXFaaN vX6Oo4gB6515oKp7pLpfBPmDT1Ndeho4qg== X-Google-Smtp-Source: ABdhPJz0kP/3R5tJiG/EF/VpmbfPdaT2p8ywtwP5dnOzYubGCzEuw5iXwslEPXSTuv4a4rrYKTwOZA== X-Received: by 2002:a17:90a:6d63:: with SMTP id z90mr27576948pjj.177.1626728142836; Mon, 19 Jul 2021 13:55:42 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:42 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Jason Gerecke , stable@vger.kernel.org, Ping Cheng Subject: [PATCH 1/6] HID: wacom: Re-enable touch by default for Cintiq 24HDT / 27QHDT Date: Mon, 19 Jul 2021 13:55:28 -0700 Message-Id: <20210719205533.2189804-1-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 Reviewed-by: Ping Cheng --- drivers/hid/wacom_wac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 81d7d12bcf34..496a000ef862 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -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; From patchwork Mon Jul 19 20:55:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 12387061 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 720D0C07E9B for ; Mon, 19 Jul 2021 23:38:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59D68610F7 for ; Mon, 19 Jul 2021 23:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352812AbhGSW5U (ORCPT ); Mon, 19 Jul 2021 18:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345648AbhGSUPR (ORCPT ); Mon, 19 Jul 2021 16:15:17 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB2CBC061766 for ; Mon, 19 Jul 2021 13:54:18 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id p14-20020a17090ad30eb02901731c776526so493863pju.4 for ; Mon, 19 Jul 2021 13:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W22iJGxX2OAA41FydcLwVMM8jH6XnncPKRGPCWl0jvU=; b=Hx33IV2E49AjhtHem0Eyw3eyNYOkuPPWOh5OCMObrQqygCD1Yi0ZugQivJ5nmkBVCh dEIlAybrI362KO6hw8ZxmuM1uuQc2otXw+HjCyuAIMLVPihcjMNEOZkckxKQ4jFZLlSF N+qxKR7py6+Glppro5TIJcsV6l9jDX3NM/qbTjJ+gYlpDCR3RQDk52CdU7eMEJd+XfrS PRmTb3NOq5bQU1VHZjSlxYB7piXAu8F6ZBks+rRqFHy1EaokYW3bxMhCEzRINZ2XGFqH mO3mmoswId5kAoyiOnArt9LVQ4s968b8aObacGftjKP8Y5esV1vEMmZfdB5QiNDdoTVv xUew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W22iJGxX2OAA41FydcLwVMM8jH6XnncPKRGPCWl0jvU=; b=JPIIRn+arlJgVSJXqUfRoEP0QFnW6W56k2Vz3yt0xibrWs9gCXD8yMxyVSg5zHVBmU 95BQV6RM23zM6xCGrngFzTMmlVCheDSb5Xz/zNYfm4+0gUSRkTdnYbnYhbMBtJnnMePz 97CXLynibMc3ZWrL9+m/T4loIAQbjEGvjZFAp25E80PhUpaJFu1Pomj8vMjb5gx1T3MF 6j6L6v82LUKd7V7m6g5+P8hVWh5jVQ+w2b6aEv90kKrSf+3eC23Z9ffK8pF/Um0ao/KG BvO+3/m9I6aGNcx8NfP3U4tQxr/ftPAex0LC5xycVz34/OdnjISUwQVeHXTQh9AZu3Yu 8DNQ== X-Gm-Message-State: AOAM533IEPz8IYseNG8r5JXO6/2GRAGwIvQReCUuJTlEzW0k/9yXvFID PBI4t2jqcsx4YOnO5gPwkEYHeb7IBMvMXA== X-Google-Smtp-Source: ABdhPJzcqSkC5RgUKGym1xqQDScCSgp4M9mOk0x1bctVsRXV7N3t7+Ew9+7mwYjzNhW3ZodsGmyJYQ== X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr26152369pjl.134.1626728144007; Mon, 19 Jul 2021 13:55:44 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:43 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Ping Cheng , Jason Gerecke Subject: [PATCH 2/6] HID: wacom: set initial hardware touch switch state to 'off' Date: Mon, 19 Jul 2021 13:55:29 -0700 Message-Id: <20210719205533.2189804-2-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719205533.2189804-1-jason.gerecke@wacom.com> References: <20210719205533.2189804-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Ping Cheng 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 Reviewed-by: Jason Gerecke Tested-by: Jason Gerecke --- 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(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 57bfa0ae9836..713a2504092f 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -2287,7 +2287,13 @@ static void wacom_set_shared_values(struct wacom_wac *wacom_wac) if (wacom_wac->has_mute_touch_switch) { wacom_wac->shared->has_mute_touch_switch = true; - wacom_wac->shared->is_touch_on = true; + /* Hardware touch switch may be off. Wait until + * we know the switch state to decide is_touch_on. + * Softkey state should be initialized to "on" to + * match historic default. + */ + if (wacom_wac->is_soft_touch_switch) + wacom_wac->shared->is_touch_on = true; } if (wacom_wac->shared->has_mute_touch_switch && diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 496a000ef862..b87fbd2a81a6 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1987,14 +1987,17 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, features->numbered_buttons++; features->device_type |= WACOM_DEVICETYPE_PAD; break; - case WACOM_HID_WD_TOUCHONOFF: case WACOM_HID_WD_MUTE_DEVICE: + /* softkey touch switch */ + wacom_wac->is_soft_touch_switch = true; + fallthrough; + case WACOM_HID_WD_TOUCHONOFF: /* - * This usage, which is used to mute touch events, comes - * from the pad packet, but is reported on the touch + * These two usages, which are used to mute touch events, come + * from the pad packet, but are reported on the touch * interface. Because the touch interface may not have * been created yet, we cannot call wacom_map_usage(). In - * order to process this usage when we receive it, we set + * order to process the usages when we receive them, we set * the usage type and code directly. */ wacom_wac->has_mute_touch_switch = true; @@ -3832,6 +3835,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, input_dev->evbit[0] |= BIT_MASK(EV_SW); __set_bit(SW_MUTE_DEVICE, input_dev->swbit); wacom_wac->has_mute_touch_switch = true; + wacom_wac->is_soft_touch_switch = true; } fallthrough; diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 8f16654eca09..4e9eb0c1eff6 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -352,6 +352,7 @@ struct wacom_wac { int mode_value; struct hid_data hid_data; bool has_mute_touch_switch; + bool is_soft_touch_switch; bool has_mode_change; bool is_direct_mode; bool is_invalid_bt_frame; From patchwork Mon Jul 19 20:55:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 12387059 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FEACC12002 for ; Mon, 19 Jul 2021 23:38:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C4476113E for ; Mon, 19 Jul 2021 23:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349995AbhGSW5R (ORCPT ); Mon, 19 Jul 2021 18:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344228AbhGSUPR (ORCPT ); Mon, 19 Jul 2021 16:15:17 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30DA0C061767 for ; Mon, 19 Jul 2021 13:54:20 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id bt15so12328506pjb.2 for ; Mon, 19 Jul 2021 13:55:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LlFQQvD8aZgpaVpFvO8lQNzn5mt/bIYYE36oNLpqeq4=; b=OgypN5jJLsqNFUdY2UnHHta0Mb9q3rZ2Ei35gd91VxrgcjWQsOnyIoJRmvyc2IksqT MiTR+cOijxAPMXKWthqnfGS+m4gG2QWeZK1BCfrDjYGcpLKXGvcWc4BQoJE8IXPXHWg0 189viG7pdoCrwjEIHa0hzAeRNMvotsdArjN1iSDlWhoirvWQVuUhxQ6QMqcjDG4MUqPQ vjsg0Wqf9Zw2A3zBtgPhpVWPHrKWqarnRjsXygyrsfO+H0bibRMjnuG5nbV7PDwtQPIZ KTtTGdphtLM5oHFi/Fmy1boLtdxlETz5faTfJjVtg938KnxLcMtdA5IOMEeCFSgE4BIP 8beg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LlFQQvD8aZgpaVpFvO8lQNzn5mt/bIYYE36oNLpqeq4=; b=MQxcdTys2gQh0QqNboNp1AJrzS1mZEzQ2d51+Up+fD9Ul29aJL2b8UZps/O4Ftx7qd Z0Sla6AhEGfmoYF5Z5JOtQDMgqarIBo94sEkmter2XG9sOkAXavQ5oXFUw3mKKnHN82C /a3mZnNZnNJAw89dtXtc5s+xGY8NZOFpK1cxWuTzmXttSw2A+osG8RVv8X5g3NEhG6dr yxAO/aDEbCNORnUMLz3wxGOBLWQwVr/M8Lv4uUKsbQoJEFmWoJVHKf6Uc4yQ9bq2T9lR HEYiL3siKeapkDFh6PR7Dm9HpUv8rBDr60pJ6oozc0A4Vw1UnaQxbK4AzAvtSisTY+ZD wWvA== X-Gm-Message-State: AOAM532pmg60C8iJ2v/flei1U2rlz7aoRNX2+k6rt1IUtrg0v4VIDrja GT9YSufS7WCp85YAzqeP+d8D+EtyDP15rg== X-Google-Smtp-Source: ABdhPJx2GDf8xvIy2yBm7Slbp1BC8a4NkcUBk9ufllrIUPuSS2HoJsKXZbNAMLSgG6Mx+4MK/14/EQ== X-Received: by 2002:a17:902:b717:b029:11a:fae3:ba7c with SMTP id d23-20020a170902b717b029011afae3ba7cmr20296937pls.28.1626728145185; Mon, 19 Jul 2021 13:55:45 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:44 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Jason Gerecke , Ping Cheng Subject: [PATCH 3/6] HID: wacom: Short-circuit processing of touch when it is disabled Date: Mon, 19 Jul 2021 13:55:30 -0700 Message-Id: <20210719205533.2189804-3-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719205533.2189804-1-jason.gerecke@wacom.com> References: <20210719205533.2189804-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 Signed-off-by: Jason Gerecke --- drivers/hid/wacom_sys.c | 1 + drivers/hid/wacom_wac.c | 12 ++++++++++++ drivers/hid/wacom_wac.h | 1 + 3 files changed, 14 insertions(+) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 713a2504092f..93f49b766376 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -2797,6 +2797,7 @@ static int wacom_probe(struct hid_device *hdev, error); } + wacom_wac->probe_complete = true; return 0; } diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index b87fbd2a81a6..27587070a192 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2581,6 +2581,12 @@ static void wacom_wac_finger_event(struct hid_device *hdev, unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); struct wacom_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, struct hid_data* hid_data = &wacom_wac->hid_data; int i; + /* 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++) { diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 4e9eb0c1eff6..8b2d4e5b2303 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -337,6 +337,7 @@ struct wacom_wac { int tool[2]; int id[2]; __u64 serial[2]; + bool probe_complete; bool reporting_data; struct wacom_features features; struct wacom_shared *shared; From patchwork Mon Jul 19 20:55:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 12387063 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5BE6C07E9D for ; Mon, 19 Jul 2021 23:38:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2D40610D2 for ; Mon, 19 Jul 2021 23:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355423AbhGSW5X (ORCPT ); Mon, 19 Jul 2021 18:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345751AbhGSUPS (ORCPT ); Mon, 19 Jul 2021 16:15:18 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69569C061768 for ; Mon, 19 Jul 2021 13:54:21 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id g24so12318219pji.4 for ; Mon, 19 Jul 2021 13:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FS7hA8Ssw0OYBVwW6lnnTxfgSQoV+0/cH1NHErOBt6k=; b=tG5WFuVoZ4zqsP8QzPAubO0pEp0kx5h+4kMdHhSo1BsB87TzirkXFrvMaDJuFOCTDL t1Q/E40U8it+wS5fCBQGzbwlxiiMskzaaRH51GBINcRxGLLvYWOkLNc1GsbXVpOMyqpc uoahGLaikqRKAcaUEeal4rjIfIRiQzSXSt2HI2KQQ2I0vophtvUP+KQKzFlgGBEqdKMW f2q5jCYk188bMFn+C0GlTOVbaKRl4r2SXYYXIbZznRi/Rm5/kymcBosOcvypNLL+4URR oCsENm5QA4ioN8Adv9OjkWbLDQlgtXEYHO8zUlNj+qvwendMGyciSwdkEYcJxbkL6NJv XdGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FS7hA8Ssw0OYBVwW6lnnTxfgSQoV+0/cH1NHErOBt6k=; b=NlgYstHgm1dBvl+/obm+Bh5iRdgX+jv+85UwogHH1CwlR3ojufYjCLoAIYssYZZMym Qe5R1aiLlGx7xs5+M8wJFMFgBqSPWI+QeVgl4YBCj7WUcNRjUGcUY/hgF5ptDxOAYGee hMJX8vk8cAf2IeTL1ux7gRMqoZ+ixP69fmHkR1EqyMyWjwOSF1yoNKD/rsee5RWfv3oU 86QaeNPgdJJ+0zp/tbGo//vpaQqJZUmaJo2qgASFJRSP9l1rqc4kS40zwhV/t5JkX5e4 swQzIJqtqiqFsEe6mlP8KbEwgxrUk9ySCiHoJnMaP1HLCCG3RrVOrJf5KrClH+CZX1ul JWeg== X-Gm-Message-State: AOAM532dfao5rwZSDPCvVxJOJbdYK5GYEhanKlGUaDIL5aQPQ5K0qmtR m4sDsyegTaAzO/dbI/Yt4CtDzL0L61xLFw== X-Google-Smtp-Source: ABdhPJzV+uJcPgBlx2dFr4U1H8XiL5ssDXyu4KWAxZGJCjtS0ZqOVEGE6UsQ73LG9uHHj0wRXuq4ew== X-Received: by 2002:a17:90a:2f63:: with SMTP id s90mr31671042pjd.168.1626728146339; Mon, 19 Jul 2021 13:55:46 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:46 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Jason Gerecke , Ping Cheng Subject: [PATCH 4/6] HID: wacom: Skip processing of touches with negative slot values Date: Mon, 19 Jul 2021 13:55:31 -0700 Message-Id: <20210719205533.2189804-4-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719205533.2189804-1-jason.gerecke@wacom.com> References: <20210719205533.2189804-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 27587070a192..ce9e8e9b48b6 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2551,6 +2551,9 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, int slot; slot = input_mt_get_slot_by_key(input, hid_data->id); + if (slot < 0) + return; + input_mt_slot(input, slot); input_mt_report_slot_state(input, MT_TOOL_FINGER, prox); } From patchwork Mon Jul 19 20:55:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 12387069 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6398C12002 for ; Mon, 19 Jul 2021 23:39:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEF68610D2 for ; Mon, 19 Jul 2021 23:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242799AbhGSW6V (ORCPT ); Mon, 19 Jul 2021 18:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346834AbhGSUPS (ORCPT ); Mon, 19 Jul 2021 16:15:18 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B53EEC0613DD for ; Mon, 19 Jul 2021 13:54:22 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 37so20472616pgq.0 for ; Mon, 19 Jul 2021 13:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gJu/GAnviYn3d7aO05yfXl9ZcEPV7S5uHS4BiGszN/k=; b=mzhPHFt3uwMtCvNFhbVfw4e2/KCVOMecAptKAsHsFdbKhmif8lcIDwsrtesvoX2QfS /OjdWXyCr+VPv+udKjGDViVPjBK/7RHqE5N9SwBTUHLt1K91MD6b/qAHhz2ILB2JqfLN pJuOL1XQgsIo1pCsoedB2XpIG6EsJVJxeHdWDX7gLZARV/OH0dM7+4i04ylRcpxyTFsZ gWU4oRuir1bk/OiZe69znOdOn+eNjLZ4aJwpwBBk8HNsLj/yvjxgNCYfVC28yU55WAtJ iv0xHpkvPCEKI7i9cBCWgtCwr2yLcu7pLaAw+Uj5OrSR9Zjc8odu2jFIUFl53AqQb1rR Fgrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gJu/GAnviYn3d7aO05yfXl9ZcEPV7S5uHS4BiGszN/k=; b=bZUFdoo9xxZ9m2VPtBbGW1QBaJPuJDLxTMHw+Ty0B9kBlAgwmGIGAwUljJpGLor31z D+2uNLvB8P03Vq4zAl2/7d+FogRyCcuAXq3onvylm4ax+6/taQO12rm7mWtkWZiOC3Fh ZR+WsmMkDO5iXHPXBsutovYhEFs8gxYicin/kaKXb6etpi6+hrbqP2Mto7FlT7h80S7U ioQIfDj1Fl2WGm5XfkyeXPxJuxj7wPhFAdsis5hamOar/SMqAkEvQe4I9ISYsNctZiy7 +W9cNdvfSi64nyW8+PesOt6Y3fkkz8GadmkH5CrPQobyPh2QuM+UTlfdgZd7pR4+9Dxm /UcQ== X-Gm-Message-State: AOAM530QRutFUsRF2Y60M2llTKV0ohOLhRYb8ItssWl6LllZXlU3eqhP m6mf78vO7F6OWxhu2209+naE56wAp69dNg== X-Google-Smtp-Source: ABdhPJxGhV+hnorFKnG01wS2frQWXBnJUFAkj/zXIPHjnAJ8fWMIP0MOSJahb0li9JbVJDK3vrifWQ== X-Received: by 2002:a62:7c16:0:b029:329:8d4c:d12d with SMTP id x22-20020a627c160000b02903298d4cd12dmr27929794pfc.47.1626728147499; Mon, 19 Jul 2021 13:55:47 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:47 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Jason Gerecke , Ping Cheng Subject: [PATCH 5/6] HID: wacom: Avoid sending empty sync events Date: Mon, 19 Jul 2021 13:55:32 -0700 Message-Id: <20210719205533.2189804-5-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719205533.2189804-1-jason.gerecke@wacom.com> References: <20210719205533.2189804-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index ce9e8e9b48b6..3f992c9dca4d 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2551,8 +2551,17 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, int slot; slot = input_mt_get_slot_by_key(input, hid_data->id); - if (slot < 0) + if (slot < 0) { return; + } else { + struct input_mt_slot *ps = &input->mt->slots[slot]; + int mt_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, struct input_dev *input = wacom_wac->touch_input; unsigned touch_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 * process them rather than immediately syncing a partial * update. From patchwork Mon Jul 19 20:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 12387065 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AED44C07E95 for ; Mon, 19 Jul 2021 23:39:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90818610D2 for ; Mon, 19 Jul 2021 23:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344988AbhGSW6D (ORCPT ); Mon, 19 Jul 2021 18:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346541AbhGSUPS (ORCPT ); Mon, 19 Jul 2021 16:15:18 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0803C0613DE for ; Mon, 19 Jul 2021 13:54:23 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id y4so17641331pfi.9 for ; Mon, 19 Jul 2021 13:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hj7k29MxTKJQR8WxrFkV2bIJPSosFcmcW1WgKY1tqjI=; b=SeMUAORWeR37L9hAKVh04ZZtqfngg0+FwYygl+wElRodajScCu48l87eeIOilPPUzg qe/N24+GDpKj0r9DUofAmTPRGyTmV3vI0b1yDg/aquLuDy6WljRK8pNjuU3i+EmvQGbo dwT/hAOBbLXXhza/wPn8z5VERDKhXv4shMTsM7J2lE/5LAKffKeFJCz81pU+TSiqWAyo ojibVU3YX9haf9L9ENRhYb6Bq6jL5/fGbg/jm+fTm/SI3UGVPls+TLcUnfbaRfeUiEh+ +FvlJKrBH/zlWD/B7Gl2wjL5GCJ8/DmzduPTefzHfMD3Jdy6ZODQgqYgIw4nG/KtvlXO jEtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hj7k29MxTKJQR8WxrFkV2bIJPSosFcmcW1WgKY1tqjI=; b=Cr9xmjuU7VhtXhBAtLUFgy3Yhyd1QQN2tlHdNWL2bzF17nyWNDJfCMFyEoAbw0pjqD GI+8S91Tro3PLP0YESW6NttAOYXucgDxoLxUXbLSgoBU0RZiZw8rcKR4SpNJVBY8sOa3 jZXJoHVgE1rnOqr7PgZDAo1cYriuCmMr8L4RSpSbOWZVaMJfUVqRv25Em4nxMgmQns+A 2q7SPrepQsjn9po9MhDpSMBrO9njMQLqWDS2WCcOmgHYcz08zZUJwCxT0LUK0+GQq6O4 4CFC0gKJXh7alXCzQeqkNAldtIVdq6MIoNDVKVXdxdbP+XBeXxkWW7ZZuRQ7cH+9/sOD UmiA== X-Gm-Message-State: AOAM532eyn2tMK2gH8w6SSMmi5P4tGZpSt6YM538DVj3vzECTYbTdhEy 9TCFLMkfVzKe7D8DZFe9FFwLqvllcJo0gA== X-Google-Smtp-Source: ABdhPJzI5K7MJEeOptvvTRX5nNSsmmgRMKf39vJOy8NgrSgFMc9N2jE32sDX9309FlcnfTDKDxz3Jw== X-Received: by 2002:aa7:93ac:0:b029:32e:4fce:bde1 with SMTP id x12-20020aa793ac0000b029032e4fcebde1mr28158579pff.54.1626728148628; Mon, 19 Jul 2021 13:55:48 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:48 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Jason Gerecke Subject: [PATCH 6/6] HID: wacom: Refactor touch input mute checks into a common function Date: Mon, 19 Jul 2021 13:55:33 -0700 Message-Id: <20210719205533.2189804-6-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719205533.2189804-1-jason.gerecke@wacom.com> References: <20210719205533.2189804-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 --- drivers/hid/wacom_wac.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 3f992c9dca4d..fd51769d0994 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -824,6 +824,13 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) return 0; } +static inline bool touch_is_muted(struct wacom_wac *wacom_wac) +{ + return wacom_wac->probe_complete && + wacom_wac->shared->has_mute_touch_switch && + !wacom_wac->shared->is_touch_on; +} + static inline bool report_touch_events(struct wacom_wac *wacom) { return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1); @@ -1525,11 +1532,8 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom) int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET; int y_offset = 2; - if (wacom->shared->has_mute_touch_switch && - !wacom->shared->is_touch_on) { - if (!wacom->shared->touch_down) - return 0; - } + if (touch_is_muted(wacom) && !wacom->shared->touch_down) + return 0; if (wacom->features.type == WACOM_27QHDT) { current_num_contacts = data[63]; @@ -2536,8 +2540,7 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, bool prox = hid_data->tipswitch && report_touch_events(wacom_wac); - if (wacom_wac->shared->has_mute_touch_switch && - !wacom_wac->shared->is_touch_on) { + if (touch_is_muted(wacom_wac)) { if (!wacom_wac->shared->touch_down) return; prox = false; @@ -2593,10 +2596,7 @@ static void wacom_wac_finger_event(struct hid_device *hdev, unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); struct wacom_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, struct hid_data* hid_data = &wacom_wac->hid_data; int i; - /* 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;