From patchwork Mon Nov 6 23:55:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Raye X-Patchwork-Id: 742122 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 27065C4167B for ; Mon, 6 Nov 2023 23:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233242AbjKFX4S (ORCPT ); Mon, 6 Nov 2023 18:56:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233478AbjKFX4O (ORCPT ); Mon, 6 Nov 2023 18:56:14 -0500 Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17DC99E for ; Mon, 6 Nov 2023 15:56:11 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 47E57580B72; Mon, 6 Nov 2023 18:56:11 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 06 Nov 2023 18:56:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1699314971; x= 1699318571; bh=KWVxPyLnJyp572EMsF9f7K4EBUGZ5WdaQoctN9xrgXI=; b=e hWkNblBXQH0CqkBALtI9478msOmKaC+oUFcUC5cxikDNrSPX7KfL3u46jSNMFjyB a7l5HGrO6OmUeK2B1rPkObvkI7HK2BCpKdIEVZu7TnASS7GybQKvNua38dEfBat5 r4tFhYM6E0AhP0DxXLuaQfd4In7ggsb9OQ8O9yI0e5e2LYi8b3YdHBIH+fMiJaCV 65998rhMV2G8yXBXRoY0ziw34f9R3KbE4PrvT9bytKjLnkE1bMwlMnNQTA65vcf6 uuK03J+9DqqqEcBc3HdzhOO4QJ4nOv9UFfqivLJhpuuh7VP6q8MY+JEGWI8K1oyl Im8gEwqoDyPIohktJVirA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1699314971; x= 1699318571; bh=KWVxPyLnJyp572EMsF9f7K4EBUGZ5WdaQoctN9xrgXI=; b=F pX75QCdOnh6WSiqtKLiOaYvlQ/yJ2S611LEzGhDeURIYBt1IWBfBrXIVg8htZCvn hUbA8gp4qGLL7v76ZfabKLXME39mJR3G1GSbnMjCp/92m3HHm8x7vpgtRUk1aPQT 5LTOCg3I28wtrfiWXrl+jOjXESALG6K91p4TP59wTHql+D0y4zobC+5oMrk8+Q/Q 03zPjeh32gPeIJCMRqeLH6HiIF2LL7McVaBdCsy0l3rHwz3vp9dNvDP04nLIKIAU KTlGga6jAGUV0jBx98u4SAd4j0rsYDk2swjQVhrLL2LZKcOf3fYDbTkgKS2BVPoe UtVmNiG3IkeK/B20gTNXQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudduhedgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeeurhgvthhtucftrgihvgcuoegsrhgrhigvsehfrghsthhm rghilhdrtghomheqnecuggftrfgrthhtvghrnhepffekieeihfekhefgfedtveekjedtvd euhfeiveelleejfeeiheeljeefvedvffdvnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepsghrrgihvgesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: ice5149f5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 6 Nov 2023 18:56:10 -0500 (EST) From: Brett Raye To: jikos@kernel.org Cc: sergeantsagara@protonmail.com, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, Brett Raye Subject: [PATCH v2 1/2] HID: glorious: fix Glorious Model I HID report Date: Mon, 6 Nov 2023 15:55:56 -0800 Message-Id: <20231106235557.8741-2-braye@fastmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231106235557.8741-1-braye@fastmail.com> References: <20231106235557.8741-1-braye@fastmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The Glorious Model I mouse has a buggy HID report descriptor for its keyboard endpoint (used for programmable buttons). For report ID 2, there is a mismatch between Logical Minimum and Usage Minimum in the array that reports keycodes. The offending portion of the descriptor: (from hid-decode) 0x95, 0x05, // Report Count (5) 30 0x75, 0x08, // Report Size (8) 32 0x15, 0x00, // Logical Minimum (0) 34 0x25, 0x65, // Logical Maximum (101) 36 0x05, 0x07, // Usage Page (Keyboard) 38 0x19, 0x01, // Usage Minimum (1) 40 0x29, 0x65, // Usage Maximum (101) 42 0x81, 0x00, // Input (Data,Arr,Abs) 44 This bug shifts all programmed keycodes up by 1. Importantly, this causes "empty" array indexes of 0x00 to be interpreted as 0x01, ErrorRollOver. The presence of ErrorRollOver causes the system to ignore all keypresses from the endpoint and breaks the ability to use the programmable buttons. Setting byte 41 to 0x00 fixes this, and causes keycodes to be interpreted correctly. Signed-off-by: Brett Raye --- drivers/hid/hid-glorious.c | 12 ++++++++++++ drivers/hid/hid-ids.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/drivers/hid/hid-glorious.c b/drivers/hid/hid-glorious.c index 558eb08c19ef..e44a39a17151 100644 --- a/drivers/hid/hid-glorious.c +++ b/drivers/hid/hid-glorious.c @@ -21,6 +21,10 @@ MODULE_DESCRIPTION("HID driver for Glorious PC Gaming Race mice"); * Glorious Model O and O- specify the const flag in the consumer input * report descriptor, which leads to inputs being ignored. Fix this * by patching the descriptor. + * + * Glorious Model I incorrectly specifes the Usage Minimum for its + * keyboard HID report, causing keycodes to be misinterpreted. + * Fix this by setting Usage Minimum to 0 in that report. */ static __u8 *glorious_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) @@ -32,6 +36,10 @@ static __u8 *glorious_report_fixup(struct hid_device *hdev, __u8 *rdesc, rdesc[85] = rdesc[113] = rdesc[141] = \ HID_MAIN_ITEM_VARIABLE | HID_MAIN_ITEM_RELATIVE; } + if (*rsize == 156 && rdesc[41] == 1) { + hid_info(hdev, "patching Glorious Model I keyboard report descriptor\n"); + rdesc[41] = 0; + } return rdesc; } @@ -44,6 +52,8 @@ static void glorious_update_name(struct hid_device *hdev) model = "Model O"; break; case USB_DEVICE_ID_GLORIOUS_MODEL_D: model = "Model D"; break; + case USB_DEVICE_ID_GLORIOUS_MODEL_I: + model = "Model I"; break; } snprintf(hdev->name, sizeof(hdev->name), "%s %s", "Glorious", model); @@ -70,6 +80,8 @@ static const struct hid_device_id glorious_devices[] = { USB_DEVICE_ID_GLORIOUS_MODEL_O) }, { HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS, USB_DEVICE_ID_GLORIOUS_MODEL_D) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LAVIEW, + USB_DEVICE_ID_GLORIOUS_MODEL_I) }, { } }; MODULE_DEVICE_TABLE(hid, glorious_devices); diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index e4d2dfd5d253..c30bca343982 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -744,6 +744,9 @@ #define USB_VENDOR_ID_LABTEC 0x1020 #define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006 +#define USB_VENDOR_ID_LAVIEW 0x22D4 +#define USB_DEVICE_ID_GLORIOUS_MODEL_I 0x1503 + #define USB_VENDOR_ID_LCPOWER 0x1241 #define USB_DEVICE_ID_LCPOWER_LC1000 0xf767 From patchwork Mon Nov 6 23:55:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Raye X-Patchwork-Id: 741630 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 7B0A2C4332F for ; Mon, 6 Nov 2023 23:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233219AbjKFX4W (ORCPT ); Mon, 6 Nov 2023 18:56:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232702AbjKFX4V (ORCPT ); Mon, 6 Nov 2023 18:56:21 -0500 Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F62125 for ; Mon, 6 Nov 2023 15:56:18 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 1B397580B6A; Mon, 6 Nov 2023 18:56:18 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 06 Nov 2023 18:56:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1699314978; x= 1699318578; bh=dn7Gk104Q8LavAf8fMa3coEQD9FEWhg7/XznMibZ2ZE=; b=o q7EF9UCL0XMnl1LH1d0cbJhLEcEwmb22c96aIHjopp8NnytsDo+b2J9Tl5RDA+wO fJ4RHvOfqUDHWd75j8P3oukLRUKUoNxRz+tR8qZtuyGma1td6klQielxZLNfurtj C2cG+yPoJk2ZXTjcnDmGhOubABMp7/W1sIofEadB1hjNQMVWV+wtQEJR7aZN3l0t 59CnEediQ2iGz9vNuFgLM2YzknipoLo3G54EiC56e8C7td5FK9sfT1IRcvPqwKIF BWnUlc/U1LdOmEeTXlbMk79gA8QVHQiPk13HrU4AOe0tcm0LMtENmpcbIyKrAw3X 9ky9akB8kJAWOshym/9iQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1699314978; x= 1699318578; bh=dn7Gk104Q8LavAf8fMa3coEQD9FEWhg7/XznMibZ2ZE=; b=m TDcb5QhmhSI91Iu33ul+0TmAGFBzsvxneB0G9nM++oQ0cIu67YdxYI0ci5vZa6BC EvYvDxg0xDrI4Hx929+DDmrx/czRoSbI5Qkg9yJa544Jxnbq3+86u3CqMstTQQCK iwGMNJKAuYUi7PtAAxOo0GGt+HWBDNG1LBiEZrxhTad/JBilvia53feu2ucG0qj6 sUDjIKdZ3NbsuOZHevmDpgxJOQz+PRN0EsF7Iw9moV/DSP6bfihqVdKLmPJkkQN5 1FdxIThy6sxs3WWj6U3zIgvt/m4J5iJt1sLqrtMNvxzdYgb00sGk/oHd/RDMAysb rqFWsqXSsaZYZW6VRDWaw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudduhedgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeeurhgvthhtucftrgihvgcuoegsrhgrhigvsehfrghsthhm rghilhdrtghomheqnecuggftrfgrthhtvghrnhepffekieeihfekhefgfedtveekjedtvd euhfeiveelleejfeeiheeljeefvedvffdvnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepsghrrgihvgesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: ice5149f5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 6 Nov 2023 18:56:17 -0500 (EST) From: Brett Raye To: jikos@kernel.org Cc: sergeantsagara@protonmail.com, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, Brett Raye Subject: [PATCH v2 2/2] HID: glorious: rename USB_VENDOR_ID_GLORIOUS Date: Mon, 6 Nov 2023 15:55:57 -0800 Message-Id: <20231106235557.8741-3-braye@fastmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231106235557.8741-1-braye@fastmail.com> References: <20231106235557.8741-1-braye@fastmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org USB_VENDOR_ID_GLORIOUS is changed to USB_VENDOR_ID_SINOWEALTH. Glorious seems to be white-labeling controller boards or mice from many vendors. There isn't a single canonical vendor ID for Glorious products. Signed-off-by: Brett Raye --- drivers/hid/hid-glorious.c | 4 ++-- drivers/hid/hid-ids.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-glorious.c b/drivers/hid/hid-glorious.c index e44a39a17151..281b3a7187ce 100644 --- a/drivers/hid/hid-glorious.c +++ b/drivers/hid/hid-glorious.c @@ -76,9 +76,9 @@ static int glorious_probe(struct hid_device *hdev, } static const struct hid_device_id glorious_devices[] = { - { HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS, + { HID_USB_DEVICE(USB_VENDOR_ID_SINOWEALTH, USB_DEVICE_ID_GLORIOUS_MODEL_O) }, - { HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS, + { HID_USB_DEVICE(USB_VENDOR_ID_SINOWEALTH, USB_DEVICE_ID_GLORIOUS_MODEL_D) }, { HID_USB_DEVICE(USB_VENDOR_ID_LAVIEW, USB_DEVICE_ID_GLORIOUS_MODEL_I) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index c30bca343982..9ed9ec03ad1b 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -510,10 +510,6 @@ #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100 -#define USB_VENDOR_ID_GLORIOUS 0x258a -#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033 -#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036 - #define I2C_VENDOR_ID_GOODIX 0x27c6 #define I2C_DEVICE_ID_GOODIX_01F0 0x01f0 @@ -1162,6 +1158,10 @@ #define USB_VENDOR_ID_SIGMATEL 0x066F #define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780 +#define USB_VENDOR_ID_SINOWEALTH 0x258a +#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033 +#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036 + #define USB_VENDOR_ID_SIS_TOUCH 0x0457 #define USB_DEVICE_ID_SIS9200_TOUCH 0x9200 #define USB_DEVICE_ID_SIS817_TOUCH 0x0817