Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2087857lqb; Mon, 27 May 2024 07:30:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMn3ZL/NLgrTcWO07ejtaCkraAmgi5WCGqEyfUGCSjoJgW9i1YMMK5weYC+o9W6EDk06KBIN6cb6MypC9vEoF2hozN0hDIUPX3e/OLmA== X-Google-Smtp-Source: AGHT+IE8gJfBCSN19TNzAYf6D63MSfJUAmpIj3FFWNcu8jOQB7N4s1n61j2UqLDFUxGnAzXC9yjP X-Received: by 2002:a50:f602:0:b0:579:e6d1:d38b with SMTP id 4fb4d7f45d1cf-579e6d2c179mr312041a12.2.1716820257927; Mon, 27 May 2024 07:30:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716820257; cv=pass; d=google.com; s=arc-20160816; b=mxCoX8HXWCn6TU3ho7BnB+ZyUOb/i6IDz/Bgxgt+QS0EZSzhq/1lquewVRX239hZnY vl4s1+bwHwtHknaM1EPxqQxmFPWZgL+86JYfgfsY0hdL/hqo4tiLZ8BtU3Q4erutU/rR 25eBJvX5dxXzp6skSFaJZpqClB9PPwcScM5IRyE4VngWitiH9TLIS93oSf0Y3q7E360y bfmqokFwLfaVinxfBMxhrwfEzMr4BL6lh0p3dj5Nl+YxkgcJHnYiJKcJAU71zzCGKf6X Q2HvAOUW+g5Gy1FgxG1v4+HMhyolSQCInb/R8K4kw9MkDSzs7/UJh4qadYrZV19TCCBI EqYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SbTIqy5x9nb6syp1qvwJ22ERfD/JVcGaF5CsM09QTwI=; fh=GKkSouR7WmbNylUxAWsMo7i47QGtSEwsHe+GG/y4N4Q=; b=dabjGLLzaSEzdUf7BGORQwmQAaswxuicHE/I5ZqxnlU78sZ4oiDqpR43JAxtLKS3n4 GN3znobif7wkPlg+Hqgz3QCh00lgkOz55jXYrYG13bCDQ0K3SSoVb9Mw+eVjcDU+nEw2 HgvnkGHo8I6CoKCIM7OqVNMK0NdrApZn1cN0KU7S18rIQjQYQ+BDVFn7DHmacqVTs1gJ O9uirCWEtDJVFADdoeE7S0OlYpJTlQDNhBxlJhnUgccrzXlI2kOdWFKRDX/UcAbpmyyA 8M0XR7WenJxQK4ED4BlnKSRvMLGL2egNjV6F/XbnYcC15hCqUKvuR+XmqDK43dNry8jG HGkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g3aZnc4d; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190865-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-578679a1fcfsi2995010a12.518.2024.05.27.07.30.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:30:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g3aZnc4d; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190865-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190865-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 117591F24C10 for ; Mon, 27 May 2024 14:29:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9596A180A7B; Mon, 27 May 2024 14:15:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g3aZnc4d" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A52C31802D7; Mon, 27 May 2024 14:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819316; cv=none; b=dz7SS5KZKiL8QzJS5rI42mp6YLeybcfzqDgbNbIib4rFGZv/auAet5pe0rjvzIwhw2VW59VEsFKz2Kgsl7B4B9KeUfRbDFn3NnRBlCFUNbHF7MfA88cibYpX3NFrRARxLlZOaYglMUyWezXE9GuSDdzqbNeh9qO4obdsCPyUwbc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819316; c=relaxed/simple; bh=gSlwN5js8MlJT3Vc2y1GjcwiAoMKOVUoZeb6E/zARnE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q7ymf7yLYlie9wjIlkM5yv41pyt0qc3WWKTs4C5CyTRApLxCSEadVn2mx0vQEOd/tBFwiaz5/QUPt81PffQTB+YPhlwR/E1XtmZrkuG9h4QRw/vWTYwCoVtNzeKlyout1IEDIF9loAbDDfGipS4JL3tZw4DgkXNS66wVFcVcYEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g3aZnc4d; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54F7BC32781; Mon, 27 May 2024 14:15:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819316; bh=gSlwN5js8MlJT3Vc2y1GjcwiAoMKOVUoZeb6E/zARnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g3aZnc4dsSmYCcH78Cj9sf1mpEfAUYze8K2k3I4ppI4FlcCicOWOD1f0uipUONxb9 0v2k8nw7rJelQ196dQWySnJ4xMC9BYvv+k0J9E5PA5wgCx0JA5MyKrRsDkUS9P21yG p89SyoQ0B3BUJt5uHpkDnj4XbLpcCoOqwslete5bd3RSRI2wWR+9pZcsbX9zUV4zDH XUuXZMQX86izSuW0H0Gt/eWWOAcuEpX+00kXPyjdC3AP9xZHexD3cOuTJYPizYs5Ug 9xwOY9e7XaQHlG3O6vSkxfmC4K/ECvOB+b65OXeceKZbbmRT/iHMHcVM/RH8tyUPuf F96DoWgK5TCgQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Luke D. Jones" , Jiri Kosina , Sasha Levin , jikos@kernel.org, bentiss@kernel.org, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 6.8 25/30] HID: asus: fix more n-key report descriptors if n-key quirked Date: Mon, 27 May 2024 10:13:34 -0400 Message-ID: <20240527141406.3852821-25-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527141406.3852821-1-sashal@kernel.org> References: <20240527141406.3852821-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.11 Content-Transfer-Encoding: 8bit From: "Luke D. Jones" [ Upstream commit 59d2f5b7392e988a391e6924e177c1a68d50223d ] Adjusts the report descriptor for N-Key devices to make the output count 0x01 which completely avoids the need for a block of filtering. Signed-off-by: Luke D. Jones Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-asus.c | 51 ++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 78cdfb8b9a7ae..d6d8a028623a7 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -335,36 +335,20 @@ static int asus_raw_event(struct hid_device *hdev, if (drvdata->quirks & QUIRK_MEDION_E1239T) return asus_e1239t_event(drvdata, data, size); - if (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) { + /* + * Skip these report ID, the device emits a continuous stream associated + * with the AURA mode it is in which looks like an 'echo'. + */ + if (report->id == FEATURE_KBD_LED_REPORT_ID1 || report->id == FEATURE_KBD_LED_REPORT_ID2) + return -1; + if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) { /* - * Skip these report ID, the device emits a continuous stream associated - * with the AURA mode it is in which looks like an 'echo'. + * G713 and G733 send these codes on some keypresses, depending on + * the key pressed it can trigger a shutdown event if not caught. */ - if (report->id == FEATURE_KBD_LED_REPORT_ID1 || - report->id == FEATURE_KBD_LED_REPORT_ID2) { + if (data[0] == 0x02 && data[1] == 0x30) { return -1; - /* Additional report filtering */ - } else if (report->id == FEATURE_KBD_REPORT_ID) { - /* - * G14 and G15 send these codes on some keypresses with no - * discernable reason for doing so. We'll filter them out to avoid - * unmapped warning messages later. - */ - if (data[1] == 0xea || data[1] == 0xec || data[1] == 0x02 || - data[1] == 0x8a || data[1] == 0x9e) { - return -1; - } } - if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) { - /* - * G713 and G733 send these codes on some keypresses, depending on - * the key pressed it can trigger a shutdown event if not caught. - */ - if(data[0] == 0x02 && data[1] == 0x30) { - return -1; - } - } - } if (drvdata->quirks & QUIRK_ROG_CLAYMORE_II_KEYBOARD) { @@ -1250,6 +1234,19 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, rdesc[205] = 0x01; } + /* match many more n-key devices */ + if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) { + for (int i = 0; i < *rsize + 1; i++) { + /* offset to the count from 0x5a report part always 14 */ + if (rdesc[i] == 0x85 && rdesc[i + 1] == 0x5a && + rdesc[i + 14] == 0x95 && rdesc[i + 15] == 0x05) { + hid_info(hdev, "Fixing up Asus N-Key report descriptor\n"); + rdesc[i + 15] = 0x01; + break; + } + } + } + return rdesc; } @@ -1319,4 +1316,4 @@ static struct hid_driver asus_driver = { }; module_hid_driver(asus_driver); -MODULE_LICENSE("GPL"); \ No newline at end of file +MODULE_LICENSE("GPL"); -- 2.43.0