Received: by 10.213.65.68 with SMTP id h4csp307865imn; Tue, 20 Mar 2018 04:12:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELvOAXtXl9eWH4mUqbbpaRRenvMBeonGIS6tzrxSBAB7XTENNqaXkD7FJeAY67B16jFC231V X-Received: by 10.101.83.13 with SMTP id m13mr12095714pgq.248.1521544346887; Tue, 20 Mar 2018 04:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521544346; cv=none; d=google.com; s=arc-20160816; b=SvKd1YG41RFSrhdTFdZGNG83M/c20WOGEe96F2L8XMQuinqZ2CAwkcNPqbhY24eLTp D+kHRS3kNIhGemq0bUdDhANkBAgIOgLJHh8RyWvzSDErNvSD4yfkqKf6vlHdpx0VH1uW n/FLGkCGUc8D8irT40ToKjZHgg1VuixydnHls+D45z52MaKRYonIzkEzI+YerwcFqViH r/xUsetOFGozZCvWb33M+jKqUGN9LHrG6satqX9pE3VQ4i0J+Xb5itJolLfrIXNb8s4D jGcb7+2nLPT3dupN9LGzsK1khpm4vdZEtdDPWu+BpWBULEq/C01nyq1ggBErBww/RCKy 1/BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1GLtha+oiH5MepLYn6yWW67HzdlUbYS/A3osSrtgz+A=; b=OHExCW7IMdoSDB+U9mRHaJ3QuaG5SeAq1xOnggMkWZYgsObx0N/S6OpTwI30nIZTCn N6dgfsHDQD4873PsRcq03E2lGYa9/3rB6Uvq1tMtla8lC8U3XyIXQ8OFSWOFIOLSvuRT 9SRL2TSoh2AHAaMAfPmd5ifiTl5pXYioPr39BDlQ/HkZ9X81Ml/b+6oOi2tuyzSBTTX/ Z8XHZV8mQgcObl0wHFclQyZMCEsjupzIXoi5TMMMDor3UUDBkwXxDPhIIBw4SsSuYHFm IUgVjuszMgl27vhdgv1LagdcPCfnWvHIkGfvWSWXCIbgdsLQJrJU59omv47TktibDauF /3FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37-v6si1414344plq.451.2018.03.20.04.12.12; Tue, 20 Mar 2018 04:12:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753032AbeCTLKZ (ORCPT + 99 others); Tue, 20 Mar 2018 07:10:25 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59174 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752679AbeCTLFA (ORCPT ); Tue, 20 Mar 2018 07:05:00 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5621C40704A3; Tue, 20 Mar 2018 11:04:59 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-116-181.ams2.redhat.com [10.36.116.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D8E310AF9FB; Tue, 20 Mar 2018 11:04:58 +0000 (UTC) From: Benjamin Tissoires To: Jiri Kosina Cc: Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH 1/7] HID: multitouch: export a quirk for the button handling of touchpads Date: Tue, 20 Mar 2018 12:04:45 +0100 Message-Id: <20180320110451.16582-2-benjamin.tissoires@redhat.com> In-Reply-To: <20180320110451.16582-1-benjamin.tissoires@redhat.com> References: <20180320110451.16582-1-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Mar 2018 11:04:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Mar 2018 11:04:59 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'benjamin.tissoires@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of using the class name, we better have a specific quirk for it so other classes can make use of it. Signed-off-by: Benjamin Tissoires --- drivers/hid/hid-multitouch.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index a144d3064829..fc80a9bf3e39 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -74,6 +74,7 @@ MODULE_LICENSE("GPL"); #define MT_QUIRK_TOUCH_SIZE_SCALING BIT(15) #define MT_QUIRK_STICKY_FINGERS BIT(16) #define MT_QUIRK_ASUS_CUSTOM_UP BIT(17) +#define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18) #define MT_INPUTMODE_TOUCHSCREEN 0x02 #define MT_INPUTMODE_TOUCHPAD 0x03 @@ -241,7 +242,8 @@ static struct mt_class mt_classes[] = { MT_QUIRK_IGNORE_DUPLICATES | MT_QUIRK_HOVERING | MT_QUIRK_CONTACT_CNT_ACCURATE | - MT_QUIRK_STICKY_FINGERS }, + MT_QUIRK_STICKY_FINGERS | + MT_QUIRK_WIN8_PTP_BUTTONS }, { .name = MT_CLS_EXPORT_ALL_INPUTS, .quirks = MT_QUIRK_ALWAYS_VALID | MT_QUIRK_CONTACT_CNT_ACCURATE, @@ -250,7 +252,8 @@ static struct mt_class mt_classes[] = { .quirks = MT_QUIRK_ALWAYS_VALID | MT_QUIRK_IGNORE_DUPLICATES | MT_QUIRK_HOVERING | - MT_QUIRK_CONTACT_CNT_ACCURATE, + MT_QUIRK_CONTACT_CNT_ACCURATE | + MT_QUIRK_WIN8_PTP_BUTTONS, .export_all_inputs = true }, /* @@ -660,8 +663,7 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, * MS PTP spec says that external buttons left and right have * usages 2 and 3. */ - if ((cls->name == MT_CLS_WIN_8 || - cls->name == MT_CLS_WIN_8_DUAL) && + if ((cls->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && field->application == HID_DG_TOUCHPAD && (usage->hid & HID_USAGE) > 1) code--; @@ -773,9 +775,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) */ static void mt_sync_frame(struct mt_device *td, struct input_dev *input) { - __s32 cls = td->mtclass.name; - - if (cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) + if (td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) input_event(input, EV_KEY, BTN_LEFT, td->left_button_state); input_mt_sync_frame(input); @@ -827,7 +827,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, bool first_packet) { struct mt_device *td = hid_get_drvdata(hid); - __s32 cls = td->mtclass.name; __s32 quirks = td->mtclass.quirks; struct input_dev *input = field->hidinput->input; @@ -905,7 +904,7 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, * non finger/touch events in the first_packet of * a (possible) multi-packet frame. */ - if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && + if ((quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && !first_packet) return; @@ -916,7 +915,7 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, * BTN_LEFT if either is pressed, so we or all values * together and report the result in mt_sync_frame(). */ - if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && + if ((quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && usage->type == EV_KEY && usage->code == BTN_LEFT) { td->left_button_state |= value; return; @@ -940,7 +939,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, static void mt_touch_report(struct hid_device *hid, struct hid_report *report) { struct mt_device *td = hid_get_drvdata(hid); - __s32 cls = td->mtclass.name; struct hid_field *field; bool first_packet; unsigned count; @@ -969,7 +967,7 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report) * of a possible multi-packet frame be checking that the * timestamp has changed. */ - if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && + if ((td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && td->num_received == 0 && td->prev_scantime != scantime) td->num_expected = value; /* A non 0 contact count always indicates a first packet */ -- 2.14.3