Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp201682rwi; Wed, 12 Oct 2022 18:38:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ahWM7Qi9E+sTQMaOoJ1XDxuo6l9xJ/byGbYhMxPKnJWFfuzPL/VYcs3bdBB/TVchPoYk1 X-Received: by 2002:a17:907:7f92:b0:78d:ed9c:d86f with SMTP id qk18-20020a1709077f9200b0078ded9cd86fmr5850749ejc.251.1665625098290; Wed, 12 Oct 2022 18:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665625098; cv=none; d=google.com; s=arc-20160816; b=Bo28Nt/4r9ToQvMHYSpx6Wd6wTB6eeUp+5UEE4hLBVkYBY6NNWfoe3r93i7o0tlL6d pqKWQiJYBECK4J0tIq+rlUCwj8oh/SV55dhArBiSeHwJO6sCDy+xz/cFG1NOt5IA99QW xhTobNFDPuegP3UAlFzDKLydwXW+tF1ZN5vHd/n8Y3sopMZ1PDxoor91KBTNge/Kfi8U MV/P8thMPN7Y+8Z3YeMPNomdJap2NaD4wNDA5+tfizUs4inRaALHahkUOK2ZgdfvW9uF IIEl5q27dASz8SkzDT4qhWaGz0XJ5Fv+aWLXKTcvVfjPIB/T8tS+0Z9OP7xsO2Th31w7 m1Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WHYRpy5or4DY8wOVhnRvGxKrKE39N9j3MNh6AbP2Tjg=; b=NQ4/VApjJG5WTIFsFQMfEit7HuTSPjbv9JdiWenYzRmpocf60Bj7tL5sVIouhQEwas 9c76IHUBImEMGtl+C28LUKcCQiFzaOodozKV72ZmH8lqffvVazm2FIed/TJNah1fLsWi 2dGNHne57WnKWTziSXO3ixbPXEA1wjItEMU74XPweoNIBrzHWUPCYmscUeem4ccKN0ZZ EzN9f732jpXTx7nLxaZGleeO+1GBHkfn3cH+QpIRRsZ79h+Xdb7Jk+GdkQnuPf5mqWjF TJQQLCZtdr5UOMQIaboJi5fKuJWaA6tSJIfx3cyrEMDKP4N+X1i6eCYKVUXal6gyni12 cmSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYOf2ywu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a056402068800b004478e283f05si13545423edy.104.2022.10.12.18.37.53; Wed, 12 Oct 2022 18:38:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYOf2ywu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232178AbiJMAku (ORCPT + 99 others); Wed, 12 Oct 2022 20:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232085AbiJMAgf (ORCPT ); Wed, 12 Oct 2022 20:36:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CF1EEB75E; Wed, 12 Oct 2022 17:31:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 67089B81CE9; Thu, 13 Oct 2022 00:22:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 582D9C433D6; Thu, 13 Oct 2022 00:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665620548; bh=bxhd877nNScPzSvqcjEFR5dI8yWPxbIbxiRwTlLajwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XYOf2ywugkxECKExqiq8ZRNXoo1yrynVnLIfYbzz7mbHvYSVXg2/ZcOk39rM/R/fR c2LMoHmegVq8vA4JaSZWp2Zg0kncLthPLRwWt3FHBdm29f/+bMxDLJqkJS3hVgas5o nLWByay6dj6NRnNJCD0w2cW7+UMH3zzSV8Ba3MQi7rIFku2kq7d6Zjb59onQqvRAYL EzYswrYPBUhQODJN4juz9w8tj9lX45X6QCRbFnWiDsP5+3vnbaixrNCXI9aGrhzmiH uiumUqlhHw7qWf9Fef7Tih0jNHIE+xZpf54QxgG2Gdp52q3eXRMXodp4/zLtRbPJb5 gzx1rLIZP/C8w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Harry Stern , Benjamin Tissoires , Sasha Levin , jikos@kernel.org, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 23/47] hid: topre: Add driver fixing report descriptor Date: Wed, 12 Oct 2022 20:20:58 -0400 Message-Id: <20221013002124.1894077-23-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221013002124.1894077-1-sashal@kernel.org> References: <20221013002124.1894077-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Harry Stern [ Upstream commit a109d5c45b3d6728b9430716b915afbe16eef27c ] The Topre REALFORCE R2 firmware incorrectly reports that interface descriptor number 1, input report descriptor 2's events are array events rather than variable events. That particular report descriptor is used to report keypresses when there are more than 6 keys held at a time. This bug prevents events from this interface from being registered properly, so only 6 keypresses (from a different interface) can be registered at once, rather than full n-key rollover. This commit fixes the bug by setting the correct value in a report_fixup function. The original bug report can be found here: Link: https://gitlab.freedesktop.org/libinput/libinput/-/issues/804 Thanks to Benjamin Tissoires for diagnosing the issue with the report descriptor. Signed-off-by: Harry Stern Signed-off-by: Benjamin Tissoires Link: https://lore.kernel.org/r/20220911003614.297613-1-harry@harrystern.net Signed-off-by: Sasha Levin --- drivers/hid/Kconfig | 6 +++++ drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 3 +++ drivers/hid/hid-topre.c | 49 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 drivers/hid/hid-topre.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 9235ab7161e3..58fcc21bf146 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -1057,6 +1057,12 @@ config HID_TOPSEED Say Y if you have a TopSeed Cyberlink or BTC Emprex or Conceptronic CLLRCMCE remote control. +config HID_TOPRE + tristate "Topre REALFORCE keyboards" + depends on HID + help + Say Y for N-key rollover support on Topre REALFORCE R2 108 key keyboards. + config HID_THINGM tristate "ThingM blink(1) USB RGB LED" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index e29efcb1c040..1026ac9e8206 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -117,6 +117,7 @@ obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o hid-thrustmaster.o obj-$(CONFIG_HID_TIVO) += hid-tivo.o obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o +obj-$(CONFIG_HID_TOPRE) += hid-topre.o obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o obj-$(CONFIG_HID_U2FZERO) += hid-u2fzero.o hid-uclogic-objs := hid-uclogic-core.o \ diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index cb2b48d6915e..335b13251c0f 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1198,6 +1198,9 @@ #define USB_DEVICE_ID_TIVO_SLIDE 0x1201 #define USB_DEVICE_ID_TIVO_SLIDE_PRO 0x1203 +#define USB_VENDOR_ID_TOPRE 0x0853 +#define USB_DEVICE_ID_TOPRE_REALFORCE_R2_108 0x0148 + #define USB_VENDOR_ID_TOPSEED 0x0766 #define USB_DEVICE_ID_TOPSEED_CYBERLINK 0x0204 diff --git a/drivers/hid/hid-topre.c b/drivers/hid/hid-topre.c new file mode 100644 index 000000000000..88a91cdad5f8 --- /dev/null +++ b/drivers/hid/hid-topre.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * HID driver for Topre REALFORCE Keyboards + * + * Copyright (c) 2022 Harry Stern + * + * Based on the hid-macally driver + */ + +#include +#include + +#include "hid-ids.h" + +MODULE_AUTHOR("Harry Stern "); +MODULE_DESCRIPTION("REALFORCE R2 Keyboard driver"); +MODULE_LICENSE("GPL"); + +/* + * Fix the REALFORCE R2's non-boot interface's report descriptor to match the + * events it's actually sending. It claims to send array events but is instead + * sending variable events. + */ +static __u8 *topre_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int *rsize) +{ + if (*rsize >= 119 && rdesc[69] == 0x29 && rdesc[70] == 0xe7 && + rdesc[71] == 0x81 && rdesc[72] == 0x00) { + hid_info(hdev, + "fixing up Topre REALFORCE keyboard report descriptor\n"); + rdesc[72] = 0x02; + } + return rdesc; +} + +static const struct hid_device_id topre_id_table[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_TOPRE, + USB_DEVICE_ID_TOPRE_REALFORCE_R2_108) }, + { } +}; +MODULE_DEVICE_TABLE(hid, topre_id_table); + +static struct hid_driver topre_driver = { + .name = "topre", + .id_table = topre_id_table, + .report_fixup = topre_report_fixup, +}; + +module_hid_driver(topre_driver); -- 2.35.1