From patchwork Mon Apr 18 03:18:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao J X-Patchwork-Id: 12816235 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B750C433EF for ; Mon, 18 Apr 2022 03:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235981AbiDRDVX (ORCPT ); Sun, 17 Apr 2022 23:21:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235974AbiDRDVW (ORCPT ); Sun, 17 Apr 2022 23:21:22 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2103.outbound.protection.outlook.com [40.92.21.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5149216582; Sun, 17 Apr 2022 20:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YrLsN3MWOZr5/vLDEIVwP4EIuVaNR3M8gTdHVPuXajam1jqT277D849vegg3OS5XX2ZnCIlZN4KAohm1oG18PY2yTH8+HDoY6zRIW+UH+F+aVG1gr8dQ5Tg3FK5YAoloHhyF5sZ69NIQai4UCEGq/gCv+Nt8QlSxAJtdyoae7Fuiqsz4Iig+3VXE4zSry1ZnvUFuWf0rW8/x4BOq0tuqBqCHc+g7lxpN5kMS1s00OdO2n4ynsxYUNUf/n2++2HP4Hf6LTk2frd+8sCLd+avrX6oYka/pUgpQvMu2ZbAAamtPhA3KnggI0du7U7iqr3BJYbuysMXrrCF2FxZVe8WRTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n8WCTicGLayYERIxGpDQeZrTPt8Gw748nN3kbAp3l54=; b=Wofg8JVWqy0QJM/ky4jFzersQpYGVcLo4vazbk2gfbVMQTkrYXG9cAr1VKJbF/2PlQD5WSu7ZFwUSWL3GWmuFl9KJDIxa1/XtR0vgTmJMwGkBe9WvZOGr9bwtdrg2F2xO0R5oMj+3xW6afNwjpUhnGApd1GBZ03pNuo9aMhSk1fo0eOCr/3HR6Pll5OmImO2/Dul2S+AG8NhE+CiUzAb+7OLCqhvGqPwbPynNyWE31tRtHlfnGAC6AMl1xutrWLt3YhGnFLK/1CdD/Ho8ggtcoL29LDjcjLjDscIYjfdDoIGsljuv+0X5v2/Q3VUGKdVdv+UnDPqXgE7ZgWHvq/6bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n8WCTicGLayYERIxGpDQeZrTPt8Gw748nN3kbAp3l54=; b=ZN0ive7J/1J2noa9bjDOpsNkB3kb+ue3JYXtrUmfwSJliq76INHjNJDSLKfrJGE0YQi9dRcw/Fg2WSa4PNixVy46Y6E2DTQF0vO1YGlTKiP1IswJcgrkAx/FJOKv+lxP2DWBvqsPjW5NJnDLgiLvaqdoBmsQGLV7VhqHSl7imk455ToJU4tBh4vk8y0qJBLjEeT6Oh/GocAiVgoonpb891QC8PtOfU8EvG2npSl5EqnwA0pYBavkvwzExuUkzOhihpyesewOTxwx7uTPIYNcL8GdJ8ey1PCUJnvSy/5WH7hFANKiHCXmCBW134Jh5/IJjSj3LH44sggGriOvp3Ge/w== Received: from CO6PR03MB6241.namprd03.prod.outlook.com (2603:10b6:303:13b::6) by BN6PR03MB2803.namprd03.prod.outlook.com (2603:10b6:404:111::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Mon, 18 Apr 2022 03:18:43 +0000 Received: from CO6PR03MB6241.namprd03.prod.outlook.com ([fe80::98cd:da57:6117:c992]) by CO6PR03MB6241.namprd03.prod.outlook.com ([fe80::98cd:da57:6117:c992%5]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 03:18:43 +0000 From: Tao Jin To: Benjamin Tissoires , linux-input@vger.kernel.org Cc: Jiri Kosina , linux-kernel@vger.kernel.org, Tao Jin , Bingchen Gong Subject: [PATCH 1/2] hid: multitouch: add module paramter to override quirks Date: Sun, 17 Apr 2022 23:18:26 -0400 Message-ID: X-Mailer: git-send-email 2.35.1 X-TMN: [XfL+OE5JIM+plyKNcGUvsa4uZFHvBEGO] X-ClientProxiedBy: MN2PR13CA0022.namprd13.prod.outlook.com (2603:10b6:208:160::35) To CO6PR03MB6241.namprd03.prod.outlook.com (2603:10b6:303:13b::6) X-Microsoft-Original-Message-ID: <20220418031827.37423-1-tao-j@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 517ae5d8-bc90-4a42-cd8d-08da20ea246e X-MS-Exchange-SLBlob-MailProps: CaK+F7me6Ck/FTX4x064BW1Pg6/6QSqD5HgsgrGrHJUBI60lcMGiC+cNFOVSecvhWrLYCK4a2xDubAdUNzEijFHeH2uhumAkojUErgA5va2jwFv+2zsVMiKkI8pQ6FuOmvG4YVEMywbEDtuIyZBR0hxIqMc1XvsmJCwPV6vXUkY6aReB6koaoWOAvr52kG92o/3W6GM3v9BrZLryM/fv2aLOxNeQ0ayJ3bxowP25im9ViKEq+/GjLUVEDjpb0PCbAAtBli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7UIO/s2acRpjw99somn6y0Nb+8IysA8wRsDW4ta24x9RoKzS7YhiIf6fPEUPhP21fuLX1AhMsxxlSY40SoOY0pR5N0iBrCmWJqFJHBSYzLH9xwRaAiAF3MfbkOfW2yD0AMLr0ZbxLxaZ62+m5rodBIV3sFumEHIhhGxa8JEE5kCbdMU7TNiyT3PtP5kf7ifvg2uZPSKWLQmwmlpi3VVNy4isrOfERNgurj7k2uNBIcqcVKdbM3d/TU1C6jwi0nvIL1XqxpSMcgCAEgP/uUgHU0sH6RzaupCVrDBwuvCkcXG97OoJvv0ndWHOTx2aNduY2dvTOU8Z0LhP3CK+4ydICx+uYzca1tJxs6W0qdfP28LmJFE8tSVrxEf7p5WKhb3RUwtV5KsonACtt1lAMNRclDWQP8eZXGD2ariiRdG86/C94Cr7v/YXogbDCOZltSt25rX3pXgffGTYtMDeNvRLIiICI3+8C5/4Y/bex0ior//GZwphpLyaVEJrxzIqFQTAw9hRdzoDgY= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 517ae5d8-bc90-4a42-cd8d-08da20ea246e X-MS-Exchange-CrossTenant-AuthSource: CO6PR03MB6241.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 03:18:43.4367 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2803 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org There is a sysfs interface to specify the quirks. However, some quirk bits such as HID_QUIRK_MULTI_INPUT are only read once during init/probe. Setting the quirks in sysfs does not make any change to the behaviors related to those bits. Also, it is hard to wait for udev to modify the quirks in case there is a rule given the current init and state machine structure. A simple kernel paramter is provided so that any time a custom quirk needs to be tested can be easily applied. This enables the users to test out which bits are indeed necessary with just a rmmod then insmod/modprobe cycle. Thus, new hardware support can be added very soon and unneccsary mildly costly quirks using mutex and timer can also be removed based on user's self-test. Co-Developed-by: Bingchen Gong Signed-off-by: Bingchen Gong Signed-off-by: Tao Jin --- drivers/hid/hid-multitouch.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 3ea57f3..c6d64f8 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -398,6 +398,10 @@ static const struct mt_class mt_classes[] = { { } }; +static int override_quirks = -1; +module_param(override_quirks, int, 0444); +MODULE_PARM_DESC(override_quirks, "Signed integer to override quirks in mtclass, must >= 0 to enable override."); + static ssize_t mt_show_quirks(struct device *dev, struct device_attribute *attr, char *buf) @@ -1749,7 +1753,12 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) if (id->group != HID_GROUP_MULTITOUCH_WIN_8) hdev->quirks |= HID_QUIRK_MULTI_INPUT; - if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) { + if (override_quirks >= 0) { + hid_info(hdev, "overriding quirks with: %d(0x%x)", override_quirks, override_quirks); + td->mtclass.quirks = override_quirks; + } + + if (td->mtclass.quirks & MT_QUIRK_FORCE_MULTI_INPUT) { hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP; hdev->quirks |= HID_QUIRK_MULTI_INPUT; } @@ -1760,7 +1769,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) if (ret != 0) return ret; - if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) + if (td->mtclass.quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) mt_fix_const_fields(hdev, HID_DG_CONTACTID); ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); From patchwork Mon Apr 18 03:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao J X-Patchwork-Id: 12816236 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E44D2C433EF for ; Mon, 18 Apr 2022 03:19:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235974AbiDRDVi (ORCPT ); Sun, 17 Apr 2022 23:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235990AbiDRDVh (ORCPT ); Sun, 17 Apr 2022 23:21:37 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2089.outbound.protection.outlook.com [40.92.21.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A31A2183A9; Sun, 17 Apr 2022 20:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SXpK3bS3dFz92az+yZQgi9SO70fYIDPuStzt5qHPXdgphLwdc4rx7/Rjc0OAPkqRUscKYZUvfTovkzoBedx+bLQkKVP8vEnJVCp02xSfzVYHzQqHOq8A71P207H2742pbD4Uh+Wu8oW2M3aSRyjGwt+3w0ZWdw9VhYPbWJo5qVK0rum7NL+E2623q7szqW7a8TYtnkofqIol0iRDFklhVz7V2+rA7COLanXo6CqUJODSyn1zzpJFz3ef0leUl53RkXkqHCW4PXqU8/jMzbqUDYZ8pBMcR8Eko4PV0Fo6rY0u1ENrgNKFd7tISrsJTTj57wrviKFDo9nN+oXFLCpL5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Sk4SZu+jR7Tjm6cQm1qNpd2g7Qn0ghP8evtjrW2RY8M=; b=YNv49LGc7TjzmkuukzkjSKneR8QdRow+XTxAjoUdAVXY904SN4UPK0ZuzSxwG30+A6aVodTotUNPb86sbCPA63Vt+lumSXLQiPlQnYfKG8mWiwl5QS2yxLQ6Oxs4pTsf61JDxdjj/Oa3SX1+84s5ybou9QSachpg6NVXb3O38GsgeorHvnZugHNXyb1rrmb8KPK2KnQ1LTqvUuF08YXfqVpRs0Z2sIQF9huGQNfsSYZQUiiFn3Q1/QQfOUWms3HZTTR/AXW7dKzCF1NWUxhUHnaYj/U341qvAcD7k3pJmAi3aNHE09mZCQpWZPlxJ3I0ykC5VRzyugCb51HaNvgCxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Sk4SZu+jR7Tjm6cQm1qNpd2g7Qn0ghP8evtjrW2RY8M=; b=Kv/9Wt9H34NoOAIve7ZUeJetmf/0V0VQI/i+SGDbqziCHzCBw+7x8H1hu49QQjFjTLak5QSLLICl87NZCQvSlInv1ojWhIHtuIfHY4ElhQ4W8+zkowj5LY0bLEzLYxSFRNFDdBuBUyp2xzevNcC/XbKtF3ejRkGPayEfNDHYcHVtRPIOQX/Vlf9eWt7jkmzi9dIkE5UdyFCRbqmthHsL5sdUYHDdzmF224metc8D4/UZLTefbr1aCykSTz8GuegBYihJtJj9HQLSuqhsC1csL/Hcz8mIOh4BMUA4fLLMNNcFvr2fU/MFgDEIywiaLC7kJixnX/QnaMNG8B/mI+9WMg== Received: from CO6PR03MB6241.namprd03.prod.outlook.com (2603:10b6:303:13b::6) by BN6PR03MB2803.namprd03.prod.outlook.com (2603:10b6:404:111::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Mon, 18 Apr 2022 03:18:57 +0000 Received: from CO6PR03MB6241.namprd03.prod.outlook.com ([fe80::98cd:da57:6117:c992]) by CO6PR03MB6241.namprd03.prod.outlook.com ([fe80::98cd:da57:6117:c992%5]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 03:18:57 +0000 From: Tao Jin To: Benjamin Tissoires , linux-input@vger.kernel.org Cc: Jiri Kosina , linux-kernel@vger.kernel.org, Tao Jin Subject: [PATCH 2/2] hid: multitouch: improve custom quirks kernel parameter Date: Sun, 17 Apr 2022 23:18:27 -0400 Message-ID: X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220418031827.37423-1-tao-j@outlook.com> References: <20220418031827.37423-1-tao-j@outlook.com> X-TMN: [y4Ipa3BRE2iMwtouKB4bqH4sLFFkNTwu] X-ClientProxiedBy: BL1PR13CA0260.namprd13.prod.outlook.com (2603:10b6:208:2ba::25) To CO6PR03MB6241.namprd03.prod.outlook.com (2603:10b6:303:13b::6) X-Microsoft-Original-Message-ID: <20220418031827.37423-2-tao-j@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e8dc4cd-3e9a-4863-bb73-08da20ea2d17 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTzvpWxvWYRCitoSl4QfY+H6OINTa2VFd7O6L1T5rYjHH+ybC6ZZRik1QjKSRhpk5soJt+GfMxK4p9+tcCrQdjZ7Xny+AIIpeeFZTQZb5wneOO/Y9vySRwfo8tQhvHn7CN1CBeCogdySuGnIhmpvLXgg6TGVTNFN7PGS/4c7rjFQB+20X7unvf1hbApq0ZTCcebeFH1qChC8S73FI8CgFSktgAq86vza/in/W7wd+W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VovbVFCZttv+S2VYsvsOymAt8nsLhOobmLFS6L/5XHnePY0DyefXBagq0bfgkmjdbDWG0VqMZTQxD3fkNB9y0etaLt3FRX6y4aZHNjMFoSnp0L9lH6moqUJA6rgbQeXiJwoK0LM7e+KUhR5ZFbhOIqTN8mfJzts4vREpCbxuok6C3zjtuo3ppYn8GMKsnguLE6PEZaVKqJ9dhVUrclNBxmd5xdD/x5uUCdrpOScdc66YktvY5cKRGueUg6IEBniMdv6xJ1z12TyvEtmvOCvCLsgubV7Sot/drs1LQBq8+C3CXCy+txs4b8gV3il8J/nIx+SpJPsxkHrUivvYsmCcVg5Y+KodONeHSY5+gojl7aFQ9h6BzmRTETWXdpb0u/eOUxe+yvA3fqLX//1Cm4Z2skK7lfibK8yDkP6GiCslXVnx9auxQqiFu56Ev7MVnMSO/Ns878ZoNQ5n1MUjhvZ4IuYo15otXsaPlg8X40DAZlbB7LislAMNVqDo17dP/dhGLdSToCDCRCSZfxhWAFEOoR3gQAEuyv2Mecb/QK6pXUlEPLKwU+uKvd37sRopZg= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e8dc4cd-3e9a-4863-bb73-08da20ea2d17 X-MS-Exchange-CrossTenant-AuthSource: CO6PR03MB6241.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 03:18:57.9031 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2803 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This allows a list of different quirks to be matched against corresponding hardware ids in case there are multiple devices present on the same system. The code borrowed some idea from vfio_pci.c Signed-off-by: Tao Jin --- drivers/hid/hid-multitouch.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index c6d64f8..f662960 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -398,9 +398,9 @@ static const struct mt_class mt_classes[] = { { } }; -static int override_quirks = -1; -module_param(override_quirks, int, 0444); -MODULE_PARM_DESC(override_quirks, "Signed integer to override quirks in mtclass, must >= 0 to enable override."); +static char override_quirks[128] = ""; +module_param_string(override_quirks, override_quirks, sizeof(override_quirks), 0444); +MODULE_PARM_DESC(override_quirks, "List of quirks and corresponding device ids in hex to override quirks, format is \"wanted_quirks:vendor:product\", multiple comma separated entries can be specified."); static ssize_t mt_show_quirks(struct device *dev, struct device_attribute *attr, @@ -1714,6 +1714,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) int ret, i; struct mt_device *td; const struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ + char *p, *qk; for (i = 0; mt_classes[i].name ; i++) { if (id->driver_data == mt_classes[i].name) { @@ -1753,9 +1754,28 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) if (id->group != HID_GROUP_MULTITOUCH_WIN_8) hdev->quirks |= HID_QUIRK_MULTI_INPUT; - if (override_quirks >= 0) { - hid_info(hdev, "overriding quirks with: %d(0x%x)", override_quirks, override_quirks); - td->mtclass.quirks = override_quirks; + p = override_quirks; + while ((qk = strsep(&p, ","))) { + __u32 wanted_quirks = 0; + __u32 vendor, product = HID_ANY_ID; + int fields; + + if (!strlen(qk)) + continue; + + fields = sscanf(qk, "%x:%x:%x", &wanted_quirks, + &vendor, &product); + + if (fields != 3) { + continue; + } + + if (id->vendor == vendor && id->product == product) { + hid_info(hdev, "overriding quirks of %04x:%04x with: %x", + id->vendor, id->product, wanted_quirks); + td->mtclass.quirks = wanted_quirks; + break; + } } if (td->mtclass.quirks & MT_QUIRK_FORCE_MULTI_INPUT) {